quicktype 17.0.4 → 17.0.6

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.
Files changed (139) hide show
  1. package/dist/cli/CompressedJSONFromStream.js +38 -26
  2. package/dist/cli/GraphQLIntrospection.js +41 -33
  3. package/dist/cli/TypeSource.d.ts +1 -1
  4. package/dist/cli/URLGrammar.js +3 -4
  5. package/dist/cli/index.js +364 -363
  6. package/dist/quicktype-core/Annotation.js +0 -2
  7. package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
  8. package/dist/quicktype-core/ConvenienceRenderer.js +81 -104
  9. package/dist/quicktype-core/DateTime.js +0 -1
  10. package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
  11. package/dist/quicktype-core/DeclarationIR.js +10 -13
  12. package/dist/quicktype-core/EncodedMarkovChain.js +0 -1
  13. package/dist/quicktype-core/GatherNames.js +25 -47
  14. package/dist/quicktype-core/Graph.d.ts +2 -2
  15. package/dist/quicktype-core/Graph.js +19 -23
  16. package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
  17. package/dist/quicktype-core/GraphRewriting.js +54 -65
  18. package/dist/quicktype-core/MakeTransformations.js +22 -23
  19. package/dist/quicktype-core/MarkovChain.d.ts +3 -3
  20. package/dist/quicktype-core/MarkovChain.js +8 -9
  21. package/dist/quicktype-core/Messages.d.ts +3 -3
  22. package/dist/quicktype-core/Messages.js +3 -8
  23. package/dist/quicktype-core/Naming.d.ts +11 -11
  24. package/dist/quicktype-core/Naming.js +61 -76
  25. package/dist/quicktype-core/Renderer.d.ts +6 -6
  26. package/dist/quicktype-core/Renderer.js +17 -34
  27. package/dist/quicktype-core/RendererOptions.d.ts +5 -5
  28. package/dist/quicktype-core/RendererOptions.js +3 -6
  29. package/dist/quicktype-core/Run.d.ts +9 -9
  30. package/dist/quicktype-core/Run.js +67 -72
  31. package/dist/quicktype-core/Source.d.ts +3 -3
  32. package/dist/quicktype-core/Source.js +18 -19
  33. package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
  34. package/dist/quicktype-core/TargetLanguage.js +2 -6
  35. package/dist/quicktype-core/Transformers.d.ts +25 -25
  36. package/dist/quicktype-core/Transformers.js +66 -94
  37. package/dist/quicktype-core/Type.d.ts +43 -41
  38. package/dist/quicktype-core/Type.js +71 -96
  39. package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
  40. package/dist/quicktype-core/TypeBuilder.js +47 -53
  41. package/dist/quicktype-core/TypeGraph.d.ts +4 -4
  42. package/dist/quicktype-core/TypeGraph.js +40 -49
  43. package/dist/quicktype-core/TypeUtils.d.ts +2 -2
  44. package/dist/quicktype-core/TypeUtils.js +22 -23
  45. package/dist/quicktype-core/UnifyClasses.js +12 -16
  46. package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
  47. package/dist/quicktype-core/UnionBuilder.js +30 -33
  48. package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
  49. package/dist/quicktype-core/attributes/AccessorNames.js +17 -18
  50. package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
  51. package/dist/quicktype-core/attributes/Constraints.js +4 -8
  52. package/dist/quicktype-core/attributes/Description.js +5 -6
  53. package/dist/quicktype-core/attributes/EnumValues.js +3 -4
  54. package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
  55. package/dist/quicktype-core/attributes/StringTypes.js +21 -24
  56. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
  57. package/dist/quicktype-core/attributes/TypeAttributes.js +10 -12
  58. package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
  59. package/dist/quicktype-core/attributes/TypeNames.js +21 -49
  60. package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
  61. package/dist/quicktype-core/attributes/URIAttributes.js +6 -10
  62. package/dist/quicktype-core/index.js +125 -128
  63. package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
  64. package/dist/quicktype-core/input/CompressedJSON.js +54 -49
  65. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +13 -5
  66. package/dist/quicktype-core/input/Inference.d.ts +2 -2
  67. package/dist/quicktype-core/input/Inference.js +17 -25
  68. package/dist/quicktype-core/input/Inputs.d.ts +2 -2
  69. package/dist/quicktype-core/input/Inputs.js +54 -38
  70. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
  71. package/dist/quicktype-core/input/JSONSchemaInput.js +523 -503
  72. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
  73. package/dist/quicktype-core/input/JSONSchemaStore.js +35 -24
  74. package/dist/quicktype-core/input/PostmanCollection.js +1 -2
  75. package/dist/quicktype-core/input/io/NodeIO.js +44 -55
  76. package/dist/quicktype-core/input/io/get-stream/index.js +2 -6
  77. package/dist/quicktype-core/language/All.js +2 -3
  78. package/dist/quicktype-core/language/CPlusPlus.d.ts +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +249 -251
  80. package/dist/quicktype-core/language/CSharp.d.ts +7 -7
  81. package/dist/quicktype-core/language/CSharp.js +72 -82
  82. package/dist/quicktype-core/language/Crystal.d.ts +2 -2
  83. package/dist/quicktype-core/language/Crystal.js +17 -18
  84. package/dist/quicktype-core/language/Dart.d.ts +4 -4
  85. package/dist/quicktype-core/language/Dart.js +34 -36
  86. package/dist/quicktype-core/language/Elm.d.ts +6 -6
  87. package/dist/quicktype-core/language/Elm.js +45 -47
  88. package/dist/quicktype-core/language/Golang.d.ts +4 -4
  89. package/dist/quicktype-core/language/Golang.js +20 -23
  90. package/dist/quicktype-core/language/Haskell.d.ts +5 -5
  91. package/dist/quicktype-core/language/Haskell.js +23 -25
  92. package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
  93. package/dist/quicktype-core/language/JSONSchema.js +16 -17
  94. package/dist/quicktype-core/language/Java.d.ts +2 -2
  95. package/dist/quicktype-core/language/Java.js +97 -97
  96. package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
  97. package/dist/quicktype-core/language/JavaScript.js +17 -19
  98. package/dist/quicktype-core/language/JavaScriptPropTypes.js +13 -15
  99. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +11 -12
  100. package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
  101. package/dist/quicktype-core/language/Kotlin.js +37 -39
  102. package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
  103. package/dist/quicktype-core/language/Objective-C.js +41 -45
  104. package/dist/quicktype-core/language/Php.d.ts +2 -2
  105. package/dist/quicktype-core/language/Php.js +41 -66
  106. package/dist/quicktype-core/language/Pike.d.ts +1 -1
  107. package/dist/quicktype-core/language/Pike.js +17 -18
  108. package/dist/quicktype-core/language/Python.d.ts +8 -8
  109. package/dist/quicktype-core/language/Python.js +64 -63
  110. package/dist/quicktype-core/language/Rust.d.ts +2 -2
  111. package/dist/quicktype-core/language/Rust.js +19 -21
  112. package/dist/quicktype-core/language/Swift.d.ts +7 -7
  113. package/dist/quicktype-core/language/Swift.js +804 -807
  114. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
  115. package/dist/quicktype-core/language/TypeScriptFlow.js +26 -28
  116. package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
  117. package/dist/quicktype-core/language/ruby/index.js +24 -49
  118. package/dist/quicktype-core/language/ruby/keywords.js +0 -1
  119. package/dist/quicktype-core/rewrites/CombineClasses.js +8 -9
  120. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
  121. package/dist/quicktype-core/rewrites/ExpandStrings.js +17 -18
  122. package/dist/quicktype-core/rewrites/FlattenStrings.js +6 -7
  123. package/dist/quicktype-core/rewrites/FlattenUnions.js +8 -9
  124. package/dist/quicktype-core/rewrites/InferMaps.js +10 -11
  125. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +7 -8
  126. package/dist/quicktype-core/rewrites/ResolveIntersections.js +67 -68
  127. package/dist/quicktype-core/support/Acronyms.js +1 -3
  128. package/dist/quicktype-core/support/Chance.js +0 -10
  129. package/dist/quicktype-core/support/Converters.js +0 -1
  130. package/dist/quicktype-core/support/Strings.d.ts +4 -4
  131. package/dist/quicktype-core/support/Strings.js +16 -17
  132. package/dist/quicktype-core/support/Support.d.ts +1 -1
  133. package/dist/quicktype-core/support/Support.js +6 -30
  134. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
  135. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -1
  136. package/dist/quicktype-graphql-input/index.d.ts +1 -1
  137. package/dist/quicktype-graphql-input/index.js +212 -229
  138. package/dist/quicktype-typescript-input/index.js +4 -28
  139. package/package.json +19 -25
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patternForType = exports.patternAttributeProducer = exports.patternTypeAttributeKind = exports.PatternTypeAttributeKind = exports.minMaxLengthForType = exports.minMaxValueForType = exports.minMaxLengthAttributeProducer = exports.minMaxAttributeProducer = exports.minMaxLengthTypeAttributeKind = exports.minMaxTypeAttributeKind = exports.MinMaxConstraintTypeAttributeKind = void 0;
4
3
  const TypeAttributes_1 = require("./TypeAttributes");
