monsqlize 2.0.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -5
- package/MIGRATION.md +127 -0
- package/README.md +194 -202
- package/SECURITY.md +21 -0
- package/changelogs/README.md +16 -4
- package/changelogs/v2.0.7.md +63 -0
- package/changelogs/v3.0.0.md +99 -0
- package/changelogs/v3.1.0-rc.0.md +23 -0
- package/changelogs/v3.1.0.md +24 -0
- package/dist/cjs/cli/data-task.cjs +380 -0
- package/dist/cjs/index.cjs +12261 -5497
- package/dist/cjs/transaction/Transaction.cjs +151 -19
- package/dist/cjs/transaction/TransactionManager.cjs +152 -20
- package/dist/esm/index.mjs +12265 -5500
- package/dist/types/collection.d.mts +92 -13
- package/dist/types/collection.d.ts +92 -13
- package/dist/types/data-tasks.d.mts +221 -0
- package/dist/types/data-tasks.d.ts +221 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lock.d.mts +7 -4
- package/dist/types/lock.d.ts +7 -4
- package/dist/types/model.d.mts +46 -14
- package/dist/types/model.d.ts +46 -14
- package/dist/types/monsqlize.d.mts +130 -16
- package/dist/types/monsqlize.d.ts +130 -16
- package/dist/types/runtime.d.mts +14 -1
- package/dist/types/runtime.d.ts +14 -1
- package/dist/types/saga.d.mts +11 -6
- package/dist/types/saga.d.ts +11 -6
- package/dist/types/sync.d.mts +47 -1
- package/dist/types/sync.d.ts +47 -1
- package/dist/types/transaction.d.mts +8 -0
- package/dist/types/transaction.d.ts +8 -0
- package/licenses/production-dependencies.json +11 -0
- package/package.json +45 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
> Summary index —
|
|
4
|
-
> **Last updated**: 2026-
|
|
3
|
+
> Summary index — the v3.1.0 stable release details are in [changelogs/v3.1.0.md](./changelogs/v3.1.0.md); the earlier RC note remains an unpublished rehearsal archive.
|
|
4
|
+
> **Last updated**: 2026-07-15
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
| Version | Date | Summary | Details |
|
|
11
11
|
|---------|------|---------|---------|
|
|
12
|
+
| [v3.1.0](./changelogs/v3.1.0.md) | 2026-07-15 | Minor: schema-dsl v3 GA consumption, canonical validation errors, and normalized full-document persistence | [View](./changelogs/v3.1.0.md) |
|
|
13
|
+
| [v3.0.0](./changelogs/v3.0.0.md) | 2026-07-14 | Major: two-instance preview/apply/restore data tasks, write-path policy, runtime-scoped schema DSL, stricter OCC/sync/query contracts, and release recovery controls | [View](./changelogs/v3.0.0.md) |
|
|
14
|
+
| [v2.0.7](./changelogs/v2.0.7.md) | Unpublished | Withdrawn patch candidate; never published and superseded by v3.0.0 | [Archive](./changelogs/v2.0.7.md) |
|
|
12
15
|
| [v2.0.6](./changelogs/v2.0.6.md) | 2026-06-15 | Patch: dependency alignment to `schema-dsl@2.0.11` so downstream frameworks inherit the ESM/CJS shared custom type registry fix | [View](./changelogs/v2.0.6.md) |
|
|
13
16
|
| [v2.0.5](./changelogs/v2.0.5.md) | 2026-06-13 | Patch: Model schema adapter delegates DSL type authority to `schema-dsl@2.0.10`, removing the duplicated monSQLize allowlist while preserving legacy aliases and business literals | [View](./changelogs/v2.0.5.md) |
|
|
14
17
|
| [v2.0.4](./changelogs/v2.0.4.md) | 2026-06-12 | Patch: production-safe Model index rollout controls, `schema-dsl@2.0.9`, capability-index wording cleanup, and documentation home refinements | [View](./changelogs/v2.0.4.md) |
|
|
@@ -449,7 +452,9 @@ const result = await msq.collection('orders').insertOne(dataFromMongoose);
|
|
|
449
452
|
changelogs/
|
|
450
453
|
├── README.md # 变更文档说明
|
|
451
454
|
├── TEMPLATE.md # 变更文档模板
|
|
452
|
-
├──
|
|
455
|
+
├── v3.0.0.md # 当前 Major 稳定发布详细变更
|
|
456
|
+
├── v2.0.7.md # 从未发布的历史候选归档
|
|
457
|
+
├── v2.0.6.md # v2.0.6 详细变更
|
|
453
458
|
├── v2.0.5.md # v2.0.5 详细变更
|
|
454
459
|
├── v2.0.4.md # v2.0.4 详细变更
|
|
455
460
|
├── v2.0.3.md # v2.0.3 详细变更
|
|
@@ -506,7 +511,9 @@ changelogs/
|
|
|
506
511
|
|
|
507
512
|
## 相关文档
|
|
508
513
|
|
|
509
|
-
- [changelogs/
|
|
514
|
+
- [changelogs/v3.0.0.md](./changelogs/v3.0.0.md) - 当前 Major 稳定发布详细变更文档
|
|
515
|
+
- [changelogs/v2.0.7.md](./changelogs/v2.0.7.md) - 从未发布的候选归档
|
|
516
|
+
- [changelogs/v2.0.6.md](./changelogs/v2.0.6.md) - v2.0.6 详细变更文档
|
|
510
517
|
- [changelogs/v2.0.5.md](./changelogs/v2.0.5.md) - v2.0.5 详细变更文档
|
|
511
518
|
- [changelogs/v2.0.4.md](./changelogs/v2.0.4.md) - v2.0.4 详细变更文档
|
|
512
519
|
- [changelogs/v2.0.3.md](./changelogs/v2.0.3.md) - v2.0.3 详细变更文档
|
|
@@ -517,5 +524,5 @@ changelogs/
|
|
|
517
524
|
|
|
518
525
|
---
|
|
519
526
|
|
|
520
|
-
**最后更新**: 2026-
|
|
527
|
+
**最后更新**: 2026-07-10
|
|
521
528
|
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Migration Guide: monSQLize v1/v2 → v3
|
|
2
|
+
|
|
3
|
+
This guide starts with the v2.0.6 to v3.0.0 upgrade path, then retains the
|
|
4
|
+
v1-to-v2 compatibility notes for older applications. Review every tightened
|
|
5
|
+
contract that intersects your application before changing the installed major.
|
|
6
|
+
|
|
7
|
+
## Upgrade from v3.0.0 to v3.1.0
|
|
8
|
+
|
|
9
|
+
monSQLize v3.1 consumes schema-dsl v3 without installing schema-dsl's legacy
|
|
10
|
+
String prototype extensions. Applications that need those extensions must opt
|
|
11
|
+
in through `schema-dsl/compat` or `schema-dsl/register-string`; monSQLize itself
|
|
12
|
+
continues to use the isolated `schema-dsl/runtime` entry and does not require
|
|
13
|
+
them.
|
|
14
|
+
|
|
15
|
+
Successful full-document Model validation now persists schema-dsl's normalized
|
|
16
|
+
`data` for `insertOne`, `insertMany`, `insertBatch`, `replaceOne`,
|
|
17
|
+
`findOneAndReplace`, and hydrated document `save()`. Coerced values and schema
|
|
18
|
+
defaults therefore reach MongoDB. The order is model defaults, before hook,
|
|
19
|
+
schema normalization, timestamps, version, then driver write. Replacement
|
|
20
|
+
writes do not apply model defaults, and `save()` has no new before-hook stage.
|
|
21
|
+
|
|
22
|
+
Validation failures still throw `VALIDATION_ERROR`, and public errors remain
|
|
23
|
+
`{ field, message }`; `field` is mapped from schema-dsl's canonical `path`.
|
|
24
|
+
Update operators and pipelines do not expose a complete final document and are
|
|
25
|
+
not included in normalized-data persistence. If an application relied on
|
|
26
|
+
schema-dsl coercion being discarded before v3.1, review stored value types in a
|
|
27
|
+
staging environment before upgrading.
|
|
28
|
+
|
|
29
|
+
## Upgrade from v2.0.6 to v3.0.0
|
|
30
|
+
|
|
31
|
+
### 1. Run the release checks before changing production
|
|
32
|
+
|
|
33
|
+
Use Node.js 18 or newer, install v3 in a staging branch, and run your own
|
|
34
|
+
Model, cache, sync, transaction, and data rollout tests. monSQLize v3 pins
|
|
35
|
+
`schema-dsl@2.1.6` and keeps the isolated `schema-dsl/runtime` integration.
|
|
36
|
+
|
|
37
|
+
### 2. Review bounded query and optimistic-locking behavior
|
|
38
|
+
|
|
39
|
+
- `find()` defaults to 500 documents. Configure an explicit safe limit when a
|
|
40
|
+
service previously depended on an unbounded result.
|
|
41
|
+
- Versioned single-document Model writes use optimistic concurrency control and
|
|
42
|
+
may throw `WRITE_CONFLICT` for stale state.
|
|
43
|
+
- Versioned `updateMany()` defaults to `counter`; select `strict` or `off` when
|
|
44
|
+
that better matches the existing write contract.
|
|
45
|
+
- `updateBatch({ upsert: true })` is rejected. Use `upsertOne()` or MongoDB's
|
|
46
|
+
native `updateMany(..., { upsert: true })` according to the required semantics.
|
|
47
|
+
|
|
48
|
+
### 3. Review sync, index, and production guards
|
|
49
|
+
|
|
50
|
+
- Resume-token persistence failures stop Change Stream sync unless a legacy
|
|
51
|
+
best-effort option is selected explicitly.
|
|
52
|
+
- `autoIndex: true` now preflights with `listIndexes()`, creates only missing
|
|
53
|
+
indexes, and reports conflicts. Keep production index rollout reviewed.
|
|
54
|
+
- `production`, `prod`, and `live` all activate production-like safety guards.
|
|
55
|
+
|
|
56
|
+
### 4. Use the new bounded data-task path for release data
|
|
57
|
+
|
|
58
|
+
For selected release data and declared indexes, use
|
|
59
|
+
`dataTasks.preview(job)` followed by `dataTasks.apply(job, { approval })`.
|
|
60
|
+
Production jobs require a durable affected-scope backup directory. This feature
|
|
61
|
+
does not replace schema migrations, full database export/import, or disaster
|
|
62
|
+
recovery. See the data-tasks and production-rollout guides before first use.
|
|
63
|
+
|
|
64
|
+
## Historical v1 to v2 notes
|
|
65
|
+
|
|
66
|
+
The sections below document intentional behavioural and contract changes between
|
|
67
|
+
monSQLize v1.x and v2.x. Most v2 type-level differences from v1 have been
|
|
68
|
+
softened (optional fields, alias keys, permissive callbacks) so that v1
|
|
69
|
+
fixtures and call sites continue to type-check unchanged. The items below
|
|
70
|
+
are the **deliberately tightened** semantics that v2 keeps for safety; v1
|
|
71
|
+
callers in these spots may need code changes.
|
|
72
|
+
|
|
73
|
+
## Tightened semantics retained in v2
|
|
74
|
+
|
|
75
|
+
### 1. `Model.findOne` returns `T | null` (not `T | undefined`)
|
|
76
|
+
|
|
77
|
+
- v1 returned `undefined` when no document matched.
|
|
78
|
+
- v2 returns `null`, matching the underlying MongoDB driver and removing
|
|
79
|
+
the `undefined` vs `null` ambiguity.
|
|
80
|
+
- **Migration**: replace `result === undefined` with `result === null`,
|
|
81
|
+
or use `!result` which works for both.
|
|
82
|
+
|
|
83
|
+
### 2. `ConnectionPoolManager#selectPool()` returns a typed handle
|
|
84
|
+
|
|
85
|
+
- v1 returned an opaque object whose shape was not declared.
|
|
86
|
+
- v2 returns a `PoolHandle` interface with documented fields
|
|
87
|
+
(`name`, `client`, etc.).
|
|
88
|
+
- **Migration**: no source change is required if you only consume fields
|
|
89
|
+
v2 declares. If your v1 code accessed undeclared fields, declare them
|
|
90
|
+
through module augmentation or assert through `as unknown as ...`.
|
|
91
|
+
|
|
92
|
+
### 3. Cache event payloads use `unknown` rather than `any`
|
|
93
|
+
|
|
94
|
+
- The cache `publish()` / subscriber callback payload type is now
|
|
95
|
+
`unknown` instead of `any`, forcing call sites to narrow before use.
|
|
96
|
+
- **Migration**: add a runtime check or a type assertion at the
|
|
97
|
+
consumption point. The wire shape is unchanged.
|
|
98
|
+
|
|
99
|
+
## Type-level compatibility additions (no source change required)
|
|
100
|
+
|
|
101
|
+
For reference, v2 type files were extended with the following alias /
|
|
102
|
+
optional fields so that v1 fixtures and runtime payloads continue to
|
|
103
|
+
type-check; you do **not** need to migrate code for these:
|
|
104
|
+
|
|
105
|
+
- `BatchRetryRecord`: added optional `attempts` (alias of `attempt`) and
|
|
106
|
+
`success?: boolean`. The runtime now also emits both fields on retry
|
|
107
|
+
records to match v1.
|
|
108
|
+
- `FindPageOptions`: added top-level `comment?: string` shortcut that
|
|
109
|
+
mirrors `options.comment`.
|
|
110
|
+
- `SagaContext.get<T = any>`: default generic relaxed from `unknown` to
|
|
111
|
+
`any` to match v1 ergonomics.
|
|
112
|
+
- `SagaResult.sagaId` / `sagaName`: marked optional alongside
|
|
113
|
+
`executionId`.
|
|
114
|
+
- `SagaStats`: aliased v2-only fields
|
|
115
|
+
(`successfulExecutions` / `failedExecutions` / `compensatedExecutions`)
|
|
116
|
+
are optional; `successCount` / `failureCount` / `compensationCount`
|
|
117
|
+
remain the v1 primary fields.
|
|
118
|
+
- `MongoSession.transaction?.state`: re-exposed for v1 callers reading
|
|
119
|
+
`session.transaction?.state`.
|
|
120
|
+
- `SyncConfig.transform`: accepts both v1 single-arg
|
|
121
|
+
`(document) => ...` and v2 `(document, event) => ...` forms.
|
|
122
|
+
- `Lock.released`: marked `readonly` to match v1.
|
|
123
|
+
- `PoolStats`: counter fields are optional to accept v1 fixture shapes.
|
|
124
|
+
|
|
125
|
+
If a previously-undocumented field still does not type-check, please
|
|
126
|
+
file an issue with the v1 reproduction so the public types can be
|
|
127
|
+
extended.
|