quicktype 16.0.42 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +40 -38
- 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 +28 -4
- package/package.json +25 -19
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionType = exports.IntersectionType = exports.SetOperationType = exports.intersectionTypeIdentity = exports.unionTypeIdentity = exports.setOperationTypeIdentity = exports.setOperationCasesEqual = exports.EnumType = exports.enumTypeIdentity = exports.MapType = exports.ClassType = exports.ObjectType = exports.mapTypeIdentify = exports.classTypeIdentity = exports.ClassProperty = exports.GenericClassProperty = exports.ArrayType = exports.arrayTypeIdentity = exports.PrimitiveType = exports.primitiveTypeIdentity = exports.Type = exports.TypeIdentity = exports.isPrimitiveTypeKind = exports.isNumberTypeKind = exports.targetTypeKindForTransformedStringTypeKind = exports.isPrimitiveStringTypeKind = exports.transformedStringTypeKinds = exports.transformedStringTypeTargetTypeKindsMap = void 0;
|
|
3
4
|
const collection_utils_1 = require("collection-utils");
|
|
4
5
|
const Support_1 = require("./support/Support");
|
|
5
6
|
const TypeNames_1 = require("./attributes/TypeNames");
|
|
@@ -21,10 +22,10 @@ const transformedStringTypeTargetTypeKinds = {
|
|
|
21
22
|
"integer-string": { jsonSchema: "integer", primitive: "integer" },
|
|
22
23
|
"bool-string": { jsonSchema: "boolean", primitive: "bool" }
|
|
23
24
|
};
|
|
24
|
-
exports.transformedStringTypeTargetTypeKindsMap = collection_utils_1.mapFromObject(transformedStringTypeTargetTypeKinds);
|
|
25
|
+
exports.transformedStringTypeTargetTypeKindsMap = (0, collection_utils_1.mapFromObject)(transformedStringTypeTargetTypeKinds);
|
|
25
26
|
exports.transformedStringTypeKinds = new Set(Object.getOwnPropertyNames(transformedStringTypeTargetTypeKinds));
|
|
26
27
|
function isPrimitiveStringTypeKind(kind) {
|
|
27
|
-
return kind === "string" || collection_utils_1.hasOwnProperty(transformedStringTypeTargetTypeKinds, kind);
|
|
28
|
+
return kind === "string" || (0, collection_utils_1.hasOwnProperty)(transformedStringTypeTargetTypeKinds, kind);
|
|
28
29
|
}
|
|
29
30
|
exports.isPrimitiveStringTypeKind = isPrimitiveStringTypeKind;
|
|
30
31
|
function targetTypeKindForTransformedStringTypeKind(kind) {
|
|
@@ -54,13 +55,16 @@ function triviallyStructurallyCompatible(x, y) {
|
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
56
57
|
class TypeIdentity {
|
|
58
|
+
_kind;
|
|
59
|
+
_components;
|
|
60
|
+
_hashCode;
|
|
57
61
|
constructor(_kind, _components) {
|
|
58
62
|
this._kind = _kind;
|
|
59
63
|
this._components = _components;
|
|
60
64
|
let h = collection_utils_1.hashCodeInit;
|
|
61
|
-
h = collection_utils_1.addHashCode(h, collection_utils_1.hashCodeOf(this._kind));
|
|
65
|
+
h = (0, collection_utils_1.addHashCode)(h, (0, collection_utils_1.hashCodeOf)(this._kind));
|
|
62
66
|
for (const c of _components) {
|
|
63
|
-
h = collection_utils_1.addHashCode(h, collection_utils_1.hashCodeOf(c));
|
|
67
|
+
h = (0, collection_utils_1.addHashCode)(h, (0, collection_utils_1.hashCodeOf)(c));
|
|
64
68
|
}
|
|
65
69
|
this._hashCode = h;
|
|
66
70
|
}
|
|
@@ -70,9 +74,9 @@ class TypeIdentity {
|
|
|
70
74
|
if (this._kind !== other._kind)
|
|
71
75
|
return false;
|
|
72
76
|
const n = this._components.length;
|
|
73
|
-
Support_1.assert(n === other._components.length, "Components of a type kind's identity must have the same length");
|
|
77
|
+
(0, Support_1.assert)(n === other._components.length, "Components of a type kind's identity must have the same length");
|
|
74
78
|
for (let i = 0; i < n; i++) {
|
|
75
|
-
if (!collection_utils_1.areEqual(this._components[i], other._components[i]))
|
|
79
|
+
if (!(0, collection_utils_1.areEqual)(this._components[i], other._components[i]))
|
|
76
80
|
return false;
|
|
77
81
|
}
|
|
78
82
|
return true;
|
|
@@ -83,31 +87,32 @@ class TypeIdentity {
|
|
|
83
87
|
}
|
|
84
88
|
exports.TypeIdentity = TypeIdentity;
|
|
85
89
|
class Type {
|
|
86
|
-
|
|
90
|
+
typeRef;
|
|
91
|
+
graph;
|
|
92
|
+
constructor(typeRef, graph) {
|
|
87
93
|
this.typeRef = typeRef;
|
|
88
94
|
this.graph = graph;
|
|
89
|
-
this.kind = kind;
|
|
90
95
|
}
|
|
91
96
|
get index() {
|
|
92
|
-
return TypeGraph_1.typeRefIndex(this.typeRef);
|
|
97
|
+
return (0, TypeGraph_1.typeRefIndex)(this.typeRef);
|
|
93
98
|
}
|
|
94
99
|
getChildren() {
|
|
95
100
|
let result = this.getNonAttributeChildren();
|
|
96
101
|
for (const [k, v] of this.getAttributes()) {
|
|
97
102
|
if (k.children === undefined)
|
|
98
103
|
continue;
|
|
99
|
-
collection_utils_1.setUnionInto(result, k.children(v));
|
|
104
|
+
(0, collection_utils_1.setUnionInto)(result, k.children(v));
|
|
100
105
|
}
|
|
101
106
|
return result;
|
|
102
107
|
}
|
|
103
108
|
getAttributes() {
|
|
104
|
-
return TypeGraph_1.attributesForTypeRef(this.typeRef, this.graph);
|
|
109
|
+
return (0, TypeGraph_1.attributesForTypeRef)(this.typeRef, this.graph);
|
|
105
110
|
}
|
|
106
111
|
get hasNames() {
|
|
107
112
|
return TypeNames_1.namesTypeAttributeKind.tryGetInAttributes(this.getAttributes()) !== undefined;
|
|
108
113
|
}
|
|
109
114
|
getNames() {
|
|
110
|
-
return Support_1.defined(TypeNames_1.namesTypeAttributeKind.tryGetInAttributes(this.getAttributes()));
|
|
115
|
+
return (0, Support_1.defined)(TypeNames_1.namesTypeAttributeKind.tryGetInAttributes(this.getAttributes()));
|
|
111
116
|
}
|
|
112
117
|
getCombinedName() {
|
|
113
118
|
return this.getNames().combinedName;
|
|
@@ -121,7 +126,7 @@ class Type {
|
|
|
121
126
|
return this.typeRef === other.typeRef;
|
|
122
127
|
}
|
|
123
128
|
hashCode() {
|
|
124
|
-
return collection_utils_1.hashCodeOf(this.typeRef);
|
|
129
|
+
return (0, collection_utils_1.hashCodeOf)(this.typeRef);
|
|
125
130
|
}
|
|
126
131
|
structurallyCompatible(other, conflateNumbers = false) {
|
|
127
132
|
function kindsCompatible(kind1, kind2) {
|
|
@@ -156,7 +161,7 @@ class Type {
|
|
|
156
161
|
return true;
|
|
157
162
|
};
|
|
158
163
|
while (workList.length > 0) {
|
|
159
|
-
let [a, b] = Support_1.defined(workList.pop());
|
|
164
|
+
let [a, b] = (0, Support_1.defined)(workList.pop());
|
|
160
165
|
if (a.index > b.index) {
|
|
161
166
|
[a, b] = [b, a];
|
|
162
167
|
}
|
|
@@ -214,10 +219,10 @@ class Type {
|
|
|
214
219
|
}
|
|
215
220
|
exports.Type = Type;
|
|
216
221
|
function hasUniqueIdentityAttributes(attributes) {
|
|
217
|
-
return collection_utils_1.mapSome(attributes, (v, ta) => ta.requiresUniqueIdentity(v));
|
|
222
|
+
return (0, collection_utils_1.mapSome)(attributes, (v, ta) => ta.requiresUniqueIdentity(v));
|
|
218
223
|
}
|
|
219
224
|
function identityAttributes(attributes) {
|
|
220
|
-
return collection_utils_1.mapFilter(attributes, (_, kind) => kind.inIdentity);
|
|
225
|
+
return (0, collection_utils_1.mapFilter)(attributes, (_, kind) => kind.inIdentity);
|
|
221
226
|
}
|
|
222
227
|
function primitiveTypeIdentity(kind, attributes) {
|
|
223
228
|
if (hasUniqueIdentityAttributes(attributes))
|
|
@@ -226,6 +231,11 @@ function primitiveTypeIdentity(kind, attributes) {
|
|
|
226
231
|
}
|
|
227
232
|
exports.primitiveTypeIdentity = primitiveTypeIdentity;
|
|
228
233
|
class PrimitiveType extends Type {
|
|
234
|
+
kind;
|
|
235
|
+
constructor(typeRef, graph, kind) {
|
|
236
|
+
super(typeRef, graph);
|
|
237
|
+
this.kind = kind;
|
|
238
|
+
}
|
|
229
239
|
get isNullable() {
|
|
230
240
|
return this.kind === "null" || this.kind === "any" || this.kind === "none";
|
|
231
241
|
}
|
|
@@ -253,24 +263,26 @@ function arrayTypeIdentity(attributes, itemsRef) {
|
|
|
253
263
|
}
|
|
254
264
|
exports.arrayTypeIdentity = arrayTypeIdentity;
|
|
255
265
|
class ArrayType extends Type {
|
|
266
|
+
_itemsRef;
|
|
267
|
+
kind = "array";
|
|
256
268
|
constructor(typeRef, graph, _itemsRef) {
|
|
257
|
-
super(typeRef, graph
|
|
269
|
+
super(typeRef, graph);
|
|
258
270
|
this._itemsRef = _itemsRef;
|
|
259
271
|
}
|
|
260
272
|
setItems(itemsRef) {
|
|
261
273
|
if (this._itemsRef !== undefined) {
|
|
262
|
-
return Support_1.panic("Can only set array items once");
|
|
274
|
+
return (0, Support_1.panic)("Can only set array items once");
|
|
263
275
|
}
|
|
264
276
|
this._itemsRef = itemsRef;
|
|
265
277
|
}
|
|
266
278
|
getItemsRef() {
|
|
267
279
|
if (this._itemsRef === undefined) {
|
|
268
|
-
return Support_1.panic("Array items accessed before they were set");
|
|
280
|
+
return (0, Support_1.panic)("Array items accessed before they were set");
|
|
269
281
|
}
|
|
270
282
|
return this._itemsRef;
|
|
271
283
|
}
|
|
272
284
|
get items() {
|
|
273
|
-
return TypeGraph_1.derefTypeRef(this.getItemsRef(), this.graph);
|
|
285
|
+
return (0, TypeGraph_1.derefTypeRef)(this.getItemsRef(), this.graph);
|
|
274
286
|
}
|
|
275
287
|
getNonAttributeChildren() {
|
|
276
288
|
return new Set([this.items]);
|
|
@@ -301,6 +313,8 @@ class ArrayType extends Type {
|
|
|
301
313
|
}
|
|
302
314
|
exports.ArrayType = ArrayType;
|
|
303
315
|
class GenericClassProperty {
|
|
316
|
+
typeData;
|
|
317
|
+
isOptional;
|
|
304
318
|
constructor(typeData, isOptional) {
|
|
305
319
|
this.typeData = typeData;
|
|
306
320
|
this.isOptional = isOptional;
|
|
@@ -309,14 +323,15 @@ class GenericClassProperty {
|
|
|
309
323
|
if (!(other instanceof GenericClassProperty)) {
|
|
310
324
|
return false;
|
|
311
325
|
}
|
|
312
|
-
return collection_utils_1.areEqual(this.typeData, other.typeData) && this.isOptional === other.isOptional;
|
|
326
|
+
return (0, collection_utils_1.areEqual)(this.typeData, other.typeData) && this.isOptional === other.isOptional;
|
|
313
327
|
}
|
|
314
328
|
hashCode() {
|
|
315
|
-
return collection_utils_1.hashCodeOf(this.typeData) + (this.isOptional ? 17 : 23);
|
|
329
|
+
return (0, collection_utils_1.hashCodeOf)(this.typeData) + (this.isOptional ? 17 : 23);
|
|
316
330
|
}
|
|
317
331
|
}
|
|
318
332
|
exports.GenericClassProperty = GenericClassProperty;
|
|
319
333
|
class ClassProperty extends GenericClassProperty {
|
|
334
|
+
graph;
|
|
320
335
|
constructor(typeRef, graph, isOptional) {
|
|
321
336
|
super(typeRef, isOptional);
|
|
322
337
|
this.graph = graph;
|
|
@@ -325,7 +340,7 @@ class ClassProperty extends GenericClassProperty {
|
|
|
325
340
|
return this.typeData;
|
|
326
341
|
}
|
|
327
342
|
get type() {
|
|
328
|
-
return TypeGraph_1.derefTypeRef(this.typeRef, this.graph);
|
|
343
|
+
return (0, TypeGraph_1.derefTypeRef)(this.typeRef, this.graph);
|
|
329
344
|
}
|
|
330
345
|
}
|
|
331
346
|
exports.ClassProperty = ClassProperty;
|
|
@@ -343,53 +358,58 @@ function mapTypeIdentify(attributes, additionalPropertiesRef) {
|
|
|
343
358
|
}
|
|
344
359
|
exports.mapTypeIdentify = mapTypeIdentify;
|
|
345
360
|
class ObjectType extends Type {
|
|
361
|
+
kind;
|
|
362
|
+
isFixed;
|
|
363
|
+
_properties;
|
|
364
|
+
_additionalPropertiesRef;
|
|
346
365
|
constructor(typeRef, graph, kind, isFixed, _properties, _additionalPropertiesRef) {
|
|
347
|
-
super(typeRef, graph
|
|
366
|
+
super(typeRef, graph);
|
|
367
|
+
this.kind = kind;
|
|
348
368
|
this.isFixed = isFixed;
|
|
349
369
|
this._properties = _properties;
|
|
350
370
|
this._additionalPropertiesRef = _additionalPropertiesRef;
|
|
351
371
|
if (kind === "map") {
|
|
352
372
|
if (_properties !== undefined) {
|
|
353
|
-
Support_1.assert(_properties.size === 0);
|
|
373
|
+
(0, Support_1.assert)(_properties.size === 0);
|
|
354
374
|
}
|
|
355
|
-
Support_1.assert(!isFixed);
|
|
375
|
+
(0, Support_1.assert)(!isFixed);
|
|
356
376
|
}
|
|
357
377
|
else if (kind === "class") {
|
|
358
|
-
Support_1.assert(_additionalPropertiesRef === undefined);
|
|
378
|
+
(0, Support_1.assert)(_additionalPropertiesRef === undefined);
|
|
359
379
|
}
|
|
360
380
|
else {
|
|
361
|
-
Support_1.assert(isFixed);
|
|
381
|
+
(0, Support_1.assert)(isFixed);
|
|
362
382
|
}
|
|
363
383
|
}
|
|
364
384
|
setProperties(properties, additionalPropertiesRef) {
|
|
365
|
-
Support_1.assert(this._properties === undefined, "Tried to set object properties twice");
|
|
385
|
+
(0, Support_1.assert)(this._properties === undefined, "Tried to set object properties twice");
|
|
366
386
|
if (this instanceof MapType) {
|
|
367
|
-
Support_1.assert(properties.size === 0, "Cannot set properties on map type");
|
|
387
|
+
(0, Support_1.assert)(properties.size === 0, "Cannot set properties on map type");
|
|
368
388
|
}
|
|
369
389
|
if (this instanceof ClassType) {
|
|
370
|
-
Support_1.assert(additionalPropertiesRef === undefined, "Cannot set additional properties of class type");
|
|
390
|
+
(0, Support_1.assert)(additionalPropertiesRef === undefined, "Cannot set additional properties of class type");
|
|
371
391
|
}
|
|
372
392
|
this._properties = properties;
|
|
373
393
|
this._additionalPropertiesRef = additionalPropertiesRef;
|
|
374
394
|
}
|
|
375
395
|
getProperties() {
|
|
376
|
-
return Support_1.defined(this._properties);
|
|
396
|
+
return (0, Support_1.defined)(this._properties);
|
|
377
397
|
}
|
|
378
398
|
getSortedProperties() {
|
|
379
|
-
return collection_utils_1.mapSortByKey(this.getProperties());
|
|
399
|
+
return (0, collection_utils_1.mapSortByKey)(this.getProperties());
|
|
380
400
|
}
|
|
381
401
|
getAdditionalPropertiesRef() {
|
|
382
|
-
Support_1.assert(this._properties !== undefined, "Properties are not set yet");
|
|
402
|
+
(0, Support_1.assert)(this._properties !== undefined, "Properties are not set yet");
|
|
383
403
|
return this._additionalPropertiesRef;
|
|
384
404
|
}
|
|
385
405
|
getAdditionalProperties() {
|
|
386
406
|
const tref = this.getAdditionalPropertiesRef();
|
|
387
407
|
if (tref === undefined)
|
|
388
408
|
return undefined;
|
|
389
|
-
return TypeGraph_1.derefTypeRef(tref, this.graph);
|
|
409
|
+
return (0, TypeGraph_1.derefTypeRef)(tref, this.graph);
|
|
390
410
|
}
|
|
391
411
|
getNonAttributeChildren() {
|
|
392
|
-
const types = collection_utils_1.mapSortToArray(this.getProperties(), (_, k) => k).map(([_, p]) => p.type);
|
|
412
|
+
const types = (0, collection_utils_1.mapSortToArray)(this.getProperties(), (_, k) => k).map(([_, p]) => p.type);
|
|
393
413
|
const additionalProperties = this.getAdditionalProperties();
|
|
394
414
|
if (additionalProperties !== undefined) {
|
|
395
415
|
types.push(additionalProperties);
|
|
@@ -410,18 +430,18 @@ class ObjectType extends Type {
|
|
|
410
430
|
reconstitute(builder, canonicalOrder) {
|
|
411
431
|
const sortedProperties = this.getSortedProperties();
|
|
412
432
|
const propertiesInNewOrder = canonicalOrder ? sortedProperties : this.getProperties();
|
|
413
|
-
const maybePropertyTypes = builder.lookupMap(collection_utils_1.mapMap(sortedProperties, cp => cp.typeRef));
|
|
414
|
-
const maybeAdditionalProperties = collection_utils_1.definedMap(this._additionalPropertiesRef, r => builder.lookup(r));
|
|
433
|
+
const maybePropertyTypes = builder.lookupMap((0, collection_utils_1.mapMap)(sortedProperties, cp => cp.typeRef));
|
|
434
|
+
const maybeAdditionalProperties = (0, collection_utils_1.definedMap)(this._additionalPropertiesRef, r => builder.lookup(r));
|
|
415
435
|
if (maybePropertyTypes !== undefined &&
|
|
416
436
|
(maybeAdditionalProperties !== undefined || this._additionalPropertiesRef === undefined)) {
|
|
417
|
-
const properties = collection_utils_1.mapMap(propertiesInNewOrder, (cp, n) => builder.makeClassProperty(Support_1.defined(maybePropertyTypes.get(n)), cp.isOptional));
|
|
437
|
+
const properties = (0, collection_utils_1.mapMap)(propertiesInNewOrder, (cp, n) => builder.makeClassProperty((0, Support_1.defined)(maybePropertyTypes.get(n)), cp.isOptional));
|
|
418
438
|
switch (this.kind) {
|
|
419
439
|
case "object":
|
|
420
|
-
Support_1.assert(this.isFixed);
|
|
440
|
+
(0, Support_1.assert)(this.isFixed);
|
|
421
441
|
builder.getObjectType(properties, maybeAdditionalProperties);
|
|
422
442
|
break;
|
|
423
443
|
case "map":
|
|
424
|
-
builder.getMapType(Support_1.defined(maybeAdditionalProperties));
|
|
444
|
+
builder.getMapType((0, Support_1.defined)(maybeAdditionalProperties));
|
|
425
445
|
break;
|
|
426
446
|
case "class":
|
|
427
447
|
if (this.isFixed) {
|
|
@@ -432,13 +452,13 @@ class ObjectType extends Type {
|
|
|
432
452
|
}
|
|
433
453
|
break;
|
|
434
454
|
default:
|
|
435
|
-
return Support_1.panic(`Invalid object type kind ${this.kind}`);
|
|
455
|
+
return (0, Support_1.panic)(`Invalid object type kind ${this.kind}`);
|
|
436
456
|
}
|
|
437
457
|
}
|
|
438
458
|
else {
|
|
439
459
|
switch (this.kind) {
|
|
440
460
|
case "object":
|
|
441
|
-
Support_1.assert(this.isFixed);
|
|
461
|
+
(0, Support_1.assert)(this.isFixed);
|
|
442
462
|
builder.getUniqueObjectType(undefined, undefined);
|
|
443
463
|
break;
|
|
444
464
|
case "map":
|
|
@@ -448,11 +468,11 @@ class ObjectType extends Type {
|
|
|
448
468
|
builder.getUniqueClassType(this.isFixed, undefined);
|
|
449
469
|
break;
|
|
450
470
|
default:
|
|
451
|
-
return Support_1.panic(`Invalid object type kind ${this.kind}`);
|
|
471
|
+
return (0, Support_1.panic)(`Invalid object type kind ${this.kind}`);
|
|
452
472
|
}
|
|
453
|
-
const reconstitutedTypes = collection_utils_1.mapMap(sortedProperties, cp => builder.reconstitute(cp.typeRef));
|
|
454
|
-
const properties = collection_utils_1.mapMap(propertiesInNewOrder, (cp, n) => builder.makeClassProperty(Support_1.defined(reconstitutedTypes.get(n)), cp.isOptional));
|
|
455
|
-
const additionalProperties = collection_utils_1.definedMap(this._additionalPropertiesRef, r => builder.reconstitute(r));
|
|
473
|
+
const reconstitutedTypes = (0, collection_utils_1.mapMap)(sortedProperties, cp => builder.reconstitute(cp.typeRef));
|
|
474
|
+
const properties = (0, collection_utils_1.mapMap)(propertiesInNewOrder, (cp, n) => builder.makeClassProperty((0, Support_1.defined)(reconstitutedTypes.get(n)), cp.isOptional));
|
|
475
|
+
const additionalProperties = (0, collection_utils_1.definedMap)(this._additionalPropertiesRef, r => builder.reconstitute(r));
|
|
456
476
|
builder.setObjectProperties(properties, additionalProperties);
|
|
457
477
|
}
|
|
458
478
|
}
|
|
@@ -489,11 +509,11 @@ class ClassType extends ObjectType {
|
|
|
489
509
|
exports.ClassType = ClassType;
|
|
490
510
|
class MapType extends ObjectType {
|
|
491
511
|
constructor(typeRef, graph, valuesRef) {
|
|
492
|
-
super(typeRef, graph, "map", false, collection_utils_1.definedMap(valuesRef, () => new Map()), valuesRef);
|
|
512
|
+
super(typeRef, graph, "map", false, (0, collection_utils_1.definedMap)(valuesRef, () => new Map()), valuesRef);
|
|
493
513
|
}
|
|
494
514
|
// FIXME: Remove and use `getAdditionalProperties()` instead.
|
|
495
515
|
get values() {
|
|
496
|
-
return Support_1.defined(this.getAdditionalProperties());
|
|
516
|
+
return (0, Support_1.defined)(this.getAdditionalProperties());
|
|
497
517
|
}
|
|
498
518
|
}
|
|
499
519
|
exports.MapType = MapType;
|
|
@@ -504,8 +524,10 @@ function enumTypeIdentity(attributes, cases) {
|
|
|
504
524
|
}
|
|
505
525
|
exports.enumTypeIdentity = enumTypeIdentity;
|
|
506
526
|
class EnumType extends Type {
|
|
527
|
+
cases;
|
|
528
|
+
kind = "enum";
|
|
507
529
|
constructor(typeRef, graph, cases) {
|
|
508
|
-
super(typeRef, graph
|
|
530
|
+
super(typeRef, graph);
|
|
509
531
|
this.cases = cases;
|
|
510
532
|
}
|
|
511
533
|
get isNullable() {
|
|
@@ -524,25 +546,25 @@ class EnumType extends Type {
|
|
|
524
546
|
builder.getEnumType(this.cases);
|
|
525
547
|
}
|
|
526
548
|
structuralEqualityStep(other, _conflateNumbers, _queue) {
|
|
527
|
-
return collection_utils_1.areEqual(this.cases, other.cases);
|
|
549
|
+
return (0, collection_utils_1.areEqual)(this.cases, other.cases);
|
|
528
550
|
}
|
|
529
551
|
}
|
|
530
552
|
exports.EnumType = EnumType;
|
|
531
553
|
function setOperationCasesEqual(typesA, typesB, conflateNumbers, membersEqual) {
|
|
532
|
-
const ma = collection_utils_1.toReadonlySet(typesA);
|
|
533
|
-
const mb = collection_utils_1.toReadonlySet(typesB);
|
|
554
|
+
const ma = (0, collection_utils_1.toReadonlySet)(typesA);
|
|
555
|
+
const mb = (0, collection_utils_1.toReadonlySet)(typesB);
|
|
534
556
|
if (ma.size !== mb.size)
|
|
535
557
|
return false;
|
|
536
|
-
return collection_utils_1.iterableEvery(ma, ta => {
|
|
537
|
-
const tb = collection_utils_1.iterableFind(mb, t => t.kind === ta.kind);
|
|
558
|
+
return (0, collection_utils_1.iterableEvery)(ma, ta => {
|
|
559
|
+
const tb = (0, collection_utils_1.iterableFind)(mb, t => t.kind === ta.kind);
|
|
538
560
|
if (tb !== undefined) {
|
|
539
561
|
if (membersEqual(ta, tb))
|
|
540
562
|
return true;
|
|
541
563
|
}
|
|
542
564
|
if (conflateNumbers) {
|
|
543
|
-
if (ta.kind === "integer" && collection_utils_1.iterableSome(mb, t => t.kind === "double"))
|
|
565
|
+
if (ta.kind === "integer" && (0, collection_utils_1.iterableSome)(mb, t => t.kind === "double"))
|
|
544
566
|
return true;
|
|
545
|
-
if (ta.kind === "double" && collection_utils_1.iterableSome(mb, t => t.kind === "integer"))
|
|
567
|
+
if (ta.kind === "double" && (0, collection_utils_1.iterableSome)(mb, t => t.kind === "integer"))
|
|
546
568
|
return true;
|
|
547
569
|
}
|
|
548
570
|
return false;
|
|
@@ -564,31 +586,34 @@ function intersectionTypeIdentity(attributes, memberRefs) {
|
|
|
564
586
|
}
|
|
565
587
|
exports.intersectionTypeIdentity = intersectionTypeIdentity;
|
|
566
588
|
class SetOperationType extends Type {
|
|
589
|
+
kind;
|
|
590
|
+
_memberRefs;
|
|
567
591
|
constructor(typeRef, graph, kind, _memberRefs) {
|
|
568
|
-
super(typeRef, graph
|
|
592
|
+
super(typeRef, graph);
|
|
593
|
+
this.kind = kind;
|
|
569
594
|
this._memberRefs = _memberRefs;
|
|
570
595
|
}
|
|
571
596
|
setMembers(memberRefs) {
|
|
572
597
|
if (this._memberRefs !== undefined) {
|
|
573
|
-
return Support_1.panic("Can only set map members once");
|
|
598
|
+
return (0, Support_1.panic)("Can only set map members once");
|
|
574
599
|
}
|
|
575
600
|
this._memberRefs = memberRefs;
|
|
576
601
|
}
|
|
577
602
|
getMemberRefs() {
|
|
578
603
|
if (this._memberRefs === undefined) {
|
|
579
|
-
return Support_1.panic("Map members accessed before they were set");
|
|
604
|
+
return (0, Support_1.panic)("Map members accessed before they were set");
|
|
580
605
|
}
|
|
581
606
|
return this._memberRefs;
|
|
582
607
|
}
|
|
583
608
|
get members() {
|
|
584
|
-
return collection_utils_1.setMap(this.getMemberRefs(), tref => TypeGraph_1.derefTypeRef(tref, this.graph));
|
|
609
|
+
return (0, collection_utils_1.setMap)(this.getMemberRefs(), tref => (0, TypeGraph_1.derefTypeRef)(tref, this.graph));
|
|
585
610
|
}
|
|
586
611
|
get sortedMembers() {
|
|
587
612
|
return this.getNonAttributeChildren();
|
|
588
613
|
}
|
|
589
614
|
getNonAttributeChildren() {
|
|
590
615
|
// FIXME: We're assuming no two members of the same kind.
|
|
591
|
-
return collection_utils_1.setSortBy(this.members, t => t.kind);
|
|
616
|
+
return (0, collection_utils_1.setSortBy)(this.members, t => t.kind);
|
|
592
617
|
}
|
|
593
618
|
isPrimitive() {
|
|
594
619
|
return false;
|
|
@@ -597,16 +622,16 @@ class SetOperationType extends Type {
|
|
|
597
622
|
return setOperationTypeIdentity(this.kind, this.getAttributes(), this.getMemberRefs());
|
|
598
623
|
}
|
|
599
624
|
reconstituteSetOperation(builder, canonicalOrder, getType) {
|
|
600
|
-
const sortedMemberRefs = collection_utils_1.mapMap(this.sortedMembers.entries(), t => t.typeRef);
|
|
625
|
+
const sortedMemberRefs = (0, collection_utils_1.mapMap)(this.sortedMembers.entries(), t => t.typeRef);
|
|
601
626
|
const membersInOrder = canonicalOrder ? this.sortedMembers : this.members;
|
|
602
627
|
const maybeMembers = builder.lookupMap(sortedMemberRefs);
|
|
603
628
|
if (maybeMembers === undefined) {
|
|
604
629
|
getType(undefined);
|
|
605
630
|
const reconstituted = builder.reconstituteMap(sortedMemberRefs);
|
|
606
|
-
builder.setSetOperationMembers(collection_utils_1.setMap(membersInOrder, t => Support_1.defined(reconstituted.get(t))));
|
|
631
|
+
builder.setSetOperationMembers((0, collection_utils_1.setMap)(membersInOrder, t => (0, Support_1.defined)(reconstituted.get(t))));
|
|
607
632
|
}
|
|
608
633
|
else {
|
|
609
|
-
getType(collection_utils_1.setMap(membersInOrder, t => Support_1.defined(maybeMembers.get(t))));
|
|
634
|
+
getType((0, collection_utils_1.setMap)(membersInOrder, t => (0, Support_1.defined)(maybeMembers.get(t))));
|
|
610
635
|
}
|
|
611
636
|
}
|
|
612
637
|
structuralEqualityStep(other, conflateNumbers, queue) {
|
|
@@ -619,7 +644,7 @@ class IntersectionType extends SetOperationType {
|
|
|
619
644
|
super(typeRef, graph, "intersection", memberRefs);
|
|
620
645
|
}
|
|
621
646
|
get isNullable() {
|
|
622
|
-
return Support_1.panic("isNullable not implemented for IntersectionType");
|
|
647
|
+
return (0, Support_1.panic)("isNullable not implemented for IntersectionType");
|
|
623
648
|
}
|
|
624
649
|
reconstitute(builder, canonicalOrder) {
|
|
625
650
|
this.reconstituteSetOperation(builder, canonicalOrder, members => {
|
|
@@ -637,18 +662,18 @@ class UnionType extends SetOperationType {
|
|
|
637
662
|
constructor(typeRef, graph, memberRefs) {
|
|
638
663
|
super(typeRef, graph, "union", memberRefs);
|
|
639
664
|
if (memberRefs !== undefined) {
|
|
640
|
-
Messages_1.messageAssert(memberRefs.size > 0, "IRNoEmptyUnions", {});
|
|
665
|
+
(0, Messages_1.messageAssert)(memberRefs.size > 0, "IRNoEmptyUnions", {});
|
|
641
666
|
}
|
|
642
667
|
}
|
|
643
668
|
setMembers(memberRefs) {
|
|
644
|
-
Messages_1.messageAssert(memberRefs.size > 0, "IRNoEmptyUnions", {});
|
|
669
|
+
(0, Messages_1.messageAssert)(memberRefs.size > 0, "IRNoEmptyUnions", {});
|
|
645
670
|
super.setMembers(memberRefs);
|
|
646
671
|
}
|
|
647
672
|
get stringTypeMembers() {
|
|
648
|
-
return collection_utils_1.setFilter(this.members, t => isPrimitiveStringTypeKind(t.kind) || t.kind === "enum");
|
|
673
|
+
return (0, collection_utils_1.setFilter)(this.members, t => isPrimitiveStringTypeKind(t.kind) || t.kind === "enum");
|
|
649
674
|
}
|
|
650
675
|
findMember(kind) {
|
|
651
|
-
return collection_utils_1.iterableFind(this.members, t => t.kind === kind);
|
|
676
|
+
return (0, collection_utils_1.iterableFind)(this.members, t => t.kind === kind);
|
|
652
677
|
}
|
|
653
678
|
get isNullable() {
|
|
654
679
|
return this.findMember("null") !== undefined;
|
|
@@ -657,7 +682,7 @@ class UnionType extends SetOperationType {
|
|
|
657
682
|
const members = this.members;
|
|
658
683
|
if (members.size <= 1)
|
|
659
684
|
return false;
|
|
660
|
-
const kinds = collection_utils_1.setMap(members, t => t.kind);
|
|
685
|
+
const kinds = (0, collection_utils_1.setMap)(members, t => t.kind);
|
|
661
686
|
if (kinds.size < members.size)
|
|
662
687
|
return false;
|
|
663
688
|
if (kinds.has("union") || kinds.has("intersection"))
|
|
@@ -3,7 +3,7 @@ import { TypeGraph, TypeRef } from "./TypeGraph";
|
|
|
3
3
|
import { TypeAttributes, TypeAttributeKind } from "./attributes/TypeAttributes";
|
|
4
4
|
import { StringTypes } from "./attributes/StringTypes";
|
|
5
5
|
export declare const provenanceTypeAttributeKind: TypeAttributeKind<Set<number>>;
|
|
6
|
-
export
|
|
6
|
+
export type StringTypeMapping = ReadonlyMap<TransformedStringTypeKind, PrimitiveStringTypeKind>;
|
|
7
7
|
export declare function stringTypeMappingGet(stm: StringTypeMapping, kind: TransformedStringTypeKind): PrimitiveStringTypeKind;
|
|
8
8
|
export declare function getNoStringTypeMapping(): StringTypeMapping;
|
|
9
9
|
export declare class TypeBuilder {
|
|
@@ -32,7 +32,7 @@ export declare class TypeBuilder {
|
|
|
32
32
|
protected forwardIfNecessary(forwardingRef: TypeRef | undefined, tref: undefined): undefined;
|
|
33
33
|
protected forwardIfNecessary(forwardingRef: TypeRef | undefined, tref: TypeRef): TypeRef;
|
|
34
34
|
protected forwardIfNecessary(forwardingRef: TypeRef | undefined, tref: TypeRef | undefined): TypeRef | undefined;
|
|
35
|
-
|
|
35
|
+
get didAddForwardingIntersection(): boolean;
|
|
36
36
|
private readonly _typeForIdentity;
|
|
37
37
|
private registerTypeForIdentity;
|
|
38
38
|
protected makeIdentity(maker: () => MaybeTypeIdentity): MaybeTypeIdentity;
|