monsqlize 2.0.4 → 2.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # CHANGELOG
2
2
 
3
- > Summary index — current release details are packaged in [changelogs/v2.0.4.md](./changelogs/v2.0.4.md); historical details live in the repository changelog archive.
4
- > **Last updated**: 2026-06-12
3
+ > Summary index — current release details are packaged in [changelogs/v2.0.6.md](./changelogs/v2.0.6.md); historical details live in the repository changelog archive.
4
+ > **Last updated**: 2026-06-15
5
5
 
6
6
  ---
7
7
 
@@ -9,6 +9,8 @@
9
9
 
10
10
  | Version | Date | Summary | Details |
11
11
  |---------|------|---------|---------|
12
+ | [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
+ | [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) |
12
14
  | [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) |
13
15
  | [v2.0.3](./changelogs/v2.0.3.md) | 2026-06-11 | Patch: v1 compatibility fixes, public stats APIs, standalone docs-site link safety, bilingual docs consistency, and release preflight alignment | [View](./changelogs/v2.0.3.md) |
14
16
  | [v2.0.2](./changelogs/v2.0.2.md) | 2026-06-09 | Patch: direct runtime, optional and development dependencies pinned to exact versions for deterministic consumer installs | [View](./changelogs/v2.0.2.md) |
@@ -447,7 +449,9 @@ const result = await msq.collection('orders').insertOne(dataFromMongoose);
447
449
  changelogs/
448
450
  ├── README.md # 变更文档说明
449
451
  ├── TEMPLATE.md # 变更文档模板
450
- ├── v2.0.4.md # 当前发布详细变更
452
+ ├── v2.0.6.md # 当前发布详细变更
453
+ ├── v2.0.5.md # v2.0.5 详细变更
454
+ ├── v2.0.4.md # v2.0.4 详细变更
451
455
  ├── v2.0.3.md # v2.0.3 详细变更
452
456
  ├── v2.0.2.md # v2.0.2 详细变更
453
457
  ├── v2.0.1.md # v2.0.1 详细变更
@@ -502,7 +506,9 @@ changelogs/
502
506
 
503
507
  ## 相关文档
504
508
 
505
- - [changelogs/v2.0.4.md](./changelogs/v2.0.4.md) - 当前发布详细变更文档
509
+ - [changelogs/v2.0.6.md](./changelogs/v2.0.6.md) - 当前发布详细变更文档
510
+ - [changelogs/v2.0.5.md](./changelogs/v2.0.5.md) - v2.0.5 详细变更文档
511
+ - [changelogs/v2.0.4.md](./changelogs/v2.0.4.md) - v2.0.4 详细变更文档
506
512
  - [changelogs/v2.0.3.md](./changelogs/v2.0.3.md) - v2.0.3 详细变更文档
507
513
  - [changelogs/v2.0.2.md](./changelogs/v2.0.2.md) - v2.0.2 详细变更文档
508
514
  - [changelogs/v2.0.1.md](./changelogs/v2.0.1.md) - v2.0.1 详细变更文档
@@ -511,5 +517,5 @@ changelogs/
511
517
 
512
518
  ---
513
519
 
514
- **最后更新**: 2026-06-12
520
+ **最后更新**: 2026-06-15
515
521
 
package/README.md CHANGED
@@ -518,7 +518,7 @@ npm run test:real-env:private
518
518
 
519
519
  ## Release Status
520
520
 
521
- The current published release is `v2.0.4`.
521
+ The current release train targets `v2.0.6`.
522
522
 
523
523
  Key release-readiness points:
524
524
 
@@ -526,11 +526,17 @@ Key release-readiness points:
526
526
  - Package exports are consolidated under `dist/cjs`, `dist/esm`, and `dist/types`.
527
527
  - 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`.
528
528
  - v1 smooth-upgrade compatibility has been validated against the target workspace consumers.
529
- - `schema-dsl` follows the npm `latest` TypeScript line `schema-dsl@2.0.9`; deprecated `2.3.x` mistake releases are intentionally excluded.
529
+ - `schema-dsl` follows the npm `latest` TypeScript line `schema-dsl@2.0.11`; deprecated `2.3.x` mistake releases are intentionally excluded.
530
530
  - 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.
531
531
 
532
532
  ## Roadmap
533
533
 
534
+ ### v2.0.6
535
+
536
+ - Dependency alignment to `schema-dsl@2.0.11`, carrying the shared ESM/CJS custom type registry fix to downstream vext applications.
537
+ - NodeNext declaration compatibility for ESM consumers through generated `*.d.mts` mirrors and import-side `types` conditions.
538
+ - Restored v1-compatible root option type exports.
539
+
534
540
  ### v2.0.4
535
541
 
536
542
  - Production-safe Model index rollout controls with `autoIndex`, dry-run preflight, conflict reporting, and explicit `ensureIndexes()` / `ensureModelIndexes()` APIs.
@@ -0,0 +1,33 @@
1
+ # v2.0.5 — 2026-06-13
2
+
3
+ ## Overview
4
+
5
+ v2.0.5 is a compatibility patch for Model schema validation. It removes the duplicated schema-dsl base-type allowlist from monSQLize and delegates DSL type decisions to schema-dsl, keeping schema-dsl as the single validation DSL authority.
6
+
7
+ ---
8
+
9
+ ## Runtime Fixes
10
+
11
+ - Removed the monSQLize-side schema-dsl base-type allowlist from the Model schema adapter.
12
+ - Delegated schema compilation and unknown-type handling to schema-dsl diagnostics instead of maintaining a second type table.
13
+ - Preserved compatibility for schema-dsl-owned aliases such as `int`, `mixed`, `buffer` and `objectid`.
14
+ - Preserved existing literal business DSL strings such as `datetime` and `admin_login!` through schema-dsl fallback semantics.
15
+
16
+ ## Dependencies
17
+
18
+ - Targets `schema-dsl@2.0.10`, which contains the shared legacy DSL aliases and structured diagnostics used by this patch.
19
+ - Keeps the root `cache-hub@2.2.4` dependency unchanged.
20
+
21
+ ## Compatibility
22
+
23
+ - SemVer: patch release.
24
+ - Breaking changes: none.
25
+ - Existing v2 Model schema declarations continue to validate through the same public Model API.
26
+ - Consumer projects do not need to change source code for the checked schema alias and business-literal paths.
27
+
28
+ ## Validation
29
+
30
+ - `npm run type-check`
31
+ - targeted Model schema validation tests
32
+ - targeted pure-function and branch coverage tests
33
+ - local schema-dsl@2.0.10 compatibility smoke
@@ -0,0 +1,16 @@
1
+ # monSQLize v2.0.6
2
+
3
+ Released: 2026-06-15
4
+
5
+ ## Changes
6
+
7
+ - Upgrade runtime dependency `schema-dsl` from `2.0.10` to `2.0.11`.
8
+ - This keeps monSQLize aligned with the schema-dsl ESM/CJS shared custom type registry fix used by downstream vext applications.
9
+ - Restore v1-compatible root type exports: `FindOptions`, `CountOptions`, `AggregateOptions`, and `DistinctOptions`.
10
+ - Add NodeNext-safe type-only import attributes for ESM `cache-hub` declarations consumed from monSQLize's CommonJS package boundary.
11
+ - Generate ESM declaration mirrors (`*.d.mts`) and point the import-side package `types` condition at `dist/types/index.d.mts`, preserving default import constructability for NodeNext ESM consumers.
12
+
13
+ ## Validation
14
+
15
+ - Dependency-only release; full release preflight should run after `schema-dsl@2.0.11` is available from npm.
16
+ - `npm run type-check`
@@ -320,49 +320,8 @@ try {
320
320
  _schemaValidateFn = mod.validate;
321
321
  } catch {
322
322
  }
323
- var KNOWN_SCHEMA_BASE_TYPES = /* @__PURE__ */ new Set([
324
- "string",
325
- "number",
326
- "boolean",
327
- "integer",
328
- "float",
329
- "int",
330
- "double",
331
- "decimal",
332
- "date",
333
- "objectid",
334
- "uuid",
335
- "email",
336
- "url",
337
- "buffer",
338
- "binary",
339
- "object",
340
- "array",
341
- "any",
342
- "mixed",
343
- "null"
344
- ]);
345
- function _extractBaseType(typeStr) {
346
- const m = typeStr.match(/^[a-zA-Z_]+/);
347
- return m ? m[0].toLowerCase() : "";
348
- }
349
323
  function _makeValidatingDslFn(realDsl) {
350
324
  const validating = function validatingDsl(fields) {
351
- if (fields && typeof fields === "object") {
352
- for (const [field, spec] of Object.entries(fields)) {
353
- if (typeof spec === "string") {
354
- if (spec.includes("|")) {
355
- continue;
356
- }
357
- const base = _extractBaseType(spec);
358
- if (base && !KNOWN_SCHEMA_BASE_TYPES.has(base)) {
359
- throw new TypeError(
360
- `[schema] Invalid type "${base}" in field "${field}". Known types: ${[...KNOWN_SCHEMA_BASE_TYPES].join(", ")}.`
361
- );
362
- }
363
- }
364
- }
365
- }
366
325
  return realDsl(fields);
367
326
  };
368
327
  return validating;
@@ -303,49 +303,8 @@ try {
303
303
  _schemaValidateFn = mod.validate;
304
304
  } catch {
305
305
  }
306
- var KNOWN_SCHEMA_BASE_TYPES = /* @__PURE__ */ new Set([
307
- "string",
308
- "number",
309
- "boolean",
310
- "integer",
311
- "float",
312
- "int",
313
- "double",
314
- "decimal",
315
- "date",
316
- "objectid",
317
- "uuid",
318
- "email",
319
- "url",
320
- "buffer",
321
- "binary",
322
- "object",
323
- "array",
324
- "any",
325
- "mixed",
326
- "null"
327
- ]);
328
- function _extractBaseType(typeStr) {
329
- const m = typeStr.match(/^[a-zA-Z_]+/);
330
- return m ? m[0].toLowerCase() : "";
331
- }
332
306
  function _makeValidatingDslFn(realDsl) {
333
307
  const validating = function validatingDsl(fields) {
334
- if (fields && typeof fields === "object") {
335
- for (const [field, spec] of Object.entries(fields)) {
336
- if (typeof spec === "string") {
337
- if (spec.includes("|")) {
338
- continue;
339
- }
340
- const base = _extractBaseType(spec);
341
- if (base && !KNOWN_SCHEMA_BASE_TYPES.has(base)) {
342
- throw new TypeError(
343
- `[schema] Invalid type "${base}" in field "${field}". Known types: ${[...KNOWN_SCHEMA_BASE_TYPES].join(", ")}.`
344
- );
345
- }
346
- }
347
- }
348
- }
349
308
  return realDsl(fields);
350
309
  };
351
310
  return validating;
@@ -0,0 +1,81 @@
1
+ export type DbType = 'mongodb';
2
+
3
+ export interface ExpressionObject {
4
+ __expr__: string;
5
+ __compiled__: boolean;
6
+ }
7
+
8
+ export type ExpressionFunction = (expression: string) => ExpressionObject;
9
+
10
+ /** Context in which an expression is evaluated. @since v1.0.0 */
11
+ export type ExpressionContext = '$match' | '$project' | '$group' | 'unknown';
12
+
13
+ export interface LoggerLike {
14
+ debug?: (...args: unknown[]) => void;
15
+ info?: (...args: unknown[]) => void;
16
+ warn?: (...args: unknown[]) => void;
17
+ error?: (...args: unknown[]) => void;
18
+ /** Wrap a function execution with a trace ID. @since v1.3.0 */
19
+ withTraceId?: (fn: Function, traceId?: string) => any;
20
+ /** Retrieve the current trace ID. @since v1.3.0 */
21
+ getTraceId?: () => string | null;
22
+ }
23
+
24
+ /** Logger configuration options. @since v1.3.0 */
25
+ export interface LoggerOptions {
26
+ /** Enable structured (JSON) log output. */
27
+ structured?: boolean;
28
+ /** Enable automatic trace ID injection into log entries. */
29
+ enableTraceId?: boolean;
30
+ }
31
+
32
+ export declare const enum ErrorCodes {
33
+ INVALID_ARGUMENT = 'INVALID_ARGUMENT',
34
+ INVALID_COLLECTION_NAME = 'INVALID_COLLECTION_NAME',
35
+ INVALID_DATABASE_NAME = 'INVALID_DATABASE_NAME',
36
+ INVALID_EXPRESSION = 'INVALID_EXPRESSION',
37
+ INVALID_PAGINATION = 'INVALID_PAGINATION',
38
+ INVALID_OPERATION = 'INVALID_OPERATION',
39
+ INVALID_CURSOR = 'INVALID_CURSOR',
40
+ INVALID_CONFIG = 'INVALID_CONFIG',
41
+ INVALID_MODEL_DEFINITION = 'INVALID_MODEL_DEFINITION',
42
+ INVALID_SCHEMA_TYPE = 'INVALID_SCHEMA_TYPE',
43
+ NOT_CONNECTED = 'NOT_CONNECTED',
44
+ NO_POOL_MANAGER = 'NO_POOL_MANAGER',
45
+ POOL_NOT_FOUND = 'POOL_NOT_FOUND',
46
+ MODEL_NOT_DEFINED = 'MODEL_NOT_DEFINED',
47
+ MODEL_ALREADY_EXISTS = 'MODEL_ALREADY_EXISTS',
48
+ MISSING_SCHEMA = 'MISSING_SCHEMA',
49
+ UNSUPPORTED_DATABASE = 'UNSUPPORTED_DATABASE',
50
+ CONNECTION_FAILED = 'CONNECTION_FAILED',
51
+ CONNECTION_CLOSED = 'CONNECTION_CLOSED',
52
+ CONNECTION_TIMEOUT = 'CONNECTION_TIMEOUT',
53
+ OPERATION_TIMEOUT = 'OPERATION_TIMEOUT',
54
+ QUERY_TIMEOUT = 'QUERY_TIMEOUT',
55
+ DATABASE_ERROR = 'DATABASE_ERROR',
56
+ CACHE_UNAVAILABLE = 'CACHE_UNAVAILABLE',
57
+ CACHE_ERROR = 'CACHE_ERROR',
58
+ CACHE_TIMEOUT = 'CACHE_TIMEOUT',
59
+ MANAGEMENT_OPERATION_FAILED = 'MANAGEMENT_OPERATION_FAILED',
60
+ VALIDATION_ERROR = 'VALIDATION_ERROR',
61
+ DOCUMENT_REQUIRED = 'DOCUMENT_REQUIRED',
62
+ DOCUMENTS_REQUIRED = 'DOCUMENTS_REQUIRED',
63
+ DUPLICATE_KEY = 'DUPLICATE_KEY',
64
+ WRITE_ERROR = 'WRITE_ERROR',
65
+ WRITE_CONFLICT = 'WRITE_CONFLICT',
66
+ CURSOR_SORT_MISMATCH = 'CURSOR_SORT_MISMATCH',
67
+ JUMP_TOO_FAR = 'JUMP_TOO_FAR',
68
+ STREAM_NO_JUMP = 'STREAM_NO_JUMP',
69
+ STREAM_NO_TOTALS = 'STREAM_NO_TOTALS',
70
+ STREAM_NO_EXPLAIN = 'STREAM_NO_EXPLAIN',
71
+ MONGODB_ERROR = 'MONGODB_ERROR',
72
+ LOCK_ACQUIRE_FAILED = 'LOCK_ACQUIRE_FAILED',
73
+ LOCK_TIMEOUT = 'LOCK_TIMEOUT',
74
+ }
75
+
76
+ export interface MonSQLizeError extends Error {
77
+ code: string;
78
+ details?: unknown[];
79
+ cause?: Error;
80
+ }
81
+