5
4
  const Support_1 = require("../support/Support");
6
5
  const Messages_1 = require("../Messages");
7
6
  function checkMinMaxConstraint(minmax) {
8
7
  const [min, max] = minmax;
9
8
  if (typeof min === "number" && typeof max === "number" && min > max) {
10
- return (0, Messages_1.messageError)("MiscInvalidMinMaxConstraint", { min, max });
9
+ return Messages_1.messageError("MiscInvalidMinMaxConstraint", { min, max });
11
10
  }
12
11
  if (min === undefined && max === undefined) {
13
12
  return undefined;
@@ -15,9 +14,6 @@ function checkMinMaxConstraint(minmax) {
15
14
  return minmax;
16
15
  }
17
16
  class MinMaxConstraintTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
18
- _typeKinds;
19
- _minSchemaProperty;
20
- _maxSchemaProperty;
21
17
  constructor(name, _typeKinds, _minSchemaProperty, _maxSchemaProperty) {
22
18
  super(name);
23
19
  this._typeKinds = _typeKinds;
@@ -28,7 +24,7 @@ class MinMaxConstraintTypeAttributeKind extends TypeAttributes_1.TypeAttributeKi
28
24
  return true;
29
25
  }
30
26
  combine(arr) {
31
- (0, Support_1.assert)(arr.length > 0);
27
+ Support_1.assert(arr.length > 0);
32
28
  let [min, max] = arr[0];
33
29
  for (let i = 1; i < arr.length; i++) {
34
30
  const [otherMin, otherMax] = arr[i];
@@ -48,7 +44,7 @@ class MinMaxConstraintTypeAttributeKind extends TypeAttributes_1.TypeAttributeKi
48
44
  return checkMinMaxConstraint([min, max]);
49
45
  }
50
46
  intersect(arr) {
51
- (0, Support_1.assert)(arr.length > 0);
47
+ Support_1.assert(arr.length > 0);
52
48
  let [min, max] = arr[0];
53
49
  for (let i = 1; i < arr.length; i++) {
54
50
  const [otherMin, otherMax] = arr[i];
@@ -137,7 +133,7 @@ class PatternTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
137
133
  return true;
138
134
  }
139
135
  combine(arr) {
140
- (0, Support_1.assert)(arr.length > 0);
136
+ Support_1.assert(arr.length > 0);
141
137
  return arr.map(p => `(${p})`).join("|");
142
138
  }
143
139
  intersect(_arr) {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.descriptionAttributeProducer = exports.propertyDescriptionsTypeAttributeKind = exports.descriptionTypeAttributeKind = exports.addDescriptionToSchema = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const TypeAttributes_1 = require("./TypeAttributes");
6
5
  const JSONSchemaInput_1 = require("../input/JSONSchemaInput");
@@ -15,7 +14,7 @@ class DescriptionTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
15
14
  super("description");
16
15
  }
17
16
  combine(attrs) {
18
- return (0, collection_utils_1.setUnionManyInto)(new Set(), attrs);
17
+ return collection_utils_1.setUnionManyInto(new Set(), attrs);
19
18
  }
20
19
  makeInferred(_) {
21
20
  return undefined;
@@ -24,7 +23,7 @@ class DescriptionTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
24
23
  addDescriptionToSchema(schema, attrs);
25
24
  }
26
25
  stringify(descriptions) {
27
- let result = (0, collection_utils_1.iterableFirst)(descriptions);
26
+ let result = collection_utils_1.iterableFirst(descriptions);
28
27
  if (result === undefined)
29
28
  return undefined;
30
29
  if (result.length > 5 + 3) {
@@ -45,7 +44,7 @@ class PropertyDescriptionsTypeAttributeKind extends TypeAttributes_1.TypeAttribu
45
44
  // FIXME: Implement this with mutable sets
46
45
  const result = new Map();
47
46
  for (const attr of attrs) {
48
- (0, collection_utils_1.mapMergeWithInto)(result, (sa, sb) => (0, collection_utils_1.setUnion)(sa, sb), attr);
47
+ collection_utils_1.mapMergeWithInto(result, (sa, sb) => collection_utils_1.setUnion(sa, sb), attr);
49
48
  }
50
49
  return result;
51
50
  }
@@ -69,7 +68,7 @@ function descriptionAttributeProducer(schema, ref, types) {
69
68
  let propertyDescription = TypeAttributes_1.emptyTypeAttributes;
70
69
  const pathLength = ref.path.length;
71
70
  if (types.has("object") ||
72
- (0, collection_utils_1.setSubtract)(types, ["null"]).size > 1 ||
71
+ collection_utils_1.setSubtract(types, ["null"]).size > 1 ||
73
72
  schema.enum !== undefined ||
74
73
  pathLength < 2 ||
75
74
  !isPropertiesKey(ref.path[pathLength - 2])) {
@@ -79,7 +78,7 @@ function descriptionAttributeProducer(schema, ref, types) {
79
78
  }
80
79
  }
81
80
  if (types.has("object") && typeof schema.properties === "object") {
82
- const propertyDescriptions = (0, collection_utils_1.mapFilterMap)((0, collection_utils_1.mapFromObject)(schema.properties), propSchema => {
81
+ const propertyDescriptions = collection_utils_1.mapFilterMap(collection_utils_1.mapFromObject(schema.properties), propSchema => {
83
82
  if (typeof propSchema === "object") {
84
83
  const desc = propSchema.description;
85
84
  if (typeof desc === "string") {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enumValuesAttributeProducer = exports.enumCaseValues = exports.enumValuesTypeAttributeKind = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const AccessorNames_1 = require("./AccessorNames");
6
5
  const TypeAttributes_1 = require("./TypeAttributes");
@@ -16,8 +15,8 @@ exports.enumValuesTypeAttributeKind = new EnumValuesTypeAttributeKind();
16
15
  function enumCaseValues(e, language) {
17
16
  const enumValues = exports.enumValuesTypeAttributeKind.tryGetInAttributes(e.getAttributes());
18
17
  if (enumValues === undefined)
19
- return (0, collection_utils_1.mapMap)(e.cases.entries(), _ => undefined);
20
- return (0, collection_utils_1.mapMap)(e.cases.entries(), c => (0, AccessorNames_1.lookupKey)(enumValues, c, language));
18
+ return collection_utils_1.mapMap(e.cases.entries(), _ => undefined);
19
+ return collection_utils_1.mapMap(e.cases.entries(), c => AccessorNames_1.lookupKey(enumValues, c, language));
21
20
  }
22
21
  exports.enumCaseValues = enumCaseValues;
23
22
  function enumValuesAttributeProducer(schema, _canonicalRef, _types) {
@@ -26,6 +25,6 @@ function enumValuesAttributeProducer(schema, _canonicalRef, _types) {
26
25
  const maybeEnumValues = schema["qt-enum-values"];
27
26
  if (maybeEnumValues === undefined)
28
27
  return undefined;
29
- return { forType: exports.enumValuesTypeAttributeKind.makeAttributes((0, AccessorNames_1.makeAccessorNames)(maybeEnumValues)) };
28
+ return { forType: exports.enumValuesTypeAttributeKind.makeAttributes(AccessorNames_1.makeAccessorNames(maybeEnumValues)) };
30
29
  }
31
30
  exports.enumValuesAttributeProducer = enumValuesAttributeProducer;
@@ -9,7 +9,7 @@ export declare class StringTypes {
9
9
  static fromCase(s: string, count: number): StringTypes;
10
10
  static fromCases(cases: string[]): StringTypes;
11
11
  constructor(cases: ReadonlyMap<string, number> | undefined, transformations: ReadonlySet<TransformedStringTypeKind>);
12
- get isRestricted(): boolean;
12
+ readonly isRestricted: boolean;
13
13
  union(othersArray: StringTypes[], startIndex: number): StringTypes;
14
14
  intersect(othersArray: StringTypes[], startIndex: number): StringTypes;
15
15
  applyStringTypeMapping(mapping: StringTypeMapping): StringTypes;
@@ -1,14 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inferTransformedStringTypeKindForString = exports.stringTypesTypeAttributeKind = exports.StringTypes = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const TypeAttributes_1 = require("./TypeAttributes");
6
5
  const Support_1 = require("../support/Support");
7
6
  const TypeBuilder_1 = require("../TypeBuilder");
8
7
  class StringTypes {
9
- cases;
10
- transformations;
11
- static unrestricted = new StringTypes(undefined, new Set());
8
+ // undefined means no restrictions
9
+ constructor(cases, transformations) {
10
+ this.cases = cases;
11
+ this.transformations = transformations;
12
+ if (cases === undefined) {
13
+ Support_1.assert(transformations.size === 0, "We can't have an unrestricted string that also allows transformations");
14
+ }
15
+ }
12
16
  static fromCase(s, count) {
13
17
  const caseMap = {};
14
18
  caseMap[s] = count;
@@ -21,14 +25,6 @@ class StringTypes {
21
25
  }
22
26
  return new StringTypes(new Map(cases.map(s => [s, 1])), new Set());
23
27
  }
24
- // undefined means no restrictions
25
- constructor(cases, transformations) {
26
- this.cases = cases;
27
- this.transformations = transformations;
28
- if (cases === undefined) {
29
- (0, Support_1.assert)(transformations.size === 0, "We can't have an unrestricted string that also allows transformations");
30
- }
31
- }
32
28
  get isRestricted() {
33
29
  return this.cases !== undefined;
34
30
  }
@@ -41,8 +37,8 @@ class StringTypes {
41
37
  const other = othersArray[i];
42
38
  if (other.cases === undefined)
43
39
  return other;
44
- (0, collection_utils_1.mapMergeWithInto)(cases, (x, y) => x + y, other.cases);
45
- (0, collection_utils_1.setUnionInto)(transformations, other.transformations);
40
+ collection_utils_1.mapMergeWithInto(cases, (x, y) => x + y, other.cases);
41
+ collection_utils_1.setUnionInto(transformations, other.transformations);
46
42
  }
47
43
  return new StringTypes(cases, transformations);
48
44
  }
@@ -52,14 +48,14 @@ class StringTypes {
52
48
  for (let i = startIndex; i < othersArray.length; i++) {
53
49
  const other = othersArray[i];
54
50
  if (cases === undefined) {
55
- cases = (0, collection_utils_1.definedMap)(other.cases, m => new Map(m));
51
+ cases = collection_utils_1.definedMap(other.cases, m => new Map(m));
56
52
  }
57
53
  else if (other.cases !== undefined) {
58
54
  const thisCases = cases;
59
55
  const otherCases = other.cases;
60
- cases = (0, collection_utils_1.mapMap)((0, collection_utils_1.setIntersect)(thisCases.keys(), new Set(otherCases.keys())).entries(), k => Math.min((0, Support_1.defined)(thisCases.get(k)), (0, Support_1.defined)(otherCases.get(k))));
56
+ cases = collection_utils_1.mapMap(collection_utils_1.setIntersect(thisCases.keys(), new Set(otherCases.keys())).entries(), k => Math.min(Support_1.defined(thisCases.get(k)), Support_1.defined(otherCases.get(k))));
61
57
  }
62
- transformations = (0, collection_utils_1.setIntersect)(transformations, other.transformations);
58
+ transformations = collection_utils_1.setIntersect(transformations, other.transformations);
63
59
  }
64
60
  return new StringTypes(cases, transformations);
65
61
  }
@@ -68,7 +64,7 @@ class StringTypes {
68
64
  return this;
69
65
  const kinds = new Set();
70
66
  for (const kind of this.transformations) {
71
- const mapped = (0, TypeBuilder_1.stringTypeMappingGet)(mapping, kind);
67
+ const mapped = TypeBuilder_1.stringTypeMappingGet(mapping, kind);
72
68
  if (mapped === "string")
73
69
  return StringTypes.unrestricted;
74
70
  kinds.add(mapped);
@@ -78,11 +74,11 @@ class StringTypes {
78
74
  equals(other) {
79
75
  if (!(other instanceof StringTypes))
80
76
  return false;
81
- return (0, collection_utils_1.areEqual)(this.cases, other.cases) && (0, collection_utils_1.areEqual)(this.transformations, other.transformations);
77
+ return collection_utils_1.areEqual(this.cases, other.cases) && collection_utils_1.areEqual(this.transformations, other.transformations);
82
78
  }
83
79
  hashCode() {
84
- let h = (0, collection_utils_1.hashCodeOf)(this.cases);
85
- h = (0, collection_utils_1.addHashCode)(h, (0, collection_utils_1.hashCodeOf)(this.transformations));
80
+ let h = collection_utils_1.hashCodeOf(this.cases);
81
+ h = collection_utils_1.addHashCode(h, collection_utils_1.hashCodeOf(this.transformations));
86
82
  return h;
87
83
  }
88
84
  toString() {
@@ -92,7 +88,7 @@ class StringTypes {
92
88
  parts.push("unrestricted");
93
89
  }
94
90
  else {
95
- const firstKey = (0, collection_utils_1.iterableFirst)(enumCases.keys());
91
+ const firstKey = collection_utils_1.iterableFirst(enumCases.keys());
96
92
  if (firstKey === undefined) {
97
93
  parts.push("enum with no cases");
98
94
  }
@@ -103,6 +99,7 @@ class StringTypes {
103
99
  return parts.concat(Array.from(this.transformations)).join(",");
104
100
  }
105
101
  }
102
+ StringTypes.unrestricted = new StringTypes(undefined, new Set());
106
103
  exports.StringTypes = StringTypes;
107
104
  class StringTypesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
108
105
  constructor() {
@@ -115,11 +112,11 @@ class StringTypesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
115
112
  return st.cases !== undefined && st.cases.size > 0;
116
113
  }
117
114
  combine(arr) {
118
- (0, Support_1.assert)(arr.length > 0);
115
+ Support_1.assert(arr.length > 0);
119
116
  return arr[0].union(arr, 1);
120
117
  }
121
118
  intersect(arr) {
122
- (0, Support_1.assert)(arr.length > 0);
119
+ Support_1.assert(arr.length > 0);
123
120
  return arr[0].intersect(arr, 1);
124
121
  }
125
122
  makeInferred(_) {
@@ -13,7 +13,7 @@ export declare class TypeAttributeKind<T> {
13
13
  }, _t: Type, _attrs: T): void;
14
14
  children(_: T): ReadonlySet<Type>;
15
15
  stringify(_: T): string | undefined;
16
- get inIdentity(): boolean;
16
+ readonly inIdentity: boolean;
17
17
  requiresUniqueIdentity(_: T): boolean;
18
18
  reconstitute<TBuilder extends BaseGraphRewriteBuilder>(_builder: TBuilder, a: T): T;
19
19
  makeAttributes(value: T): TypeAttributes;
@@ -25,9 +25,9 @@ export declare class TypeAttributeKind<T> {
25
25
  equals(other: any): boolean;
26
26
  hashCode(): number;
27
27
  }
28
- export type TypeAttributes = ReadonlyMap<TypeAttributeKind<any>, any>;
28
+ export declare type TypeAttributes = ReadonlyMap<TypeAttributeKind<any>, any>;
29
29
  export declare const emptyTypeAttributes: TypeAttributes;
30
- export type CombinationKind = "union" | "intersect";
30
+ export declare type CombinationKind = "union" | "intersect";
31
31
  export declare function combineTypeAttributes(kind: CombinationKind, attributeArray: TypeAttributes[]): TypeAttributes;
32
32
  export declare function combineTypeAttributes(kind: CombinationKind, a: TypeAttributes, b: TypeAttributes): TypeAttributes;
33
33
  export declare function makeTypeAttributesInferred(attr: TypeAttributes): TypeAttributes;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.increaseTypeAttributesDistance = exports.makeTypeAttributesInferred = exports.combineTypeAttributes = exports.emptyTypeAttributes = exports.TypeAttributeKind = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const Support_1 = require("../support/Support");
6
5
  class TypeAttributeKind {
7
- name;
8
6
  constructor(name) {
9
7
  this.name = name;
10
8
  }
@@ -12,13 +10,13 @@ class TypeAttributeKind {
12
10
  return kind !== "any";
13
11
  }
14
12
  combine(_attrs) {
15
- return (0, Support_1.panic)(`Cannot combine type attribute ${this.name}`);
13
+ return Support_1.panic(`Cannot combine type attribute ${this.name}`);
16
14
  }
17
15
  intersect(attrs) {
18
16
  return this.combine(attrs);
19
17
  }
20
18
  makeInferred(_) {
21
- return (0, Support_1.panic)(`Cannot make type attribute ${this.name} inferred`);
19
+ return Support_1.panic(`Cannot make type attribute ${this.name} inferred`);
22
20
  }
23
21
  increaseDistance(attrs) {
24
22
  return attrs;
@@ -68,7 +66,7 @@ class TypeAttributeKind {
68
66
  return this.modifyInAttributes(a, makeDefault);
69
67
  }
70
68
  removeInAttributes(a) {
71
- return (0, collection_utils_1.mapFilter)(a, (_, k) => k !== this);
69
+ return collection_utils_1.mapFilter(a, (_, k) => k !== this);
72
70
  }
73
71
  equals(other) {
74
72
  if (!(other instanceof TypeAttributeKind)) {
@@ -77,7 +75,7 @@ class TypeAttributeKind {
77
75
  return this.name === other.name;
78
76
  }
79
77
  hashCode() {
80
- return (0, collection_utils_1.hashString)(this.name);
78
+ return collection_utils_1.hashString(this.name);
81
79
  }
82
80
  }
83
81
  exports.TypeAttributeKind = TypeAttributeKind;
@@ -90,13 +88,13 @@ function combineTypeAttributes(combinationKind, firstOrArray, second) {
90
88
  }
91
89
  else {
92
90
  if (second === undefined) {
93
- return (0, Support_1.panic)("Must have on array or two attributes");
91
+ return Support_1.panic("Must have on array or two attributes");
94
92
  }
95
93
  attributeArray = [firstOrArray, second];
96
94
  }
97
- const attributesByKind = (0, collection_utils_1.mapTranspose)(attributeArray);
95
+ const attributesByKind = collection_utils_1.mapTranspose(attributeArray);
98
96
  function combine(attrs, kind) {
99
- (0, Support_1.assert)(attrs.length > 0, "Cannot combine zero type attributes");
97
+ Support_1.assert(attrs.length > 0, "Cannot combine zero type attributes");
100
98
  if (attrs.length === 1)
101
99
  return attrs[0];
102
100
  if (union) {
@@ -106,14 +104,14 @@ function combineTypeAttributes(combinationKind, firstOrArray, second) {
106
104
  return kind.intersect(attrs);
107
105
  }
108
106
  }
109
- return (0, collection_utils_1.mapFilterMap)(attributesByKind, combine);
107
+ return collection_utils_1.mapFilterMap(attributesByKind, combine);
110
108
  }
111
109
  exports.combineTypeAttributes = combineTypeAttributes;
112
110
  function makeTypeAttributesInferred(attr) {
113
- return (0, collection_utils_1.mapFilterMap)(attr, (value, kind) => kind.makeInferred(value));
111
+ return collection_utils_1.mapFilterMap(attr, (value, kind) => kind.makeInferred(value));
114
112
  }
115
113
  exports.makeTypeAttributesInferred = makeTypeAttributesInferred;
116
114
  function increaseTypeAttributesDistance(attr) {
117
- return (0, collection_utils_1.mapFilterMap)(attr, (value, kind) => kind.increaseDistance(value));
115
+ return collection_utils_1.mapFilterMap(attr, (value, kind) => kind.increaseDistance(value));
118
116
  }
119
117
  exports.increaseTypeAttributesDistance = increaseTypeAttributesDistance;
@@ -1,16 +1,16 @@
1
1
  import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
2
2
  export declare function initTypeNames(): void;
3
- export type NameOrNames = string | TypeNames;
3
+ export declare type NameOrNames = string | TypeNames;
4
4
  export declare const tooManyNamesThreshold = 1000;
5
5
  export declare abstract class TypeNames {
6
6
  readonly distance: number;
7
7
  static makeWithDistance(names: ReadonlySet<string>, alternativeNames: ReadonlySet<string> | undefined, distance: number): TypeNames;
8
8
  static make(names: ReadonlySet<string>, alternativeNames: ReadonlySet<string> | undefined, areInferred: boolean): TypeNames;
9
9
  constructor(distance: number);
10
- get areInferred(): boolean;
11
- abstract get names(): ReadonlySet<string>;
12
- abstract get combinedName(): string;
13
- abstract get proposedNames(): ReadonlySet<string>;
10
+ readonly areInferred: boolean;
11
+ abstract readonly names: ReadonlySet<string>;
12
+ abstract readonly combinedName: string;
13
+ abstract readonly proposedNames: ReadonlySet<string>;
14
14
  abstract add(namesArray: TypeNames[], startIndex?: number): TypeNames;
15
15
  abstract clearInferred(): TypeNames;
16
16
  abstract makeInferred(): TypeNames;
@@ -23,8 +23,8 @@ export declare class RegularTypeNames extends TypeNames {
23
23
  constructor(names: ReadonlySet<string>, _alternativeNames: ReadonlySet<string> | undefined, distance: number);
24
24
  add(namesArray: TypeNames[], startIndex?: number): TypeNames;
25
25
  clearInferred(): TypeNames;
26
- get combinedName(): string;
27
- get proposedNames(): ReadonlySet<string>;
26
+ readonly combinedName: string;
27
+ readonly proposedNames: ReadonlySet<string>;
28
28
  makeInferred(): TypeNames;
29
29
  singularize(): TypeNames;
30
30
  toString(): string;
@@ -32,8 +32,8 @@ export declare class RegularTypeNames extends TypeNames {
32
32
  export declare class TooManyTypeNames extends TypeNames {
33
33
  readonly names: ReadonlySet<string>;
34
34
  constructor(distance: number, name?: string);
35
- get combinedName(): string;
36
- get proposedNames(): ReadonlySet<string>;
35
+ readonly combinedName: string;
36
+ readonly proposedNames: ReadonlySet<string>;
37
37
  add(namesArray: TypeNames[], startIndex?: number): TypeNames;
38
38
  clearInferred(): TypeNames;
39
39
  makeInferred(): TypeNames;
@@ -1,30 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.makeNamesTypeAttributes = exports.singularizeTypeNames = exports.modifyTypeNames = exports.namesTypeAttributeKind = exports.TooManyTypeNames = exports.RegularTypeNames = exports.TypeNames = exports.tooManyNamesThreshold = exports.initTypeNames = void 0;
27
- const pluralize = __importStar(require("pluralize"));
3
+ const pluralize = require("pluralize");
28
4
  const collection_utils_1 = require("collection-utils");
29
5
  const Support_1 = require("../support/Support");
30
6
  const TypeAttributes_1 = require("./TypeAttributes");
@@ -52,23 +28,23 @@ function makeRandomName() {
52
28
  // the names "aaa" and "aaaa" we have the common prefix "aaa" and the
53
29
  // common suffix "aaa", so we will produce the combined name "aaaaaa".
54
30
  function combineNames(names) {
55
- let originalFirst = (0, collection_utils_1.iterableFirst)(names);
31
+ let originalFirst = collection_utils_1.iterableFirst(names);
56
32
  if (originalFirst === undefined) {
57
- return (0, Support_1.panic)("Named type has no names");
33
+ return Support_1.panic("Named type has no names");
58
34
  }
59
35
  if (names.size === 1) {
60
36
  return originalFirst;
61
37
  }
62
- const namesSet = (0, collection_utils_1.setMap)(names, s => (0, Strings_1.splitIntoWords)(s)
38
+ const namesSet = collection_utils_1.setMap(names, s => Strings_1.splitIntoWords(s)
63
39
  .map(w => w.word.toLowerCase())
64
40
  .join("_"));
65
- const first = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(namesSet));
41
+ const first = Support_1.defined(collection_utils_1.iterableFirst(namesSet));
66
42
  if (namesSet.size === 1) {
67
43
  return first;
68
44
  }
69
45
  let prefixLength = first.length;
70
46
  let suffixLength = first.length;
71
- for (const n of (0, collection_utils_1.iterableSkip)(namesSet, 1)) {
47
+ for (const n of collection_utils_1.iterableSkip(namesSet, 1)) {
72
48
  prefixLength = Math.min(prefixLength, n.length);
73
49
  for (let i = 0; i < prefixLength; i++) {
74
50
  if (first[i] !== n[i]) {
@@ -94,7 +70,9 @@ function combineNames(names) {
94
70
  }
95
71
  exports.tooManyNamesThreshold = 1000;
96
72
  class TypeNames {
97
- distance;
73
+ constructor(distance) {
74
+ this.distance = distance;
75
+ }
98
76
  static makeWithDistance(names, alternativeNames, distance) {
99
77
  if (names.size >= exports.tooManyNamesThreshold) {
100
78
  return new TooManyTypeNames(distance);
@@ -107,17 +85,12 @@ class TypeNames {
107
85
  static make(names, alternativeNames, areInferred) {
108
86
  return TypeNames.makeWithDistance(names, alternativeNames, areInferred ? 1 : 0);
109
87
  }
110
- constructor(distance) {
111
- this.distance = distance;
112
- }
113
88
  get areInferred() {
114
89
  return this.distance > 0;
115
90
  }
116
91
  }
117
92
  exports.TypeNames = TypeNames;
118
93
  class RegularTypeNames extends TypeNames {
119
- names;
120
- _alternativeNames;
121
94
  constructor(names, _alternativeNames, distance) {
122
95
  super(distance);
123
96
  this.names = names;
@@ -126,19 +99,19 @@ class RegularTypeNames extends TypeNames {
126
99
  add(namesArray, startIndex = 0) {
127
100
  let newNames = new Set(this.names);
128
101
  let newDistance = this.distance;
129
- let newAlternativeNames = (0, collection_utils_1.definedMap)(this._alternativeNames, s => new Set(s));
102
+ let newAlternativeNames = collection_utils_1.definedMap(this._alternativeNames, s => new Set(s));
130
103
  for (let i = startIndex; i < namesArray.length; i++) {
131
104
  const other = namesArray[i];
132
105
  if (other instanceof RegularTypeNames && other._alternativeNames !== undefined) {
133
106
  if (newAlternativeNames === undefined) {
134
107
  newAlternativeNames = new Set();
135
108
  }
136
- (0, collection_utils_1.setUnionInto)(newAlternativeNames, other._alternativeNames);
109
+ collection_utils_1.setUnionInto(newAlternativeNames, other._alternativeNames);
137
110
  }
138
111
  if (other.distance > newDistance)
139
112
  continue;
140
113
  if (!(other instanceof RegularTypeNames)) {
141
- (0, Support_1.assert)(other instanceof TooManyTypeNames, "Unknown TypeNames instance");
114
+ Support_1.assert(other instanceof TooManyTypeNames, "Unknown TypeNames instance");
142
115
  // The other one is at most our distance, so let it sort it out
143
116
  return other.add(namesArray, i + 1);
144
117
  }
@@ -146,12 +119,12 @@ class RegularTypeNames extends TypeNames {
146
119
  // The other one is closer, so take its names
147
120
  newNames = new Set(other.names);
148
121
  newDistance = other.distance;
149
- newAlternativeNames = (0, collection_utils_1.definedMap)(other._alternativeNames, s => new Set(s));
122
+ newAlternativeNames = collection_utils_1.definedMap(other._alternativeNames, s => new Set(s));
150
123
  }
151
124
  else {
152
125
  // Same distance, merge them
153
- (0, Support_1.assert)(other.distance === newDistance, "This should be the only case left");
154
- (0, collection_utils_1.setUnionInto)(newNames, other.names);
126
+ Support_1.assert(other.distance === newDistance, "This should be the only case left");
127
+ collection_utils_1.setUnionInto(newNames, other.names);
155
128
  }
156
129
  }
157
130
  return TypeNames.makeWithDistance(newNames, newAlternativeNames, newDistance);
@@ -168,14 +141,14 @@ class RegularTypeNames extends TypeNames {
168
141
  if (this._alternativeNames === undefined) {
169
142
  return set;
170
143
  }
171
- (0, collection_utils_1.setUnionInto)(set, this._alternativeNames);
144
+ collection_utils_1.setUnionInto(set, this._alternativeNames);
172
145
  return set;
173
146
  }
174
147
  makeInferred() {
175
148
  return TypeNames.makeWithDistance(this.names, this._alternativeNames, this.distance + 1);
176
149
  }
177
150
  singularize() {
178
- return TypeNames.makeWithDistance((0, collection_utils_1.setMap)(this.names, pluralize.singular), (0, collection_utils_1.definedMap)(this._alternativeNames, an => (0, collection_utils_1.setMap)(an, pluralize.singular)), this.distance + 1);
151
+ return TypeNames.makeWithDistance(collection_utils_1.setMap(this.names, pluralize.singular), collection_utils_1.definedMap(this._alternativeNames, an => collection_utils_1.setMap(an, pluralize.singular)), this.distance + 1);
179
152
  }
180
153
  toString() {
181
154
  const inferred = this.areInferred ? `distance ${this.distance}` : "given";
@@ -188,7 +161,6 @@ class RegularTypeNames extends TypeNames {
188
161
  }
189
162
  exports.RegularTypeNames = RegularTypeNames;
190
163
  class TooManyTypeNames extends TypeNames {
191
- names;
192
164
  constructor(distance, name) {
193
165
  super(distance);
194
166
  if (name === undefined) {
@@ -197,7 +169,7 @@ class TooManyTypeNames extends TypeNames {
197
169
  this.names = new Set([name]);
198
170
  }
199
171
  get combinedName() {
200
- return (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(this.names));
172
+ return Support_1.defined(collection_utils_1.iterableFirst(this.names));
201
173
  }
202
174
  get proposedNames() {
203
175
  return this.names;
@@ -220,7 +192,7 @@ class TooManyTypeNames extends TypeNames {
220
192
  return TypeNames.makeWithDistance(new Set(), new Set(), this.distance);
221
193
  }
222
194
  makeInferred() {
223
- return new TooManyTypeNames(this.distance + 1, (0, collection_utils_1.iterableFirst)(this.names));
195
+ return new TooManyTypeNames(this.distance + 1, collection_utils_1.iterableFirst(this.names));
224
196
  }
225
197
  singularize() {
226
198
  return this;
@@ -235,7 +207,7 @@ class TypeNamesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
235
207
  super("names");
236
208
  }
237
209
  combine(namesArray) {
238
- (0, Support_1.assert)(namesArray.length > 0, "Can't combine zero type names");
210
+ Support_1.assert(namesArray.length > 0, "Can't combine zero type names");
239
211
  return namesArray[0].add(namesArray, 1);
240
212
  }
241
213
  makeInferred(tn) {
@@ -264,7 +236,7 @@ exports.singularizeTypeNames = singularizeTypeNames;
264
236
  function makeNamesTypeAttributes(nameOrNames, areNamesInferred) {
265
237
  let typeNames;
266
238
  if (typeof nameOrNames === "string") {
267
- typeNames = TypeNames.make(new Set([nameOrNames]), new Set(), (0, Support_1.defined)(areNamesInferred));
239
+ typeNames = TypeNames.make(new Set([nameOrNames]), new Set(), Support_1.defined(areNamesInferred));
268
240
  }
269
241
  else {
270
242
  typeNames = nameOrNames;
@@ -1,7 +1,7 @@
1
1
  import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
2
2
  import { JSONSchemaType, JSONSchemaAttributes, Ref } from "../input/JSONSchemaInput";
3
3
  import { JSONSchema } from "../input/JSONSchemaStore";
4
- type URIAttributes = [ReadonlySet<string>, ReadonlySet<string>];
4
+ declare type URIAttributes = [ReadonlySet<string>, ReadonlySet<string>];
5
5
  export declare const uriTypeAttributeKind: TypeAttributeKind<URIAttributes>;
6
6
  export declare function uriInferenceAttributesProducer(s: string): TypeAttributes;
7
7
  export declare function uriSchemaAttributesProducer(schema: JSONSchema, _ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.uriSchemaAttributesProducer = exports.uriInferenceAttributesProducer = exports.uriTypeAttributeKind = void 0;
7
- const urijs_1 = __importDefault(require("urijs"));
3
+ const URI = require("urijs");
8
4
  const TypeAttributes_1 = require("./TypeAttributes");
9
5
  const collection_utils_1 = require("collection-utils");
10
6
  const Support_1 = require("../support/Support");
@@ -20,7 +16,7 @@ class URITypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
20
16
  combine(attrs) {
21
17
  const protocolSets = attrs.map(a => a[0]);
22
18
  const extensionSets = attrs.map(a => a[1]);
23
- return [(0, collection_utils_1.setUnionManyInto)(new Set(), protocolSets), (0, collection_utils_1.setUnionManyInto)(new Set(), extensionSets)];
19
+ return [collection_utils_1.setUnionManyInto(new Set(), protocolSets), collection_utils_1.setUnionManyInto(new Set(), extensionSets)];
24
20
  }
25
21
  makeInferred(_) {
26
22
  return undefined;
@@ -47,12 +43,12 @@ function pathExtension(path) {
47
43
  }
48
44
  function uriInferenceAttributesProducer(s) {
49
45
  try {
50
- const uri = (0, urijs_1.default)(s);
46
+ const uri = URI(s);
51
47
  const extension = pathExtension(uri.path());
52
48
  const extensions = extension === undefined ? [] : [extension.toLowerCase()];
53
49
  return exports.uriTypeAttributeKind.makeAttributes([new Set([uri.protocol().toLowerCase()]), new Set(extensions)]);
54
50
  }
55
- catch {
51
+ catch (_a) {
56
52
  return TypeAttributes_1.emptyTypeAttributes;
57
53
  }
58
54
  }
@@ -65,7 +61,7 @@ function uriSchemaAttributesProducer(schema, _ref, types) {
65
61
  let protocols;
66
62
  const maybeProtocols = schema[protocolsSchemaProperty];
67
63
  if (maybeProtocols !== undefined) {
68
- protocols = new Set((0, Support_1.checkArray)(maybeProtocols, Support_1.checkString));
64
+ protocols = new Set(Support_1.checkArray(maybeProtocols, Support_1.checkString));
69
65
  }
70
66
  else {
71
67
  protocols = new Set();
@@ -73,7 +69,7 @@ function uriSchemaAttributesProducer(schema, _ref, types) {
73
69
  let extensions;
74
70
  const maybeExtensions = schema[extensionsSchemaProperty];
75
71
  if (maybeExtensions !== undefined) {
76
- extensions = new Set((0, Support_1.checkArray)(maybeExtensions, Support_1.checkString));
72
+ extensions = new Set(Support_1.checkArray(maybeExtensions, Support_1.checkString));
77
73
  }
78
74
  else {
79
75
  extensions = new Set();