@ir-kit/fn-schema-typescript 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +85 -0
- package/dist/aliases.d.ts +37 -0
- package/dist/aliases.d.ts.map +1 -0
- package/dist/aliases.js +468 -0
- package/dist/aliases.js.map +1 -0
- package/dist/discover.d.ts +24 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +284 -0
- package/dist/discover.js.map +1 -0
- package/dist/extractor.d.ts +9 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/extractor.js +94 -0
- package/dist/extractor.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/jsdoc.d.ts +4 -0
- package/dist/jsdoc.d.ts.map +1 -0
- package/dist/jsdoc.js +22 -0
- package/dist/jsdoc.js.map +1 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +344 -0
- package/dist/schema.js.map +1 -0
- package/dist/well-known.d.ts +17 -0
- package/dist/well-known.d.ts.map +1 -0
- package/dist/well-known.js +50 -0
- package/dist/well-known.js.map +1 -0
- package/package.json +68 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ahmed Rowaihi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @ir-kit/fn-schema-typescript
|
|
2
|
+
|
|
3
|
+
TypeScript extractor for fn-schema. The default TS implementation of the `Extractor` contract from `core`.
|
|
4
|
+
|
|
5
|
+
Most users don't import this directly — they use the [`cli`](../cli/README.md). Reach for the programmatic API when you're building tooling on top of fn-schema.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @ir-kit/fn-schema-typescript
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { extract } from "@ir-kit/fn-schema-typescript"
|
|
17
|
+
|
|
18
|
+
const result = await extract({
|
|
19
|
+
files: ["src/api/handlers.ts"],
|
|
20
|
+
tsConfigPath: "./tsconfig.json",
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
for (const sig of result.signatures) {
|
|
24
|
+
console.log(sig.id, sig.input, sig.output)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`extract` is a one-shot helper. For repeat calls (server endpoints, dev mode, watch), use [`createProject`](../core/README.md) from `core` directly with `typescript()` as the extractor — it keeps the ts-morph project warm.
|
|
29
|
+
|
|
30
|
+
## What it discovers
|
|
31
|
+
|
|
32
|
+
- `function foo() {}` declarations
|
|
33
|
+
- `const foo = () => {}` and `const foo = function() {}`
|
|
34
|
+
- Class methods (instance + static, exported classes)
|
|
35
|
+
- Object-literal members: `export const api = { create() {}, tag: () => {} }`
|
|
36
|
+
- Default-export arrows: `export default (input) => {}`
|
|
37
|
+
- Function and method overloads (configurable via `signature.overloads`)
|
|
38
|
+
- `this` parameter is auto-skipped
|
|
39
|
+
|
|
40
|
+
## What it extracts
|
|
41
|
+
|
|
42
|
+
- Multi-parameter functions — `signature.parameters` controls layout (`array` / `first-only` / `object`)
|
|
43
|
+
- Async returns — `Promise<T>` auto-unwrapped (toggle via `signature.unwrapPromise`)
|
|
44
|
+
- Generic functions — skipped by default (set `signature.generics: "erase"` to coerce to `unknown`)
|
|
45
|
+
- Branded types (`type X = string & { __brand: "X" }`) — phantom stripped, identity preserved when the keyword is on
|
|
46
|
+
- Well-known types canonicalized: `Date`, `URL`, `RegExp`, `File`, `Blob`, `Buffer`, `Uint8Array`, `ArrayBuffer`, `bigint`
|
|
47
|
+
- `symbol` and function-as-input → `NOT_REPRESENTABLE` diagnostic
|
|
48
|
+
|
|
49
|
+
## Filters
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
extract({
|
|
53
|
+
files: ["src/api/**/*.ts"],
|
|
54
|
+
include: {
|
|
55
|
+
exported: true,
|
|
56
|
+
name: /^create/,
|
|
57
|
+
jsDocTag: "schema",
|
|
58
|
+
kind: ["function", "method"],
|
|
59
|
+
},
|
|
60
|
+
exclude: { name: /^_/, jsDocTag: "internal" },
|
|
61
|
+
filter: (fn) => fn.async,
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## How the type resolution works
|
|
66
|
+
|
|
67
|
+
For each function we synthesize a virtual TS file alongside it:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// src/__fn_schema_virtual__/handlers_createUser.virtual.ts
|
|
71
|
+
import type { CreateUserInput, User } from "../handlers"
|
|
72
|
+
|
|
73
|
+
type __FnSchemaMap_Date = { readonly __fn_schema_marker: "Date" }
|
|
74
|
+
|
|
75
|
+
export type __In_0 = CreateUserInput
|
|
76
|
+
export type __Out__ = Awaited<Promise<User>>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
ts-json-schema-generator processes this like any other source file. Sentinel object types (`__FnSchemaMap_Date`, etc.) survive union flattening because they're structurally distinct from primitives. After generation, a post-process pass swaps each sentinel for its canonical schema and (optionally) attaches identity/transport/source-location keywords.
|
|
80
|
+
|
|
81
|
+
This indirection is what lets fn-schema reuse ts-json-schema-generator without forking it — we work around its inability to resolve `Parameters<typeof X>` and `import("path").Y` by emitting bare type identifiers and resolving cross-file imports ourselves.
|
|
82
|
+
|
|
83
|
+
## Diagnostics
|
|
84
|
+
|
|
85
|
+
Subscribe via `extract({ onDiagnostic: (d) => ... })` or read `result.diagnostics`. Codes are documented in [`core/README.md`](../core/README.md#diagnostics).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { JSONSchema } from "@ir-kit/fn-schema-core";
|
|
2
|
+
import { Node, type SourceFile, type Type, type TypeNode } from "ts-morph";
|
|
3
|
+
export type ImportKind = "named" | "default" | "namespace";
|
|
4
|
+
export interface AliasImport {
|
|
5
|
+
module: string;
|
|
6
|
+
name: string;
|
|
7
|
+
typeOnly: boolean;
|
|
8
|
+
kind: ImportKind;
|
|
9
|
+
}
|
|
10
|
+
export type AliasNote = {
|
|
11
|
+
kind: "well-known";
|
|
12
|
+
name: string;
|
|
13
|
+
defaultSchema?: JSONSchema;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "not-representable";
|
|
16
|
+
name: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "lossy";
|
|
19
|
+
name: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
};
|
|
22
|
+
export interface SourceLocation {
|
|
23
|
+
file: string;
|
|
24
|
+
line: number;
|
|
25
|
+
column: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolvedAlias {
|
|
28
|
+
text: string;
|
|
29
|
+
imports: AliasImport[];
|
|
30
|
+
hasUnresolvedGenerics: boolean;
|
|
31
|
+
notes: AliasNote[];
|
|
32
|
+
/** Per-named-type declaration sites — used for the source-location keyword. */
|
|
33
|
+
sources: Record<string, SourceLocation>;
|
|
34
|
+
}
|
|
35
|
+
export declare function resolveTypeExpression(node: Node, type: Type, hostFile: SourceFile, virtualDir: string, typeNode?: TypeNode): ResolvedAlias;
|
|
36
|
+
export declare function renderImports(imports: AliasImport[]): string;
|
|
37
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../src/aliases.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAEL,IAAI,EACJ,KAAK,UAAU,EAEf,KAAK,IAAI,EACT,KAAK,QAAQ,EAEd,MAAM,UAAU,CAAC;AAQlB,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAE3D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GACjB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,UAAU,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAUpD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACzC;AAKD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,QAAQ,GAClB,aAAa,CAiDf;AA+ZD,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CA0D5D"}
|
package/dist/aliases.js
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { Node, SyntaxKind, ts, } from "ts-morph";
|
|
3
|
+
import { LOSSY_REASONS, NOT_REPRESENTABLE, sentinelTypeAlias, WELL_KNOWN_NAMES, } from "./well-known.js";
|
|
4
|
+
const PRIMITIVE_DEFAULTS = {
|
|
5
|
+
string: { type: "string" },
|
|
6
|
+
number: { type: "number" },
|
|
7
|
+
boolean: { type: "boolean" },
|
|
8
|
+
null: { type: "null" },
|
|
9
|
+
bigint: { type: "integer" },
|
|
10
|
+
};
|
|
11
|
+
/** Use ts.TypeFlags directly — the numeric value drifts across TS releases. */
|
|
12
|
+
const SYMBOL_FLAGS = ts.TypeFlags.ESSymbol | ts.TypeFlags.UniqueESSymbol;
|
|
13
|
+
export function resolveTypeExpression(node, type, hostFile, virtualDir, typeNode) {
|
|
14
|
+
const acc = new ImportAccumulator(hostFile, virtualDir);
|
|
15
|
+
const notes = [];
|
|
16
|
+
const sources = {};
|
|
17
|
+
if (!type.isLiteral()) {
|
|
18
|
+
const flags = type.compilerType.flags;
|
|
19
|
+
if ((flags & SYMBOL_FLAGS) !== 0) {
|
|
20
|
+
notes.push({ kind: "not-representable", name: "symbol" });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (typeNode) {
|
|
24
|
+
collectFromTypeNode(typeNode, acc, notes, sources);
|
|
25
|
+
const { text, brand, primitive } = stripBrand(typeNode.getText());
|
|
26
|
+
if (brand) {
|
|
27
|
+
notes.push({
|
|
28
|
+
kind: "well-known",
|
|
29
|
+
name: brand,
|
|
30
|
+
defaultSchema: primitive ? PRIMITIVE_DEFAULTS[primitive] : undefined,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
text: rewriteWellKnown(text, notes),
|
|
35
|
+
imports: acc.toList(),
|
|
36
|
+
hasUnresolvedGenerics: typeContainsTypeParameter(type),
|
|
37
|
+
notes,
|
|
38
|
+
sources,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const text = type.getText(node);
|
|
42
|
+
if (text.includes("import(")) {
|
|
43
|
+
return rewriteImportQualifications(text, acc, hostFile, virtualDir, type, notes);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
text: rewriteWellKnown(text, notes),
|
|
47
|
+
imports: [],
|
|
48
|
+
hasUnresolvedGenerics: typeContainsTypeParameter(type),
|
|
49
|
+
notes,
|
|
50
|
+
sources,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
class ImportAccumulator {
|
|
54
|
+
hostFile;
|
|
55
|
+
entries = new Map();
|
|
56
|
+
virtualDirRef;
|
|
57
|
+
constructor(hostFile, virtualDir) {
|
|
58
|
+
this.hostFile = hostFile;
|
|
59
|
+
this.virtualDirRef = virtualDir;
|
|
60
|
+
}
|
|
61
|
+
addLocal(name, typeOnly = true, kind = "named") {
|
|
62
|
+
const spec = relSpecifier(this.hostFile.getFilePath(), this.virtualDirRef);
|
|
63
|
+
this.add(spec, name, typeOnly, kind);
|
|
64
|
+
}
|
|
65
|
+
addExternal(module, name, typeOnly = true, kind = "named") {
|
|
66
|
+
this.add(module, name, typeOnly, kind);
|
|
67
|
+
}
|
|
68
|
+
add(module, name, typeOnly, kind) {
|
|
69
|
+
let names = this.entries.get(module);
|
|
70
|
+
if (!names) {
|
|
71
|
+
names = new Map();
|
|
72
|
+
this.entries.set(module, names);
|
|
73
|
+
}
|
|
74
|
+
const prior = names.get(name);
|
|
75
|
+
names.set(name, {
|
|
76
|
+
typeOnly: prior?.typeOnly === false ? false : typeOnly,
|
|
77
|
+
kind: prior?.kind ?? kind,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
toList() {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (const [module, names] of this.entries) {
|
|
83
|
+
for (const [name, entry] of names) {
|
|
84
|
+
out.push({ module, name, typeOnly: entry.typeOnly, kind: entry.kind });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function collectFromTypeNode(node, acc, notes, sources) {
|
|
91
|
+
const visit = (n) => {
|
|
92
|
+
if (Node.isTypeReference(n)) {
|
|
93
|
+
const nameNode = n.getTypeName();
|
|
94
|
+
const ident = leftmostIdentifier(nameNode);
|
|
95
|
+
if (ident)
|
|
96
|
+
registerIdentifier(ident, acc, notes, sources);
|
|
97
|
+
}
|
|
98
|
+
else if (Node.isExpressionWithTypeArguments(n)) {
|
|
99
|
+
const expr = n.getExpression();
|
|
100
|
+
if (Node.isIdentifier(expr))
|
|
101
|
+
registerIdentifier(expr, acc, notes, sources);
|
|
102
|
+
}
|
|
103
|
+
n.forEachChild(visit);
|
|
104
|
+
};
|
|
105
|
+
visit(node);
|
|
106
|
+
}
|
|
107
|
+
function leftmostIdentifier(node) {
|
|
108
|
+
if (Node.isIdentifier(node))
|
|
109
|
+
return node;
|
|
110
|
+
if (Node.isQualifiedName(node))
|
|
111
|
+
return leftmostIdentifier(node.getLeft());
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
function registerIdentifier(ident, acc, notes, sources) {
|
|
115
|
+
if (!Node.isIdentifier(ident))
|
|
116
|
+
return;
|
|
117
|
+
const name = ident.getText();
|
|
118
|
+
if (isTsLibraryName(name))
|
|
119
|
+
return;
|
|
120
|
+
if (isTypeParameter(ident))
|
|
121
|
+
return;
|
|
122
|
+
const sourceFile = ident.getSourceFile();
|
|
123
|
+
const decls = ident.getSymbol()?.getDeclarations() ?? [];
|
|
124
|
+
for (const decl of decls) {
|
|
125
|
+
if (decl.getSourceFile().isDeclarationFile())
|
|
126
|
+
continue;
|
|
127
|
+
const target = canonicalDecl(decl);
|
|
128
|
+
if (!target)
|
|
129
|
+
continue;
|
|
130
|
+
const sf = target.getSourceFile();
|
|
131
|
+
const { line, column } = sf.getLineAndColumnAtPos(target.getStart());
|
|
132
|
+
sources[name] = { file: sf.getFilePath(), line, column };
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
const allAmbient = decls.length > 0 &&
|
|
136
|
+
decls.every((d) => d.getSourceFile().isDeclarationFile());
|
|
137
|
+
if (allAmbient && WELL_KNOWN_NAMES.has(name)) {
|
|
138
|
+
notes.push({ kind: "well-known", name });
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (allAmbient && NOT_REPRESENTABLE.has(name)) {
|
|
142
|
+
notes.push({ kind: "not-representable", name });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (allAmbient)
|
|
146
|
+
return;
|
|
147
|
+
for (const decl of decls) {
|
|
148
|
+
// Import bindings live in the host file, so check ImportDeclaration
|
|
149
|
+
// first — otherwise they'd be misclassified as host-declared.
|
|
150
|
+
const importDecl = decl.getFirstAncestorByKind(SyntaxKind.ImportDeclaration);
|
|
151
|
+
if (importDecl) {
|
|
152
|
+
const spec = importDecl.getModuleSpecifierValue();
|
|
153
|
+
if (spec) {
|
|
154
|
+
acc.addExternal(retargetSpecifier(spec, sourceFile, acc), exportedNameFromDecl(decl, name), true, importKindFromDecl(decl));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const declSf = decl.getSourceFile();
|
|
159
|
+
if (declSf === sourceFile || !declSf.isDeclarationFile()) {
|
|
160
|
+
const branded = detectBrandedAlias(decl);
|
|
161
|
+
if (branded) {
|
|
162
|
+
notes.push({
|
|
163
|
+
kind: "well-known",
|
|
164
|
+
name,
|
|
165
|
+
defaultSchema: branded.primitive
|
|
166
|
+
? PRIMITIVE_DEFAULTS[branded.primitive]
|
|
167
|
+
: undefined,
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (declSf === sourceFile) {
|
|
172
|
+
acc.addLocal(name, true, "named");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
acc.addLocal(name, true, "named");
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (declSf.isDeclarationFile())
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Follow import bindings up to the original declaration so source locations
|
|
183
|
+
* point at the actual definition, not the import site in the host file. */
|
|
184
|
+
function canonicalDecl(decl) {
|
|
185
|
+
if (Node.isImportSpecifier(decl) ||
|
|
186
|
+
Node.isImportClause(decl) ||
|
|
187
|
+
Node.isNamespaceImport(decl)) {
|
|
188
|
+
const sym = decl.getSymbol();
|
|
189
|
+
if (!sym)
|
|
190
|
+
return decl;
|
|
191
|
+
const aliasedSym = sym.getAliasedSymbol?.();
|
|
192
|
+
if (!aliasedSym)
|
|
193
|
+
return decl;
|
|
194
|
+
const target = aliasedSym.getDeclarations()[0];
|
|
195
|
+
return target ?? decl;
|
|
196
|
+
}
|
|
197
|
+
return decl;
|
|
198
|
+
}
|
|
199
|
+
/** `import { Foo as Bar }` — the virtual file uses the exported name `Foo`. */
|
|
200
|
+
function exportedNameFromDecl(decl, fallback) {
|
|
201
|
+
if (Node.isImportSpecifier(decl)) {
|
|
202
|
+
const propertyName = decl.compilerNode.propertyName;
|
|
203
|
+
if (propertyName)
|
|
204
|
+
return propertyName.text;
|
|
205
|
+
}
|
|
206
|
+
return fallback;
|
|
207
|
+
}
|
|
208
|
+
/** Relative specifiers in the host get re-expressed against the virtual file's directory. */
|
|
209
|
+
function retargetSpecifier(spec, hostFile, acc) {
|
|
210
|
+
if (!spec.startsWith(".") && !spec.startsWith("/"))
|
|
211
|
+
return spec;
|
|
212
|
+
const hostDir = path.dirname(hostFile.getFilePath());
|
|
213
|
+
const abs = path.resolve(hostDir, spec).replace(/\.(m|c)?js$/, "");
|
|
214
|
+
return relSpecifierFromAbs(abs, acc.virtualDirRef);
|
|
215
|
+
}
|
|
216
|
+
function importKindFromDecl(decl) {
|
|
217
|
+
if (Node.isImportSpecifier(decl))
|
|
218
|
+
return "named";
|
|
219
|
+
if (Node.isNamespaceImport(decl))
|
|
220
|
+
return "namespace";
|
|
221
|
+
if (Node.isImportClause(decl))
|
|
222
|
+
return "default";
|
|
223
|
+
return "named";
|
|
224
|
+
}
|
|
225
|
+
function isTypeParameter(ident) {
|
|
226
|
+
const sym = ident.getSymbol();
|
|
227
|
+
if (!sym)
|
|
228
|
+
return false;
|
|
229
|
+
for (const decl of sym.getDeclarations()) {
|
|
230
|
+
if (decl.getKind() === SyntaxKind.TypeParameter)
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
function isTsLibraryName(name) {
|
|
236
|
+
return TS_LIB.has(name);
|
|
237
|
+
}
|
|
238
|
+
const TS_LIB = new Set([
|
|
239
|
+
"Array",
|
|
240
|
+
"ReadonlyArray",
|
|
241
|
+
"Record",
|
|
242
|
+
"Readonly",
|
|
243
|
+
"Partial",
|
|
244
|
+
"Required",
|
|
245
|
+
"Pick",
|
|
246
|
+
"Omit",
|
|
247
|
+
"Exclude",
|
|
248
|
+
"Extract",
|
|
249
|
+
"NonNullable",
|
|
250
|
+
"Parameters",
|
|
251
|
+
"ConstructorParameters",
|
|
252
|
+
"ReturnType",
|
|
253
|
+
"InstanceType",
|
|
254
|
+
"ThisParameterType",
|
|
255
|
+
"OmitThisParameter",
|
|
256
|
+
"Awaited",
|
|
257
|
+
"Promise",
|
|
258
|
+
"Map",
|
|
259
|
+
"Set",
|
|
260
|
+
"WeakMap",
|
|
261
|
+
"WeakSet",
|
|
262
|
+
"Error",
|
|
263
|
+
"String",
|
|
264
|
+
"Number",
|
|
265
|
+
"Boolean",
|
|
266
|
+
"Object",
|
|
267
|
+
"Function",
|
|
268
|
+
"Uppercase",
|
|
269
|
+
"Lowercase",
|
|
270
|
+
"Capitalize",
|
|
271
|
+
"Uncapitalize",
|
|
272
|
+
]);
|
|
273
|
+
function typeContainsTypeParameter(type) {
|
|
274
|
+
if (type.isTypeParameter())
|
|
275
|
+
return true;
|
|
276
|
+
if (type.getTypeArguments().some(typeContainsTypeParameter))
|
|
277
|
+
return true;
|
|
278
|
+
if (type.getUnionTypes().some(typeContainsTypeParameter))
|
|
279
|
+
return true;
|
|
280
|
+
if (type.getIntersectionTypes().some(typeContainsTypeParameter))
|
|
281
|
+
return true;
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
function rewriteImportQualifications(text, acc, hostFile, virtualDir, _type, notes) {
|
|
285
|
+
const importRe = /import\("([^"]+)"\)\.([A-Za-z_$][\w$]*)/g;
|
|
286
|
+
const rewritten = text.replace(importRe, (_match, modulePath, name) => {
|
|
287
|
+
const hostNoExt = hostFile.getFilePath().replace(/\.tsx?$/, "");
|
|
288
|
+
if (path.normalize(modulePath) === path.normalize(hostNoExt)) {
|
|
289
|
+
acc.addLocal(name);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
acc.addExternal(relSpecifierFromAbs(modulePath, virtualDir), name);
|
|
293
|
+
}
|
|
294
|
+
return name;
|
|
295
|
+
});
|
|
296
|
+
return {
|
|
297
|
+
text: rewriteWellKnown(rewritten, notes),
|
|
298
|
+
imports: acc.toList(),
|
|
299
|
+
hasUnresolvedGenerics: false,
|
|
300
|
+
notes,
|
|
301
|
+
sources: {},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** Substitute well-known names with sentinels, but skip text inside string
|
|
305
|
+
* literals so `"Date" | "URL"` literal-type unions stay intact. */
|
|
306
|
+
function rewriteWellKnown(text, notes) {
|
|
307
|
+
const parts = splitOutsideStrings(text);
|
|
308
|
+
const dynamicNames = new Set(notes.filter((n) => n.kind === "well-known").map((n) => n.name));
|
|
309
|
+
const lossySeen = new Set(notes.filter((n) => n.kind === "lossy").map((n) => n.name));
|
|
310
|
+
const allNames = new Set([...WELL_KNOWN_NAMES, ...dynamicNames]);
|
|
311
|
+
return parts
|
|
312
|
+
.map((part) => {
|
|
313
|
+
if (part.kind === "string")
|
|
314
|
+
return part.text;
|
|
315
|
+
let out = part.text;
|
|
316
|
+
for (const name of allNames) {
|
|
317
|
+
const re = new RegExp(`\\b${escapeRegExp(name)}\\b`, "g");
|
|
318
|
+
if (re.test(out)) {
|
|
319
|
+
if (!dynamicNames.has(name)) {
|
|
320
|
+
notes.push({ kind: "well-known", name });
|
|
321
|
+
dynamicNames.add(name);
|
|
322
|
+
}
|
|
323
|
+
const lossyReason = LOSSY_REASONS[name];
|
|
324
|
+
if (lossyReason && !lossySeen.has(name)) {
|
|
325
|
+
notes.push({ kind: "lossy", name, reason: lossyReason });
|
|
326
|
+
lossySeen.add(name);
|
|
327
|
+
}
|
|
328
|
+
out = out.replace(new RegExp(`\\b${escapeRegExp(name)}\\b`, "g"), sentinelTypeAlias(name));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return out;
|
|
332
|
+
})
|
|
333
|
+
.join("");
|
|
334
|
+
}
|
|
335
|
+
function splitOutsideStrings(text) {
|
|
336
|
+
const out = [];
|
|
337
|
+
let buf = "";
|
|
338
|
+
let i = 0;
|
|
339
|
+
while (i < text.length) {
|
|
340
|
+
const c = text[i];
|
|
341
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
342
|
+
if (buf) {
|
|
343
|
+
out.push({ kind: "code", text: buf });
|
|
344
|
+
buf = "";
|
|
345
|
+
}
|
|
346
|
+
let lit = c;
|
|
347
|
+
i++;
|
|
348
|
+
while (i < text.length) {
|
|
349
|
+
const k = text[i];
|
|
350
|
+
lit += k;
|
|
351
|
+
i++;
|
|
352
|
+
if (k === "\\" && i < text.length) {
|
|
353
|
+
lit += text[i];
|
|
354
|
+
i++;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (k === c)
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
out.push({ kind: "string", text: lit });
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
buf += c;
|
|
364
|
+
i++;
|
|
365
|
+
}
|
|
366
|
+
if (buf)
|
|
367
|
+
out.push({ kind: "code", text: buf });
|
|
368
|
+
return out;
|
|
369
|
+
}
|
|
370
|
+
function stripBrand(text) {
|
|
371
|
+
const brandRe = /^(.+?)\s*&\s*\{\s*(?:readonly\s+)?(?:__brand|_brand|brand|kind)\s*:\s*(["'])(.*?)\2\s*;?\s*\}\s*$/;
|
|
372
|
+
const m = text.match(brandRe);
|
|
373
|
+
if (!m)
|
|
374
|
+
return { text, brand: null, primitive: null };
|
|
375
|
+
const stripped = m[1].trim();
|
|
376
|
+
return { text: stripped, brand: m[3], primitive: stripped };
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Detect named branded aliases (`type UserId = string & { __brand: "UserId" }`).
|
|
380
|
+
* The brand-text regex only catches inline forms; this resolves the alias's
|
|
381
|
+
* RHS via ts-morph and runs the same matcher against it.
|
|
382
|
+
*/
|
|
383
|
+
function detectBrandedAlias(decl) {
|
|
384
|
+
if (!Node.isTypeAliasDeclaration(decl))
|
|
385
|
+
return null;
|
|
386
|
+
const rhs = decl.getTypeNode();
|
|
387
|
+
if (!rhs)
|
|
388
|
+
return null;
|
|
389
|
+
const { brand, primitive } = stripBrand(rhs.getText());
|
|
390
|
+
if (!brand)
|
|
391
|
+
return null;
|
|
392
|
+
return { brand, primitive };
|
|
393
|
+
}
|
|
394
|
+
function escapeRegExp(s) {
|
|
395
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
396
|
+
}
|
|
397
|
+
function relSpecifier(absHostFile, virtualDir) {
|
|
398
|
+
const noExt = absHostFile.replace(/\.tsx?$/, "");
|
|
399
|
+
return relSpecifierFromAbs(noExt, virtualDir);
|
|
400
|
+
}
|
|
401
|
+
function relSpecifierFromAbs(absPath, virtualDir) {
|
|
402
|
+
let rel = path.relative(virtualDir, absPath).replace(/\\/g, "/");
|
|
403
|
+
if (!rel.startsWith("."))
|
|
404
|
+
rel = `./${rel}`;
|
|
405
|
+
return rel;
|
|
406
|
+
}
|
|
407
|
+
export function renderImports(imports) {
|
|
408
|
+
if (imports.length === 0)
|
|
409
|
+
return "";
|
|
410
|
+
const byModule = new Map();
|
|
411
|
+
for (const imp of imports) {
|
|
412
|
+
let bucket = byModule.get(imp.module);
|
|
413
|
+
if (!bucket) {
|
|
414
|
+
bucket = {
|
|
415
|
+
named: { type: [], value: [] },
|
|
416
|
+
default: { type: null, value: null },
|
|
417
|
+
namespace: { type: null, value: null },
|
|
418
|
+
};
|
|
419
|
+
byModule.set(imp.module, bucket);
|
|
420
|
+
}
|
|
421
|
+
if (imp.kind === "named") {
|
|
422
|
+
(imp.typeOnly ? bucket.named.type : bucket.named.value).push(imp.name);
|
|
423
|
+
}
|
|
424
|
+
else if (imp.kind === "default") {
|
|
425
|
+
if (imp.typeOnly)
|
|
426
|
+
bucket.default.type = imp.name;
|
|
427
|
+
else
|
|
428
|
+
bucket.default.value = imp.name;
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
if (imp.typeOnly)
|
|
432
|
+
bucket.namespace.type = imp.name;
|
|
433
|
+
else
|
|
434
|
+
bucket.namespace.value = imp.name;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const lines = [];
|
|
438
|
+
for (const [module, bucket] of byModule) {
|
|
439
|
+
// Default + named on the same line: `import D, { A, B } from "x"` is
|
|
440
|
+
// valid TS, but mixing type-only is not — keep them on separate lines
|
|
441
|
+
// for simplicity and TS strictness.
|
|
442
|
+
if (bucket.namespace.value) {
|
|
443
|
+
lines.push(`import * as ${bucket.namespace.value} from "${module}";`);
|
|
444
|
+
}
|
|
445
|
+
if (bucket.namespace.type) {
|
|
446
|
+
lines.push(`import type * as ${bucket.namespace.type} from "${module}";`);
|
|
447
|
+
}
|
|
448
|
+
if (bucket.default.value) {
|
|
449
|
+
lines.push(`import ${bucket.default.value} from "${module}";`);
|
|
450
|
+
}
|
|
451
|
+
if (bucket.default.type) {
|
|
452
|
+
lines.push(`import type ${bucket.default.type} from "${module}";`);
|
|
453
|
+
}
|
|
454
|
+
const valueNames = unique(bucket.named.value);
|
|
455
|
+
const typeNames = unique(bucket.named.type);
|
|
456
|
+
if (valueNames.length > 0) {
|
|
457
|
+
lines.push(`import { ${valueNames.join(", ")} } from "${module}";`);
|
|
458
|
+
}
|
|
459
|
+
if (typeNames.length > 0) {
|
|
460
|
+
lines.push(`import type { ${typeNames.join(", ")} } from "${module}";`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return lines.join("\n");
|
|
464
|
+
}
|
|
465
|
+
function unique(xs) {
|
|
466
|
+
return Array.from(new Set(xs));
|
|
467
|
+
}
|
|
468
|
+
//# sourceMappingURL=aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aliases.js","sourceRoot":"","sources":["../src/aliases.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAEL,IAAI,EAEJ,UAAU,EAGV,EAAE,GACH,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,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AM,IAAI,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,MAAM,CAAC,EAAY;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FunctionInfo, ParameterInfo } from "@ir-kit/fn-schema-core";
|
|
2
|
+
import { type Project as TsMorphProject } from "ts-morph";
|
|
3
|
+
import { type ResolvedAlias } from "./aliases.js";
|
|
4
|
+
export interface ResolvedParameter extends ParameterInfo {
|
|
5
|
+
alias: ResolvedAlias;
|
|
6
|
+
}
|
|
7
|
+
export interface OverloadSignature {
|
|
8
|
+
parameters: ResolvedParameter[];
|
|
9
|
+
returnAlias: ResolvedAlias;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Pre-resolved handle the schema step assembles into a virtual file. The
|
|
13
|
+
* implementation signature is mirrored at the top level for convenience;
|
|
14
|
+
* `overloads` always includes it as its last entry.
|
|
15
|
+
*/
|
|
16
|
+
export interface DiscoveredFunction extends FunctionInfo {
|
|
17
|
+
sourceFilePath: string;
|
|
18
|
+
importable: boolean;
|
|
19
|
+
resolvedParameters: ResolvedParameter[];
|
|
20
|
+
returnAlias: ResolvedAlias;
|
|
21
|
+
overloads: OverloadSignature[];
|
|
22
|
+
}
|
|
23
|
+
export declare function discoverFunctions(project: TsMorphProject, files: readonly string[], virtualDirFor: (sourceFile: string) => string): DiscoveredFunction[];
|
|
24
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../src/discover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAEZ,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAYL,KAAK,OAAO,IAAI,cAAc,EAE/B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,cAAc,CAAC;AAGzE,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,WAAW,EAAE,aAAa,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,WAAW,EAAE,aAAa,CAAC;IAC3B,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAC5C,kBAAkB,EAAE,CAQtB"}
|