quicktype 17.0.6 → 18.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 +36 -34
  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 +24 -20
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeNameStyle = exports.addPrefixIfNecessary = exports.combineWords = exports.allLowerWordStyle = exports.originalWord = exports.allUpperWordStyle = exports.firstUpperWordStyle = exports.splitIntoWords = exports.fastIsUpperCase = exports.startWithLetter = exports.snakeCase = exports.camelCase = exports.pascalCase = exports.decapitalize = exports.capitalize = exports.trimEnd = exports.isWordCharacter = exports.isLetterOrUnderscoreOrDigit = exports.isLetterOrUnderscore = exports.isLetterOrDigit = exports.isNumeric = exports.isDigit = exports.isLetter = exports.isAscii = exports.isPrintable = exports.stringEscape = exports.utf16StringEscape = exports.escapeNonPrintableMapper = exports.standardUnicodeHexEscape = exports.intToHex = exports.repeatString = exports.legalizeCharacters = exports.utf16LegalizeCharacters = exports.utf32ConcatMap = exports.utf16ConcatMap = void 0;
3
4
  const Support_1 = require("./Support");
4
5
  const Acronyms_1 = require("./Acronyms");
5
6
  const Messages_1 = require("../Messages");
@@ -80,7 +81,7 @@ function utf32ConcatMap(mapper) {
80
81
  const highSurrogate = cc;
81
82
  i++;
82
83
  const lowSurrogate = s.charCodeAt(i);
83
- Messages_1.messageAssert(isLowSurrogate(lowSurrogate), "MiscUnicodeHighSurrogateWithoutLowSurrogate", {});
84
+ (0, Messages_1.messageAssert)(isLowSurrogate(lowSurrogate), "MiscUnicodeHighSurrogateWithoutLowSurrogate", {});
84
85
  const highBits = highSurrogate - 0xd800;
85
86
  const lowBits = lowSurrogate - 0xdc00;
86
87
  cc = 0x10000 + lowBits + (highBits << 10);
@@ -112,7 +113,7 @@ function legalizeCharacters(isLegal) {
112
113
  }
113
114
  exports.legalizeCharacters = legalizeCharacters;
114
115
  function repeatString(s, n) {
115
- Support_1.assert(n >= 0, "Cannot repeat a string a negative number of times");
116
+ (0, Support_1.assert)(n >= 0, "Cannot repeat a string a negative number of times");
116
117
  if (n === 0)
117
118
  return "";
118
119
  // From https://github.com/lodash/lodash
@@ -306,7 +307,7 @@ function splitIntoWords(s) {
306
307
  return i >= len;
307
308
  }
308
309
  function currentCodePoint() {
309
- return Support_1.defined(s.codePointAt(i));
310
+ return (0, Support_1.defined)(s.codePointAt(i));
310
311
  }
311
312
  function skipWhile(p) {
312
313
  while (!atEnd()) {
@@ -334,14 +335,14 @@ function splitIntoWords(s) {
334
335
  skipWhile(fastIsDigit);
335
336
  }
336
337
  function startInterval() {
337
- Support_1.assert(intervalStart === undefined, "Interval started before last one was committed");
338
+ (0, Support_1.assert)(intervalStart === undefined, "Interval started before last one was committed");
338
339
  intervalStart = i;
339
340
  }
340
341
  function commitInterval() {
341
342
  if (intervalStart === undefined) {
342
- return Support_1.panic("Tried to commit interval without starting one");
343
+ return (0, Support_1.panic)("Tried to commit interval without starting one");
343
344
  }
344
- Support_1.assert(i > intervalStart, "Interval must be non-empty");
345
+ (0, Support_1.assert)(i > intervalStart, "Interval must be non-empty");
345
346
  // FIXME: This is a hack to avoid splitting up surrogates. We shouldn't
346
347
  // look at surrogates individually in the first place. When we
347
348
  // encounter a high surrogate we have to combine it with the low
@@ -356,7 +357,7 @@ function splitIntoWords(s) {
356
357
  }
357
358
  function intervalLength() {
358
359
  if (intervalStart === undefined) {
359
- return Support_1.panic("Tried to get interval length without starting one");
360
+ return (0, Support_1.panic)("Tried to get interval length without starting one");
360
361
  }
361
362
  return i - intervalStart;
362
363
  }
@@ -370,7 +371,7 @@ function splitIntoWords(s) {
370
371
  skipDigits();
371
372
  commitInterval();
372
373
  }
373
- else if (exports.fastIsUpperCase(currentCodePoint())) {
374
+ else if ((0, exports.fastIsUpperCase)(currentCodePoint())) {
374
375
  skipUpperCase();
375
376
  if (atEnd()) {
376
377
  commitInterval();
@@ -406,7 +407,7 @@ function splitIntoWords(s) {
406
407
  }
407
408
  exports.splitIntoWords = splitIntoWords;
408
409
  function firstUpperWordStyle(s) {
409
- Support_1.assert(s.length > 0, "Cannot style an empty string");
410
+ (0, Support_1.assert)(s.length > 0, "Cannot style an empty string");
410
411
  return s[0].toUpperCase() + s.slice(1).toLowerCase();
411
412
  }
412
413
  exports.firstUpperWordStyle = firstUpperWordStyle;
@@ -423,9 +424,9 @@ function allLowerWordStyle(s) {
423
424
  }
424
425
  exports.allLowerWordStyle = allLowerWordStyle;
425
426
  function styleWord(style, word) {
426
- Support_1.assert(word.length > 0, "Tried to style an empty word");
427
+ (0, Support_1.assert)(word.length > 0, "Tried to style an empty word");
427
428
  const result = style(word);
428
- Support_1.assert(result.length > 0, "Word style must not make word empty");
429
+ (0, Support_1.assert)(result.length > 0, "Word style must not make word empty");
429
430
  return result;
430
431
  }
431
432
  function combineWords(words, removeInvalidCharacters, firstWordStyle, restWordStyle, firstWordAcronymStyle, restAcronymStyle, separator, isStartCharacter) {
@@ -438,7 +439,7 @@ function combineWords(words, removeInvalidCharacters, firstWordStyle, restWordSt
438
439
  }
439
440
  if (legalizedWords.length === 0) {
440
441
  const validEmpty = removeInvalidCharacters("empty");
441
- Support_1.assert(validEmpty.length > 0, 'Word "empty" is invalid in target language');
442
+ (0, Support_1.assert)(validEmpty.length > 0, 'Word "empty" is invalid in target language');
442
443
  legalizedWords.push({ word: validEmpty, isAcronym: false });
443
444
  }
444
445
  const styledWords = [];
@@ -446,11 +447,11 @@ function combineWords(words, removeInvalidCharacters, firstWordStyle, restWordSt
446
447
  const firstStyle = first.isAcronym ? firstWordAcronymStyle : firstWordStyle;
447
448
  const styledFirstWord = styleWord(firstStyle, first.word);
448
449
  let restWords;
449
- if (!isStartCharacter(Support_1.defined(styledFirstWord.codePointAt(0)))) {
450
+ if (!isStartCharacter((0, Support_1.defined)(styledFirstWord.codePointAt(0)))) {
450
451
  const validThe = removeInvalidCharacters("the");
451
- Support_1.assert(validThe.length > 0, 'Word "the" is invalid in the target language');
452
+ (0, Support_1.assert)(validThe.length > 0, 'Word "the" is invalid in the target language');
452
453
  const styledThe = styleWord(firstWordStyle, validThe);
453
- Support_1.assert(isStartCharacter(Support_1.defined(styledThe.codePointAt(0))), 'The first character of styling "the" is not a start character');
454
+ (0, Support_1.assert)(isStartCharacter((0, Support_1.defined)(styledThe.codePointAt(0))), 'The first character of styling "the" is not a start character');
454
455
  styledWords.push(styledThe);
455
456
  restWords = legalizedWords;
456
457
  }
@@ -508,7 +509,7 @@ function makeNameStyle(namingStyle, legalizeName, prefix) {
508
509
  firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allUpperWordStyle;
509
510
  break;
510
511
  default:
511
- return Support_1.assertNever(namingStyle);
512
+ return (0, Support_1.assertNever)(namingStyle);
512
513
  }
513
514
  return (original) => {
514
515
  const words = splitIntoWords(original);
@@ -1,4 +1,4 @@
1
- export declare type StringMap = {
1
+ export type StringMap = {
2
2
  [name: string]: any;
3
3
  };
4
4
  export declare function isStringMap(x: any): x is StringMap;
@@ -1,9 +1,33 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.numberEnumValues = exports.indentationString = exports.parseJSON = exports.inflateBase64 = exports.errorMessage = exports.repeatedCall = exports.repeated = exports.mustNotHappen = exports.panic = exports.assert = exports.assertNever = exports.nonNull = exports.defined = exports.checkArray = exports.checkStringMap = exports.checkString = exports.isStringMap = void 0;
3
27
  const js_base64_1 = require("js-base64");
4
- const pako = require("pako");
28
+ const pako = __importStar(require("pako"));
5
29
  const Messages_1 = require("../Messages");
6
- const YAML = require("yaml");
30
+ const YAML = __importStar(require("yaml"));
7
31
  function isStringMap(x, checkValue) {
8
32
  if (typeof x !== "object" || Array.isArray(x) || x === null) {
9
33
  return false;
@@ -56,17 +80,17 @@ function nonNull(x) {
56
80
  }
57
81
  exports.nonNull = nonNull;
58
82
  function assertNever(x) {
59
- return Messages_1.messageError("InternalError", { message: `Unexpected object ${x}` });
83
+ return (0, Messages_1.messageError)("InternalError", { message: `Unexpected object ${x}` });
60
84
  }
61
85
  exports.assertNever = assertNever;
62
86
  function assert(condition, message = "Assertion failed") {
63
87
  if (!condition) {
64
- return Messages_1.messageError("InternalError", { message });
88
+ return (0, Messages_1.messageError)("InternalError", { message });
65
89
  }
66
90
  }
67
91
  exports.assert = assert;
68
92
  function panic(message) {
69
- return Messages_1.messageError("InternalError", { message });
93
+ return (0, Messages_1.messageError)("InternalError", { message });
70
94
  }
71
95
  exports.panic = panic;
72
96
  function mustNotHappen() {
@@ -117,7 +141,7 @@ function parseJSON(text, description, address = "<unknown>") {
117
141
  else {
118
142
  message = `Unknown exception ${e}`;
119
143
  }
120
- return Messages_1.messageError("MiscJSONParseError", { description, address, message });
144
+ return (0, Messages_1.messageError)("MiscJSONParseError", { description, address, message });
121
145
  }
122
146
  }
123
147
  exports.parseJSON = parseJSON;
@@ -28,7 +28,7 @@ export declare enum TypeKind {
28
28
  LIST = "LIST",
29
29
  NON_NULL = "NON_NULL"
30
30
  }
31
- export declare type GraphQLSchema = {
31
+ export type GraphQLSchema = {
32
32
  __schema: {
33
33
  __typename: "__Schema";
34
34
  queryType: {
@@ -327,7 +327,7 @@ export declare type GraphQLSchema = {
327
327
  }>;
328
328
  };
329
329
  };
330
- export declare type FullTypeFragment = {
330
+ export type FullTypeFragment = {
331
331
  __typename: "__Type";
332
332
  kind: TypeKind;
333
333
  name: string | null;
@@ -557,7 +557,7 @@ export declare type FullTypeFragment = {
557
557
  } | null;
558
558
  }> | null;
559
559
  };
560
- export declare type InputValueFragment = {
560
+ export type InputValueFragment = {
561
561
  __typename: "__InputValue";
562
562
  name: string;
563
563
  description: string | null;
@@ -603,7 +603,7 @@ export declare type InputValueFragment = {
603
603
  };
604
604
  defaultValue: string | null;
605
605
  };
606
- export declare type TypeRefFragment = {
606
+ export type TypeRefFragment = {
607
607
  __typename: "__Type";
608
608
  kind: TypeKind;
609
609
  name: string | null;
@@ -2,6 +2,7 @@
2
2
  /* tslint:disable */
3
3
  // This file was automatically generated and should not be edited.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.TypeKind = exports.__DirectiveLocation = void 0;
5
6
  // A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
6
7
  var __DirectiveLocation;
7
8
  (function (__DirectiveLocation) {
@@ -1,5 +1,5 @@
1
1
  import { TypeBuilder, Input, RunContext } from "../quicktype-core";
2
- export declare type GraphQLSourceData = {
2
+ export type GraphQLSourceData = {
3
3
  name: string;
4
4
  schema: any;
5
5
  query: string;