quicktype 17.0.4 → 17.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/cli/CompressedJSONFromStream.js +38 -26
  2. package/dist/cli/GraphQLIntrospection.js +41 -33
  3. package/dist/cli/TypeSource.d.ts +1 -1
  4. package/dist/cli/URLGrammar.js +3 -4
  5. package/dist/cli/index.js +364 -363
  6. package/dist/quicktype-core/Annotation.js +0 -2
  7. package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
  8. package/dist/quicktype-core/ConvenienceRenderer.js +81 -104
  9. package/dist/quicktype-core/DateTime.js +0 -1
  10. package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
  11. package/dist/quicktype-core/DeclarationIR.js +10 -13
  12. package/dist/quicktype-core/EncodedMarkovChain.js +0 -1
  13. package/dist/quicktype-core/GatherNames.js +25 -47
  14. package/dist/quicktype-core/Graph.d.ts +2 -2
  15. package/dist/quicktype-core/Graph.js +19 -23
  16. package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
  17. package/dist/quicktype-core/GraphRewriting.js +54 -65
  18. package/dist/quicktype-core/MakeTransformations.js +22 -23
  19. package/dist/quicktype-core/MarkovChain.d.ts +3 -3
  20. package/dist/quicktype-core/MarkovChain.js +8 -9
  21. package/dist/quicktype-core/Messages.d.ts +3 -3
  22. package/dist/quicktype-core/Messages.js +3 -8
  23. package/dist/quicktype-core/Naming.d.ts +11 -11
  24. package/dist/quicktype-core/Naming.js +61 -76
  25. package/dist/quicktype-core/Renderer.d.ts +6 -6
  26. package/dist/quicktype-core/Renderer.js +17 -34
  27. package/dist/quicktype-core/RendererOptions.d.ts +5 -5
  28. package/dist/quicktype-core/RendererOptions.js +3 -6
  29. package/dist/quicktype-core/Run.d.ts +9 -9
  30. package/dist/quicktype-core/Run.js +67 -72
  31. package/dist/quicktype-core/Source.d.ts +3 -3
  32. package/dist/quicktype-core/Source.js +18 -19
  33. package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
  34. package/dist/quicktype-core/TargetLanguage.js +2 -6
  35. package/dist/quicktype-core/Transformers.d.ts +25 -25
  36. package/dist/quicktype-core/Transformers.js +66 -94
  37. package/dist/quicktype-core/Type.d.ts +43 -41
  38. package/dist/quicktype-core/Type.js +71 -96
  39. package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
  40. package/dist/quicktype-core/TypeBuilder.js +47 -53
  41. package/dist/quicktype-core/TypeGraph.d.ts +4 -4
  42. package/dist/quicktype-core/TypeGraph.js +40 -49
  43. package/dist/quicktype-core/TypeUtils.d.ts +2 -2
  44. package/dist/quicktype-core/TypeUtils.js +22 -23
  45. package/dist/quicktype-core/UnifyClasses.js +12 -16
  46. package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
  47. package/dist/quicktype-core/UnionBuilder.js +30 -33
  48. package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
  49. package/dist/quicktype-core/attributes/AccessorNames.js +17 -18
  50. package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
  51. package/dist/quicktype-core/attributes/Constraints.js +4 -8
  52. package/dist/quicktype-core/attributes/Description.js +5 -6
  53. package/dist/quicktype-core/attributes/EnumValues.js +3 -4
  54. package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
  55. package/dist/quicktype-core/attributes/StringTypes.js +21 -24
  56. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
  57. package/dist/quicktype-core/attributes/TypeAttributes.js +10 -12
  58. package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
  59. package/dist/quicktype-core/attributes/TypeNames.js +21 -49
  60. package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
  61. package/dist/quicktype-core/attributes/URIAttributes.js +6 -10
  62. package/dist/quicktype-core/index.js +125 -128
  63. package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
  64. package/dist/quicktype-core/input/CompressedJSON.js +54 -49
  65. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +13 -5
  66. package/dist/quicktype-core/input/Inference.d.ts +2 -2
  67. package/dist/quicktype-core/input/Inference.js +17 -25
  68. package/dist/quicktype-core/input/Inputs.d.ts +2 -2
  69. package/dist/quicktype-core/input/Inputs.js +54 -38
  70. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
  71. package/dist/quicktype-core/input/JSONSchemaInput.js +523 -503
  72. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
  73. package/dist/quicktype-core/input/JSONSchemaStore.js +35 -24
  74. package/dist/quicktype-core/input/PostmanCollection.js +1 -2
  75. package/dist/quicktype-core/input/io/NodeIO.js +44 -55
  76. package/dist/quicktype-core/input/io/get-stream/index.js +2 -6
  77. package/dist/quicktype-core/language/All.js +2 -3
  78. package/dist/quicktype-core/language/CPlusPlus.d.ts +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +249 -251
  80. package/dist/quicktype-core/language/CSharp.d.ts +7 -7
  81. package/dist/quicktype-core/language/CSharp.js +72 -82
  82. package/dist/quicktype-core/language/Crystal.d.ts +2 -2
  83. package/dist/quicktype-core/language/Crystal.js +17 -18
  84. package/dist/quicktype-core/language/Dart.d.ts +4 -4
  85. package/dist/quicktype-core/language/Dart.js +34 -36
  86. package/dist/quicktype-core/language/Elm.d.ts +6 -6
  87. package/dist/quicktype-core/language/Elm.js +45 -47
  88. package/dist/quicktype-core/language/Golang.d.ts +4 -4
  89. package/dist/quicktype-core/language/Golang.js +20 -23
  90. package/dist/quicktype-core/language/Haskell.d.ts +5 -5
  91. package/dist/quicktype-core/language/Haskell.js +23 -25
  92. package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
  93. package/dist/quicktype-core/language/JSONSchema.js +16 -17
  94. package/dist/quicktype-core/language/Java.d.ts +2 -2
  95. package/dist/quicktype-core/language/Java.js +97 -97
  96. package/dist/quicktype-core/language/JavaScript.d.ts +7 -7
  97. package/dist/quicktype-core/language/JavaScript.js +17 -19
  98. package/dist/quicktype-core/language/JavaScriptPropTypes.js +13 -15
  99. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +11 -12
  100. package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
  101. package/dist/quicktype-core/language/Kotlin.js +37 -39
  102. package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
  103. package/dist/quicktype-core/language/Objective-C.js +41 -45
  104. package/dist/quicktype-core/language/Php.d.ts +2 -2
  105. package/dist/quicktype-core/language/Php.js +41 -66
  106. package/dist/quicktype-core/language/Pike.d.ts +1 -1
  107. package/dist/quicktype-core/language/Pike.js +17 -18
  108. package/dist/quicktype-core/language/Python.d.ts +8 -8
  109. package/dist/quicktype-core/language/Python.js +64 -63
  110. package/dist/quicktype-core/language/Rust.d.ts +2 -2
  111. package/dist/quicktype-core/language/Rust.js +19 -21
  112. package/dist/quicktype-core/language/Swift.d.ts +7 -7
  113. package/dist/quicktype-core/language/Swift.js +804 -807
  114. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
  115. package/dist/quicktype-core/language/TypeScriptFlow.js +26 -28
  116. package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
  117. package/dist/quicktype-core/language/ruby/index.js +24 -49
  118. package/dist/quicktype-core/language/ruby/keywords.js +0 -1
  119. package/dist/quicktype-core/rewrites/CombineClasses.js +8 -9
  120. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
  121. package/dist/quicktype-core/rewrites/ExpandStrings.js +17 -18
  122. package/dist/quicktype-core/rewrites/FlattenStrings.js +6 -7
  123. package/dist/quicktype-core/rewrites/FlattenUnions.js +8 -9
  124. package/dist/quicktype-core/rewrites/InferMaps.js +10 -11
  125. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +7 -8
  126. package/dist/quicktype-core/rewrites/ResolveIntersections.js +67 -68
  127. package/dist/quicktype-core/support/Acronyms.js +1 -3
  128. package/dist/quicktype-core/support/Chance.js +0 -10
  129. package/dist/quicktype-core/support/Converters.js +0 -1
  130. package/dist/quicktype-core/support/Strings.d.ts +4 -4
  131. package/dist/quicktype-core/support/Strings.js +16 -17
  132. package/dist/quicktype-core/support/Support.d.ts +1 -1
  133. package/dist/quicktype-core/support/Support.js +6 -30
  134. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
  135. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -1
  136. package/dist/quicktype-graphql-input/index.d.ts +1 -1
  137. package/dist/quicktype-graphql-input/index.js +212 -229
  138. package/dist/quicktype-typescript-input/index.js +4 -28
  139. package/package.json +19 -25
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CompressedJSONFromStream = void 0;
4
11
  const CompressedJSON_1 = require("../quicktype-core/input/CompressedJSON");
