1 | import * as reflect from 'jsii-reflect';
|
2 | import { JsiiEntity, TypeSchema } from '../schema';
|
3 |
|
4 |
|
5 |
|
6 | export declare class Language {
|
7 | |
8 |
|
9 |
|
10 | static readonly TYPESCRIPT: Language;
|
11 | |
12 |
|
13 |
|
14 | static readonly PYTHON: Language;
|
15 | |
16 |
|
17 |
|
18 | static readonly JAVA: Language;
|
19 | |
20 |
|
21 |
|
22 | static readonly CSHARP: Language;
|
23 | |
24 |
|
25 |
|
26 |
|
27 | static readonly GO: Language;
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 | static fromString(lang: string): Language;
|
34 | static values(): Language[];
|
35 | readonly name: string;
|
36 | readonly targetName: string;
|
37 | private readonly validator;
|
38 | private constructor();
|
39 | isValidConfiguration(config: Record<string, unknown> | undefined): boolean;
|
40 | toString(): string;
|
41 | }
|
42 | export declare class UnsupportedLanguageError extends Error {
|
43 | constructor(lang: string, supported: Language[]);
|
44 | }
|
45 | /**
|
46 | * Outcome of transpiling a jsii struct.
|
47 | */
|
48 | export interface TranspiledStruct {
|
49 | |
50 |
|
51 |
|
52 | readonly type: TranspiledType;
|
53 | |
54 |
|
55 |
|
56 | readonly name: string;
|
57 | |
58 |
|
59 |
|
60 | readonly import: string;
|
61 | |
62 |
|
63 |
|
64 | readonly initialization: string;
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 | export interface TranspiledClass {
|
70 | |
71 |
|
72 |
|
73 | readonly type: TranspiledType;
|
74 | |
75 |
|
76 |
|
77 | readonly name: string;
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 | export interface TranspiledCallable {
|
83 | |
84 |
|
85 |
|
86 | readonly parentType: TranspiledType;
|
87 | |
88 |
|
89 |
|
90 |
|
91 |
|
92 | readonly signatures: string[];
|
93 | |
94 |
|
95 |
|
96 | readonly name: string;
|
97 | |
98 |
|
99 |
|
100 | readonly import: string;
|
101 | |
102 |
|
103 |
|
104 |
|
105 |
|
106 | readonly invocations: string[];
|
107 | |
108 |
|
109 |
|
110 | readonly parameters: reflect.Parameter[];
|
111 | |
112 |
|
113 |
|
114 | readonly returnType?: TranspiledTypeReference;
|
115 | }
|
116 |
|
117 |
|
118 |
|
119 | export interface TranspiledParameter extends TranspiledProperty {
|
120 | |
121 |
|
122 |
|
123 | readonly variadic: boolean;
|
124 | }
|
125 |
|
126 |
|
127 |
|
128 | export interface TranspiledInterface {
|
129 | |
130 |
|
131 |
|
132 | readonly type: TranspiledType;
|
133 | |
134 |
|
135 |
|
136 | readonly name: string;
|
137 | }
|
138 |
|
139 |
|
140 |
|
141 | export declare class TranspiledType {
|
142 | |
143 |
|
144 |
|
145 | readonly source: reflect.Type;
|
146 | |
147 |
|
148 |
|
149 | readonly language: Language;
|
150 | |
151 |
|
152 |
|
153 | readonly fqn: string;
|
154 | |
155 |
|
156 |
|
157 | readonly name: string;
|
158 | |
159 |
|
160 |
|
161 | readonly namespace?: string;
|
162 | |
163 |
|
164 |
|
165 | readonly module: string;
|
166 | /**
|
167 | * The language specific submodule name the type belongs to.
|
168 | */
|
169 | readonly submodule?: string;
|
170 | /**
|
171 | * The language-independent name of the submodule the type belongs to.
|
172 | */
|
173 | readonly submodulePath?: string;
|
174 | constructor(options: {
|
175 | source: reflect.Type;
|
176 | language: Language;
|
177 | fqn: string;
|
178 | name: string;
|
179 | namespace?: string;
|
180 | module: string;
|
181 | submodule?: string;
|
182 | submodulePath?: string;
|
183 | });
|
184 | toJson(): JsiiEntity;
|
185 | }
|
186 | /**
|
187 | * Options for how to render a string representation of a type reference.
|
188 | */
|
189 | export interface TranspiledTypeReferenceToStringOptions {
|
190 | |
191 |
|
192 |
|
193 | typeFormatter?: (type: TranspiledType) => string;
|
194 | |
195 |
|
196 |
|
197 | stringFormatter?: (typeName: string) => string;
|
198 | }
|
199 |
|
200 |
|
201 |
|
202 | export declare class TranspiledTypeReference {
|
203 | |
204 |
|
205 |
|
206 | private readonly transpile;
|
207 | |
208 |
|
209 |
|
210 | private readonly ref;
|
211 | |
212 |
|
213 |
|
214 | private readonly primitive?;
|
215 | |
216 |
|
217 |
|
218 | private readonly isAny?;
|
219 | |
220 |
|
221 |
|
222 | private readonly type?;
|
223 | |
224 |
|
225 |
|
226 | private readonly arrayOfType?;
|
227 | |
228 |
|
229 |
|
230 | private readonly mapOfType?;
|
231 | |
232 |
|
233 |
|
234 | private readonly unionOfTypes?;
|
235 | |
236 |
|
237 |
|
238 | private readonly isVoid?;
|
239 | |
240 |
|
241 |
|
242 | static primitive(transpile: Transpile, ref: reflect.TypeReference, primitive: string): TranspiledTypeReference;
|
243 | |
244 |
|
245 |
|
246 | static any(transpile: Transpile, ref: reflect.TypeReference): TranspiledTypeReference;
|
247 | |
248 |
|
249 |
|
250 | static void(transpile: Transpile, ref: reflect.TypeReference): TranspiledTypeReference;
|
251 | |
252 |
|
253 |
|
254 | static type(transpile: Transpile, ref: reflect.TypeReference, type: TranspiledType): TranspiledTypeReference;
|
255 | |
256 |
|
257 |
|
258 | static arrayOfType(transpile: Transpile, ref: reflect.TypeReference, tf: TranspiledTypeReference): TranspiledTypeReference;
|
259 | |
260 |
|
261 |
|
262 | static mapOfType(transpile: Transpile, ref: reflect.TypeReference, tf: TranspiledTypeReference): TranspiledTypeReference;
|
263 | |
264 |
|
265 |
|
266 | static unionOfTypes(transpile: Transpile, ref: reflect.TypeReference, tfs: TranspiledTypeReference[]): TranspiledTypeReference;
|
267 | private constructor();
|
268 | toString(options?: TranspiledTypeReferenceToStringOptions): string;
|
269 | toJson(): TypeSchema;
|
270 | }
|
271 | /**
|
272 | * Outcome of transpiling a jsii property.
|
273 | */
|
274 | export interface TranspiledProperty {
|
275 | |
276 |
|
277 |
|
278 | readonly name: string;
|
279 | |
280 |
|
281 |
|
282 | readonly parentType: TranspiledType;
|
283 | |
284 |
|
285 |
|
286 | readonly typeReference: TranspiledTypeReference;
|
287 | |
288 |
|
289 |
|
290 | readonly optional: boolean;
|
291 | |
292 |
|
293 |
|
294 |
|
295 | readonly declaration: string;
|
296 | }
|
297 |
|
298 |
|
299 |
|
300 | export interface TranspiledEnum {
|
301 | |
302 |
|
303 |
|
304 | readonly fqn: string;
|
305 | |
306 |
|
307 |
|
308 | readonly name: string;
|
309 | }
|
310 |
|
311 |
|
312 |
|
313 | export interface TranspiledEnumMember {
|
314 | |
315 |
|
316 |
|
317 | readonly fqn: string;
|
318 | |
319 |
|
320 |
|
321 | readonly name: string;
|
322 | }
|
323 |
|
324 |
|
325 |
|
326 | export interface TranspiledModuleLike {
|
327 | |
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | readonly name: string;
|
343 | |
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | readonly submodule?: string;
|
358 | }
|
359 |
|
360 |
|
361 |
|
362 | export interface Transpile {
|
363 | |
364 |
|
365 |
|
366 | readonly language: Language;
|
367 | |
368 |
|
369 |
|
370 |
|
371 |
|
372 | readonly linkFormatter?: (type: TranspiledType) => string;
|
373 | |
374 |
|
375 |
|
376 | moduleLike(moduleLike: reflect.ModuleLike): TranspiledModuleLike;
|
377 | |
378 |
|
379 |
|
380 |
|
381 |
|
382 | callable(callable: reflect.Callable): TranspiledCallable;
|
383 | |
384 |
|
385 |
|
386 | class(klass: reflect.ClassType): TranspiledClass;
|
387 | |
388 |
|
389 |
|
390 | struct(struct: reflect.InterfaceType): TranspiledStruct;
|
391 | |
392 |
|
393 |
|
394 | interface(iface: reflect.InterfaceType): TranspiledInterface;
|
395 | /**
|
396 | * Transpile a parameter.
|
397 | */
|
398 | parameter(parameter: reflect.Parameter): TranspiledParameter;
|
399 | /**
|
400 | * Transpile a property.
|
401 | */
|
402 | property(property: reflect.Property): TranspiledProperty;
|
403 | /**
|
404 | * Transpile an enum.
|
405 | */
|
406 | enum(enu: reflect.EnumType): TranspiledEnum;
|
407 | /**
|
408 | * Transpile an enum member.
|
409 | */
|
410 | enumMember(em: reflect.EnumMember): TranspiledEnumMember;
|
411 | /**
|
412 | * Transpile a type.
|
413 | */
|
414 | type(type: reflect.Type): TranspiledType;
|
415 | /**
|
416 | * Transpile (recursively) a type reference.
|
417 | */
|
418 | typeReference(typeReference: reflect.TypeReference): TranspiledTypeReference;
|
419 | /**
|
420 | * How a union looks like in the target language.
|
421 | */
|
422 | unionOf(types: string[]): string;
|
423 | /**
|
424 | * How a variadic parameter looks in the target language.
|
425 | */
|
426 | variadicOf(type: string): string;
|
427 | /**
|
428 | * How a list looks like in the target language.
|
429 | */
|
430 | listOf(type: string): string;
|
431 | /**
|
432 | * How a map looks like in the target language.
|
433 | */
|
434 | mapOf(type: string): string;
|
435 | /**
|
436 | * How the 'any' type is represented in the target language.
|
437 | */
|
438 | any(): string;
|
439 | /**
|
440 | * How the 'void' (return) type is represented in the target language.
|
441 | */
|
442 | void(): string;
|
443 | /**
|
444 | * How the 'string' type is represented in the target language.
|
445 | */
|
446 | str(): string;
|
447 | /**
|
448 | * How the 'number' type is represented in the target language.
|
449 | */
|
450 | number(): string;
|
451 | /**
|
452 | * How the 'boolean' type is represented in the target language.
|
453 | */
|
454 | boolean(): string;
|
455 | /**
|
456 | * How the 'json' type is represented in the target language.
|
457 | */
|
458 | json(): string;
|
459 | /**
|
460 | * How the 'date' type is represented in the target language.
|
461 | */
|
462 | date(): string;
|
463 | /**
|
464 | * How a readme is displayed in the target language.
|
465 | */
|
466 | readme(readme: string): string;
|
467 | }
|
468 | export interface TranspileBase extends Transpile {
|
469 | }
|
470 |
|
471 |
|
472 |
|
473 | export declare abstract class TranspileBase implements Transpile {
|
474 | readonly language: Language;
|
475 | private readonly parentModulesCache;
|
476 | private readonly submodulesCache;
|
477 | constructor(language: Language);
|
478 | typeReference(ref: reflect.TypeReference): TranspiledTypeReference;
|
479 | protected findSubmodule(type: reflect.Type): reflect.Submodule | undefined;
|
480 | protected getParentModule(moduleLike: reflect.ModuleLike): reflect.Assembly;
|
481 | protected optionalityCompare(p1: reflect.Parameter, p2: reflect.Parameter): number;
|
482 | }
|
483 | /**
|
484 | * Return the root-relative name for a submodule
|
485 | *
|
486 | * Ex: for a submodule `asm.sub1.sub2`, return `sub1.sub2`.
|
487 | */
|
488 | export declare function submoduleRelName(submodule: reflect.Submodule): string;
|