@deepseek-ai/dsh-typert-generator 0.0.1-rc.1
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 +28 -0
- package/README.i18n.yaml +6 -0
- package/README.md +41 -0
- package/README.zh.md +41 -0
- package/lib/index.js +3922 -0
- package/lib/invariant.js +24 -0
- package/lib/types/analyzer.d.ts +143 -0
- package/lib/types/analyzer.js +2723 -0
- package/lib/types/cordis-catalog.d.ts +148 -0
- package/lib/types/cordis-catalog.js +695 -0
- package/lib/types/emitter.d.ts +55 -0
- package/lib/types/emitter.js +745 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/index.js +12 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/invariant.js +23 -0
- package/lib/types/model.d.ts +409 -0
- package/lib/types/model.js +48 -0
- package/lib/types/renderer.d.ts +90 -0
- package/lib/types/renderer.js +351 -0
- package/lib/types/tsdown-plugin.d.ts +34 -0
- package/lib/types/tsdown-plugin.js +136 -0
- package/lib/types/workspace.d.ts +36 -0
- package/lib/types/workspace.js +114 -0
- package/package.json +54 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of the Typert analyzer, compiler-independent model, and
|
|
3
|
+
* model-driven artifact emitters. Build wiring lives in the `./tsdown`
|
|
4
|
+
* subpath.
|
|
5
|
+
* @module @deepseek-ai/dsh-typert-generator
|
|
6
|
+
*/
|
|
7
|
+
export { WorkspaceAnalyzer, WorkspaceCaches, TypertAnalysisError } from './analyzer.ts';
|
|
8
|
+
export type { AnalysisMode, DiscoveredTypertPackage, WorkspaceAnalyzerOptions } from './analyzer.ts';
|
|
9
|
+
export { FaceModelEmitter, TypertEmitError } from './emitter.ts';
|
|
10
|
+
export type { ModelEmitResult } from './emitter.ts';
|
|
11
|
+
export * from './cordis-catalog.ts';
|
|
12
|
+
export { TypeGraphRenderer, TypeGraphRenderError } from './renderer.ts';
|
|
13
|
+
export { WorkspaceTypertGenerator } from './workspace.ts';
|
|
14
|
+
export type { WorkspaceEmitResult } from './workspace.ts';
|
|
15
|
+
export type * from './model.ts';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public surface of the Typert analyzer, compiler-independent model, and
|
|
3
|
+
* model-driven artifact emitters. Build wiring lives in the `./tsdown`
|
|
4
|
+
* subpath.
|
|
5
|
+
* @module @deepseek-ai/dsh-typert-generator
|
|
6
|
+
*/
|
|
7
|
+
export { WorkspaceAnalyzer, WorkspaceCaches, TypertAnalysisError } from "./analyzer.js";
|
|
8
|
+
export { FaceModelEmitter, TypertEmitError } from "./emitter.js";
|
|
9
|
+
export * from "./cordis-catalog.js";
|
|
10
|
+
export { TypeGraphRenderer, TypeGraphRenderError } from "./renderer.js";
|
|
11
|
+
export { WorkspaceTypertGenerator } from "./workspace.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-typert-generator`.
|
|
3
|
+
* @module @deepseek-ai/dsh-typert-generator/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "typert-generator-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-typert-generator`.
|
|
3
|
+
* @module @deepseek-ai/dsh-typert-generator/invariant
|
|
4
|
+
*/
|
|
5
|
+
const PACKAGE_NAME = '@deepseek-ai/dsh-typert-generator';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export const name = 'typert-generator-invariant';
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export const inject = ['invariants'];
|
|
10
|
+
/**
|
|
11
|
+
* No runtime invariant: this source-project analyzer and build-time emitter
|
|
12
|
+
* runs outside any cordis runtime; model snapshots, executable artifacts, and
|
|
13
|
+
* consuming-package typechecks enforce its output contract.
|
|
14
|
+
*/
|
|
15
|
+
const install = () => { };
|
|
16
|
+
/**
|
|
17
|
+
* Register this package's invariant companion.
|
|
18
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
+
*/
|
|
21
|
+
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
+
/* jscpd:ignore-end */
|
|
23
|
+
//# sourceMappingURL=invariant.js.map
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler-independent Typert analysis model. TypeScript nodes and checker
|
|
3
|
+
* objects are extraction inputs only; emitters consume this graph.
|
|
4
|
+
* @module @deepseek-ai/dsh-typert-generator/model
|
|
5
|
+
*/
|
|
6
|
+
/** One independently compiled side of the workspace. */
|
|
7
|
+
export type TypertFace = 'host' | 'client';
|
|
8
|
+
/** Stable graph-local identifier of a type expression. */
|
|
9
|
+
export type TypeNodeId = string;
|
|
10
|
+
/** Stable workspace identifier of a declared symbol. */
|
|
11
|
+
export type SymbolId = string;
|
|
12
|
+
/** Keyword types accepted in ordinary TypeScript source declarations. */
|
|
13
|
+
export type KeywordTypeName = 'any' | 'bigint' | 'boolean' | 'never' | 'number' | 'object' | 'string' | 'symbol' | 'undefined' | 'unknown' | 'void';
|
|
14
|
+
/** Prefix operators accepted on TypeScript type nodes. */
|
|
15
|
+
export type TypeOperatorName = 'keyof' | 'readonly' | 'unique';
|
|
16
|
+
/** Source position retained for diagnostics and source-edit mode. */
|
|
17
|
+
export interface SourceLocation {
|
|
18
|
+
readonly file: string;
|
|
19
|
+
readonly line: number;
|
|
20
|
+
readonly column: number;
|
|
21
|
+
}
|
|
22
|
+
/** One public package export and the declaration it resolves to. */
|
|
23
|
+
export interface ExportModel {
|
|
24
|
+
readonly subpath: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly symbol: SymbolId;
|
|
27
|
+
readonly aliases: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/** One structured JSDoc tag, retaining its original text for unknown tags. */
|
|
30
|
+
export interface JsDocTagModel {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly argument?: string;
|
|
33
|
+
readonly comment?: string;
|
|
34
|
+
readonly text: string;
|
|
35
|
+
}
|
|
36
|
+
/** JSDoc retained as a standard part of every documented model element. */
|
|
37
|
+
export interface DocumentationModel {
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
readonly summary?: string;
|
|
40
|
+
readonly tags: readonly JsDocTagModel[];
|
|
41
|
+
readonly jsDoc?: string;
|
|
42
|
+
}
|
|
43
|
+
/** One Cordis Context contribution. */
|
|
44
|
+
export interface ServiceModel extends DocumentationModel {
|
|
45
|
+
readonly key: string;
|
|
46
|
+
readonly symbol: SymbolId;
|
|
47
|
+
readonly export: ExportModel;
|
|
48
|
+
readonly members: readonly string[];
|
|
49
|
+
readonly location: SourceLocation;
|
|
50
|
+
}
|
|
51
|
+
/** One Cordis Events contribution. */
|
|
52
|
+
export interface EventModel extends DocumentationModel {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly signature: TypeNodeId;
|
|
55
|
+
/** Body-free declaration text retained for byte-stable source projections. */
|
|
56
|
+
readonly text: string;
|
|
57
|
+
readonly mode?: string;
|
|
58
|
+
readonly location: SourceLocation;
|
|
59
|
+
}
|
|
60
|
+
/** One explicitly exported reference-passed object. */
|
|
61
|
+
export interface ObjectModel extends DocumentationModel {
|
|
62
|
+
readonly export: ExportModel;
|
|
63
|
+
readonly symbol: SymbolId;
|
|
64
|
+
readonly passing: 'reference';
|
|
65
|
+
}
|
|
66
|
+
/** One explicitly selected value type for schema generation. */
|
|
67
|
+
export interface SchemaModel extends DocumentationModel {
|
|
68
|
+
readonly export: ExportModel;
|
|
69
|
+
readonly symbol: SymbolId;
|
|
70
|
+
readonly type: TypeNodeId;
|
|
71
|
+
}
|
|
72
|
+
/** One public business type import retained for a generated Remote declaration. */
|
|
73
|
+
export interface RemoteTypeImportModel {
|
|
74
|
+
readonly symbol: SymbolId;
|
|
75
|
+
readonly specifier: string;
|
|
76
|
+
readonly name: string;
|
|
77
|
+
}
|
|
78
|
+
/** One strict wire boundary and the public symbols needed to name it. */
|
|
79
|
+
export interface RemoteBoundaryModel {
|
|
80
|
+
/** Authored public type retained for generated consumer declarations. */
|
|
81
|
+
readonly type: TypeNodeId;
|
|
82
|
+
/** Checker-resolved projection used only to emit the runtime codec. */
|
|
83
|
+
readonly codecType: TypeNodeId;
|
|
84
|
+
readonly typeSymbol: string;
|
|
85
|
+
readonly imports: readonly RemoteTypeImportModel[];
|
|
86
|
+
}
|
|
87
|
+
/** One ordered business argument projected onto a Remote wire field. */
|
|
88
|
+
export interface InvocationParameterModel {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly wire: string;
|
|
91
|
+
readonly source: 'json' | 'lookup';
|
|
92
|
+
readonly lookup?: string;
|
|
93
|
+
readonly boundary: RemoteBoundaryModel;
|
|
94
|
+
}
|
|
95
|
+
/** One strictly analyzed Host method exported through TypeRT Gateway. */
|
|
96
|
+
export interface InvocationModel {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
readonly service: string;
|
|
99
|
+
readonly namespace: string;
|
|
100
|
+
readonly method: string;
|
|
101
|
+
readonly implementation?: string;
|
|
102
|
+
readonly invocation: {
|
|
103
|
+
readonly kind: 'direct';
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: 'context';
|
|
106
|
+
readonly context: string;
|
|
107
|
+
readonly wire: string;
|
|
108
|
+
readonly boundary: RemoteBoundaryModel;
|
|
109
|
+
};
|
|
110
|
+
readonly scope?: {
|
|
111
|
+
readonly context: string;
|
|
112
|
+
readonly wire: string;
|
|
113
|
+
};
|
|
114
|
+
readonly parameters: readonly InvocationParameterModel[];
|
|
115
|
+
readonly cancellation?: {
|
|
116
|
+
readonly parameter: 'signal';
|
|
117
|
+
};
|
|
118
|
+
readonly result: RemoteBoundaryModel;
|
|
119
|
+
readonly location: SourceLocation;
|
|
120
|
+
}
|
|
121
|
+
/** Business semantics discovered in one package on one face. */
|
|
122
|
+
export interface PackageModel {
|
|
123
|
+
readonly name: string;
|
|
124
|
+
readonly root: string;
|
|
125
|
+
readonly exports: readonly ExportModel[];
|
|
126
|
+
readonly services: readonly ServiceModel[];
|
|
127
|
+
readonly events: readonly EventModel[];
|
|
128
|
+
readonly objects: readonly ObjectModel[];
|
|
129
|
+
readonly schemas: readonly SchemaModel[];
|
|
130
|
+
readonly invocations: readonly InvocationModel[];
|
|
131
|
+
}
|
|
132
|
+
/** One explicit import/re-export edge between independently compiled faces. */
|
|
133
|
+
export interface CrossFaceLink {
|
|
134
|
+
readonly fromFace: TypertFace;
|
|
135
|
+
readonly fromPackage: string;
|
|
136
|
+
readonly toFace: TypertFace;
|
|
137
|
+
readonly toPackage: string;
|
|
138
|
+
readonly subpath: string;
|
|
139
|
+
readonly name: string;
|
|
140
|
+
}
|
|
141
|
+
/** Complete analysis result for an independently compiled face. */
|
|
142
|
+
export interface FaceModel {
|
|
143
|
+
readonly face: TypertFace;
|
|
144
|
+
readonly packages: readonly PackageModel[];
|
|
145
|
+
readonly graph: TypeGraph;
|
|
146
|
+
}
|
|
147
|
+
/** Complete host/client analysis result. */
|
|
148
|
+
export interface WorkspaceModel {
|
|
149
|
+
readonly faces: readonly FaceModel[];
|
|
150
|
+
readonly crossFaceLinks: readonly CrossFaceLink[];
|
|
151
|
+
}
|
|
152
|
+
/** One top-level authored type declaration indexed without making it a graph root. */
|
|
153
|
+
export interface SourceDeclarationModel {
|
|
154
|
+
readonly face: TypertFace;
|
|
155
|
+
readonly package: string;
|
|
156
|
+
readonly name: string;
|
|
157
|
+
readonly kind: 'interface' | 'class' | 'alias' | 'enum';
|
|
158
|
+
readonly location: SourceLocation;
|
|
159
|
+
readonly text: string;
|
|
160
|
+
}
|
|
161
|
+
/** Visibility recorded on class members. */
|
|
162
|
+
export type MemberVisibility = 'public' | 'protected' | 'private';
|
|
163
|
+
/** One generic type parameter, preserving its pre-evaluation constraint/default. */
|
|
164
|
+
export interface TypeParameterModel {
|
|
165
|
+
readonly id: string;
|
|
166
|
+
readonly name: string;
|
|
167
|
+
readonly const: boolean;
|
|
168
|
+
readonly constraint?: TypeNodeId;
|
|
169
|
+
readonly default?: TypeNodeId;
|
|
170
|
+
readonly variance?: 'in' | 'out' | 'in-out';
|
|
171
|
+
}
|
|
172
|
+
/** One function-like parameter. */
|
|
173
|
+
export interface ParameterModel {
|
|
174
|
+
readonly name: string;
|
|
175
|
+
readonly binding: 'identifier' | 'object' | 'array';
|
|
176
|
+
readonly type: TypeNodeId;
|
|
177
|
+
readonly optional: boolean;
|
|
178
|
+
readonly rest: boolean;
|
|
179
|
+
readonly receiver: boolean;
|
|
180
|
+
readonly initializer?: string;
|
|
181
|
+
}
|
|
182
|
+
/** A function/call/construct signature. */
|
|
183
|
+
export interface SignatureModel {
|
|
184
|
+
readonly typeParameters: readonly TypeParameterModel[];
|
|
185
|
+
readonly parameters: readonly ParameterModel[];
|
|
186
|
+
readonly returns: TypeNodeId;
|
|
187
|
+
}
|
|
188
|
+
/** Shared flags of a class/interface/type-literal member. */
|
|
189
|
+
export interface MemberBase extends DocumentationModel {
|
|
190
|
+
readonly id: string;
|
|
191
|
+
readonly name: string;
|
|
192
|
+
/** JSON property name when a literal computed key differs from source text. */
|
|
193
|
+
readonly jsonName?: string;
|
|
194
|
+
/** Non-literal computed keys; symbol keys are erased from JSON schemas. */
|
|
195
|
+
readonly computed?: 'symbol' | 'dynamic';
|
|
196
|
+
readonly optional: boolean;
|
|
197
|
+
readonly readonly: boolean;
|
|
198
|
+
readonly async: boolean;
|
|
199
|
+
readonly abstract: boolean;
|
|
200
|
+
readonly static: boolean;
|
|
201
|
+
readonly visibility: MemberVisibility;
|
|
202
|
+
readonly location: SourceLocation;
|
|
203
|
+
/** Body-free declaration text retained for byte-stable source projections. */
|
|
204
|
+
readonly text: string;
|
|
205
|
+
}
|
|
206
|
+
/** A property member. */
|
|
207
|
+
export interface PropertyMemberModel extends MemberBase {
|
|
208
|
+
readonly kind: 'property';
|
|
209
|
+
readonly type: TypeNodeId;
|
|
210
|
+
}
|
|
211
|
+
/** A method member. */
|
|
212
|
+
export interface MethodMemberModel extends MemberBase {
|
|
213
|
+
readonly kind: 'method';
|
|
214
|
+
readonly signature: SignatureModel;
|
|
215
|
+
}
|
|
216
|
+
/** A getter or setter member. */
|
|
217
|
+
export interface AccessorMemberModel extends MemberBase {
|
|
218
|
+
readonly kind: 'getter' | 'setter';
|
|
219
|
+
readonly signature: SignatureModel;
|
|
220
|
+
}
|
|
221
|
+
/** A call/construct/index signature in an interface or type literal. */
|
|
222
|
+
export interface SignatureMemberModel extends MemberBase {
|
|
223
|
+
readonly kind: 'call' | 'construct' | 'index';
|
|
224
|
+
readonly signature: SignatureModel;
|
|
225
|
+
}
|
|
226
|
+
/** One declaration or object-literal member. */
|
|
227
|
+
export type MemberModel = PropertyMemberModel | MethodMemberModel | AccessorMemberModel | SignatureMemberModel;
|
|
228
|
+
/** One enum member, retaining its developer-authored initializer. */
|
|
229
|
+
export interface EnumMemberModel extends DocumentationModel {
|
|
230
|
+
readonly name: string;
|
|
231
|
+
readonly initializer?: string;
|
|
232
|
+
readonly location: SourceLocation;
|
|
233
|
+
}
|
|
234
|
+
/** One authored part of a merged interface declaration. */
|
|
235
|
+
export interface TypeDeclarationPartModel extends DocumentationModel {
|
|
236
|
+
readonly package: string;
|
|
237
|
+
readonly location: SourceLocation;
|
|
238
|
+
readonly typeParameters: readonly TypeParameterModel[];
|
|
239
|
+
readonly extends: readonly TypeNodeId[];
|
|
240
|
+
readonly members: readonly string[];
|
|
241
|
+
}
|
|
242
|
+
/** A declared interface, class, or alias. */
|
|
243
|
+
export interface TypeDeclarationModel extends DocumentationModel {
|
|
244
|
+
readonly id: SymbolId;
|
|
245
|
+
readonly package: string;
|
|
246
|
+
readonly name: string;
|
|
247
|
+
readonly kind: 'interface' | 'class' | 'alias' | 'enum';
|
|
248
|
+
readonly abstract: boolean;
|
|
249
|
+
readonly exported: boolean;
|
|
250
|
+
readonly location: SourceLocation;
|
|
251
|
+
/** Canonical body-free declaration text retained alongside the type tree. */
|
|
252
|
+
readonly text: string;
|
|
253
|
+
readonly typeParameters: readonly TypeParameterModel[];
|
|
254
|
+
readonly extends: readonly TypeNodeId[];
|
|
255
|
+
readonly implements: readonly TypeNodeId[];
|
|
256
|
+
readonly members: readonly MemberModel[];
|
|
257
|
+
readonly parts?: readonly TypeDeclarationPartModel[];
|
|
258
|
+
readonly type?: TypeNodeId;
|
|
259
|
+
readonly enumMembers?: readonly EnumMemberModel[];
|
|
260
|
+
}
|
|
261
|
+
/** Target of a named type reference. */
|
|
262
|
+
export type TypeTargetModel = {
|
|
263
|
+
readonly kind: 'declaration';
|
|
264
|
+
readonly symbol: SymbolId;
|
|
265
|
+
} | {
|
|
266
|
+
readonly kind: 'type-parameter';
|
|
267
|
+
readonly parameter: string;
|
|
268
|
+
} | {
|
|
269
|
+
readonly kind: 'cross-face';
|
|
270
|
+
readonly face: TypertFace;
|
|
271
|
+
readonly package: string;
|
|
272
|
+
readonly subpath: string;
|
|
273
|
+
readonly name: string;
|
|
274
|
+
} | {
|
|
275
|
+
readonly kind: 'external';
|
|
276
|
+
readonly module: string;
|
|
277
|
+
readonly subpath: string;
|
|
278
|
+
readonly name: string;
|
|
279
|
+
} | {
|
|
280
|
+
readonly kind: 'standard';
|
|
281
|
+
readonly name: string;
|
|
282
|
+
};
|
|
283
|
+
/** One tuple element, retaining labels and optional/rest modifiers. */
|
|
284
|
+
export interface TupleElementModel {
|
|
285
|
+
readonly name?: string;
|
|
286
|
+
readonly type: TypeNodeId;
|
|
287
|
+
readonly optional: boolean;
|
|
288
|
+
readonly rest: boolean;
|
|
289
|
+
}
|
|
290
|
+
/** One template-literal interpolation. */
|
|
291
|
+
export interface TemplateSpanModel {
|
|
292
|
+
readonly type: TypeNodeId;
|
|
293
|
+
readonly text: string;
|
|
294
|
+
}
|
|
295
|
+
/** Compiler-independent TypeScript type expression. */
|
|
296
|
+
export type TypeNodeModel = {
|
|
297
|
+
readonly id: TypeNodeId;
|
|
298
|
+
readonly kind: 'keyword';
|
|
299
|
+
readonly name: KeywordTypeName;
|
|
300
|
+
} | {
|
|
301
|
+
readonly id: TypeNodeId;
|
|
302
|
+
readonly kind: 'literal';
|
|
303
|
+
readonly value: string | number | bigint | boolean | null;
|
|
304
|
+
readonly text: string;
|
|
305
|
+
} | {
|
|
306
|
+
readonly id: TypeNodeId;
|
|
307
|
+
readonly kind: 'parenthesized';
|
|
308
|
+
readonly type: TypeNodeId;
|
|
309
|
+
} | {
|
|
310
|
+
readonly id: TypeNodeId;
|
|
311
|
+
readonly kind: 'reference';
|
|
312
|
+
readonly name: string;
|
|
313
|
+
readonly target: TypeTargetModel;
|
|
314
|
+
readonly arguments: readonly TypeNodeId[];
|
|
315
|
+
} | {
|
|
316
|
+
readonly id: TypeNodeId;
|
|
317
|
+
readonly kind: 'union' | 'intersection';
|
|
318
|
+
readonly types: readonly TypeNodeId[];
|
|
319
|
+
} | {
|
|
320
|
+
readonly id: TypeNodeId;
|
|
321
|
+
readonly kind: 'array';
|
|
322
|
+
readonly element: TypeNodeId;
|
|
323
|
+
} | {
|
|
324
|
+
readonly id: TypeNodeId;
|
|
325
|
+
readonly kind: 'tuple';
|
|
326
|
+
readonly elements: readonly TupleElementModel[];
|
|
327
|
+
} | {
|
|
328
|
+
readonly id: TypeNodeId;
|
|
329
|
+
readonly kind: 'object';
|
|
330
|
+
readonly members: readonly MemberModel[];
|
|
331
|
+
} | {
|
|
332
|
+
readonly id: TypeNodeId;
|
|
333
|
+
readonly kind: 'function';
|
|
334
|
+
readonly signature: SignatureModel;
|
|
335
|
+
} | {
|
|
336
|
+
readonly id: TypeNodeId;
|
|
337
|
+
readonly kind: 'constructor';
|
|
338
|
+
readonly abstract: boolean;
|
|
339
|
+
readonly signature: SignatureModel;
|
|
340
|
+
} | {
|
|
341
|
+
readonly id: TypeNodeId;
|
|
342
|
+
readonly kind: 'indexed-access';
|
|
343
|
+
readonly object: TypeNodeId;
|
|
344
|
+
readonly index: TypeNodeId;
|
|
345
|
+
} | {
|
|
346
|
+
readonly id: TypeNodeId;
|
|
347
|
+
readonly kind: 'operator';
|
|
348
|
+
readonly operator: TypeOperatorName;
|
|
349
|
+
readonly type: TypeNodeId;
|
|
350
|
+
} | {
|
|
351
|
+
readonly id: TypeNodeId;
|
|
352
|
+
readonly kind: 'conditional';
|
|
353
|
+
readonly check: TypeNodeId;
|
|
354
|
+
readonly extends: TypeNodeId;
|
|
355
|
+
readonly whenTrue: TypeNodeId;
|
|
356
|
+
readonly whenFalse: TypeNodeId;
|
|
357
|
+
} | {
|
|
358
|
+
readonly id: TypeNodeId;
|
|
359
|
+
readonly kind: 'infer';
|
|
360
|
+
readonly parameter: TypeParameterModel;
|
|
361
|
+
} | {
|
|
362
|
+
readonly id: TypeNodeId;
|
|
363
|
+
readonly kind: 'mapped';
|
|
364
|
+
readonly parameter: TypeParameterModel;
|
|
365
|
+
readonly nameType?: TypeNodeId;
|
|
366
|
+
readonly value?: TypeNodeId;
|
|
367
|
+
readonly readonly: 'add' | 'remove' | 'preserve';
|
|
368
|
+
readonly optional: 'add' | 'remove' | 'preserve';
|
|
369
|
+
} | {
|
|
370
|
+
readonly id: TypeNodeId;
|
|
371
|
+
readonly kind: 'template-literal';
|
|
372
|
+
readonly head: string;
|
|
373
|
+
readonly spans: readonly TemplateSpanModel[];
|
|
374
|
+
} | {
|
|
375
|
+
readonly id: TypeNodeId;
|
|
376
|
+
readonly kind: 'type-query';
|
|
377
|
+
readonly expression: string;
|
|
378
|
+
readonly arguments: readonly TypeNodeId[];
|
|
379
|
+
} | {
|
|
380
|
+
readonly id: TypeNodeId;
|
|
381
|
+
readonly kind: 'import-type';
|
|
382
|
+
readonly module: string;
|
|
383
|
+
readonly qualifier?: string;
|
|
384
|
+
readonly arguments: readonly TypeNodeId[];
|
|
385
|
+
readonly typeof: boolean;
|
|
386
|
+
readonly attributes?: string;
|
|
387
|
+
readonly target?: TypeTargetModel;
|
|
388
|
+
} | {
|
|
389
|
+
readonly id: TypeNodeId;
|
|
390
|
+
readonly kind: 'predicate';
|
|
391
|
+
readonly asserts: boolean;
|
|
392
|
+
readonly parameter: string;
|
|
393
|
+
readonly type?: TypeNodeId;
|
|
394
|
+
} | {
|
|
395
|
+
readonly id: TypeNodeId;
|
|
396
|
+
readonly kind: 'this';
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Return the direct type-expression edges owned by one node.
|
|
400
|
+
* @param node - compiler-independent type node to inspect.
|
|
401
|
+
* @returns graph-local ids of its direct child type nodes.
|
|
402
|
+
*/
|
|
403
|
+
export declare function childTypeNodeIds(node: TypeNodeModel): TypeNodeId[];
|
|
404
|
+
/** Type declarations and expressions owned by one face. */
|
|
405
|
+
export interface TypeGraph {
|
|
406
|
+
readonly declarations: readonly TypeDeclarationModel[];
|
|
407
|
+
readonly nodes: readonly TypeNodeModel[];
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler-independent Typert analysis model. TypeScript nodes and checker
|
|
3
|
+
* objects are extraction inputs only; emitters consume this graph.
|
|
4
|
+
* @module @deepseek-ai/dsh-typert-generator/model
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Return the direct type-expression edges owned by one node.
|
|
8
|
+
* @param node - compiler-independent type node to inspect.
|
|
9
|
+
* @returns graph-local ids of its direct child type nodes.
|
|
10
|
+
*/
|
|
11
|
+
export function childTypeNodeIds(node) {
|
|
12
|
+
switch (node.kind) {
|
|
13
|
+
case 'parenthesized':
|
|
14
|
+
case 'operator': return [node.type];
|
|
15
|
+
case 'reference': return [...node.arguments];
|
|
16
|
+
case 'union':
|
|
17
|
+
case 'intersection': return [...node.types];
|
|
18
|
+
case 'array': return [node.element];
|
|
19
|
+
case 'tuple': return node.elements.map(element => element.type);
|
|
20
|
+
case 'indexed-access': return [node.object, node.index];
|
|
21
|
+
case 'conditional': return [node.check, node.extends, node.whenTrue, node.whenFalse];
|
|
22
|
+
case 'mapped': return [
|
|
23
|
+
...(node.parameter.constraint === undefined ? [] : [node.parameter.constraint]),
|
|
24
|
+
...(node.parameter.default === undefined ? [] : [node.parameter.default]),
|
|
25
|
+
...(node.nameType === undefined ? [] : [node.nameType]),
|
|
26
|
+
...(node.value === undefined ? [] : [node.value]),
|
|
27
|
+
];
|
|
28
|
+
case 'template-literal': return node.spans.map(span => span.type);
|
|
29
|
+
case 'type-query':
|
|
30
|
+
case 'import-type': return [...node.arguments];
|
|
31
|
+
case 'predicate': return node.type === undefined ? [] : [node.type];
|
|
32
|
+
case 'infer': return [
|
|
33
|
+
...(node.parameter.constraint === undefined ? [] : [node.parameter.constraint]),
|
|
34
|
+
...(node.parameter.default === undefined ? [] : [node.parameter.default]),
|
|
35
|
+
];
|
|
36
|
+
case 'keyword':
|
|
37
|
+
case 'literal':
|
|
38
|
+
case 'object':
|
|
39
|
+
case 'function':
|
|
40
|
+
case 'constructor':
|
|
41
|
+
case 'this': return [];
|
|
42
|
+
default: return assertNever(node);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function assertNever(value) {
|
|
46
|
+
throw new Error(`unsupported model variant ${JSON.stringify(value)}`);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering and traversal over the compiler-independent TypeGraph. Emitters
|
|
3
|
+
* use this module instead of reaching back into TypeScript AST nodes.
|
|
4
|
+
* @module @deepseek-ai/dsh-typert-generator/renderer
|
|
5
|
+
*/
|
|
6
|
+
import type { MemberModel, SignatureModel, SymbolId, TypeDeclarationModel, TypeGraph, TypeNodeId, TypeNodeModel } from './model.ts';
|
|
7
|
+
/** Failure to render or traverse an internally inconsistent TypeGraph. */
|
|
8
|
+
export declare class TypeGraphRenderError extends Error {
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
/** Read and render one TypeGraph without compiler objects. */
|
|
12
|
+
export declare class TypeGraphRenderer {
|
|
13
|
+
readonly graph: TypeGraph;
|
|
14
|
+
private readonly nodes;
|
|
15
|
+
private readonly declarations;
|
|
16
|
+
private readonly members;
|
|
17
|
+
private readonly parameterNames;
|
|
18
|
+
/**
|
|
19
|
+
* Index one complete graph.
|
|
20
|
+
* @param graph - compiler-independent graph to render.
|
|
21
|
+
*/
|
|
22
|
+
constructor(graph: TypeGraph);
|
|
23
|
+
/**
|
|
24
|
+
* Resolve a node id or fail with the broken edge.
|
|
25
|
+
* @param id - graph-local type node id.
|
|
26
|
+
* @returns the referenced node.
|
|
27
|
+
*/
|
|
28
|
+
node(id: TypeNodeId): TypeNodeModel;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a declaration id or fail with the broken edge.
|
|
31
|
+
* @param id - workspace symbol id.
|
|
32
|
+
* @returns the referenced declaration.
|
|
33
|
+
*/
|
|
34
|
+
declaration(id: SymbolId): TypeDeclarationModel;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve a public member id.
|
|
37
|
+
* @param id - declaration member id.
|
|
38
|
+
* @returns the referenced member.
|
|
39
|
+
*/
|
|
40
|
+
member(id: string): MemberModel;
|
|
41
|
+
/**
|
|
42
|
+
* Render one type expression from the retained source structure.
|
|
43
|
+
* @param id - type node id.
|
|
44
|
+
* @param references - optional generated names for declaration references.
|
|
45
|
+
* @returns TypeScript type text.
|
|
46
|
+
*/
|
|
47
|
+
renderType(id: TypeNodeId, references?: ReadonlyMap<SymbolId, string>): string;
|
|
48
|
+
/**
|
|
49
|
+
* Render a callable signature without a member name.
|
|
50
|
+
* @param signature - modeled signature.
|
|
51
|
+
* @param references - optional generated names for declaration references.
|
|
52
|
+
* @returns parameter list and return type.
|
|
53
|
+
*/
|
|
54
|
+
renderSignature(signature: SignatureModel, references?: ReadonlyMap<SymbolId, string>): string;
|
|
55
|
+
/**
|
|
56
|
+
* Render one class/interface member as a body-free declaration.
|
|
57
|
+
* @param member - modeled member.
|
|
58
|
+
* @param sourceModifiers - retain source-only modifiers for reflection text.
|
|
59
|
+
* @param references - optional generated names for declaration references.
|
|
60
|
+
* @returns one-line TypeScript member text.
|
|
61
|
+
*/
|
|
62
|
+
renderMember(member: MemberModel, sourceModifiers?: boolean, references?: ReadonlyMap<SymbolId, string>): string;
|
|
63
|
+
/**
|
|
64
|
+
* Render a named declaration without JSDoc.
|
|
65
|
+
* @param id - declaration symbol id.
|
|
66
|
+
* @returns exported TypeScript declaration text.
|
|
67
|
+
*/
|
|
68
|
+
renderDeclaration(id: SymbolId): string;
|
|
69
|
+
/**
|
|
70
|
+
* Find the transitive declaration closure referenced by members.
|
|
71
|
+
* @param memberIds - business-surface member ids.
|
|
72
|
+
* @returns declarations in graph order, excluding no roots implicitly.
|
|
73
|
+
*/
|
|
74
|
+
declarationClosureForMembers(memberIds: readonly string[]): TypeDeclarationModel[];
|
|
75
|
+
/**
|
|
76
|
+
* Find the transitive declaration closure referenced by type roots.
|
|
77
|
+
* @param typeIds - graph type roots.
|
|
78
|
+
* @returns declarations in graph order.
|
|
79
|
+
*/
|
|
80
|
+
declarationClosureForTypes(typeIds: readonly TypeNodeId[]): TypeDeclarationModel[];
|
|
81
|
+
private declarationClosure;
|
|
82
|
+
private renderSignatureHead;
|
|
83
|
+
private renderReturn;
|
|
84
|
+
private renderParameter;
|
|
85
|
+
private renderTypeParameters;
|
|
86
|
+
private renderTypeParameter;
|
|
87
|
+
private renderObject;
|
|
88
|
+
private indexParameters;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=renderer.d.ts.map
|