5
12
  const { Parser } = require("stream-json");
6
13
  const methodMap = {
@@ -18,36 +25,41 @@ const methodMap = {
18
25
  falseValue: "handleFalseValue"
19
26
  };
20
27
  class CompressedJSONFromStream extends CompressedJSON_1.CompressedJSON {
21
- async parse(readStream) {
22
- const combo = new Parser({ packKeys: true, packStrings: true });
23
- combo.on("data", (item) => {
24
- if (typeof methodMap[item.name] === "string") {
25
- this[methodMap[item.name]](item.value);
28
+ constructor() {
29
+ super(...arguments);
30
+ this.handleStartNumber = () => {
31
+ this.pushContext();
32
+ this.context.currentNumberIsDouble = false;
33
+ };
34
+ this.handleNumberChunk = (s) => {
35
+ const ctx = this.context;
36
+ if (!ctx.currentNumberIsDouble && /[\.e]/i.test(s)) {
37
+ ctx.currentNumberIsDouble = true;
26
38
  }
27
- });
28
- const promise = new Promise((resolve, reject) => {
29
- combo.on("end", () => {
30
- resolve(this.finish());
39
+ };
40
+ }
41
+ parse(readStream) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const combo = new Parser({ packKeys: true, packStrings: true });
44
+ combo.on("data", (item) => {
45
+ if (typeof methodMap[item.name] === "string") {
46
+ this[methodMap[item.name]](item.value);
47
+ }
31
48
  });
32
- combo.on("error", (err) => {
33
- reject(err);
49
+ const promise = new Promise((resolve, reject) => {
50
+ combo.on("end", () => {
51
+ resolve(this.finish());
52
+ });
53
+ combo.on("error", (err) => {
54
+ reject(err);
55
+ });
34
56
  });
57
+ readStream.setEncoding("utf8");
58
+ readStream.pipe(combo);
59
+ readStream.resume();
60
+ return promise;
35
61
  });
36
- readStream.setEncoding("utf8");
37
- readStream.pipe(combo);
38
- readStream.resume();
39
- return promise;
40
62
  }
41
- handleStartNumber = () => {
42
- this.pushContext();
43
- this.context.currentNumberIsDouble = false;
44
- };
45
- handleNumberChunk = (s) => {
46
- const ctx = this.context;
47
- if (!ctx.currentNumberIsDouble && /[\.e]/i.test(s)) {
48
- ctx.currentNumberIsDouble = true;
49
- }
50
- };
51
63
  handleEndNumber() {
52
64
  const isDouble = this.context.currentNumberIsDouble;
53
65
  this.popContext();
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
2
10
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.introspectServer = void 0;
4
11
  const quicktype_core_1 = require("../quicktype-core");
5
12
  const graphql_1 = require("graphql");
6
- const ts_necessities_1 = require("@glideapps/ts-necessities");
7
13
  const fetch = require("node-fetch");
8
14
  // https://github.com/apollographql/apollo-codegen/blob/master/src/downloadSchema.ts
9
15
  const defaultHeaders = {
@@ -11,37 +17,39 @@ const defaultHeaders = {
11
17
  "Content-Type": "application/json"
12
18
  };
13
19
  const headerRegExp = /^([^:]+):\s*(.*)$/;
14
- async function introspectServer(url, method, headerStrings) {
15
- const headers = {};
16
- for (const name of Object.getOwnPropertyNames(defaultHeaders)) {
17
- headers[name] = defaultHeaders[name];
18
- }
19
- for (const str of headerStrings) {
20
- const matches = str.match(headerRegExp);
21
- if (matches === null) {
22
- return (0, quicktype_core_1.panic)(`Not a valid HTTP header: "${str}"`);
20
+ function introspectServer(url, method, headerStrings) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const headers = {};
23
+ for (const name of Object.getOwnPropertyNames(defaultHeaders)) {
24
+ headers[name] = defaultHeaders[name];
25
+ }
26
+ for (const str of headerStrings) {
27
+ const matches = str.match(headerRegExp);
28
+ if (matches === null) {
29
+ return quicktype_core_1.panic(`Not a valid HTTP header: "${str}"`);
30
+ }
31
+ headers[matches[1]] = matches[2];
32
+ }
33
+ let result;
34
+ try {
35
+ const response = yield fetch(url, {
36
+ method,
37
+ headers: headers,
38
+ body: JSON.stringify({ query: graphql_1.introspectionQuery })
39
+ });
40
+ result = yield response.json();
41
+ }
42
+ catch (error) {
43
+ return quicktype_core_1.panic(`Error while fetching introspection query result: ${error.message}`);
44
+ }
45
+ if (result.errors) {
46
+ return quicktype_core_1.panic(`Errors in introspection query result: ${JSON.stringify(result.errors)}`);
47
+ }
48
+ const schemaData = result;
49
+ if (!schemaData.data) {
50
+ return quicktype_core_1.panic(`No introspection query result data found, server responded with: ${JSON.stringify(result)}`);
23
51
  }
24
- headers[matches[1]] = matches[2];
25
- }
26
- let result;
27
- try {
28
- const response = await fetch(url, {
29
- method,
30
- headers: headers,
31
- body: JSON.stringify({ query: graphql_1.introspectionQuery })
32
- });
33
- result = await response.json();
34
- }
35
- catch (error) {
36
- return (0, quicktype_core_1.panic)(`Error while fetching introspection query result: ${(0, ts_necessities_1.exceptionToString)(error)}`);
37
- }
38
- if (result.errors) {
39
- return (0, quicktype_core_1.panic)(`Errors in introspection query result: ${JSON.stringify(result.errors)}`);
40
- }
41
- const schemaData = result;
42
- if (!schemaData.data) {
43
- return (0, quicktype_core_1.panic)(`No introspection query result data found, server responded with: ${JSON.stringify(result)}`);
44
- }
45
- return JSON.stringify(schemaData, null, 2);
52
+ return JSON.stringify(schemaData, null, 2);
53
+ });
46
54
  }
47
55
  exports.introspectServer = introspectServer;
@@ -10,4 +10,4 @@ export interface SchemaTypeSource extends JSONSchemaSourceData {
10
10
  export interface GraphQLTypeSource extends GraphQLSourceData {
11
11
  kind: "graphql";
12
12
  }
13
- export type TypeSource = GraphQLTypeSource | JSONTypeSource | SchemaTypeSource;
13
+ export declare type TypeSource = GraphQLTypeSource | JSONTypeSource | SchemaTypeSource;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.urlsFromURLGrammar = void 0;
4
3
  const quicktype_core_1 = require("../quicktype-core");
5
4
  function expand(json) {
6
5
  if (typeof json === "string") {
@@ -21,7 +20,7 @@ function expand(json) {
21
20
  return result;
22
21
  }
23
22
  if (Object.prototype.hasOwnProperty.call(json, "oneOf")) {
24
- const options = (0, quicktype_core_1.checkArray)(json.oneOf);
23
+ const options = quicktype_core_1.checkArray(json.oneOf);
25
24
  const result = [];
26
25
  for (const j of options) {
27
26
  for (const x of expand(j)) {
@@ -30,10 +29,10 @@ function expand(json) {
30
29
  }
31
30
  return result;
32
31
  }
33
- return (0, quicktype_core_1.panic)(`Value is not a valid URL grammar: ${json}`);
32
+ return quicktype_core_1.panic(`Value is not a valid URL grammar: ${json}`);
34
33
  }
35
34
  function urlsFromURLGrammar(json) {
36
- const topLevelMap = (0, quicktype_core_1.checkStringMap)(json);
35
+ const topLevelMap = quicktype_core_1.checkStringMap(json);
37
36
  const results = {};
38
37
  for (const name of Object.getOwnPropertyNames(topLevelMap)) {
39
38
  results[name] = expand(topLevelMap[name]);