jsii-reflect 1.119.0 → 1.121.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/lib/assembly.d.ts +5 -1
- package/lib/assembly.js +19 -4
- package/lib/submodule.d.ts +6 -1
- package/lib/submodule.js +2 -1
- package/lib/type-system.js +12 -1
- package/package.json +6 -6
- package/test/__snapshots__/jsii-tree.test.js.snap +37 -0
- package/test/__snapshots__/tree.test.js.snap +22 -0
- package/test/__snapshots__/type-system.test.js.snap +1 -0
- package/test/type-system.test.js +7 -0
- package/test/util.js +5 -1
package/lib/assembly.d.ts
CHANGED
|
@@ -9,10 +9,14 @@ import { Type } from './type';
|
|
|
9
9
|
import { TypeSystem } from './type-system';
|
|
10
10
|
export declare class Assembly extends ModuleLike {
|
|
11
11
|
readonly spec: jsii.Assembly;
|
|
12
|
+
private readonly _directory?;
|
|
13
|
+
private readonly _packageJson?;
|
|
12
14
|
private _typeCache?;
|
|
13
15
|
private _submoduleCache?;
|
|
14
16
|
private _dependencyCache?;
|
|
15
|
-
constructor(system: TypeSystem, spec: jsii.Assembly);
|
|
17
|
+
constructor(system: TypeSystem, spec: jsii.Assembly, _directory?: string | undefined, _packageJson?: any | undefined);
|
|
18
|
+
get directory(): string;
|
|
19
|
+
get packageJson(): any;
|
|
16
20
|
get fqn(): string;
|
|
17
21
|
/**
|
|
18
22
|
* The version of the spec schema
|
package/lib/assembly.js
CHANGED
|
@@ -9,9 +9,23 @@ const interface_1 = require("./interface");
|
|
|
9
9
|
const module_like_1 = require("./module-like");
|
|
10
10
|
const submodule_1 = require("./submodule");
|
|
11
11
|
class Assembly extends module_like_1.ModuleLike {
|
|
12
|
-
constructor(system, spec) {
|
|
12
|
+
constructor(system, spec, _directory, _packageJson) {
|
|
13
13
|
super(system);
|
|
14
14
|
this.spec = spec;
|
|
15
|
+
this._directory = _directory;
|
|
16
|
+
this._packageJson = _packageJson;
|
|
17
|
+
}
|
|
18
|
+
get directory() {
|
|
19
|
+
if (!this._directory) {
|
|
20
|
+
throw new Error('A directory was not supplied when initializing this Assembly');
|
|
21
|
+
}
|
|
22
|
+
return this._directory;
|
|
23
|
+
}
|
|
24
|
+
get packageJson() {
|
|
25
|
+
if (!this._packageJson) {
|
|
26
|
+
throw new Error('A package.json was not supplied when initializing this Assembly');
|
|
27
|
+
}
|
|
28
|
+
return this._packageJson;
|
|
15
29
|
}
|
|
16
30
|
get fqn() {
|
|
17
31
|
return this.spec.name;
|
|
@@ -252,7 +266,7 @@ class Assembly extends module_like_1.ModuleLike {
|
|
|
252
266
|
const system = this.system;
|
|
253
267
|
const ret = new Map();
|
|
254
268
|
for (const [submoduleName, submoduleSpec] of Object.entries(this.spec.submodules ?? {})) {
|
|
255
|
-
ret.set(submoduleName, new SubmoduleBuilder(system, submoduleSpec, submoduleName, ret));
|
|
269
|
+
ret.set(submoduleName, new SubmoduleBuilder(this, system, submoduleSpec, submoduleName, ret));
|
|
256
270
|
}
|
|
257
271
|
return ret;
|
|
258
272
|
}
|
|
@@ -267,7 +281,8 @@ exports.Assembly = Assembly;
|
|
|
267
281
|
* to translate
|
|
268
282
|
*/
|
|
269
283
|
class SubmoduleBuilder {
|
|
270
|
-
constructor(system, spec, fullName, allModuleBuilders) {
|
|
284
|
+
constructor(parent, system, spec, fullName, allModuleBuilders) {
|
|
285
|
+
this.parent = parent;
|
|
271
286
|
this.system = system;
|
|
272
287
|
this.spec = spec;
|
|
273
288
|
this.fullName = fullName;
|
|
@@ -282,7 +297,7 @@ class SubmoduleBuilder {
|
|
|
282
297
|
this.fullName.split('.').length === other.fullName.split('.').length + 1);
|
|
283
298
|
}
|
|
284
299
|
build() {
|
|
285
|
-
this._built ?? (this._built = new submodule_1.Submodule(this.system, this.spec, this.fullName, mapValues(this.findSubmoduleBuilders(), (b) => b.build()), this.types));
|
|
300
|
+
this._built ?? (this._built = new submodule_1.Submodule(this.system, this.spec, this.fullName, mapValues(this.findSubmoduleBuilders(), (b) => b.build()), this.types, this.parent));
|
|
286
301
|
return this._built;
|
|
287
302
|
}
|
|
288
303
|
/**
|
package/lib/submodule.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as jsii from '@jsii/spec';
|
|
2
|
+
import { Assembly } from './assembly';
|
|
2
3
|
import { ModuleLike } from './module-like';
|
|
3
4
|
import { Type } from './type';
|
|
4
5
|
import { TypeSystem } from './type-system';
|
|
@@ -11,7 +12,11 @@ export declare class Submodule extends ModuleLike {
|
|
|
11
12
|
* The simple name of the submodule (the last segment of the `fullName`).
|
|
12
13
|
*/
|
|
13
14
|
readonly name: string;
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The parent assembly of the submodule.
|
|
17
|
+
*/
|
|
18
|
+
readonly parent: Assembly;
|
|
19
|
+
constructor(system: TypeSystem, spec: jsii.Submodule, fqn: string, submoduleMap: ReadonlyMap<string, Submodule>, typeMap: ReadonlyMap<string, Type>, parent: Assembly);
|
|
15
20
|
/**
|
|
16
21
|
* A map of target name to configuration, which is used when generating packages for
|
|
17
22
|
* various languages.
|
package/lib/submodule.js
CHANGED
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Submodule = void 0;
|
|
4
4
|
const module_like_1 = require("./module-like");
|
|
5
5
|
class Submodule extends module_like_1.ModuleLike {
|
|
6
|
-
constructor(system, spec, fqn, submoduleMap, typeMap) {
|
|
6
|
+
constructor(system, spec, fqn, submoduleMap, typeMap, parent) {
|
|
7
7
|
super(system);
|
|
8
8
|
this.spec = spec;
|
|
9
9
|
this.fqn = fqn;
|
|
10
10
|
this.submoduleMap = submoduleMap;
|
|
11
11
|
this.typeMap = typeMap;
|
|
12
12
|
this.name = fqn.split('.').pop();
|
|
13
|
+
this.parent = parent;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* A map of target name to configuration, which is used when generating packages for
|
package/lib/type-system.js
CHANGED
|
@@ -280,7 +280,18 @@ class TypeSystem {
|
|
|
280
280
|
loadAssembly(file, validate = true, supportedFeatures) {
|
|
281
281
|
validateFeatureSubset(supportedFeatures);
|
|
282
282
|
const contents = (0, spec_1.loadAssemblyFromFile)(file, validate, supportedFeatures);
|
|
283
|
-
|
|
283
|
+
const pjFile = path.join(path.dirname(file), 'package.json');
|
|
284
|
+
let pjData = {};
|
|
285
|
+
try {
|
|
286
|
+
pjData = JSON.parse(fs.readFileSync(pjFile, 'utf-8'));
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
// Opportunistically it's not a failure if the file doesn't exist
|
|
290
|
+
if (e.code !== 'ENOENT') {
|
|
291
|
+
throw new Error(`Error loading ${pjFile}: ${e}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return new assembly_1.Assembly(this, contents, path.dirname(file), pjData);
|
|
284
295
|
}
|
|
285
296
|
addRoot(asm) {
|
|
286
297
|
if (!this.roots.some((r) => r.name === asm.name)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsii-reflect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.121.0",
|
|
4
4
|
"description": "strongly-typed reflection library and tools for jsii",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"package": "package-js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@jsii/check-node": "1.
|
|
39
|
-
"@jsii/spec": "1.
|
|
38
|
+
"@jsii/check-node": "1.121.0",
|
|
39
|
+
"@jsii/spec": "1.121.0",
|
|
40
40
|
"chalk": "^4",
|
|
41
41
|
"fs-extra": "^10.1.0",
|
|
42
|
-
"oo-ascii-tree": "^1.
|
|
42
|
+
"oo-ascii-tree": "^1.121.0",
|
|
43
43
|
"yargs": "^17.7.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@scope/jsii-calc-lib": "^1.
|
|
46
|
+
"@scope/jsii-calc-lib": "^1.121.0",
|
|
47
47
|
"@types/fs-extra": "^9.0.13",
|
|
48
48
|
"@types/yargs": "^17.0.33",
|
|
49
49
|
"jsii": "^5.9.10",
|
|
50
|
-
"jsii-build-tools": "^1.
|
|
50
|
+
"jsii-build-tools": "^1.121.0",
|
|
51
51
|
"jsii-calc": "^3.20.120"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -2296,6 +2296,11 @@ exports[`jsii-tree --all 1`] = `
|
|
|
2296
2296
|
│ │ │ └─┬ value
|
|
2297
2297
|
│ │ │ └── type: string
|
|
2298
2298
|
│ │ └── returns: boolean
|
|
2299
|
+
│ ├─┬ class SomeContainingClass (stable)
|
|
2300
|
+
│ │ └─┬ members
|
|
2301
|
+
│ │ ├── <initializer>() initializer (stable)
|
|
2302
|
+
│ │ └─┬ sayHello() method (stable)
|
|
2303
|
+
│ │ └── returns: string
|
|
2299
2304
|
│ ├─┬ class SomeTypeJsii976 (stable)
|
|
2300
2305
|
│ │ └─┬ members
|
|
2301
2306
|
│ │ ├── <initializer>() initializer (stable)
|
|
@@ -3442,6 +3447,20 @@ exports[`jsii-tree --all 1`] = `
|
|
|
3442
3447
|
│ │ ├── abstract
|
|
3443
3448
|
│ │ ├── immutable
|
|
3444
3449
|
│ │ └── type: boolean
|
|
3450
|
+
│ ├─┬ interface ChildStruct (stable)
|
|
3451
|
+
│ │ ├─┬ interfaces
|
|
3452
|
+
│ │ │ └── ParentStruct
|
|
3453
|
+
│ │ └─┬ members
|
|
3454
|
+
│ │ └─┬ field2 property (stable)
|
|
3455
|
+
│ │ ├── abstract
|
|
3456
|
+
│ │ ├── immutable
|
|
3457
|
+
│ │ └── type: string
|
|
3458
|
+
│ ├─┬ interface ParentStruct (stable)
|
|
3459
|
+
│ │ └─┬ members
|
|
3460
|
+
│ │ └─┬ field1 property (stable)
|
|
3461
|
+
│ │ ├── abstract
|
|
3462
|
+
│ │ ├── immutable
|
|
3463
|
+
│ │ └── type: string
|
|
3445
3464
|
│ ├─┬ interface StableStruct (stable)
|
|
3446
3465
|
│ │ └─┬ members
|
|
3447
3466
|
│ │ └─┬ readonlyProperty property (stable)
|
|
@@ -4202,6 +4221,7 @@ exports[`jsii-tree --inheritance 1`] = `
|
|
|
4202
4221
|
│ ├── class SingleInstanceTwoTypes
|
|
4203
4222
|
│ ├── class SingletonInt
|
|
4204
4223
|
│ ├── class SingletonString
|
|
4224
|
+
│ ├── class SomeContainingClass
|
|
4205
4225
|
│ ├── class SomeTypeJsii976
|
|
4206
4226
|
│ ├── class StableClass
|
|
4207
4227
|
│ ├── class StaticContext
|
|
@@ -4335,6 +4355,10 @@ exports[`jsii-tree --inheritance 1`] = `
|
|
|
4335
4355
|
│ ├── interface RootStruct
|
|
4336
4356
|
│ ├── interface SecondLevelStruct
|
|
4337
4357
|
│ ├── interface SmellyStruct
|
|
4358
|
+
│ ├─┬ interface ChildStruct
|
|
4359
|
+
│ │ └─┬ interfaces
|
|
4360
|
+
│ │ └── ParentStruct
|
|
4361
|
+
│ ├── interface ParentStruct
|
|
4338
4362
|
│ ├── interface StableStruct
|
|
4339
4363
|
│ ├── interface StructA
|
|
4340
4364
|
│ ├── interface StructB
|
|
@@ -5512,6 +5536,10 @@ exports[`jsii-tree --members 1`] = `
|
|
|
5512
5536
|
│ ├─┬ class SingletonString
|
|
5513
5537
|
│ │ └─┬ members
|
|
5514
5538
|
│ │ └── isSingletonString(value) method
|
|
5539
|
+
│ ├─┬ class SomeContainingClass
|
|
5540
|
+
│ │ └─┬ members
|
|
5541
|
+
│ │ ├── <initializer>() initializer
|
|
5542
|
+
│ │ └── sayHello() method
|
|
5515
5543
|
│ ├─┬ class SomeTypeJsii976
|
|
5516
5544
|
│ │ └─┬ members
|
|
5517
5545
|
│ │ ├── <initializer>() initializer
|
|
@@ -5973,6 +6001,12 @@ exports[`jsii-tree --members 1`] = `
|
|
|
5973
6001
|
│ │ └─┬ members
|
|
5974
6002
|
│ │ ├── property property
|
|
5975
6003
|
│ │ └── yetAnoterOne property
|
|
6004
|
+
│ ├─┬ interface ChildStruct
|
|
6005
|
+
│ │ └─┬ members
|
|
6006
|
+
│ │ └── field2 property
|
|
6007
|
+
│ ├─┬ interface ParentStruct
|
|
6008
|
+
│ │ └─┬ members
|
|
6009
|
+
│ │ └── field1 property
|
|
5976
6010
|
│ ├─┬ interface StableStruct
|
|
5977
6011
|
│ │ └─┬ members
|
|
5978
6012
|
│ │ └── readonlyProperty property
|
|
@@ -6532,6 +6566,7 @@ exports[`jsii-tree --types 1`] = `
|
|
|
6532
6566
|
│ ├── class SingleInstanceTwoTypes
|
|
6533
6567
|
│ ├── class SingletonInt
|
|
6534
6568
|
│ ├── class SingletonString
|
|
6569
|
+
│ ├── class SomeContainingClass
|
|
6535
6570
|
│ ├── class SomeTypeJsii976
|
|
6536
6571
|
│ ├── class StableClass
|
|
6537
6572
|
│ ├── class StaticContext
|
|
@@ -6631,6 +6666,8 @@ exports[`jsii-tree --types 1`] = `
|
|
|
6631
6666
|
│ ├── interface RootStruct
|
|
6632
6667
|
│ ├── interface SecondLevelStruct
|
|
6633
6668
|
│ ├── interface SmellyStruct
|
|
6669
|
+
│ ├── interface ChildStruct
|
|
6670
|
+
│ ├── interface ParentStruct
|
|
6634
6671
|
│ ├── interface StableStruct
|
|
6635
6672
|
│ ├── interface StructA
|
|
6636
6673
|
│ ├── interface StructB
|
|
@@ -2491,6 +2491,11 @@ exports[`showAll 1`] = `
|
|
|
2491
2491
|
│ │ │ └─┬ value
|
|
2492
2492
|
│ │ │ └── type: string
|
|
2493
2493
|
│ │ └── returns: boolean
|
|
2494
|
+
│ ├─┬ class SomeContainingClass
|
|
2495
|
+
│ │ └─┬ members
|
|
2496
|
+
│ │ ├── <initializer>() initializer
|
|
2497
|
+
│ │ └─┬ sayHello() method
|
|
2498
|
+
│ │ └── returns: string
|
|
2494
2499
|
│ ├─┬ class SomeTypeJsii976
|
|
2495
2500
|
│ │ └─┬ members
|
|
2496
2501
|
│ │ ├── <initializer>() initializer
|
|
@@ -3637,6 +3642,20 @@ exports[`showAll 1`] = `
|
|
|
3637
3642
|
│ │ ├── abstract
|
|
3638
3643
|
│ │ ├── immutable
|
|
3639
3644
|
│ │ └── type: boolean
|
|
3645
|
+
│ ├─┬ interface ChildStruct
|
|
3646
|
+
│ │ ├─┬ interfaces
|
|
3647
|
+
│ │ │ └── ParentStruct
|
|
3648
|
+
│ │ └─┬ members
|
|
3649
|
+
│ │ └─┬ field2 property
|
|
3650
|
+
│ │ ├── abstract
|
|
3651
|
+
│ │ ├── immutable
|
|
3652
|
+
│ │ └── type: string
|
|
3653
|
+
│ ├─┬ interface ParentStruct
|
|
3654
|
+
│ │ └─┬ members
|
|
3655
|
+
│ │ └─┬ field1 property
|
|
3656
|
+
│ │ ├── abstract
|
|
3657
|
+
│ │ ├── immutable
|
|
3658
|
+
│ │ └── type: string
|
|
3640
3659
|
│ ├─┬ interface StableStruct
|
|
3641
3660
|
│ │ └─┬ members
|
|
3642
3661
|
│ │ └─┬ readonlyProperty property
|
|
@@ -4394,6 +4413,7 @@ exports[`types 1`] = `
|
|
|
4394
4413
|
│ ├── class SingleInstanceTwoTypes
|
|
4395
4414
|
│ ├── class SingletonInt
|
|
4396
4415
|
│ ├── class SingletonString
|
|
4416
|
+
│ ├── class SomeContainingClass
|
|
4397
4417
|
│ ├── class SomeTypeJsii976
|
|
4398
4418
|
│ ├── class StableClass
|
|
4399
4419
|
│ ├── class StaticContext
|
|
@@ -4493,6 +4513,8 @@ exports[`types 1`] = `
|
|
|
4493
4513
|
│ ├── interface RootStruct
|
|
4494
4514
|
│ ├── interface SecondLevelStruct
|
|
4495
4515
|
│ ├── interface SmellyStruct
|
|
4516
|
+
│ ├── interface ChildStruct
|
|
4517
|
+
│ ├── interface ParentStruct
|
|
4496
4518
|
│ ├── interface StableStruct
|
|
4497
4519
|
│ ├── interface StructA
|
|
4498
4520
|
│ ├── interface StructB
|
|
@@ -140,6 +140,7 @@ exports[`TypeSystem.classes lists all the classes in the typesystem 1`] = `
|
|
|
140
140
|
"jsii-calc.SingleInstanceTwoTypes",
|
|
141
141
|
"jsii-calc.SingletonInt",
|
|
142
142
|
"jsii-calc.SingletonString",
|
|
143
|
+
"jsii-calc.SomeContainingClass",
|
|
143
144
|
"jsii-calc.SomeTypeJsii976",
|
|
144
145
|
"jsii-calc.StableClass",
|
|
145
146
|
"jsii-calc.StaticContext",
|
package/test/type-system.test.js
CHANGED
|
@@ -13,6 +13,13 @@ beforeAll(async () => {
|
|
|
13
13
|
supportedFeatures: features_1.TEST_FEATURES,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
|
+
test('jsii-calc assembly has package.json data attached', () => {
|
|
17
|
+
const asm = typesys.assemblies.find((a) => a.name === 'jsii-calc');
|
|
18
|
+
expect(asm?.packageJson).toMatchObject({
|
|
19
|
+
name: 'jsii-calc',
|
|
20
|
+
homepage: 'https://github.com/aws/jsii',
|
|
21
|
+
});
|
|
22
|
+
});
|
|
16
23
|
test('TypeSystem.hasAssembly', () => {
|
|
17
24
|
expect(typesys.includesAssembly('@foo/bar')).toBeFalsy();
|
|
18
25
|
expect(typesys.includesAssembly('jsii-calc')).toBeTruthy();
|
package/test/util.js
CHANGED
|
@@ -10,7 +10,11 @@ function typeSystemFromSource(source, cb) {
|
|
|
10
10
|
}
|
|
11
11
|
function assemblyFromSource(source, cb) {
|
|
12
12
|
const ass = (0, jsii_1.sourceToAssemblyHelper)(source, cb);
|
|
13
|
+
let pjData = {};
|
|
14
|
+
if (typeof source === 'object' && 'package.json' in source) {
|
|
15
|
+
pjData = JSON.parse(source['package.json']);
|
|
16
|
+
}
|
|
13
17
|
const ts = new lib_1.TypeSystem();
|
|
14
|
-
return ts.addAssembly(new lib_1.Assembly(ts, ass));
|
|
18
|
+
return ts.addAssembly(new lib_1.Assembly(ts, ass, '/fake-dir', pjData));
|
|
15
19
|
}
|
|
16
20
|
//# sourceMappingURL=util.js.map
|