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
package/dist/cli/index.js CHANGED
@@ -1,35 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
25
10
  };
26
11
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.main = exports.writeOutput = exports.makeQuicktypeOptions = exports.jsonInputForTargetLanguage = exports.parseCLIOptions = void 0;
28
- const fs = __importStar(require("fs"));
29
- const path = __importStar(require("path"));
30
- const _ = __importStar(require("lodash"));
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const _ = require("lodash");
31
15
  const collection_utils_1 = require("collection-utils");
32
- const ts_necessities_1 = require("@glideapps/ts-necessities");
33
16
  const quicktype_core_1 = require("../quicktype-core");
34
17
  const quicktype_typescript_input_1 = require("../quicktype-typescript-input");
35
18
  const quicktype_graphql_input_1 = require("../quicktype-graphql-input");
@@ -43,122 +26,128 @@ const chalk = require("chalk");
43
26
  const wordWrap = require("wordwrap")(90);
44
27
  const packageJSON = require("../../package.json");
45
28
  const defaultDefaultTargetLanguageName = "go";
46
- async function sourceFromFileOrUrlArray(name, filesOrUrls, httpHeaders) {
47
- const samples = await Promise.all(filesOrUrls.map(file => (0, quicktype_core_1.readableFromFileOrURL)(file, httpHeaders)));
48
- return { kind: "json", name, samples };
29
+ function sourceFromFileOrUrlArray(name, filesOrUrls, httpHeaders) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const samples = yield Promise.all(filesOrUrls.map(file => quicktype_core_1.readableFromFileOrURL(file, httpHeaders)));
32
+ return { kind: "json", name, samples };
33
+ });
49
34
  }
50
35
  function typeNameFromFilename(filename) {
51
36
  const name = path.basename(filename);
52
37
  return name.substring(0, name.lastIndexOf("."));
53
38
  }
