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,18 +1,26 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FetchingJSONSchemaStore = void 0;
4
11
  const JSONSchemaStore_1 = require("./JSONSchemaStore");
5
12
  const __1 = require("..");
6
13
  const NodeIO_1 = require("./io/NodeIO");
7
14
  class FetchingJSONSchemaStore extends JSONSchemaStore_1.JSONSchemaStore {
8
- _httpHeaders;
9
15
  constructor(_httpHeaders) {
10
16
  super();
11
17
  this._httpHeaders = _httpHeaders;
12
18
  }
13
- async fetch(address) {
14
- // console.log(`Fetching ${address}`);
15
- return (0, __1.parseJSON)(await (0, NodeIO_1.readFromFileOrURL)(address, this._httpHeaders), "JSON Schema", address);
19
+ fetch(address) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ // console.log(`Fetching ${address}`);
22
+ return __1.parseJSON(yield NodeIO_1.readFromFileOrURL(address, this._httpHeaders), "JSON Schema", address);
23
+ });
16
24
  }
17
25
  }
18
26
  exports.FetchingJSONSchemaStore = FetchingJSONSchemaStore;
@@ -3,8 +3,8 @@ import { TypeBuilder } from "../TypeBuilder";
3
3
  import { UnionAccumulator } from "../UnionBuilder";
4
4
  import { TypeAttributes } from "../attributes/TypeAttributes";
5
5
  import { TypeRef } from "../TypeGraph";
6
- export type NestedValueArray = any;
7
- export type Accumulator = UnionAccumulator<NestedValueArray, NestedValueArray>;
6
+ export declare type NestedValueArray = any;
7
+ export declare type Accumulator = UnionAccumulator<NestedValueArray, NestedValueArray>;
8
8
  export declare class TypeInference {
9
9
  private readonly _cjson;
10
10
  private readonly _typeBuilder;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeInference = void 0;
4
3
  const CompressedJSON_1 = require("./CompressedJSON");
5
4
  const Support_1 = require("../support/Support");
6
5
  const UnionBuilder_1 = require("../UnionBuilder");
@@ -31,8 +30,6 @@ function forEachValueInNestedValueArray(va, f) {
31
30
  });
32
31
  }
