quicktype 17.0.1 → 17.0.3
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/dist/cli/CompressedJSONFromStream.js +26 -38
- package/dist/cli/GraphQLIntrospection.js +33 -41
- package/dist/cli/TypeSource.d.ts +1 -1
- package/dist/cli/URLGrammar.js +4 -3
- package/dist/cli/index.js +363 -364
- package/dist/quicktype-core/Annotation.js +2 -0
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
- package/dist/quicktype-core/ConvenienceRenderer.js +104 -81
- package/dist/quicktype-core/DateTime.js +1 -0
- package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
- package/dist/quicktype-core/DeclarationIR.js +13 -10
- package/dist/quicktype-core/EncodedMarkovChain.js +1 -0
- package/dist/quicktype-core/GatherNames.js +47 -25
- package/dist/quicktype-core/Graph.d.ts +2 -2
- package/dist/quicktype-core/Graph.js +23 -19
- package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
- package/dist/quicktype-core/GraphRewriting.js +65 -54
- package/dist/quicktype-core/MakeTransformations.js +23 -22
- package/dist/quicktype-core/MarkovChain.d.ts +3 -3
- package/dist/quicktype-core/MarkovChain.js +9 -8
- package/dist/quicktype-core/Messages.d.ts +3 -3
- package/dist/quicktype-core/Messages.js +8 -3
- package/dist/quicktype-core/Naming.d.ts +11 -11
- package/dist/quicktype-core/Naming.js +76 -61
- package/dist/quicktype-core/Renderer.d.ts +6 -6
- package/dist/quicktype-core/Renderer.js +34 -17
- package/dist/quicktype-core/RendererOptions.d.ts +5 -5
- package/dist/quicktype-core/RendererOptions.js +6 -3
- package/dist/quicktype-core/Run.d.ts +9 -9
- package/dist/quicktype-core/Run.js +72 -67
- package/dist/quicktype-core/Source.d.ts +3 -3
- package/dist/quicktype-core/Source.js +19 -18
- package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
- package/dist/quicktype-core/TargetLanguage.js +6 -2
- package/dist/quicktype-core/Transformers.d.ts +25 -25
- package/dist/quicktype-core/Transformers.js +94 -66
- package/dist/quicktype-core/Type.d.ts +41 -43
- package/dist/quicktype-core/Type.js +96 -71
- package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
- package/dist/quicktype-core/TypeBuilder.js +53 -47
- package/dist/quicktype-core/TypeGraph.d.ts +4 -4
- package/dist/quicktype-core/TypeGraph.js +49 -40
- package/dist/quicktype-core/TypeUtils.d.ts +2 -2
- package/dist/quicktype-core/TypeUtils.js +23 -22
- package/dist/quicktype-core/UnifyClasses.js +16 -12
- package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
- package/dist/quicktype-core/UnionBuilder.js +33 -30
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
- package/dist/quicktype-core/attributes/AccessorNames.js +18 -17
- package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
- package/dist/quicktype-core/attributes/Constraints.js +8 -4
- package/dist/quicktype-core/attributes/Description.js +6 -5
- package/dist/quicktype-core/attributes/EnumValues.js +4 -3
- package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
- package/dist/quicktype-core/attributes/StringTypes.js +24 -21
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
- package/dist/quicktype-core/attributes/TypeAttributes.js +12 -10
- package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
- package/dist/quicktype-core/attributes/TypeNames.js +49 -21
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
- package/dist/quicktype-core/attributes/URIAttributes.js +10 -6
- package/dist/quicktype-core/index.js +128 -125
- package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
- package/dist/quicktype-core/input/CompressedJSON.js +49 -54
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +5 -13
- package/dist/quicktype-core/input/Inference.d.ts +2 -2
- package/dist/quicktype-core/input/Inference.js +25 -17
- package/dist/quicktype-core/input/Inputs.d.ts +2 -2
- package/dist/quicktype-core/input/Inputs.js +38 -54
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
- package/dist/quicktype-core/input/JSONSchemaInput.js +503 -523
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
- package/dist/quicktype-core/input/JSONSchemaStore.js +24 -35
- package/dist/quicktype-core/input/PostmanCollection.js +2 -1
- package/dist/quicktype-core/input/io/NodeIO.js +55 -44
- package/dist/quicktype-core/input/io/get-stream/index.js +6 -2
- package/dist/quicktype-core/language/All.js +3 -2
- package/dist/quicktype-core/language/CPlusPlus.d.ts +8 -8
- package/dist/quicktype-core/language/CPlusPlus.js +185 -151
- package/dist/quicktype-core/language/CSharp.d.ts +7 -7
- package/dist/quicktype-core/language/CSharp.js +82 -72
- package/dist/quicktype-core/language/Crystal.d.ts +2 -2
- package/dist/quicktype-core/language/Crystal.js +18 -17
- package/dist/quicktype-core/language/Dart.d.ts +4 -4
- package/dist/quicktype-core/language/Dart.js +36 -34
- package/dist/quicktype-core/language/Elm.d.ts +6 -6
- package/dist/quicktype-core/language/Elm.js +47 -45
- package/dist/quicktype-core/language/Golang.d.ts +4 -4
- package/dist/quicktype-core/language/Golang.js +23 -20
- package/dist/quicktype-core/language/Haskell.d.ts +5 -5
- package/dist/quicktype-core/language/Haskell.js +25 -23
- package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
- package/dist/quicktype-core/language/JSONSchema.js +17 -16
- package/dist/quicktype-core/language/Java.d.ts +2 -2
- package/dist/quicktype-core/language/Java.js +97 -97
- package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
- package/dist/quicktype-core/language/JavaScript.js +19 -17
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +15 -13
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +12 -11
- package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
- package/dist/quicktype-core/language/Kotlin.js +39 -37
- package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
- package/dist/quicktype-core/language/Objective-C.js +45 -41
- package/dist/quicktype-core/language/Php.d.ts +2 -2
- package/dist/quicktype-core/language/Php.js +66 -41
- package/dist/quicktype-core/language/Pike.d.ts +1 -1
- package/dist/quicktype-core/language/Pike.js +18 -17
- package/dist/quicktype-core/language/Python.d.ts +8 -8
- package/dist/quicktype-core/language/Python.js +63 -64
- package/dist/quicktype-core/language/Rust.d.ts +2 -2
- package/dist/quicktype-core/language/Rust.js +21 -19
- package/dist/quicktype-core/language/Swift.d.ts +7 -7
- package/dist/quicktype-core/language/Swift.js +568 -565
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
- package/dist/quicktype-core/language/TypeScriptFlow.js +28 -26
- package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
- package/dist/quicktype-core/language/ruby/index.js +49 -24
- package/dist/quicktype-core/language/ruby/keywords.js +1 -0
- package/dist/quicktype-core/rewrites/CombineClasses.js +9 -8
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
- package/dist/quicktype-core/rewrites/ExpandStrings.js +18 -17
- package/dist/quicktype-core/rewrites/FlattenStrings.js +7 -6
- package/dist/quicktype-core/rewrites/FlattenUnions.js +9 -8
- package/dist/quicktype-core/rewrites/InferMaps.js +11 -10
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +8 -7
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +68 -67
- package/dist/quicktype-core/support/Acronyms.js +3 -1
- package/dist/quicktype-core/support/Chance.js +10 -0
- package/dist/quicktype-core/support/Converters.js +1 -0
- package/dist/quicktype-core/support/Strings.d.ts +4 -4
- package/dist/quicktype-core/support/Strings.js +17 -16
- package/dist/quicktype-core/support/Support.d.ts +1 -1
- package/dist/quicktype-core/support/Support.js +30 -6
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
- package/dist/quicktype-graphql-input/GraphQLSchema.js +1 -0
- package/dist/quicktype-graphql-input/index.d.ts +1 -1
- package/dist/quicktype-graphql-input/index.js +229 -212
- package/dist/quicktype-typescript-input/index.js +30 -5
- package/package.json +25 -19
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenStrings = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const TypeUtils_1 = require("../TypeUtils");
|
|
5
6
|
const Support_1 = require("../support/Support");
|
|
@@ -13,15 +14,15 @@ function unionNeedsReplacing(u) {
|
|
|
13
14
|
const stringType = u.findMember("string");
|
|
14
15
|
if (stringType === undefined)
|
|
15
16
|
return undefined;
|
|
16
|
-
Support_1.assert(!TypeUtils_1.stringTypesForType(stringType).isRestricted, "We must only flatten strings if we have no restriced strings");
|
|
17
|
+
(0, Support_1.assert)(!(0, TypeUtils_1.stringTypesForType)(stringType).isRestricted, "We must only flatten strings if we have no restriced strings");
|
|
17
18
|
return stringMembers;
|
|
18
19
|
}
|
|
19
20
|
// Replaces all string types in an enum with the basic string type.
|
|
20
21
|
function replaceUnion(group, builder, forwardingRef) {
|
|
21
|
-
Support_1.assert(group.size === 1);
|
|
22
|
-
const u = Support_1.defined(collection_utils_1.iterableFirst(group));
|
|
23
|
-
const stringMembers = Support_1.defined(unionNeedsReplacing(u));
|
|
24
|
-
const stringAttributes = TypeUtils_1.combineTypeAttributesOfTypes("union", stringMembers);
|
|
22
|
+
(0, Support_1.assert)(group.size === 1);
|
|
23
|
+
const u = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(group));
|
|
24
|
+
const stringMembers = (0, Support_1.defined)(unionNeedsReplacing(u));
|
|
25
|
+
const stringAttributes = (0, TypeUtils_1.combineTypeAttributesOfTypes)("union", stringMembers);
|
|
25
26
|
const types = [];
|
|
26
27
|
for (const t of u.members) {
|
|
27
28
|
if (stringMembers.has(t))
|
|
@@ -29,7 +30,7 @@ function replaceUnion(group, builder, forwardingRef) {
|
|
|
29
30
|
types.push(builder.reconstituteType(t));
|
|
30
31
|
}
|
|
31
32
|
if (types.length === 0) {
|
|
32
|
-
return builder.getStringType(TypeAttributes_1.combineTypeAttributes("union", stringAttributes, u.getAttributes()), undefined, forwardingRef);
|
|
33
|
+
return builder.getStringType((0, TypeAttributes_1.combineTypeAttributes)("union", stringAttributes, u.getAttributes()), undefined, forwardingRef);
|
|
33
34
|
}
|
|
34
35
|
types.push(builder.getStringType(stringAttributes, undefined));
|
|
35
36
|
return builder.getUnionType(u.getAttributes(), new Set(types), forwardingRef);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenUnions = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const TypeGraph_1 = require("../TypeGraph");
|
|
5
6
|
const Type_1 = require("../Type");
|
|
@@ -12,22 +13,22 @@ function flattenUnions(graph, stringTypeMapping, conflateNumbers, makeObjectType
|
|
|
12
13
|
let needsRepeat = false;
|
|
13
14
|
function replace(types, builder, forwardingRef) {
|
|
14
15
|
const unionBuilder = new UnifyClasses_1.UnifyUnionBuilder(builder, makeObjectTypes, true, trefs => {
|
|
15
|
-
Support_1.assert(trefs.length > 0, "Must have at least one type to build union");
|
|
16
|
-
trefs = trefs.map(tref => builder.reconstituteType(TypeGraph_1.derefTypeRef(tref, graph)));
|
|
16
|
+
(0, Support_1.assert)(trefs.length > 0, "Must have at least one type to build union");
|
|
17
|
+
trefs = trefs.map(tref => builder.reconstituteType((0, TypeGraph_1.derefTypeRef)(tref, graph)));
|
|
17
18
|
if (trefs.length === 1) {
|
|
18
19
|
return trefs[0];
|
|
19
20
|
}
|
|
20
21
|
needsRepeat = true;
|
|
21
22
|
return builder.getUnionType(TypeAttributes_1.emptyTypeAttributes, new Set(trefs));
|
|
22
23
|
});
|
|
23
|
-
return UnifyClasses_1.unifyTypes(types, TypeAttributes_1.emptyTypeAttributes, builder, unionBuilder, conflateNumbers, forwardingRef);
|
|
24
|
+
return (0, UnifyClasses_1.unifyTypes)(types, TypeAttributes_1.emptyTypeAttributes, builder, unionBuilder, conflateNumbers, forwardingRef);
|
|
24
25
|
}
|
|
25
|
-
const allUnions = collection_utils_1.setFilter(graph.allTypesUnordered(), t => t instanceof Type_1.UnionType);
|
|
26
|
-
const nonCanonicalUnions = collection_utils_1.setFilter(allUnions, u => !u.isCanonical);
|
|
26
|
+
const allUnions = (0, collection_utils_1.setFilter)(graph.allTypesUnordered(), t => t instanceof Type_1.UnionType);
|
|
27
|
+
const nonCanonicalUnions = (0, collection_utils_1.setFilter)(allUnions, u => !u.isCanonical);
|
|
27
28
|
let foundIntersection = false;
|
|
28
|
-
const groups = TypeUtils_1.makeGroupsToFlatten(nonCanonicalUnions, members => {
|
|
29
|
-
Messages_1.messageAssert(members.size > 0, "IRNoEmptyUnions", {});
|
|
30
|
-
if (!collection_utils_1.iterableSome(members, m => m instanceof Type_1.IntersectionType))
|
|
29
|
+
const groups = (0, TypeUtils_1.makeGroupsToFlatten)(nonCanonicalUnions, members => {
|
|
30
|
+
(0, Messages_1.messageAssert)(members.size > 0, "IRNoEmptyUnions", {});
|
|
31
|
+
if (!(0, collection_utils_1.iterableSome)(members, m => m instanceof Type_1.IntersectionType))
|
|
31
32
|
return true;
|
|
32
33
|
// FIXME: This is stupid. `flattenUnions` returns true when no more union
|
|
33
34
|
// flattening is necessary, but `resolveIntersections` can introduce new
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inferMaps = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const Type_1 = require("../Type");
|
|
5
6
|
const TypeUtils_1 = require("../TypeUtils");
|
|
@@ -11,9 +12,9 @@ const stringMapSizeThreshold = 50;
|
|
|
11
12
|
let markovChain = undefined;
|
|
12
13
|
function nameProbability(name) {
|
|
13
14
|
if (markovChain === undefined) {
|
|
14
|
-
markovChain = MarkovChain_1.load();
|
|
15
|
+
markovChain = (0, MarkovChain_1.load)();
|
|
15
16
|
}
|
|
16
|
-
return MarkovChain_1.evaluate(markovChain, name);
|
|
17
|
+
return (0, MarkovChain_1.evaluate)(markovChain, name);
|
|
17
18
|
}
|
|
18
19
|
function shouldBeMap(properties) {
|
|
19
20
|
// Only classes with a certain number of properties are inferred
|
|
@@ -23,13 +24,13 @@ function shouldBeMap(properties) {
|
|
|
23
24
|
return undefined;
|
|
24
25
|
// If all property names are digit-only, we always make a map, no
|
|
25
26
|
// questions asked.
|
|
26
|
-
if (collection_utils_1.iterableEvery(properties.keys(), n => /^[0-9]+$/.test(n))) {
|
|
27
|
-
return collection_utils_1.setMap(properties.values(), cp => cp.type);
|
|
27
|
+
if ((0, collection_utils_1.iterableEvery)(properties.keys(), n => /^[0-9]+$/.test(n))) {
|
|
28
|
+
return (0, collection_utils_1.setMap)(properties.values(), cp => cp.type);
|
|
28
29
|
}
|
|
29
30
|
// If all properties are strings or null then an object must have at least
|
|
30
31
|
// `stringMapSizeThreshold` to qualify as a map.
|
|
31
32
|
if (numProperties < stringMapSizeThreshold &&
|
|
32
|
-
collection_utils_1.iterableEvery(properties.values(), cp => Type_1.isPrimitiveStringTypeKind(cp.type.kind) || cp.type.kind === "null")) {
|
|
33
|
+
(0, collection_utils_1.iterableEvery)(properties.values(), cp => (0, Type_1.isPrimitiveStringTypeKind)(cp.type.kind) || cp.type.kind === "null")) {
|
|
33
34
|
return undefined;
|
|
34
35
|
}
|
|
35
36
|
if (numProperties < mapSizeThreshold) {
|
|
@@ -69,12 +70,12 @@ function shouldBeMap(properties) {
|
|
|
69
70
|
// Check that all the property types are the same, modulo nullability.
|
|
70
71
|
for (const [, p] of properties) {
|
|
71
72
|
// The set of types first property can be, minus null.
|
|
72
|
-
const nn = TypeUtils_1.removeNullFromType(p.type)[1];
|
|
73
|
+
const nn = (0, TypeUtils_1.removeNullFromType)(p.type)[1];
|
|
73
74
|
if (nn.size > 0) {
|
|
74
75
|
if (firstNonNullCases !== undefined) {
|
|
75
76
|
// The set of non-null cases for all other properties must
|
|
76
77
|
// be the the same, otherwise we won't infer a map.
|
|
77
|
-
if (!Type_1.setOperationCasesEqual(nn, firstNonNullCases, true, (a, b) => a.structurallyCompatible(b, true))) {
|
|
78
|
+
if (!(0, Type_1.setOperationCasesEqual)(nn, firstNonNullCases, true, (a, b) => a.structurallyCompatible(b, true))) {
|
|
78
79
|
canBeMap = false;
|
|
79
80
|
break;
|
|
80
81
|
}
|
|
@@ -92,11 +93,11 @@ function shouldBeMap(properties) {
|
|
|
92
93
|
}
|
|
93
94
|
function inferMaps(graph, stringTypeMapping, conflateNumbers, debugPrintReconstitution) {
|
|
94
95
|
function replaceClass(setOfOneClass, builder, forwardingRef) {
|
|
95
|
-
const c = Support_1.defined(collection_utils_1.iterableFirst(setOfOneClass));
|
|
96
|
+
const c = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(setOfOneClass));
|
|
96
97
|
const properties = c.getProperties();
|
|
97
98
|
const shouldBe = shouldBeMap(properties);
|
|
98
99
|
if (shouldBe === undefined) {
|
|
99
|
-
return Support_1.panic(`We shouldn't be replacing class ${c.getCombinedName()} with a map`);
|
|
100
|
+
return (0, Support_1.panic)(`We shouldn't be replacing class ${c.getCombinedName()} with a map`);
|
|
100
101
|
}
|
|
101
102
|
// Now reconstitute all the types in the new graph. TypeGraphs are
|
|
102
103
|
// immutable, so any change in the graph actually means building a new
|
|
@@ -104,7 +105,7 @@ function inferMaps(graph, stringTypeMapping, conflateNumbers, debugPrintReconsti
|
|
|
104
105
|
// Reconstituting a type means generating the "same" type in the new
|
|
105
106
|
// type graph. Except we don't get Type objects but TypeRef objects,
|
|
106
107
|
// which is a type-to-be.
|
|
107
|
-
return builder.getMapType(c.getAttributes(), UnifyClasses_1.unifyTypes(shouldBe, c.getAttributes(), builder, UnifyClasses_1.unionBuilderForUnification(builder, false, false, conflateNumbers), conflateNumbers), forwardingRef);
|
|
108
|
+
return builder.getMapType(c.getAttributes(), (0, UnifyClasses_1.unifyTypes)(shouldBe, c.getAttributes(), builder, (0, UnifyClasses_1.unionBuilderForUnification)(builder, false, false, conflateNumbers), conflateNumbers), forwardingRef);
|
|
108
109
|
}
|
|
109
110
|
const classesToReplace = Array.from(graph.allNamedTypesSeparated().objects).filter(o => {
|
|
110
111
|
if (!(o instanceof Type_1.ClassType))
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceObjectType = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const Support_1 = require("../support/Support");
|
|
5
6
|
const TypeAttributes_1 = require("../attributes/TypeAttributes");
|
|
6
7
|
function replaceObjectType(graph, stringTypeMapping, _conflateNumbers, leaveFullObjects, debugPrintReconstitution) {
|
|
7
8
|
function replace(setOfOneType, builder, forwardingRef) {
|
|
8
|
-
const o = Support_1.defined(collection_utils_1.iterableFirst(setOfOneType));
|
|
9
|
+
const o = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(setOfOneType));
|
|
9
10
|
const attributes = o.getAttributes();
|
|
10
11
|
const properties = o.getProperties();
|
|
11
12
|
const additionalProperties = o.getAdditionalProperties();
|
|
12
13
|
function reconstituteProperties() {
|
|
13
|
-
return collection_utils_1.mapMap(properties, cp => builder.makeClassProperty(builder.reconstituteTypeRef(cp.typeRef), cp.isOptional));
|
|
14
|
+
return (0, collection_utils_1.mapMap)(properties, cp => builder.makeClassProperty(builder.reconstituteTypeRef(cp.typeRef), cp.isOptional));
|
|
14
15
|
}
|
|
15
16
|
function makeClass() {
|
|
16
17
|
return builder.getUniqueClassType(attributes, true, reconstituteProperties(), forwardingRef);
|
|
17
18
|
}
|
|
18
19
|
function reconstituteAdditionalProperties() {
|
|
19
|
-
return builder.reconstituteType(Support_1.defined(additionalProperties));
|
|
20
|
+
return builder.reconstituteType((0, Support_1.defined)(additionalProperties));
|
|
20
21
|
}
|
|
21
22
|
if (additionalProperties === undefined) {
|
|
22
23
|
return makeClass();
|
|
@@ -30,10 +31,10 @@ function replaceObjectType(graph, stringTypeMapping, _conflateNumbers, leaveFull
|
|
|
30
31
|
return makeClass();
|
|
31
32
|
}
|
|
32
33
|
// FIXME: Warn that we're losing class semantics.
|
|
33
|
-
const propertyTypes = collection_utils_1.setMap(properties.values(), cp => cp.type).add(additionalProperties);
|
|
34
|
+
const propertyTypes = (0, collection_utils_1.setMap)(properties.values(), cp => cp.type).add(additionalProperties);
|
|
34
35
|
let union = builder.lookupTypeRefs(Array.from(propertyTypes).map(t => t.typeRef));
|
|
35
36
|
if (union === undefined) {
|
|
36
|
-
const reconstitutedTypes = collection_utils_1.setMap(propertyTypes, t => builder.reconstituteType(t));
|
|
37
|
+
const reconstitutedTypes = (0, collection_utils_1.setMap)(propertyTypes, t => builder.reconstituteType(t));
|
|
37
38
|
union = builder.getUniqueUnionType(TypeAttributes_1.emptyTypeAttributes, new Set(reconstitutedTypes));
|
|
38
39
|
// This is the direct unification alternative. Weirdly enough, it is a tiny
|
|
39
40
|
// bit slower. It gives the same results.
|
|
@@ -49,9 +50,9 @@ function replaceObjectType(graph, stringTypeMapping, _conflateNumbers, leaveFull
|
|
|
49
50
|
}
|
|
50
51
|
return builder.getMapType(attributes, union, forwardingRef);
|
|
51
52
|
}
|
|
52
|
-
const allObjectTypes = collection_utils_1.setFilter(graph.allTypesUnordered(), t => t.kind === "object");
|
|
53
|
+
const allObjectTypes = (0, collection_utils_1.setFilter)(graph.allTypesUnordered(), t => t.kind === "object");
|
|
53
54
|
const objectTypesToReplace = leaveFullObjects
|
|
54
|
-
? collection_utils_1.setFilter(allObjectTypes, o => o.getProperties().size === 0 || o.getAdditionalProperties() === undefined)
|
|
55
|
+
? (0, collection_utils_1.setFilter)(allObjectTypes, o => o.getProperties().size === 0 || o.getAdditionalProperties() === undefined)
|
|
55
56
|
: allObjectTypes;
|
|
56
57
|
const groups = Array.from(objectTypesToReplace).map(t => [t]);
|
|
57
58
|
return graph.rewrite("replace object type", stringTypeMapping, false, groups, debugPrintReconstitution, replace);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveIntersections = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const UnionBuilder_1 = require("../UnionBuilder");
|
|
5
6
|
const Type_1 = require("../Type");
|
|
@@ -7,56 +8,59 @@ const TypeUtils_1 = require("../TypeUtils");
|
|
|
7
8
|
const Support_1 = require("../support/Support");
|
|
8
9
|
const TypeAttributes_1 = require("../attributes/TypeAttributes");
|
|
9
10
|
function canResolve(t) {
|
|
10
|
-
const members = TypeUtils_1.setOperationMembersRecursively(t, undefined)[0];
|
|
11
|
+
const members = (0, TypeUtils_1.setOperationMembersRecursively)(t, undefined)[0];
|
|
11
12
|
if (members.size <= 1)
|
|
12
13
|
return true;
|
|
13
|
-
return collection_utils_1.iterableEvery(members, m => !(m instanceof Type_1.UnionType) || m.isCanonical);
|
|
14
|
+
return (0, collection_utils_1.iterableEvery)(members, m => !(m instanceof Type_1.UnionType) || m.isCanonical);
|
|
14
15
|
}
|
|
15
16
|
function attributesForTypes(types) {
|
|
16
|
-
return collection_utils_1.mapMapEntries(types.entries(), t => [t.kind, t.getAttributes()]);
|
|
17
|
+
return (0, collection_utils_1.mapMapEntries)(types.entries(), t => [t.kind, t.getAttributes()]);
|
|
17
18
|
}
|
|
18
19
|
class IntersectionAccumulator {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
_primitiveTypes;
|
|
21
|
+
_primitiveAttributes = new Map();
|
|
22
|
+
// * undefined: We haven't seen any types yet.
|
|
23
|
+
// * Set: All types we've seen can be arrays.
|
|
24
|
+
// * false: At least one of the types seen can't be an array.
|
|
25
|
+
_arrayItemTypes;
|
|
26
|
+
_arrayAttributes = TypeAttributes_1.emptyTypeAttributes;
|
|
27
|
+
// We start out with all object types allowed, which means
|
|
28
|
+
// _additionalPropertyTypes is empty - no restrictions - and
|
|
29
|
+
// _classProperties is empty - no defined properties so far.
|
|
30
|
+
//
|
|
31
|
+
// If _additionalPropertyTypes is undefined, no additional
|
|
32
|
+
// properties are allowed anymore. If _classProperties is
|
|
33
|
+
// undefined, no object types are allowed, in which case
|
|
34
|
+
// _additionalPropertyTypes must also be undefined;
|
|
35
|
+
_objectProperties = new Map();
|
|
36
|
+
_objectAttributes = TypeAttributes_1.emptyTypeAttributes;
|
|
37
|
+
_additionalPropertyTypes = new Set();
|
|
38
|
+
_lostTypeAttributes = false;
|
|
35
39
|
updatePrimitiveTypes(members) {
|
|
36
|
-
const types = collection_utils_1.setFilter(members, t => Type_1.isPrimitiveTypeKind(t.kind));
|
|
40
|
+
const types = (0, collection_utils_1.setFilter)(members, t => (0, Type_1.isPrimitiveTypeKind)(t.kind));
|
|
37
41
|
const attributes = attributesForTypes(types);
|
|
38
|
-
collection_utils_1.mapMergeWithInto(this._primitiveAttributes, (a, b) => TypeAttributes_1.combineTypeAttributes("intersect", a, b), attributes);
|
|
39
|
-
const kinds = collection_utils_1.setMap(types, t => t.kind);
|
|
42
|
+
(0, collection_utils_1.mapMergeWithInto)(this._primitiveAttributes, (a, b) => (0, TypeAttributes_1.combineTypeAttributes)("intersect", a, b), attributes);
|
|
43
|
+
const kinds = (0, collection_utils_1.setMap)(types, t => t.kind);
|
|
40
44
|
if (this._primitiveTypes === undefined) {
|
|
41
45
|
this._primitiveTypes = new Set(kinds);
|
|
42
46
|
return;
|
|
43
47
|
}
|
|
44
|
-
const haveNumber = collection_utils_1.iterableFind(this._primitiveTypes, Type_1.isNumberTypeKind) !== undefined &&
|
|
45
|
-
collection_utils_1.iterableFind(kinds, Type_1.isNumberTypeKind) !== undefined;
|
|
46
|
-
this._primitiveTypes = collection_utils_1.setIntersect(this._primitiveTypes, kinds);
|
|
47
|
-
if (haveNumber && collection_utils_1.iterableFind(this._primitiveTypes, Type_1.isNumberTypeKind) === undefined) {
|
|
48
|
+
const haveNumber = (0, collection_utils_1.iterableFind)(this._primitiveTypes, Type_1.isNumberTypeKind) !== undefined &&
|
|
49
|
+
(0, collection_utils_1.iterableFind)(kinds, Type_1.isNumberTypeKind) !== undefined;
|
|
50
|
+
this._primitiveTypes = (0, collection_utils_1.setIntersect)(this._primitiveTypes, kinds);
|
|
51
|
+
if (haveNumber && (0, collection_utils_1.iterableFind)(this._primitiveTypes, Type_1.isNumberTypeKind) === undefined) {
|
|
48
52
|
// One set has integer, the other has double. The intersection
|
|
49
53
|
// of that is integer.
|
|
50
54
|
this._primitiveTypes = this._primitiveTypes.add("integer");
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
updateArrayItemTypes(members) {
|
|
54
|
-
const maybeArray = collection_utils_1.iterableFind(members, t => t instanceof Type_1.ArrayType);
|
|
58
|
+
const maybeArray = (0, collection_utils_1.iterableFind)(members, t => t instanceof Type_1.ArrayType);
|
|
55
59
|
if (maybeArray === undefined) {
|
|
56
60
|
this._arrayItemTypes = false;
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
|
-
this._arrayAttributes = TypeAttributes_1.combineTypeAttributes("intersect", this._arrayAttributes, maybeArray.getAttributes());
|
|
63
|
+
this._arrayAttributes = (0, TypeAttributes_1.combineTypeAttributes)("intersect", this._arrayAttributes, maybeArray.getAttributes());
|
|
60
64
|
if (this._arrayItemTypes === undefined) {
|
|
61
65
|
this._arrayItemTypes = new Set();
|
|
62
66
|
}
|
|
@@ -65,43 +69,43 @@ class IntersectionAccumulator {
|
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
updateObjectProperties(members) {
|
|
68
|
-
const maybeObject = collection_utils_1.iterableFind(members, t => t instanceof Type_1.ObjectType);
|
|
72
|
+
const maybeObject = (0, collection_utils_1.iterableFind)(members, t => t instanceof Type_1.ObjectType);
|
|
69
73
|
if (maybeObject === undefined) {
|
|
70
74
|
this._objectProperties = undefined;
|
|
71
75
|
this._additionalPropertyTypes = undefined;
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
|
-
this._objectAttributes = TypeAttributes_1.combineTypeAttributes("intersect", this._objectAttributes, maybeObject.getAttributes());
|
|
78
|
+
this._objectAttributes = (0, TypeAttributes_1.combineTypeAttributes)("intersect", this._objectAttributes, maybeObject.getAttributes());
|
|
75
79
|
const objectAdditionalProperties = maybeObject.getAdditionalProperties();
|
|
76
80
|
if (this._objectProperties === undefined) {
|
|
77
|
-
Support_1.assert(this._additionalPropertyTypes === undefined);
|
|
81
|
+
(0, Support_1.assert)(this._additionalPropertyTypes === undefined);
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
|
-
const allPropertyNames = collection_utils_1.setUnionInto(new Set(this._objectProperties.keys()), maybeObject.getProperties().keys());
|
|
84
|
+
const allPropertyNames = (0, collection_utils_1.setUnionInto)(new Set(this._objectProperties.keys()), maybeObject.getProperties().keys());
|
|
81
85
|
for (const name of allPropertyNames) {
|
|
82
|
-
const existing = Support_1.defined(this._objectProperties).get(name);
|
|
86
|
+
const existing = (0, Support_1.defined)(this._objectProperties).get(name);
|
|
83
87
|
const newProperty = maybeObject.getProperties().get(name);
|
|
84
88
|
if (existing !== undefined && newProperty !== undefined) {
|
|
85
89
|
const cp = new Type_1.GenericClassProperty(existing.typeData.add(newProperty.type), existing.isOptional && newProperty.isOptional);
|
|
86
|
-
Support_1.defined(this._objectProperties).set(name, cp);
|
|
90
|
+
(0, Support_1.defined)(this._objectProperties).set(name, cp);
|
|
87
91
|
}
|
|
88
92
|
else if (existing !== undefined && objectAdditionalProperties !== undefined) {
|
|
89
93
|
const cp = new Type_1.GenericClassProperty(existing.typeData.add(objectAdditionalProperties), existing.isOptional);
|
|
90
|
-
Support_1.defined(this._objectProperties).set(name, cp);
|
|
94
|
+
(0, Support_1.defined)(this._objectProperties).set(name, cp);
|
|
91
95
|
}
|
|
92
96
|
else if (existing !== undefined) {
|
|
93
|
-
Support_1.defined(this._objectProperties).delete(name);
|
|
97
|
+
(0, Support_1.defined)(this._objectProperties).delete(name);
|
|
94
98
|
}
|
|
95
99
|
else if (newProperty !== undefined && this._additionalPropertyTypes !== undefined) {
|
|
96
100
|
// FIXME: This is potentially slow
|
|
97
101
|
const types = new Set(this._additionalPropertyTypes).add(newProperty.type);
|
|
98
|
-
Support_1.defined(this._objectProperties).set(name, new Type_1.GenericClassProperty(types, newProperty.isOptional));
|
|
102
|
+
(0, Support_1.defined)(this._objectProperties).set(name, new Type_1.GenericClassProperty(types, newProperty.isOptional));
|
|
99
103
|
}
|
|
100
104
|
else if (newProperty !== undefined) {
|
|
101
|
-
Support_1.defined(this._objectProperties).delete(name);
|
|
105
|
+
(0, Support_1.defined)(this._objectProperties).delete(name);
|
|
102
106
|
}
|
|
103
107
|
else {
|
|
104
|
-
return Support_1.mustNotHappen();
|
|
108
|
+
return (0, Support_1.mustNotHappen)();
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
if (this._additionalPropertyTypes !== undefined && objectAdditionalProperties !== undefined) {
|
|
@@ -119,40 +123,40 @@ class IntersectionAccumulator {
|
|
|
119
123
|
}
|
|
120
124
|
addType(t) {
|
|
121
125
|
let attributes = t.getAttributes();
|
|
122
|
-
TypeUtils_1.matchTypeExhaustive(t, _noneType => {
|
|
123
|
-
return Support_1.panic("There shouldn't be a none type");
|
|
126
|
+
(0, TypeUtils_1.matchTypeExhaustive)(t, _noneType => {
|
|
127
|
+
return (0, Support_1.panic)("There shouldn't be a none type");
|
|
124
128
|
}, _anyType => {
|
|
125
|
-
return Support_1.panic("The any type should have been filtered out in setOperationMembersRecursively");
|
|
126
|
-
}, nullType => this.addUnionSet([nullType]), boolType => this.addUnionSet([boolType]), integerType => this.addUnionSet([integerType]), doubleType => this.addUnionSet([doubleType]), stringType => this.addUnionSet([stringType]), arrayType => this.addUnionSet([arrayType]), _classType => Support_1.panic("We should never see class types in intersections"), _mapType => Support_1.panic("We should never see map types in intersections"), objectType => this.addUnionSet([objectType]), _enumType => Support_1.panic("We should never see enum types in intersections"), unionType => {
|
|
127
|
-
attributes = TypeAttributes_1.combineTypeAttributes("intersect", [attributes].concat(Array.from(unionType.members).map(m => m.getAttributes())));
|
|
129
|
+
return (0, Support_1.panic)("The any type should have been filtered out in setOperationMembersRecursively");
|
|
130
|
+
}, nullType => this.addUnionSet([nullType]), boolType => this.addUnionSet([boolType]), integerType => this.addUnionSet([integerType]), doubleType => this.addUnionSet([doubleType]), stringType => this.addUnionSet([stringType]), arrayType => this.addUnionSet([arrayType]), _classType => (0, Support_1.panic)("We should never see class types in intersections"), _mapType => (0, Support_1.panic)("We should never see map types in intersections"), objectType => this.addUnionSet([objectType]), _enumType => (0, Support_1.panic)("We should never see enum types in intersections"), unionType => {
|
|
131
|
+
attributes = (0, TypeAttributes_1.combineTypeAttributes)("intersect", [attributes].concat(Array.from(unionType.members).map(m => m.getAttributes())));
|
|
128
132
|
this.addUnionSet(unionType.members);
|
|
129
133
|
}, transformedStringType => this.addUnionSet([transformedStringType]));
|
|
130
|
-
return TypeAttributes_1.makeTypeAttributesInferred(attributes);
|
|
134
|
+
return (0, TypeAttributes_1.makeTypeAttributesInferred)(attributes);
|
|
131
135
|
}
|
|
132
136
|
get arrayData() {
|
|
133
137
|
if (this._arrayItemTypes === undefined || this._arrayItemTypes === false) {
|
|
134
|
-
return Support_1.panic("This should not be called if the type can't be an array");
|
|
138
|
+
return (0, Support_1.panic)("This should not be called if the type can't be an array");
|
|
135
139
|
}
|
|
136
140
|
return this._arrayItemTypes;
|
|
137
141
|
}
|
|
138
142
|
get objectData() {
|
|
139
143
|
if (this._objectProperties === undefined) {
|
|
140
|
-
Support_1.assert(this._additionalPropertyTypes === undefined);
|
|
144
|
+
(0, Support_1.assert)(this._additionalPropertyTypes === undefined);
|
|
141
145
|
return undefined;
|
|
142
146
|
}
|
|
143
147
|
return [this._objectProperties, this._additionalPropertyTypes];
|
|
144
148
|
}
|
|
145
149
|
get enumCases() {
|
|
146
|
-
return Support_1.panic("We don't support enums in intersections");
|
|
150
|
+
return (0, Support_1.panic)("We don't support enums in intersections");
|
|
147
151
|
}
|
|
148
152
|
getMemberKinds() {
|
|
149
|
-
const kinds = collection_utils_1.mapMap(Support_1.defined(this._primitiveTypes).entries(), k => Support_1.defined(this._primitiveAttributes.get(k)));
|
|
153
|
+
const kinds = (0, collection_utils_1.mapMap)((0, Support_1.defined)(this._primitiveTypes).entries(), k => (0, Support_1.defined)(this._primitiveAttributes.get(k)));
|
|
150
154
|
const maybeDoubleAttributes = this._primitiveAttributes.get("double");
|
|
151
155
|
// If double was eliminated, add its attributes to integer
|
|
152
156
|
if (maybeDoubleAttributes !== undefined && !kinds.has("double") && kinds.has("integer")) {
|
|
153
157
|
// FIXME: How can this ever happen??? Where do we "eliminate" double?
|
|
154
|
-
collection_utils_1.mapUpdateInto(kinds, "integer", a => {
|
|
155
|
-
return TypeAttributes_1.combineTypeAttributes("intersect", Support_1.defined(a), maybeDoubleAttributes);
|
|
158
|
+
(0, collection_utils_1.mapUpdateInto)(kinds, "integer", a => {
|
|
159
|
+
return (0, TypeAttributes_1.combineTypeAttributes)("intersect", (0, Support_1.defined)(a), maybeDoubleAttributes);
|
|
156
160
|
});
|
|
157
161
|
}
|
|
158
162
|
if (this._arrayItemTypes !== undefined && this._arrayItemTypes !== false) {
|
|
@@ -174,13 +178,10 @@ class IntersectionAccumulator {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
class IntersectionUnionBuilder extends UnionBuilder_1.UnionBuilder {
|
|
177
|
-
|
|
178
|
-
super(...arguments);
|
|
179
|
-
this._createdNewIntersections = false;
|
|
180
|
-
}
|
|
181
|
+
_createdNewIntersections = false;
|
|
181
182
|
makeIntersection(members, attributes) {
|
|
182
|
-
const reconstitutedMembers = collection_utils_1.setMap(members, t => this.typeBuilder.reconstituteTypeRef(t.typeRef));
|
|
183
|
-
const first = Support_1.defined(collection_utils_1.iterableFirst(reconstitutedMembers));
|
|
183
|
+
const reconstitutedMembers = (0, collection_utils_1.setMap)(members, t => this.typeBuilder.reconstituteTypeRef(t.typeRef));
|
|
184
|
+
const first = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(reconstitutedMembers));
|
|
184
185
|
if (reconstitutedMembers.size === 1) {
|
|
185
186
|
this.typeBuilder.addAttributes(first, attributes);
|
|
186
187
|
return first;
|
|
@@ -193,10 +194,10 @@ class IntersectionUnionBuilder extends UnionBuilder_1.UnionBuilder {
|
|
|
193
194
|
}
|
|
194
195
|
makeObject(maybeData, typeAttributes, forwardingRef) {
|
|
195
196
|
if (maybeData === undefined) {
|
|
196
|
-
return Support_1.panic("Either properties or additional properties must be given to make an object type");
|
|
197
|
+
return (0, Support_1.panic)("Either properties or additional properties must be given to make an object type");
|
|
197
198
|
}
|
|
198
199
|
const [propertyTypes, maybeAdditionalProperties] = maybeData;
|
|
199
|
-
const properties = collection_utils_1.mapMap(propertyTypes, cp => this.typeBuilder.makeClassProperty(this.makeIntersection(cp.typeData, TypeAttributes_1.emptyTypeAttributes), cp.isOptional));
|
|
200
|
+
const properties = (0, collection_utils_1.mapMap)(propertyTypes, cp => this.typeBuilder.makeClassProperty(this.makeIntersection(cp.typeData, TypeAttributes_1.emptyTypeAttributes), cp.isOptional));
|
|
200
201
|
const additionalProperties = maybeAdditionalProperties === undefined
|
|
201
202
|
? undefined
|
|
202
203
|
: this.makeIntersection(maybeAdditionalProperties, TypeAttributes_1.emptyTypeAttributes);
|
|
@@ -212,18 +213,18 @@ class IntersectionUnionBuilder extends UnionBuilder_1.UnionBuilder {
|
|
|
212
213
|
function resolveIntersections(graph, stringTypeMapping, debugPrintReconstitution) {
|
|
213
214
|
let needsRepeat = false;
|
|
214
215
|
function replace(types, builder, forwardingRef) {
|
|
215
|
-
const intersections = collection_utils_1.setFilter(types, t => t instanceof Type_1.IntersectionType);
|
|
216
|
-
const [members, intersectionAttributes] = TypeUtils_1.setOperationMembersRecursively(Array.from(intersections), "intersect");
|
|
216
|
+
const intersections = (0, collection_utils_1.setFilter)(types, t => t instanceof Type_1.IntersectionType);
|
|
217
|
+
const [members, intersectionAttributes] = (0, TypeUtils_1.setOperationMembersRecursively)(Array.from(intersections), "intersect");
|
|
217
218
|
if (members.size === 0) {
|
|
218
219
|
const t = builder.getPrimitiveType("any", intersectionAttributes, forwardingRef);
|
|
219
220
|
return t;
|
|
220
221
|
}
|
|
221
222
|
if (members.size === 1) {
|
|
222
|
-
return builder.reconstituteType(Support_1.defined(collection_utils_1.iterableFirst(members)), intersectionAttributes, forwardingRef);
|
|
223
|
+
return builder.reconstituteType((0, Support_1.defined)((0, collection_utils_1.iterableFirst)(members)), intersectionAttributes, forwardingRef);
|
|
223
224
|
}
|
|
224
225
|
const accumulator = new IntersectionAccumulator();
|
|
225
|
-
const extraAttributes = TypeAttributes_1.makeTypeAttributesInferred(TypeAttributes_1.combineTypeAttributes("intersect", Array.from(members).map(t => accumulator.addType(t))));
|
|
226
|
-
const attributes = TypeAttributes_1.combineTypeAttributes("intersect", intersectionAttributes, extraAttributes);
|
|
226
|
+
const extraAttributes = (0, TypeAttributes_1.makeTypeAttributesInferred)((0, TypeAttributes_1.combineTypeAttributes)("intersect", Array.from(members).map(t => accumulator.addType(t))));
|
|
227
|
+
const attributes = (0, TypeAttributes_1.combineTypeAttributes)("intersect", intersectionAttributes, extraAttributes);
|
|
227
228
|
const unionBuilder = new IntersectionUnionBuilder(builder);
|
|
228
229
|
const tref = unionBuilder.buildUnion(accumulator, true, attributes, forwardingRef);
|
|
229
230
|
if (unionBuilder.createdNewIntersections) {
|
|
@@ -233,9 +234,9 @@ function resolveIntersections(graph, stringTypeMapping, debugPrintReconstitution
|
|
|
233
234
|
}
|
|
234
235
|
// FIXME: We need to handle intersections that resolve to the same set of types.
|
|
235
236
|
// See for example the intersections-nested.schema example.
|
|
236
|
-
const allIntersections = collection_utils_1.setFilter(graph.allTypesUnordered(), t => t instanceof Type_1.IntersectionType);
|
|
237
|
-
const resolvableIntersections = collection_utils_1.setFilter(allIntersections, canResolve);
|
|
238
|
-
const groups = TypeUtils_1.makeGroupsToFlatten(resolvableIntersections, undefined);
|
|
237
|
+
const allIntersections = (0, collection_utils_1.setFilter)(graph.allTypesUnordered(), t => t instanceof Type_1.IntersectionType);
|
|
238
|
+
const resolvableIntersections = (0, collection_utils_1.setFilter)(allIntersections, canResolve);
|
|
239
|
+
const groups = (0, TypeUtils_1.makeGroupsToFlatten)(resolvableIntersections, undefined);
|
|
239
240
|
graph = graph.rewrite("resolve intersections", stringTypeMapping, false, groups, debugPrintReconstitution, replace);
|
|
240
241
|
// console.log(`resolved ${resolvableIntersections.size} of ${intersections.size} intersections`);
|
|
241
242
|
return [graph, !needsRepeat && allIntersections.size === resolvableIntersections.size];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.acronymStyle = exports.acronymOption = exports.AcronymStyleOptions = exports.acronyms = void 0;
|
|
3
4
|
const RendererOptions_1 = require("../RendererOptions");
|
|
4
5
|
const Strings_1 = require("./Strings");
|
|
5
6
|
exports.acronyms = [
|
|
@@ -1106,7 +1107,7 @@ var AcronymStyleOptions;
|
|
|
1106
1107
|
AcronymStyleOptions["Original"] = "original";
|
|
1107
1108
|
AcronymStyleOptions["Lower"] = "lowerCase";
|
|
1108
1109
|
})(AcronymStyleOptions = exports.AcronymStyleOptions || (exports.AcronymStyleOptions = {}));
|
|
1109
|
-
|
|
1110
|
+
const acronymOption = function (defaultOption) {
|
|
1110
1111
|
return new RendererOptions_1.EnumOption("acronym-style", "Acronym naming style", [
|
|
1111
1112
|
[AcronymStyleOptions.Original, AcronymStyleOptions.Original],
|
|
1112
1113
|
[AcronymStyleOptions.Pascal, AcronymStyleOptions.Pascal],
|
|
@@ -1114,6 +1115,7 @@ exports.acronymOption = function (defaultOption) {
|
|
|
1114
1115
|
[AcronymStyleOptions.Lower, AcronymStyleOptions.Lower]
|
|
1115
1116
|
], defaultOption, "secondary");
|
|
1116
1117
|
};
|
|
1118
|
+
exports.acronymOption = acronymOption;
|
|
1117
1119
|
function acronymStyle(style) {
|
|
1118
1120
|
const options = {
|
|
1119
1121
|
[AcronymStyleOptions.Pascal]: Strings_1.allUpperWordStyle,
|
|
@@ -34,7 +34,15 @@ http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
|
|
|
34
34
|
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
|
|
35
35
|
*/
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.Chance = void 0;
|
|
37
38
|
class MersenneTwister {
|
|
39
|
+
N;
|
|
40
|
+
M;
|
|
41
|
+
MATRIX_A;
|
|
42
|
+
UPPER_MASK;
|
|
43
|
+
LOWER_MASK;
|
|
44
|
+
mt;
|
|
45
|
+
mti;
|
|
38
46
|
constructor(seed) {
|
|
39
47
|
if (seed === undefined) {
|
|
40
48
|
// kept random number same size as time used previously to ensure no unexpected results downstream
|
|
@@ -105,6 +113,8 @@ class MersenneTwister {
|
|
|
105
113
|
}
|
|
106
114
|
// https://github.com/chancejs/chancejs
|
|
107
115
|
class Chance {
|
|
116
|
+
seed;
|
|
117
|
+
mt;
|
|
108
118
|
constructor(seed) {
|
|
109
119
|
this.seed = seed;
|
|
110
120
|
// If no generator function was provided, use our MT
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export type NamingStyle = "pascal" | "camel" | "underscore" | "upper-underscore" | "pascal-upper-acronyms" | "camel-upper-acronyms";
|
|
2
|
+
type CodePointPredicate = (codePoint: number) => boolean;
|
|
3
3
|
export declare function utf16ConcatMap(mapper: (utf16Unit: number) => string): (s: string) => string;
|
|
4
4
|
export declare function utf32ConcatMap(mapper: (codePoint: number) => string): (s: string) => string;
|
|
5
5
|
export declare function utf16LegalizeCharacters(isLegal: (utf16Unit: number) => boolean): (s: string) => string;
|
|
@@ -27,13 +27,13 @@ export declare function camelCase(str: string): string;
|
|
|
27
27
|
export declare function snakeCase(str: string): string;
|
|
28
28
|
export declare function startWithLetter(isAllowedStart: (codePoint: number) => boolean, // FIXME: technically, this operates on UTF16 units
|
|
29
29
|
upper: boolean, str: string): string;
|
|
30
|
-
export
|
|
30
|
+
export type WordInName = {
|
|
31
31
|
word: string;
|
|
32
32
|
isAcronym: boolean;
|
|
33
33
|
};
|
|
34
34
|
export declare const fastIsUpperCase: CodePointPredicate;
|
|
35
35
|
export declare function splitIntoWords(s: string): WordInName[];
|
|
36
|
-
export
|
|
36
|
+
export type WordStyle = (word: string) => string;
|
|
37
37
|
export declare function firstUpperWordStyle(s: string): string;
|
|
38
38
|
export declare function allUpperWordStyle(s: string): string;
|
|
39
39
|
export declare function originalWord(s: string): string;
|