quicktype 17.0.1 → 17.0.2

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