@adaptivestone/framework 5.0.0-beta.50 → 5.0.0-beta.52
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 +36 -11
- package/dist/codegen/appTypes.d.ts +2 -2
- package/dist/codegen/appTypes.js +20 -5
- package/dist/codegen/appTypes.js.map +1 -1
- package/dist/codegen/collectMetadata.d.ts +6 -0
- package/dist/codegen/collectMetadata.js +4 -0
- package/dist/codegen/collectMetadata.js.map +1 -1
- package/dist/codegen/emit.js +15 -1
- package/dist/codegen/emit.js.map +1 -1
- package/dist/controllers/Auth.d.ts +14 -29
- package/dist/controllers/Auth.js +147 -21
- package/dist/controllers/Auth.js.map +1 -1
- package/dist/controllers/index.js +81 -8
- package/dist/controllers/index.js.map +1 -1
- package/dist/helpers/logger.d.ts +3 -1
- package/dist/helpers/logger.js +22 -1
- package/dist/helpers/logger.js.map +1 -1
- package/dist/helpers/yup.d.ts +11 -2
- package/dist/helpers/yup.js +20 -2
- package/dist/helpers/yup.js.map +1 -1
- package/dist/models/KeyValue.d.ts +22 -0
- package/dist/models/KeyValue.js +17 -0
- package/dist/models/KeyValue.js.map +1 -0
- package/dist/modules/AbstractController.d.ts +12 -1
- package/dist/modules/AbstractController.js.map +1 -1
- package/dist/modules/Base.d.ts +1 -1
- package/dist/modules/Base.js +12 -8
- package/dist/modules/Base.js.map +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.js +10 -6
- package/dist/server.js.map +1 -1
- package/dist/services/http/files.d.ts +18 -0
- package/dist/services/http/files.js +19 -0
- package/dist/services/http/files.js.map +1 -0
- package/dist/services/http/middleware/AbstractMiddleware.d.ts +24 -7
- package/dist/services/http/middleware/AbstractMiddleware.js +28 -7
- package/dist/services/http/middleware/AbstractMiddleware.js.map +1 -1
- package/dist/services/http/middleware/Pagination.d.ts +5 -7
- package/dist/services/http/middleware/Pagination.js +22 -5
- package/dist/services/http/middleware/Pagination.js.map +1 -1
- package/dist/services/http/routing/RouteNode.d.ts +2 -1
- package/dist/services/http/routing/RouteNode.js.map +1 -1
- package/dist/services/validate/ValidateService.js +2 -2
- package/dist/services/validate/ValidateService.js.map +1 -1
- package/dist/services/validate/contentType.d.ts +18 -0
- package/dist/services/validate/contentType.js +30 -0
- package/dist/services/validate/contentType.js.map +1 -0
- package/dist/services/validate/defineSchema.d.ts +23 -0
- package/dist/services/validate/defineSchema.js +25 -0
- package/dist/services/validate/defineSchema.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
## [5.0.0-next]
|
|
9
9
|
|
|
10
10
|
This is a big release that contains a lot of new features and breaking changes.
|
|
11
|
-
Main feature of that release is full TypeScript support
|
|
11
|
+
Main feature of that release is full TypeScript support including mongoose models.
|
|
12
12
|
|
|
13
13
|
### New Features
|
|
14
14
|
|
|
@@ -43,13 +43,16 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
43
43
|
- **[NEW]** Codegen emits `appInfo.query: StandardSchemaV1.InferOutput<...>` from route-level `query:` schemas. Mirrors how `request:` schemas are already handled — declares it on the route, handlers read typed `req.appInfo.query.X`.
|
|
44
44
|
- **[NEW]** Codegen deduplicates identical union branches when one handler serves multiple routes with the same resolved chain + path params + schemas. Prevents `Foo = (X & {...}) | (X & {...})` output in `.routes.gen.ts`.
|
|
45
45
|
- **[NEW]** `Pagination` middleware declares `static get provides()` returning `PaginationMiddlewareAppInfo['appInfo']`. Routes with `Pagination` in their chain get `req.appInfo.pagination: { page, limit, skip }` typed automatically.
|
|
46
|
+
- **[NEW]** Middleware request/query schemas can be declared **statically** — `static get relatedRequestParameters()` / `static get relatedQueryParameters()`. The framework reads them without instantiating the middleware (avoids constructor side effects during route setup / codegen). Framework middlewares (`Pagination`) migrated.
|
|
47
|
+
- **[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`).
|
|
46
48
|
- **[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.
|
|
47
49
|
- **[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. extending a framework class from `node_modules`) are skipped because their `.ts` source isn't accessible at codegen time; child controllers in that case should either override the middleware Map or add a type-only re-import.
|
|
50
|
+
- **[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`).
|
|
48
51
|
|
|
49
52
|
### Breaking changes (please read carefully)
|
|
50
53
|
|
|
51
54
|
- **[BREAKING]** No more global variables for testing and default user will not be created by default
|
|
52
|
-
- **[BREAKING]** All models now should be extended from `BaseModel`. This is a
|
|
55
|
+
- **[BREAKING]** All models now should be extended from `BaseModel`. This is a potential breaking change specially for `User` model.
|
|
53
56
|
- **[BREAKING]** Remove jest support for testing.
|
|
54
57
|
- **[BREAKING]** Move email module to separate package `@adaptivestone/framework-module-email`. Please use it if you want to send emails.
|
|
55
58
|
- **[BREAKING]** Remove `VIEWS` folders at all. Should not affect any user as this was not used internally.
|
|
@@ -59,7 +62,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
59
62
|
- **[BREAKING]** `i18next` v24 <https://www.i18next.com/misc/migration-guide#v23.x.x-to-v24.0.0>.
|
|
60
63
|
- **[BREAKING]** Possible breaking. Framework start using express 5 instead of express 4. Please follow express migration guide too <https://expressjs.com/en/guide/migrating-5.html>.
|
|
61
64
|
- **[BREAKING]** As part of express 5 migration `_` in rotes (middlewares) should have perameter. please replace `_` to `*splat`.
|
|
62
|
-
- **[BREAKING]** Default auth
|
|
65
|
+
- **[BREAKING]** Default auth response changed to be unified. `{token, user}` => `{data:{token, user}}`.
|
|
63
66
|
- **[BREAKING]** `RateLimiter` now need to have `IpDetector` middleware before.
|
|
64
67
|
- **[BREAKING]** Removing `staticFiles` middleware as it not used in projects anymore. Docs with nginx config will be provided.
|
|
65
68
|
- **[BREAKING]** Remove default `AUTH_SALT`. It should be provided on a app level now.
|
|
@@ -68,6 +71,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
68
71
|
- **[BREAKING]** Mongoose v8. <https://mongoosejs.com/docs/migrating_to_8.html>.
|
|
69
72
|
- **[BREAKING]** Mongoose v9. <https://mongoosejs.com/docs/migrating_to_9.html>.
|
|
70
73
|
- **[BREAKING]** Vitest v4 <https://vitest.dev/guide/migration.html#vitest-4>
|
|
74
|
+
- **[BREAKING]** `@redis/client` v6. Now defaults to the RESP3 protocol (was RESP2) and requires a Redis ≥6 server; pass `createClient({ RESP: 2 })` to keep v5 wire behavior. Also adds a default 5s command timeout. <https://github.com/redis/node-redis/blob/master/docs/v5-to-v6.md>
|
|
71
75
|
- **[BREAKING]** Yup ≥1.7 required (was ≥1.0). Stays as a direct dep — used by built-in `Auth` controller. Schemas must implement Standard Schema (`~standard`); yup ≥1.7 does this natively.
|
|
72
76
|
- **[BREAKING]** Legacy `{validate, cast}` plain-object validators removed. Wrap as Standard Schema (~10 lines).
|
|
73
77
|
- **[BREAKING]** Yup `req:` context inside `.test()` / `.when()` removed. Use `this.parent` or move logic to handler.
|
|
@@ -79,6 +83,27 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
79
83
|
- **[BREAKING]** Path-pattern syntax narrowed. The new tree-based router supports literal segments, `:name` params (exactly one segment), and `{*name}` splats (zero or more segments to end of path). **Express 5's optional-param `{:name}` and inline regex are NOT supported.** If you had routes like `/fullpath/:paramOne/{:paramTwo}`, split into two explicit routes (`/fullpath/:paramOne` + `/fullpath/:paramOne/:paramTwo`) or restructure. Specificity is structural (static > param > splat); URL decoding is per-segment.
|
|
80
84
|
- **[BREAKING]** `AbstractController` constructor third argument `isExpressMergeParams` removed. The old default Express-router behavior of stripping parent params is gone — all matched params (across the full path, including the controller prefix) are available on `req.params`. If you relied on the merge-params toggle, no action needed in most cases; if you specifically depended on the strip behavior, restructure your handler to filter `req.params` keys.
|
|
81
85
|
|
|
86
|
+
---
|
|
87
|
+
## [5.0.0-beta.52-next]
|
|
88
|
+
|
|
89
|
+
- **[NEW]** Middleware request/query schemas can be declared **statically** — `static get relatedRequestParameters()` / `static get relatedQueryParameters()`. The framework reads them without instantiating the middleware (avoids constructor side effects during route setup / codegen). Framework middlewares (`Pagination`) migrated.
|
|
90
|
+
- **[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`).
|
|
91
|
+
- **[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`).
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
## [5.0.0-beta.51]
|
|
97
|
+
|
|
98
|
+
- **[NEW]** `KeyValue` model: a minimal persistent key/value store backed by MongoDB for lightweight caching, runtime config, and feature flags.
|
|
99
|
+
- **[NEW]** `defineSchema<Output>(validate)` helper (`@adaptivestone/framework/services/validate/defineSchema.js`) — wrap a plain validate function into a zero-dependency Standard Schema. Codegen reads its `Output` generic for handler request types via `StandardSchemaV1.InferOutput`.
|
|
100
|
+
- **[NEW]** `File` type exported from `@adaptivestone/framework/types.js` — vendor-neutral uploaded-file type (aliases formidable's `PersistentFile` today; re-points at the web-standard `File` after the P3 parser swap). Validate uploads with your validator's idiom, e.g. `z.instanceof(File)`.
|
|
101
|
+
- **[NEW]** Content-type-keyed request schemas: a route's `request` can be a map (`{ 'application/json': schemaA, 'multipart/form-data': schemaB }`, mirrors OpenAPI `requestBody.content`). The framework validates with the schema matching the request's `Content-Type` (415 on no match) and `req.appInfo.request` becomes a `contentType`-discriminated union; codegen emits the union automatically. Media-type matching is case-insensitive and ignores parameters (`; charset=...`); `contentType` is a reserved field on the validated request object.
|
|
102
|
+
- **[CHANGE]** Built-in `Auth` controller and `Pagination` middleware now validate with `defineSchema` instead of yup. The framework runtime and built-ins are yup-free.
|
|
103
|
+
- **[BREAKING]** `yup` moved from `dependencies` to an optional `peerDependency`. It is no longer bundled. Apps that use yup schemas (including `YupFile`) must add `yup` to their own `dependencies`. Zod/Valibot/ArkType users are unaffected.
|
|
104
|
+
- **[BREAKING]** `@redis/client` v6. Now defaults to the RESP3 protocol (was RESP2) and requires a Redis ≥6 server; pass `createClient({ RESP: 2 })` to keep v5 wire behavior. Also adds a default 5s command timeout. <https://github.com/redis/node-redis/blob/master/docs/v5-to-v6.md>
|
|
105
|
+
- **[DEPRECATED]** `YupFile` (`@adaptivestone/framework/helpers/yup.js`) — removed in v6. Validate files via the new `File` export + your validator's `instanceof` idiom instead.
|
|
106
|
+
|
|
82
107
|
---
|
|
83
108
|
## [5.0.0-beta.50]
|
|
84
109
|
|
|
@@ -296,14 +321,14 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
296
321
|
## [5.0.0-beta.19]
|
|
297
322
|
|
|
298
323
|
- **[NEW]** Introducing new model type. `BaseModel`. Features - simplifie works with typescript. And based on statics.
|
|
299
|
-
- **[BREAKING]** All models now should be extended from `BaseModel`. This is a
|
|
324
|
+
- **[BREAKING]** All models now should be extended from `BaseModel`. This is a potential breaking change specially for `User` model.
|
|
300
325
|
|
|
301
326
|
---
|
|
302
327
|
|
|
303
328
|
## [5.0.0-beta.18]
|
|
304
329
|
|
|
305
330
|
- **[UPDATE]** Move away connection from `mongooseModels` to server itself (preparation for different model types).
|
|
306
|
-
- **[BREAKING]**
|
|
331
|
+
- **[BREAKING]** potential. We are removed callback from `mongooseModels` contrctuctor. It was not used in code.
|
|
307
332
|
- **[NEW]** Add `appInstance` helper to access app instance from anywhere without passing it.
|
|
308
333
|
|
|
309
334
|
---
|
|
@@ -343,7 +368,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
343
368
|
## [5.0.0-beta.12]
|
|
344
369
|
|
|
345
370
|
- **[BREAKING]** Remove jest support for testing.
|
|
346
|
-
- **[NEW]** Initial move to typescript.
|
|
371
|
+
- **[NEW]** Initial move to typescript. potentially breaking.
|
|
347
372
|
- **[NEW]** Introduce `src` and `dist` folders.
|
|
348
373
|
|
|
349
374
|
---
|
|
@@ -461,7 +486,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
461
486
|
|
|
462
487
|
## [5.0.0-alpha.18]
|
|
463
488
|
|
|
464
|
-
- **[BREAKING]** Default auth
|
|
489
|
+
- **[BREAKING]** Default auth response changed to be unified. `{token, user}` => `{data:{token, user}}`.
|
|
465
490
|
- **[UPDATE]** `RateLimiter` updae key generation.
|
|
466
491
|
|
|
467
492
|
---
|
|
@@ -612,7 +637,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
612
637
|
## [4.11.0]
|
|
613
638
|
|
|
614
639
|
- **[NEW]** `Cors` middleware.
|
|
615
|
-
- **[BREAKING]** This is a
|
|
640
|
+
- **[BREAKING]** This is a potential breaking change as we switched from `cors` external package to internal middleware. From API nothing was changed. This is a potential breaking changes, but it should keep working as it.
|
|
616
641
|
|
|
617
642
|
---
|
|
618
643
|
|
|
@@ -620,7 +645,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
620
645
|
|
|
621
646
|
- **[UPDATE]** Deps update.
|
|
622
647
|
- **[NEW]** Static file middleware.
|
|
623
|
-
- **[BREAKING]** This is a
|
|
648
|
+
- **[BREAKING]** This is a potential breaking change as we switched from `express.static` to internal middleware that provide less features but faster. From API nothing was changed.
|
|
624
649
|
|
|
625
650
|
---
|
|
626
651
|
|
|
@@ -632,7 +657,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
632
657
|
|
|
633
658
|
## [4.9.1]
|
|
634
659
|
|
|
635
|
-
- **[UPDATE]** All
|
|
660
|
+
- **[UPDATE]** All responses from framework now happens in JSON. Previouls sometime aswers was in plan text.
|
|
636
661
|
|
|
637
662
|
---
|
|
638
663
|
|
|
@@ -997,7 +1022,7 @@ Main feature of that release is full TypeScript support insluding mongoose model
|
|
|
997
1022
|
- **[REMOVED]** Removed deprecated `isUseControllerNameForRouting()` on abstract controller. Use `getExpressPath()` instead.
|
|
998
1023
|
- **[REMOVED]** Removed deprecated `Base.loadFilesWithInheritance` please use `getFilesPathWithInheritance` that produce almost the same output.
|
|
999
1024
|
- **[BREAKING]** Removed "success" field on Auth contreoller. Please use http status instead.
|
|
1000
|
-
- **[BREAKING]** Auth controller - "error" error
|
|
1025
|
+
- **[BREAKING]** Auth controller - "error" error response renamed to "message".
|
|
1001
1026
|
```js
|
|
1002
1027
|
// Before
|
|
1003
1028
|
{
|
|
@@ -12,8 +12,8 @@ export interface CodegenLogger {
|
|
|
12
12
|
}
|
|
13
13
|
/** Generate the app-level `genTypes.d.ts` file. */
|
|
14
14
|
export declare function generateAppTypes(app: IApp, logger?: CodegenLogger | null): Promise<void>;
|
|
15
|
-
/** Render the `genTypes.d.ts` template text from
|
|
16
|
-
export declare function getTemplate(
|
|
15
|
+
/** Render the `genTypes.d.ts` template text from config paths + model paths. */
|
|
16
|
+
export declare function getTemplate(configPaths: Map<string, Record<string, string>>, modelPaths: {
|
|
17
17
|
file: string;
|
|
18
18
|
path: string;
|
|
19
19
|
}[]): Promise<string>;
|
package/dist/codegen/appTypes.js
CHANGED
|
@@ -16,15 +16,30 @@ import fs from 'node:fs/promises';
|
|
|
16
16
|
import { BaseModel } from "../modules/BaseModel.js";
|
|
17
17
|
/** Generate the app-level `genTypes.d.ts` file. */
|
|
18
18
|
export async function generateAppTypes(app, logger) {
|
|
19
|
-
const template = await getTemplate(app.internalFilesCache.
|
|
19
|
+
const template = await getTemplate(app.internalFilesCache.configPaths, app.internalFilesCache.modelPaths);
|
|
20
20
|
await fs.writeFile(`${process.cwd()}/genTypes.d.ts`, template);
|
|
21
21
|
logger?.info?.('TypeScript types generated successfully at genTypes.d.ts');
|
|
22
22
|
}
|
|
23
|
-
/** Render the `genTypes.d.ts` template text from
|
|
24
|
-
export async function getTemplate(
|
|
23
|
+
/** Render the `genTypes.d.ts` template text from config paths + model paths. */
|
|
24
|
+
export async function getTemplate(configPaths, modelPaths) {
|
|
25
25
|
const dir = process.cwd();
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Emit `getConfig` as a reference to each config module's inferred type —
|
|
27
|
+
// never a serialized value. Serializing live values leaks secrets into the
|
|
28
|
+
// committed file and drops env-only fields (`JSON.stringify` omits
|
|
29
|
+
// `undefined`). A config name resolves (post-inheritance) to one base file
|
|
30
|
+
// plus optional `NODE_ENV` layers; the base is required, each extra layer is
|
|
31
|
+
// `& Partial<…>` (deep-merged at runtime, optional and env-independent here).
|
|
32
|
+
const typeRef = (filePath) => `typeof import('${filePath.replace(dir, '.')}').default`;
|
|
33
|
+
const configTypes = Array.from(configPaths)
|
|
34
|
+
.map(([name, layers]) => {
|
|
35
|
+
const baseKey = layers.default ? 'default' : Object.keys(layers)[0];
|
|
36
|
+
const base = layers[baseKey];
|
|
37
|
+
const overlays = Object.entries(layers)
|
|
38
|
+
.filter(([key]) => key !== baseKey)
|
|
39
|
+
.map(([, p]) => ` & Partial<${typeRef(p)}>`)
|
|
40
|
+
.join('');
|
|
41
|
+
return ` getConfig(configName: '${name}'): ${typeRef(base)}${overlays};`;
|
|
42
|
+
})
|
|
28
43
|
.join('\n');
|
|
29
44
|
const modelTypes = (await Promise.all(modelPaths.map(async (modelPath) => {
|
|
30
45
|
const modelModule = await import(__rewriteRelativeImportExtension(modelPath.path));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appTypes.js","sourceRoot":"","sources":["../../src/codegen/appTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAS,EACT,MAA6B;IAE7B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAChC,GAAG,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"appTypes.js","sourceRoot":"","sources":["../../src/codegen/appTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAS,EAC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,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,OAAO,8BAA8B,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC;IAC9E,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,UAAU,GAAG,CACjB,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACjC,MAAM,WAAW,GAAG,MAAM,MAAM,kCAAC,SAAS,CAAC,IAAI,EAAC,CAAC;QACjD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjD,IAAI,WAAW,CAAC,OAAO,CAAC,SAAS,YAAY,SAAS,EAAE,CAAC;YACvD,OAAO,4BAA4B,SAAS,CAAC,IAAI,4CAA4C,OAAO,aAAa,CAAC;QACpH,CAAC;QACD,OAAO,4BAA4B,SAAS,CAAC,IAAI,eAAe,OAAO,6BAA6B,CAAC;IACvG,CAAC,CAAC,CACH,CACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO;;;;;;QAMD,WAAW;QACX,UAAU;;;CAGjB,CAAC;AACF,CAAC"}
|
|
@@ -22,6 +22,12 @@ export interface RouteMeta {
|
|
|
22
22
|
handlerName: string | null;
|
|
23
23
|
/** True when the route entry is `{ handler, request }` and `request` is set. */
|
|
24
24
|
hasSchema: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Media-type keys when `request` is a content-type map (`{ 'application/json':
|
|
27
|
+
* schema, ... }`). Drives the discriminated-union request type. Absent for a
|
|
28
|
+
* single-schema `request`.
|
|
29
|
+
*/
|
|
30
|
+
requestContentTypes?: string[];
|
|
25
31
|
/** True when the route entry is `{ handler, query }` and `query` is set. */
|
|
26
32
|
hasQuerySchema: boolean;
|
|
27
33
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* (`RouteRegistry.flatten()`). Codegen pairs this metadata with the
|
|
8
8
|
* registry output to render per-handler `<MethodName>Request` aliases.
|
|
9
9
|
*/
|
|
10
|
+
import { isContentTypeRequestMap } from "../services/validate/contentType.js";
|
|
10
11
|
/** Extract metadata from one already-instantiated controller. */
|
|
11
12
|
export function extractControllerMeta(controller) {
|
|
12
13
|
const className = controller.constructor.name;
|
|
@@ -38,6 +39,9 @@ function extractRouteMeta(verb, path, entry) {
|
|
|
38
39
|
path,
|
|
39
40
|
handlerName: typeof obj.handler === 'function' ? nameOf(obj.handler) : null,
|
|
40
41
|
hasSchema: obj.request != null,
|
|
42
|
+
requestContentTypes: isContentTypeRequestMap(obj.request)
|
|
43
|
+
? Object.keys(obj.request)
|
|
44
|
+
: undefined,
|
|
41
45
|
hasQuerySchema: obj.query != null,
|
|
42
46
|
};
|
|
43
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectMetadata.js","sourceRoot":"","sources":["../../src/codegen/collectMetadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"collectMetadata.js","sourceRoot":"","sources":["../../src/codegen/collectMetadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAsC9E,iEAAiE;AACjE,MAAM,UAAU,qBAAqB,CACnC,UAA8B;IAE9B,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC;IAC9C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAE3C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAC/C,UAAU,CAAC,MAAiD,CAC7D,EAAE,CAAC;QACF,KAAK,MAAM,CAAC,I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AACJ,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,KAA0B,CAAC;QACtC,OAAO,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/codegen/emit.js
CHANGED
|
@@ -147,7 +147,21 @@ function renderShape(route, chain, routesAlias) {
|
|
|
147
147
|
// on the route entry.
|
|
148
148
|
const appInfoOverrides = [];
|
|
149
149
|
if (route.hasSchema) {
|
|
150
|
-
|
|
150
|
+
if (route.requestContentTypes?.length) {
|
|
151
|
+
// Content-type map → discriminated union keyed by `contentType`. Each
|
|
152
|
+
// branch reads InferOutput of that media type's schema.
|
|
153
|
+
const base = `${routesAlias}['${route.method}']['${route.path}']['request']`;
|
|
154
|
+
// Discriminant literal is lower-cased to match the runtime-injected
|
|
155
|
+
// value (the parser normalizes `Content-Type` to lower case); the type
|
|
156
|
+
// navigation keeps the author's original key so the schema resolves.
|
|
157
|
+
const union = route.requestContentTypes
|
|
158
|
+
.map((ct) => `({ contentType: '${ct.toLowerCase()}' } & StandardSchemaV1.InferOutput<${base}['${ct}']>)`)
|
|
159
|
+
.join(' | ');
|
|
160
|
+
appInfoOverrides.push(`request: ${union}`);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
appInfoOverrides.push(`request: StandardSchemaV1.InferOutput<${routesAlias}['${route.method}']['${route.path}']['request']>`);
|
|
164
|
+
}
|
|
151
165
|
}
|
|
152
166
|
if (route.hasQuerySchema) {
|
|
153
167
|
appInfoOverrides.push(`query: StandardSchemaV1.InferOutput<${routesAlias}['${route.method}']['${route.path}']['query']>`);
|
package/dist/codegen/emit.js.map
CHANGED
|
@@ -1 +1 @@
|
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AM,SAAS,GAAG,OAAO;oBACvB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;oBACZ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;gBAC3C,IAAI,SAAS,EAAE,CAAC;oBACd,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;gBACvC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,wEAAwE;IACxE,oEAAoE;IACpE,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,0BAA0B;IAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,+EAA+E;AAC/E,SAAS,cAAc,CAAC,OAAe,EAAE,MAAc;IACrD,IAAI,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,GAAG,GAAG,KAAK,GAAG,EAAE,CAAC;IACnB,CAAC;IACD,0CAA0C;IAC1C,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -2,63 +2,48 @@ import type { Response } from 'express';
|
|
|
2
2
|
import AbstractController from '../modules/AbstractController.ts';
|
|
3
3
|
import GetUserByToken from '../services/http/middleware/GetUserByToken.ts';
|
|
4
4
|
import RateLimiter from '../services/http/middleware/RateLimiter.ts';
|
|
5
|
+
import type { StandardSchemaV1 } from '../services/validate/types.ts';
|
|
5
6
|
import type { PostLoginRequest, PostLogoutRequest, PostRegisterRequest, RecoverPasswordRequest, SendPasswordRecoveryEmailRequest, SendVerificationRequest, VerifyUserRequest } from './Auth.routes.gen.ts';
|
|
6
7
|
declare class Auth extends AbstractController {
|
|
7
8
|
get routes(): {
|
|
8
9
|
post: {
|
|
9
10
|
'/login': {
|
|
10
11
|
handler: (req: PostLoginRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
11
|
-
request:
|
|
12
|
+
request: StandardSchemaV1<unknown, {
|
|
12
13
|
email: string;
|
|
13
14
|
password: string;
|
|
14
|
-
}
|
|
15
|
-
email: undefined;
|
|
16
|
-
password: undefined;
|
|
17
|
-
}, "">;
|
|
15
|
+
}>;
|
|
18
16
|
};
|
|
19
17
|
'/register': {
|
|
20
18
|
handler: (req: PostRegisterRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
21
|
-
request:
|
|
19
|
+
request: StandardSchemaV1<unknown, {
|
|
22
20
|
email: string;
|
|
23
21
|
password: string;
|
|
24
|
-
nickName
|
|
25
|
-
firstName
|
|
26
|
-
lastName
|
|
27
|
-
}
|
|
28
|
-
email: undefined;
|
|
29
|
-
password: undefined;
|
|
30
|
-
nickName: undefined;
|
|
31
|
-
firstName: undefined;
|
|
32
|
-
lastName: undefined;
|
|
33
|
-
}, "">;
|
|
22
|
+
nickName?: string;
|
|
23
|
+
firstName?: string;
|
|
24
|
+
lastName?: string;
|
|
25
|
+
}>;
|
|
34
26
|
};
|
|
35
27
|
'/logout': (req: PostLogoutRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
36
28
|
'/verify': (req: VerifyUserRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
37
29
|
'/send-recovery-email': {
|
|
38
30
|
handler: (req: SendPasswordRecoveryEmailRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
39
|
-
request:
|
|
31
|
+
request: StandardSchemaV1<unknown, {
|
|
40
32
|
email: string;
|
|
41
|
-
}
|
|
42
|
-
email: undefined;
|
|
43
|
-
}, "">;
|
|
33
|
+
}>;
|
|
44
34
|
};
|
|
45
35
|
'/recover-password': {
|
|
46
36
|
handler: (req: RecoverPasswordRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
47
|
-
request:
|
|
37
|
+
request: StandardSchemaV1<unknown, {
|
|
48
38
|
password: string;
|
|
49
39
|
passwordRecoveryToken: string;
|
|
50
|
-
}
|
|
51
|
-
password: undefined;
|
|
52
|
-
passwordRecoveryToken: undefined;
|
|
53
|
-
}, "">;
|
|
40
|
+
}>;
|
|
54
41
|
};
|
|
55
42
|
'/send-verification': {
|
|
56
43
|
handler: (req: SendVerificationRequest, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
57
|
-
request:
|
|
44
|
+
request: StandardSchemaV1<unknown, {
|
|
58
45
|
email: string;
|
|
59
|
-
}
|
|
60
|
-
email: undefined;
|
|
61
|
-
}, "">;
|
|
46
|
+
}>;
|
|
62
47
|
};
|
|
63
48
|
};
|
|
64
49
|
};
|
package/dist/controllers/Auth.js
CHANGED
|
@@ -1,50 +1,176 @@
|
|
|
1
|
-
import { object, string } from 'yup';
|
|
2
1
|
import AbstractController from "../modules/AbstractController.js";
|
|
3
2
|
import GetUserByToken from "../services/http/middleware/GetUserByToken.js";
|
|
4
3
|
import RateLimiter from "../services/http/middleware/RateLimiter.js";
|
|
4
|
+
import { defineSchema } from "../services/validate/defineSchema.js";
|
|
5
|
+
// Zero-dependency validation for the built-in auth routes. Messages are i18n
|
|
6
|
+
// keys (see `src/locales/*`); the framework auto-translates them via the
|
|
7
|
+
// request's `i18n.t` before the error is serialized.
|
|
8
|
+
const EMAIL_RE = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
|
|
9
|
+
const PASSWORD_RE = /^[a-zA-Z0-9!@#$%ˆ^&*()_+\-{}[\]<>]+$/;
|
|
10
|
+
const NICK_RE = /^[a-zA-Z0-9_\-.]+$/;
|
|
11
|
+
const isMissing = (v) => v === undefined || v === null || v === '';
|
|
12
|
+
// Coerce primitives to string the way yup's `string()` did, so numeric/boolean
|
|
13
|
+
// JSON values keep validating (e.g. `password: 123` → `"123"`). `null`,
|
|
14
|
+
// `undefined`, and non-primitives (arrays/objects) pass through unchanged — yup
|
|
15
|
+
// did not stringify those either, so the type/required checks still fire.
|
|
16
|
+
const coerceStr = (v) => v == null || typeof v === 'object' ? v : String(v);
|
|
17
|
+
const pushEmailIssues = (email, issues) => {
|
|
18
|
+
if (isMissing(email)) {
|
|
19
|
+
issues.push({ message: 'auth.emailProvided', path: ['email'] });
|
|
20
|
+
}
|
|
21
|
+
else if (typeof email !== 'string' || !EMAIL_RE.test(email)) {
|
|
22
|
+
issues.push({ message: 'auth.emailValid', path: ['email'] });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
5
25
|
class Auth extends AbstractController {
|
|
6
26
|
get routes() {
|
|
7
27
|
return {
|
|
8
28
|
post: {
|
|
9
29
|
'/login': {
|
|
10
30
|
handler: this.postLogin,
|
|
11
|
-
request:
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
request: defineSchema((value) => {
|
|
32
|
+
const v = (value ?? {});
|
|
33
|
+
const email = coerceStr(v.email);
|
|
34
|
+
const password = coerceStr(v.password);
|
|
35
|
+
const issues = [];
|
|
36
|
+
pushEmailIssues(email, issues);
|
|
37
|
+
if (isMissing(password) || typeof password !== 'string') {
|
|
38
|
+
issues.push({
|
|
39
|
+
message: 'auth.passwordProvided',
|
|
40
|
+
path: ['password'],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (issues.length) {
|
|
44
|
+
return { issues };
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
value: {
|
|
48
|
+
email: email,
|
|
49
|
+
password: password,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
14
52
|
}),
|
|
15
53
|
},
|
|
16
54
|
'/register': {
|
|
17
55
|
handler: this.postRegister,
|
|
18
|
-
request:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
56
|
+
request: defineSchema((value) => {
|
|
57
|
+
const v = (value ?? {});
|
|
58
|
+
const email = coerceStr(v.email);
|
|
59
|
+
const password = coerceStr(v.password);
|
|
60
|
+
const nickName = coerceStr(v.nickName);
|
|
61
|
+
const firstName = coerceStr(v.firstName);
|
|
62
|
+
const lastName = coerceStr(v.lastName);
|
|
63
|
+
const issues = [];
|
|
64
|
+
pushEmailIssues(email, issues);
|
|
65
|
+
if (isMissing(password)) {
|
|
66
|
+
issues.push({
|
|
67
|
+
message: 'auth.passwordProvided',
|
|
68
|
+
path: ['password'],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else if (typeof password !== 'string' ||
|
|
72
|
+
!PASSWORD_RE.test(password)) {
|
|
73
|
+
issues.push({
|
|
74
|
+
message: 'auth.passwordValid',
|
|
75
|
+
path: ['password'],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// nickName is optional, but an empty string is invalid (matches the
|
|
79
|
+
// old yup `.matches()` behavior — only `null`/`undefined` skip).
|
|
80
|
+
if (nickName != null &&
|
|
81
|
+
(typeof nickName !== 'string' || !NICK_RE.test(nickName))) {
|
|
82
|
+
issues.push({
|
|
83
|
+
message: 'auth.nickNameValid',
|
|
84
|
+
path: ['nickName'],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// firstName/lastName are optional free-form strings, but a non-string
|
|
88
|
+
// (array/object) would otherwise reach `User.create` and fail the
|
|
89
|
+
// Mongoose String cast with a 500. Reject it as a 400 (yup parity).
|
|
90
|
+
if (firstName != null && typeof firstName !== 'string') {
|
|
91
|
+
issues.push({ message: 'auth.nameValid', path: ['firstName'] });
|
|
92
|
+
}
|
|
93
|
+
if (lastName != null && typeof lastName !== 'string') {
|
|
94
|
+
issues.push({ message: 'auth.nameValid', path: ['lastName'] });
|
|
95
|
+
}
|
|
96
|
+
if (issues.length) {
|
|
97
|
+
return { issues };
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
value: {
|
|
101
|
+
email: email,
|
|
102
|
+
password: password,
|
|
103
|
+
nickName: nickName,
|
|
104
|
+
firstName: firstName,
|
|
105
|
+
lastName: lastName,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
28
108
|
}),
|
|
29
109
|
},
|
|
30
110
|
'/logout': this.postLogout,
|
|
31
111
|
'/verify': this.verifyUser,
|
|
32
112
|
'/send-recovery-email': {
|
|
33
113
|
handler: this.sendPasswordRecoveryEmail,
|
|
34
|
-
request:
|
|
114
|
+
request: defineSchema((value) => {
|
|
115
|
+
const v = (value ?? {});
|
|
116
|
+
const email = coerceStr(v.email);
|
|
117
|
+
const issues = [];
|
|
118
|
+
pushEmailIssues(email, issues);
|
|
119
|
+
if (issues.length) {
|
|
120
|
+
return { issues };
|
|
121
|
+
}
|
|
122
|
+
return { value: { email: email } };
|
|
123
|
+
}),
|
|
35
124
|
},
|
|
36
125
|
'/recover-password': {
|
|
37
126
|
handler: this.recoverPassword,
|
|
38
|
-
request:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
127
|
+
request: defineSchema((value) => {
|
|
128
|
+
const v = (value ?? {});
|
|
129
|
+
const password = coerceStr(v.password);
|
|
130
|
+
const passwordRecoveryToken = coerceStr(v.passwordRecoveryToken);
|
|
131
|
+
const issues = [];
|
|
132
|
+
if (isMissing(password)) {
|
|
133
|
+
issues.push({
|
|
134
|
+
message: 'auth.passwordProvided',
|
|
135
|
+
path: ['password'],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else if (typeof password !== 'string' ||
|
|
139
|
+
!PASSWORD_RE.test(password)) {
|
|
140
|
+
issues.push({
|
|
141
|
+
message: 'auth.passwordValid',
|
|
142
|
+
path: ['password'],
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (isMissing(passwordRecoveryToken)) {
|
|
146
|
+
issues.push({
|
|
147
|
+
message: 'auth.passwordRecoveryTokenProvided',
|
|
148
|
+
path: ['passwordRecoveryToken'],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (issues.length) {
|
|
152
|
+
return { issues };
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
value: {
|
|
156
|
+
password: password,
|
|
157
|
+
passwordRecoveryToken: passwordRecoveryToken,
|
|
158
|
+
},
|
|
159
|
+
};
|
|
43
160
|
}),
|
|
44
161
|
},
|
|
45
162
|
'/send-verification': {
|
|
46
163
|
handler: this.sendVerification,
|
|
47
|
-
request:
|
|
164
|
+
request: defineSchema((value) => {
|
|
165
|
+
const v = (value ?? {});
|
|
166
|
+
const email = coerceStr(v.email);
|
|
167
|
+
const issues = [];
|
|
168
|
+
pushEmailIssues(email, issues);
|
|
169
|
+
if (issues.length) {
|
|
170
|
+
return { issues };
|
|
171
|
+
}
|
|
172
|
+
return { value: { email: email } };
|
|
173
|
+
}),
|
|
48
174
|
},
|
|
49
175
|
},
|
|
50
176
|
};
|