quicktype 18.0.6 → 19.0.4
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/README.md +1 -1
- package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
- package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
- package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
- package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
- package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
- package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
- package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
- package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
- package/dist/{cli/index.d.ts → index.d.ts} +1 -1
- package/dist/{cli/index.js → index.js} +4 -5
- package/package.json +61 -77
- package/dist/quicktype-core/Annotation.d.ts +0 -8
- package/dist/quicktype-core/Annotation.js +0 -16
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
- package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
- package/dist/quicktype-core/DateTime.d.ts +0 -10
- package/dist/quicktype-core/DateTime.js +0 -57
- package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
- package/dist/quicktype-core/DeclarationIR.js +0 -167
- package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
- package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
- package/dist/quicktype-core/GatherNames.d.ts +0 -2
- package/dist/quicktype-core/GatherNames.js +0 -333
- package/dist/quicktype-core/Graph.d.ts +0 -12
- package/dist/quicktype-core/Graph.js +0 -220
- package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
- package/dist/quicktype-core/GraphRewriting.js +0 -421
- package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
- package/dist/quicktype-core/MakeTransformations.js +0 -193
- package/dist/quicktype-core/MarkovChain.d.ts +0 -15
- package/dist/quicktype-core/MarkovChain.js +0 -154
- package/dist/quicktype-core/Messages.d.ts +0 -294
- package/dist/quicktype-core/Messages.js +0 -105
- package/dist/quicktype-core/Naming.d.ts +0 -64
- package/dist/quicktype-core/Naming.js +0 -356
- package/dist/quicktype-core/Renderer.d.ts +0 -50
- package/dist/quicktype-core/Renderer.js +0 -274
- package/dist/quicktype-core/RendererOptions.d.ts +0 -71
- package/dist/quicktype-core/RendererOptions.js +0 -141
- package/dist/quicktype-core/Run.d.ts +0 -174
- package/dist/quicktype-core/Run.js +0 -393
- package/dist/quicktype-core/Source.d.ts +0 -65
- package/dist/quicktype-core/Source.js +0 -204
- package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
- package/dist/quicktype-core/TargetLanguage.js +0 -66
- package/dist/quicktype-core/Transformers.d.ts +0 -209
- package/dist/quicktype-core/Transformers.js +0 -836
- package/dist/quicktype-core/Type.d.ts +0 -206
- package/dist/quicktype-core/Type.js +0 -716
- package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
- package/dist/quicktype-core/TypeBuilder.js +0 -324
- package/dist/quicktype-core/TypeGraph.d.ts +0 -75
- package/dist/quicktype-core/TypeGraph.js +0 -420
- package/dist/quicktype-core/TypeUtils.d.ts +0 -33
- package/dist/quicktype-core/TypeUtils.js +0 -230
- package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
- package/dist/quicktype-core/UnifyClasses.js +0 -159
- package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
- package/dist/quicktype-core/UnionBuilder.js +0 -282
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
- package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
- package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
- package/dist/quicktype-core/attributes/Constraints.js +0 -172
- package/dist/quicktype-core/attributes/Description.d.ts +0 -9
- package/dist/quicktype-core/attributes/Description.js +0 -97
- package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
- package/dist/quicktype-core/attributes/EnumValues.js +0 -31
- package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
- package/dist/quicktype-core/attributes/StringTypes.js +0 -189
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
- package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
- package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
- package/dist/quicktype-core/attributes/TypeNames.js +0 -274
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
- package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
- package/dist/quicktype-core/index.d.ts +0 -48
- package/dist/quicktype-core/index.js +0 -180
- package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
- package/dist/quicktype-core/input/CompressedJSON.js +0 -276
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
- package/dist/quicktype-core/input/Inference.d.ts +0 -22
- package/dist/quicktype-core/input/Inference.js +0 -240
- package/dist/quicktype-core/input/Inputs.d.ts +0 -48
- package/dist/quicktype-core/input/Inputs.js +0 -145
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
- package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
- package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
- package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
- package/dist/quicktype-core/input/PostmanCollection.js +0 -60
- package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
- package/dist/quicktype-core/input/io/NodeIO.js +0 -87
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
- package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
- package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
- package/dist/quicktype-core/language/All.d.ts +0 -3
- package/dist/quicktype-core/language/All.js +0 -57
- package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
- package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
- package/dist/quicktype-core/language/CSharp.d.ts +0 -201
- package/dist/quicktype-core/language/CSharp.js +0 -1850
- package/dist/quicktype-core/language/Crystal.d.ts +0 -37
- package/dist/quicktype-core/language/Crystal.js +0 -337
- package/dist/quicktype-core/language/Dart.d.ts +0 -66
- package/dist/quicktype-core/language/Dart.js +0 -576
- package/dist/quicktype-core/language/Elm.d.ts +0 -58
- package/dist/quicktype-core/language/Elm.js +0 -522
- package/dist/quicktype-core/language/Golang.d.ts +0 -51
- package/dist/quicktype-core/language/Golang.js +0 -460
- package/dist/quicktype-core/language/Haskell.d.ts +0 -56
- package/dist/quicktype-core/language/Haskell.js +0 -411
- package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
- package/dist/quicktype-core/language/JSONSchema.js +0 -169
- package/dist/quicktype-core/language/Java.d.ts +0 -125
- package/dist/quicktype-core/language/Java.js +0 -1081
- package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
- package/dist/quicktype-core/language/JavaScript.js +0 -435
- package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
- package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
- package/dist/quicktype-core/language/Kotlin.js +0 -832
- package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
- package/dist/quicktype-core/language/Objective-C.js +0 -777
- package/dist/quicktype-core/language/Php.d.ts +0 -80
- package/dist/quicktype-core/language/Php.js +0 -702
- package/dist/quicktype-core/language/Pike.d.ts +0 -37
- package/dist/quicktype-core/language/Pike.js +0 -276
- package/dist/quicktype-core/language/Python.d.ts +0 -107
- package/dist/quicktype-core/language/Python.js +0 -969
- package/dist/quicktype-core/language/Rust.d.ts +0 -56
- package/dist/quicktype-core/language/Rust.js +0 -309
- package/dist/quicktype-core/language/Swift.d.ts +0 -96
- package/dist/quicktype-core/language/Swift.js +0 -1211
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
- package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
- package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
- package/dist/quicktype-core/language/ruby/index.js +0 -557
- package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
- package/dist/quicktype-core/language/ruby/keywords.js +0 -358
- package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
- package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
- package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
- package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
- package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
- package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
- package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
- package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
- package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
- package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
- package/dist/quicktype-core/support/Acronyms.js +0 -1128
- package/dist/quicktype-core/support/Chance.d.ts +0 -38
- package/dist/quicktype-core/support/Chance.js +0 -2146
- package/dist/quicktype-core/support/Converters.d.ts +0 -6
- package/dist/quicktype-core/support/Converters.js +0 -16
- package/dist/quicktype-core/support/Strings.d.ts +0 -44
- package/dist/quicktype-core/support/Strings.js +0 -525
- package/dist/quicktype-core/support/Support.d.ts +0 -29
- package/dist/quicktype-core/support/Support.js +0 -162
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
- package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
- package/dist/quicktype-graphql-input/index.d.ts +0 -17
- package/dist/quicktype-graphql-input/index.js +0 -407
- package/dist/quicktype-typescript-input/index.d.ts +0 -2
- package/dist/quicktype-typescript-input/index.js +0 -98
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Type } from "./Type";
|
|
2
|
-
import { TypeBuilder } from "./TypeBuilder";
|
|
3
|
-
import { TypeLookerUp, GraphRewriteBuilder, BaseGraphRewriteBuilder } from "./GraphRewriting";
|
|
4
|
-
import { UnionBuilder } from "./UnionBuilder";
|
|
5
|
-
import { TypeAttributes } from "./attributes/TypeAttributes";
|
|
6
|
-
import { TypeRef } from "./TypeGraph";
|
|
7
|
-
export declare class UnifyUnionBuilder extends UnionBuilder<BaseGraphRewriteBuilder, TypeRef[], TypeRef[]> {
|
|
8
|
-
private readonly _makeObjectTypes;
|
|
9
|
-
private readonly _makeClassesFixed;
|
|
10
|
-
private readonly _unifyTypes;
|
|
11
|
-
constructor(typeBuilder: BaseGraphRewriteBuilder, _makeObjectTypes: boolean, _makeClassesFixed: boolean, _unifyTypes: (typesToUnify: TypeRef[]) => TypeRef);
|
|
12
|
-
protected makeObject(objectRefs: TypeRef[], typeAttributes: TypeAttributes, forwardingRef: TypeRef | undefined): TypeRef;
|
|
13
|
-
protected makeArray(arrays: TypeRef[], typeAttributes: TypeAttributes, forwardingRef: TypeRef | undefined): TypeRef;
|
|
14
|
-
}
|
|
15
|
-
export declare function unionBuilderForUnification<T extends Type>(typeBuilder: GraphRewriteBuilder<T>, makeObjectTypes: boolean, makeClassesFixed: boolean, conflateNumbers: boolean): UnionBuilder<TypeBuilder & TypeLookerUp, TypeRef[], TypeRef[]>;
|
|
16
|
-
export declare function unifyTypes<T extends Type>(types: ReadonlySet<Type>, typeAttributes: TypeAttributes, typeBuilder: GraphRewriteBuilder<T>, unionBuilder: UnionBuilder<TypeBuilder & TypeLookerUp, TypeRef[], TypeRef[]>, conflateNumbers: boolean, maybeForwardingRef?: TypeRef): TypeRef;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unifyTypes = exports.unionBuilderForUnification = exports.UnifyUnionBuilder = void 0;
|
|
4
|
-
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const Type_1 = require("./Type");
|
|
6
|
-
const TypeUtils_1 = require("./TypeUtils");
|
|
7
|
-
const UnionBuilder_1 = require("./UnionBuilder");
|
|
8
|
-
const Support_1 = require("./support/Support");
|
|
9
|
-
const TypeAttributes_1 = require("./attributes/TypeAttributes");
|
|
10
|
-
const TypeGraph_1 = require("./TypeGraph");
|
|
11
|
-
function getCliqueProperties(clique, builder, makePropertyType) {
|
|
12
|
-
let lostTypeAttributes = false;
|
|
13
|
-
let propertyNames = new Set();
|
|
14
|
-
for (const o of clique) {
|
|
15
|
-
(0, collection_utils_1.setUnionInto)(propertyNames, o.getProperties().keys());
|
|
16
|
-
}
|
|
17
|
-
let properties = Array.from(propertyNames).map(name => [name, new Set(), false]);
|
|
18
|
-
let additionalProperties = undefined;
|
|
19
|
-
for (const o of clique) {
|
|
20
|
-
let additional = o.getAdditionalProperties();
|
|
21
|
-
if (additional !== undefined) {
|
|
22
|
-
if (additionalProperties === undefined) {
|
|
23
|
-
additionalProperties = new Set();
|
|
24
|
-
}
|
|
25
|
-
if (additional !== undefined) {
|
|
26
|
-
additionalProperties.add(additional);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (let i = 0; i < properties.length; i++) {
|
|
30
|
-
let [name, types, isOptional] = properties[i];
|
|
31
|
-
const maybeProperty = o.getProperties().get(name);
|
|
32
|
-
if (maybeProperty === undefined) {
|
|
33
|
-
isOptional = true;
|
|
34
|
-
if (additional !== undefined && additional.kind !== "any") {
|
|
35
|
-
types.add(additional);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (maybeProperty.isOptional) {
|
|
40
|
-
isOptional = true;
|
|
41
|
-
}
|
|
42
|
-
types.add(maybeProperty.type);
|
|
43
|
-
}
|
|
44
|
-
properties[i][2] = isOptional;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const unifiedAdditionalProperties = additionalProperties === undefined ? undefined : makePropertyType(additionalProperties);
|
|
48
|
-
const unifiedPropertiesArray = properties.map(([name, types, isOptional]) => {
|
|
49
|
-
return [name, builder.makeClassProperty(makePropertyType(types), isOptional)];
|
|
50
|
-
});
|
|
51
|
-
const unifiedProperties = new Map(unifiedPropertiesArray);
|
|
52
|
-
return [unifiedProperties, unifiedAdditionalProperties, lostTypeAttributes];
|
|
53
|
-
}
|
|
54
|
-
function countProperties(clique) {
|
|
55
|
-
let hasProperties = false;
|
|
56
|
-
let hasAdditionalProperties = false;
|
|
57
|
-
let hasNonAnyAdditionalProperties = false;
|
|
58
|
-
for (const o of clique) {
|
|
59
|
-
if (o.getProperties().size > 0) {
|
|
60
|
-
hasProperties = true;
|
|
61
|
-
}
|
|
62
|
-
const additional = o.getAdditionalProperties();
|
|
63
|
-
if (additional !== undefined) {
|
|
64
|
-
hasAdditionalProperties = true;
|
|
65
|
-
if (additional.kind !== "any") {
|
|
66
|
-
hasNonAnyAdditionalProperties = true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return { hasProperties, hasAdditionalProperties, hasNonAnyAdditionalProperties };
|
|
71
|
-
}
|
|
72
|
-
class UnifyUnionBuilder extends UnionBuilder_1.UnionBuilder {
|
|
73
|
-
_makeObjectTypes;
|
|
74
|
-
_makeClassesFixed;
|
|
75
|
-
_unifyTypes;
|
|
76
|
-
constructor(typeBuilder, _makeObjectTypes, _makeClassesFixed, _unifyTypes) {
|
|
77
|
-
super(typeBuilder);
|
|
78
|
-
this._makeObjectTypes = _makeObjectTypes;
|
|
79
|
-
this._makeClassesFixed = _makeClassesFixed;
|
|
80
|
-
this._unifyTypes = _unifyTypes;
|
|
81
|
-
}
|
|
82
|
-
makeObject(objectRefs, typeAttributes, forwardingRef) {
|
|
83
|
-
const maybeTypeRef = this.typeBuilder.lookupTypeRefs(objectRefs, forwardingRef);
|
|
84
|
-
if (maybeTypeRef !== undefined) {
|
|
85
|
-
(0, Support_1.assert)(forwardingRef === undefined || maybeTypeRef === forwardingRef, "The forwarding ref must be consumed");
|
|
86
|
-
this.typeBuilder.addAttributes(maybeTypeRef, typeAttributes);
|
|
87
|
-
return maybeTypeRef;
|
|
88
|
-
}
|
|
89
|
-
if (objectRefs.length === 1) {
|
|
90
|
-
return this.typeBuilder.reconstituteTypeRef(objectRefs[0], typeAttributes, forwardingRef);
|
|
91
|
-
}
|
|
92
|
-
const objectTypes = objectRefs.map(r => (0, TypeUtils_1.assertIsObject)((0, TypeGraph_1.derefTypeRef)(r, this.typeBuilder)));
|
|
93
|
-
const { hasProperties, hasAdditionalProperties, hasNonAnyAdditionalProperties } = countProperties(objectTypes);
|
|
94
|
-
if (!this._makeObjectTypes && (hasNonAnyAdditionalProperties || (!hasProperties && hasAdditionalProperties))) {
|
|
95
|
-
const propertyTypes = new Set();
|
|
96
|
-
for (const o of objectTypes) {
|
|
97
|
-
(0, collection_utils_1.setUnionInto)(propertyTypes, Array.from(o.getProperties().values()).map(cp => cp.typeRef));
|
|
98
|
-
}
|
|
99
|
-
const additionalPropertyTypes = new Set(objectTypes
|
|
100
|
-
.filter(o => o.getAdditionalProperties() !== undefined)
|
|
101
|
-
.map(o => (0, Support_1.defined)(o.getAdditionalProperties()).typeRef));
|
|
102
|
-
(0, collection_utils_1.setUnionInto)(propertyTypes, additionalPropertyTypes);
|
|
103
|
-
return this.typeBuilder.getMapType(typeAttributes, this._unifyTypes(Array.from(propertyTypes)));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
const [properties, additionalProperties, lostTypeAttributes] = getCliqueProperties(objectTypes, this.typeBuilder, types => {
|
|
107
|
-
(0, Support_1.assert)(types.size > 0, "Property has no type");
|
|
108
|
-
return this._unifyTypes(Array.from(types).map(t => t.typeRef));
|
|
109
|
-
});
|
|
110
|
-
if (lostTypeAttributes) {
|
|
111
|
-
this.typeBuilder.setLostTypeAttributes();
|
|
112
|
-
}
|
|
113
|
-
if (this._makeObjectTypes) {
|
|
114
|
-
return this.typeBuilder.getUniqueObjectType(typeAttributes, properties, additionalProperties, forwardingRef);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
(0, Support_1.assert)(additionalProperties === undefined, "We have additional properties but want to make a class");
|
|
118
|
-
return this.typeBuilder.getUniqueClassType(typeAttributes, this._makeClassesFixed, properties, forwardingRef);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
makeArray(arrays, typeAttributes, forwardingRef) {
|
|
123
|
-
const ref = this.typeBuilder.getArrayType(typeAttributes, this._unifyTypes(arrays), forwardingRef);
|
|
124
|
-
return ref;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.UnifyUnionBuilder = UnifyUnionBuilder;
|
|
128
|
-
function unionBuilderForUnification(typeBuilder, makeObjectTypes, makeClassesFixed, conflateNumbers) {
|
|
129
|
-
return new UnifyUnionBuilder(typeBuilder, makeObjectTypes, makeClassesFixed, trefs => unifyTypes(new Set(trefs.map(tref => (0, TypeGraph_1.derefTypeRef)(tref, typeBuilder))), TypeAttributes_1.emptyTypeAttributes, typeBuilder, unionBuilderForUnification(typeBuilder, makeObjectTypes, makeClassesFixed, conflateNumbers), conflateNumbers));
|
|
130
|
-
}
|
|
131
|
-
exports.unionBuilderForUnification = unionBuilderForUnification;
|
|
132
|
-
// typeAttributes must not be reconstituted yet.
|
|
133
|
-
// FIXME: The UnionBuilder might end up not being used.
|
|
134
|
-
function unifyTypes(types, typeAttributes, typeBuilder, unionBuilder, conflateNumbers, maybeForwardingRef) {
|
|
135
|
-
typeAttributes = typeBuilder.reconstituteTypeAttributes(typeAttributes);
|
|
136
|
-
if (types.size === 0) {
|
|
137
|
-
return (0, Support_1.panic)("Cannot unify empty set of types");
|
|
138
|
-
}
|
|
139
|
-
else if (types.size === 1) {
|
|
140
|
-
const first = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(types));
|
|
141
|
-
if (!(first instanceof Type_1.UnionType)) {
|
|
142
|
-
return typeBuilder.reconstituteTypeRef(first.typeRef, typeAttributes, maybeForwardingRef);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const typeRefs = Array.from(types).map(t => t.typeRef);
|
|
146
|
-
const maybeTypeRef = typeBuilder.lookupTypeRefs(typeRefs, maybeForwardingRef);
|
|
147
|
-
if (maybeTypeRef !== undefined) {
|
|
148
|
-
typeBuilder.addAttributes(maybeTypeRef, typeAttributes);
|
|
149
|
-
return maybeTypeRef;
|
|
150
|
-
}
|
|
151
|
-
const accumulator = new UnionBuilder_1.TypeRefUnionAccumulator(conflateNumbers);
|
|
152
|
-
const nestedAttributes = typeBuilder.reconstituteTypeAttributes(accumulator.addTypes(types));
|
|
153
|
-
typeAttributes = (0, TypeAttributes_1.combineTypeAttributes)("union", typeAttributes, nestedAttributes);
|
|
154
|
-
return typeBuilder.withForwardingRef(maybeForwardingRef, forwardingRef => {
|
|
155
|
-
typeBuilder.registerUnion(typeRefs, forwardingRef);
|
|
156
|
-
return unionBuilder.buildUnion(accumulator, false, typeAttributes, forwardingRef);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
exports.unifyTypes = unifyTypes;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { TypeKind, PrimitiveStringTypeKind, Type, PrimitiveTypeKind } from "./Type";
|
|
2
|
-
import { TypeAttributes } from "./attributes/TypeAttributes";
|
|
3
|
-
import { TypeBuilder } from "./TypeBuilder";
|
|
4
|
-
import { StringTypes } from "./attributes/StringTypes";
|
|
5
|
-
import { TypeRef } from "./TypeGraph";
|
|
6
|
-
export interface UnionTypeProvider<TArrayData, TObjectData> {
|
|
7
|
-
readonly arrayData: TArrayData;
|
|
8
|
-
readonly objectData: TObjectData;
|
|
9
|
-
readonly enumCases: ReadonlySet<string>;
|
|
10
|
-
getMemberKinds(): TypeAttributeMap<TypeKind>;
|
|
11
|
-
readonly lostTypeAttributes: boolean;
|
|
12
|
-
}
|
|
13
|
-
export type TypeAttributeMap<T extends TypeKind> = Map<T, TypeAttributes>;
|
|
14
|
-
export declare class UnionAccumulator<TArray, TObject> implements UnionTypeProvider<TArray[], TObject[]> {
|
|
15
|
-
private readonly _conflateNumbers;
|
|
16
|
-
private readonly _nonStringTypeAttributes;
|
|
17
|
-
private readonly _stringTypeAttributes;
|
|
18
|
-
readonly arrayData: TArray[];
|
|
19
|
-
readonly objectData: TObject[];
|
|
20
|
-
private readonly _enumCases;
|
|
21
|
-
private _lostTypeAttributes;
|
|
22
|
-
constructor(_conflateNumbers: boolean);
|
|
23
|
-
private have;
|
|
24
|
-
addNone(_attributes: TypeAttributes): void;
|
|
25
|
-
addAny(attributes: TypeAttributes): void;
|
|
26
|
-
addPrimitive(kind: PrimitiveTypeKind, attributes: TypeAttributes): void;
|
|
27
|
-
protected addFullStringType(attributes: TypeAttributes, stringTypes: StringTypes | undefined): void;
|
|
28
|
-
addStringType(kind: PrimitiveStringTypeKind, attributes: TypeAttributes, stringTypes?: StringTypes): void;
|
|
29
|
-
addArray(t: TArray, attributes: TypeAttributes): void;
|
|
30
|
-
addObject(t: TObject, attributes: TypeAttributes): void;
|
|
31
|
-
addEnum(cases: ReadonlySet<string>, attributes: TypeAttributes): void;
|
|
32
|
-
addStringCases(cases: string[], attributes: TypeAttributes): void;
|
|
33
|
-
addStringCase(s: string, count: number, attributes: TypeAttributes): void;
|
|
34
|
-
get enumCases(): ReadonlySet<string>;
|
|
35
|
-
getMemberKinds(): TypeAttributeMap<TypeKind>;
|
|
36
|
-
get lostTypeAttributes(): boolean;
|
|
37
|
-
}
|
|
38
|
-
export declare class TypeRefUnionAccumulator extends UnionAccumulator<TypeRef, TypeRef> {
|
|
39
|
-
private addType;
|
|
40
|
-
addTypes(types: Iterable<Type>): TypeAttributes;
|
|
41
|
-
}
|
|
42
|
-
export declare abstract class UnionBuilder<TBuilder extends TypeBuilder, TArrayData, TObjectData> {
|
|
43
|
-
protected readonly typeBuilder: TBuilder;
|
|
44
|
-
constructor(typeBuilder: TBuilder);
|
|
45
|
-
protected abstract makeObject(objects: TObjectData, typeAttributes: TypeAttributes, forwardingRef: TypeRef | undefined): TypeRef;
|
|
46
|
-
protected abstract makeArray(arrays: TArrayData, typeAttributes: TypeAttributes, forwardingRef: TypeRef | undefined): TypeRef;
|
|
47
|
-
private makeTypeOfKind;
|
|
48
|
-
buildUnion(typeProvider: UnionTypeProvider<TArrayData, TObjectData>, unique: boolean, typeAttributes: TypeAttributes, forwardingRef?: TypeRef): TypeRef;
|
|
49
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnionBuilder = exports.TypeRefUnionAccumulator = exports.UnionAccumulator = void 0;
|
|
4
|
-
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const Type_1 = require("./Type");
|
|
6
|
-
const TypeUtils_1 = require("./TypeUtils");
|
|
7
|
-
const TypeAttributes_1 = require("./attributes/TypeAttributes");
|
|
8
|
-
const Support_1 = require("./support/Support");
|
|
9
|
-
const StringTypes_1 = require("./attributes/StringTypes");
|
|
10
|
-
function addAttributes(accumulatorAttributes, newAttributes) {
|
|
11
|
-
if (accumulatorAttributes === undefined)
|
|
12
|
-
return newAttributes;
|
|
13
|
-
return (0, TypeAttributes_1.combineTypeAttributes)("union", accumulatorAttributes, newAttributes);
|
|
14
|
-
}
|
|
15
|
-
function setAttributes(attributeMap, kind, newAttributes) {
|
|
16
|
-
attributeMap.set(kind, addAttributes(attributeMap.get(kind), newAttributes));
|
|
17
|
-
}
|
|
18
|
-
function addAttributesToBuilder(builder, kind, newAttributes) {
|
|
19
|
-
let arr = builder.get(kind);
|
|
20
|
-
if (arr === undefined) {
|
|
21
|
-
arr = [];
|
|
22
|
-
builder.set(kind, arr);
|
|
23
|
-
}
|
|
24
|
-
arr.push(newAttributes);
|
|
25
|
-
}
|
|
26
|
-
function buildTypeAttributeMap(builder) {
|
|
27
|
-
return (0, collection_utils_1.mapMap)(builder, arr => (0, TypeAttributes_1.combineTypeAttributes)("union", arr));
|
|
28
|
-
}
|
|
29
|
-
function moveAttributes(map, fromKind, toKind) {
|
|
30
|
-
const fromAttributes = (0, Support_1.defined)(map.get(fromKind));
|
|
31
|
-
map.delete(fromKind);
|
|
32
|
-
setAttributes(map, toKind, fromAttributes);
|
|
33
|
-
}
|
|
34
|
-
class UnionAccumulator {
|
|
35
|
-
_conflateNumbers;
|
|
36
|
-
_nonStringTypeAttributes = new Map();
|
|
37
|
-
_stringTypeAttributes = new Map();
|
|
38
|
-
arrayData = [];
|
|
39
|
-
objectData = [];
|
|
40
|
-
_enumCases = new Set();
|
|
41
|
-
_lostTypeAttributes = false;
|
|
42
|
-
constructor(_conflateNumbers) {
|
|
43
|
-
this._conflateNumbers = _conflateNumbers;
|
|
44
|
-
}
|
|
45
|
-
have(kind) {
|
|
46
|
-
return (this._nonStringTypeAttributes.has(kind) || this._stringTypeAttributes.has(kind));
|
|
47
|
-
}
|
|
48
|
-
addNone(_attributes) {
|
|
49
|
-
// FIXME: Add them to all members? Or add them to the union, which means we'd have
|
|
50
|
-
// to change getMemberKinds() to also return the attributes for the union itself,
|
|
51
|
-
// or add a new method that does that.
|
|
52
|
-
this._lostTypeAttributes = true;
|
|
53
|
-
}
|
|
54
|
-
addAny(attributes) {
|
|
55
|
-
addAttributesToBuilder(this._nonStringTypeAttributes, "any", attributes);
|
|
56
|
-
this._lostTypeAttributes = true;
|
|
57
|
-
}
|
|
58
|
-
addPrimitive(kind, attributes) {
|
|
59
|
-
(0, Support_1.assert)(kind !== "any", "any must be added with addAny");
|
|
60
|
-
addAttributesToBuilder(this._nonStringTypeAttributes, kind, attributes);
|
|
61
|
-
}
|
|
62
|
-
addFullStringType(attributes, stringTypes) {
|
|
63
|
-
let stringTypesAttributes = undefined;
|
|
64
|
-
if (stringTypes === undefined) {
|
|
65
|
-
stringTypes = StringTypes_1.stringTypesTypeAttributeKind.tryGetInAttributes(attributes);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
stringTypesAttributes = StringTypes_1.stringTypesTypeAttributeKind.makeAttributes(stringTypes);
|
|
69
|
-
}
|
|
70
|
-
if (stringTypes === undefined) {
|
|
71
|
-
stringTypes = StringTypes_1.StringTypes.unrestricted;
|
|
72
|
-
stringTypesAttributes = StringTypes_1.stringTypesTypeAttributeKind.makeAttributes(stringTypes);
|
|
73
|
-
}
|
|
74
|
-
const maybeEnumAttributes = this._nonStringTypeAttributes.get("enum");
|
|
75
|
-
if (stringTypes.isRestricted) {
|
|
76
|
-
(0, Support_1.assert)(maybeEnumAttributes === undefined, "We can't add both an enum as well as a restricted string type to a union builder");
|
|
77
|
-
}
|
|
78
|
-
addAttributesToBuilder(this._stringTypeAttributes, "string", attributes);
|
|
79
|
-
if (stringTypesAttributes !== undefined) {
|
|
80
|
-
addAttributesToBuilder(this._stringTypeAttributes, "string", stringTypesAttributes);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
addStringType(kind, attributes, stringTypes) {
|
|
84
|
-
if (kind === "string") {
|
|
85
|
-
this.addFullStringType(attributes, stringTypes);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
addAttributesToBuilder(this._stringTypeAttributes, kind, attributes);
|
|
89
|
-
if (stringTypes !== undefined) {
|
|
90
|
-
addAttributesToBuilder(this._stringTypeAttributes, kind, StringTypes_1.stringTypesTypeAttributeKind.makeAttributes(stringTypes));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
addArray(t, attributes) {
|
|
94
|
-
this.arrayData.push(t);
|
|
95
|
-
addAttributesToBuilder(this._nonStringTypeAttributes, "array", attributes);
|
|
96
|
-
}
|
|
97
|
-
addObject(t, attributes) {
|
|
98
|
-
this.objectData.push(t);
|
|
99
|
-
addAttributesToBuilder(this._nonStringTypeAttributes, "object", attributes);
|
|
100
|
-
}
|
|
101
|
-
addEnum(cases, attributes) {
|
|
102
|
-
const maybeStringAttributes = this._stringTypeAttributes.get("string");
|
|
103
|
-
if (maybeStringAttributes !== undefined) {
|
|
104
|
-
addAttributesToBuilder(this._stringTypeAttributes, "string", attributes);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
addAttributesToBuilder(this._nonStringTypeAttributes, "enum", attributes);
|
|
108
|
-
(0, collection_utils_1.setUnionInto)(this._enumCases, cases);
|
|
109
|
-
}
|
|
110
|
-
addStringCases(cases, attributes) {
|
|
111
|
-
this.addFullStringType(attributes, StringTypes_1.StringTypes.fromCases(cases));
|
|
112
|
-
}
|
|
113
|
-
addStringCase(s, count, attributes) {
|
|
114
|
-
this.addFullStringType(attributes, StringTypes_1.StringTypes.fromCase(s, count));
|
|
115
|
-
}
|
|
116
|
-
get enumCases() {
|
|
117
|
-
return this._enumCases;
|
|
118
|
-
}
|
|
119
|
-
getMemberKinds() {
|
|
120
|
-
(0, Support_1.assert)(!(this.have("enum") && this.have("string")), "We can't have both strings and enums in the same union");
|
|
121
|
-
let merged = (0, collection_utils_1.mapMerge)(buildTypeAttributeMap(this._nonStringTypeAttributes), buildTypeAttributeMap(this._stringTypeAttributes));
|
|
122
|
-
if (merged.size === 0) {
|
|
123
|
-
return new Map([["none", TypeAttributes_1.emptyTypeAttributes]]);
|
|
124
|
-
}
|
|
125
|
-
if (this._nonStringTypeAttributes.has("any")) {
|
|
126
|
-
(0, Support_1.assert)(this._lostTypeAttributes, "This had to be set when we added 'any'");
|
|
127
|
-
const allAttributes = (0, TypeAttributes_1.combineTypeAttributes)("union", Array.from(merged.values()));
|
|
128
|
-
return new Map([["any", allAttributes]]);
|
|
129
|
-
}
|
|
130
|
-
if (this._conflateNumbers && this.have("integer") && this.have("double")) {
|
|
131
|
-
moveAttributes(merged, "integer", "double");
|
|
132
|
-
}
|
|
133
|
-
if (this.have("map")) {
|
|
134
|
-
moveAttributes(merged, "map", "class");
|
|
135
|
-
}
|
|
136
|
-
return merged;
|
|
137
|
-
}
|
|
138
|
-
get lostTypeAttributes() {
|
|
139
|
-
return this._lostTypeAttributes;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.UnionAccumulator = UnionAccumulator;
|
|
143
|
-
class FauxUnion {
|
|
144
|
-
getAttributes() {
|
|
145
|
-
return TypeAttributes_1.emptyTypeAttributes;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function attributesForTypes(types) {
|
|
149
|
-
// These two maps are the reverse of each other. unionsForType is all the unions
|
|
150
|
-
// that are ancestors of that type, when going from one of the given types, only
|
|
151
|
-
// following unions.
|
|
152
|
-
const unionsForType = new Map();
|
|
153
|
-
const typesForUnion = new Map();
|
|
154
|
-
// All the unions we've seen, starting from types, stopping when we hit non-unions.
|
|
155
|
-
const unions = new Set();
|
|
156
|
-
// All the unions that are equivalent to the single root type. If more than one type
|
|
157
|
-
// is given, this will be empty.
|
|
158
|
-
let unionsEquivalentToRoot = new Set();
|
|
159
|
-
function traverse(t, path, isEquivalentToRoot) {
|
|
160
|
-
if (t instanceof Type_1.UnionType) {
|
|
161
|
-
unions.add(t);
|
|
162
|
-
if (isEquivalentToRoot) {
|
|
163
|
-
unionsEquivalentToRoot = unionsEquivalentToRoot.add(t);
|
|
164
|
-
}
|
|
165
|
-
isEquivalentToRoot = isEquivalentToRoot && t.members.size === 1;
|
|
166
|
-
path.push(t);
|
|
167
|
-
for (const m of t.members) {
|
|
168
|
-
traverse(m, path, isEquivalentToRoot);
|
|
169
|
-
}
|
|
170
|
-
path.pop();
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
(0, collection_utils_1.mapUpdateInto)(unionsForType, t, s => (s === undefined ? new Set(path) : (0, collection_utils_1.setUnionInto)(s, path)));
|
|
174
|
-
for (const u of path) {
|
|
175
|
-
(0, collection_utils_1.mapUpdateInto)(typesForUnion, u, s => (s === undefined ? new Set([t]) : s.add(t)));
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const rootPath = [new FauxUnion()];
|
|
180
|
-
const typesArray = Array.from(types);
|
|
181
|
-
for (const t of typesArray) {
|
|
182
|
-
traverse(t, rootPath, typesArray.length === 1);
|
|
183
|
-
}
|
|
184
|
-
const resultAttributes = (0, collection_utils_1.mapMap)(unionsForType, (unionForType, t) => {
|
|
185
|
-
const singleAncestors = Array.from(unionForType).filter(u => (0, Support_1.defined)(typesForUnion.get(u)).size === 1);
|
|
186
|
-
(0, Support_1.assert)(singleAncestors.every(u => (0, Support_1.defined)(typesForUnion.get(u)).has(t)), "We messed up bookkeeping");
|
|
187
|
-
const inheritedAttributes = singleAncestors.map(u => u.getAttributes());
|
|
188
|
-
return (0, TypeAttributes_1.combineTypeAttributes)("union", [t.getAttributes()].concat(inheritedAttributes));
|
|
189
|
-
});
|
|
190
|
-
const unionAttributes = Array.from(unions).map(u => {
|
|
191
|
-
const t = typesForUnion.get(u);
|
|
192
|
-
if (t !== undefined && t.size === 1) {
|
|
193
|
-
return TypeAttributes_1.emptyTypeAttributes;
|
|
194
|
-
}
|
|
195
|
-
const attributes = u.getAttributes();
|
|
196
|
-
if (unionsEquivalentToRoot.has(u)) {
|
|
197
|
-
return attributes;
|
|
198
|
-
}
|
|
199
|
-
return (0, TypeAttributes_1.makeTypeAttributesInferred)(attributes);
|
|
200
|
-
});
|
|
201
|
-
return [resultAttributes, (0, TypeAttributes_1.combineTypeAttributes)("union", unionAttributes)];
|
|
202
|
-
}
|
|
203
|
-
// FIXME: Move this to UnifyClasses.ts?
|
|
204
|
-
class TypeRefUnionAccumulator extends UnionAccumulator {
|
|
205
|
-
// There is a method analogous to this in the IntersectionAccumulator. It might
|
|
206
|
-
// make sense to find a common interface.
|
|
207
|
-
addType(t, attributes) {
|
|
208
|
-
(0, TypeUtils_1.matchTypeExhaustive)(t, _noneType => this.addNone(attributes), _anyType => this.addAny(attributes), _nullType => this.addPrimitive("null", attributes), _boolType => this.addPrimitive("bool", attributes), _integerType => this.addPrimitive("integer", attributes), _doubleType => this.addPrimitive("double", attributes), _stringType => this.addStringType("string", attributes), arrayType => this.addArray(arrayType.items.typeRef, attributes), classType => this.addObject(classType.typeRef, attributes), mapType => this.addObject(mapType.typeRef, attributes), objectType => this.addObject(objectType.typeRef, attributes),
|
|
209
|
-
// FIXME: We're not carrying counts, so this is not correct if we do enum
|
|
210
|
-
// inference. JSON Schema input uses this case, however, without enum
|
|
211
|
-
// inference, which is fine, but still a bit ugly.
|
|
212
|
-
enumType => this.addEnum(enumType.cases, attributes), _unionType => {
|
|
213
|
-
return (0, Support_1.panic)("The unions should have been eliminated in attributesForTypesInUnion");
|
|
214
|
-
}, transformedStringType => this.addStringType(transformedStringType.kind, attributes));
|
|
215
|
-
}
|
|
216
|
-
addTypes(types) {
|
|
217
|
-
const [attributesMap, unionAttributes] = attributesForTypes(types);
|
|
218
|
-
for (const [t, attributes] of attributesMap) {
|
|
219
|
-
this.addType(t, attributes);
|
|
220
|
-
}
|
|
221
|
-
return unionAttributes;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
exports.TypeRefUnionAccumulator = TypeRefUnionAccumulator;
|
|
225
|
-
class UnionBuilder {
|
|
226
|
-
typeBuilder;
|
|
227
|
-
constructor(typeBuilder) {
|
|
228
|
-
this.typeBuilder = typeBuilder;
|
|
229
|
-
}
|
|
230
|
-
makeTypeOfKind(typeProvider, kind, typeAttributes, forwardingRef) {
|
|
231
|
-
switch (kind) {
|
|
232
|
-
case "string":
|
|
233
|
-
return this.typeBuilder.getStringType(typeAttributes, undefined, forwardingRef);
|
|
234
|
-
case "enum":
|
|
235
|
-
return this.typeBuilder.getEnumType(typeAttributes, typeProvider.enumCases, forwardingRef);
|
|
236
|
-
case "object":
|
|
237
|
-
return this.makeObject(typeProvider.objectData, typeAttributes, forwardingRef);
|
|
238
|
-
case "array":
|
|
239
|
-
return this.makeArray(typeProvider.arrayData, typeAttributes, forwardingRef);
|
|
240
|
-
default:
|
|
241
|
-
if ((0, Type_1.isPrimitiveTypeKind)(kind)) {
|
|
242
|
-
return this.typeBuilder.getPrimitiveType(kind, typeAttributes, forwardingRef);
|
|
243
|
-
}
|
|
244
|
-
if (kind === "union" || kind === "class" || kind === "map" || kind === "intersection") {
|
|
245
|
-
return (0, Support_1.panic)(`getMemberKinds() shouldn't return ${kind}`);
|
|
246
|
-
}
|
|
247
|
-
return (0, Support_1.assertNever)(kind);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
buildUnion(typeProvider, unique, typeAttributes, forwardingRef) {
|
|
251
|
-
const kinds = typeProvider.getMemberKinds();
|
|
252
|
-
if (typeProvider.lostTypeAttributes) {
|
|
253
|
-
this.typeBuilder.setLostTypeAttributes();
|
|
254
|
-
}
|
|
255
|
-
// FIXME: We don't reconstitute type attributes here, so it's possible that
|
|
256
|
-
// we get type refs for the wrong graphs if the transformation making rewrite
|
|
257
|
-
// makes unions that have to be unified here. That's a bug anyway, at least
|
|
258
|
-
// right now, it's just a very bad way of surfacing that error.
|
|
259
|
-
if (kinds.size === 1) {
|
|
260
|
-
const [[kind, memberAttributes]] = Array.from(kinds);
|
|
261
|
-
const allAttributes = (0, TypeAttributes_1.combineTypeAttributes)("union", typeAttributes, (0, TypeAttributes_1.increaseTypeAttributesDistance)(memberAttributes));
|
|
262
|
-
const t = this.makeTypeOfKind(typeProvider, kind, allAttributes, forwardingRef);
|
|
263
|
-
return t;
|
|
264
|
-
}
|
|
265
|
-
const union = unique
|
|
266
|
-
? this.typeBuilder.getUniqueUnionType(typeAttributes, undefined, forwardingRef)
|
|
267
|
-
: undefined;
|
|
268
|
-
const types = [];
|
|
269
|
-
for (const [kind, memberAttributes] of kinds) {
|
|
270
|
-
types.push(this.makeTypeOfKind(typeProvider, kind, memberAttributes, undefined));
|
|
271
|
-
}
|
|
272
|
-
const typesSet = new Set(types);
|
|
273
|
-
if (union !== undefined) {
|
|
274
|
-
this.typeBuilder.setSetOperationMembers(union, typesSet);
|
|
275
|
-
return union;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
return this.typeBuilder.getUnionType(typeAttributes, typesSet, forwardingRef);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
exports.UnionBuilder = UnionBuilder;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
|
2
|
-
import { EnumType, UnionType, Type, ObjectType } from "../Type";
|
|
3
|
-
import { JSONSchema } from "../input/JSONSchemaStore";
|
|
4
|
-
import { Ref, JSONSchemaType, JSONSchemaAttributes } from "../input/JSONSchemaInput";
|
|
5
|
-
export type AccessorEntry = string | Map<string, string>;
|
|
6
|
-
export type AccessorNames = Map<string, AccessorEntry>;
|
|
7
|
-
export declare const accessorNamesTypeAttributeKind: TypeAttributeKind<AccessorNames>;
|
|
8
|
-
export declare function lookupKey(accessors: AccessorNames, key: string, language: string): [string, boolean] | undefined;
|
|
9
|
-
export declare function objectPropertyNames(o: ObjectType, language: string): Map<string, [string, boolean] | undefined>;
|
|
10
|
-
export declare function enumCaseNames(e: EnumType, language: string): Map<string, [string, boolean] | undefined>;
|
|
11
|
-
export declare function getAccessorName(names: Map<string, [string, boolean] | undefined>, original: string): [string | undefined, boolean];
|
|
12
|
-
export declare const unionIdentifierTypeAttributeKind: TypeAttributeKind<ReadonlySet<number>>;
|
|
13
|
-
export declare function makeUnionIdentifierAttribute(): TypeAttributes;
|
|
14
|
-
export declare const unionMemberNamesTypeAttributeKind: TypeAttributeKind<Map<number, AccessorEntry>>;
|
|
15
|
-
export declare function makeUnionMemberNamesAttribute(unionAttributes: TypeAttributes, entry: AccessorEntry): TypeAttributes;
|
|
16
|
-
export declare function unionMemberName(u: UnionType, member: Type, language: string): [string | undefined, boolean];
|
|
17
|
-
export declare function makeAccessorNames(x: any): AccessorNames;
|
|
18
|
-
export declare function accessorNamesAttributeProducer(schema: JSONSchema, canonicalRef: Ref, _types: Set<JSONSchemaType>, cases: JSONSchema[] | undefined): JSONSchemaAttributes | undefined;
|