quicktype 17.0.6 → 18.0.1

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 +20 -18
  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.JacksonRenderer = exports.JavaRenderer = exports.javaNameStyle = exports.stringEscape = exports.JavaTargetLanguage = exports.javaOptions = void 0;
3
4
  const Annotation_1 = require("../Annotation");
4
5
  const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
5
6
  const Naming_1 = require("../Naming");
@@ -21,7 +22,7 @@ exports.javaOptions = {
21
22
  ["java8", "java8"],
22
23
  ["legacy", "legacy"]
23
24
  ], "java8"),
24
- acronymStyle: Acronyms_1.acronymOption(Acronyms_1.AcronymStyleOptions.Pascal),
25
+ acronymStyle: (0, Acronyms_1.acronymOption)(Acronyms_1.AcronymStyleOptions.Pascal),
25
26
  // FIXME: Do this via a configurable named eventually.
26
27
  packageName: new RendererOptions_1.StringOption("package", "Generated package name", "NAME", "io.quicktype"),
27
28
  lombok: new RendererOptions_1.BooleanOption("lombok", "Use lombok", false, "primary"),
@@ -46,7 +47,7 @@ class JavaTargetLanguage extends TargetLanguage_1.TargetLanguage {
46
47
  return true;
47
48
  }
48
49
  makeRenderer(renderContext, untypedOptionValues) {
49
- const options = RendererOptions_1.getOptionValues(exports.javaOptions, untypedOptionValues);
50
+ const options = (0, RendererOptions_1.getOptionValues)(exports.javaOptions, untypedOptionValues);
50
51
  if (options.justTypes) {
51
52
  return new JavaRenderer(this, renderContext, options);
52
53
  }
@@ -130,63 +131,62 @@ const javaKeywords = [
130
131
  "false",
131
132
  "true"
132
133
  ];
133
- exports.stringEscape = Strings_1.utf16ConcatMap(Strings_1.escapeNonPrintableMapper(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
134
+ exports.stringEscape = (0, Strings_1.utf16ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isAscii, Strings_1.standardUnicodeHexEscape));
134
135
  function isStartCharacter(codePoint) {
135
136
  if (codePoint === 0x5f)
136
137
  return true; // underscore
137
- return Strings_1.isAscii(codePoint) && Strings_1.isLetter(codePoint);
138
+ return (0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isLetter)(codePoint);
138
139
  }
139
140
  function isPartCharacter(codePoint) {
140
- return isStartCharacter(codePoint) || (Strings_1.isAscii(codePoint) && Strings_1.isDigit(codePoint));
141
+ return isStartCharacter(codePoint) || ((0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isDigit)(codePoint));
141
142
  }
142
- const legalizeName = Strings_1.utf16LegalizeCharacters(isPartCharacter);
143
+ const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
143
144
  function javaNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle = Strings_1.allUpperWordStyle) {
144
- const words = Strings_1.splitIntoWords(original);
145
- return Strings_1.combineWords(words, legalizeName, upperUnderscore ? Strings_1.allUpperWordStyle : startWithUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
145
+ const words = (0, Strings_1.splitIntoWords)(original);
146
+ return (0, Strings_1.combineWords)(words, legalizeName, upperUnderscore ? Strings_1.allUpperWordStyle : startWithUpper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle, upperUnderscore || startWithUpper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
146
147
  }
147
148
  exports.javaNameStyle = javaNameStyle;
148
149
  class JavaDateTimeProvider {
150
+ _renderer;
151
+ _className;
149
152
  constructor(_renderer, _className) {
150
153
  this._renderer = _renderer;
151
154
  this._className = _className;
152
- this.shouldEmitDateTimeConverter = true;
153
- this.shouldEmitTimeConverter = true;
154
- this.shouldEmitDateConverter = true;
155
155
  }
156
+ shouldEmitDateTimeConverter = true;
157
+ shouldEmitTimeConverter = true;
158
+ shouldEmitDateConverter = true;
156
159
  }
157
160
  class Java8DateTimeProvider extends JavaDateTimeProvider {
158
- constructor() {
159
- super(...arguments);
160
- this.keywords = [
161
- "LocalDate",
162
- "OffsetDateTime",
163
- "OffsetTime",
164
- "ZoneOffset",
165
- "ZonedDateTime",
166
- "DateTimeFormatter",
167
- "DateTimeFormatterBuilder",
168
- "ChronoField"
169
- ];
170
- this.dateTimeImports = ["java.time.OffsetDateTime"];
171
- this.dateImports = ["java.time.LocalDate"];
172
- this.timeImports = ["java.time.OffsetTime"];
173
- this.converterImports = [
174
- "java.time.LocalDate",
175
- "java.time.OffsetDateTime",
176
- "java.time.OffsetTime",
177
- "java.time.ZoneOffset",
178
- "java.time.ZonedDateTime",
179
- "java.time.format.DateTimeFormatter",
180
- "java.time.format.DateTimeFormatterBuilder",
181
- "java.time.temporal.ChronoField"
182
- ];
183
- this.dateTimeType = "OffsetDateTime";
184
- this.dateType = "LocalDate";
185
- this.timeType = "OffsetTime";
186
- this.dateTimeJacksonAnnotations = [];
187
- this.dateJacksonAnnotations = [];
188
- this.timeJacksonAnnotations = [];
189
- }
161
+ keywords = [
162
+ "LocalDate",
163
+ "OffsetDateTime",
164
+ "OffsetTime",
165
+ "ZoneOffset",
166
+ "ZonedDateTime",
167
+ "DateTimeFormatter",
168
+ "DateTimeFormatterBuilder",
169
+ "ChronoField"
170
+ ];
171
+ dateTimeImports = ["java.time.OffsetDateTime"];
172
+ dateImports = ["java.time.LocalDate"];
173
+ timeImports = ["java.time.OffsetTime"];
174
+ converterImports = [
175
+ "java.time.LocalDate",
176
+ "java.time.OffsetDateTime",
177
+ "java.time.OffsetTime",
178
+ "java.time.ZoneOffset",
179
+ "java.time.ZonedDateTime",
180
+ "java.time.format.DateTimeFormatter",
181
+ "java.time.format.DateTimeFormatterBuilder",
182
+ "java.time.temporal.ChronoField"
183
+ ];
184
+ dateTimeType = "OffsetDateTime";
185
+ dateType = "LocalDate";
186
+ timeType = "OffsetTime";
187
+ dateTimeJacksonAnnotations = [];
188
+ dateJacksonAnnotations = [];
189
+ timeJacksonAnnotations = [];
190
190
  emitDateTimeConverters() {
191
191
  this._renderer.ensureBlankLine();
192
192
  this._renderer.emitLine("private static final DateTimeFormatter DATE_TIME_FORMATTER = new DateTimeFormatterBuilder()");
@@ -240,22 +240,17 @@ class Java8DateTimeProvider extends JavaDateTimeProvider {
240
240
  }
241
241
  }
242
242
  class JavaLegacyDateTimeProvider extends JavaDateTimeProvider {
243
- constructor() {
244
- super(...arguments);
245
- this.keywords = ["SimpleDateFormat", "Date"];
246
- this.dateTimeImports = ["java.util.Date"];
247
- this.dateImports = ["java.util.Date"];
248
- this.timeImports = ["java.util.Date"];
249
- this.converterImports = ["java.util.Date", "java.text.SimpleDateFormat"];
250
- this.dateTimeType = "Date";
251
- this.dateType = "Date";
252
- this.timeType = "Date";
253
- this.dateTimeJacksonAnnotations = ['@JsonFormat(pattern = "yyyy-MM-dd\'T\'HH:mm:ssX", timezone = "UTC")'];
254
- this.dateJacksonAnnotations = ['@JsonFormat(pattern = "yyyy-MM-dd")'];
255
- this.timeJacksonAnnotations = ['@JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")'];
256
- this.shouldEmitTimeConverter = false;
257
- this.shouldEmitDateConverter = false;
258
- }
243
+ keywords = ["SimpleDateFormat", "Date"];
244
+ dateTimeImports = ["java.util.Date"];
245
+ dateImports = ["java.util.Date"];
246
+ timeImports = ["java.util.Date"];
247
+ converterImports = ["java.util.Date", "java.text.SimpleDateFormat"];
248
+ dateTimeType = "Date";
249
+ dateType = "Date";
250
+ timeType = "Date";
251
+ dateTimeJacksonAnnotations = ['@JsonFormat(pattern = "yyyy-MM-dd\'T\'HH:mm:ssX", timezone = "UTC")'];
252
+ dateJacksonAnnotations = ['@JsonFormat(pattern = "yyyy-MM-dd")'];
253
+ timeJacksonAnnotations = ['@JsonFormat(pattern = "HH:mm:ssX", timezone = "UTC")'];
259
254
  emitDateTimeConverters() {
260
255
  this._renderer.ensureBlankLine();
261
256
  this._renderer.emitLine("private static final String[] DATE_TIME_FORMATS = {");
@@ -297,6 +292,8 @@ class JavaLegacyDateTimeProvider extends JavaDateTimeProvider {
297
292
  this._renderer.emitLine('return new SimpleDateFormat("hh:mm:ssZ").format(datetime);');
298
293
  });
299
294
  }
295
+ shouldEmitTimeConverter = false;
296
+ shouldEmitDateConverter = false;
300
297
  convertStringToDateTime(variable) {
301
298
  return [this._className, ".parseAllDateTimeString(", variable, ")"];
302
299
  }
@@ -317,13 +314,16 @@ class JavaLegacyDateTimeProvider extends JavaDateTimeProvider {
317
314
  }
318
315
  }
319
316
  class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
317
+ _options;
318
+ _currentFilename;
319
+ _gettersAndSettersForPropertyName = new Map();
320
+ _haveEmittedLeadingComments = false;
321
+ _dateTimeProvider;
322
+ _converterClassname = "Converter";
323
+ _converterKeywords = [];
320
324
  constructor(targetLanguage, renderContext, _options) {
321
325
  super(targetLanguage, renderContext);
322
326
  this._options = _options;
323
- this._gettersAndSettersForPropertyName = new Map();
324
- this._haveEmittedLeadingComments = false;
325
- this._converterClassname = "Converter";
326
- this._converterKeywords = [];
327
327
  switch (_options.dateTimeProvider) {
328
328
  default:
329
329
  case "java8":
@@ -359,13 +359,13 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
359
359
  return this.getNameStyling("enumCaseNamingFunction");
360
360
  }
361
361
  unionNeedsName(u) {
362
- return TypeUtils_1.nullableFromUnion(u) === null;
362
+ return (0, TypeUtils_1.nullableFromUnion)(u) === null;
363
363
  }
364
364
  namedTypeToNameForTopLevel(type) {
365
365
  // If the top-level type doesn't contain any classes or unions
366
366
  // we have to define a class just for the `FromJson` method, in
367
367
  // emitFromJsonForTopLevel.
368
- return TypeUtils_1.directlyReachableSingleNamedType(type);
368
+ return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
369
369
  }
370
370
  makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
371
371
  const getterName = new Naming_1.DependencyName(this.getNameStyling("propertyNamingFunction"), name.order, lookup => `get_${lookup(name)}`);
@@ -379,9 +379,9 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
379
379
  }
380
380
  getNameStyling(convention) {
381
381
  const styling = {
382
- typeNamingFunction: Naming_1.funPrefixNamer("types", n => javaNameStyle(true, false, n, Acronyms_1.acronymStyle(this._options.acronymStyle))),
383
- propertyNamingFunction: Naming_1.funPrefixNamer("properties", n => javaNameStyle(false, false, n, Acronyms_1.acronymStyle(this._options.acronymStyle))),
384
- enumCaseNamingFunction: Naming_1.funPrefixNamer("enum-cases", n => javaNameStyle(true, true, n, Acronyms_1.acronymStyle(this._options.acronymStyle)))
382
+ typeNamingFunction: (0, Naming_1.funPrefixNamer)("types", n => javaNameStyle(true, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
383
+ propertyNamingFunction: (0, Naming_1.funPrefixNamer)("properties", n => javaNameStyle(false, false, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle))),
384
+ enumCaseNamingFunction: (0, Naming_1.funPrefixNamer)("enum-cases", n => javaNameStyle(true, true, n, (0, Acronyms_1.acronymStyle)(this._options.acronymStyle)))
385
385
  };
386
386
  return styling[convention];
387
387
  }
@@ -389,7 +389,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
389
389
  if (this.topLevels.size === 1) {
390
390
  return methodName;
391
391
  }
392
- return [topLevelName, Strings_1.capitalize(methodName)];
392
+ return [topLevelName, (0, Strings_1.capitalize)(methodName)];
393
393
  }
394
394
  methodName(prefix, suffix, topLevelName) {
395
395
  if (this.topLevels.size === 1) {
@@ -410,7 +410,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
410
410
  return this.methodName("get", "ObjectWriter", topLevelName);
411
411
  }
412
412
  startFile(basename) {
413
- Support_1.assert(this._currentFilename === undefined, "Previous file wasn't finished");
413
+ (0, Support_1.assert)(this._currentFilename === undefined, "Previous file wasn't finished");
414
414
  // FIXME: The filenames should actually be Sourcelikes, too
415
415
  this._currentFilename = `${this.sourcelikeToString(basename)}.java`;
416
416
  // FIXME: Why is this necessary?
@@ -422,7 +422,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
422
422
  }
423
423
  }
424
424
  finishFile() {
425
- super.finishFile(Support_1.defined(this._currentFilename));
425
+ super.finishFile((0, Support_1.defined)(this._currentFilename));
426
426
  this._currentFilename = undefined;
427
427
  }
428
428
  emitPackageAndImports(imports) {
@@ -456,7 +456,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
456
456
  this.emitTryCatch(f, () => this.emitLine("// Ignored"));
457
457
  }
458
458
  javaType(reference, t, withIssues = false) {
459
- return TypeUtils_1.matchType(t, _anyType => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, "Object"), _nullType => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, "Object"), _boolType => (reference ? "Boolean" : "boolean"), _integerType => (reference ? "Long" : "long"), _doubleType => (reference ? "Double" : "double"), _stringType => "String", arrayType => {
459
+ return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, "Object"), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, "Object"), _boolType => (reference ? "Boolean" : "boolean"), _integerType => (reference ? "Long" : "long"), _doubleType => (reference ? "Double" : "double"), _stringType => "String", arrayType => {
460
460
  if (this._options.useList) {
461
461
  return ["List<", this.javaType(true, arrayType.items, withIssues), ">"];
462
462
  }
@@ -464,7 +464,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
464
464
  return [this.javaType(false, arrayType.items, withIssues), "[]"];
465
465
  }
466
466
  }, classType => this.nameForNamedType(classType), mapType => ["Map<String, ", this.javaType(true, mapType.values, withIssues), ">"], enumType => this.nameForNamedType(enumType), unionType => {
467
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
467
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
468
468
  if (nullable !== null)
469
469
  return this.javaType(true, nullable, withIssues);
470
470
  return this.nameForNamedType(unionType);
@@ -485,7 +485,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
485
485
  });
