@adaptivestone/framework 5.5.0 → 5.6.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 +112 -77
- package/README.md +31 -1
- package/dist/controllers/Auth.js +34 -20
- package/dist/controllers/Auth.js.map +1 -1
- package/dist/controllers/index.js +86 -71
- package/dist/controllers/index.js.map +1 -1
- package/dist/models/User.d.ts +22 -9
- package/dist/models/User.js +35 -7
- package/dist/models/User.js.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/services/cache/Cache.js +4 -2
- package/dist/services/cache/Cache.js.map +1 -1
- package/dist/services/cache/drivers/MemoryDriver.js +3 -1
- package/dist/services/cache/drivers/MemoryDriver.js.map +1 -1
- package/dist/services/http/middleware/Auth.d.ts +1 -1
- package/dist/services/http/middleware/Auth.js.map +1 -1
- package/dist/services/http/middleware/RateLimiter.js +7 -1
- package/dist/services/http/middleware/RateLimiter.js.map +1 -1
- package/dist/services/http/middleware/Role.d.ts +1 -1
- package/dist/services/http/middleware/Role.js.map +1 -1
- package/dist/services/http/routing/RouteNode.d.ts +4 -3
- package/dist/services/http/routing/match.d.ts +7 -2
- package/dist/services/http/routing/match.js +58 -41
- package/dist/services/http/routing/match.js.map +1 -1
- package/dist/services/i18n/types.d.ts +2 -1
- package/dist/services/validate/ValidateService.d.ts +2 -0
- package/dist/services/validate/ValidateService.js +2 -0
- package/dist/services/validate/ValidateService.js.map +1 -1
- package/dist/services/validate/ValidationError.d.ts +4 -0
- package/dist/services/validate/ValidationError.js +6 -1
- package/dist/services/validate/ValidationError.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [5.6.0] - 2026-10-27
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Code generation now requires `oxc-parser` `^0.156.0`.** Projects that run `npm run gen` should update their optional development peer with `npm i -D oxc-parser@^0.156.0`. Runtime-only consumers do not need it.
|
|
14
|
+
- **Route validators are built at boot, not per request.** Each `params:`, `request:` and `query:` schema (route-level and middleware-declared) resolves its `ValidatorDriver` once when the route is registered. A schema no driver matches now fails `startServer()` with the migration message prefixed by the controller and route (before: a 500 on the first request). Register custom drivers (`ValidateService.register`) before `startServer()`, at module scope as documented — a driver registered inside the `bootHttp` hook no longer reaches already-registered routes.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **A static route no longer hides a `:param` route that has the request's method.** With `GET /events/new` and `DELETE /events/:slug`, `DELETE /events/new` answered 405 (`Allow: GET, HEAD`) instead of reaching the `:slug` route, so a slug equal to a sibling static segment could not be deleted or updated. Matching now skips a static (or `:param`) route that lacks the method and tries the next candidate, as in Express. A 405 is answered only when no route matching the path has the method, and its `Allow` header lists the methods of all of them (`GET, HEAD, DELETE` for `POST /events/new` above). The same applies to `{*splat}` routes, including the empty-rest match (`PUT /files` reaching `PUT /files/{*path}` next to `GET /files`). Static segments still win for the methods they define.
|
|
19
|
+
- **Password recovery and email verification persist in one write.** `recoverPassword` and `verifyUser` used to consume the token in one `save()` and apply the change in a second, so a failing second save (a validator on a customized `User` model, a transient database error) burned the link without resetting the password or verifying the account. `getUserByPasswordRecoveryToken` and `getUserByVerificationToken` take an optional `{ save: false }` that removes the token from the returned document only; the built-in routes use it and save once, so a failed write leaves the same link usable for a retry. The default call still consumes and saves.
|
|
20
|
+
- **A `NaN` cache TTL no longer stores a never-expiring entry.** `cache.getSetValue(key, fn, NaN)` (for example `(expiresAt - Date.now()) / 1000` with an `undefined` expiry) skips the cache like a zero or negative TTL. Before, the memory driver stored the value, never read it as expired, and re-armed its cleanup timer every millisecond.
|
|
21
|
+
- **A per-mount `RateLimiter` `consumeKeyComponents.request` list replaces the configured one.** The middleware parameters were deep-merged with array concatenation, so `[RateLimiter, { consumeKeyComponents: { request: ['phone'] } }]` on top of a config `['email']` keyed on both fields, and `[]` could not turn the component off. Arrays now replace, as in the config loader.
|
|
22
|
+
- **A Mongoose `ValidationError` thrown inside a request schema is no longer answered as a field-error 400.** `ValidationError.isValidationError` also requires the framework's `issues` array, so a validator that calls `Model.validate()` and lets the Mongoose error escape goes through the error-handler registry (its safety net, or a 500) instead of a 400 whose `errors` was Mongoose's message string, which embeds the submitted values.
|
|
23
|
+
- **`getModel` nudges about a plural name once per name** instead of on every call, so a singular model ending in `s` (`Address`, `Status`) no longer warns on every request.
|
|
24
|
+
- **`TranslationFunction` accepts the i18next 26.5 translator.** i18next 26.5 split its `t(key, defaultValue, options?)` signature into two overloads, so assigning an i18next instance or its `t` to `I18nBaseInstance`, `TI18n` or `TranslationFunction` failed to compile (TS2322). `TranslationFunction` makes the same split. Calls are unchanged, and earlier i18next 26 releases still fit.
|
|
25
|
+
|
|
26
|
+
## [5.5.1] - 2026-10-06
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **Code generation now requires `oxc-parser` `^0.153.0`.** Projects that run `npm run gen` should update their optional development peer with `npm i -D oxc-parser@^0.153.0`. Runtime-only consumers do not need it.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **A login racing a password change no longer needs its own catch.** When the stored password changed after the user was read, `user.generateToken()` now rejects with a `BadRequestError` that answers exactly like a wrong password (`400 { message: 'User/password not valid' }`, translated via `auth.errorUPValid`), instead of a raw Mongoose `VersionError` or `DocumentNotFoundError`. A custom login handler that did not catch those answered 500. Code that catches them around `generateToken` should catch `BadRequestError` instead.
|
|
35
|
+
- **Subclasses of `Auth` and `Role` can answer with a response again.** 5.5.0 narrowed their `middleware()` return type to `Promise<void>`, so a subclass returning `res.status(…).json(…)` failed to compile (TS2416). They declare the base `Promise<void | Response>` again.
|
|
36
|
+
|
|
9
37
|
## [5.5.0] - 2026-10-03
|
|
10
38
|
|
|
11
39
|
### Added
|
|
@@ -13,14 +41,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
13
41
|
- **`hashSecret` / `verifySecret` for short codes.** E-mail login, SMS and reset codes are too short for `hashToken`: a leaked SHA-256 of a 6-digit code is reversed in under a second. `hashSecret(code, { purpose })` from `helpers/crypto.js` returns a base64url HMAC-SHA256 keyed from `AUTH_SALT`, so a leaked hash is useless without the secret, and `verifySecret(code, stored, { purpose })` checks a candidate in constant time. `purpose` names the feature; a hash made for one purpose never verifies under another. Rotating `AUTH_SALT` invalidates outstanding codes. Keep `hashToken` for long random tokens and `hashPassword` for passwords.
|
|
14
42
|
- **CORS can expose response headers to browser code.** Browsers hide every response header except a few basic ones from cross-origin JavaScript, so a web app could not read `Retry-After` on a 429. The new `http.corsExposedHeaders` config (and the `exposedHeaders` parameter of the `Cors` middleware) sends `Access-Control-Expose-Headers` on responses to allowed origins. It defaults to `['Retry-After']`; an app that sets its own array replaces the default, so keep `Retry-After` in it.
|
|
15
43
|
- **`HttpError` can carry an error code, a translation key and field errors.** Pass a details object instead of the message: `new ConflictError({ code: 'ALREADY_CONFIRMED', i18nKey: 'accounts.errors.alreadyConfirmed', message: 'Already confirmed.' })` answers `{ error: 'ALREADY_CONFIRMED', message }`, with the message translated from `i18nKey` when the request's locale has it and the English `message` otherwise. The `i18nKey` is never sent to the client, and the English text is used literally (never interpreted as i18next syntax). Field errors go in `errors` (`{ field: 'msg' | ['msg'] }`, or validation issues with `params`) and are answered exactly like request validation: `errors: { field: ['msg'] }`, with i18n-key messages translated. `code`, `i18nKey` and `errors` are optional and readable on the error (`err.code`, `err.i18nKey`, `err.issues`). For a fully custom response, pass `{ message, body }`: `body` is sent as-is, `message` only goes to the log, and `body` cannot be combined with `code`, `i18nKey` or `errors` (TypeScript rejects it; at runtime `body` wins and a one-time warning `ASF_HTTP_ERROR_BODY_MIXED` names the ignored fields). Handlers you register for `HttpError` classes still run first.
|
|
16
|
-
- **Built-in health endpoints.** `GET /health/live` answers `{ status: 'ok' }` whenever the process serves requests, and `GET /health/ready` also pings MongoDB (1 s timeout), answering 200 `{ status: 'ok', checks: { mongo: 'ok' } }` or 503 with `'error'` and no details. Point liveness probes at `/live` and readiness or deploy checks at `/ready`. Set `HEALTH_TOKEN` (`config/health.ts`) to require the token as an `X-Health-Token` header or `?token=` query parameter (for load balancers that cannot send headers); a missing or wrong token gets 401. Successful probes are no longer request-logged; failures are logged at `warn`. The endpoints come from a built-in `Health` controller: add your own `controllers/Health.ts` to extend or replace it. `GET /health` itself stays free, so an existing app route there keeps working.
|
|
44
|
+
- **Built-in health endpoints.** `GET /health/live` answers `{ status: 'ok' }` whenever the process serves requests, and `GET /health/ready` also pings MongoDB (1 s timeout), answering 200 `{ status: 'ok', checks: { mongo: 'ok' } }` or 503 with `'error'` and no details. Point liveness probes at `/live` and readiness or deploy checks at `/ready`. Set `HEALTH_TOKEN` (`config/health.ts`) to require the token as an `X-Health-Token` header or `?token=` query parameter (for load balancers that cannot send headers); a missing or wrong token gets 401. Successful probes are no longer request-logged; failures are logged at `warn`. The endpoints come from a built-in `Health` controller: add your own `controllers/Health.ts` to extend or replace it. `GET /health` itself stays free, so an existing app route there keeps working. An app that already has its own `controllers/Health.ts` replaces the built-in controller, so `/health/live` and `/health/ready` are not served until that class extends the built-in `Health` (from `controllers/Health.js`) and keeps its routes.
|
|
17
45
|
- **`timingSafeEqualStrings(a, b)` compares secrets in constant time.** Exported from `helpers/crypto.js` for tokens, API keys or webhook secrets you check yourself: unlike `===`, its timing reveals neither where the strings differ nor the secret's length.
|
|
18
46
|
- **Log redaction, on by default.** Values of the log fields named in the new `redact` list of `config/log.ts` are replaced with `[REDACTED]` before any transport sees them (console, Sentry and custom transports), at any depth and in any letter case. The default list is `authorization`, `cookie`, `password`, `secret` and `token`, so `logger.info('Code sent', { email, token })` no longer writes the token. Message text is never rewritten, so pass sensitive values as fields rather than inside the message. Your own array replaces the default one, so keep these names when you add yours; `redact: []` turns redaction off. The caller's objects are not modified. The same `redact` setting carries over to the v6 logger.
|
|
19
47
|
- **`createEnv` CLI command.** `npm run cli createEnv` creates `.env` for a fresh clone: it copies `.env.example` and fills its `AUTH_SALT` line with a newly generated secret (or writes just `AUTH_SALT` when there is no example file). It does nothing when `.env` already exists, so it never overwrites secrets and is safe to run before every `dev` start. The secret is written to the file only, never printed or logged.
|
|
20
48
|
- **More framework responses can be translated.** The 404, 405 (`Method not allowed`), 415 (`Unsupported Content-Type`) and malformed-URL 400 texts now go through the request's translator, under `http.notFound`, `http.methodNotAllowed`, `http.unsupportedContentType` (with a `{{types}}` placeholder for the accepted content types) and `http.malformedUrl`. The built-in auth controller's messages also fall back to English when a request has no translator.
|
|
21
49
|
- **Unverified login has an error code.** The 400 for a correct password on an unverified account now carries `error: 'EMAIL_NOT_VERIFIED'`, so clients can branch on the code instead of a flag.
|
|
22
50
|
- **`HttpError` can set response headers.** Pass `headers` in the details object, for example `throw new HttpError(429, { message: 'Too Many Requests', headers: { 'Retry-After': '30' } })`. Your own error handlers can return `headers` next to `status` and `body` too.
|
|
23
|
-
- **Error codes on the role and rate-limit responses.** The `Role` 401 now carries `error: 'AUTH001'` (the same code as the `Auth` 401: the client has to log in), the `Role` 403 carries `error: 'NO_ACCESS'`, and the `RateLimiter` 429 carries `error: 'TOO_MANY_REQUESTS'`.
|
|
51
|
+
- **Error codes on the role and rate-limit responses.** The `Role` 401 now carries `error: 'AUTH001'` (the same code as the `Auth` 401: the client has to log in), the `Role` 403 carries `error: 'NO_ACCESS'`, and the `RateLimiter` 429 carries `error: 'TOO_MANY_REQUESTS'`. These bodies gain an `error` field; messages and status codes are unchanged.
|
|
24
52
|
|
|
25
53
|
### Changed
|
|
26
54
|
|
|
@@ -81,7 +109,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
81
109
|
- **Generated request/query types include middleware validation outputs.** Later required fields replace earlier types; optional fields retain the possibility of an earlier value. Array, scalar, and nullable outputs keep their actual types, and content-type branches remain correlated after middleware validation. Nullish route query schemas are treated as absent.
|
|
82
110
|
- **A single validated request/query output retains its shape.** Arrays, scalars, and null are passed to handlers intact. Multiple validation outputs must be plain objects and keep the existing ordered shallow merge; incompatible combinations now produce a configuration error through the normal 500 handler. Content-type maps likewise require object outputs and add their discriminator without mutating the validator's returned object.
|
|
83
111
|
|
|
84
|
-
- **A schema that turns the `id` virtual off, or defines its own `id` path, no longer gets a phantom `id: string` on its documents.** The hydrated document type intersected `{ id: string }` unconditionally — a leftover from before Mongoose added the virtual to its own inference (9.1, refined in 9.4), which now supplies `id: string` itself and honours both a `schemaOptions` `id: false` and a real `id` field. The forced intersection won over both: with `id: false`, `doc.id` was typed `string` while the runtime value is `undefined`; with `id: { type: Number }`, it was `string` while the runtime value is a number. The intersection is gone, so the document follows the schema in both cases and the default case is unchanged (`doc.id` is still `string`). A custom `id`
|
|
112
|
+
- **A schema that turns the `id` virtual off, or defines its own `id` path, no longer gets a phantom `id: string` on its documents.** The hydrated document type intersected `{ id: string }` unconditionally — a leftover from before Mongoose added the virtual to its own inference (9.1, refined in 9.4), which now supplies `id: string` itself and honours both a `schemaOptions` `id: false` and a real `id` field. The forced intersection won over both: with `id: false`, `doc.id` was typed `string` while the runtime value is `undefined`; with `id: { type: Number }`, it was `string` while the runtime value is a number. The intersection is gone, so the document follows the schema in both cases and the default case is unchanged (`doc.id` is still `string`). A custom `id` _virtual_ is a different matter: it is still intersected with Mongoose's default `id: string`, so one that returns anything other than a string collapses to `never` — declare it as a path or rename it. Type-level only. Pinned by the new `idVirtual.ts` fixture in the model-typing compile gate.
|
|
85
113
|
|
|
86
114
|
- **A single-nested subdocument spelled `field: { type: { … }, _id: false }` no longer carries a phantom `_id` on hydrated documents.** Mongoose disables the generated `_id` for both spellings — the `_id: false` beside `type:` and the one inside it — but the hydrated-type correction unwrapped the `type:` wrapper before checking for the marker, so the sibling spelling kept an `_id: Types.ObjectId` the runtime never sets, while the inside spelling was handled. The marker now survives the unwrap. The raw and lean surfaces were already correct and are unchanged; a subdocument without `_id: false` keeps its generated `_id` as before. Type-level only. Pinned in the `nestedPathIds.ts` fixture, which now covers both spellings on both surfaces.
|
|
87
115
|
|
|
@@ -108,7 +136,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
108
136
|
|
|
109
137
|
### Added
|
|
110
138
|
|
|
111
|
-
- **The test suite is type-checked now — `npm run check:types:tests`.** `tsconfig.json` excludes `src/**/*.test.ts` from the build, so no test file had ever been through `tsc`; a first run surfaced 164 errors. The new `tsconfig.tests.json` extends the build config with the tests included (fixtures stay out — they carry deliberate module augmentations and are already checked in isolation by `ModelTyping.typecheck.test.ts` and `routeTypes.golden.test.ts`), and CI runs it alongside `check:types`. Two things it caught, both silent until now: 20 `it()` calls still used Vitest's `it(name, fn, timeout)` signature, which node:test ignores — every one of those per-test timeouts, up to 240s, had quietly been running under the global 10s cap and is now declared as `it(name, { timeout }, fn)`; and `assertThrowsLike` / `assertRejectsLike` in `tests/assertions.js` matched error
|
|
139
|
+
- **The test suite is type-checked now — `npm run check:types:tests`.** `tsconfig.json` excludes `src/**/*.test.ts` from the build, so no test file had ever been through `tsc`; a first run surfaced 164 errors. The new `tsconfig.tests.json` extends the build config with the tests included (fixtures stay out — they carry deliberate module augmentations and are already checked in isolation by `ModelTyping.typecheck.test.ts` and `routeTypes.golden.test.ts`), and CI runs it alongside `check:types`. Two things it caught, both silent until now: 20 `it()` calls still used Vitest's `it(name, fn, timeout)` signature, which node:test ignores — every one of those per-test timeouts, up to 240s, had quietly been running under the global 10s cap and is now declared as `it(name, { timeout }, fn)`; and `assertThrowsLike` / `assertRejectsLike` in `tests/assertions.js` matched error _classes_ at runtime while typing the argument as a plain function, so `assertThrowsLike(fn, MyError)` failed to compile. The parameter now accepts constructors.
|
|
112
140
|
|
|
113
141
|
- **The shipped test bootstrap now accepts project `Server` options, so `bootHttp` runs under test.** `Server` takes exactly two things — `folders` and the `bootHttp` hook — and the test bootstrap passed only the first, hardcoding `new Server({ folders })`. Every project that wires app-wide HTTP behavior in `bootHttp` (error handlers via `registerErrorHandler`, ad-hoc routes, Express middleware) therefore ran its tests against a server that had none of it: a mapped 400 in production showed up as a 500 under test, with nothing reporting the difference. Declare them with `configureTestServer` from `tests/testHelpers.js`, at module scope in the preload that imports the setup glue:
|
|
114
142
|
|
|
@@ -123,23 +151,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
123
151
|
|
|
124
152
|
- **Built-in middleware messages are now translatable — and can no longer leak a raw key.** The six messages the shipped middleware return were hardcoded English with no way for an app to reword or translate them. Each is now emitted with an i18n key **and** the current English text as its in-code default, so responses stay byte-identical unless the app's locale files actually define the key:
|
|
125
153
|
|
|
126
|
-
| Key
|
|
127
|
-
|
|
128
|
-
| `middleware.auth.notLoggedIn`
|
|
129
|
-
| `middleware.role.userRequired`
|
|
130
|
-
| `middleware.role.noAccess`
|
|
131
|
-
| `middleware.rateLimiter.tooManyRequests`
|
|
132
|
-
| `middleware.requestParser.entityTooLarge` | Request entity too large. Your upload exceeds the allowed size or count limits.
|
|
133
|
-
| `middleware.requestParser.parseError`
|
|
154
|
+
| Key | Default (English) |
|
|
155
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
156
|
+
| `middleware.auth.notLoggedIn` | Please login to application |
|
|
157
|
+
| `middleware.role.userRequired` | User should be provided |
|
|
158
|
+
| `middleware.role.noAccess` | You do not have access |
|
|
159
|
+
| `middleware.rateLimiter.tooManyRequests` | Too Many Requests |
|
|
160
|
+
| `middleware.requestParser.entityTooLarge` | Request entity too large. Your upload exceeds the allowed size or count limits. |
|
|
161
|
+
| `middleware.requestParser.parseError` | Error to parse your request. You provided invalid content type or content-length. Please check your request headers and content type. |
|
|
134
162
|
|
|
135
163
|
Nothing is added to the framework's own locale files — the in-code default is the single English source of truth, and a key present in the app's locales always wins, so existing translations keep working unchanged. The default also holds in every degenerate case: i18n disabled (the fallback translator now honours `defaultValue` instead of handing back the key), a request with no i18n at all, or a `t()` that returns a non-string. Custom middleware get the same behavior from the new protected `translate(req, key, defaultValue)` helper on `AbstractMiddleware`. Machine-readable fields are untouched — the auth 401 still carries `error: 'AUTH001'` — and the rate limiter's 500 `RateLimiter error` stays hardcoded, as it reports a misconfigured limiter to operators rather than something the caller can act on. With `saveMissing: true` in `config/i18n.ts`, a request that hits one of these messages writes the English default into `<lng>/translation.missing.json`, giving translators a ready-made starter file.
|
|
136
164
|
|
|
137
165
|
- **The 404 and 500 fallback responses joined the translatable set.** `HttpServer`'s two sinks — the 404 for a path no route matched, and the generic 500 that finalizes an unhandled error — answered with hardcoded JSON. Both now emit an i18n key with the current English text as its in-code default, exactly like the middleware messages above:
|
|
138
166
|
|
|
139
|
-
| Key
|
|
140
|
-
|
|
141
|
-
| `http.notFound`
|
|
142
|
-
| `http.serverError` | Something broke!
|
|
167
|
+
| Key | Default (English) |
|
|
168
|
+
| ------------------ | ----------------- |
|
|
169
|
+
| `http.notFound` | 404 |
|
|
170
|
+
| `http.serverError` | Something broke! |
|
|
143
171
|
|
|
144
172
|
Same semantics: nothing is added to the framework's locale files, a key present in the app's locales wins, and the English default holds when i18n is disabled, when the request carries no i18n at all, or when `t()` returns a non-string — so untranslated responses stay byte-identical. Status codes are untouched, as is the guard that hands a 500 arriving after the response already started to Express's own finalizer.
|
|
145
173
|
|
|
@@ -151,32 +179,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
151
179
|
|
|
152
180
|
- **Behavior change — a framework message whose key is missing now falls back to English instead of leaking the raw key, and `i18next` is optional.** The built-in auth controller, its request validation and the shipped email templates emitted bare i18n keys with no default, so an app whose locale files did not carry the key answered with `auth.messageSome` or `email.registered` in place of a sentence — the example project copied 3 of 26 keys and hit exactly that. Every framework-emitted key now travels with its current English text as an in-code `defaultValue` (validation issues carry it in `params`, which `ValidateService` already forwards to `t()`), so a key present in your locales still wins and existing translations are byte-identical, while a miss reads as English:
|
|
153
181
|
|
|
154
|
-
| Key
|
|
155
|
-
|
|
156
|
-
| `auth.emailProvided`
|
|
157
|
-
| `auth.emailValid`
|
|
158
|
-
| `auth.passwordProvided`
|
|
159
|
-
| `auth.passwordValid`
|
|
160
|
-
| `auth.passwordRecoveryTokenProvided` | Password recovery token must be provided
|
|
161
|
-
| `auth.nickNameValid`
|
|
162
|
-
| `auth.nameValid`
|
|
163
|
-
| `auth.errorUPValid`
|
|
164
|
-
| `auth.nicknameExists`
|
|
165
|
-
| `auth.recoveryEmailSent`
|
|
166
|
-
| `auth.verificationEmailSent`
|
|
167
|
-
| `email.notVerified`
|
|
168
|
-
| `email.registered`
|
|
169
|
-
| `email.alreadyVerifiedOrWrongToken`
|
|
170
|
-
| `email.passwordRecovery`
|
|
171
|
-
| `email.passwordChanged`
|
|
172
|
-
| `email.greeating`
|
|
173
|
-
| `password.wrongToken`
|
|
182
|
+
| Key | Default (English) |
|
|
183
|
+
| ------------------------------------ | -------------------------------------------------------------------------- |
|
|
184
|
+
| `auth.emailProvided` | Email must be provided |
|
|
185
|
+
| `auth.emailValid` | Email is not valid |
|
|
186
|
+
| `auth.passwordProvided` | Password must be provided |
|
|
187
|
+
| `auth.passwordValid` | Password is not valid,only a-z,A-Z,0-9,!,@,#,$,%,ˆ,&,*,(,),_,+,{,},[,],<,> |
|
|
188
|
+
| `auth.passwordRecoveryTokenProvided` | Password recovery token must be provided |
|
|
189
|
+
| `auth.nickNameValid` | Nick name is not valid,only a-z,A-Z,0-9 |
|
|
190
|
+
| `auth.nameValid` | Name is not valid |
|
|
191
|
+
| `auth.errorUPValid` | User/password not valid |
|
|
192
|
+
| `auth.nicknameExists` | User with such nickname already exists |
|
|
193
|
+
| `auth.recoveryEmailSent` | If an account exists for this address, a recovery email has been sent. |
|
|
194
|
+
| `auth.verificationEmailSent` | If an account exists for this address, a verification email has been sent. |
|
|
195
|
+
| `email.notVerified` | Your email is not verified |
|
|
196
|
+
| `email.registered` | User with such an email already registered |
|
|
197
|
+
| `email.alreadyVerifiedOrWrongToken` | Your email is already verified or your verification token is wrong |
|
|
198
|
+
| `email.passwordRecovery` | Recovery password |
|
|
199
|
+
| `email.passwordChanged` | Password changed |
|
|
200
|
+
| `email.greeating` | Dear user |
|
|
201
|
+
| `password.wrongToken` | Password recovery token is not valid |
|
|
174
202
|
|
|
175
203
|
`password.wrongToken` is the one message that never had a catalog entry at all — a wrong recovery token answered with the literal string `password.wrongToken` — so its English text is new. The in-code default is now the single English source of truth: the keys above were removed from the framework's `en/translation.json` (what remains there has no emit site in the framework, so nothing covers it), and `ru/translation.json` still ships in full and still wins for `ru` requests.
|
|
176
204
|
|
|
177
205
|
`i18next` and `i18next-fs-backend` move from dependencies to **optional peer dependencies**, the treatment `@redis/client`, `yup` and `oxc-parser` already got. **Install both only if you actually translate** (`npm i i18next i18next-fs-backend`); the default `i18n.enabled: true` no longer implies they are present. They are still imported lazily and only when i18n is enabled, so a fresh install serves every framework message in English with no translation engine at all; the first request that needs a translator logs one warning — naming both packages and the `enabled` flag — and then falls back for the rest of the process, rather than repeating per request or failing the request. `getI18nBaseInstance()` (the raw i18next instance) still rejects with that message for callers that require the real thing. Consumers who type-check with `skipLibCheck: false` will see `Cannot find module 'i18next'` reported inside the framework's `.d.ts` files if the package is absent — the same trade-off the other optional peers already carry; keep `skipLibCheck: true` (what the project template ships) or install the packages.
|
|
178
206
|
|
|
179
|
-
- **The shipped email templates are now JavaScript template modules, and the built-in auth mails require `@adaptivestone/framework-module-email` >= 2.1.** `recovery` and `verification` shipped as `.pug` files, which rendered only because the email module used to bundle Pug; v2 dropped every bundled engine, so on module v2 an app that triggered password recovery or email verification without registering a Pug engine got a render failure instead of a mail. Each template file is now a small module whose default export turns the render data into the rendered string — `html`, `subject` and `text` per template folder — which module 2.1 renders with its built-in module engine. `tsc` compiles them into `dist`, and `postbuild` no longer copies `src/services/messaging` wholesale: the email module picks its renderer from the on-disk extension, so a raw `.ts` sitting next to the compiled `.js` could be handed to a consumer that cannot run it. A published template folder now holds compiled `.js` only, which the packaging smoke test asserts and renders. `folders.emails` overrides are unchanged — an app still points at its own folder and ships `.ts` (run natively), `.js` (compiled) or any extension it registers an engine for. The `peerDependencies` range narrows from `^1.0.0 || ^2.0.0` to `^2.1.0` to match: **an older module renders the new defaults as an unknown-extension error, exactly the failure the `.pug` defaults already produced there, so no working setup regresses.** The module stays an
|
|
207
|
+
- **The shipped email templates are now JavaScript template modules, and the built-in auth mails require `@adaptivestone/framework-module-email` >= 2.1.** `recovery` and `verification` shipped as `.pug` files, which rendered only because the email module used to bundle Pug; v2 dropped every bundled engine, so on module v2 an app that triggered password recovery or email verification without registering a Pug engine got a render failure instead of a mail. Each template file is now a small module whose default export turns the render data into the rendered string — `html`, `subject` and `text` per template folder — which module 2.1 renders with its built-in module engine. `tsc` compiles them into `dist`, and `postbuild` no longer copies `src/services/messaging` wholesale: the email module picks its renderer from the on-disk extension, so a raw `.ts` sitting next to the compiled `.js` could be handed to a consumer that cannot run it. A published template folder now holds compiled `.js` only, which the packaging smoke test asserts and renders. `folders.emails` overrides are unchanged — an app still points at its own folder and ships `.ts` (run natively), `.js` (compiled) or any extension it registers an engine for. The `peerDependencies` range narrows from `^1.0.0 || ^2.0.0` to `^2.1.0` to match: **an older module renders the new defaults as an unknown-extension error, exactly the failure the `.pug` defaults already produced there, so no working setup regresses.** The module stays an _optional_ peer — an app that never sends the built-in auth mails still needs none of it. The data a template receives is typed by `TEmailTemplateData` (`locale`, `t`, `link`, `editor`, plus anything `globalVariablesToTemplates` adds), which ships compiled in `dist` but is not on the package `exports` map yet.
|
|
180
208
|
|
|
181
209
|
- **The shipped email HTML now declares the language it is written in.** `recovery` and `verification` hardcoded `<html lang="en">` while every sentence inside already followed the request locale, so a Russian mail still announced itself as English to screen readers, mail clients and translation prompts. Both templates now render `lang` from the `locale` the email module passes in — escaped like every other interpolated value — and fall back to `en` when it is absent or empty.
|
|
182
210
|
|
|
@@ -186,12 +214,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
186
214
|
|
|
187
215
|
- **Verification emails were hardcoded Russian.** `verification/{subject,html,text}` carried Russian sentences and not a single `t()` call, so every app sent `Верификаия емейла` to every user whatever their locale — and the HTML greeted `#{username}`, a variable the auth flow never passes, so the greeting rendered empty for everyone. The three templates now mirror `recovery`: English text, every string emitted through `t(key, { defaultValue })` so a key present in your locales wins and a miss reads as English, and the greeting taken from the existing `email.greeating` key instead of a phantom variable.
|
|
188
216
|
|
|
189
|
-
| Key
|
|
190
|
-
|
|
191
|
-
| `email.emailConfirm`
|
|
192
|
-
| `email.verify`
|
|
217
|
+
| Key | Default (English) |
|
|
218
|
+
| -------------------------- | ---------------------------------------------- |
|
|
219
|
+
| `email.emailConfirm` | Email confirmation |
|
|
220
|
+
| `email.verify` | Verify email |
|
|
193
221
|
| `email.verifyInstructions` | To verify your email address, follow the link: |
|
|
194
|
-
| `email.greeating`
|
|
222
|
+
| `email.greeating` | Dear user |
|
|
195
223
|
|
|
196
224
|
`email.emailConfirm` and `email.verify` were already in the locale files with no emit site anywhere; now that they are emitted their English text lives in code like every other framework message, so the two keys were dropped from `en/translation.json`. `ru/translation.json` still wins for `ru` requests and now carries a Russian `email.verifyInstructions` of its own. Values interpolated into the HTML body are escaped, which the template language used to do implicitly.
|
|
197
225
|
|
|
@@ -313,9 +341,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
313
341
|
|
|
314
342
|
- **A non-string body `token` no longer crashes the request with a `500`.** `GetUserByToken` read `req.body.token` and called `.replace()` on it with no type check, and body parsing preserves a JSON number and keeps a repeated form field as an array — so a request carrying `{"token": 123}`, or `token` sent twice as a form field, threw `token.replace is not a function` → `TypeError` → the generic `500` sink, instead of being treated as an unauthenticated request. A non-string token is now treated as **absent**: the middleware falls through to the `Authorization` header (and `postLogout`, which shares the same `GetUserByToken.resolveToken`, treats it as no token and returns `200`). A string token behaves exactly as before.
|
|
315
343
|
|
|
316
|
-
- **Route-type codegen now emits the correct import form for named-export middleware.** The AST resolver classifies each middleware import as `default` or `named` (carrying its original name for an alias), but the emitter discarded that and always rendered a default import (`import type Mw from '…'`). A middleware exported as a **named** export, or a middleware class exported from the controller's own file, therefore produced a `.routes.gen.ts` that either failed to typecheck (`TS2613`: the module has no default export) or silently bound the middleware type to the file's
|
|
344
|
+
- **Route-type codegen now emits the correct import form for named-export middleware.** The AST resolver classifies each middleware import as `default` or `named` (carrying its original name for an alias), but the emitter discarded that and always rendered a default import (`import type Mw from '…'`). A middleware exported as a **named** export, or a middleware class exported from the controller's own file, therefore produced a `.routes.gen.ts` that either failed to typecheck (`TS2613`: the module has no default export) or silently bound the middleware type to the file's _default_ export — a wrong type that surfaced later as a confusing `TS2339` in the handler. The `kind` and original name are now threaded through to emit (via a shared `MiddlewareImport` type), so named and aliased middleware render as `import type { Name } from '…'` / `import type { Orig as Local } from '…'`. Output for default-export middleware — every framework built-in — is byte-identical.
|
|
317
345
|
|
|
318
|
-
- **`Lock.waitForUnlock` no longer races the change stream into an eternal hang.** The change stream opens its server-side cursor lazily on the first `'change'` listener, and its logical start point is fixed only then — but the old code ran the `findOne` existence check
|
|
346
|
+
- **`Lock.waitForUnlock` no longer races the change stream into an eternal hang.** The change stream opens its server-side cursor lazily on the first `'change'` listener, and its logical start point is fixed only then — but the old code ran the `findOne` existence check _before_ attaching the listener, so a `releaseLock` that committed in that window was never observed: the waiter hung forever (or, with `timeoutMs`, surfaced a spurious timeout while the lock was already gone). The `'change'` listener is now attached first, and the code waits for mongoose's forwarded `resumeTokenChanged` signal (which fires only once the stream's start point is fixed) before the authoritative `findOne` re-check — closing the window. The public API is unchanged and no default timeout was added. **Edge note:** on a standalone MongoDB (change streams unsupported — never a working topology for this API), `waitForUnlock` on an absent lock now rejects with the stream error rather than accidentally resolving.
|
|
319
347
|
|
|
320
348
|
- **OpenAPI `operationId`s are now unique and controller-namespaced.** The generator emitted the bare handler name (`getList`) as the `operationId` with no uniqueness guard, so two controllers that both define `getList` — or one handler wired to multiple verbs/paths — produced duplicate ids, which OpenAPI 3.1 forbids: validators (Redocly, Spectral, swagger-cli) reject the document and client generators emit colliding function names. Each `operationId` is now namespaced by its controller (`${controllerName}_${methodName}`, the same derivation already used for `tags`) and de-duplicated against a document-wide set — a residual collision (the same handler on multiple verbs/paths) gets a deterministic verb suffix, then a numeric one. **Behavior change (consumer-visible output):** every emitted `operationId` changes (e.g. `getList` → `Users_getList`); regenerate and re-pin any client SDK or tooling that referenced the old ids.
|
|
321
349
|
|
|
@@ -335,7 +363,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
335
363
|
|
|
336
364
|
- **Controller load order is now a contractual, consistent sort rather than a coincidence of V8's sort internals.** The index-first comparator returned `-1` when `a` was an index file and `0` otherwise — it never returned `1`, so `compare(index, nonIndex)` was `-1` while `compare(nonIndex, index)` was `0`, violating ECMA-262's antisymmetry requirement. Index-first registration (and root `index` before a nested `index`) therefore held only by sort luck, and a V8 sort-strategy change or a longer controller list could have loaded a nested controller before a root index one, shifting middleware accumulation at boot. A new `compareControllerLoadOrder` is antisymmetric and consistent — index files before others, a shallower index before a deeper one — and separator-agnostic (works with `\` paths). Registration order for existing apps is unchanged.
|
|
337
365
|
|
|
338
|
-
- **Route-type codegen no longer truncates non-identifier path-param names, and a literal `*/` in a route path no longer breaks the generated file.** (a) `parsePathParams` matched only `:([a-zA-Z_][a-zA-Z0-9_]*)`, while the runtime router takes the whole segment after `:` — so `'/order/:order-id'` emitted `params: { order: string }` even though the runtime populates `req.params['order-id']`, and `:1st` was dropped entirely; codegen now captures the full segment and quotes any key that isn't a valid identifier (`'order-id': string`). (b) A literal `*/` in a route path (a legal static segment — only a
|
|
366
|
+
- **Route-type codegen no longer truncates non-identifier path-param names, and a literal `*/` in a route path no longer breaks the generated file.** (a) `parsePathParams` matched only `:([a-zA-Z_][a-zA-Z0-9_]*)`, while the runtime router takes the whole segment after `:` — so `'/order/:order-id'` emitted `params: { order: string }` even though the runtime populates `req.params['order-id']`, and `:1st` was dropped entirely; codegen now captures the full segment and quotes any key that isn't a valid identifier (`'order-id': string`). (b) A literal `*/` in a route path (a legal static segment — only a _leading_ `*` is a splat) terminated the generated file's JSDoc comment and broke parsing; the path is now escaped where it's rendered into the comment. Output for normal routes is byte-identical.
|
|
339
367
|
|
|
340
368
|
- **The OpenAPI generator no longer emits duplicate query parameters.** `buildQueryParameters` concatenated the route's own query schema with every middleware's introspectable `relatedQueryParameters` and pushed one parameter per property with no dedup — so a route query key that overlapped a middleware-declared one (e.g. `limit` on both) produced two `{ name: 'limit', in: 'query' }` entries, which OpenAPI 3.1 forbids and validators (Redocly, Spectral, swagger-cli) reject. Parameters are now deduplicated by `(name, in)`, with the route's own schema taking precedence over middleware contributions. A document that had no collision is byte-identical.
|
|
341
369
|
|
|
@@ -345,13 +373,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
345
373
|
|
|
346
374
|
### Fixed
|
|
347
375
|
|
|
348
|
-
- **Route-type codegen emitted an empty middleware chain for sibling param routes with different names.** When two routes on the same controller sat at the same position in the route tree but used param segments with **different** names (e.g. `PUT /:slug` and `POST /:event`), the generated `*.routes.gen.ts` gave the sibling whose param name was
|
|
376
|
+
- **Route-type codegen emitted an empty middleware chain for sibling param routes with different names.** When two routes on the same controller sat at the same position in the route tree but used param segments with **different** names (e.g. `PUT /:slug` and `POST /:event`), the generated `*.routes.gen.ts` gave the sibling whose param name was _not_ registered first an empty `UnionAppInfoProvides<readonly []>` — dropping `req.appInfo.user` (and every other middleware-provided field) from its request type, even though that route runs the controller's full middleware chain at runtime. Root cause: the router keeps a single param child per tree node, so same-depth param siblings collapse onto one node named after the first-registered segment (`:slug`); `flatten()` then reconstructs every sibling's path with that name, while codegen looked each route's chain up by its own **source** path (`:event`) and missed. The middleware-chain lookup is now param-name-insensitive (segment names never affect which node a path resolves to), so all siblings resolve their real chain. **Types-only fix — runtime routing, `req.params` extraction, and middleware execution are unchanged** (they were already correct; only the generated types were wrong).
|
|
349
377
|
|
|
350
378
|
## [5.1.1] - 2026-07-05
|
|
351
379
|
|
|
352
380
|
### Security
|
|
353
381
|
|
|
354
|
-
- **Mongoose validation safety net no longer echoes submitted input.** The safety net (added in 5.1.0) mapped an escaped Mongoose `ValidationError` to `400 { errors: { <path>: message } }` using the **raw** Mongoose message. Those default templates interpolate the rejected value (
|
|
382
|
+
- **Mongoose validation safety net no longer echoes submitted input.** The safety net (added in 5.1.0) mapped an escaped Mongoose `ValidationError` to `400 { errors: { <path>: message } }` using the **raw** Mongoose message. Those default templates interpolate the rejected value (``Path `title` (`<the whole 300-char submission>`) is longer than …``, `Cast to Number failed for value "<PII>" …`), so the offending input — a phone number, a password pasted into the wrong field, any oversized string — rode into both the `400` response body and the `warn`-level log (and thus Sentry). Each per-path message is now **rebuilt from the validation `kind` + the schema constraint only** (`maxlength: 255` → "Must be at most 255 characters", a `Number` cast failure → "Must be a number", an `enum` violation → "Must be one of: …"), and the submitted value is never included, under any kind. The `warn`-level log line for a safety-net-handled error is sanitized the same way — the logged error is rebuilt with those kind-based messages and a fresh, input-free stack — while an error that stays a **500** (internal/renamed paths, or no registry match) still logs the original in full, since that branch is a server-side defect the developer needs complete detail on. This matches the `YupDriver`, which already strips `value`/`originalValue` from route-validation errors. Messages are plain English, not i18n (the route validator owns user-facing wording; this is a last-resort fallback for a route schema that failed to mirror a model constraint). **Trade-off:** a model-defined _custom_ message (`maxlength: [50, 'Name too long']`) is indistinguishable from a templated default that embedded the value, so **all** messages are rebuilt generically — a custom message set on the model is not passed through the safety net. Set user-facing wording on the route `request:`/`query:` schema instead. The `400`/`500` split, the "client actually sent this field" gate, the log levels, and the `{ errors: { path } }` response shape are unchanged.
|
|
355
383
|
|
|
356
384
|
## [5.1.0] - 2026-07-05
|
|
357
385
|
|
|
@@ -367,7 +395,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
367
395
|
- **Cache drivers — `@redis/client` is now optional.** The cache is built on a small `CacheDriver` interface with two first-party drivers: a per-process `MemoryDriver` (new default — needs no external service) and a `RedisDriver` that lazy-imports `@redis/client` only when selected. Choose via `config/cache.ts` (`{ driver: 'memory' | 'redis' }`, or `CACHE_DRIVER` env). A `CacheDriver` instance can be injected directly for a custom backend. The orchestration you rely on — namespacing, in-flight request dedup, JSON/bigint (de)serialization, and fail-soft degradation — is unchanged.
|
|
368
396
|
- **Zero-TTL means "don't cache" (issue #10).** `cache.getSetValue(key, fn, 0)` now skips the cache entirely and recomputes every call, instead of writing a never-expiring entry.
|
|
369
397
|
- **`getAppInstance()` helper.** `helpers/appInstance` now exports a throwing getter alongside the raw `appInstance` binding: it returns the app singleton, or throws a guided error ("construct the Server first"; tests can use `setAppInstance()`/`resetAppInstance()`) when nothing is set. Prefer it in code that may run before the `Server` is constructed (module scope, lazy imports, external modules) — reading the raw binding there fails later with an opaque `TypeError: cannot read properties of undefined` that gives no hint at the cause.
|
|
370
|
-
- **Duplicate-framework-copy diagnostic in the model loader.** When npm fails to dedupe and a model class extends `BaseModel` from a
|
|
398
|
+
- **Duplicate-framework-copy diagnostic in the model loader.** When npm fails to dedupe and a model class extends `BaseModel` from a _different_ installed copy of `@adaptivestone/framework`, `instanceof BaseModel` is false, so the loader used to silently misroute the class into the legacy (`AbstractModel`) branch — surfacing only as a confusing downstream failure. Boot now recognizes the shape (BaseModel's static `initialize` + `modelSchema` surface without the `instanceof`, via the new `isBaseModelSubclassShape` export) and fails with an error naming the model, the cause (duplicate/undeduped install), and the fix (`npm ls @adaptivestone/framework`, then dedupe). Genuinely legacy models still route to the legacy branch unchanged.
|
|
371
399
|
- **Error-handler registry + typed HTTP errors.** Throw `NotFoundError` / `new HttpError(status, message, body?)` (from `services/http/httpErrors.js`) inside a route handler to produce that status (built-in mapper, logged `verbose`), or map error classes you don't own via `app.httpServer.registerErrorHandler(ErrorClass, handler, { logLevel? })` (returns an unregister function) — e.g. from the `bootHttp` hook. Consumer handlers are checked before built-ins; a handler returning `null` passes to the next entry; unmatched errors keep the 500. The Mongoose validation safety net is now a built-in registry entry (semantics unchanged).
|
|
372
400
|
|
|
373
401
|
### Changed
|
|
@@ -430,7 +458,7 @@ Read the `5.0.0-rc.1` entry below for the full text and migration notes; the con
|
|
|
430
458
|
|
|
431
459
|
## [5.0.0-rc.6] - 2026-06-14
|
|
432
460
|
|
|
433
|
-
- **[FIX]** The `User` auth helpers are now reusable on a **customized** `User` model without `this`-binding casts. The statics (`getUserByEmailAndPassword`, `getUserBy{Token,Email,VerificationToken,PasswordRecoveryToken}`) and instance methods (`generateToken`, `getPublic`, `send{Verification,PasswordRecovery}Email`) were typed against the framework's own schema (`this: UserModelLite`), so on a project model with a different shape every call site hit `TS2684` and needed a cast. They're now typed against small structural contracts (`UserAuthDoc` / `UserAuthInstance` / `UserAuthModel`, all newly exported) describing only the fields each helper touches — the framework's `User` and a project's replacement both satisfy them, and return types stay precise. This makes the supported customization paths cast-free: `extends User` to **add** fields, or compose (`extends BaseModel` + spread `User.modelStatics` / `modelInstanceMethods`) to **reshape** them (an i18n `name`, a singular `role`, …) — a field-type
|
|
461
|
+
- **[FIX]** The `User` auth helpers are now reusable on a **customized** `User` model without `this`-binding casts. The statics (`getUserByEmailAndPassword`, `getUserBy{Token,Email,VerificationToken,PasswordRecoveryToken}`) and instance methods (`generateToken`, `getPublic`, `send{Verification,PasswordRecovery}Email`) were typed against the framework's own schema (`this: UserModelLite`), so on a project model with a different shape every call site hit `TS2684` and needed a cast. They're now typed against small structural contracts (`UserAuthDoc` / `UserAuthInstance` / `UserAuthModel`, all newly exported) describing only the fields each helper touches — the framework's `User` and a project's replacement both satisfy them, and return types stay precise. This makes the supported customization paths cast-free: `extends User` to **add** fields, or compose (`extends BaseModel` + spread `User.modelStatics` / `modelInstanceMethods`) to **reshape** them (an i18n `name`, a singular `role`, …) — a field-type _replacement_ can't go through `extends` (static-getter covariance, `TS2417`). Both paths are documented on the `User` class. A `tsc`-gate test pins them.
|
|
434
462
|
|
|
435
463
|
- **[FIX]** Config-type codegen no longer drops env-only keys. A config value read straight from the environment with no default (`saltSecret: process.env.AUTH_SALT`) is `undefined` at gen time, so the value-based pass omitted it from `getConfig('…')`'s type and every read needed an `as` cast. Codegen now reads the config **source** (via `oxc-parser`, no value import) and types a bare `process.env.X` as `string | undefined` (and `process.env.X!` as `string`) — from the source, so the result is the same whether or not the var happened to be set during codegen (deterministic output, no `--check` drift). Keys without an env read (literals, `process.env.X || default`) are still typed from their value as before. Secrets are never serialized (types only). Nested keys and `NODE_ENV`-specific config files are handled.
|
|
436
464
|
|
|
@@ -472,7 +500,7 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
472
500
|
- **[NEW]** Test helpers getTestServerURL and serverInstance.
|
|
473
501
|
- **[NEW]** Rate limiter middleware - add consumeResult function to allow user middleware as a regular rate limiter
|
|
474
502
|
- **[NEW]** Ip detector middleware - add getIpAdressFromIncomingMessage function to allow user middleware as a detector of id adresses without middleware
|
|
475
|
-
- **[NEW]**
|
|
503
|
+
- **[NEW]** Introduce i18nService (ability to user i18n not only inside middleware)
|
|
476
504
|
- **[NEW]** [Standard Schema](https://standardschema.dev/) validation. Yup ≥1.7, Zod, Valibot, ArkType supported.
|
|
477
505
|
- **[NEW]** Pluggable `ValidatorDriver` + `ValidateService.register(driver)` for custom validators.
|
|
478
506
|
- **[NEW]** `StandardSchemaV1.InferOutput<typeof schema>` for compile-time handler types.
|
|
@@ -493,7 +521,7 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
493
521
|
- **[DEPRECATED]** The **instance** form of those getters (`get relatedRequestParameters()` / `relatedQueryParameters` / `relatedReqParameters`) is deprecated and **will be removed in v6** — migrate to the static form. It still works (the framework detects the override, instantiates as a fallback, and emits a one-per-class `DeprecationWarning`, code `ASF_DEP_MW_INSTANCE_SCHEMA`).
|
|
494
522
|
- **[FIX]** `setupVitest.ts` no longer imports framework-internal fixtures. The test-fixture controller (`SomeController`) is now registered inside its own test file via late `controllerManager.registerController()` (the adapter reads the registry live, so registration after `startServer` works). Consumer projects can use `@adaptivestone/framework/tests/setupVitest.js` without `Cannot find module './fixtures/...'` errors. `frameworkVitestSetup.*` is now `.npmignore`'d as framework-only.
|
|
495
523
|
- **[FIX]** Codegen now walks the `extends` chain when resolving middleware import paths. A child controller that inherits `static get middleware()` from its parent class no longer has those middlewares filtered out of its generated chain — codegen scans the parent's source file for the import line and emits the right `import type` in the child's `.routes.gen.ts`. Bare-package ancestors (e.g. a consumer extending the framework's `AbstractController` via `@adaptivestone/framework/modules/...`) are resolved too (since beta.55): codegen reads the installed package file through the importing file's module resolution (honoring the package `exports` map) and rewrites the ancestor's relative middleware imports into bare specifiers the consumer's gen file can resolve — the public subpath tree mirrors `src/`.
|
|
496
|
-
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are emitted as inline **value-shape** types — each config value's structure rendered with value
|
|
524
|
+
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are emitted as inline **value-shape** types — each config value's structure rendered with value _types_ (`string`, `number`), never the literal values and never an `import()` reference. This avoids baking secret values into the generated file and avoids over-narrow literal types, while staying robust: the type is fully inline (no module resolution, so it can't silently degrade to `any` under stricter or preview TypeScript toolchains), and arrays stay **tuples** so per-element patterns like `Object.values(config.list[0])` keep precise types. (Replaces an earlier `typeof import('./config/foo.ts').default` reference form, which inferred array elements as a union with `?: undefined` keys — breaking `Object.values()` — and could resolve to `any` on some compilers.)
|
|
497
525
|
|
|
498
526
|
### Breaking changes (please read carefully)
|
|
499
527
|
|
|
@@ -533,24 +561,24 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
533
561
|
|
|
534
562
|
### Bug Fixes
|
|
535
563
|
|
|
536
|
-
- **[FIX]** Codegen's `extends`-walk now follows the
|
|
564
|
+
- **[FIX]** Codegen's `extends`-walk now follows the _exported_ controller's parent, not the first `class … extends` in the file. A helper or secondary class declared before the controller (e.g. `class Helper extends X` … `export default class Ctrl extends Y`) used to hijack the walk, so middleware inherited from the controller's real parent was silently dropped from the generated `req.appInfo` types. The parent is now resolved from the `export default`/`export class` declaration (falling back to the last `class … extends`).
|
|
537
565
|
- **[FIX]** Codegen's import scanner now parses semicolon-less (ASI) imports. Statements were terminated only at `;` or end-of-file, so under a no-semicolon style (Prettier `semi: false`, StandardJS) consecutive `import` lines collapsed into one and all but the first binding were dropped — quietly losing those middlewares' type narrowing. A statement now also ends at the newline after its specifier string closes; `;`-terminated, multi-line `{ … }`, and side-effect (`import './x'`) imports are unaffected.
|
|
538
566
|
- **[FIX]** The `extends`-walk no longer mistakes a **regex literal** for a class declaration. `parseExtendsParent` scanned the whole file, so a regex such as `/export default class Z extends Wrong/` lexically before the real controller hijacked the walk and dropped the controller's inherited middleware. Regex-literal bodies are now blanked (alongside comments and strings) before the scan.
|
|
539
567
|
- **[FIX]** A controller whose exported class has **no `extends`** (`export default class Ctrl {}`) no longer inherits a helper class's parent. The scan used to fall through to the last `class … extends` in the file — a sibling helper's — and merge its middleware; it now returns "no parent" when the exported class declares none.
|
|
540
568
|
- **[FIX]** A malformed import specifier with a **trailing backslash** (`import X from './a\'`) no longer breaks the generated file or swallows the imports that follow it. Specifiers containing a backslash or a Unicode line separator (U+2028 / U+2029) are now rejected, and the scanner no longer honors `\`-escapes inside a specifier (a real one has none), so the string closes at its quote.
|
|
541
569
|
- **[FIX]** Multi-line import-attributes clauses (`import x from './x.json'` then `with { type: 'json' }` on the next line) no longer end the import prologue early and drop every later import; the clause is folded into the statement.
|
|
542
570
|
- **[FIX]** `req.appInfo.user` is typed as the hydrated **document**, not the Mongoose model class. Codegen's `AppModels` augmentation emitted `User: GetModelTypeFromClass<…>` (the model class) where the runtime assigns `InstanceType<…>`, so after `npm run gen` `user.id` / `user.email` stopped type-checking. The augmentation now wraps the model in `InstanceType<GetModelTypeFromClass<…>>` (while `getModel('User')` correctly keeps returning the class). Verified with a `tsc` probe.
|
|
543
|
-
- **[FIX]** Codegen now skips colocated `.d.ts` / `.gen.d.ts` files when discovering controllers, matching the runtime loader. A capitalized declaration file next to your controllers passed the `.ts`-only filter, reached the AST extractor, parsed as "no controller class," and — since non-analyzable controllers are a hard error — made `npm run gen` throw, blocking route-type generation for
|
|
571
|
+
- **[FIX]** Codegen now skips colocated `.d.ts` / `.gen.d.ts` files when discovering controllers, matching the runtime loader. A capitalized declaration file next to your controllers passed the `.ts`-only filter, reached the AST extractor, parsed as "no controller class," and — since non-analyzable controllers are a hard error — made `npm run gen` throw, blocking route-type generation for _every_ controller.
|
|
544
572
|
- **[FIX]** A non-literal `static get middleware()` in an **ancestor** controller is no longer silently dropped. The `extends`-walk treated "this ancestor builds its middleware Map dynamically" the same as "this ancestor declares no middleware," so it walked past and emitted the child with an empty middleware chain (and `req.appInfo` missing those fields) with no error. It now stops and throws, naming the controller — symmetric with the same getter on the controller itself.
|
|
545
573
|
- **[FIX]** A route entry with no statically identifiable handler — object shorthand (`{ handler }`), an optional-chained handler (`this?.x`), or a spread (`{ ...defaults, handler }`) — now throws instead of silently dropping the route from the generated types.
|
|
546
574
|
- **[FIX]** Codegen's `extends`-walk now also follows the `export { Ctrl as default }` form (including the ES2022 string-literal name `export { Ctrl as "default" }`). Previously only `export default …` was recognized; the `as default` re-export fell through to "last class wins," so a trailing helper class could hijack the walk (wrong `extends` / routes).
|
|
547
|
-
- **[FIX]** Codegen now discovers **`.js` controllers** like the runtime loader does. A plain-JavaScript controller used to be invisible to `npm run gen`: it got no `.routes.gen.ts`, and — since codegen computes cross-controller middleware bleed from all controllers at once — its root-scoped middleware was missing from
|
|
575
|
+
- **[FIX]** Codegen now discovers **`.js` controllers** like the runtime loader does. A plain-JavaScript controller used to be invisible to `npm run gen`: it got no `.routes.gen.ts`, and — since codegen computes cross-controller middleware bleed from all controllers at once — its root-scoped middleware was missing from _other_ controllers' generated `req.appInfo` types. `.js` sources are parsed by the same AST front-end (`.gen.js` / `.test.js` are skipped, mirroring the loader), and the gen file's self-import keeps the controller's real extension.
|
|
548
576
|
- **[FIX]** `RateLimiter` no longer turns a **backing-store outage into a 429 for everyone**. `rate-limiter-flexible` rejects with a `RateLimiterRes` when the limit is hit but with an `Error` when the store (Redis/Mongo) fails; the middleware treated both as "limit hit" and returned `429 Retry-After: 1` on every request during an outage (and logged "Too many requests", misdirecting investigators). Store errors are now distinguished (`instanceof Error`) and **fail open** with an error-level log; the redis/mongo limiters also get a `RateLimiterMemory` **insurance limiter** so brute-force protection degrades to per-process memory instead of vanishing.
|
|
549
577
|
- **[FIX]** `Cache.getSetValue` no longer **deadlocks a key forever** when Redis fails mid-request. The request-coalescing map entry was only cleared on the happy path, so a Redis error after the entry was stored left a permanently-pending promise that every future call for that key awaited — surviving Redis recovery. The whole body is now wrapped so the entry always settles and clears (`finally`); the in-flight promise gets a no-op `.catch` (no `unhandledRejection` when a single caller's `onNotFound` throws), the cache write is best-effort (logged, never fails the request), and an `undefined` result skips the write instead of crashing. A cache **read/connect failure now degrades to computing the value via `onNotFound`** (cache outage ≠ request outage — slow, not broken) rather than throwing; only `onNotFound`'s own errors propagate.
|
|
550
578
|
- **[FIX]** A failed HTTP `listen()` (`EADDRINUSE` / `EACCES`) no longer leaves a **silent zombie process**. The server socket had no `'error'` listener, so a bind failure surfaced as an `uncaughtException` that the global handler only logged — the process kept running, healthy-looking to a supervisor that doesn't probe the port, while serving nothing. The bind error is now caught and the process exits non-zero so a supervisor restarts it with backoff.
|
|
551
|
-
- **[FIX]** Custom (non-console, non-sentry) winston transports now actually load. The constructor check in `#createLogger` was **inverted** — a transport whose default export
|
|
552
|
-
- **[FIX]** Boolean environment variables are no longer coerced backwards. `config/log.ts` read `process.env.LOGGER_SENTRY_ENABLE || false` and `… || true`, but env values are strings — `"false"`/`"0"` are **truthy**, so `LOGGER_SENTRY_ENABLE=false`
|
|
553
|
-
- **[FIX]** The migration runner no longer silently skips **branch-merged migrations**. Pending files were chosen by comparing each filename timestamp against the timestamp of the
|
|
579
|
+
- **[FIX]** Custom (non-console, non-sentry) winston transports now actually load. The constructor check in `#createLogger` was **inverted** — a transport whose default export _is_ the constructor (every normally-published winston transport) failed the guard, got a "not a constructor" log, and was silently dropped; only an unusual CJS double-wrapped shape happened to load. The export is now unwrapped (default export, then the CJS-interop `default.default`) and validated **once** before `new`, and the dynamic `import()` has a `.catch` so a typo'd module name logs a friendly error instead of an unhandled rejection.
|
|
580
|
+
- **[FIX]** Boolean environment variables are no longer coerced backwards. `config/log.ts` read `process.env.LOGGER_SENTRY_ENABLE || false` and `… || true`, but env values are strings — `"false"`/`"0"` are **truthy**, so `LOGGER_SENTRY_ENABLE=false` _enabled_ Sentry and `LOGGER_CONSOLE_ENABLE` could never disable the console. A new `envBool(name, default)` helper (`src/helpers/env.ts`) parses them explicitly (only `"true"`/`"1"` are `true`; unset/empty falls back to the default), and both log flags now use it.
|
|
581
|
+
- **[FIX]** The migration runner no longer silently skips **branch-merged migrations**. Pending files were chosen by comparing each filename timestamp against the timestamp of the _most recently applied_ record — so a migration merged in later but stamped earlier than one already deployed was filtered out and **never ran** (no error, no log). Pending is now a **set difference** against the applied filenames (`distinct('migrationFile')`), so any unapplied file runs regardless of timestamp ordering, executed in filename order (run-then-record preserved). The run is also wrapped in the `Lock` model (`acquireLock('migrations')`) so two simultaneous deploys can't run migrations twice; a run that can't take the lock warns and returns `false`.
|
|
554
582
|
- **[FIX]** `Lock` model correctness. (1) `acquireLock` **steals an expired lock atomically** — `findOneAndUpdate({ _id, expiredAt: { $lt: now } }, …, { upsert: true })` instead of `create`, so a crashed holder's lock is reclaimable immediately rather than after Mongo's TTL-reaper lag (up to ~60s); the unique-`_id` upsert race still yields exactly one winner under contention. (2) `waitForUnlock` registers its change stream **before** re-checking existence (closing a missed-delete window where the promise could hang forever), adds an `'error'` handler (an unhandled stream error — e.g. on a non-replica-set Mongo — would otherwise crash the process), and accepts an optional `timeoutMs`. Locks remain **advisory** — no ownership token, `releaseLock` is unconditional; release only from the flow that acquired it — now documented on the statics.
|
|
555
583
|
- **[FIX]** `RequestParser` (the global multipart/urlencoded/json body parser) now bounds and cleans up file uploads, and normalizes field shapes. **(1) Limits:** it ran on every request with formidable's defaults (~200 MB/file, no total/count cap), so any unauthenticated client could spool large bodies to any path. Conservative limits now come from `config.http.requestParser` (`maxFileSize` 20 MB, `maxTotalFileSize` 50 MB, `maxFiles` 10, `maxFields` 1000, `maxFieldsSize` 2 MB; per-mount params override), and limit-exceeded errors return **413** instead of 400. **(2) Temp-file cleanup:** spooled files were **never deleted** (disk exhaustion over time). Every file formidable opens is now unlinked when the response finishes (`finish`) or aborts (`close`) — a handler that wants to keep an upload must move/copy it before responding. **(3) Field shapes:** multipart/urlencoded fields arrive as arrays while json fields are scalars; a single-value field is now collapsed to a scalar (json untouched, repeated keys stay arrays), fixing consumers like `GetUserByToken` that did `token.replace(...)` and threw a 500 on a urlencoded token.
|
|
556
584
|
- **[DOCS]** The per-route `bodyParsing` option now documents that **only `'parsed'` takes effect** — `'raw'` and `'none'` are reserved for v5.1 and currently do nothing (the parser is mounted globally, so `req.rawBody` is never set and the stream is always consumed). The matcher plumbing for the mode ships in v5; the implementation (parser registry + `req.rawBody`, enabling webhook signature verification) is planned for v5.1. Previously the type/JSDoc advertised `'raw'`/`'none'` as working.
|
|
@@ -572,7 +600,7 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
572
600
|
- **[SECURITY]** Resetting a password (`POST /auth/recover-password`) now revokes all of the user's existing session tokens, so any session created before the reset is invalidated.
|
|
573
601
|
- **[CHANGE]** Removed dead code: the unused `src/views/*.pug` templates (no `pug` dependency), the unread `config.validate.controllerValidationAbortEarly`, the no-op `consoleLogger` level filter, and the debug `console.log` on the prod entrypoint.
|
|
574
602
|
- **[CHANGE]** Added a packaging smoke test (`npm run smoke`, CI workflow `packaging.yml`): packs the tarball, installs it into a throwaway consumer, and verifies the **published dist** — public entry points import (catching broken built-import paths, the cluster-bug class) and internal subpaths stay unexported (the exports map). The TS-source test suite can't see dist-only breakage.
|
|
575
|
-
- **[FIX]** Router static-child lookup is now **O(1)** instead of a per-request linear scan. The tree matcher's `lookupStaticChild` walked every static child of every node on the path with a `toLowerCase()` allocation per child — and since `caseSensitive` is always `false` in production, that scan was the
|
|
603
|
+
- **[FIX]** Router static-child lookup is now **O(1)** instead of a per-request linear scan. The tree matcher's `lookupStaticChild` walked every static child of every node on the path with a `toLowerCase()` allocation per child — and since `caseSensitive` is always `false` in production, that scan was the _only_ path requests took (the O(1) branch was dead). Static children are now keyed by lowercase segment at registration time, so the now-always case-insensitive match is a single `Map.get`. Nodes keep their original-cased `segment` (display / `formatTree` / codegen paths unchanged — gen output byte-identical). Segments differing only by case now fold onto one node (case-insensitive matching already treated them as one); a same-method collision surfaces via the existing conflicting-handler error.
|
|
576
604
|
- **[FIX]** Redis connection helper now caches the **connect promise**, not the bare client. A second concurrent caller could get the client before its `connect()` resolved (double-connect on a half-built socket), a failed first connect cached a dead client forever (no retry), and the synchronous accessor fired `connect()` in an uncaught IIFE (process-level `unhandledRejection` when Redis was down at boot). Concurrent callers now await one connect, a failed connect clears the cache so the next call retries, and the sync accessor logs connection failures instead of crashing.
|
|
577
605
|
|
|
578
606
|
### Internal
|
|
@@ -581,31 +609,34 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
581
609
|
- **[BREAKING]** Route-type codegen requires **statically analyzable controllers**. A controller whose `routes` / `static get middleware()` / `getHttpPath()` is built dynamically (loops, conditionals, computed values) can no longer be reflected — `npm run gen` now throws and names the controller instead of booting the app to read it. Make those getters return literal structures (the framework's own controllers and the audited consumer projects already do).
|
|
582
610
|
|
|
583
611
|
---
|
|
612
|
+
|
|
584
613
|
## [5.0.0-beta.55] - 2026-06-06
|
|
585
614
|
|
|
586
615
|
- **[FIX]** Codegen no longer emits an empty middleware chain for a controller's root (`/`) route. `chainFor` keyed the flattened-route lookup with a trailing slash for a `/` route under a non-root prefix (e.g. `POST /` on a controller mounted at `/file` was looked up as `POST /file/` while `RouteRegistry.flatten()` emits `POST /file`), so the route's middleware came back empty and the generated `req.appInfo` lost every middleware-provided field. Path joining now mirrors the registry (segment join, no trailing slash).
|
|
587
616
|
- **[FIX]** Codegen resolves middleware whose local import binding differs from its exported class name. The emit step matched chain entries against the controller's imports by class name, but the import map is keyed by the local binding — so a default export imported under another name (e.g. `import Auth from '.../Auth.js'` where the class is `AuthMiddleware`) was dropped from the generated type (and would otherwise have emitted an unbound `typeof AuthMiddleware`). The live class is now carried through and matched by module identity to recover the real binding (`Auth`). Affected the built-in `Auth` and `Role` middlewares.
|
|
588
617
|
- **[FIX]** Codegen resolves inherited default middleware through **bare-package** ancestors. A consumer controller relying on `AbstractController`'s default `static get middleware()` (without re-declaring it) extends the framework via a bare specifier (`@adaptivestone/framework/modules/AbstractController.js`); codegen previously skipped such ancestors, leaving the inherited `[GetUserByToken, Auth]` out of the generated `req.appInfo` type. Codegen now resolves the ancestor through the importing file's module resolution (honoring the package `exports` map) and rewrites the ancestor's relative middleware imports into bare specifiers the consumer's gen file can resolve. Re-declaring the middleware Map is no longer required to get typed `appInfo`.
|
|
589
618
|
- **[FIX]** Codegen rebases inherited middleware import paths when the parent controller lives in a **different directory** than the child. The `extends`-chain walk previously emitted the ancestor's relative import paths verbatim — correct only when parent and child share a folder — so a controller inheriting middleware from a parent elsewhere in the tree got a wrong relative path (and the middleware was then silently dropped from the type when the path failed to resolve). Ancestor relative imports are now rebased to the child's gen-file directory.
|
|
590
|
-
- **[NEW]** Golden-fixture codegen test (`src/codegen/routeTypes.golden.test.ts`): runs the real boot-free `generateRouteTypes` over fixture controllers, then `tsc`-checks the generated types against handlers that read `req.appInfo.user` without a guard. String-level assertions can't catch a wrong
|
|
619
|
+
- **[NEW]** Golden-fixture codegen test (`src/codegen/routeTypes.golden.test.ts`): runs the real boot-free `generateRouteTypes` over fixture controllers, then `tsc`-checks the generated types against handlers that read `req.appInfo.user` without a guard. String-level assertions can't catch a wrong _type_ (e.g. an empty `UnionAppInfoProvides<readonly []>`); this gate type-checks the output and would have caught every codegen bug fixed in this release.
|
|
591
620
|
- **[FIX]** `Auth` middleware now narrows `req.appInfo.user` to **required**. `AuthMiddleware` rejects unauthenticated requests at runtime but declared no `provides`, so behind `[GetUserByToken, Auth]` the user stayed optional (`user?`) and every handler needed an `if (!user)` guard purely to satisfy types. It now declares `static get provides()` returning `{ user: InstanceType<TUser> }`; `UnionAppInfoProvides` intersects it with `GetUserByToken`'s optional `user?` and collapses to a required `user`. Type-only — runtime unchanged.
|
|
592
621
|
- **[FIX]** `req.appInfo.user` now follows a project's OWN `User` model when it replaces the framework's, instead of always typing as the framework `User`. `GetUserByToken`/`Auth` resolve the user type through an augmentable `AppModels` interface (exported from `models/User.ts`), and `npm run gen` emits the binding into `genTypes.d.ts` automatically — the same mechanism that already types `app.getModel('User')`. Falls back to the framework `User` when not replaced; no consumer action needed beyond running codegen. (Previously the middleware `provides` hardcoded the framework `User`, so a replaced model's fields were missing from `appInfo.user` even though `getModel('User')` was correct.)
|
|
593
622
|
- **[CHANGE]** Removed the unused `source` field from `MiddlewareEntry` (`services/http/routing`). It was a write-only placeholder that no code read — codegen resolves middleware import paths from controller source instead — so it and its plumbing through `normalizeMiddleware`/`normalizeMiddlewares` are gone. If you constructed `MiddlewareEntry` objects directly (rare), drop the `source` property.
|
|
594
623
|
- **[BREAKING]** The built-in `Home` controller no longer registers `GetUserByToken` on a root-level `'/{*splat}'` scope. Because `Home` mounts at `/`, that middleware landed on the route-tree root and ran on **every request app-wide** — a hidden global default that couldn't be opted out of (a controller declaring empty middleware still ran it). `Home` now adds no middleware (it's a public route); controllers still parse the user token via their own/inherited `[GetUserByToken, Auth]`. **Impact:** if you relied on `req.appInfo.user` being populated on routes that don't themselves include `GetUserByToken` (e.g. ad-hoc `registerRoute` endpoints), add the middleware explicitly. Re-add `[GetUserByToken]` to your home controller for a token-aware home.
|
|
595
624
|
|
|
596
625
|
---
|
|
626
|
+
|
|
597
627
|
## [5.0.0-beta.54] - 2026-06-05
|
|
598
628
|
|
|
599
|
-
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are now inline **value-shape** types (value
|
|
629
|
+
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are now inline **value-shape** types (value _types_ like `string`, with arrays kept as **tuples**) instead of the `typeof import('./config/foo.ts').default` reference form introduced in beta.52. The reference form inferred array config elements as a union with `?: undefined` keys, which broke `Object.values()` over a config item (it widened to `any`) and could resolve to `any` outright on stricter/preview TypeScript (e.g. older `tsgo` builds) — a regression that surfaced only in CI for projects whose local type-checker differed. The value-shape form keeps `Object.values()` and per-element typing precise and is robust across compilers (it resolves no module), while still never serializing a literal config value into the generated file.
|
|
600
630
|
|
|
601
631
|
---
|
|
632
|
+
|
|
602
633
|
## [5.0.0-beta.53] - 2026-06-05
|
|
603
634
|
|
|
604
635
|
- **[NEW]** Codegen reads controllers without running their constructors. `generatetypes` now introspects each controller via a prototype-only "ghost" (`Object.create(Class.prototype)`) instead of `new Controller(app, prefix)`, so config reads, client construction, and other constructor side effects no longer fire during type generation. Runtime is unchanged — handlers still bind to real instances.
|
|
605
636
|
- **[DEPRECATED]** A controller whose `routes` getter reads **constructor-set state** is deprecated. Codegen transparently falls back to instantiating it (so nothing breaks) and emits a one-per-class `DeprecationWarning`, code `ASF_DEP_CTOR_ROUTES`. Make `routes` independent of constructor state; the instantiation fallback **will be removed in v6**.
|
|
606
637
|
- **[FIX]** Model-using CLI commands now wait for the MongoDB connection before running. Previously `#mongooseConnect()` was fire-and-forget, so a CLI command (`isShouldInitModels`) could fire its first query before the connection was established and rely on mongoose's buffer (default 10s `bufferTimeoutMS`) — causing intermittent "buffering timed out" failures on slow connects. Now `initAllModels({ waitForConnection: true })` (used only by model-using CLI commands) blocks until the connection is ready, with explicit progress logs (`Connecting to MongoDB…`, `MongoDB connection established in Nms`, `waiting … → ready after Nms`). Modelless commands (e.g. `generatetypes`) and the HTTP server are unaffected — the server stays lazy (requests buffer until ready).
|
|
607
|
-
---
|
|
608
638
|
|
|
639
|
+
---
|
|
609
640
|
|
|
610
641
|
## [5.0.0-beta.52] - 2026-06-04
|
|
611
642
|
|
|
@@ -613,9 +644,8 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
613
644
|
- **[DEPRECATED]** The **instance** form of those getters (`get relatedRequestParameters()` / `relatedQueryParameters` / `relatedReqParameters`) is deprecated and **will be removed in v6** — migrate to the static form. It still works (the framework detects the override, instantiates as a fallback, and emits a one-per-class `DeprecationWarning`, code `ASF_DEP_MW_INSTANCE_SCHEMA`).
|
|
614
645
|
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are now emitted as references to each config module's type (`typeof import('./config/foo.ts').default`) instead of a serialized snapshot of the resolved runtime value. The old value-based approach had two real problems: env-only fields (e.g. `connectionString: process.env.MONGO_DSN`) **silently vanished** from the type when the env var was unset at gen time (`JSON.stringify` drops `undefined`), and populating the env var to keep them **baked the secret value into the committed file**. Reference-based types keep env-only fields (typed `string | undefined`), never serialize a value, and avoid over-narrow literal types (`port` is `string | number`, not `3300`). _(Superseded in beta.54 — see above.)_
|
|
615
646
|
|
|
616
|
-
|
|
617
|
-
|
|
618
647
|
---
|
|
648
|
+
|
|
619
649
|
## [5.0.0-beta.51] - 2026-05-31
|
|
620
650
|
|
|
621
651
|
- **[NEW]** `KeyValue` model: a minimal persistent key/value store backed by MongoDB for lightweight caching, runtime config, and feature flags.
|
|
@@ -628,17 +658,20 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
628
658
|
- **[DEPRECATED]** `YupFile` (`@adaptivestone/framework/helpers/yup.js`) — removed in v6. Validate files via the new `File` export + your validator's `instanceof` idiom instead.
|
|
629
659
|
|
|
630
660
|
---
|
|
661
|
+
|
|
631
662
|
## [5.0.0-beta.50] - 2026-05-25
|
|
632
663
|
|
|
633
664
|
- **[FIX]** Tree-based router: different HTTP methods at the same param position can now use different `:name` segments. Previously, `PUT /:slug` and `POST /:event` on the same controller would either throw at boot ("conflicting param children") or silently use the first-registered name for all methods (`req.params.event` → `undefined`). Each `HandlerEntry` now carries its own `paramNames` array — the tree is structural only, param naming is per-handler.
|
|
634
665
|
|
|
635
666
|
---
|
|
667
|
+
|
|
636
668
|
## [5.0.0-beta.49] - 2026-05-18
|
|
637
669
|
|
|
638
670
|
- **[FIX]** Codegen: fix router name resolution in generated route types.
|
|
639
671
|
- **[UPDATE]** Codegen output improvements.
|
|
640
672
|
|
|
641
673
|
---
|
|
674
|
+
|
|
642
675
|
## [5.0.0-beta.48] - 2026-05-11
|
|
643
676
|
|
|
644
677
|
- **[NEW]** Codegen emits route metadata (`methodName`, `controllerClass`, `sourceFile`) on `HandlerEntry.meta`.
|
|
@@ -647,12 +680,14 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
647
680
|
- **[NEW]** Codegen deduplicates identical union branches.
|
|
648
681
|
|
|
649
682
|
---
|
|
683
|
+
|
|
650
684
|
## [5.0.0-beta.47] - 2026-05-11
|
|
651
685
|
|
|
652
686
|
- **[UPDATE]** Tree-based route type generation improvements.
|
|
653
687
|
- **[UPDATE]** Dependencies update.
|
|
654
688
|
|
|
655
689
|
---
|
|
690
|
+
|
|
656
691
|
## [5.0.0-beta.46] - 2026-05-11
|
|
657
692
|
|
|
658
693
|
- **[NEW]** Tree-based `RouteRegistry` replaces Express's hidden router internally. One global tree, walkable by codegen / OpenAPI / MCP emitters.
|
|
@@ -671,39 +706,41 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
671
706
|
- **[BREAKING]** OpenAPI / documentation generation removed (will return later).
|
|
672
707
|
|
|
673
708
|
---
|
|
709
|
+
|
|
674
710
|
## [5.0.0-beta.45] - 2026-03-28
|
|
711
|
+
|
|
675
712
|
- **[BREAKING]** rate-limiter-flexible v9->v10
|
|
676
713
|
- **[BREAKING]** typecript v5->v6
|
|
677
714
|
|
|
678
715
|
---
|
|
716
|
+
|
|
679
717
|
## [5.0.0-beta.44] - 2026-02-22
|
|
680
718
|
|
|
681
719
|
- **[NEW]** Logout method
|
|
682
720
|
- **[Update]** set model typing
|
|
683
721
|
|
|
684
|
-
|
|
685
|
-
|
|
686
722
|
---
|
|
723
|
+
|
|
687
724
|
## [5.0.0-beta.43] - 2026-01-24
|
|
688
725
|
|
|
689
726
|
- **[FIX]** Fix typo in peerDeps
|
|
690
727
|
|
|
691
|
-
|
|
692
728
|
---
|
|
729
|
+
|
|
693
730
|
## [5.0.0-beta.42] - 2026-01-24
|
|
694
731
|
|
|
695
732
|
- **[BREAKING]** Mongoose v9. <https://mongoosejs.com/docs/migrating_to_9.html>.
|
|
696
733
|
|
|
697
734
|
---
|
|
735
|
+
|
|
698
736
|
## [5.0.0-beta.41] - 2026-01-17
|
|
699
737
|
|
|
700
738
|
- **[UPDATE]** Update deps
|
|
701
739
|
- **[NEW]** Bearer scheme support
|
|
702
740
|
- **[NEW]** redisConnection helper
|
|
703
741
|
|
|
704
|
-
|
|
705
|
-
|
|
706
742
|
---
|
|
743
|
+
|
|
707
744
|
## [5.0.0-beta.40] - 2025-12-15
|
|
708
745
|
|
|
709
746
|
- **[UPDATE]** Update `rate-limiter-flexible` to v9.
|
|
@@ -712,27 +749,28 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
712
749
|
|
|
713
750
|
## [5.0.0-beta.39] - 2025-10-25
|
|
714
751
|
|
|
715
|
-
- **[UPDATE]**
|
|
752
|
+
- **[UPDATE]** rete limiter. Do not create index on mongo if we have "process.env.test === 'true'"
|
|
716
753
|
|
|
717
754
|
---
|
|
718
755
|
|
|
719
756
|
## [5.0.0-beta.38] - 2025-10-25
|
|
720
757
|
|
|
721
|
-
- **[UPDATE]**
|
|
722
|
-
- **[UPDATE]**
|
|
723
|
-
- **[UPDATE]**
|
|
758
|
+
- **[UPDATE]** update dependencies
|
|
759
|
+
- **[UPDATE]** update rate limiter Mongo option to not create an index by default when NODE_ENV=test
|
|
760
|
+
- **[UPDATE]** the default User model now uses roles and permissions with the String type (previously was any, for historical reasons). To avoid changes on Mongoose 8.19 as it affects User model https://github.com/Automattic/mongoose/issues/15699
|
|
724
761
|
- **[BREAKING]** Vitest v4 <https://vitest.dev/guide/migration.html#vitest-4>
|
|
725
762
|
|
|
726
763
|
---
|
|
727
764
|
|
|
728
765
|
## [5.0.0-beta.36] - 2025-08-24
|
|
729
766
|
|
|
730
|
-
- **[UPDATE]**
|
|
767
|
+
- **[UPDATE]** i18nService update loading to avoid race conditions
|
|
768
|
+
|
|
731
769
|
---
|
|
732
770
|
|
|
733
771
|
## [5.0.0-beta.36] - 2025-08-24
|
|
734
772
|
|
|
735
|
-
- **[UPDATE]**
|
|
773
|
+
- **[UPDATE]** i18nService update method names
|
|
736
774
|
|
|
737
775
|
---
|
|
738
776
|
|
|
@@ -764,14 +802,12 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
764
802
|
|
|
765
803
|
- **[NEW]** Rate limiter middleware - add consumeResult function to allow user middleware as a regular rate limiter
|
|
766
804
|
|
|
767
|
-
|
|
768
805
|
---
|
|
769
806
|
|
|
770
807
|
## [5.0.0-beta.30] - 2025-08-01
|
|
771
808
|
|
|
772
809
|
- **[FIX]** Fix CLI mongo app name generation (64 symbols limit)
|
|
773
810
|
|
|
774
|
-
|
|
775
811
|
---
|
|
776
812
|
|
|
777
813
|
## [5.0.0-beta.29] - 2025-07-31
|
|
@@ -793,7 +829,6 @@ This is a big release that contains a lot of new features and breaking changes.
|
|
|
793
829
|
- **[UPDATE]** Update types.
|
|
794
830
|
- **[UPDATE]** Update deps.
|
|
795
831
|
|
|
796
|
-
|
|
797
832
|
---
|
|
798
833
|
|
|
799
834
|
## [5.0.0-beta.26] - 2025-06-19
|