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
@@ -4,7 +4,7 @@ import { StringTypeMapping } from "./TypeBuilder";
4
4
  import { InputData } from "./input/Inputs";
5
5
  import { TransformedStringTypeKind } from "./Type";
6
6
  export declare function getTargetLanguage(nameOrInstance: string | TargetLanguage): TargetLanguage;
7
- export type RendererOptions = {
7
+ export declare type RendererOptions = {
8
8
  [name: string]: string;
9
9
  };
10
10
  export interface InferenceFlag {
@@ -34,7 +34,7 @@ export declare const inferenceFlagsObject: {
34
34
  description: string;
35
35
  negationDescription: string;
36
36
  explanation: string;
37
- stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
37
+ stringType: "time" | "date" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
38
38
  order: number;
39
39
  };
40
40
  /** Whether to assume that JSON strings that look like dates are dates */
@@ -42,7 +42,7 @@ export declare const inferenceFlagsObject: {
42
42
  description: string;
43
43
  negationDescription: string;
44
44
  explanation: string;
45
- stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
45
+ stringType: "time" | "date" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
46
46
  order: number;
47
47
  };
48
48
  /** Whether to convert stringified integers to integers */
@@ -50,7 +50,7 @@ export declare const inferenceFlagsObject: {
50
50
  description: string;
51
51
  negationDescription: string;
52
52
  explanation: string;
53
- stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
53
+ stringType: "time" | "date" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
54
54
  order: number;
55
55
  };
56
56
  /** Whether to convert stringified booleans to boolean values */
@@ -58,7 +58,7 @@ export declare const inferenceFlagsObject: {
58
58
  description: string;
59
59
  negationDescription: string;
60
60
  explanation: string;
61
- stringType: "date" | "time" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
61
+ stringType: "time" | "date" | "date-time" | "uuid" | "uri" | "integer-string" | "bool-string";
62
62
  order: number;
63
63
  };
64
64
  /** Combine similar classes. This doesn't apply to classes from a schema, only from inference. */
@@ -76,19 +76,19 @@ export declare const inferenceFlagsObject: {
76
76
  order: number;
77
77
  };
78
78
  };
79
- export type InferenceFlagName = keyof typeof inferenceFlagsObject;
79
+ export declare type InferenceFlagName = keyof typeof inferenceFlagsObject;
80
80
  export declare const inferenceFlagNames: ("inferMaps" | "inferEnums" | "inferUuids" | "inferDateTimes" | "inferIntegerStrings" | "inferBooleanStrings" | "combineClasses" | "ignoreJsonRefs")[];
81
81
  export declare const inferenceFlags: {
82
82
  [F in InferenceFlagName]: InferenceFlag;
83
83
  };
84
- export type InferenceFlags = {
84
+ export declare type InferenceFlags = {
85
85
  [F in InferenceFlagName]: boolean;
86
86
  };
87
87
  /**
88
88
  * The options type for the main quicktype entry points,
89
89
  * `quicktypeMultiFile` and `quicktype`.
90
90
  */
91
- export type NonInferenceOptions = {
91
+ export declare type NonInferenceOptions = {
92
92
  /**
93
93
  * The target language for which to produce code. This can be either an instance of `TargetLanguage`,
94
94
  * or a string specifying one of the names for quicktype's built-in target languages. For example,
@@ -139,7 +139,7 @@ export type NonInferenceOptions = {
139
139
  /** Print schema resolving steps */
140
140
  debugPrintSchemaResolving: boolean;
141
141
  };
142
- export type Options = NonInferenceOptions & InferenceFlags;
142
+ export declare type Options = NonInferenceOptions & InferenceFlags;
143
143
  export interface RunContext {
144
144
  stringTypeMapping: StringTypeMapping;
145
145
  debugPrintReconstitution: boolean;
@@ -1,31 +1,15 @@
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;
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
+ });
24
9
  };
25
10
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.quicktype = exports.combineRenderResults = exports.quicktypeMultiFileSync = exports.quicktypeMultiFile = exports.defaultInferenceFlags = exports.inferenceFlags = exports.inferenceFlagNames = exports.inferenceFlagsObject = exports.getTargetLanguage = void 0;
27
11
  const collection_utils_1 = require("collection-utils");
28
- const targetLanguages = __importStar(require("./language/All"));
12
+ const targetLanguages = require("./language/All");
29
13
  const Support_1 = require("./support/Support");
30
14
  const CombineClasses_1 = require("./rewrites/CombineClasses");
31
15
  const InferMaps_1 = require("./rewrites/InferMaps");
@@ -49,7 +33,7 @@ function getTargetLanguage(nameOrInstance) {
49
33
  if (language !== undefined) {
50
34
  return language;
51
35
  }
52
- return (0, Messages_1.messageError)("DriverUnknownOutputLanguage", { lang: nameOrInstance });
36
+ return Messages_1.messageError("DriverUnknownOutputLanguage", { lang: nameOrInstance });
53
37
  }
54
38
  exports.getTargetLanguage = getTargetLanguage;
55
39
  exports.inferenceFlagsObject = {
@@ -144,7 +128,6 @@ function makeDefaultInferenceFlags() {
144
128
  }
145
129
  exports.defaultInferenceFlags = makeDefaultInferenceFlags();
146
130
  class Run {
147
- _options;
148
131
  constructor(options) {
149
132
  // We must not overwrite defaults with undefined values, which
150
133
  // we sometimes get.
@@ -176,14 +159,16 @@ class Run {
176
159
  get debugPrintSchemaResolving() {
177
160
  return this._options.debugPrintSchemaResolving;
178
161
  }
179
- async timeSync(name, f) {
180
- const start = Date.now();
181
- const result = await f();
182
- const end = Date.now();
183
- if (this._options.debugPrintTimes) {
184
- console.log(`${name} took ${end - start}ms`);
185
- }
186
- return result;
162
+ timeSync(name, f) {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ const start = Date.now();
165
+ const result = yield f();
166
+ const end = Date.now();
167
+ if (this._options.debugPrintTimes) {
168
+ console.log(`${name} took ${end - start}ms`);
169
+ }
170
+ return result;
171
+ });
187
172
  }
188
173
  time(name, f) {
189
174
  const start = Date.now();
@@ -201,10 +186,14 @@ class Run {
201
186
  const typeBuilder = new TypeBuilder_1.TypeBuilder(0, stringTypeMapping, this._options.alphabetizeProperties, this._options.allPropertiesOptional, this._options.checkProvenance, false);
202
187
  return { targetLanguage, stringTypeMapping, conflateNumbers, typeBuilder };
203
188
  }
204
- async makeGraph(allInputs) {
205
- const graphInputs = this.makeGraphInputs();
206
- await this.timeSync("read input", async () => await allInputs.addTypes(this, graphInputs.typeBuilder, this._options.inferMaps, this._options.inferEnums, this._options.fixedTopLevels));
207
- return this.processGraph(allInputs, graphInputs);
189
+ makeGraph(allInputs) {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ const graphInputs = this.makeGraphInputs();
192
+ yield this.timeSync("read input", () => __awaiter(this, void 0, void 0, function* () {
193
+ return yield allInputs.addTypes(this, graphInputs.typeBuilder, this._options.inferMaps, this._options.inferEnums, this._options.fixedTopLevels);
194
+ }));
195
+ return this.processGraph(allInputs, graphInputs);
196
+ });
208
197
  }
209
198
  makeGraphSync(allInputs) {
210
199
  const graphInputs = this.makeGraphInputs();
@@ -220,7 +209,7 @@ class Run {
220
209
  }
221
210
  const debugPrintReconstitution = this.debugPrintReconstitution;
222
211
  if (typeBuilder.didAddForwardingIntersection || !this._options.ignoreJsonRefs) {
223
- this.time("remove indirection intersections", () => (graph = (0, TypeGraph_1.removeIndirectionIntersections)(graph, stringTypeMapping, debugPrintReconstitution)));
212
+ this.time("remove indirection intersections", () => (graph = TypeGraph_1.removeIndirectionIntersections(graph, stringTypeMapping, debugPrintReconstitution)));
224
213
  }
225
214
  let unionsDone = false;
226
215
  if (allInputs.needSchemaProcessing || !this._options.ignoreJsonRefs) {
@@ -228,32 +217,32 @@ class Run {
228
217
  do {
229
218
  const graphBeforeRewrites = graph;
230
219
  if (!intersectionsDone) {
231
- this.time("resolve intersections", () => ([graph, intersectionsDone] = (0, ResolveIntersections_1.resolveIntersections)(graph, stringTypeMapping, debugPrintReconstitution)));
220
+ this.time("resolve intersections", () => ([graph, intersectionsDone] = ResolveIntersections_1.resolveIntersections(graph, stringTypeMapping, debugPrintReconstitution)));
232
221
  }
233
222
  if (!unionsDone) {
234
- this.time("flatten unions", () => ([graph, unionsDone] = (0, FlattenUnions_1.flattenUnions)(graph, stringTypeMapping, conflateNumbers, true, debugPrintReconstitution)));
223
+ this.time("flatten unions", () => ([graph, unionsDone] = FlattenUnions_1.flattenUnions(graph, stringTypeMapping, conflateNumbers, true, debugPrintReconstitution)));
235
224
  }
236
225
  if (graph === graphBeforeRewrites) {
237
- (0, Support_1.assert)(intersectionsDone && unionsDone, "Graph didn't change but we're not done");
226
+ Support_1.assert(intersectionsDone && unionsDone, "Graph didn't change but we're not done");
238
227
  }
239
228
  } while (!intersectionsDone || !unionsDone);
240
229
  }
241
- this.time("replace object type", () => (graph = (0, ReplaceObjectType_1.replaceObjectType)(graph, stringTypeMapping, conflateNumbers, targetLanguage.supportsFullObjectType, debugPrintReconstitution)));
230
+ this.time("replace object type", () => (graph = ReplaceObjectType_1.replaceObjectType(graph, stringTypeMapping, conflateNumbers, targetLanguage.supportsFullObjectType, debugPrintReconstitution)));
242
231
  do {
243
- this.time("flatten unions", () => ([graph, unionsDone] = (0, FlattenUnions_1.flattenUnions)(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
232
+ this.time("flatten unions", () => ([graph, unionsDone] = FlattenUnions_1.flattenUnions(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
244
233
  } while (!unionsDone);
245
234
  if (this._options.combineClasses) {
246
- const combinedGraph = this.time("combine classes", () => (0, CombineClasses_1.combineClasses)(this, graph, this._options.alphabetizeProperties, true, false, debugPrintReconstitution));
235
+ const combinedGraph = this.time("combine classes", () => CombineClasses_1.combineClasses(this, graph, this._options.alphabetizeProperties, true, false, debugPrintReconstitution));
247
236
  if (combinedGraph === graph) {
248
237
  graph = combinedGraph;
249
238
  }
250
239
  else {
251
- this.time("combine classes cleanup", () => (graph = (0, CombineClasses_1.combineClasses)(this, combinedGraph, this._options.alphabetizeProperties, false, true, debugPrintReconstitution)));
240
+ this.time("combine classes cleanup", () => (graph = CombineClasses_1.combineClasses(this, combinedGraph, this._options.alphabetizeProperties, false, true, debugPrintReconstitution)));
252
241
  }
253
242
  }
254
243
  if (this._options.inferMaps) {
255
244
  for (;;) {
256
- const newGraph = this.time("infer maps", () => (0, InferMaps_1.inferMaps)(graph, stringTypeMapping, true, debugPrintReconstitution));
245
+ const newGraph = this.time("infer maps", () => InferMaps_1.inferMaps(graph, stringTypeMapping, true, debugPrintReconstitution));
257
246
  if (newGraph === graph) {
258
247
  break;
259
248
  }
@@ -261,20 +250,20 @@ class Run {
261
250
  }
262
251
  }
263
252
  const enumInference = allInputs.needSchemaProcessing ? "all" : this._options.inferEnums ? "infer" : "none";
264
- this.time("expand strings", () => (graph = (0, ExpandStrings_1.expandStrings)(this, graph, enumInference)));
265
- this.time("flatten unions", () => ([graph, unionsDone] = (0, FlattenUnions_1.flattenUnions)(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
266
- (0, Support_1.assert)(unionsDone, "We should only have to flatten unions once after expanding strings");
253
+ this.time("expand strings", () => (graph = ExpandStrings_1.expandStrings(this, graph, enumInference)));
254
+ this.time("flatten unions", () => ([graph, unionsDone] = FlattenUnions_1.flattenUnions(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
255
+ Support_1.assert(unionsDone, "We should only have to flatten unions once after expanding strings");
267
256
  if (allInputs.needSchemaProcessing) {
268
- this.time("flatten strings", () => (graph = (0, FlattenStrings_1.flattenStrings)(graph, stringTypeMapping, debugPrintReconstitution)));
257
+ this.time("flatten strings", () => (graph = FlattenStrings_1.flattenStrings(graph, stringTypeMapping, debugPrintReconstitution)));
269
258
  }
270
- this.time("none to any", () => (graph = (0, TypeGraph_1.noneToAny)(graph, stringTypeMapping, debugPrintReconstitution)));
259
+ this.time("none to any", () => (graph = TypeGraph_1.noneToAny(graph, stringTypeMapping, debugPrintReconstitution)));
271
260
  if (!targetLanguage.supportsOptionalClassProperties) {
272
- this.time("optional to nullable", () => (graph = (0, TypeGraph_1.optionalToNullable)(graph, stringTypeMapping, debugPrintReconstitution)));
261
+ this.time("optional to nullable", () => (graph = TypeGraph_1.optionalToNullable(graph, stringTypeMapping, debugPrintReconstitution)));
273
262
  }
274
263
  this.time("fixed point", () => (graph = graph.rewriteFixedPoint(false, debugPrintReconstitution)));
275
- this.time("make transformations", () => (graph = (0, MakeTransformations_1.makeTransformations)(this, graph, targetLanguage)));
276
- this.time("flatten unions", () => ([graph, unionsDone] = (0, FlattenUnions_1.flattenUnions)(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
277
- (0, Support_1.assert)(unionsDone, "We should only have to flatten unions once after making transformations");
264
+ this.time("make transformations", () => (graph = MakeTransformations_1.makeTransformations(this, graph, targetLanguage)));
265
+ this.time("flatten unions", () => ([graph, unionsDone] = FlattenUnions_1.flattenUnions(graph, stringTypeMapping, conflateNumbers, false, debugPrintReconstitution)));
266
+ Support_1.assert(unionsDone, "We should only have to flatten unions once after making transformations");
278
267
  // Sometimes we combine classes in ways that will the order come out
279
268
  // differently compared to what it would be from the equivalent schema,
280
269
  // so we always just garbage collect to get a defined order and be done
@@ -286,7 +275,7 @@ class Run {
286
275
  if (this._options.debugPrintGraph) {
287
276
  console.log("\n# gather names");
288
277
  }
289
- this.time("gather names", () => (0, GatherNames_1.gatherNames)(graph, !allInputs.needSchemaProcessing, this._options.debugPrintGatherNames));
278
+ this.time("gather names", () => GatherNames_1.gatherNames(graph, !allInputs.needSchemaProcessing, this._options.debugPrintGatherNames));
290
279
  if (this._options.debugPrintGraph) {
291
280
  graph.printGraph();
292
281
  }
@@ -297,7 +286,7 @@ class Run {
297
286
  }
298
287
  preRun() {
299
288
  // FIXME: This makes quicktype not quite reentrant
300
- (0, TypeNames_1.initTypeNames)();
289
+ TypeNames_1.initTypeNames();
301
290
  const targetLanguage = getTargetLanguage(this._options.lang);
302
291
  const inputData = this._options.inputData;
303
292
  const needIR = inputData.needIR || targetLanguage.names.indexOf("schema") < 0;
@@ -310,14 +299,16 @@ class Run {
310
299
  }
311
300
  return [inputData, targetLanguage];
312
301
  }
313
- async run() {
314
- const preRunResult = this.preRun();
315
- if (!Array.isArray(preRunResult)) {
316
- return preRunResult;
317
- }
318
- const [inputData, targetLanguage] = preRunResult;
319
- const graph = await this.makeGraph(inputData);
320
- return this.renderGraph(targetLanguage, graph);
302
+ run() {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ const preRunResult = this.preRun();
305
+ if (!Array.isArray(preRunResult)) {
306
+ return preRunResult;
307
+ }
308
+ const [inputData, targetLanguage] = preRunResult;
309
+ const graph = yield this.makeGraph(inputData);
310
+ return this.renderGraph(targetLanguage, graph);
311
+ });
321
312
  }
322
313
  runSync() {
323
314
  const preRunResult = this.preRun();
@@ -341,8 +332,10 @@ class Run {
341
332
  * @param options Partial options. For options that are not defined, the
342
333
  * defaults will be used.
343
334
  */
344
- async function quicktypeMultiFile(options) {
345
- return await new Run(options).run();
335
+ function quicktypeMultiFile(options) {
336
+ return __awaiter(this, void 0, void 0, function* () {
337
+ return yield new Run(options).run();
338
+ });
346
339
  }
347
340
  exports.quicktypeMultiFile = quicktypeMultiFile;
348
341
  function quicktypeMultiFileSync(options) {
@@ -362,7 +355,7 @@ function offsetSpan(span, lineOffset) {
362
355
  */
363
356
  function combineRenderResults(result) {
364
357
  if (result.size <= 1) {
365
- const first = (0, collection_utils_1.mapFirst)(result);
358
+ const first = collection_utils_1.mapFirst(result);
366
359
  if (first === undefined) {
367
360
  return { lines: [], annotations: [] };
368
361
  }
@@ -386,8 +379,10 @@ exports.combineRenderResults = combineRenderResults;
386
379
  * @param options Partial options. For options that are not defined, the
387
380
  * defaults will be used.
388
381
  */
389
- async function quicktype(options) {
390
- const result = await quicktypeMultiFile(options);
391
- return combineRenderResults(result);
382
+ function quicktype(options) {
383
+ return __awaiter(this, void 0, void 0, function* () {
384
+ const result = yield quicktypeMultiFile(options);
385
+ return combineRenderResults(result);
386
+ });
392
387
  }
393
388
  exports.quicktype = quicktype;
@@ -1,6 +1,6 @@
1
1
  import { AnnotationData } from "./Annotation";
2
2
  import { Name } from "./Naming";
3
- export type Source = TextSource | NewlineSource | SequenceSource | TableSource | AnnotatedSource | NameSource | ModifiedSource;
3
+ export declare type Source = TextSource | NewlineSource | SequenceSource | TableSource | AnnotatedSource | NameSource | ModifiedSource;
4
4
  export interface TextSource {
5
5
  kind: "text";
6
6
  text: string;
@@ -32,7 +32,7 @@ export interface ModifiedSource {
32
32
  source: Source;
33
33
  }
34
34
  export declare function newline(): NewlineSource;
35
- export type Sourcelike = Source | string | Name | SourcelikeArray;
35
+ export declare type Sourcelike = Source | string | Name | SourcelikeArray;
36
36
  export interface SourcelikeArray extends Array<Sourcelike> {
37
37
  }
38
38
  export declare function sourcelikeToSource(sl: Sourcelike): Source;
@@ -56,7 +56,7 @@ export interface SerializedRenderResult {
56
56
  annotations: ReadonlyArray<Annotation>;
57
57
  }
58
58
  export declare function serializeRenderResult(rootSource: Source, names: ReadonlyMap<Name, string>, indentation: string): SerializedRenderResult;
59
- export type MultiWord = {
59
+ export declare type MultiWord = {
60
60
  source: Sourcelike;
61
61
  needsParens: boolean;
62
62
  };
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parenIfNeeded = exports.multiWord = exports.singleWord = exports.serializeRenderResult = exports.modifySource = exports.maybeAnnotated = exports.annotated = exports.sourcelikeToSource = exports.newline = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const Naming_1 = require("./Naming");
6
5
  const Support_1 = require("./support/Support");
@@ -25,7 +24,7 @@ function sourcelikeToSource(sl) {
25
24
  }
26
25
  return {
27
26
  kind: "sequence",
28
- sequence: (0, collection_utils_1.arrayIntercalate)(newline(), lines.map((l) => ({ kind: "text", text: l })))
27
+ sequence: collection_utils_1.arrayIntercalate(newline(), lines.map((l) => ({ kind: "text", text: l })))
29
28
  };
30
29
  }
31
30
  if (sl instanceof Naming_1.Name) {
@@ -62,21 +61,21 @@ function sourceLineLength(source, names) {
62
61
  case "text":
63
62
  return source.text.length;
64
63
  case "newline":
65
- return (0, Support_1.panic)("Newline must not occur within a line.");
64
+ return Support_1.panic("Newline must not occur within a line.");
66
65
  case "sequence":
67
66
  return source.sequence
68
67
  .map((s) => sourceLineLength(s, names))
69
68
  .reduce((a, b) => a + b, 0);
70
69
  case "table":
71
- return (0, Support_1.panic)("Table must not occur within a line.");
70
+ return Support_1.panic("Table must not occur within a line.");
72
71
  case "annotated":
73
72
  return sourceLineLength(source.source, names);
74
73
  case "name":
75
- return (0, Support_1.defined)(names.get(source.named)).length;
74
+ return Support_1.defined(names.get(source.named)).length;
76
75
  case "modified":
77
76
  return serializeRenderResult(source, names, "").lines.join("\n").length;
78
77
  default:
79
- return (0, Support_1.assertNever)(source);
78
+ return Support_1.assertNever(source);
80
79
  }
81
80
  }
82
81
  function serializeRenderResult(rootSource, names, indentation) {
@@ -88,7 +87,7 @@ function serializeRenderResult(rootSource, names, indentation) {
88
87
  function indentIfNeeded() {
89
88
  if (indentNeeded === 0)
90
89
  return;
91
- currentLine.push((0, Strings_1.repeatString)(indentation, indentNeeded));
90
+ currentLine.push(Strings_1.repeatString(indentation, indentNeeded));
92
91
  indentNeeded = 0;
93
92
  }
94
93
  function flattenCurrentLine() {
@@ -125,24 +124,24 @@ function serializeRenderResult(rootSource, names, indentation) {
125
124
  if (numRows === 0)
126
125
  break;
127
126
  const widths = t.map(l => l.map(s => sourceLineLength(s, names)));
128
- const numColumns = (0, Support_1.defined)((0, collection_utils_1.iterableMax)(t.map(l => l.length)));
127
+ const numColumns = Support_1.defined(collection_utils_1.iterableMax(t.map(l => l.length)));
129
128
  if (numColumns === 0)
130
129
  break;
131
130
  const columnWidths = [];
132
131
  for (let i = 0; i < numColumns; i++) {
133
- columnWidths.push((0, Support_1.defined)((0, collection_utils_1.iterableMax)(widths.map(l => (0, collection_utils_1.withDefault)(l[i], 0)))));
132
+ columnWidths.push(Support_1.defined(collection_utils_1.iterableMax(widths.map(l => collection_utils_1.withDefault(l[i], 0)))));
134
133
  }
135
134
  for (let y = 0; y < numRows; y++) {
136
135
  indentIfNeeded();
137
- const row = (0, Support_1.defined)(t[y]);
138
- const rowWidths = (0, Support_1.defined)(widths[y]);
136
+ const row = Support_1.defined(t[y]);
137
+ const rowWidths = Support_1.defined(widths[y]);
139
138
  for (let x = 0; x < numColumns; x++) {
140
139
  const colWidth = columnWidths[x];
141
- const src = (0, collection_utils_1.withDefault)(row[x], { kind: "text", text: "" });
142
- const srcWidth = (0, collection_utils_1.withDefault)(rowWidths[x], 0);
140
+ const src = collection_utils_1.withDefault(row[x], { kind: "text", text: "" });
141
+ const srcWidth = collection_utils_1.withDefault(rowWidths[x], 0);
143
142
  serializeToStringArray(src);
144
143
  if (x < numColumns - 1 && srcWidth < colWidth) {
145
- currentLine.push((0, Strings_1.repeatString)(" ", colWidth - srcWidth));
144
+ currentLine.push(Strings_1.repeatString(" ", colWidth - srcWidth));
146
145
  }
147
146
  }
148
147
  if (y < numRows - 1) {
@@ -158,18 +157,18 @@ function serializeRenderResult(rootSource, names, indentation) {
158
157
  annotations.push({ annotation: source.annotation, span: { start, end } });
159
158
  break;
160
159
  case "name":
161
- (0, Support_1.assert)(names.has(source.named), "No name for Named");
160
+ Support_1.assert(names.has(source.named), "No name for Named");
162
161
  indentIfNeeded();
163
- currentLine.push((0, Support_1.defined)(names.get(source.named)));
162
+ currentLine.push(Support_1.defined(names.get(source.named)));
164
163
  break;
165
164
  case "modified":
166
165
  indentIfNeeded();
167
166
  const serialized = serializeRenderResult(source.source, names, indentation).lines;
168
- (0, Support_1.assert)(serialized.length === 1, "Cannot modify more than one line.");
167
+ Support_1.assert(serialized.length === 1, "Cannot modify more than one line.");
169
168
  currentLine.push(source.modifier(serialized[0]));
170
169
  break;
171
170
  default:
172
- return (0, Support_1.assertNever)(source);
171
+ return Support_1.assertNever(source);
173
172
  }
174
173
  }
175
174
  serializeToStringArray(rootSource);
@@ -182,7 +181,7 @@ function singleWord(...source) {
182
181
  }
183
182
  exports.singleWord = singleWord;
184
183
  function multiWord(separator, ...words) {
185
- (0, Support_1.assert)(words.length > 0, "Zero words is not multiple");
184
+ Support_1.assert(words.length > 0, "Zero words is not multiple");
186
185
  if (words.length === 1) {
187
186
  return singleWord(words[0]);
188
187
  }
@@ -5,30 +5,30 @@ import { SerializedRenderResult } from "./Source";
5
5
  import { StringTypeMapping } from "./TypeBuilder";
6
6
  import { Type } from "./Type";
7
7
  import { DateTimeRecognizer } from "./DateTime";
8
- export type MultiFileRenderResult = ReadonlyMap<string, SerializedRenderResult>;
8
+ export declare type MultiFileRenderResult = ReadonlyMap<string, SerializedRenderResult>;
9
9
  export declare abstract class TargetLanguage {
10
10
  readonly displayName: string;
11
11
  readonly names: string[];
12
12
  readonly extension: string;
13
13
  constructor(displayName: string, names: string[], extension: string);
14
14
  protected abstract getOptions(): Option<any>[];
15
- get optionDefinitions(): OptionDefinition[];
16
- get cliOptionDefinitions(): {
15
+ readonly optionDefinitions: OptionDefinition[];
16
+ readonly cliOptionDefinitions: {
17
17
  display: OptionDefinition[];
18
18
  actual: OptionDefinition[];
19
19
  };
20
- get name(): string;
20
+ readonly name: string;
21
21
  protected abstract makeRenderer(renderContext: RenderContext, optionValues: {
22
22
  [name: string]: any;
23
23
  }): Renderer;
24
24
  renderGraphAndSerialize(typeGraph: TypeGraph, givenOutputFilename: string, alphabetizeProperties: boolean, leadingComments: string[] | undefined, rendererOptions: {
25
25
  [name: string]: any;
26
26
  }, indentation?: string): MultiFileRenderResult;
27
- protected get defaultIndentation(): string;
28
- get stringTypeMapping(): StringTypeMapping;
29
- get supportsOptionalClassProperties(): boolean;
30
- get supportsUnionsWithBothNumberTypes(): boolean;
31
- get supportsFullObjectType(): boolean;
27
+ protected readonly defaultIndentation: string;
28
+ readonly stringTypeMapping: StringTypeMapping;
29
+ readonly supportsOptionalClassProperties: boolean;
30
+ readonly supportsUnionsWithBothNumberTypes: boolean;
31
+ readonly supportsFullObjectType: boolean;
32
32
  needsTransformerForType(_t: Type): boolean;
33
- get dateTimeRecognizer(): DateTimeRecognizer;
33
+ readonly dateTimeRecognizer: DateTimeRecognizer;
34
34
  }
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TargetLanguage = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const Source_1 = require("./Source");
6
5
  const Support_1 = require("./support/Support");
7
6
  const DateTime_1 = require("./DateTime");
8
7
  class TargetLanguage {
9
- displayName;
10
- names;
11
- extension;
12
8
  constructor(displayName, names, extension) {
13
9
  this.displayName = displayName;
14
10
  this.names = names;
@@ -27,7 +23,7 @@ class TargetLanguage {
27
23
  return { actual, display };
28
24
  }
29
25
  get name() {
30
- return (0, Support_1.defined)(this.names[0]);
26
+ return Support_1.defined(this.names[0]);
31
27
  }
32
28
  renderGraphAndSerialize(typeGraph, givenOutputFilename, alphabetizeProperties, leadingComments, rendererOptions, indentation) {
33
29
  if (indentation === undefined) {
@@ -39,7 +35,7 @@ class TargetLanguage {
39
35
  renderer.setAlphabetizeProperties(alphabetizeProperties);
40
36
  }
41
37
  const renderResult = renderer.render(givenOutputFilename);
42
- return (0, collection_utils_1.mapMap)(renderResult.sources, s => (0, Source_1.serializeRenderResult)(s, renderResult.names, (0, Support_1.defined)(indentation)));
38
+ return collection_utils_1.mapMap(renderResult.sources, s => Source_1.serializeRenderResult(s, renderResult.names, Support_1.defined(indentation)));
43
39
  }
44
40
  get defaultIndentation() {
45
41
  return " ";