@adaptivestone/framework 5.0.0-rc.8 → 5.0.0-rc.9

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
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.0.0-rc.9] - 2026-06-15
9
+
10
+ - **[FIX]** Regression in rc.8: a model whose `modelSchema` reuses a pre-built
11
+ mongoose `Schema` instance as a (sub-)document definition (`field: SubSchema`
12
+ or `[SubSchema]` — a standard Mongoose pattern) failed to type-check at every
13
+ `findOne(...)` call site with `TS2615` ("circularly references itself in mapped
14
+ type"). The rc.8 marker-scan (`HasTsOverride`) recursed over `keyof Schema`,
15
+ and a `Schema` instance isn't a constructor, so it wasn't treated as a leaf —
16
+ the scan descended into the instance's self-referential internals
17
+ (`childSchemas`, `options`, `session`, …). `IsLeafFieldDef` now treats a
18
+ `Schema` instance as a leaf (it can carry no `__tsType` marker anyway), so the
19
+ scan stops there. Type-only; a `tsc`-gate fixture pins it.
20
+
8
21
  ## [5.0.0-rc.8] - 2026-06-15
9
22
 
10
23
  - **[FIX]** Instance methods are now callable on the hydrated document without
@@ -40,17 +40,21 @@ export interface TsTypeOverride<T> {
40
40
  readonly __tsType?: T;
41
41
  }
42
42
  /**
43
- * A leaf field definition — a bare constructor (`String`, `ObjectId`) or a
43
+ * A leaf field definition — a bare constructor (`String`, `ObjectId`), a
44
44
  * `{ type: SomeConstructor, … }` form (String, Number, ObjectId, Date, Map,
45
- * Buffer, …). This mirrors how Mongoose itself decides "leaf field" vs "nested
46
- * schema", so {@link ApplyTsOverrides} recurses only into nested *schemas* (a
47
- * record of field defs) and leaves built-in instances (ObjectId, Date, Map)
48
- * untouched — instead of mapping over their internals, which only bloated the
49
- * displayed type and wasted compile work (it was always a structural no-op).
45
+ * Buffer, …), or a pre-built mongoose `Schema` instance reused as a (sub-)doc
46
+ * definition (`field: SubSchema` / `[SubSchema]`). This mirrors how Mongoose
47
+ * itself decides "leaf field" vs "nested schema", so {@link ApplyTsOverrides}
48
+ * and {@link HasTsOverride} recurse only into nested *schemas* (a record of
49
+ * field defs) and leave built-in instances (ObjectId, Date, Map) and `Schema`
50
+ * instances untouched. The `Schema` case is essential: a `Schema` instance's own
51
+ * type is deeply self-referential (`childSchemas`, `options`, …), so scanning
52
+ * into it triggers a TS2615 circular mapped-type error — and it can carry no
53
+ * `__tsType` marker anyway, so stopping there is always correct.
50
54
  */
51
- type IsLeafFieldDef<S> = S extends abstract new (...args: never) => unknown ? true : S extends {
55
+ type IsLeafFieldDef<S> = S extends Schema ? true : S extends abstract new (...args: never) => unknown ? true : S extends {
52
56
  type: infer Tp;
53
- } ? Tp extends abstract new (...args: never) => unknown ? true : false : false;
57
+ } ? Tp extends Schema ? true : Tp extends abstract new (...args: never) => unknown ? true : false : false;
54
58
  /**
55
59
  * Walk an inferred raw-doc type alongside its schema and replace each field
56
60
  * marked with {@link TsTypeOverride} by the declared override type. Recurses
@@ -1 +1 @@
1
- {"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../../src/modules/BaseModel.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,EAAE,EAAc,MAAM,UAAU,CAAC;AAiOhD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAW,CAAC;AAG7E,gFAAgF;AAChF,MAAM,OAAO,SAAS;IACpB,MAAM,KAAK,WAAW;QACpB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,aAAa;QACtB,OAAO,EAAW,CAAC;IACrB,CAAC;IAED,MAAM,KAAK,oBAAoB;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,aAAa;QACtB,OAAO,EAAE,CAAC;IAC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nB,CAAC;IAED,wDAAwD;IACjD,MAAM,CAAC,UAAU;QACtB,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE;YACnD,GAAG,cAAc;YACjB,GAAI,IAAI,CAAC,aAA+B;YACxC,OAAO,EAAE,IAAI,CAAC,oBAAoB;YAClC,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,QAAQ,EAAE,IAAI,CAAC,aAAa;SAC7B,CAAmC,CAAC;QAErC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEvB,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAClC,IAAI,CAAC,IAAI,EACT,MAAM,CACqB,CAAC;QAE9B,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptivestone/framework",
3
- "version": "5.0.0-rc.8",
3
+ "version": "5.0.0-rc.9",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "type": "module",
6
6
  "engines": {