quicktype 16.0.42 → 17.0.0

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