monsqlize 2.0.6 → 3.0.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 +11 -5
- package/MIGRATION.md +105 -0
- package/README.md +183 -195
- 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 +97 -0
- package/dist/cjs/cli/data-task.cjs +17768 -0
- package/dist/cjs/index.cjs +12166 -5505
- package/dist/cjs/transaction/Transaction.cjs +151 -19
- package/dist/cjs/transaction/TransactionManager.cjs +152 -20
- package/dist/esm/index.mjs +12171 -5509
- 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/package.json +26 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
> Summary index — current
|
|
4
|
-
> **Last updated**: 2026-
|
|
3
|
+
> Summary index — current stable v3.0.0 details are in [changelogs/v3.0.0.md](./changelogs/v3.0.0.md); v2.0.7 was never published and remains an audit archive.
|
|
4
|
+
> **Last updated**: 2026-07-14
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
| Version | Date | Summary | Details |
|
|
11
11
|
|---------|------|---------|---------|
|
|
12
|
+
| [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) |
|
|
13
|
+
| [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
14
|
| [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
15
|
| [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
16
|
| [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 +451,9 @@ const result = await msq.collection('orders').insertOne(dataFromMongoose);
|
|
|
449
451
|
changelogs/
|
|
450
452
|
├── README.md # 变更文档说明
|
|
451
453
|
├── TEMPLATE.md # 变更文档模板
|
|
452
|
-
├──
|
|
454
|
+
├── v3.0.0.md # 当前 Major 稳定发布详细变更
|
|
455
|
+
├── v2.0.7.md # 从未发布的历史候选归档
|
|
456
|
+
├── v2.0.6.md # v2.0.6 详细变更
|
|
453
457
|
├── v2.0.5.md # v2.0.5 详细变更
|
|
454
458
|
├── v2.0.4.md # v2.0.4 详细变更
|
|
455
459
|
├── v2.0.3.md # v2.0.3 详细变更
|
|
@@ -506,7 +510,9 @@ changelogs/
|
|
|
506
510
|
|
|
507
511
|
## 相关文档
|
|
508
512
|
|
|
509
|
-
- [changelogs/
|
|
513
|
+
- [changelogs/v3.0.0.md](./changelogs/v3.0.0.md) - 当前 Major 稳定发布详细变更文档
|
|
514
|
+
- [changelogs/v2.0.7.md](./changelogs/v2.0.7.md) - 从未发布的候选归档
|
|
515
|
+
- [changelogs/v2.0.6.md](./changelogs/v2.0.6.md) - v2.0.6 详细变更文档
|
|
510
516
|
- [changelogs/v2.0.5.md](./changelogs/v2.0.5.md) - v2.0.5 详细变更文档
|
|
511
517
|
- [changelogs/v2.0.4.md](./changelogs/v2.0.4.md) - v2.0.4 详细变更文档
|
|
512
518
|
- [changelogs/v2.0.3.md](./changelogs/v2.0.3.md) - v2.0.3 详细变更文档
|
|
@@ -517,5 +523,5 @@ changelogs/
|
|
|
517
523
|
|
|
518
524
|
---
|
|
519
525
|
|
|
520
|
-
**最后更新**: 2026-
|
|
526
|
+
**最后更新**: 2026-07-10
|
|
521
527
|
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
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 v2.0.6 to v3.0.0
|
|
8
|
+
|
|
9
|
+
### 1. Run the release checks before changing production
|
|
10
|
+
|
|
11
|
+
Use Node.js 18 or newer, install v3 in a staging branch, and run your own
|
|
12
|
+
Model, cache, sync, transaction, and data rollout tests. monSQLize v3 pins
|
|
13
|
+
`schema-dsl@2.1.6` and keeps the isolated `schema-dsl/runtime` integration.
|
|
14
|
+
|
|
15
|
+
### 2. Review bounded query and optimistic-locking behavior
|
|
16
|
+
|
|
17
|
+
- `find()` defaults to 500 documents. Configure an explicit safe limit when a
|
|
18
|
+
service previously depended on an unbounded result.
|
|
19
|
+
- Versioned single-document Model writes use optimistic concurrency control and
|
|
20
|
+
may throw `WRITE_CONFLICT` for stale state.
|
|
21
|
+
- Versioned `updateMany()` defaults to `counter`; select `strict` or `off` when
|
|
22
|
+
that better matches the existing write contract.
|
|
23
|
+
- `updateBatch({ upsert: true })` is rejected. Use `upsertOne()` or MongoDB's
|
|
24
|
+
native `updateMany(..., { upsert: true })` according to the required semantics.
|
|
25
|
+
|
|
26
|
+
### 3. Review sync, index, and production guards
|
|
27
|
+
|
|
28
|
+
- Resume-token persistence failures stop Change Stream sync unless a legacy
|
|
29
|
+
best-effort option is selected explicitly.
|
|
30
|
+
- `autoIndex: true` now preflights with `listIndexes()`, creates only missing
|
|
31
|
+
indexes, and reports conflicts. Keep production index rollout reviewed.
|
|
32
|
+
- `production`, `prod`, and `live` all activate production-like safety guards.
|
|
33
|
+
|
|
34
|
+
### 4. Use the new bounded data-task path for release data
|
|
35
|
+
|
|
36
|
+
For selected release data and declared indexes, use
|
|
37
|
+
`dataTasks.preview(job)` followed by `dataTasks.apply(job, { approval })`.
|
|
38
|
+
Production jobs require a durable affected-scope backup directory. This feature
|
|
39
|
+
does not replace schema migrations, full database export/import, or disaster
|
|
40
|
+
recovery. See the data-tasks and production-rollout guides before first use.
|
|
41
|
+
|
|
42
|
+
## Historical v1 to v2 notes
|
|
43
|
+
|
|
44
|
+
The sections below document intentional behavioural and contract changes between
|
|
45
|
+
monSQLize v1.x and v2.x. Most v2 type-level differences from v1 have been
|
|
46
|
+
softened (optional fields, alias keys, permissive callbacks) so that v1
|
|
47
|
+
fixtures and call sites continue to type-check unchanged. The items below
|
|
48
|
+
are the **deliberately tightened** semantics that v2 keeps for safety; v1
|
|
49
|
+
callers in these spots may need code changes.
|
|
50
|
+
|
|
51
|
+
## Tightened semantics retained in v2
|
|
52
|
+
|
|
53
|
+
### 1. `Model.findOne` returns `T | null` (not `T | undefined`)
|
|
54
|
+
|
|
55
|
+
- v1 returned `undefined` when no document matched.
|
|
56
|
+
- v2 returns `null`, matching the underlying MongoDB driver and removing
|
|
57
|
+
the `undefined` vs `null` ambiguity.
|
|
58
|
+
- **Migration**: replace `result === undefined` with `result === null`,
|
|
59
|
+
or use `!result` which works for both.
|
|
60
|
+
|
|
61
|
+
### 2. `ConnectionPoolManager#selectPool()` returns a typed handle
|
|
62
|
+
|
|
63
|
+
- v1 returned an opaque object whose shape was not declared.
|
|
64
|
+
- v2 returns a `PoolHandle` interface with documented fields
|
|
65
|
+
(`name`, `client`, etc.).
|
|
66
|
+
- **Migration**: no source change is required if you only consume fields
|
|
67
|
+
v2 declares. If your v1 code accessed undeclared fields, declare them
|
|
68
|
+
through module augmentation or assert through `as unknown as ...`.
|
|
69
|
+
|
|
70
|
+
### 3. Cache event payloads use `unknown` rather than `any`
|
|
71
|
+
|
|
72
|
+
- The cache `publish()` / subscriber callback payload type is now
|
|
73
|
+
`unknown` instead of `any`, forcing call sites to narrow before use.
|
|
74
|
+
- **Migration**: add a runtime check or a type assertion at the
|
|
75
|
+
consumption point. The wire shape is unchanged.
|
|
76
|
+
|
|
77
|
+
## Type-level compatibility additions (no source change required)
|
|
78
|
+
|
|
79
|
+
For reference, v2 type files were extended with the following alias /
|
|
80
|
+
optional fields so that v1 fixtures and runtime payloads continue to
|
|
81
|
+
type-check; you do **not** need to migrate code for these:
|
|
82
|
+
|
|
83
|
+
- `BatchRetryRecord`: added optional `attempts` (alias of `attempt`) and
|
|
84
|
+
`success?: boolean`. The runtime now also emits both fields on retry
|
|
85
|
+
records to match v1.
|
|
86
|
+
- `FindPageOptions`: added top-level `comment?: string` shortcut that
|
|
87
|
+
mirrors `options.comment`.
|
|
88
|
+
- `SagaContext.get<T = any>`: default generic relaxed from `unknown` to
|
|
89
|
+
`any` to match v1 ergonomics.
|
|
90
|
+
- `SagaResult.sagaId` / `sagaName`: marked optional alongside
|
|
91
|
+
`executionId`.
|
|
92
|
+
- `SagaStats`: aliased v2-only fields
|
|
93
|
+
(`successfulExecutions` / `failedExecutions` / `compensatedExecutions`)
|
|
94
|
+
are optional; `successCount` / `failureCount` / `compensationCount`
|
|
95
|
+
remain the v1 primary fields.
|
|
96
|
+
- `MongoSession.transaction?.state`: re-exposed for v1 callers reading
|
|
97
|
+
`session.transaction?.state`.
|
|
98
|
+
- `SyncConfig.transform`: accepts both v1 single-arg
|
|
99
|
+
`(document) => ...` and v2 `(document, event) => ...` forms.
|
|
100
|
+
- `Lock.released`: marked `readonly` to match v1.
|
|
101
|
+
- `PoolStats`: counter fields are optional to accept v1 fixture shapes.
|
|
102
|
+
|
|
103
|
+
If a previously-undocumented field still does not type-check, please
|
|
104
|
+
file an issue with the v1 reproduction so the public types can be
|
|
105
|
+
extended.
|