quicktype 17.0.4 → 17.0.5

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