@adaptivestone/framework 5.0.0-rc.8 → 5.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 CHANGED
@@ -5,6 +5,86 @@ 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] - 2026-06-19
9
+
10
+ First stable release of the **v5** series — a major rewrite. v5 is
11
+ TypeScript-first and ESM-only, replaces Express's hidden router with a
12
+ framework-owned tree-based router, makes validation validator-agnostic via
13
+ [Standard Schema](https://standardschema.dev/), and hardens auth and boot.
14
+
15
+ This section is an upgrade-oriented summary. The granular per-change notes
16
+ (every `[NEW]` / `[FIX]` / `[BREAKING]`) live in the `5.0.0-rc.1` … `5.0.0-rc.9`
17
+ entries below; nothing changed in behavior between rc.9 and this release.
18
+
19
+ ### Highlights
20
+
21
+ - **Full TypeScript support, including Mongoose models.** New `BaseModel`
22
+ statics-based model type; per-controller route/handler type generation
23
+ (`npm run gen` → `<File>.routes.gen.ts` + `genTypes.d.ts`) so handler
24
+ signatures, `req.appInfo`, `params`, and `query` are typed from the real
25
+ resolved middleware chain. Typed `getConfig` / `getModel`.
26
+ - **Tree-based router.** A framework-owned `RouteRegistry` replaces Express's
27
+ internal router: structural specificity (static > param > splat), per-segment
28
+ URL decoding, `405` + `Allow`, `400` on malformed paths, HEAD→GET fallback,
29
+ and a boot-time route-tree log. Walkable by codegen / future emitters.
30
+ - **Standard Schema validation.** Yup ≥1.7, Zod, Valibot, and ArkType work out
31
+ of the box; pluggable `ValidatorDriver` + `ValidateService.register()`;
32
+ framework-owned `ValidationError` with structured `.issues`.
33
+ - **Security hardening.** Random, SHA-256-hashed session / recovery /
34
+ verification tokens with enforced expiry; per-user-salt versioned scrypt
35
+ password scheme; standard security headers on by default; account-enumeration
36
+ oracles closed; credentials no longer written to logs.
37
+ - **Robust lifecycle.** Graceful shutdown on `SIGTERM`/`SIGINT` (drains
38
+ in-flight requests, tears down mongo/redis/logger); fail-fast boot (Mongo and
39
+ `AUTH_SALT` required); crash-loop protection for clustered workers.
40
+ - **Runtime.** ESM-only, Node ≥ 24, runs `.ts` sources natively with no build
41
+ step. New helpers/models: `AppInstance`, `Lock`, `i18nService`, `IpDetector`,
42
+ and test helpers (`getTestServerURL`, `serverInstance`).
43
+
44
+ ### Breaking changes (v4 → v5)
45
+
46
+ Read the `5.0.0-rc.1` entry below for the full text and migration notes; the
47
+ condensed list:
48
+
49
+ - **Runtime & deps:** Node ≥ 24, ESM-only (no CommonJS); Express 5, Mongoose 9,
50
+ Vitest 4, i18next 24, `@redis/client` v6 (RESP3 default). Jest support and
51
+ `minimist` CLI parsing removed.
52
+ - **Validation:** Yup is now an **optional peer dependency** (validator-agnostic
53
+ Standard Schema). Legacy `{validate, cast}` validators, internal driver
54
+ classes, and Yup `req:` context in `.test()`/`.when()` removed; `ValidateService`
55
+ surface trimmed; `relatedRequest/QueryParameters` default to `null`.
56
+ - **Routing:** path syntax narrowed to literals, `:name`, and `{*name}` splats —
57
+ Express 5 optional params (`{:name}`) and inline regex are unsupported; replace
58
+ bare `_` route params with `*splat`. Route-type codegen requires statically
59
+ analyzable controllers. OpenAPI/documentation generation removed (returns later
60
+ with per-vendor `toJsonSchema`).
61
+ - **Models & auth:** all models must extend `BaseModel`. `AUTH_SALT` is required
62
+ (no default) and Mongo is required at boot. Default auth response changed to
63
+ `{ data: { token, user } }`. On upgrade, **all existing sessions and
64
+ recovery/verification links are invalidated** (token hardening); passwords
65
+ migrate silently on next login. `POST /auth/send-recovery-email` and
66
+ `/auth/send-verification` now return a uniform `200` (no account-existence
67
+ oracle) — update any frontend that branched on the old `400`. `RateLimiter`
68
+ now requires `IpDetector` earlier in the chain.
69
+ - **Removed / moved:** the email module moved to
70
+ `@adaptivestone/framework-module-email`; `staticFiles` middleware, `VIEWS`
71
+ folders, and `nodemailer-sendmail-transport` removed. The package `exports` map
72
+ is scoped to the public surface — internal subpaths are no longer importable
73
+ (see "Public API & stability" in the README).
74
+
75
+ ## [5.0.0-rc.9] - 2026-06-15
76
+
77
+ - **[FIX]** Regression in rc.8: a model whose `modelSchema` reuses a pre-built
78
+ mongoose `Schema` instance as a (sub-)document definition (`field: SubSchema`
79
+ or `[SubSchema]` — a standard Mongoose pattern) failed to type-check at every
80
+ `findOne(...)` call site with `TS2615` ("circularly references itself in mapped
81
+ type"). The rc.8 marker-scan (`HasTsOverride`) recursed over `keyof Schema`,
82
+ and a `Schema` instance isn't a constructor, so it wasn't treated as a leaf —
83
+ the scan descended into the instance's self-referential internals
84
+ (`childSchemas`, `options`, `session`, …). `IsLeafFieldDef` now treats a
85
+ `Schema` instance as a leaf (it can carry no `__tsType` marker anyway), so the
86
+ scan stops there. Type-only; a `tsc`-gate fixture pins it.
87
+
8
88
  ## [5.0.0-rc.8] - 2026-06-15
9
89
 
10
90
  - **[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;IACZ,CAAC;IAED,MAAM,KAAK,YAAY;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,OAAe;QAC9B,iBAAiB;IACnB,CAAC;IAED,wDAAwD;IACjD,MAAM,CAAC,UAAU;QACtB,MAAM,MAAM,GAA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AE,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",
4
4
  "description": "Adaptive stone node js framework",
5
5
  "type": "module",
6
6
  "engines": {