33
32
  class InferenceUnionBuilder extends UnionBuilder_1.UnionBuilder {
34
- _typeInference;
35
- _fixed;
36
33
  constructor(typeBuilder, _typeInference, _fixed) {
37
34
  super(typeBuilder);
38
35
  this._typeInference = _typeInference;
@@ -49,11 +46,6 @@ function canBeEnumCase(_s) {
49
46
  return true;
50
47
  }
51
48
  class TypeInference {
52
- _cjson;
53
- _typeBuilder;
54
- _inferMaps;
55
- _inferEnums;
56
- _refIntersections;
57
49
  constructor(_cjson, _typeBuilder, _inferMaps, _inferEnums) {
58
50
  this._cjson = _cjson;
59
51
  this._typeBuilder = _typeBuilder;
@@ -62,7 +54,7 @@ class TypeInference {
62
54
  }
63
55
  addValuesToAccumulator(valueArray, accumulator) {
64
56
  forEachValueInNestedValueArray(valueArray, value => {
65
- const t = (0, CompressedJSON_1.valueTag)(value);
57
+ const t = CompressedJSON_1.valueTag(value);
66
58
  switch (t) {
67
59
  case CompressedJSON_1.Tag.Null:
68
60
  accumulator.addPrimitive("null", TypeAttributes_1.emptyTypeAttributes);
@@ -107,19 +99,19 @@ class TypeInference {
107
99
  }
108
100
  case CompressedJSON_1.Tag.TransformedString: {
109
101
  const s = this._cjson.getStringForValue(value);
110
- const kind = (0, StringTypes_1.inferTransformedStringTypeKindForString)(s, this._cjson.dateTimeRecognizer);
102
+ const kind = StringTypes_1.inferTransformedStringTypeKindForString(s, this._cjson.dateTimeRecognizer);
111
103
  if (kind === undefined) {
112
- return (0, Support_1.panic)("TransformedString does not have a kind");
104
+ return Support_1.panic("TransformedString does not have a kind");
113
105
  }
114
- const producer = (0, Support_1.defined)(Type_1.transformedStringTypeTargetTypeKindsMap.get(kind)).attributesProducer;
106
+ const producer = Support_1.defined(Type_1.transformedStringTypeTargetTypeKindsMap.get(kind)).attributesProducer;
115
107
  if (producer === undefined) {
116
- return (0, Support_1.panic)("TransformedString does not have attribute producer");
108
+ return Support_1.panic("TransformedString does not have attribute producer");
117
109
  }
118
110
  accumulator.addStringType("string", producer(s), new StringTypes_1.StringTypes(new Map(), new Set([kind])));
119
111
  break;
120
112
  }
121
113
  default:
122
- return (0, Support_1.assertNever)(t);
114
+ return Support_1.assertNever(t);
123
115
  }
124
116
  });
125
117
  }
@@ -129,25 +121,25 @@ class TypeInference {
129
121
  }
130
122
  resolveRef(ref, topLevel) {
131
123
  if (!ref.startsWith("#/")) {
132
- return (0, Messages_1.messageError)("InferenceJSONReferenceNotRooted", { reference: ref });
124
+ return Messages_1.messageError("InferenceJSONReferenceNotRooted", { reference: ref });
133
125
  }
134
126
  const parts = ref.split("/").slice(1);
135
127
  const graph = this._typeBuilder.typeGraph;
136
128
  let tref = topLevel;
137
129
  for (const part of parts) {
138
- let t = (0, TypeGraph_1.derefTypeRef)(tref, graph);
130
+ let t = TypeGraph_1.derefTypeRef(tref, graph);
139
131
  if (t instanceof Type_1.UnionType) {
140
- const nullable = (0, TypeUtils_1.nullableFromUnion)(t);
132
+ const nullable = TypeUtils_1.nullableFromUnion(t);
141
133
  if (nullable === null) {
142
134
  // FIXME: handle unions
143
- return (0, Messages_1.messageError)("InferenceJSONReferenceToUnion", { reference: ref });
135
+ return Messages_1.messageError("InferenceJSONReferenceToUnion", { reference: ref });
144
136
  }
145
137
  t = nullable;
146
138
  }
147
139
  if (t instanceof Type_1.ClassType) {
148
140
  const cp = t.getProperties().get(part);
149
141
  if (cp === undefined) {
150
- return (0, Messages_1.messageError)("InferenceJSONReferenceWrongProperty", { reference: ref });
142
+ return Messages_1.messageError("InferenceJSONReferenceWrongProperty", { reference: ref });
151
143
  }
152
144
  tref = cp.typeRef;
153
145
  }
@@ -156,24 +148,24 @@ class TypeInference {
156
148
  }
157
149
  else if (t instanceof Type_1.ArrayType) {
158
150
  if (part.match("^[0-9]+$") === null) {
159
- return (0, Messages_1.messageError)("InferenceJSONReferenceInvalidArrayIndex", { reference: ref });
151
+ return Messages_1.messageError("InferenceJSONReferenceInvalidArrayIndex", { reference: ref });
160
152
  }
161
153
  tref = t.items.typeRef;
162
154
  }
163
155
  else {
164
- return (0, Messages_1.messageError)("InferenceJSONReferenceWrongProperty", { reference: ref });
156
+ return Messages_1.messageError("InferenceJSONReferenceWrongProperty", { reference: ref });
165
157
  }
166
158
  }
167
159
  return tref;
168
160
  }
169
161
  inferTopLevelType(typeAttributes, valueArray, fixed) {
170
- (0, Support_1.assert)(this._refIntersections === undefined, "Didn't reset ref intersections - nested invocations?");
162
+ Support_1.assert(this._refIntersections === undefined, "Didn't reset ref intersections - nested invocations?");
171
163
  if (this._cjson.handleRefs) {
172
164
  this._refIntersections = [];
173
165
  }
174
166
  const topLevel = this.inferType(typeAttributes, valueArray, fixed);
175
167
  if (this._cjson.handleRefs) {
176
- for (const [tref, refs] of (0, Support_1.defined)(this._refIntersections)) {
168
+ for (const [tref, refs] of Support_1.defined(this._refIntersections)) {
177
169
  const resolved = refs.map(r => this.resolveRef(r, topLevel));
178
170
  this._typeBuilder.setSetOperationMembers(tref, new Set(resolved));
179
171
  }
@@ -206,11 +198,11 @@ class TypeInference {
206
198
  });
207
199
  if (this._cjson.handleRefs && propertyNames.length === 1 && propertyNames[0] === "$ref") {
208
200
  const values = propertyValues["$ref"];
209
- if (values.every(v => (0, CompressedJSON_1.valueTag)(v) === CompressedJSON_1.Tag.InternedString)) {
201
+ if (values.every(v => CompressedJSON_1.valueTag(v) === CompressedJSON_1.Tag.InternedString)) {
210
202
  const allRefs = values.map(v => this._cjson.getStringForValue(v));
211
203
  // FIXME: Add is-ref attribute
212
204
  const tref = this._typeBuilder.getUniqueIntersectionType(typeAttributes, undefined);
213
- (0, Support_1.defined)(this._refIntersections).push([tref, allRefs]);
205
+ Support_1.defined(this._refIntersections).push([tref, allRefs]);
214
206
  return tref;
215
207
  }
216
208
  }
@@ -42,7 +42,7 @@ export declare class InputData {
42
42
  addSourceSync<T>(kind: string, source: T, makeInput: () => Input<T>): void;
43
43
  addTypes(ctx: RunContext, typeBuilder: TypeBuilder, inferMaps: boolean, inferEnums: boolean, fixedTopLevels: boolean): Promise<void>;
44
44
  addTypesSync(ctx: RunContext, typeBuilder: TypeBuilder, inferMaps: boolean, inferEnums: boolean, fixedTopLevels: boolean): void;
45
- get needIR(): boolean;
46
- get needSchemaProcessing(): boolean;
45
+ readonly needIR: boolean;
46
+ readonly needSchemaProcessing: boolean;
47
47
  singleStringSchemaSource(): string | undefined;
48
48
  }
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InputData = exports.jsonInputForTargetLanguage = exports.JSONInput = void 0;
4
11
  const collection_utils_1 = require("collection-utils");
5
12
  const CompressedJSON_1 = require("./CompressedJSON");
6
13
  const Support_1 = require("../support/Support");
@@ -10,21 +17,20 @@ const Description_1 = require("../attributes/Description");
10
17
  const Inference_1 = require("./Inference");
11
18
  const All_1 = require("../language/All");
12
19
  function messageParseError(name, description, e) {
13
- return (0, Messages_1.messageError)("MiscJSONParseError", {
14
- description: (0, collection_utils_1.withDefault)(description, "input"),
20
+ return Messages_1.messageError("MiscJSONParseError", {
21
+ description: collection_utils_1.withDefault(description, "input"),
15
22
  address: name,
16
- message: (0, Support_1.errorMessage)(e)
23
+ message: Support_1.errorMessage(e)
17
24
  });
18
25
  }
19
26
  class JSONInput {
20
- _compressedJSON;
21
- kind = "json";
22
- needIR = true;
23
- needSchemaProcessing = false;
24
- _topLevels = new Map();
25
27
  /* tslint:disable:no-unused-variable */
26
28
  constructor(_compressedJSON) {
27
29
  this._compressedJSON = _compressedJSON;
30
+ this.kind = "json";
31
+ this.needIR = true;
32
+ this.needSchemaProcessing = false;
33
+ this._topLevels = new Map();
28
34
  }
29
35
  addSample(topLevelName, sample) {
30
36
  let topLevel = this._topLevels.get(topLevelName);
@@ -37,7 +43,7 @@ class JSONInput {
37
43
  setDescription(topLevelName, description) {
38
44
  let topLevel = this._topLevels.get(topLevelName);
39
45
  if (topLevel === undefined) {
40
- return (0, Support_1.panic)("Trying to set description for a top-level that doesn't exist");
46
+ return Support_1.panic("Trying to set description for a top-level that doesn't exist");
41
47
  }
42
48
  topLevel.description = description;
43
49
  }
@@ -49,15 +55,17 @@ class JSONInput {
49
55
  }
50
56
  }
51
57
  }
52
- async addSource(source) {
53
- const { name, samples, description } = source;
54
- try {
55
- const values = await (0, collection_utils_1.arrayMapSync)(samples, async (s) => await this._compressedJSON.parse(s));
56
- this.addSamples(name, values, description);
57
- }
58
- catch (e) {
59
- return messageParseError(name, description, e);
60
- }
58
+ addSource(source) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const { name, samples, description } = source;
61
+ try {
62
+ const values = yield collection_utils_1.arrayMapSync(samples, (s) => __awaiter(this, void 0, void 0, function* () { return yield this._compressedJSON.parse(s); }));
63
+ this.addSamples(name, values, description);
64
+ }
65
+ catch (e) {
66
+ return messageParseError(name, description, e);
67
+ }
68
+ });
61
69
  }
62
70
  addSourceSync(source) {
63
71
  const { name, samples, description } = source;
@@ -72,13 +80,15 @@ class JSONInput {
72
80
  singleStringSchemaSource() {
73
81
  return undefined;
74
82
  }
75
- async addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
76
- return this.addTypesSync(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels);
83
+ addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ return this.addTypesSync(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels);
86
+ });
77
87
  }
78
88
  addTypesSync(_ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
79
89
  const inference = new Inference_1.TypeInference(this._compressedJSON, typeBuilder, inferMaps, inferEnums);
80
90
  for (const [name, { samples, description }] of this._topLevels) {
81
- const tref = inference.inferTopLevelType((0, TypeNames_1.makeNamesTypeAttributes)(name, false), samples, fixedTopLevels);
91
+ const tref = inference.inferTopLevelType(TypeNames_1.makeNamesTypeAttributes(name, false), samples, fixedTopLevels);
82
92
  typeBuilder.addTopLevel(name, tref);
83
93
  if (description !== undefined) {
84
94
  const attributes = Description_1.descriptionTypeAttributeKind.makeAttributes(new Set([description]));
@@ -90,38 +100,44 @@ class JSONInput {
90
100
  exports.JSONInput = JSONInput;
91
101
  function jsonInputForTargetLanguage(targetLanguage, languages, handleJSONRefs = false) {
92
102
  if (typeof targetLanguage === "string") {
93
- targetLanguage = (0, Support_1.defined)((0, All_1.languageNamed)(targetLanguage, languages));
103
+ targetLanguage = Support_1.defined(All_1.languageNamed(targetLanguage, languages));
94
104
  }
95
105
  const compressedJSON = new CompressedJSON_1.CompressedJSONFromString(targetLanguage.dateTimeRecognizer, handleJSONRefs);
96
106
  return new JSONInput(compressedJSON);
97
107
  }
98
108
  exports.jsonInputForTargetLanguage = jsonInputForTargetLanguage;
99
109
  class InputData {
100
- // FIXME: Make into a Map, indexed by kind.
101
- _inputs = new Set();
110
+ constructor() {
111
+ // FIXME: Make into a Map, indexed by kind.
112
+ this._inputs = new Set();
113
+ }
102
114
  addInput(input) {
103
115
  this._inputs = this._inputs.add(input);
104
116
  }
105
117
  getOrAddInput(kind, makeInput) {
106
- let input = (0, collection_utils_1.iterableFind)(this._inputs, i => i.kind === kind);
118
+ let input = collection_utils_1.iterableFind(this._inputs, i => i.kind === kind);
107
119
  if (input === undefined) {
108
120
  input = makeInput();
109
121
  this.addInput(input);
110
122
  }
111
123
  return input;
112
124
  }
113
- async addSource(kind, source, makeInput) {
114
- const input = this.getOrAddInput(kind, makeInput);
115
- await input.addSource(source);
125
+ addSource(kind, source, makeInput) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ const input = this.getOrAddInput(kind, makeInput);
128
+ yield input.addSource(source);
129
+ });
116
130
  }
117
131
  addSourceSync(kind, source, makeInput) {
118
132
  const input = this.getOrAddInput(kind, makeInput);
119
133
  input.addSourceSync(source);
120
134
  }
121
- async addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
122
- for (const input of this._inputs) {
123
- await input.addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels);
124
- }
135
+ addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ for (const input of this._inputs) {
138
+ yield input.addTypes(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels);
139
+ }
140
+ });
125
141
  }
126
142
  addTypesSync(ctx, typeBuilder, inferMaps, inferEnums, fixedTopLevels) {
127
143
  for (const input of this._inputs) {
@@ -129,17 +145,17 @@ class InputData {
129
145
  }
130
146
  }
131
147
  get needIR() {
132
- return (0, collection_utils_1.iterableSome)(this._inputs, i => i.needIR);
148
+ return collection_utils_1.iterableSome(this._inputs, i => i.needIR);
133
149
  }
134
150
  get needSchemaProcessing() {
135
- return (0, collection_utils_1.iterableSome)(this._inputs, i => i.needSchemaProcessing);
151
+ return collection_utils_1.iterableSome(this._inputs, i => i.needSchemaProcessing);
136
152
  }
137
153
  singleStringSchemaSource() {
138
- const schemaStrings = (0, collection_utils_1.setFilterMap)(this._inputs, i => i.singleStringSchemaSource());
154
+ const schemaStrings = collection_utils_1.setFilterMap(this._inputs, i => i.singleStringSchemaSource());
139
155
  if (schemaStrings.size > 1) {
140
- return (0, Support_1.panic)("We have more than one input with a string schema source");
156
+ return Support_1.panic("We have more than one input with a string schema source");
141
157
  }
142
- return (0, collection_utils_1.iterableFirst)(schemaStrings);
158
+ return collection_utils_1.iterableFirst(schemaStrings);
143
159
  }
144
160
  }
145
161
  exports.InputData = InputData;
@@ -1,4 +1,4 @@
1
- import URI from "urijs";
1
+ import * as URI from "urijs";
2
2
  import { TypeBuilder } from "../TypeBuilder";
3
3
  import { TypeAttributes } from "../attributes/TypeAttributes";
4
4
  import { JSONSchema, JSONSchemaStore } from "./JSONSchemaStore";
@@ -10,7 +10,7 @@ export declare enum PathElementKind {
10
10
  Type = 2,
11
11
  Object = 3
12
12
  }
13
- export type PathElement = {
13
+ export declare type PathElement = {
14
14
  kind: PathElementKind.Root;
15
15
  } | {
16
16
  kind: PathElementKind.KeyOrIndex;
@@ -29,16 +29,16 @@ export declare class Ref {
29
29
  static parse(ref: string): Ref;
30
30
  addressURI: URI | undefined;
31
31
  constructor(addressURI: URI | undefined, path: ReadonlyArray<PathElement>);
32
- get hasAddress(): boolean;
33
- get address(): string;
34
- get isRoot(): boolean;
32
+ readonly hasAddress: boolean;
33
+ readonly address: string;
34
+ readonly isRoot: boolean;
35
35
  private pushElement;
36
36
  push(...keys: string[]): Ref;
37
37
  pushObject(): Ref;
38
38
  pushType(index: number): Ref;
39
39
  resolveAgainst(base: Ref | undefined): Ref;
40
- get name(): string;
41
- get definitionName(): string | undefined;
40
+ readonly name: string;
41
+ readonly definitionName: string | undefined;
42
42
  toString(): string;
43
43
  private lookup;
44
44
  lookupRef(root: JSONSchema): JSONSchema;
@@ -54,8 +54,8 @@ export declare const schemaTypeDict: {
54
54
  array: boolean;
55
55
  object: boolean;
56
56
  };
57
- export type JSONSchemaType = keyof typeof schemaTypeDict;
58
- export type JSONSchemaAttributes = {
57
+ export declare type JSONSchemaType = keyof typeof schemaTypeDict;
58
+ export declare type JSONSchemaAttributes = {
59
59
  forType?: TypeAttributes;
60
60
  forUnion?: TypeAttributes;
61
61
  forObject?: TypeAttributes;
@@ -63,7 +63,7 @@ export type JSONSchemaAttributes = {
63
63
  forString?: TypeAttributes;
64
64
  forCases?: TypeAttributes[];
65
65
  };
66
- export type JSONSchemaAttributeProducer = (schema: JSONSchema, canonicalRef: Ref, types: Set<JSONSchemaType>, unionCases: JSONSchema[] | undefined) => JSONSchemaAttributes | undefined;
66
+ export declare type JSONSchemaAttributeProducer = (schema: JSONSchema, canonicalRef: Ref, types: Set<JSONSchemaType>, unionCases: JSONSchema[] | undefined) => JSONSchemaAttributes | undefined;
67
67
  export interface JSONSchemaSourceData {
68
68
  name: string;
69
69
  uris?: string[];
@@ -81,7 +81,7 @@ export declare class JSONSchemaInput implements Input<JSONSchemaSourceData> {
81
81
  private readonly _topLevels;
82
82
  private _needIR;
83
83
  constructor(_schemaStore: JSONSchemaStore | undefined, additionalAttributeProducers?: JSONSchemaAttributeProducer[], _additionalSchemaAddresses?: ReadonlyArray<string>);
84
- get needIR(): boolean;
84
+ readonly needIR: boolean;
85
85
  addTopLevel(name: string, ref: Ref): void;
86
86
  addTypes(ctx: RunContext, typeBuilder: TypeBuilder): Promise<void>;
87
87
  addTypesSync(): void;