@adaptivestone/framework 5.0.0-rc.5 → 5.0.0-rc.6
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/README.md +1 -0
- package/dist/codegen/appTypes.d.ts +6 -2
- package/dist/codegen/appTypes.js +63 -12
- package/dist/codegen/appTypes.js.map +1 -1
- package/dist/codegen/astConfig.d.ts +47 -0
- package/dist/codegen/astConfig.js +157 -0
- package/dist/codegen/astConfig.js.map +1 -0
- package/dist/codegen/index.js +1 -1
- package/dist/codegen/index.js.map +1 -1
- package/dist/models/User.d.ts +89 -553
- package/dist/models/User.js +34 -1
- package/dist/models/User.js.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.js +10 -3
- package/dist/server.js.map +1 -1
- package/dist/tests/testHelpers.d.ts +11 -237
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Mongoose models, a tree-based router with per-controller generated route/handler
|
|
|
5
5
|
types, and batteries-included auth, rate limiting, i18n, and caching.
|
|
6
6
|
|
|
7
7
|
📖 **Full documentation → https://framework.adaptivestone.com/**
|
|
8
|
+
|
|
8
9
|
🤖 **LLM-ready docs (whole site as one file) → https://framework.adaptivestone.com/llm-context.md**
|
|
9
10
|
|
|
10
11
|
## Requirements
|
|
@@ -12,8 +12,12 @@ 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 values + model paths.
|
|
15
|
+
/** Render the `genTypes.d.ts` template text from config values + model paths.
|
|
16
|
+
*
|
|
17
|
+
* `configPaths` (config name → contributing source files) is optional: when
|
|
18
|
+
* present, env-only keys dropped by the value pass are recovered from source
|
|
19
|
+
* (see {@link valueToTypeString}). Omitted by unit tests that pass raw values. */
|
|
16
20
|
export declare function getTemplate(configs: Map<string, unknown>, modelPaths: {
|
|
17
21
|
file: string;
|
|
18
22
|
path: string;
|
|
19
|
-
}[]): Promise<string>;
|
|
23
|
+
}[], configPaths?: Map<string, string[]>): Promise<string>;
|
package/dist/codegen/appTypes.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from 'node:fs/promises';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import { envShapeToType, extractConfigEnvShape, mergeEnvShapes, } from "./astConfig.js";
|
|
9
10
|
import { isBaseModelSource } from "./astModel.js";
|
|
10
11
|
/** A `./`-rooted, forward-slash specifier from `dir` to `target` for the emitted
|
|
11
12
|
* `import('…')`. Throws if `target` is outside `dir` (can't be a relative import)
|
|
@@ -19,7 +20,7 @@ function toRelativeSpecifier(dir, target) {
|
|
|
19
20
|
}
|
|
20
21
|
/** Generate the app-level `genTypes.d.ts` file. */
|
|
21
22
|
export async function generateAppTypes(app, logger) {
|
|
22
|
-
const template = await getTemplate(app.internalFilesCache.configs, app.internalFilesCache.modelPaths);
|
|
23
|
+
const template = await getTemplate(app.internalFilesCache.configs, app.internalFilesCache.modelPaths, app.internalFilesCache.configPaths);
|
|
23
24
|
await fs.writeFile(`${process.cwd()}/genTypes.d.ts`, template);
|
|
24
25
|
logger?.info?.('TypeScript types generated successfully at genTypes.d.ts');
|
|
25
26
|
}
|
|
@@ -31,10 +32,15 @@ export async function generateAppTypes(app, logger) {
|
|
|
31
32
|
* like `Object.values(config.list[0])` keep precise per-element types) — while
|
|
32
33
|
* never serializing a secret value into the generated file.
|
|
33
34
|
*
|
|
34
|
-
* `undefined`-valued
|
|
35
|
-
*
|
|
35
|
+
* A `undefined`-valued key is normally dropped (no knowable type at gen time).
|
|
36
|
+
* `env` (from {@link extractConfigEnvShape}) overrides that for keys read from
|
|
37
|
+
* the environment: a bare `process.env.X` is typed from source as `string |
|
|
38
|
+
* undefined` REGARDLESS of the runtime value — so the emitted type is the same
|
|
39
|
+
* whether or not the var happened to be set during codegen (deterministic
|
|
40
|
+
* output, no `as` cast at the read site). Keys with a value at gen time and no
|
|
41
|
+
* env-shape entry (literals, `process.env.X || default`) are typed from value.
|
|
36
42
|
*/
|
|
37
|
-
function valueToTypeString(value) {
|
|
43
|
+
function valueToTypeString(value, env) {
|
|
38
44
|
if (value === null) {
|
|
39
45
|
return 'null';
|
|
40
46
|
}
|
|
@@ -55,19 +61,52 @@ function valueToTypeString(value) {
|
|
|
55
61
|
if (Array.isArray(value)) {
|
|
56
62
|
return value.length === 0
|
|
57
63
|
? 'unknown[]'
|
|
58
|
-
: `[${value.map(valueToTypeString).join(', ')}]`;
|
|
64
|
+
: `[${value.map((v) => valueToTypeString(v)).join(', ')}]`;
|
|
59
65
|
}
|
|
60
66
|
// Only walk plain objects; anything exotic (Date, RegExp, Map, …) is opaque.
|
|
61
67
|
const proto = Object.getPrototypeOf(value);
|
|
62
68
|
if (proto !== Object.prototype && proto !== null) {
|
|
63
69
|
return 'unknown';
|
|
64
70
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
71
|
+
const rendered = new Map();
|
|
72
|
+
for (const [k, v] of Object.entries(value)) {
|
|
73
|
+
const e = env?.[k];
|
|
74
|
+
// A source-derived leaf type (a bare `process.env.X` read) WINS over the
|
|
75
|
+
// runtime value: that value is whatever the env var happened to hold at
|
|
76
|
+
// gen time (often a real string, often `undefined`), so trusting it would
|
|
77
|
+
// make the emitted type flip with the ambient environment — `string` on a
|
|
78
|
+
// machine where the var is set, `string | undefined` where it isn't, and
|
|
79
|
+
// spurious `generatetypes --check` drift between them. The source says
|
|
80
|
+
// `string | undefined`; that's the honest, environment-independent type.
|
|
81
|
+
// Deliberate edge: if a NODE_ENV-specific file hard-codes a key that the
|
|
82
|
+
// base file reads from env, the env shape still wins (`string |
|
|
83
|
+
// undefined`) even though the override makes it always defined — a rare
|
|
84
|
+
// pattern, and erring nullable is safe (a guard, never a wrong value).
|
|
85
|
+
if (typeof e === 'string') {
|
|
86
|
+
rendered.set(k, e);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (v === undefined) {
|
|
90
|
+
continue; // recovered from a nested `env` shape below, if any
|
|
91
|
+
}
|
|
92
|
+
rendered.set(k, valueToTypeString(v, typeof e === 'object' ? e : undefined));
|
|
93
|
+
}
|
|
94
|
+
// Recover env-only keys that never appeared in the value (dropped because
|
|
95
|
+
// `undefined` at gen time, or a wholly env-only sub-object) — typed from
|
|
96
|
+
// the source, never from a value.
|
|
97
|
+
if (env) {
|
|
98
|
+
for (const [k, t] of Object.entries(env)) {
|
|
99
|
+
if (rendered.has(k)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
rendered.set(k, typeof t === 'string' ? t : envShapeToType(t));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (rendered.size === 0) {
|
|
67
106
|
return '{}';
|
|
68
107
|
}
|
|
69
|
-
const body =
|
|
70
|
-
.map(([k,
|
|
108
|
+
const body = Array.from(rendered)
|
|
109
|
+
.map(([k, t]) => `${JSON.stringify(k)}: ${t}`)
|
|
71
110
|
.join('; ');
|
|
72
111
|
return `{ ${body} }`;
|
|
73
112
|
}
|
|
@@ -75,11 +114,23 @@ function valueToTypeString(value) {
|
|
|
75
114
|
return 'unknown';
|
|
76
115
|
}
|
|
77
116
|
}
|
|
78
|
-
/** Render the `genTypes.d.ts` template text from config values + model paths.
|
|
79
|
-
|
|
117
|
+
/** Render the `genTypes.d.ts` template text from config values + model paths.
|
|
118
|
+
*
|
|
119
|
+
* `configPaths` (config name → contributing source files) is optional: when
|
|
120
|
+
* present, env-only keys dropped by the value pass are recovered from source
|
|
121
|
+
* (see {@link valueToTypeString}). Omitted by unit tests that pass raw values. */
|
|
122
|
+
export async function getTemplate(configs, modelPaths, configPaths) {
|
|
80
123
|
const dir = process.cwd();
|
|
124
|
+
// Parse each config's source(s) once for env-only keys (no value import).
|
|
125
|
+
const envByConfig = new Map();
|
|
126
|
+
if (configPaths) {
|
|
127
|
+
await Promise.all(Array.from(configPaths, async ([name, paths]) => {
|
|
128
|
+
const shapes = await Promise.all(paths.map(extractConfigEnvShape));
|
|
129
|
+
envByConfig.set(name, mergeEnvShapes(shapes));
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
81
132
|
const configTypes = Array.from(configs)
|
|
82
|
-
.map(([name, value]) => ` getConfig(configName: '${name}'): ${valueToTypeString(value)};`)
|
|
133
|
+
.map(([name, value]) => ` getConfig(configName: '${name}'): ${valueToTypeString(value, envByConfig.get(name))};`)
|
|
83
134
|
.join('\n');
|
|
84
135
|
// Detect `BaseModel` subclasses by parsing each model's source (no runtime
|
|
85
136
|
// import — codegen never loads the model graph / Mongoose). Result drives both
|
|
@@ -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,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;kFAEkF;AAClF,SAAS,mBAAmB,CAAC,GAAW,EAAE,MAAc;IACtD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,eAAe,MAAM,kCAAkC,GAAG,qDAAqD,CAChH,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC9C,CAAC;AAQD,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAS,EACT,MAA6B;IAE7B,MAAM,QAAQ,GAAG,MAAM,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AE,SAAS,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,OAAO,EAAE,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC;QACjD,WAAW,EAAE,MAAM,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,CAAC;KACpE,CAAC,CAAC,CACJ,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM;SACtB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT,CAAC,CAAC,WAAW;QACX,CAAC,CAAC,4BAA4B,CAAC,CAAC,IAAI,4CAA4C,CAAC,CAAC,OAAO,aAAa;QACtG,CAAC,CAAC,4BAA4B,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,OAAO,6BAA6B,CAC5F;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,+EAA+E;IAC/E,2EAA2E;IAC3E,6EAA6E;IAC7E,2EAA2E;IAC3E,mCAAmC;IACnC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC;IACzE,MAAM,WAAW,GAAG,SAAS;QAC3B,CAAC,CAAC;;;8DAGwD,SAAS,CAAC,OAAO;;;CAG9E;QACG,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;;;;;;QAMD,WAAW;QACX,UAAU;;;EAGhB,WAAW,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config env-key detection via AST. The value-based config type generator
|
|
3
|
+
* (`appTypes.ts`) renders each config's *runtime* shape — which is accurate for
|
|
4
|
+
* everything that has a value at gen time, but a key read straight from the
|
|
5
|
+
* environment with **no default** (`saltSecret: process.env.AUTH_SALT`) is
|
|
6
|
+
* `undefined` then, so it gets dropped from the generated type and every read
|
|
7
|
+
* needs an `as` cast.
|
|
8
|
+
*
|
|
9
|
+
* This module recovers exactly those keys by reading the config SOURCE: a bare
|
|
10
|
+
* `process.env.X` is always `string | undefined` regardless of whether the var
|
|
11
|
+
* happens to be set during codegen, so we can type it correctly without ever
|
|
12
|
+
* importing the value. Keys that DO have a value at gen time (a literal, or
|
|
13
|
+
* `process.env.X || default`) are left to the value-based pass — it already
|
|
14
|
+
* types them, including the default's contribution.
|
|
15
|
+
*
|
|
16
|
+
* No runtime import (Mongoose/secrets never load); parsed with `oxc-parser`,
|
|
17
|
+
* the same front-end the rest of codegen uses.
|
|
18
|
+
*
|
|
19
|
+
* Scope: only `process.env` reads written INLINE in a config's own default-
|
|
20
|
+
* exported object literal are recovered. A key whose env read lives in a spread-
|
|
21
|
+
* in base (`export default { ...frameworkConfig, … }`) or behind an indirection
|
|
22
|
+
* (`const x = process.env.Y; export default { x }`) is not followed across that
|
|
23
|
+
* boundary — it falls back to the value-based pass (i.e. dropped if `undefined`
|
|
24
|
+
* at gen time, as before this feature). Inline reads cover the common case (a
|
|
25
|
+
* project's own `apiKey: process.env.X`); cross-module spread resolution is
|
|
26
|
+
* deliberately out of scope.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Env-derived key types for one config, mirroring its nesting. A string leaf is
|
|
30
|
+
* the TypeScript type for that key (e.g. `'string | undefined'`); a nested
|
|
31
|
+
* object is a sub-shape.
|
|
32
|
+
*/
|
|
33
|
+
export type EnvShape = {
|
|
34
|
+
[key: string]: string | EnvShape;
|
|
35
|
+
};
|
|
36
|
+
/** Extract the env-only key types from one config source file. Any read/parse
|
|
37
|
+
* problem yields an empty shape — codegen then just falls back to value-based. */
|
|
38
|
+
export declare function extractConfigEnvShape(srcPath: string): Promise<EnvShape>;
|
|
39
|
+
/** Deep-merge the env shapes from a config's contributing files (default +
|
|
40
|
+
* NODE_ENV override) with `deepmerge`: later sources win, nested shapes merge
|
|
41
|
+
* key-wise — mirroring how the loader merges the values themselves. (Env shapes
|
|
42
|
+
* only ever hold string leaves and nested objects, never arrays, so the loader's
|
|
43
|
+
* array-replace option has nothing to apply to here.) */
|
|
44
|
+
export declare function mergeEnvShapes(shapes: EnvShape[]): EnvShape;
|
|
45
|
+
/** Render an {@link EnvShape} as a standalone TS type — used when a whole
|
|
46
|
+
* sub-object is env-only and absent from the runtime value. */
|
|
47
|
+
export declare function envShapeToType(shape: EnvShape): string;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config env-key detection via AST. The value-based config type generator
|
|
3
|
+
* (`appTypes.ts`) renders each config's *runtime* shape — which is accurate for
|
|
4
|
+
* everything that has a value at gen time, but a key read straight from the
|
|
5
|
+
* environment with **no default** (`saltSecret: process.env.AUTH_SALT`) is
|
|
6
|
+
* `undefined` then, so it gets dropped from the generated type and every read
|
|
7
|
+
* needs an `as` cast.
|
|
8
|
+
*
|
|
9
|
+
* This module recovers exactly those keys by reading the config SOURCE: a bare
|
|
10
|
+
* `process.env.X` is always `string | undefined` regardless of whether the var
|
|
11
|
+
* happens to be set during codegen, so we can type it correctly without ever
|
|
12
|
+
* importing the value. Keys that DO have a value at gen time (a literal, or
|
|
13
|
+
* `process.env.X || default`) are left to the value-based pass — it already
|
|
14
|
+
* types them, including the default's contribution.
|
|
15
|
+
*
|
|
16
|
+
* No runtime import (Mongoose/secrets never load); parsed with `oxc-parser`,
|
|
17
|
+
* the same front-end the rest of codegen uses.
|
|
18
|
+
*
|
|
19
|
+
* Scope: only `process.env` reads written INLINE in a config's own default-
|
|
20
|
+
* exported object literal are recovered. A key whose env read lives in a spread-
|
|
21
|
+
* in base (`export default { ...frameworkConfig, … }`) or behind an indirection
|
|
22
|
+
* (`const x = process.env.Y; export default { x }`) is not followed across that
|
|
23
|
+
* boundary — it falls back to the value-based pass (i.e. dropped if `undefined`
|
|
24
|
+
* at gen time, as before this feature). Inline reads cover the common case (a
|
|
25
|
+
* project's own `apiKey: process.env.X`); cross-module spread resolution is
|
|
26
|
+
* deliberately out of scope.
|
|
27
|
+
*/
|
|
28
|
+
import { promises as fs } from 'node:fs';
|
|
29
|
+
import merge from 'deepmerge';
|
|
30
|
+
import { parseSync } from 'oxc-parser';
|
|
31
|
+
/** True for `process.env.X` and `process.env['X']` (the dropped, no-default form). */
|
|
32
|
+
function isProcessEnv(node) {
|
|
33
|
+
return (node?.type === 'MemberExpression' &&
|
|
34
|
+
node.object?.type === 'MemberExpression' &&
|
|
35
|
+
node.object.object?.type === 'Identifier' &&
|
|
36
|
+
node.object.object.name === 'process' &&
|
|
37
|
+
node.object.property?.type === 'Identifier' &&
|
|
38
|
+
node.object.property.name === 'env');
|
|
39
|
+
}
|
|
40
|
+
/** Strip `as T` / `satisfies T` wrappers; report `!` so we can drop the `undefined`. */
|
|
41
|
+
function unwrap(node) {
|
|
42
|
+
let n = node;
|
|
43
|
+
let nonNull = false;
|
|
44
|
+
while (n?.type === 'TSAsExpression' ||
|
|
45
|
+
n?.type === 'TSSatisfiesExpression' ||
|
|
46
|
+
n?.type === 'TSNonNullExpression' ||
|
|
47
|
+
n?.type === 'ParenthesizedExpression') {
|
|
48
|
+
if (n.type === 'TSNonNullExpression') {
|
|
49
|
+
nonNull = true;
|
|
50
|
+
}
|
|
51
|
+
n = n.expression;
|
|
52
|
+
}
|
|
53
|
+
return { node: n, nonNull };
|
|
54
|
+
}
|
|
55
|
+
/** The env type contributed by a value expression, or null to defer to the
|
|
56
|
+
* value-based pass (literal, logical-with-default, function call, …). */
|
|
57
|
+
function envTypeOf(valueNode) {
|
|
58
|
+
const { node, nonNull } = unwrap(valueNode);
|
|
59
|
+
if (isProcessEnv(node)) {
|
|
60
|
+
// `process.env.X!` asserts the value is present → `string`; otherwise the
|
|
61
|
+
// honest type of an unset env var is `string | undefined`.
|
|
62
|
+
return nonNull ? 'string' : 'string | undefined';
|
|
63
|
+
}
|
|
64
|
+
if (node?.type === 'ObjectExpression') {
|
|
65
|
+
const nested = shapeOfObject(node);
|
|
66
|
+
return Object.keys(nested).length > 0 ? nested : null;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
/** Walk an object literal's properties into an {@link EnvShape} (env keys only). */
|
|
71
|
+
function shapeOfObject(obj) {
|
|
72
|
+
const shape = {};
|
|
73
|
+
for (const prop of obj.properties ?? []) {
|
|
74
|
+
if (prop.type !== 'Property') {
|
|
75
|
+
continue; // SpreadElement, methods — not statically env-typable here
|
|
76
|
+
}
|
|
77
|
+
let key = null;
|
|
78
|
+
if (!prop.computed && prop.key?.type === 'Identifier') {
|
|
79
|
+
key = prop.key.name;
|
|
80
|
+
}
|
|
81
|
+
else if (prop.key?.type === 'Literal' &&
|
|
82
|
+
typeof prop.key.value === 'string') {
|
|
83
|
+
key = prop.key.value;
|
|
84
|
+
}
|
|
85
|
+
if (key === null) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const t = envTypeOf(prop.value);
|
|
89
|
+
if (t !== null) {
|
|
90
|
+
shape[key] = t;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return shape;
|
|
94
|
+
}
|
|
95
|
+
/** Resolve a file's `export default` to its object literal (direct, via a
|
|
96
|
+
* `const`, or wrapped in `as`/`satisfies`). Returns null if not an object. */
|
|
97
|
+
function findDefaultExportObject(body) {
|
|
98
|
+
const def = body.find((n) => n.type === 'ExportDefaultDeclaration');
|
|
99
|
+
if (!def) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const { node } = unwrap(def.declaration);
|
|
103
|
+
if (node?.type === 'ObjectExpression') {
|
|
104
|
+
return node;
|
|
105
|
+
}
|
|
106
|
+
if (node?.type === 'Identifier') {
|
|
107
|
+
// `const cfg = {…}; export default cfg;`
|
|
108
|
+
for (const stmt of body) {
|
|
109
|
+
if (stmt.type !== 'VariableDeclaration') {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
for (const d of stmt.declarations ?? []) {
|
|
113
|
+
if (d.id?.type === 'Identifier' && d.id.name === node.name && d.init) {
|
|
114
|
+
const init = unwrap(d.init).node;
|
|
115
|
+
return init?.type === 'ObjectExpression' ? init : null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
/** Extract the env-only key types from one config source file. Any read/parse
|
|
123
|
+
* problem yields an empty shape — codegen then just falls back to value-based. */
|
|
124
|
+
export async function extractConfigEnvShape(srcPath) {
|
|
125
|
+
let source;
|
|
126
|
+
try {
|
|
127
|
+
source = await fs.readFile(srcPath, 'utf8');
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const { program } = parseSync(srcPath, source);
|
|
134
|
+
const obj = findDefaultExportObject(program.body);
|
|
135
|
+
return obj ? shapeOfObject(obj) : {};
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return {};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Deep-merge the env shapes from a config's contributing files (default +
|
|
142
|
+
* NODE_ENV override) with `deepmerge`: later sources win, nested shapes merge
|
|
143
|
+
* key-wise — mirroring how the loader merges the values themselves. (Env shapes
|
|
144
|
+
* only ever hold string leaves and nested objects, never arrays, so the loader's
|
|
145
|
+
* array-replace option has nothing to apply to here.) */
|
|
146
|
+
export function mergeEnvShapes(shapes) {
|
|
147
|
+
return shapes.length ? merge.all(shapes) : {};
|
|
148
|
+
}
|
|
149
|
+
/** Render an {@link EnvShape} as a standalone TS type — used when a whole
|
|
150
|
+
* sub-object is env-only and absent from the runtime value. */
|
|
151
|
+
export function envShapeToType(shape) {
|
|
152
|
+
const body = Object.entries(shape)
|
|
153
|
+
.map(([k, v]) => `${JSON.stringify(k)}: ${typeof v === 'string' ? v : envShapeToType(v)}`)
|
|
154
|
+
.join('; ');
|
|
155
|
+
return body ? `{ ${body} }` : '{}';
|
|
156
|
+
}
|
|
157
|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IAAI,CAAC,CAAC;IACd,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrC,CAAC"}
|
package/dist/codegen/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export { generateAppTypes, generateRouteTypesViaAst };
|
|
|
27
27
|
*/
|
|
28
28
|
export async function generateAll(app, logger, options = {}) {
|
|
29
29
|
// 1. Analyze everything first (pure text, no writes).
|
|
30
|
-
const appTypesText = await getTemplate(app.internalFilesCache.configs, app.internalFilesCache.modelPaths);
|
|
30
|
+
const appTypesText = await getTemplate(app.internalFilesCache.configs, app.internalFilesCache.modelPaths, app.internalFilesCache.configPaths);
|
|
31
31
|
const plan = await planRouteTypes(app, logger, { skipNonAnalyzable: true });
|
|
32
32
|
if (plan.needsBoot.length > 0) {
|
|
33
33
|
const names = plan.needsBoot.map((p) => path.basename(p)).join(', ');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAEL,gBAAgB,EAChB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,wBAAwB,EAExB,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;AAQtD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAS,EACT,MAA6B,EAC7B,UAA8B,EAAE;IAEhC,sDAAsD;IACtD,MAAM,YAAY,GAAG,MAAM,WAAW,CACpC,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAC9B,GAAG,CAAC,kBAAkB,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":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