jsii 5.9.5-dev.4 → 5.9.5
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/assembler.d.ts +1 -24
- package/lib/assembler.js +38 -258
- package/lib/assembler.js.map +1 -1
- package/lib/helpers.d.ts +3 -37
- package/lib/helpers.js +6 -27
- package/lib/helpers.js.map +1 -1
- package/lib/jsii-diagnostic.d.ts +0 -5
- package/lib/jsii-diagnostic.js +0 -25
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/project-info.js +1 -2
- package/lib/project-info.js.map +1 -1
- package/lib/version.d.ts +2 -2
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -1
- package/package.json +4 -4
- package/lib/sets.d.ts +0 -16
- package/lib/sets.js +0 -41
- package/lib/sets.js.map +0 -1
- package/lib/type-reference.d.ts +0 -10
- package/lib/type-reference.js +0 -52
- package/lib/type-reference.js.map +0 -1
- package/lib/type-visitor.d.ts +0 -19
- package/lib/type-visitor.js +0 -51
- package/lib/type-visitor.js.map +0 -1
package/lib/sets.js
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.Sets = void 0;
|
4
|
-
class Sets {
|
5
|
-
/**
|
6
|
-
* Return the intersection of N sets
|
7
|
-
*/
|
8
|
-
static intersection(...xss) {
|
9
|
-
if (xss.length === 0) {
|
10
|
-
return new Set();
|
11
|
-
}
|
12
|
-
const ret = new Set(xss[0]);
|
13
|
-
for (const x of xss[0]) {
|
14
|
-
if (!xss.every((xs) => xs.has(x))) {
|
15
|
-
ret.delete(x);
|
16
|
-
}
|
17
|
-
}
|
18
|
-
return ret;
|
19
|
-
}
|
20
|
-
/**
|
21
|
-
* Return the union of N sets
|
22
|
-
*/
|
23
|
-
static union(...xss) {
|
24
|
-
return new Set(xss.flatMap((xs) => Array.from(xs)));
|
25
|
-
}
|
26
|
-
/**
|
27
|
-
* Return the diff of 2 sets
|
28
|
-
*/
|
29
|
-
static diff(xs, ys) {
|
30
|
-
return new Set(Array.from(xs).filter((x) => !ys.has(x)));
|
31
|
-
}
|
32
|
-
static *intersect(xs, ys) {
|
33
|
-
for (const x of xs) {
|
34
|
-
if (ys.has(x)) {
|
35
|
-
yield x;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
exports.Sets = Sets;
|
41
|
-
//# sourceMappingURL=sets.js.map
|
package/lib/sets.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sets.js","sourceRoot":"","sources":["../src/sets.ts"],"names":[],"mappings":";;;AAAA,MAAsB,IAAI;IACxB;;OAEG;IACI,MAAM,CAAC,YAAY,CAAI,GAAG,GAAkB;QACjD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,GAAG,EAAE,CAAC;QACnB,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAI,GAAG,GAAkB;QAC1C,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,IAAI,CAAI,EAAU,EAAE,EAAU;QAC1C,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,CAAC,SAAS,CAAI,EAAU,EAAE,EAAU;QAChD,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YACnB,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACd,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAtCD,oBAsCC","sourcesContent":["export abstract class Sets {\n /**\n * Return the intersection of N sets\n */\n public static intersection<T>(...xss: Array<Set<T>>): Set<T> {\n if (xss.length === 0) {\n return new Set();\n }\n const ret = new Set(xss[0]);\n for (const x of xss[0]) {\n if (!xss.every((xs) => xs.has(x))) {\n ret.delete(x);\n }\n }\n return ret;\n }\n\n /**\n * Return the union of N sets\n */\n public static union<T>(...xss: Array<Set<T>>): Set<T> {\n return new Set(xss.flatMap((xs) => Array.from(xs)));\n }\n\n /**\n * Return the diff of 2 sets\n */\n public static diff<T>(xs: Set<T>, ys: Set<T>) {\n return new Set(Array.from(xs).filter((x) => !ys.has(x)));\n }\n\n public static *intersect<T>(xs: Set<T>, ys: Set<T>) {\n for (const x of xs) {\n if (ys.has(x)) {\n yield x;\n }\n }\n }\n}\n"]}
|
package/lib/type-reference.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import * as spec from '@jsii/spec';
|
2
|
-
/**
|
3
|
-
* Convert a type reference to a string
|
4
|
-
*/
|
5
|
-
export declare function typeReferenceToString(x: spec.TypeReference): string;
|
6
|
-
/**
|
7
|
-
* Return whether the given type references are equal
|
8
|
-
*/
|
9
|
-
export declare function typeReferenceEqual(a: spec.TypeReference, b: spec.TypeReference): boolean;
|
10
|
-
//# sourceMappingURL=type-reference.d.ts.map
|
package/lib/type-reference.js
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.typeReferenceToString = typeReferenceToString;
|
4
|
-
exports.typeReferenceEqual = typeReferenceEqual;
|
5
|
-
const spec = require("@jsii/spec");
|
6
|
-
const type_visitor_1 = require("./type-visitor");
|
7
|
-
/**
|
8
|
-
* Convert a type reference to a string
|
9
|
-
*/
|
10
|
-
function typeReferenceToString(x) {
|
11
|
-
return (0, type_visitor_1.visitTypeReference)(x, {
|
12
|
-
named: function (ref) {
|
13
|
-
return ref.fqn;
|
14
|
-
},
|
15
|
-
primitive: function (ref) {
|
16
|
-
return ref.primitive;
|
17
|
-
},
|
18
|
-
collection: function (ref) {
|
19
|
-
return `${ref.collection.kind}<${typeReferenceToString(ref.collection.elementtype)}>`;
|
20
|
-
},
|
21
|
-
union: function (ref) {
|
22
|
-
return ref.union.types.map(typeReferenceToString).join(' | ');
|
23
|
-
},
|
24
|
-
intersection: function (ref) {
|
25
|
-
return ref.intersection.types.map(typeReferenceToString).join(' & ');
|
26
|
-
},
|
27
|
-
});
|
28
|
-
}
|
29
|
-
/**
|
30
|
-
* Return whether the given type references are equal
|
31
|
-
*/
|
32
|
-
function typeReferenceEqual(a, b) {
|
33
|
-
if (spec.isNamedTypeReference(a) && spec.isNamedTypeReference(b)) {
|
34
|
-
return a.fqn === b.fqn;
|
35
|
-
}
|
36
|
-
if (spec.isPrimitiveTypeReference(a) && spec.isPrimitiveTypeReference(b)) {
|
37
|
-
return a.primitive === b.primitive;
|
38
|
-
}
|
39
|
-
if (spec.isCollectionTypeReference(a) && spec.isCollectionTypeReference(b)) {
|
40
|
-
return (a.collection.kind === b.collection.kind && typeReferenceEqual(a.collection.elementtype, b.collection.elementtype));
|
41
|
-
}
|
42
|
-
if (spec.isUnionTypeReference(a) && spec.isUnionTypeReference(b)) {
|
43
|
-
return (a.union.types.length === b.union.types.length &&
|
44
|
-
a.union.types.every((aType, i) => typeReferenceEqual(aType, b.union.types[i])));
|
45
|
-
}
|
46
|
-
if (spec.isIntersectionTypeReference(a) && spec.isIntersectionTypeReference(b)) {
|
47
|
-
return (a.intersection.types.length === b.intersection.types.length &&
|
48
|
-
a.intersection.types.every((aType, i) => typeReferenceEqual(aType, b.intersection.types[i])));
|
49
|
-
}
|
50
|
-
return false;
|
51
|
-
}
|
52
|
-
//# sourceMappingURL=type-reference.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"type-reference.js","sourceRoot":"","sources":["../src/type-reference.ts"],"names":[],"mappings":";;AAMA,sDAkBC;AAKD,gDAyBC;AAtDD,mCAAmC;AACnC,iDAAoD;AAEpD;;GAEG;AACH,SAAgB,qBAAqB,CAAC,CAAqB;IACzD,OAAO,IAAA,iCAAkB,EAAS,CAAC,EAAE;QACnC,KAAK,EAAE,UAAU,GAA4B;YAC3C,OAAO,GAAG,CAAC,GAAG,CAAC;QACjB,CAAC;QACD,SAAS,EAAE,UAAU,GAAgC;YACnD,OAAO,GAAG,CAAC,SAAS,CAAC;QACvB,CAAC;QACD,UAAU,EAAE,UAAU,GAAiC;YACrD,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC;QACxF,CAAC;QACD,KAAK,EAAE,UAAU,GAA4B;YAC3C,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChE,CAAC;QACD,YAAY,EAAE,UAAU,GAAmC;YACzD,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvE,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC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,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM;YAC3D,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAC7F,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import * as spec from '@jsii/spec';\nimport { visitTypeReference } from './type-visitor';\n\n/**\n * Convert a type reference to a string\n */\nexport function typeReferenceToString(x: spec.TypeReference): string {\n return visitTypeReference<string>(x, {\n named: function (ref: spec.NamedTypeReference) {\n return ref.fqn;\n },\n primitive: function (ref: spec.PrimitiveTypeReference) {\n return ref.primitive;\n },\n collection: function (ref: spec.CollectionTypeReference) {\n return `${ref.collection.kind}<${typeReferenceToString(ref.collection.elementtype)}>`;\n },\n union: function (ref: spec.UnionTypeReference) {\n return ref.union.types.map(typeReferenceToString).join(' | ');\n },\n intersection: function (ref: spec.IntersectionTypeReference) {\n return ref.intersection.types.map(typeReferenceToString).join(' & ');\n },\n });\n}\n\n/**\n * Return whether the given type references are equal\n */\nexport function typeReferenceEqual(a: spec.TypeReference, b: spec.TypeReference): boolean {\n if (spec.isNamedTypeReference(a) && spec.isNamedTypeReference(b)) {\n return a.fqn === b.fqn;\n }\n if (spec.isPrimitiveTypeReference(a) && spec.isPrimitiveTypeReference(b)) {\n return a.primitive === b.primitive;\n }\n if (spec.isCollectionTypeReference(a) && spec.isCollectionTypeReference(b)) {\n return (\n a.collection.kind === b.collection.kind && typeReferenceEqual(a.collection.elementtype, b.collection.elementtype)\n );\n }\n if (spec.isUnionTypeReference(a) && spec.isUnionTypeReference(b)) {\n return (\n a.union.types.length === b.union.types.length &&\n a.union.types.every((aType, i) => typeReferenceEqual(aType, b.union.types[i]))\n );\n }\n if (spec.isIntersectionTypeReference(a) && spec.isIntersectionTypeReference(b)) {\n return (\n a.intersection.types.length === b.intersection.types.length &&\n a.intersection.types.every((aType, i) => typeReferenceEqual(aType, b.intersection.types[i]))\n );\n }\n return false;\n}\n"]}
|
package/lib/type-visitor.d.ts
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import * as spec from '@jsii/spec';
|
2
|
-
export interface TypeReferenceVisitor<A = void> {
|
3
|
-
named(ref: spec.NamedTypeReference): A;
|
4
|
-
primitive(ref: spec.PrimitiveTypeReference): A;
|
5
|
-
collection(ref: spec.CollectionTypeReference): A;
|
6
|
-
union(ref: spec.UnionTypeReference): A;
|
7
|
-
intersection(ref: spec.IntersectionTypeReference): A;
|
8
|
-
}
|
9
|
-
export declare function visitTypeReference<A>(typeRef: spec.TypeReference, visitor: TypeReferenceVisitor<A>): A;
|
10
|
-
export interface TypeVisitor<A = void> {
|
11
|
-
classType(t: spec.ClassType): A;
|
12
|
-
interfaceType(t: spec.InterfaceType): A;
|
13
|
-
dataType(t: spec.InterfaceType): A;
|
14
|
-
enumType(t: spec.EnumType): A;
|
15
|
-
}
|
16
|
-
export declare function visitType<A>(t: spec.Type, visitor: TypeVisitor<A>): A;
|
17
|
-
export declare function isDataType(t: spec.Type): t is spec.InterfaceType;
|
18
|
-
export declare function isBehavioralInterfaceType(t: spec.Type): t is spec.InterfaceType;
|
19
|
-
//# sourceMappingURL=type-visitor.d.ts.map
|
package/lib/type-visitor.js
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.visitTypeReference = visitTypeReference;
|
4
|
-
exports.visitType = visitType;
|
5
|
-
exports.isDataType = isDataType;
|
6
|
-
exports.isBehavioralInterfaceType = isBehavioralInterfaceType;
|
7
|
-
const spec = require("@jsii/spec");
|
8
|
-
function visitTypeReference(typeRef, visitor) {
|
9
|
-
if (spec.isNamedTypeReference(typeRef)) {
|
10
|
-
return visitor.named(typeRef);
|
11
|
-
}
|
12
|
-
else if (spec.isPrimitiveTypeReference(typeRef)) {
|
13
|
-
return visitor.primitive(typeRef);
|
14
|
-
}
|
15
|
-
else if (spec.isCollectionTypeReference(typeRef)) {
|
16
|
-
return visitor.collection(typeRef);
|
17
|
-
}
|
18
|
-
else if (spec.isUnionTypeReference(typeRef)) {
|
19
|
-
return visitor.union(typeRef);
|
20
|
-
}
|
21
|
-
else if (spec.isIntersectionTypeReference(typeRef)) {
|
22
|
-
return visitor.intersection(typeRef);
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
throw new Error(`Unknown type reference: ${JSON.stringify(typeRef)}`);
|
26
|
-
}
|
27
|
-
}
|
28
|
-
function visitType(t, visitor) {
|
29
|
-
if (spec.isClassType(t)) {
|
30
|
-
return visitor.classType(t);
|
31
|
-
}
|
32
|
-
else if (spec.isInterfaceType(t) && t.datatype) {
|
33
|
-
return visitor.dataType(t);
|
34
|
-
}
|
35
|
-
else if (spec.isInterfaceType(t)) {
|
36
|
-
return visitor.interfaceType(t);
|
37
|
-
}
|
38
|
-
else if (spec.isEnumType(t)) {
|
39
|
-
return visitor.enumType(t);
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
throw new Error(`Unknown type: ${JSON.stringify(t)}`);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
function isDataType(t) {
|
46
|
-
return spec.isInterfaceType(t) && !!t.datatype;
|
47
|
-
}
|
48
|
-
function isBehavioralInterfaceType(t) {
|
49
|
-
return spec.isInterfaceType(t) && !t.datatype;
|
50
|
-
}
|
51
|
-
//# sourceMappingURL=type-visitor.js.map
|
package/lib/type-visitor.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"type-visitor.js","sourceRoot":"","sources":["../src/type-visitor.ts"],"names":[],"mappings":";;AAUA,gDAcC;AASD,8BAYC;AAED,gCAEC;AAED,8DAEC;AArDD,mCAAmC;AAUnC,SAAgB,kBAAkB,CAAI,OAA2B,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AC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,CAAY;IACrC,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjD,CAAC;AAED,SAAgB,yBAAyB,CAAC,CAAY;IACpD,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChD,CAAC","sourcesContent":["import * as spec from '@jsii/spec';\n\nexport interface TypeReferenceVisitor<A = void> {\n named(ref: spec.NamedTypeReference): A;\n primitive(ref: spec.PrimitiveTypeReference): A;\n collection(ref: spec.CollectionTypeReference): A;\n union(ref: spec.UnionTypeReference): A;\n intersection(ref: spec.IntersectionTypeReference): A;\n}\n\nexport function visitTypeReference<A>(typeRef: spec.TypeReference, visitor: TypeReferenceVisitor<A>) {\n if (spec.isNamedTypeReference(typeRef)) {\n return visitor.named(typeRef);\n } else if (spec.isPrimitiveTypeReference(typeRef)) {\n return visitor.primitive(typeRef);\n } else if (spec.isCollectionTypeReference(typeRef)) {\n return visitor.collection(typeRef);\n } else if (spec.isUnionTypeReference(typeRef)) {\n return visitor.union(typeRef);\n } else if (spec.isIntersectionTypeReference(typeRef)) {\n return visitor.intersection(typeRef);\n } else {\n throw new Error(`Unknown type reference: ${JSON.stringify(typeRef)}`);\n }\n}\n\nexport interface TypeVisitor<A = void> {\n classType(t: spec.ClassType): A;\n interfaceType(t: spec.InterfaceType): A;\n dataType(t: spec.InterfaceType): A;\n enumType(t: spec.EnumType): A;\n}\n\nexport function visitType<A>(t: spec.Type, visitor: TypeVisitor<A>) {\n if (spec.isClassType(t)) {\n return visitor.classType(t);\n } else if (spec.isInterfaceType(t) && t.datatype) {\n return visitor.dataType(t);\n } else if (spec.isInterfaceType(t)) {\n return visitor.interfaceType(t);\n } else if (spec.isEnumType(t)) {\n return visitor.enumType(t);\n } else {\n throw new Error(`Unknown type: ${JSON.stringify(t)}`);\n }\n}\n\nexport function isDataType(t: spec.Type): t is spec.InterfaceType {\n return spec.isInterfaceType(t) && !!t.datatype;\n}\n\nexport function isBehavioralInterfaceType(t: spec.Type): t is spec.InterfaceType {\n return spec.isInterfaceType(t) && !t.datatype;\n}\n"]}
|