54
- async function samplesFromDirectory(dataDir, httpHeaders) {
55
- async function readFilesOrURLsInDirectory(d) {
56
- const files = fs
57
- .readdirSync(d)
58
- .map(x => path.join(d, x))
59
- .filter(x => fs.lstatSync(x).isFile());
60
- // Each file is a (Name, JSON | URL)
61
- const sourcesInDir = [];
62
- const graphQLSources = [];
63
- let graphQLSchema = undefined;
64
- let graphQLSchemaFileName = undefined;
65
- for (let file of files) {
66
- const name = typeNameFromFilename(file);
67
- let fileOrUrl = file;
68
- file = file.toLowerCase();
69
- // If file is a URL string, download it
70
- if (file.endsWith(".url")) {
71
- fileOrUrl = fs.readFileSync(file, "utf8").trim();
39
+ function samplesFromDirectory(dataDir, httpHeaders) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ function readFilesOrURLsInDirectory(d) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const files = fs
44
+ .readdirSync(d)
45
+ .map(x => path.join(d, x))
46
+ .filter(x => fs.lstatSync(x).isFile());
47
+ // Each file is a (Name, JSON | URL)
48
+ const sourcesInDir = [];
49
+ const graphQLSources = [];
50
+ let graphQLSchema = undefined;
51
+ let graphQLSchemaFileName = undefined;
52
+ for (let file of files) {
53
+ const name = typeNameFromFilename(file);
54
+ let fileOrUrl = file;
55
+ file = file.toLowerCase();
56
+ // If file is a URL string, download it
57
+ if (file.endsWith(".url")) {
58
+ fileOrUrl = fs.readFileSync(file, "utf8").trim();
59
+ }
60
+ if (file.endsWith(".url") || file.endsWith(".json")) {
61
+ sourcesInDir.push({
62
+ kind: "json",
63
+ name,
64
+ samples: [yield quicktype_core_1.readableFromFileOrURL(fileOrUrl, httpHeaders)]
65
+ });
66
+ }
67
+ else if (file.endsWith(".schema")) {
68
+ sourcesInDir.push({
69
+ kind: "schema",
70
+ name,
71
+ uris: [fileOrUrl]
72
+ });
73
+ }
74
+ else if (file.endsWith(".gqlschema")) {
75
+ quicktype_core_1.messageAssert(graphQLSchema === undefined, "DriverMoreThanOneGraphQLSchemaInDir", {
76
+ dir: dataDir
77
+ });
78
+ graphQLSchema = yield quicktype_core_1.readableFromFileOrURL(fileOrUrl, httpHeaders);
79
+ graphQLSchemaFileName = fileOrUrl;
80
+ }
81
+ else if (file.endsWith(".graphql")) {
82
+ graphQLSources.push({
83
+ kind: "graphql",
84
+ name,
85
+ schema: undefined,
86
+ query: yield quicktype_core_1.getStream(yield quicktype_core_1.readableFromFileOrURL(fileOrUrl, httpHeaders))
87
+ });
88
+ }
89
+ }
90
+ if (graphQLSources.length > 0) {
91
+ if (graphQLSchema === undefined) {
92
+ return quicktype_core_1.messageError("DriverNoGraphQLSchemaInDir", { dir: dataDir });
93
+ }
94
+ const schema = quicktype_core_1.parseJSON(yield quicktype_core_1.getStream(graphQLSchema), "GraphQL schema", graphQLSchemaFileName);
95
+ for (const source of graphQLSources) {
96
+ source.schema = schema;
97
+ sourcesInDir.push(source);
98
+ }
99
+ }
100
+ return sourcesInDir;
101
+ });
102
+ }
103
+ const contents = fs.readdirSync(dataDir).map(x => path.join(dataDir, x));
104
+ const directories = contents.filter(x => fs.lstatSync(x).isDirectory());
105
+ let sources = yield readFilesOrURLsInDirectory(dataDir);
106
+ for (const dir of directories) {
107
+ let jsonSamples = [];
108
+ const schemaSources = [];
109
+ const graphQLSources = [];
110
+ for (const source of yield readFilesOrURLsInDirectory(dir)) {
111
+ switch (source.kind) {
112
+ case "json":
113
+ jsonSamples = jsonSamples.concat(source.samples);
114
+ break;
115
+ case "schema":
116
+ schemaSources.push(source);
117
+ break;
118
+ case "graphql":
119
+ graphQLSources.push(source);
120
+ break;
121
+ default:
122
+ return quicktype_core_1.assertNever(source);
123
+ }
72
124
  }
73
- if (file.endsWith(".url") || file.endsWith(".json")) {
74
- sourcesInDir.push({
75
- kind: "json",
76
- name,
77
- samples: [await (0, quicktype_core_1.readableFromFileOrURL)(fileOrUrl, httpHeaders)]
78
- });
125
+ if (jsonSamples.length > 0 && schemaSources.length + graphQLSources.length > 0) {
126
+ return quicktype_core_1.messageError("DriverCannotMixJSONWithOtherSamples", { dir: dir });
79
127
  }
80
- else if (file.endsWith(".schema")) {
81
- sourcesInDir.push({
82
- kind: "schema",
83
- name,
84
- uris: [fileOrUrl]
85
- });
128
+ const oneUnlessEmpty = (xs) => Math.sign(xs.length);
129
+ if (oneUnlessEmpty(schemaSources) + oneUnlessEmpty(graphQLSources) > 1) {
130
+ return quicktype_core_1.messageError("DriverCannotMixNonJSONInputs", { dir: dir });
86
131
  }
87
- else if (file.endsWith(".gqlschema")) {
88
- (0, quicktype_core_1.messageAssert)(graphQLSchema === undefined, "DriverMoreThanOneGraphQLSchemaInDir", {
89
- dir: dataDir
90
- });
91
- graphQLSchema = await (0, quicktype_core_1.readableFromFileOrURL)(fileOrUrl, httpHeaders);
92
- graphQLSchemaFileName = fileOrUrl;
93
- }
94
- else if (file.endsWith(".graphql")) {
95
- graphQLSources.push({
96
- kind: "graphql",
97
- name,
98
- schema: undefined,
99
- query: await (0, quicktype_core_1.getStream)(await (0, quicktype_core_1.readableFromFileOrURL)(fileOrUrl, httpHeaders))
132
+ if (jsonSamples.length > 0) {
133
+ sources.push({
134
+ kind: "json",
135
+ name: path.basename(dir),
136
+ samples: jsonSamples
100
137
  });
101
138
  }
139
+ sources = sources.concat(schemaSources);
140
+ sources = sources.concat(graphQLSources);
102
141
  }
103
- if (graphQLSources.length > 0) {
104
- if (graphQLSchema === undefined) {
105
- return (0, quicktype_core_1.messageError)("DriverNoGraphQLSchemaInDir", { dir: dataDir });
106
- }
107
- const schema = (0, quicktype_core_1.parseJSON)(await (0, quicktype_core_1.getStream)(graphQLSchema), "GraphQL schema", graphQLSchemaFileName);
108
- for (const source of graphQLSources) {
109
- source.schema = schema;
110
- sourcesInDir.push(source);
111
- }
112
- }
113
- return sourcesInDir;
114
- }
115
- const contents = fs.readdirSync(dataDir).map(x => path.join(dataDir, x));
116
- const directories = contents.filter(x => fs.lstatSync(x).isDirectory());
117
- let sources = await readFilesOrURLsInDirectory(dataDir);
118
- for (const dir of directories) {
119
- let jsonSamples = [];
120
- const schemaSources = [];
121
- const graphQLSources = [];
122
- for (const source of await readFilesOrURLsInDirectory(dir)) {
123
- switch (source.kind) {
124
- case "json":
125
- jsonSamples = jsonSamples.concat(source.samples);
126
- break;
127
- case "schema":
128
- schemaSources.push(source);
129
- break;
130
- case "graphql":
131
- graphQLSources.push(source);
132
- break;
133
- default:
134
- return (0, quicktype_core_1.assertNever)(source);
135
- }
136
- }
137
- if (jsonSamples.length > 0 && schemaSources.length + graphQLSources.length > 0) {
138
- return (0, quicktype_core_1.messageError)("DriverCannotMixJSONWithOtherSamples", { dir: dir });
139
- }
140
- const oneUnlessEmpty = (xs) => Math.sign(xs.length);
141
- if (oneUnlessEmpty(schemaSources) + oneUnlessEmpty(graphQLSources) > 1) {
142
- return (0, quicktype_core_1.messageError)("DriverCannotMixNonJSONInputs", { dir: dir });
143
- }
144
- if (jsonSamples.length > 0) {
145
- sources.push({
146
- kind: "json",
147
- name: path.basename(dir),
148
- samples: jsonSamples
149
- });
150
- }
151
- sources = sources.concat(schemaSources);
152
- sources = sources.concat(graphQLSources);
153
- }
154
- return sources;
142
+ return sources;
143
+ });
155
144
  }
156
145
  function inferLang(options, defaultLanguage) {
157
146
  // Output file extension determines the language if language is undefined
158
147
  if (options.out !== undefined) {
159
148
  let extension = path.extname(options.out);
160
149
  if (extension === "") {
161
- return (0, quicktype_core_1.messageError)("DriverNoLanguageOrExtension", {});
150
+ return quicktype_core_1.messageError("DriverNoLanguageOrExtension", {});
162
151
  }
163
152
  return extension.slice(1);
164
153
  }
@@ -183,15 +172,15 @@ function inferTopLevel(options) {
183
172
  function inferCLIOptions(opts, targetLanguage) {
184
173
  let srcLang = opts.srcLang;
185
174
  if (opts.graphqlSchema !== undefined || opts.graphqlIntrospect !== undefined) {
186
- (0, quicktype_core_1.messageAssert)(srcLang === undefined || srcLang === "graphql", "DriverSourceLangMustBeGraphQL", {});
175
+ quicktype_core_1.messageAssert(srcLang === undefined || srcLang === "graphql", "DriverSourceLangMustBeGraphQL", {});
187
176
  srcLang = "graphql";
188
177
  }
189
178
  else if (opts.src !== undefined && opts.src.length > 0 && opts.src.every(file => _.endsWith(file, ".ts"))) {
190
179
  srcLang = "typescript";
191
180
  }
192
181
  else {
193
- (0, quicktype_core_1.messageAssert)(srcLang !== "graphql", "DriverGraphQLSchemaNeeded", {});
194
- srcLang = (0, collection_utils_1.withDefault)(srcLang, "json");
182
+ quicktype_core_1.messageAssert(srcLang !== "graphql", "DriverGraphQLSchemaNeeded", {});
183
+ srcLang = collection_utils_1.withDefault(srcLang, "json");
195
184
  }
196
185
  let language;
197
186
  if (targetLanguage !== undefined) {
@@ -199,9 +188,9 @@ function inferCLIOptions(opts, targetLanguage) {
199
188
  }
200
189
  else {
201
190
  const languageName = opts.lang !== undefined ? opts.lang : inferLang(opts, defaultDefaultTargetLanguageName);
202
- const maybeLanguage = (0, quicktype_core_1.languageNamed)(languageName);
191
+ const maybeLanguage = quicktype_core_1.languageNamed(languageName);
203
192
  if (maybeLanguage === undefined) {
204
- return (0, quicktype_core_1.messageError)("DriverUnknownOutputLanguage", { lang: languageName });
193
+ return quicktype_core_1.messageError("DriverUnknownOutputLanguage", { lang: languageName });
205
194
  }
206
195
  language = maybeLanguage;
207
196
  }
@@ -237,7 +226,7 @@ function inferCLIOptions(opts, targetLanguage) {
237
226
  return options;
238
227
  }
239
228
  function makeLangTypeLabel(targetLanguages) {
240
- (0, quicktype_core_1.assert)(targetLanguages.length > 0, "Must have at least one target language");
229
+ quicktype_core_1.assert(targetLanguages.length > 0, "Must have at least one target language");
241
230
  return targetLanguages.map(r => _.minBy(r.names, s => s.length)).join("|");
242
231
  }
243
232
  function negatedInferenceFlagName(name) {
@@ -245,10 +234,10 @@ function negatedInferenceFlagName(name) {
245
234
  if (name.startsWith(prefix)) {
246
235
  name = name.slice(prefix.length);
247
236
  }
248
- return "no" + (0, quicktype_core_1.capitalize)(name);
237
+ return "no" + quicktype_core_1.capitalize(name);
249
238
  }
250
239
  function dashedFromCamelCase(name) {
251
- return (0, quicktype_core_1.splitIntoWords)(name)
240
+ return quicktype_core_1.splitIntoWords(name)
252
241
  .map(w => w.word.toLowerCase())
253
242
  .join("-");
254
243
  }
@@ -304,7 +293,7 @@ function makeOptionDefinitions(targetLanguages) {
304
293
  description: "Tracery grammar describing URLs to crawl."
305
294
  }
306
295
  ];
307
- const inference = Array.from((0, collection_utils_1.mapMap)((0, collection_utils_1.mapFromObject)(quicktype_core_1.inferenceFlags), (flag, name) => {
296
+ const inference = Array.from(collection_utils_1.mapMap(collection_utils_1.mapFromObject(quicktype_core_1.inferenceFlags), (flag, name) => {
308
297
  return {
309
298
  name: dashedFromCamelCase(negatedInferenceFlagName(name)),
310
299
  type: Boolean,
@@ -468,7 +457,7 @@ function parseCLIOptions(argv, targetLanguage) {
468
457
  // twice. This is the first parse to get the renderer:
469
458
  const incompleteOptions = inferCLIOptions(parseOptions(optionDefinitions, argv, true), targetLanguage);
470
459
  if (targetLanguage === undefined) {
471
- targetLanguage = (0, quicktype_core_1.getTargetLanguage)(incompleteOptions.lang);
460
+ targetLanguage = quicktype_core_1.getTargetLanguage(incompleteOptions.lang);
472
461
  }
473
462
  const rendererOptionDefinitions = targetLanguage.cliOptionDefinitions.actual;
474
463
  // Use the global options as well as the renderer options from now on:
@@ -486,19 +475,19 @@ function parseOptions(definitions, argv, partial) {
486
475
  opts = commandLineArgs(definitions, { argv, partial });
487
476
  }
488
477
  catch (e) {
489
- (0, quicktype_core_1.assert)(!partial, "Partial option parsing should not have failed");
490
- return (0, quicktype_core_1.messageError)("DriverCLIOptionParsingFailed", { message: (0, ts_necessities_1.exceptionToString)(e) });
478
+ quicktype_core_1.assert(!partial, "Partial option parsing should not have failed");
479
+ return quicktype_core_1.messageError("DriverCLIOptionParsingFailed", { message: e.message });
491
480
  }
492
481
  for (const k of Object.keys(opts)) {
493
482
  if (opts[k] === null) {
494
- return (0, quicktype_core_1.messageError)("DriverCLIOptionParsingFailed", {
483
+ return quicktype_core_1.messageError("DriverCLIOptionParsingFailed", {
495
484
  message: `Missing value for command line option "${k}"`
496
485
  });
497
486
  }
498
487
  }
499
488
  const options = { rendererOptions: {} };
500
489
  for (const o of definitions) {
501
- if (!(0, collection_utils_1.hasOwnProperty)(opts, o.name))
490
+ if (!collection_utils_1.hasOwnProperty(opts, o.name))
502
491
  continue;
503
492
  const v = opts[o.name];
504
493
  if (o.renderer !== undefined)
@@ -526,234 +515,244 @@ function usage(targetLanguages) {
526
515
  console.log(getUsage(sections));
527
516
  }
528
517
  // Returns an array of [name, sourceURIs] pairs.
529
- async function getSourceURIs(options) {
530
- if (options.srcUrls !== undefined) {
531
- const json = (0, quicktype_core_1.parseJSON)(await (0, quicktype_core_1.readFromFileOrURL)(options.srcUrls, options.httpHeader), "URL grammar", options.srcUrls);
532
- const jsonMap = (0, URLGrammar_1.urlsFromURLGrammar)(json);
533
- const topLevels = Object.getOwnPropertyNames(jsonMap);
534
- return topLevels.map(name => [name, jsonMap[name]]);
535
- }
536
- else if (options.src.length === 0) {
537
- return [[options.topLevel, ["-"]]];
538
- }
539
- else {
540
- return [];
541
- }
518
+ function getSourceURIs(options) {
519
+ return __awaiter(this, void 0, void 0, function* () {
520
+ if (options.srcUrls !== undefined) {
521
+ const json = quicktype_core_1.parseJSON(yield quicktype_core_1.readFromFileOrURL(options.srcUrls, options.httpHeader), "URL grammar", options.srcUrls);
522
+ const jsonMap = URLGrammar_1.urlsFromURLGrammar(json);
523
+ const topLevels = Object.getOwnPropertyNames(jsonMap);
524
+ return topLevels.map(name => [name, jsonMap[name]]);
525
+ }
526
+ else if (options.src.length === 0) {
527
+ return [[options.topLevel, ["-"]]];
528
+ }
529
+ else {
530
+ return [];
531
+ }
532
+ });
542
533
  }
543
- async function typeSourcesForURIs(name, uris, options) {
544
- switch (options.srcLang) {
545
- case "json":
546
- return [await sourceFromFileOrUrlArray(name, uris, options.httpHeader)];
547
- case "schema":
548
- return uris.map(uri => ({ kind: "schema", name, uris: [uri] }));
549
- default:
550
- return (0, quicktype_core_1.panic)(`typeSourceForURIs must not be called for source language ${options.srcLang}`);
551
- }
534
+ function typeSourcesForURIs(name, uris, options) {
535
+ return __awaiter(this, void 0, void 0, function* () {
536
+ switch (options.srcLang) {
537
+ case "json":
538
+ return [yield sourceFromFileOrUrlArray(name, uris, options.httpHeader)];
539
+ case "schema":
540
+ return uris.map(uri => ({ kind: "schema", name, uris: [uri] }));
541
+ default:
542
+ return quicktype_core_1.panic(`typeSourceForURIs must not be called for source language ${options.srcLang}`);
543
+ }
544
+ });
552
545
  }
553
- async function getSources(options) {
554
- const sourceURIs = await getSourceURIs(options);
555
- const sourceArrays = await Promise.all(sourceURIs.map(async ([name, uris]) => await typeSourcesForURIs(name, uris, options)));
556
- let sources = [].concat(...sourceArrays);
557
- const exists = options.src.filter(fs.existsSync);
558
- const directories = exists.filter(x => fs.lstatSync(x).isDirectory());
559
- for (const dataDir of directories) {
560
- sources = sources.concat(await samplesFromDirectory(dataDir, options.httpHeader));
561
- }
562
- // Every src that's not a directory is assumed to be a file or URL
563
- const filesOrUrls = options.src.filter(x => !_.includes(directories, x));
564
- if (!_.isEmpty(filesOrUrls)) {
565
- sources.push(...(await typeSourcesForURIs(options.topLevel, filesOrUrls, options)));
566
- }
567
- return sources;
546
+ function getSources(options) {
547
+ return __awaiter(this, void 0, void 0, function* () {
548
+ const sourceURIs = yield getSourceURIs(options);
549
+ const sourceArrays = yield Promise.all(sourceURIs.map(([name, uris]) => __awaiter(this, void 0, void 0, function* () { return yield typeSourcesForURIs(name, uris, options); })));
550
+ let sources = [].concat(...sourceArrays);
551
+ const exists = options.src.filter(fs.existsSync);
552
+ const directories = exists.filter(x => fs.lstatSync(x).isDirectory());
553
+ for (const dataDir of directories) {
554
+ sources = sources.concat(yield samplesFromDirectory(dataDir, options.httpHeader));
555
+ }
556
+ // Every src that's not a directory is assumed to be a file or URL
557
+ const filesOrUrls = options.src.filter(x => !_.includes(directories, x));
558
+ if (!_.isEmpty(filesOrUrls)) {
559
+ sources.push(...(yield typeSourcesForURIs(options.topLevel, filesOrUrls, options)));
560
+ }
561
+ return sources;
562
+ });
568
563
  }
569
564
  function makeTypeScriptSource(fileNames) {
570
- return Object.assign({ kind: "schema" }, (0, quicktype_typescript_input_1.schemaForTypeScriptSources)(fileNames));
565
+ return Object.assign({ kind: "schema" }, quicktype_typescript_input_1.schemaForTypeScriptSources(fileNames));
571
566
  }
572
567
  function jsonInputForTargetLanguage(targetLanguage, languages, handleJSONRefs = false) {
573
568
  if (typeof targetLanguage === "string") {
574
- targetLanguage = (0, quicktype_core_1.defined)((0, quicktype_core_1.languageNamed)(targetLanguage, languages));
569
+ targetLanguage = quicktype_core_1.defined(quicktype_core_1.languageNamed(targetLanguage, languages));
575
570
  }
576
571
  const compressedJSON = new CompressedJSONFromStream_1.CompressedJSONFromStream(targetLanguage.dateTimeRecognizer, handleJSONRefs);
577
572
  return new quicktype_core_1.JSONInput(compressedJSON);
578
573
  }
579
574
  exports.jsonInputForTargetLanguage = jsonInputForTargetLanguage;
580
- async function makeInputData(sources, targetLanguage, additionalSchemaAddresses, handleJSONRefs, httpHeaders) {
581
- const inputData = new quicktype_core_1.InputData();
582
- for (const source of sources) {
583
- switch (source.kind) {
575
+ function makeInputData(sources, targetLanguage, additionalSchemaAddresses, handleJSONRefs, httpHeaders) {
576
+ return __awaiter(this, void 0, void 0, function* () {
577
+ const inputData = new quicktype_core_1.InputData();
578
+ for (const source of sources) {
579
+ switch (source.kind) {
580
+ case "graphql":
581
+ yield inputData.addSource("graphql", source, () => new quicktype_graphql_input_1.GraphQLInput());
582
+ break;
583
+ case "json":
584
+ yield inputData.addSource("json", source, () => jsonInputForTargetLanguage(targetLanguage, undefined, handleJSONRefs));
585
+ break;
586
+ case "schema":
587
+ yield inputData.addSource("schema", source, () => new quicktype_core_1.JSONSchemaInput(new quicktype_core_1.FetchingJSONSchemaStore(httpHeaders), [], additionalSchemaAddresses));
588
+ break;
589
+ default:
590
+ return quicktype_core_1.assertNever(source);
591
+ }
592
+ }
593
+ return inputData;
594
+ });
595
+ }
596
+ function stringSourceDataToStreamSourceData(src) {
597
+ return { name: src.name, description: src.description, samples: src.samples.map(stringToStream) };
598
+ }
599
+ function makeQuicktypeOptions(options, targetLanguages) {
600
+ return __awaiter(this, void 0, void 0, function* () {
601
+ if (options.help) {
602
+ usage(targetLanguages === undefined ? quicktype_core_1.defaultTargetLanguages : targetLanguages);
603
+ return undefined;
604
+ }
605
+ if (options.version) {
606
+ console.log(`quicktype version ${packageJSON.version}`);
607
+ console.log("Visit quicktype.io for more info.");
608
+ return undefined;
609
+ }
610
+ if (options.buildMarkovChain !== undefined) {
611
+ const contents = fs.readFileSync(options.buildMarkovChain).toString();
612
+ const lines = contents.split("\n");
613
+ const mc = quicktype_core_1.trainMarkovChain(lines, 3);
614
+ console.log(JSON.stringify(mc));
615
+ return undefined;
616
+ }
617
+ let sources = [];
618
+ let leadingComments = undefined;
619
+ let fixedTopLevels = false;
620
+ switch (options.srcLang) {
584
621
  case "graphql":
585
- await inputData.addSource("graphql", source, () => new quicktype_graphql_input_1.GraphQLInput());
622
+ let schemaString = undefined;
623
+ let wroteSchemaToFile = false;
624
+ if (options.graphqlIntrospect !== undefined) {
625
+ schemaString = yield GraphQLIntrospection_1.introspectServer(options.graphqlIntrospect, collection_utils_1.withDefault(options.httpMethod, "POST"), collection_utils_1.withDefault(options.httpHeader, []));
626
+ if (options.graphqlSchema !== undefined) {
627
+ fs.writeFileSync(options.graphqlSchema, schemaString);
628
+ wroteSchemaToFile = true;
629
+ }
630
+ }
631
+ const numSources = options.src.length;
632
+ if (numSources !== 1) {
633
+ if (wroteSchemaToFile) {
634
+ // We're done.
635
+ return undefined;
636
+ }
637
+ if (numSources === 0) {
638
+ if (schemaString !== undefined) {
639
+ console.log(schemaString);
640
+ return undefined;
641
+ }
642
+ return quicktype_core_1.messageError("DriverNoGraphQLQueryGiven", {});
643
+ }
644
+ }
645
+ const gqlSources = [];
646
+ for (const queryFile of options.src) {
647
+ let schemaFileName = undefined;
648
+ if (schemaString === undefined) {
649
+ schemaFileName = quicktype_core_1.defined(options.graphqlSchema);
650
+ schemaString = fs.readFileSync(schemaFileName, "utf8");
651
+ }
652
+ const schema = quicktype_core_1.parseJSON(schemaString, "GraphQL schema", schemaFileName);
653
+ const query = yield quicktype_core_1.getStream(yield quicktype_core_1.readableFromFileOrURL(queryFile, options.httpHeader));
654
+ const name = numSources === 1 ? options.topLevel : typeNameFromFilename(queryFile);
655
+ gqlSources.push({ kind: "graphql", name, schema, query });
656
+ }
657
+ sources = gqlSources;
586
658
  break;
587
659
  case "json":
588
- await inputData.addSource("json", source, () => jsonInputForTargetLanguage(targetLanguage, undefined, handleJSONRefs));
589
- break;
590
660
  case "schema":
591
- await inputData.addSource("schema", source, () => new quicktype_core_1.JSONSchemaInput(new quicktype_core_1.FetchingJSONSchemaStore(httpHeaders), [], additionalSchemaAddresses));
661
+ sources = yield getSources(options);
662
+ break;
663
+ case "typescript":
664
+ sources = [makeTypeScriptSource(options.src)];
665
+ break;
666
+ case "postman":
667
+ for (const collectionFile of options.src) {
668
+ const collectionJSON = fs.readFileSync(collectionFile, "utf8");
669
+ const { sources: postmanSources, description } = quicktype_core_1.sourcesFromPostmanCollection(collectionJSON, collectionFile);
670
+ for (const src of postmanSources) {
671
+ sources.push(Object.assign({ kind: "json" }, stringSourceDataToStreamSourceData(src)));
672
+ }
673
+ if (postmanSources.length > 1) {
674
+ fixedTopLevels = true;
675
+ }
676
+ if (description !== undefined) {
677
+ leadingComments = wordWrap(description).split("\n");
678
+ }
679
+ }
592
680
  break;
593
681
  default:
594
- return (0, quicktype_core_1.assertNever)(source);
682
+ return quicktype_core_1.messageError("DriverUnknownSourceLanguage", { lang: options.srcLang });
595
683
  }
596
- }
597
- return inputData;
598
- }
599
- function stringSourceDataToStreamSourceData(src) {
600
- return { name: src.name, description: src.description, samples: src.samples.map(stringToStream) };
601
- }
602
- async function makeQuicktypeOptions(options, targetLanguages) {
603
- if (options.help) {
604
- usage(targetLanguages === undefined ? quicktype_core_1.defaultTargetLanguages : targetLanguages);
605
- return undefined;
606
- }
607
- if (options.version) {
608
- console.log(`quicktype version ${packageJSON.version}`);
609
- console.log("Visit quicktype.io for more info.");
610
- return undefined;
611
- }
612
- if (options.buildMarkovChain !== undefined) {
613
- const contents = fs.readFileSync(options.buildMarkovChain).toString();
614
- const lines = contents.split("\n");
615
- const mc = (0, quicktype_core_1.trainMarkovChain)(lines, 3);
616
- console.log(JSON.stringify(mc));
617
- return undefined;
618
- }
619
- let sources = [];
620
- let leadingComments = undefined;
621
- let fixedTopLevels = false;
622
- switch (options.srcLang) {
623
- case "graphql":
624
- let schemaString = undefined;
625
- let wroteSchemaToFile = false;
626
- if (options.graphqlIntrospect !== undefined) {
627
- schemaString = await (0, GraphQLIntrospection_1.introspectServer)(options.graphqlIntrospect, (0, collection_utils_1.withDefault)(options.httpMethod, "POST"), (0, collection_utils_1.withDefault)(options.httpHeader, []));
628
- if (options.graphqlSchema !== undefined) {
629
- fs.writeFileSync(options.graphqlSchema, schemaString);
630
- wroteSchemaToFile = true;
684
+ const components = collection_utils_1.definedMap(options.debug, d => d.split(","));
685
+ const debugAll = components !== undefined && components.indexOf("all") >= 0;
686
+ let debugPrintGraph = debugAll;
687
+ let checkProvenance = debugAll;
688
+ let debugPrintReconstitution = debugAll;
689
+ let debugPrintGatherNames = debugAll;
690
+ let debugPrintTransformations = debugAll;
691
+ let debugPrintSchemaResolving = debugAll;
692
+ let debugPrintTimes = debugAll;
693
+ if (components !== undefined) {
694
+ for (let component of components) {
695
+ component = component.trim();
696
+ if (component === "print-graph") {
697
+ debugPrintGraph = true;
631
698
  }
632
- }
633
- const numSources = options.src.length;
634
- if (numSources !== 1) {
635
- if (wroteSchemaToFile) {
636
- // We're done.
637
- return undefined;
699
+ else if (component === "print-reconstitution") {
700
+ debugPrintReconstitution = true;
638
701
  }
639
- if (numSources === 0) {
640
- if (schemaString !== undefined) {
641
- console.log(schemaString);
642
- return undefined;
643
- }
644
- return (0, quicktype_core_1.messageError)("DriverNoGraphQLQueryGiven", {});
702
+ else if (component === "print-gather-names") {
703
+ debugPrintGatherNames = true;
645
704
  }
646
- }
647
- const gqlSources = [];
648
- for (const queryFile of options.src) {
649
- let schemaFileName = undefined;
650
- if (schemaString === undefined) {
651
- schemaFileName = (0, quicktype_core_1.defined)(options.graphqlSchema);
652
- schemaString = fs.readFileSync(schemaFileName, "utf8");
705
+ else if (component === "print-transformations") {
706
+ debugPrintTransformations = true;
653
707
  }
654
- const schema = (0, quicktype_core_1.parseJSON)(schemaString, "GraphQL schema", schemaFileName);
655
- const query = await (0, quicktype_core_1.getStream)(await (0, quicktype_core_1.readableFromFileOrURL)(queryFile, options.httpHeader));
656
- const name = numSources === 1 ? options.topLevel : typeNameFromFilename(queryFile);
657
- gqlSources.push({ kind: "graphql", name, schema, query });
658
- }
659
- sources = gqlSources;
660
- break;
661
- case "json":
662
- case "schema":
663
- sources = await getSources(options);
664
- break;
665
- case "typescript":
666
- sources = [makeTypeScriptSource(options.src)];
667
- break;
668
- case "postman":
669
- for (const collectionFile of options.src) {
670
- const collectionJSON = fs.readFileSync(collectionFile, "utf8");
671
- const { sources: postmanSources, description } = (0, quicktype_core_1.sourcesFromPostmanCollection)(collectionJSON, collectionFile);
672
- for (const src of postmanSources) {
673
- sources.push(Object.assign({ kind: "json" }, stringSourceDataToStreamSourceData(src)));
708
+ else if (component === "print-times") {
709
+ debugPrintTimes = true;
674
710
  }
675
- if (postmanSources.length > 1) {
676
- fixedTopLevels = true;
711
+ else if (component === "print-schema-resolving") {
712
+ debugPrintSchemaResolving = true;
677
713
  }
678
- if (description !== undefined) {
679
- leadingComments = wordWrap(description).split("\n");
714
+ else if (component === "provenance") {
715
+ checkProvenance = true;
716
+ }
717
+ else if (component !== "all") {
718
+ return quicktype_core_1.messageError("DriverUnknownDebugOption", { option: component });
680
719
  }
681
- }
682
- break;
683
- default:
684
- return (0, quicktype_core_1.messageError)("DriverUnknownSourceLanguage", { lang: options.srcLang });
685
- }
686
- const components = (0, collection_utils_1.definedMap)(options.debug, d => d.split(","));
687
- const debugAll = components !== undefined && components.indexOf("all") >= 0;
688
- let debugPrintGraph = debugAll;
689
- let checkProvenance = debugAll;
690
- let debugPrintReconstitution = debugAll;
691
- let debugPrintGatherNames = debugAll;
692
- let debugPrintTransformations = debugAll;
693
- let debugPrintSchemaResolving = debugAll;
694
- let debugPrintTimes = debugAll;
695
- if (components !== undefined) {
696
- for (let component of components) {
697
- component = component.trim();
698
- if (component === "print-graph") {
699
- debugPrintGraph = true;
700
- }
701
- else if (component === "print-reconstitution") {
702
- debugPrintReconstitution = true;
703
- }
704
- else if (component === "print-gather-names") {
705
- debugPrintGatherNames = true;
706
- }
707
- else if (component === "print-transformations") {
708
- debugPrintTransformations = true;
709
- }
710
- else if (component === "print-times") {
711
- debugPrintTimes = true;
712
- }
713
- else if (component === "print-schema-resolving") {
714
- debugPrintSchemaResolving = true;
715
- }
716
- else if (component === "provenance") {
717
- checkProvenance = true;
718
- }
719
- else if (component !== "all") {
720
- return (0, quicktype_core_1.messageError)("DriverUnknownDebugOption", { option: component });
721
720
  }
722
721
  }
723
- }
724
- const lang = (0, quicktype_core_1.languageNamed)(options.lang, targetLanguages);
725
- if (lang === undefined) {
726
- return (0, quicktype_core_1.messageError)("DriverUnknownOutputLanguage", { lang: options.lang });
727
- }
728
- const quicktypeOptions = {
729
- lang,
730
- alphabetizeProperties: options.alphabetizeProperties,
731
- allPropertiesOptional: options.allPropertiesOptional,
732
- fixedTopLevels,
733
- noRender: options.noRender,
734
- rendererOptions: options.rendererOptions,
735
- leadingComments,
736
- outputFilename: (0, collection_utils_1.definedMap)(options.out, path.basename),
737
- debugPrintGraph,
738
- checkProvenance,
739
- debugPrintReconstitution,
740
- debugPrintGatherNames,
741
- debugPrintTransformations,
742
- debugPrintSchemaResolving,
743
- debugPrintTimes
744
- };
745
- for (const flagName of quicktype_core_1.inferenceFlagNames) {
746
- const cliName = negatedInferenceFlagName(flagName);
747
- const v = options[cliName];
748
- if (typeof v === "boolean") {
749
- quicktypeOptions[flagName] = !v;
722
+ const lang = quicktype_core_1.languageNamed(options.lang, targetLanguages);
723
+ if (lang === undefined) {
724
+ return quicktype_core_1.messageError("DriverUnknownOutputLanguage", { lang: options.lang });
750
725
  }
751
- else {
752
- quicktypeOptions[flagName] = true;
726
+ const quicktypeOptions = {
727
+ lang,
728
+ alphabetizeProperties: options.alphabetizeProperties,
729
+ allPropertiesOptional: options.allPropertiesOptional,
730
+ fixedTopLevels,
731
+ noRender: options.noRender,
732
+ rendererOptions: options.rendererOptions,
733
+ leadingComments,
734
+ outputFilename: collection_utils_1.definedMap(options.out, path.basename),
735
+ debugPrintGraph,
736
+ checkProvenance,
737
+ debugPrintReconstitution,
738
+ debugPrintGatherNames,
739
+ debugPrintTransformations,
740
+ debugPrintSchemaResolving,
741
+ debugPrintTimes
742
+ };
743
+ for (const flagName of quicktype_core_1.inferenceFlagNames) {
744
+ const cliName = negatedInferenceFlagName(flagName);
745
+ const v = options[cliName];
746
+ if (typeof v === "boolean") {
747
+ quicktypeOptions[flagName] = !v;
748
+ }
749
+ else {
750
+ quicktypeOptions[flagName] = true;
751
+ }
753
752
  }
754
- }
755
- quicktypeOptions.inputData = await makeInputData(sources, lang, options.additionalSchema, quicktypeOptions.ignoreJsonRefs !== true, options.httpHeader);
756
- return quicktypeOptions;
753
+ quicktypeOptions.inputData = yield makeInputData(sources, lang, options.additionalSchema, quicktypeOptions.ignoreJsonRefs !== true, options.httpHeader);
754
+ return quicktypeOptions;
755
+ });
757
756
  }
758
757
  exports.makeQuicktypeOptions = makeQuicktypeOptions;
759
758
  function writeOutput(cliOptions, resultsByFilename) {
@@ -788,34 +787,36 @@ function writeOutput(cliOptions, resultsByFilename) {
788
787
  }
789
788
  }
790
789
  exports.writeOutput = writeOutput;
791
- async function main(args) {
792
- let cliOptions;
793
- if (Array.isArray(args)) {
794
- cliOptions = parseCLIOptions(args);
795
- }
796
- else {
797
- cliOptions = inferCLIOptions(args, undefined);
798
- }
799
- if (cliOptions.telemetry !== undefined) {
800
- switch (cliOptions.telemetry) {
801
- case "enable":
802
- break;
803
- case "disable":
804
- break;
805
- default:
806
- console.error(chalk.red("telemetry must be 'enable' or 'disable'"));
790
+ function main(args) {
791
+ return __awaiter(this, void 0, void 0, function* () {
792
+ let cliOptions;
793
+ if (Array.isArray(args)) {
794
+ cliOptions = parseCLIOptions(args);
795
+ }
796
+ else {
797
+ cliOptions = inferCLIOptions(args, undefined);
798
+ }
799
+ if (cliOptions.telemetry !== undefined) {
800
+ switch (cliOptions.telemetry) {
801
+ case "enable":
802
+ break;
803
+ case "disable":
804
+ break;
805
+ default:
806
+ console.error(chalk.red("telemetry must be 'enable' or 'disable'"));
807
+ return;
808
+ }
809
+ if (Array.isArray(args) && args.length === 2) {
810
+ // This was merely a CLI run to set telemetry and we should not proceed
807
811
  return;
812
+ }
808
813
  }
809
- if (Array.isArray(args) && args.length === 2) {
810
- // This was merely a CLI run to set telemetry and we should not proceed
814
+ const quicktypeOptions = yield makeQuicktypeOptions(cliOptions);
815
+ if (quicktypeOptions === undefined)
811
816
  return;
812
- }
813
- }
814
- const quicktypeOptions = await makeQuicktypeOptions(cliOptions);
815
- if (quicktypeOptions === undefined)
816
- return;
817
- const resultsByFilename = await (0, quicktype_core_1.quicktypeMultiFile)(quicktypeOptions);
818
- writeOutput(cliOptions, resultsByFilename);
817
+ const resultsByFilename = yield quicktype_core_1.quicktypeMultiFile(quicktypeOptions);
818
+ writeOutput(cliOptions, resultsByFilename);
819
+ });
819
820
  }
820
821
  exports.main = main;
821
822
  if (require.main === module) {