486
486
  }
487
487
  javaImport(t) {
488
- return TypeUtils_1.matchType(t, _anyType => [], _nullType => [], _boolType => [], _integerType => [], _doubleType => [], _stringType => [], arrayType => {
488
+ return (0, TypeUtils_1.matchType)(t, _anyType => [], _nullType => [], _boolType => [], _integerType => [], _doubleType => [], _stringType => [], arrayType => {
489
489
  if (this._options.useList) {
490
490
  return [...this.javaImport(arrayType.items), "java.util.List"];
491
491
  }
@@ -525,7 +525,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
525
525
  return "Map";
526
526
  }
527
527
  else if (t instanceof Type_1.UnionType) {
528
- const nullable = TypeUtils_1.nullableFromUnion(t);
528
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(t);
529
529
  if (nullable !== null)
530
530
  return this.javaTypeWithoutGenerics(true, nullable);
531
531
  return this.nameForNamedType(t);
@@ -552,7 +552,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
552
552
  if (t instanceof Type_1.EnumType) {
553
553
  return ["java.io.IOException"];
554
554
  }
555
- return Support_1.assertNever(t);
555
+ return (0, Support_1.assertNever)(t);
556
556
  }
557
557
  importsForClass(c) {
558
558
  const imports = [];
@@ -564,7 +564,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
564
564
  }
565
565
  importsForUnionMembers(u) {
566
566
  const imports = [];
567
- const [, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
567
+ const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
568
568
  this.forEachUnionMember(u, nonNulls, "none", null, (_fieldName, t) => {
569
569
  this.javaImport(t).forEach(imp => imports.push(imp));
570
570
  });
@@ -593,7 +593,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
593
593
  if (!this._options.lombok) {
594
594
  this.forEachClassProperty(c, "leading-and-interposing", (name, jsonName, p) => {
595
595
  this.emitDescription(this.descriptionForClassProperty(c, jsonName));
596
- const [getterName, setterName] = Support_1.defined(this._gettersAndSettersForPropertyName.get(name));
596
+ const [getterName, setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
597
597
  const rendered = this.javaType(false, p.type);
598
598
  this.annotationsForAccessor(c, className, name, jsonName, p, false).forEach(annotation => this.emitLine(annotation));
599
599
  this.emitLine("public ", rendered, " ", getterName, "() { return ", name, "; }");
@@ -620,7 +620,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
620
620
  const imports = [...this.importsForType(u), ...this.importsForUnionMembers(u)];
621
621
  this.emitFileHeader(unionName, imports);
622
622
  this.emitDescription(this.descriptionForType(u));
623
- const [, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
623
+ const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
624
624
  this.emitUnionAttributes(u, unionName);
625
625
  this.emitBlock(["public class ", unionName], () => {
626
626
  for (const t of nonNulls) {
@@ -655,7 +655,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
655
655
  this.emitLine("switch (this) {");
656
656
  this.indent(() => {
657
657
  this.forEachEnumCase(e, "none", (name, jsonName) => {
658
- this.emitLine("case ", name, ': return "', exports.stringEscape(jsonName), '";');
658
+ this.emitLine("case ", name, ': return "', (0, exports.stringEscape)(jsonName), '";');
659
659
  });
660
660
  });
661
661
  this.emitLine("}");
@@ -665,7 +665,7 @@ class JavaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
665
665
  this.emitEnumDeserializationAttributes(e);
666
666
  this.emitBlock(["public static ", enumName, " forValue(String value) throws IOException"], () => {
667
667
  this.forEachEnumCase(e, "none", (name, jsonName) => {
668
- this.emitLine('if (value.equals("', exports.stringEscape(jsonName), '")) return ', name, ";");
668
+ this.emitLine('if (value.equals("', (0, exports.stringEscape)(jsonName), '")) return ', name, ";");
669
669
  });
670
670
  this.emitLine('throw new IOException("Cannot deserialize ', enumName, '");');
671
671
  });
@@ -680,18 +680,18 @@ exports.JavaRenderer = JavaRenderer;
680
680
  class JacksonRenderer extends JavaRenderer {
681
681
  constructor(targetLanguage, renderContext, options) {
682
682
  super(targetLanguage, renderContext, options);
683
- this._converterKeywords = [
684
- "JsonProperty",
685
- "JsonDeserialize",
686
- "JsonDeserializer",
687
- "JsonSerialize",
688
- "JsonSerializer",
689
- "JsonParser",
690
- "JsonProcessingException",
691
- "DeserializationContext",
692
- "SerializerProvider"
693
- ];
694
683
  }
684
+ _converterKeywords = [
685
+ "JsonProperty",
686
+ "JsonDeserialize",
687
+ "JsonDeserializer",
688
+ "JsonSerialize",
689
+ "JsonSerializer",
690
+ "JsonParser",
691
+ "JsonProcessingException",
692
+ "DeserializationContext",
693
+ "SerializerProvider"
694
+ ];
695
695
  emitClassAttributes(c, _className) {
696
696
  if (c.getProperties().size === 0)
697
697
  this.emitLine("@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.NONE)");
@@ -699,7 +699,7 @@ class JacksonRenderer extends JavaRenderer {
699
699
  }
700
700
  annotationsForAccessor(_c, _className, _propertyName, jsonName, p, _isSetter) {
701
701
  const superAnnotations = super.annotationsForAccessor(_c, _className, _propertyName, jsonName, p, _isSetter);
702
- const annotations = ['@JsonProperty("' + exports.stringEscape(jsonName) + '")'];
702
+ const annotations = ['@JsonProperty("' + (0, exports.stringEscape)(jsonName) + '")'];
703
703
  switch (p.type.kind) {
704
704
  case "date-time":
705
705
  this._dateTimeProvider.dateTimeJacksonAnnotations.forEach(annotation => annotations.push(annotation));
@@ -734,7 +734,7 @@ class JacksonRenderer extends JavaRenderer {
734
734
  imports.push("com.fasterxml.jackson.annotation.*");
735
735
  return imports;
736
736
  }
737
- return Support_1.assertNever(t);
737
+ return (0, Support_1.assertNever)(t);
738
738
  }
739
739
  emitUnionAttributes(_u, unionName) {
740
740
  this.emitLine("@JsonDeserialize(using = ", unionName, ".Deserializer.class)");
@@ -766,7 +766,7 @@ class JacksonRenderer extends JavaRenderer {
766
766
  this.emitLine("value.", fieldName, " = UUID.fromString(", parseFrom, ");");
767
767
  break;
768
768
  default:
769
- return Support_1.panic("Requested type isnt an object!");
769
+ return (0, Support_1.panic)("Requested type isnt an object!");
770
770
  }
771
771
  };
772
772
  const emitDeserializeType = (t, variableFieldName = "") => {
@@ -868,7 +868,7 @@ class JacksonRenderer extends JavaRenderer {
868
868
  case "date-time":
869
869
  return this._dateTimeProvider.convertDateTimeToString(fieldName);
870
870
  default:
871
- return Support_1.panic("Requested type doesn't have custom serializer code!");
871
+ return (0, Support_1.panic)("Requested type doesn't have custom serializer code!");
872
872
  }
873
873
  };
874
874
  const emitSerializeType = (t) => {
@@ -883,7 +883,7 @@ class JacksonRenderer extends JavaRenderer {
883
883
  this.emitLine("return;");
884
884
  });
885
885
  };
886
- const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
886
+ const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
887
887
  this.ensureBlankLine();
888
888
  this.emitBlock(["static class Deserializer extends JsonDeserializer<", unionName, ">"], () => {
889
889
  this.emitLine("@Override");
@@ -15,7 +15,7 @@ export declare const javaScriptOptions: {
15
15
  converters: EnumOption<ConvertersOptions>;
16
16
  rawType: EnumOption<"any" | "json">;
17
17
  };
18
- export declare type JavaScriptTypeAnnotations = {
18
+ export type JavaScriptTypeAnnotations = {
19
19
  any: string;
20
20
  anyArray: string;
21
21
  anyMap: string;
@@ -27,9 +27,9 @@ export declare type JavaScriptTypeAnnotations = {
27
27
  export declare class JavaScriptTargetLanguage extends TargetLanguage {
28
28
  constructor(displayName?: string, names?: string[], extension?: string);
29
29
  protected getOptions(): Option<any>[];
30
- readonly stringTypeMapping: StringTypeMapping;
31
- readonly supportsOptionalClassProperties: boolean;
32
- readonly supportsFullObjectType: boolean;
30
+ get stringTypeMapping(): StringTypeMapping;
31
+ get supportsOptionalClassProperties(): boolean;
32
+ get supportsFullObjectType(): boolean;
33
33
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
34
34
  [name: string]: any;
35
35
  }): JavaScriptRenderer;
@@ -54,9 +54,9 @@ export declare class JavaScriptRenderer extends ConvenienceRenderer {
54
54
  protected deserializerFunctionLine(_t: Type, name: Name): Sourcelike;
55
55
  protected serializerFunctionName(name: Name): Sourcelike;
56
56
  protected serializerFunctionLine(_t: Type, name: Name): Sourcelike;
57
- protected readonly moduleLine: string | undefined;
58
- protected readonly castFunctionLines: [string, string];
59
- protected readonly typeAnnotations: JavaScriptTypeAnnotations;
57
+ protected get moduleLine(): string | undefined;
58
+ protected get castFunctionLines(): [string, string];
59
+ protected get typeAnnotations(): JavaScriptTypeAnnotations;
60
60
  protected emitConvertModuleBody(): void;
61
61
  protected emitConvertModuleHelpers(): void;
62
62
  protected emitConvertModule(): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JavaScriptRenderer = exports.legalizeName = exports.JavaScriptTargetLanguage = exports.javaScriptOptions = void 0;
3
4
  const collection_utils_1 = require("collection-utils");
4
5
  const TypeUtils_1 = require("../TypeUtils");
5
6
  const Acronyms_1 = require("../support/Acronyms");
@@ -13,10 +14,10 @@ const TargetLanguage_1 = require("../TargetLanguage");
13
14
  const RendererOptions_1 = require("../RendererOptions");
14
15
  const JavaScriptUnicodeMaps_1 = require("./JavaScriptUnicodeMaps");
15
16
  exports.javaScriptOptions = {
16
- acronymStyle: Acronyms_1.acronymOption(Acronyms_1.AcronymStyleOptions.Pascal),
17
+ acronymStyle: (0, Acronyms_1.acronymOption)(Acronyms_1.AcronymStyleOptions.Pascal),
17
18
  runtimeTypecheck: new RendererOptions_1.BooleanOption("runtime-typecheck", "Verify JSON.parse results at runtime", true),
18
19
  runtimeTypecheckIgnoreUnknownProperties: new RendererOptions_1.BooleanOption("runtime-typecheck-ignore-unknown-properties", "Ignore unknown properties when verifying at runtime", false, "secondary"),
19
- converters: Converters_1.convertersOption(),
20
+ converters: (0, Converters_1.convertersOption)(),
20
21
  rawType: new RendererOptions_1.EnumOption("raw-type", "Type of raw input (json by default)", [
21
22
  ["json", "json"],
22
23
  ["any", "any"]
@@ -49,24 +50,25 @@ class JavaScriptTargetLanguage extends TargetLanguage_1.TargetLanguage {
49
50
  return true;
50
51
  }
51
52
  makeRenderer(renderContext, untypedOptionValues) {
52
- return new JavaScriptRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.javaScriptOptions, untypedOptionValues));
53
+ return new JavaScriptRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.javaScriptOptions, untypedOptionValues));
53
54
  }
54
55
  }
55
56
  exports.JavaScriptTargetLanguage = JavaScriptTargetLanguage;
56
- exports.legalizeName = Strings_1.utf16LegalizeCharacters(JavaScriptUnicodeMaps_1.isES3IdentifierPart);
57
- const identityNamingFunction = Naming_1.funPrefixNamer("properties", s => s);
57
+ exports.legalizeName = (0, Strings_1.utf16LegalizeCharacters)(JavaScriptUnicodeMaps_1.isES3IdentifierPart);
58
+ const identityNamingFunction = (0, Naming_1.funPrefixNamer)("properties", s => s);
58
59
  class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
60
+ _jsOptions;
59
61
  constructor(targetLanguage, renderContext, _jsOptions) {
60
62
  super(targetLanguage, renderContext);
61
63
  this._jsOptions = _jsOptions;
62
64
  }
63
65
  nameStyle(original, upper) {
64
- const acronyms = Acronyms_1.acronymStyle(this._jsOptions.acronymStyle);
65
- const words = Strings_1.splitIntoWords(original);
66
- return Strings_1.combineWords(words, exports.legalizeName, upper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, upper ? s => Strings_1.capitalize(acronyms(s)) : Strings_1.allLowerWordStyle, acronyms, "", JavaScriptUnicodeMaps_1.isES3IdentifierStart);
66
+ const acronyms = (0, Acronyms_1.acronymStyle)(this._jsOptions.acronymStyle);
67
+ const words = (0, Strings_1.splitIntoWords)(original);
68
+ return (0, Strings_1.combineWords)(words, exports.legalizeName, upper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, upper ? s => (0, Strings_1.capitalize)(acronyms(s)) : Strings_1.allLowerWordStyle, acronyms, "", JavaScriptUnicodeMaps_1.isES3IdentifierStart);
67
69
  }
68
70
  makeNamedTypeNamer() {
69
- return Naming_1.funPrefixNamer("types", s => this.nameStyle(s, true));
71
+ return (0, Naming_1.funPrefixNamer)("types", s => this.nameStyle(s, true));
70
72
  }
71
73
  namerForObjectProperty() {
72
74
  return identityNamingFunction;
@@ -75,10 +77,10 @@ class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
75
77
  return null;
76
78
  }
77
79
  makeEnumCaseNamer() {
78
- return Naming_1.funPrefixNamer("enum-cases", s => this.nameStyle(s, true));
80
+ return (0, Naming_1.funPrefixNamer)("enum-cases", s => this.nameStyle(s, true));
79
81
  }
80
82
  namedTypeToNameForTopLevel(type) {
81
- return TypeUtils_1.directlyReachableSingleNamedType(type);
83
+ return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
82
84
  }
83
85
  makeNameForProperty(c, className, p, jsonName, _assignedName) {
84
86
  // Ignore the assigned name
@@ -91,9 +93,9 @@ class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
91
93
  if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
92
94
  return ['r("', this.nameForNamedType(t), '")'];
93
95
  }
94
- return TypeUtils_1.matchType(t, _anyType => '"any"', _nullType => `null`, _boolType => `true`, _integerType => `0`, _doubleType => `3.14`, _stringType => `""`, arrayType => ["a(", this.typeMapTypeFor(arrayType.items), ")"], _classType => Support_1.panic("We handled this above"), mapType => ["m(", this.typeMapTypeFor(mapType.values), ")"], _enumType => Support_1.panic("We handled this above"), unionType => {
96
+ return (0, TypeUtils_1.matchType)(t, _anyType => '"any"', _nullType => `null`, _boolType => `true`, _integerType => `0`, _doubleType => `3.14`, _stringType => `""`, arrayType => ["a(", this.typeMapTypeFor(arrayType.items), ")"], _classType => (0, Support_1.panic)("We handled this above"), mapType => ["m(", this.typeMapTypeFor(mapType.values), ")"], _enumType => (0, Support_1.panic)("We handled this above"), unionType => {
95
97
  const children = Array.from(unionType.getChildren()).map((type) => this.typeMapTypeFor(type));
96
- return ["u(", ...collection_utils_1.arrayIntercalate(", ", children), ")"];
98
+ return ["u(", ...(0, collection_utils_1.arrayIntercalate)(", ", children), ")"];
97
99
  }, transformedStringType => {
98
100
  if (transformedStringType.kind === "date-time") {
99
101
  return "Date";
@@ -122,7 +124,7 @@ class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
122
124
  this.emitLine('"', name, '": o([');
123
125
  this.indent(() => {
124
126
  this.forEachClassProperty(t, "none", (propName, jsonName, property) => {
125
- this.emitLine('{ json: "', Strings_1.utf16StringEscape(jsonName), '", js: "', Source_1.modifySource(Strings_1.utf16StringEscape, propName), '", typ: ', this.typeMapTypeForProperty(property), " },");
127
+ this.emitLine('{ json: "', (0, Strings_1.utf16StringEscape)(jsonName), '", js: "', (0, Source_1.modifySource)(Strings_1.utf16StringEscape, propName), '", typ: ', this.typeMapTypeForProperty(property), " },");
126
128
  });
127
129
  });
128
130
  this.emitLine("], ", additional, "),");
@@ -131,7 +133,7 @@ class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
131
133
  this.emitLine('"', name, '": [');
132
134
  this.indent(() => {
133
135
  this.forEachEnumCase(e, "none", (_caseName, jsonName) => {
134
- this.emitLine(`"${Strings_1.utf16StringEscape(jsonName)}",`);
136
+ this.emitLine(`"${(0, Strings_1.utf16StringEscape)(jsonName)}",`);
135
137
  });
136
138
  });
137
139
  this.emitLine("],");
@@ -145,7 +147,7 @@ class JavaScriptRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
145
147
  return ["function ", this.deserializerFunctionName(name), "(json)"];
146
148
  }
147
149
  serializerFunctionName(name) {
148
- const camelCaseName = Source_1.modifySource(Strings_1.camelCase, name);
150
+ const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
149
151
  return [camelCaseName, "ToJson"];
150
152
  }
151
153
  serializerFunctionLine(_t, name) {
@@ -319,7 +321,7 @@ function transform(val${anyAnnotation}, typ${anyAnnotation}, getProps${anyAnnota
319
321
  return invalidValue(typ, val, key, parent);
320
322
  }
321
323
  if (typ === false) return invalidValue(typ, val, key, parent);
322
- let ref = undefined;
324
+ let ref${anyAnnotation} = undefined;
323
325
  while (typeof typ === "object" && typ.ref !== undefined) {
324
326
  ref = typ.ref;
325
327
  typ = typeMap[typ.ref];
@@ -397,7 +399,7 @@ function r(name${stringAnnotation}) {
397
399
  this.emitUsageImportComment();
398
400
  this.emitLine("//");
399
401
  this.forEachTopLevel("none", (_t, name) => {
400
- const camelCaseName = Source_1.modifySource(Strings_1.camelCase, name);
402
+ const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
401
403
  this.emitLine("// const ", camelCaseName, " = Convert.to", name, "(json);");
402
404
  });
403
405
  if (this._jsOptions.runtimeTypecheck) {