@adaptivestone/framework 5.0.0-beta.53 → 5.0.0-beta.55
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 +22 -3
- package/dist/codegen/appTypes.d.ts +2 -2
- package/dist/codegen/appTypes.js +75 -21
- package/dist/codegen/appTypes.js.map +1 -1
- package/dist/codegen/collectMetadata.d.ts +9 -0
- package/dist/codegen/collectMetadata.js.map +1 -1
- package/dist/codegen/emit.d.ts +4 -5
- package/dist/codegen/emit.js +29 -137
- package/dist/codegen/emit.js.map +1 -1
- package/dist/codegen/importResolution.d.ts +55 -0
- package/dist/codegen/importResolution.js +342 -0
- package/dist/codegen/importResolution.js.map +1 -0
- package/dist/codegen/routeTypes.js +10 -4
- package/dist/codegen/routeTypes.js.map +1 -1
- package/dist/controllers/Home.d.ts +2 -3
- package/dist/controllers/Home.js +7 -3
- package/dist/controllers/Home.js.map +1 -1
- package/dist/controllers/Home.routes.gen.d.ts +1 -2
- package/dist/controllers/index.js +6 -10
- package/dist/controllers/index.js.map +1 -1
- package/dist/models/User.d.ts +20 -0
- package/dist/models/User.js.map +1 -1
- package/dist/server.d.ts +0 -7
- package/dist/server.js +0 -4
- package/dist/server.js.map +1 -1
- package/dist/services/http/middleware/Auth.d.ts +13 -0
- package/dist/services/http/middleware/Auth.js +12 -0
- package/dist/services/http/middleware/Auth.js.map +1 -1
- package/dist/services/http/middleware/GetUserByToken.d.ts +3 -3
- package/dist/services/http/middleware/GetUserByToken.js.map +1 -1
- package/dist/services/http/routing/RouteNode.d.ts +0 -7
- package/dist/services/http/routing/middlewareNormalization.d.ts +2 -7
- package/dist/services/http/routing/middlewareNormalization.js +5 -10
- package/dist/services/http/routing/middlewareNormalization.js.map +1 -1
- package/docs/codegen-ast-approach.md +147 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -46,8 +46,8 @@ Main feature of that release is full TypeScript support including mongoose model
|
|
|
46
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
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`).
|
|
48
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.
|
|
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
|
|
50
|
-
- **[FIX]** `getConfig()` types in `genTypes.d.ts` are
|
|
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. 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/`.
|
|
50
|
+
- **[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.)
|
|
51
51
|
|
|
52
52
|
### Breaking changes (please read carefully)
|
|
53
53
|
|
|
@@ -82,6 +82,25 @@ Main feature of that release is full TypeScript support including mongoose model
|
|
|
82
82
|
- **[BREAKING]** OpenAPI / documentation generation removed: `framework documentation` and `framework getOpenApiJson` CLI commands, `DocumentationGenerator`, and `app.documentation` field deleted. Output was already partial after Standard Schema migration. Will return in later with per-vendor `toJsonSchema` support.
|
|
83
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.
|
|
84
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.
|
|
85
|
+
- **[BREAKING]** The built-in `Home` controller no longer runs `GetUserByToken` globally. It previously declared `'/{*splat}': [GetUserByToken]`, and since `Home` mounts at `/` that landed on the route-tree root and ran on **every request**. `Home` now adds no middleware. Controllers still parse the token via their own/inherited `[GetUserByToken, Auth]`; only routes that don't include it themselves (e.g. ad-hoc `registerRoute` endpoints) lose the implicit `req.appInfo.user`. See the beta.55 note below.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
## [5.0.0-beta.55]
|
|
89
|
+
|
|
90
|
+
- **[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).
|
|
91
|
+
- **[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.
|
|
92
|
+
- **[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`.
|
|
93
|
+
- **[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.
|
|
94
|
+
- **[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.
|
|
95
|
+
- **[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.
|
|
96
|
+
- **[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.)
|
|
97
|
+
- **[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.
|
|
98
|
+
- **[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.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
## [5.0.0-beta.54]
|
|
102
|
+
|
|
103
|
+
- **[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.
|
|
85
104
|
|
|
86
105
|
---
|
|
87
106
|
## [5.0.0-beta.53]
|
|
@@ -96,7 +115,7 @@ Main feature of that release is full TypeScript support including mongoose model
|
|
|
96
115
|
|
|
97
116
|
- **[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.
|
|
98
117
|
- **[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`).
|
|
99
|
-
- **[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`).
|
|
118
|
+
- **[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.)_
|
|
100
119
|
|
|
101
120
|
|
|
102
121
|
|
|
@@ -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 config
|
|
16
|
-
export declare function getTemplate(
|
|
15
|
+
/** Render the `genTypes.d.ts` template text from config values + model paths. */
|
|
16
|
+
export declare function getTemplate(configs: Map<string, unknown>, modelPaths: {
|
|
17
17
|
file: string;
|
|
18
18
|
path: string;
|
|
19
19
|
}[]): Promise<string>;
|
package/dist/codegen/appTypes.js
CHANGED
|
@@ -16,30 +16,67 @@ 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.configs, 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
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Render a TypeScript type from a runtime config value's **shape** — value
|
|
25
|
+
* *types* (`string`, `number`), never the literal values. This is emitted
|
|
26
|
+
* inline (no `import()` to resolve, so output is robust across compilers and
|
|
27
|
+
* module settings) and structure-preserving (arrays stay tuples, so patterns
|
|
28
|
+
* like `Object.values(config.list[0])` keep precise per-element types) — while
|
|
29
|
+
* never serializing a secret value into the generated file.
|
|
30
|
+
*
|
|
31
|
+
* `undefined`-valued object keys are dropped (a field whose value is absent at
|
|
32
|
+
* gen time has no knowable type; same as the historical `JSON.stringify` form).
|
|
33
|
+
*/
|
|
34
|
+
function valueToTypeString(value) {
|
|
35
|
+
if (value === null) {
|
|
36
|
+
return 'null';
|
|
37
|
+
}
|
|
38
|
+
switch (typeof value) {
|
|
39
|
+
case 'string':
|
|
40
|
+
return 'string';
|
|
41
|
+
case 'number':
|
|
42
|
+
return 'number';
|
|
43
|
+
case 'boolean':
|
|
44
|
+
return 'boolean';
|
|
45
|
+
case 'bigint':
|
|
46
|
+
return 'bigint';
|
|
47
|
+
case 'undefined':
|
|
48
|
+
return 'undefined';
|
|
49
|
+
case 'function':
|
|
50
|
+
return '((...args: any[]) => any)';
|
|
51
|
+
case 'object': {
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
return value.length === 0
|
|
54
|
+
? 'unknown[]'
|
|
55
|
+
: `[${value.map(valueToTypeString).join(', ')}]`;
|
|
56
|
+
}
|
|
57
|
+
// Only walk plain objects; anything exotic (Date, RegExp, Map, …) is opaque.
|
|
58
|
+
const proto = Object.getPrototypeOf(value);
|
|
59
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
60
|
+
return 'unknown';
|
|
61
|
+
}
|
|
62
|
+
const entries = Object.entries(value).filter(([, v]) => v !== undefined);
|
|
63
|
+
if (entries.length === 0) {
|
|
64
|
+
return '{}';
|
|
65
|
+
}
|
|
66
|
+
const body = entries
|
|
67
|
+
.map(([k, v]) => `${JSON.stringify(k)}: ${valueToTypeString(v)}`)
|
|
68
|
+
.join('; ');
|
|
69
|
+
return `{ ${body} }`;
|
|
70
|
+
}
|
|
71
|
+
default:
|
|
72
|
+
return 'unknown';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Render the `genTypes.d.ts` template text from config values + model paths. */
|
|
76
|
+
export async function getTemplate(configs, modelPaths) {
|
|
25
77
|
const dir = process.cwd();
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
})
|
|
78
|
+
const configTypes = Array.from(configs)
|
|
79
|
+
.map(([name, value]) => ` getConfig(configName: '${name}'): ${valueToTypeString(value)};`)
|
|
43
80
|
.join('\n');
|
|
44
81
|
const modelTypes = (await Promise.all(modelPaths.map(async (modelPath) => {
|
|
45
82
|
const modelModule = await import(__rewriteRelativeImportExtension(modelPath.path));
|
|
@@ -49,6 +86,23 @@ export async function getTemplate(configPaths, modelPaths) {
|
|
|
49
86
|
}
|
|
50
87
|
return ` getModel(modelName: '${modelPath.file}'): import('${relPath}').default['mongooseModel']`;
|
|
51
88
|
}))).join('\n');
|
|
89
|
+
// Bind `req.appInfo.user` to the project's `User` model (if it's a BaseModel),
|
|
90
|
+
// so it follows a replaced model exactly like `getModel('User')` does.
|
|
91
|
+
const userModel = modelPaths.find((m) => m.file === 'User');
|
|
92
|
+
let userAppInfo = '';
|
|
93
|
+
if (userModel) {
|
|
94
|
+
const mod = await import(__rewriteRelativeImportExtension(userModel.path));
|
|
95
|
+
if (mod.default?.prototype instanceof BaseModel) {
|
|
96
|
+
const relPath = userModel.path.replace(dir, '.');
|
|
97
|
+
userAppInfo = `
|
|
98
|
+
declare module '@adaptivestone/framework/models/User.js' {
|
|
99
|
+
export interface AppModels {
|
|
100
|
+
User: GetModelTypeFromClass<typeof import('${relPath}').default>;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
52
106
|
return `
|
|
53
107
|
import type {} from '@adaptivestone/framework/server.js';
|
|
54
108
|
import type { GetModelTypeFromClass } from '@adaptivestone/framework/modules/BaseModel.js';
|
|
@@ -59,6 +113,6 @@ declare module '@adaptivestone/framework/server.js' {
|
|
|
59
113
|
${modelTypes}
|
|
60
114
|
}
|
|
61
115
|
}
|
|
62
|
-
`;
|
|
116
|
+
${userAppInfo}`;
|
|
63
117
|
}
|
|
64
118
|
//# sourceMappingURL=appTypes.js.map
|
|
@@ -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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AAY,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,+EAA+E;IAC/E,uEAAuE;IACvE,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAC5D,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,GAAG,GAAG,MAAM,MAAM,kCAAC,SAAS,CAAC,IAAI,EAAC,CAAC;QACzC,IAAI,GAAG,CAAC,OAAO,EAAE,SAAS,YAAY,SAAS,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACjD,WAAW,GAAG;;;iDAG6B,OAAO;;;CAGvD,CAAC;QACE,CAAC;IACH,CAAC;IAED,OAAO;;;;;;QAMD,WAAW;QACX,UAAU;;;EAGhB,WAAW,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -13,6 +13,15 @@ export interface MiddlewareRef {
|
|
|
13
13
|
className: string;
|
|
14
14
|
/** Present when the middleware was declared as `[Class, params]` in a Map or route-level array. */
|
|
15
15
|
params?: Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* The resolved middleware class, when the ref came from the live registry
|
|
18
|
+
* (codegen). Lets `emit` map the class back to the *local import binding*
|
|
19
|
+
* a controller uses for it — e.g. `Auth.ts` default-exports `AuthMiddleware`
|
|
20
|
+
* but controllers import it as `Auth`, so `className` ('AuthMiddleware')
|
|
21
|
+
* won't match the import map (keyed by binding). Absent in synthetic refs.
|
|
22
|
+
* Typed `unknown` — `emit` only needs reference identity, not the shape.
|
|
23
|
+
*/
|
|
24
|
+
Class?: unknown;
|
|
16
25
|
}
|
|
17
26
|
/** One route registered by a controller. */
|
|
18
27
|
export interface RouteMeta {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectMetadata.js","sourceRoot":"","sources":["../../src/codegen/collectMetadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"collectMetadata.js","sourceRoot":"","sources":["../../src/codegen/collectMetadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AA+C9E,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,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACzD,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,gBAAgB,CACvB,IAAY,EACZ,IAAY,EACZ,KAAc;IAEd,gDAAgD;IAChD,IA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@ -4,11 +4,10 @@
|
|
|
4
4
|
* shipped in step 1.5 — same import shape, same per-handler `<Method>Request`
|
|
5
5
|
* aliases, same `InstanceType<typeof Controller>['routes']` navigation pattern.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* are computed relative to the controller's location.
|
|
7
|
+
* Middleware import bindings + specifiers are resolved in `importResolution.ts`
|
|
8
|
+
* (the heavy part — reconstructing paths from controller source); this file just
|
|
9
|
+
* renders the resolved chains into text. Framework types (`BaseRequestContext`,
|
|
10
|
+
* `StandardSchemaV1`) are computed relative to the controller's location.
|
|
12
11
|
*/
|
|
13
12
|
import type { ControllerMeta, MiddlewareRef } from './collectMetadata.ts';
|
|
14
13
|
/**
|
package/dist/codegen/emit.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* shipped in step 1.5 — same import shape, same per-handler `<Method>Request`
|
|
5
5
|
* aliases, same `InstanceType<typeof Controller>['routes']` navigation pattern.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* are computed relative to the controller's location.
|
|
7
|
+
* Middleware import bindings + specifiers are resolved in `importResolution.ts`
|
|
8
|
+
* (the heavy part — reconstructing paths from controller source); this file just
|
|
9
|
+
* renders the resolved chains into text. Framework types (`BaseRequestContext`,
|
|
10
|
+
* `StandardSchemaV1`) are computed relative to the controller's location.
|
|
12
11
|
*/
|
|
13
12
|
import { promises as fs } from 'node:fs';
|
|
14
13
|
import path from 'node:path';
|
|
15
14
|
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { buildExtendsImportMap, relativeImport, resolveBinding, } from "./importResolution.js";
|
|
16
16
|
/** Emit the gen.ts text for one controller. */
|
|
17
17
|
export async function emitGenFile(input) {
|
|
18
18
|
const { controller, srcPath, chains } = input;
|
|
@@ -23,15 +23,32 @@ export async function emitGenFile(input) {
|
|
|
23
23
|
// to emit `import type` lines in the child's gen file. Child imports
|
|
24
24
|
// win on collisions.
|
|
25
25
|
const importMap = await buildExtendsImportMap(srcPath, source);
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
26
|
+
const ctrlDir = path.dirname(srcPath);
|
|
27
|
+
// Resolve each chain entry to the *local import binding* the controller (or
|
|
28
|
+
// an ancestor) uses for it, and drop entries not imported anywhere in the
|
|
29
|
+
// extends chain. Two cases collapse here:
|
|
30
|
+
// - binding === class name (the common case) → matched directly by name.
|
|
31
|
+
// - binding !== class name (a default export aliased on import, e.g.
|
|
32
|
+
// `Auth.ts` exports `AuthMiddleware` but controllers `import Auth`) →
|
|
33
|
+
// matched by module identity against the live class.
|
|
34
|
+
// - imported nowhere (cross-controller `/{*splat}` bleed) → dropped.
|
|
35
|
+
// `className` is rewritten to the binding so the import line, the
|
|
36
|
+
// `typeof <binding>` reference, and the import-map lookup all agree.
|
|
37
|
+
const moduleCache = new Map();
|
|
38
|
+
const bindingCache = new Map();
|
|
39
|
+
const filteredChains = [];
|
|
40
|
+
for (const chain of chains) {
|
|
41
|
+
const resolved = [];
|
|
42
|
+
for (const mw of chain) {
|
|
43
|
+
const binding = await resolveBinding(mw, importMap, ctrlDir, moduleCache, bindingCache);
|
|
44
|
+
if (binding !== null) {
|
|
45
|
+
resolved.push({ ...mw, className: binding });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
filteredChains.push(resolved);
|
|
49
|
+
}
|
|
32
50
|
const uniqueMiddlewares = collectUniqueMiddlewares(filteredChains);
|
|
33
51
|
const frameworkRoot = findFrameworkSrcRoot(srcPath);
|
|
34
|
-
const ctrlDir = path.dirname(srcPath);
|
|
35
52
|
const isFrameworkOwnController = srcPath.startsWith(`${frameworkRoot}${path.sep}`);
|
|
36
53
|
const relFromCtrl = (target) => relativeImport(ctrlDir, target);
|
|
37
54
|
// Framework's own controllers (during framework dev / build) use
|
|
@@ -199,122 +216,6 @@ function pascalCase(name) {
|
|
|
199
216
|
}
|
|
200
217
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
201
218
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Build an import map covering the controller and its `extends` ancestors.
|
|
204
|
-
*
|
|
205
|
-
* Inherited `static get middleware()` from a parent class references
|
|
206
|
-
* middleware classes the parent imports — the child file doesn't import
|
|
207
|
-
* them. To emit `import type` lines for them, we walk the extends chain,
|
|
208
|
-
* scan each ancestor's source file for its imports, and merge.
|
|
209
|
-
*
|
|
210
|
-
* Resolution rules:
|
|
211
|
-
* - Child's imports win on name collisions (matches JS class-override
|
|
212
|
-
* semantics).
|
|
213
|
-
* - Only ancestors with a *resolvable local source path* are walked.
|
|
214
|
-
* Bare-package ancestors (e.g. extending a class from `node_modules`)
|
|
215
|
-
* are skipped because their `.ts` source isn't accessible at codegen
|
|
216
|
-
* time. The child either re-imports inherited middlewares explicitly
|
|
217
|
-
* or those middlewares get filtered out as today.
|
|
218
|
-
*/
|
|
219
|
-
async function buildExtendsImportMap(srcPath, source) {
|
|
220
|
-
const merged = new Map();
|
|
221
|
-
const visited = new Set();
|
|
222
|
-
async function visit(filePath, fileSource) {
|
|
223
|
-
if (visited.has(filePath)) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
visited.add(filePath);
|
|
227
|
-
const localImports = parseImports(fileSource);
|
|
228
|
-
// Merge with "deepest ancestor first" → child wins by being applied last.
|
|
229
|
-
// We descend first, then set our own imports after, so we always overwrite
|
|
230
|
-
// ancestor entries with our own. Achieved by visiting parent before
|
|
231
|
-
// setting our imports.
|
|
232
|
-
const parentName = parseExtendsParent(fileSource);
|
|
233
|
-
if (parentName) {
|
|
234
|
-
const parentImportPath = localImports.get(parentName);
|
|
235
|
-
if (parentImportPath) {
|
|
236
|
-
const parentSrcPath = resolveSiblingSource(filePath, parentImportPath);
|
|
237
|
-
if (parentSrcPath !== null) {
|
|
238
|
-
try {
|
|
239
|
-
const parentSource = await fs.readFile(parentSrcPath, 'utf8');
|
|
240
|
-
await visit(parentSrcPath, parentSource);
|
|
241
|
-
}
|
|
242
|
-
catch {
|
|
243
|
-
// Parent source unreachable — skip silently. The child's own
|
|
244
|
-
// imports still apply.
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
// Apply this level's imports AFTER ancestors so we overwrite collisions.
|
|
250
|
-
for (const [name, importPath] of localImports) {
|
|
251
|
-
merged.set(name, importPath);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
await visit(srcPath, source);
|
|
255
|
-
return merged;
|
|
256
|
-
}
|
|
257
|
-
/** `class X extends Y {` → `'Y'`. Returns `null` if no extends clause. */
|
|
258
|
-
function parseExtendsParent(source) {
|
|
259
|
-
const m = source.match(/\bclass\s+\w+\s+extends\s+(\w+)/);
|
|
260
|
-
return m ? (m[1] ?? null) : null;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Given an import path used by `fromFile`, resolve it to an absolute
|
|
264
|
-
* source path if it points at a local `.ts` sibling. Returns `null` for
|
|
265
|
-
* bare-package specifiers and for paths whose target isn't a readable
|
|
266
|
-
* `.ts` file.
|
|
267
|
-
*/
|
|
268
|
-
function resolveSiblingSource(fromFile, importPath) {
|
|
269
|
-
if (!importPath.startsWith('.')) {
|
|
270
|
-
return null; // bare package, can't resolve locally
|
|
271
|
-
}
|
|
272
|
-
const fromDir = path.dirname(fromFile);
|
|
273
|
-
// Strip the trailing `.js` / `.ts` (we want the `.ts` file)
|
|
274
|
-
const stripped = importPath.replace(/\.(js|ts)$/, '');
|
|
275
|
-
return path.resolve(fromDir, `${stripped}.ts`);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Parse top-of-file `import` declarations into a binding-name → path map.
|
|
279
|
-
* Handles default imports (`import X from '…'`), namespace-style default
|
|
280
|
-
* (`import * as X from '…'`), and named imports (`import { A, B as C }
|
|
281
|
-
* from '…'`). Strips `import type` and `as Alias` rebinding.
|
|
282
|
-
*/
|
|
283
|
-
function parseImports(source) {
|
|
284
|
-
const map = new Map();
|
|
285
|
-
const re = /import\s+(?:type\s+)?(?:(\w+)\s*,?\s*)?(?:\*\s+as\s+(\w+)\s+)?(?:\{([^}]+)\}\s+)?from\s+['"]([^'"]+)['"]/g;
|
|
286
|
-
let m;
|
|
287
|
-
while (true) {
|
|
288
|
-
m = re.exec(source);
|
|
289
|
-
if (m === null) {
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
const [, defaultName, starName, namedBlock, importPath] = m;
|
|
293
|
-
if (defaultName) {
|
|
294
|
-
map.set(defaultName, importPath ?? '');
|
|
295
|
-
}
|
|
296
|
-
if (starName) {
|
|
297
|
-
map.set(starName, importPath ?? '');
|
|
298
|
-
}
|
|
299
|
-
if (namedBlock) {
|
|
300
|
-
for (const piece of namedBlock.split(',')) {
|
|
301
|
-
const trimmed = piece.trim();
|
|
302
|
-
if (!trimmed) {
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
// `OrigName as LocalName` → bind LocalName
|
|
306
|
-
const asMatch = trimmed.match(/(\w+)\s+as\s+(\w+)/);
|
|
307
|
-
const localName = asMatch
|
|
308
|
-
? asMatch[2]
|
|
309
|
-
: trimmed.replace(/^type\s+/, '').trim();
|
|
310
|
-
if (localName) {
|
|
311
|
-
map.set(localName, importPath ?? '');
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return map;
|
|
317
|
-
}
|
|
318
219
|
/**
|
|
319
220
|
* Find the framework's `src/` root by walking up from `srcPath` until we hit
|
|
320
221
|
* a directory whose name is `src`. Used to compute import paths to framework
|
|
@@ -327,13 +228,4 @@ function findFrameworkSrcRoot(_srcPath) {
|
|
|
327
228
|
// here = .../src/codegen/
|
|
328
229
|
return path.resolve(here, '..');
|
|
329
230
|
}
|
|
330
|
-
/** Compute a TS-style relative import specifier from `fromDir` to `toFile`. */
|
|
331
|
-
function relativeImport(fromDir, toFile) {
|
|
332
|
-
let rel = path.relative(fromDir, toFile);
|
|
333
|
-
if (!rel.startsWith('.')) {
|
|
334
|
-
rel = `./${rel}`;
|
|
335
|
-
}
|
|
336
|
-
// Ensure forward slashes (cross-platform)
|
|
337
|
-
return rel.split(path.sep).join('/');
|
|
338
|
-
}
|
|
339
231
|
//# sourceMappingURL=emit.js.map
|
package/dist/codegen/emit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/codegen/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAsBzC,+CAA+C;AAC/C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAgB;IAChD,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC9C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAClD,sEAAsE;IACtE,oEAAoE;IACpE,uEAAuE;IACvE,qEAAqE;IACrE,qBAAqB;IACrB,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAE/D,uEAAuE;IACvE,qEAAqE;IACrE,sEAAsE;IACtE,uEAAuE;IACvE,2CAA2C;IAC3C,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAClD,CAAC;IACF,MAAM,iBAAiB,GAAG,wBA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2
|
+
* Resolve, for each middleware in a route's chain, the local import binding and
|
|
3
|
+
* specifier the generated `.routes.gen.ts` file should use — so `emit` can write
|
|
4
|
+
* `import type <binding> from '<specifier>'` + `typeof <binding>`.
|
|
5
|
+
*
|
|
6
|
+
* This is the codegen's heaviest piece, and it exists for one reason: the route
|
|
7
|
+
* chain comes from the runtime registry as live CLASS objects, and a JS class
|
|
8
|
+
* carries no source path. So we reconstruct the path/binding from the
|
|
9
|
+
* controller's source — walking the `extends` chain (relative AND bare-package
|
|
10
|
+
* ancestors), rebasing relative imports to the gen file's directory, and
|
|
11
|
+
* identity-matching the live class against the imported modules to recover the
|
|
12
|
+
* binding (the class name may differ from the import name).
|
|
13
|
+
*/
|
|
14
|
+
import type { MiddlewareRef } from './collectMetadata.ts';
|
|
15
|
+
export type ModuleNamespace = Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the local import binding a controller uses for a middleware in its
|
|
18
|
+
* chain, or `null` when the middleware is imported nowhere in the extends
|
|
19
|
+
* chain (so it should be dropped from the emitted type).
|
|
20
|
+
*
|
|
21
|
+
* We identity-match the live class against the imported modules so a binding
|
|
22
|
+
* whose name merely collides with the class name (a different class imported
|
|
23
|
+
* under that name) can't win — `import Auth from '.../Auth.js'` where the class
|
|
24
|
+
* is `AuthMiddleware` is resolved to `Auth`, and an unrelated `AuthMiddleware`
|
|
25
|
+
* import is rejected. The class's own name is probed first (the binding in the
|
|
26
|
+
* common case); modules are already loaded, so these dynamic imports hit the
|
|
27
|
+
* cache. Synthetic refs (no live class, e.g. unit tests) fall back to matching
|
|
28
|
+
* the import map by name.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveBinding(mw: MiddlewareRef, importMap: Map<string, string>, ctrlDir: string, moduleCache: Map<string, ModuleNamespace | null>, bindingCache: Map<unknown, string | null>): Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Build an import map covering the controller and its `extends` ancestors.
|
|
33
|
+
*
|
|
34
|
+
* Inherited `static get middleware()` from a parent class references
|
|
35
|
+
* middleware classes the parent imports — the child file doesn't import
|
|
36
|
+
* them. To emit `import type` lines for them, we walk the extends chain,
|
|
37
|
+
* scan each ancestor's source file for its imports, and merge.
|
|
38
|
+
*
|
|
39
|
+
* Resolution rules:
|
|
40
|
+
* - Child's imports win on name collisions (matches JS class-override
|
|
41
|
+
* semantics).
|
|
42
|
+
* - Relative ancestors are read from their sibling source on disk; their
|
|
43
|
+
* relative imports are rebased to the child gen file's directory.
|
|
44
|
+
* - Bare-package ancestors (e.g. a consumer extending the framework's
|
|
45
|
+
* `AbstractController` via `@adaptivestone/framework/modules/...`) are
|
|
46
|
+
* resolved through the importing file's `require.resolve` (honoring the
|
|
47
|
+
* package's `exports` map), then their RELATIVE middleware imports are
|
|
48
|
+
* rewritten into bare specifiers rooted at the same package subpath —
|
|
49
|
+
* valid because the public subpath tree mirrors `src/`. This is what lets
|
|
50
|
+
* a consumer relying on inherited default middleware get the right import
|
|
51
|
+
* lines without re-importing those classes itself.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildExtendsImportMap(srcPath: string, source: string): Promise<Map<string, string>>;
|
|
54
|
+
/** Compute a TS-style relative import specifier from `fromDir` to `toFile`. */
|
|
55
|
+
export declare function relativeImport(fromDir: string, toFile: string): string;
|