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.JSONPythonRenderer = exports.PythonRenderer = exports.PythonTargetLanguage = exports.pythonOptions = void 0;
3
4
  const TargetLanguage_1 = require("../TargetLanguage");
4
5
  const Type_1 = require("../Type");
5
6
  const RendererOptions_1 = require("../RendererOptions");
@@ -102,12 +103,12 @@ class PythonTargetLanguage extends TargetLanguage_1.TargetLanguage {
102
103
  }
103
104
  needsTransformerForType(t) {
104
105
  if (t instanceof Type_1.UnionType) {
105
- return collection_utils_1.iterableSome(t.members, m => this.needsTransformerForType(m));
106
+ return (0, collection_utils_1.iterableSome)(t.members, m => this.needsTransformerForType(m));
106
107
  }
107
108
  return t.kind === "integer-string" || t.kind === "bool-string";
108
109
  }
109
110
  makeRenderer(renderContext, untypedOptionValues) {
110
- const options = RendererOptions_1.getOptionValues(exports.pythonOptions, untypedOptionValues);
111
+ const options = (0, RendererOptions_1.getOptionValues)(exports.pythonOptions, untypedOptionValues);
111
112
  if (options.justTypes) {
112
113
  return new PythonRenderer(this, renderContext, options);
113
114
  }
@@ -149,10 +150,10 @@ function isPartCharacter3(utf16Unit) {
149
150
  }
150
151
  return true;
151
152
  }
152
- const legalizeName3 = Strings_1.utf16LegalizeCharacters(isPartCharacter3);
153
+ const legalizeName3 = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter3);
153
154
  function classNameStyle(original) {
154
- const words = Strings_1.splitIntoWords(original);
155
- return Strings_1.combineWords(words, legalizeName3, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter3);
155
+ const words = (0, Strings_1.splitIntoWords)(original);
156
+ return (0, Strings_1.combineWords)(words, legalizeName3, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter3);
156
157
  }
157
158
  function getWordStyle(uppercase, forceSnakeNameStyle) {
158
159
  if (!forceSnakeNameStyle) {
@@ -163,15 +164,16 @@ function getWordStyle(uppercase, forceSnakeNameStyle) {
163
164
  function snakeNameStyle(original, uppercase, forceSnakeNameStyle) {
164
165
  const wordStyle = getWordStyle(uppercase, forceSnakeNameStyle);
165
166
  const separator = forceSnakeNameStyle ? "_" : "";
166
- const words = Strings_1.splitIntoWords(original);
167
- return Strings_1.combineWords(words, legalizeName3, wordStyle, wordStyle, wordStyle, wordStyle, separator, isStartCharacter3);
167
+ const words = (0, Strings_1.splitIntoWords)(original);
168
+ return (0, Strings_1.combineWords)(words, legalizeName3, wordStyle, wordStyle, wordStyle, wordStyle, separator, isStartCharacter3);
168
169
  }
169
170
  class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
171
+ pyOptions;
172
+ imports = new Map();
173
+ declaredTypes = new Set();
170
174
  constructor(targetLanguage, renderContext, pyOptions) {
171
175
  super(targetLanguage, renderContext);
172
176
  this.pyOptions = pyOptions;
173
- this.imports = new Map();
174
- this.declaredTypes = new Set();
175
177
  }
176
178
  forbiddenNamesForGlobalNamespace() {
177
179
  return forbiddenTypeNames;
@@ -180,16 +182,16 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
180
182
  return { names: forbiddenPropertyNames, includeGlobalForbidden: false };
181
183
  }
182
184
  makeNamedTypeNamer() {
183
- return Naming_1.funPrefixNamer("type", classNameStyle);
185
+ return (0, Naming_1.funPrefixNamer)("type", classNameStyle);
184
186
  }
185
187
  namerForObjectProperty() {
186
- return Naming_1.funPrefixNamer("property", s => snakeNameStyle(s, false, this.pyOptions.nicePropertyNames));
188
+ return (0, Naming_1.funPrefixNamer)("property", s => snakeNameStyle(s, false, this.pyOptions.nicePropertyNames));
187
189
  }
188
190
  makeUnionMemberNamer() {
189
191
  return null;
190
192
  }
191
193
  makeEnumCaseNamer() {
192
- return Naming_1.funPrefixNamer("enum-case", s => snakeNameStyle(s, true, this.pyOptions.nicePropertyNames));
194
+ return (0, Naming_1.funPrefixNamer)("enum-case", s => snakeNameStyle(s, true, this.pyOptions.nicePropertyNames));
193
195
  }
194
196
  get commentLineStart() {
195
197
  return "# ";
@@ -215,7 +217,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
215
217
  }
216
218
  string(s) {
217
219
  const openQuote = '"';
218
- return [openQuote, Strings_1.stringEscape(s), '"'];
220
+ return [openQuote, (0, Strings_1.stringEscape)(s), '"'];
219
221
  }
220
222
  withImport(module, name) {
221
223
  if (this.pyOptions.features.typeHints || module !== "typing") {
@@ -223,7 +225,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
223
225
  // place, but right now we just make the type source and then throw it away. It's
224
226
  // not a performance issue, so it's fine, I just bemoan this special case, and
225
227
  // potential others down the road.
226
- collection_utils_1.mapUpdateInto(this.imports, module, s => (s ? collection_utils_1.setUnionInto(s, [name]) : new Set([name])));
228
+ (0, collection_utils_1.mapUpdateInto)(this.imports, module, s => (s ? (0, collection_utils_1.setUnionInto)(s, [name]) : new Set([name])));
227
229
  }
228
230
  return name;
229
231
  }
@@ -237,9 +239,9 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
237
239
  return ["'", name, "'"];
238
240
  }
239
241
  pythonType(t) {
240
- const actualType = Transformers_1.followTargetType(t);
241
- return TypeUtils_1.matchType(actualType, _anyType => this.withTyping("Any"), _nullType => "None", _boolType => "bool", _integerType => "int", _doubletype => "float", _stringType => "str", arrayType => [this.withTyping("List"), "[", this.pythonType(arrayType.items), "]"], classType => this.namedType(classType), mapType => [this.withTyping("Dict"), "[str, ", this.pythonType(mapType.values), "]"], enumType => this.namedType(enumType), unionType => {
242
- const [hasNull, nonNulls] = TypeUtils_1.removeNullFromUnion(unionType);
242
+ const actualType = (0, Transformers_1.followTargetType)(t);
243
+ return (0, TypeUtils_1.matchType)(actualType, _anyType => this.withTyping("Any"), _nullType => "None", _boolType => "bool", _integerType => "int", _doubletype => "float", _stringType => "str", arrayType => [this.withTyping("List"), "[", this.pythonType(arrayType.items), "]"], classType => this.namedType(classType), mapType => [this.withTyping("Dict"), "[str, ", this.pythonType(mapType.values), "]"], enumType => this.namedType(enumType), unionType => {
244
+ const [hasNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(unionType);
243
245
  const memberTypes = Array.from(nonNulls).map(m => this.pythonType(m));
244
246
  if (hasNull !== null) {
245
247
  let rest = [];
@@ -250,17 +252,17 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
250
252
  return [
251
253
  this.withTyping("Optional"),
252
254
  "[Union[",
253
- collection_utils_1.arrayIntercalate(", ", memberTypes),
255
+ (0, collection_utils_1.arrayIntercalate)(", ", memberTypes),
254
256
  "]]",
255
257
  ...rest
256
258
  ];
257
259
  }
258
260
  else {
259
- return [this.withTyping("Optional"), "[", Support_1.defined(collection_utils_1.iterableFirst(memberTypes)), "]", ...rest];
261
+ return [this.withTyping("Optional"), "[", (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(memberTypes)), "]", ...rest];
260
262
  }
261
263
  }
262
264
  else {
263
- return [this.withTyping("Union"), "[", collection_utils_1.arrayIntercalate(", ", memberTypes), "]"];
265
+ return [this.withTyping("Union"), "[", (0, collection_utils_1.arrayIntercalate)(", ", memberTypes), "]"];
264
266
  }
265
267
  }, transformedStringType => {
266
268
  if (transformedStringType.kind === "date-time") {
@@ -269,7 +271,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
269
271
  if (transformedStringType.kind === "uuid") {
270
272
  return this.withImport("uuid", "UUID");
271
273
  }
272
- return Support_1.panic(`Transformed type ${transformedStringType.kind} not supported`);
274
+ return (0, Support_1.panic)(`Transformed type ${transformedStringType.kind} not supported`);
273
275
  });
274
276
  }
275
277
  declarationLine(t) {
@@ -279,7 +281,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
279
281
  if (t instanceof Type_1.EnumType) {
280
282
  return ["class ", this.nameForNamedType(t), "(", this.withImport("enum", "Enum"), "):"];
281
283
  }
282
- return Support_1.panic(`Can't declare type ${t.kind}`);
284
+ return (0, Support_1.panic)(`Can't declare type ${t.kind}`);
283
285
  }
284
286
  declareType(t, emitter) {
285
287
  this.emitBlock(this.declarationLine(t), () => {
@@ -295,7 +297,7 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
295
297
  this.forEachClassProperty(t, "none", (name, _, cp) => {
296
298
  args.push([name, this.typeHint(": ", this.pythonType(cp.type))]);
297
299
  });
298
- this.emitBlock(["def __init__(self, ", collection_utils_1.arrayIntercalate(", ", args), ")", this.typeHint(" -> None"), ":"], () => {
300
+ this.emitBlock(["def __init__(self, ", (0, collection_utils_1.arrayIntercalate)(", ", args), ")", this.typeHint(" -> None"), ":"], () => {
299
301
  if (args.length === 0) {
300
302
  this.emitLine("pass");
301
303
  }
@@ -320,8 +322,8 @@ class PythonRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
320
322
  }
321
323
  sortClassProperties(properties, propertyNames) {
322
324
  if (this.pyOptions.features.dataClasses) {
323
- return collection_utils_1.mapSortBy(properties, (p) => {
324
- return p.type instanceof Type_1.UnionType && TypeUtils_1.nullableFromUnion(p.type) != null ? 1 : 0;
325
+ return (0, collection_utils_1.mapSortBy)(properties, (p) => {
326
+ return p.type instanceof Type_1.UnionType && (0, TypeUtils_1.nullableFromUnion)(p.type) != null ? 1 : 0;
325
327
  });
326
328
  }
327
329
  else {
@@ -396,13 +398,13 @@ function compose(input, f) {
396
398
  }
397
399
  if (input.lambda !== undefined) {
398
400
  // `input` is a lambda, so build `lambda x: f(input(x))`.
399
- return { lambda: Source_1.multiWord(" ", "lambda x:", f([Source_1.parenIfNeeded(input.lambda), "(x)"])), value: undefined };
401
+ return { lambda: (0, Source_1.multiWord)(" ", "lambda x:", f([(0, Source_1.parenIfNeeded)(input.lambda), "(x)"])), value: undefined };
400
402
  }
401
403
  // `input` is the identify function, so the composition is `lambda x: f(x)`.
402
- return { lambda: Source_1.multiWord(" ", "lambda x:", f("x")), value: undefined };
404
+ return { lambda: (0, Source_1.multiWord)(" ", "lambda x:", f("x")), value: undefined };
403
405
  }
404
406
  if (f.value !== undefined) {
405
- return Support_1.panic("Cannot compose into a value");
407
+ return (0, Support_1.panic)("Cannot compose into a value");
406
408
  }
407
409
  if (f.lambda === undefined) {
408
410
  // `f` is the identity function, so the result is just `input`.
@@ -416,7 +418,7 @@ function compose(input, f) {
416
418
  }
417
419
  // `input` is a lambda, so the result is `lambda x: f(input(x))`.
418
420
  return {
419
- lambda: Source_1.multiWord("", "lambda x: ", Source_1.parenIfNeeded(f.lambda), "(", Source_1.parenIfNeeded(input.lambda), "(x))"),
421
+ lambda: (0, Source_1.multiWord)("", "lambda x: ", (0, Source_1.parenIfNeeded)(f.lambda), "(", (0, Source_1.parenIfNeeded)(input.lambda), "(x))"),
420
422
  value: undefined
421
423
  };
422
424
  }
@@ -431,34 +433,31 @@ function makeLambda(vol) {
431
433
  if (vol.value === undefined) {
432
434
  return vol.lambda;
433
435
  }
434
- return Source_1.multiWord("", "lambda x: ", Source_1.parenIfNeeded(vol.lambda), "(", vol.value, ")");
436
+ return (0, Source_1.multiWord)("", "lambda x: ", (0, Source_1.parenIfNeeded)(vol.lambda), "(", vol.value, ")");
435
437
  }
436
438
  else if (vol.value !== undefined) {
437
- return Source_1.multiWord(" ", "lambda x:", vol.value);
439
+ return (0, Source_1.multiWord)(" ", "lambda x:", vol.value);
438
440
  }
439
- return Source_1.multiWord(" ", "lambda x:", "x");
441
+ return (0, Source_1.multiWord)(" ", "lambda x:", "x");
440
442
  }
441
443
  // If `vol` is a value, return the value in its source form.
442
444
  // Calling this with `vol` being a lambda is not allowed.
443
445
  function makeValue(vol) {
444
446
  if (vol.value === undefined) {
445
- return Support_1.panic("Cannot make value from lambda without value");
447
+ return (0, Support_1.panic)("Cannot make value from lambda without value");
446
448
  }
447
449
  if (vol.lambda !== undefined) {
448
- return [Source_1.parenIfNeeded(vol.lambda), "(", vol.value, ")"];
450
+ return [(0, Source_1.parenIfNeeded)(vol.lambda), "(", vol.value, ")"];
449
451
  }
450
452
  return vol.value;
451
453
  }
452
454
  class JSONPythonRenderer extends PythonRenderer {
453
- constructor() {
454
- super(...arguments);
455
- this._deserializerFunctions = new Set();
456
- this._converterNamer = Naming_1.funPrefixNamer("converter", s => snakeNameStyle(s, false, this.pyOptions.nicePropertyNames));
457
- this._topLevelConverterNames = new Map();
458
- this._haveTypeVar = false;
459
- this._haveEnumTypeVar = false;
460
- this._haveDateutil = false;
461
- }
455
+ _deserializerFunctions = new Set();
456
+ _converterNamer = (0, Naming_1.funPrefixNamer)("converter", s => snakeNameStyle(s, false, this.pyOptions.nicePropertyNames));
457
+ _topLevelConverterNames = new Map();
458
+ _haveTypeVar = false;
459
+ _haveEnumTypeVar = false;
460
+ _haveDateutil = false;
462
461
  emitTypeVar(tvar, constraints) {
463
462
  if (!this.pyOptions.features.typeHints) {
464
463
  return;
@@ -664,7 +663,7 @@ class JSONPythonRenderer extends PythonRenderer {
664
663
  case "is-type":
665
664
  return this.emitIsTypeConverter();
666
665
  default:
667
- return Support_1.assertNever(cf);
666
+ return (0, Support_1.assertNever)(cf);
668
667
  }
669
668
  }
670
669
  // Return the name of the Python converter function `cf`.
@@ -677,10 +676,10 @@ class JSONPythonRenderer extends PythonRenderer {
677
676
  }
678
677
  // Applies the converter function to `arg`
679
678
  convFn(cf, arg) {
680
- return compose(arg, { lambda: Source_1.singleWord(this.conv(cf)), value: undefined });
679
+ return compose(arg, { lambda: (0, Source_1.singleWord)(this.conv(cf)), value: undefined });
681
680
  }
682
681
  typeObject(t) {
683
- const s = TypeUtils_1.matchType(t, _anyType => undefined, _nullType => "type(None)", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "str", _arrayType => "List", classType => this.nameForNamedType(classType), _mapType => "dict", enumType => this.nameForNamedType(enumType), _unionType => undefined, transformedStringType => {
682
+ const s = (0, TypeUtils_1.matchType)(t, _anyType => undefined, _nullType => "type(None)", _boolType => "bool", _integerType => "int", _doubleType => "float", _stringType => "str", _arrayType => "List", classType => this.nameForNamedType(classType), _mapType => "dict", enumType => this.nameForNamedType(enumType), _unionType => undefined, transformedStringType => {
684
683
  if (transformedStringType.kind === "date-time") {
685
684
  return this.withImport("datetime", "datetime");
686
685
  }
@@ -690,7 +689,7 @@ class JSONPythonRenderer extends PythonRenderer {
690
689
  return undefined;
691
690
  });
692
691
  if (s === undefined) {
693
- return Support_1.panic(`No type object for ${t.kind}`);
692
+ return (0, Support_1.panic)(`No type object for ${t.kind}`);
694
693
  }
695
694
  return s;
696
695
  }
@@ -709,7 +708,7 @@ class JSONPythonRenderer extends PythonRenderer {
709
708
  return compose(inputTransformer, v => [
710
709
  this.conv("union"),
711
710
  "([",
712
- collection_utils_1.arrayIntercalate(", ", lambdas),
711
+ (0, collection_utils_1.arrayIntercalate)(", ", lambdas),
713
712
  "], ",
714
713
  v,
715
714
  ")"
@@ -752,7 +751,7 @@ class JSONPythonRenderer extends PythonRenderer {
752
751
  vol = compose(inputTransformer, v => [this.withImport("uuid", "UUID"), "(", v, ")"]);
753
752
  break;
754
753
  default:
755
- return Support_1.panic(`Parsing of ${immediateTargetType.kind} in a transformer is not supported`);
754
+ return (0, Support_1.panic)(`Parsing of ${immediateTargetType.kind} in a transformer is not supported`);
756
755
  }
757
756
  return consume(consumer, vol);
758
757
  }
@@ -776,23 +775,23 @@ class JSONPythonRenderer extends PythonRenderer {
776
775
  vol = compose(inputTransformer, v => ["str(", v, ")"]);
777
776
  break;
778
777
  default:
779
- return Support_1.panic(`Parsing of ${xfer.sourceType.kind} in a transformer is not supported`);
778
+ return (0, Support_1.panic)(`Parsing of ${xfer.sourceType.kind} in a transformer is not supported`);
780
779
  }
781
780
  return consume(consumer, vol);
782
781
  }
783
782
  else {
784
- return Support_1.panic(`Transformer ${xfer.kind} is not supported`);
783
+ return (0, Support_1.panic)(`Transformer ${xfer.kind} is not supported`);
785
784
  }
786
785
  }
787
786
  // Returns the code to deserialize `value` as type `t`. If `t` has
788
787
  // an associated transformer, the code for that transformer is
789
788
  // returned.
790
789
  deserializer(value, t) {
791
- const xf = Transformers_1.transformationForType(t);
790
+ const xf = (0, Transformers_1.transformationForType)(t);
792
791
  if (xf !== undefined) {
793
792
  return this.transformer(value, xf.transformer, xf.targetType);
794
793
  }
795
- return TypeUtils_1.matchType(t, _anyType => value, _nullType => this.convFn("none", value), _boolType => this.convFn("bool", value), _integerType => this.convFn("int", value), _doubleType => this.convFn("from-float", value), _stringType => this.convFn("str", value), arrayType => compose(value, v => [
794
+ return (0, TypeUtils_1.matchType)(t, _anyType => value, _nullType => this.convFn("none", value), _boolType => this.convFn("bool", value), _integerType => this.convFn("int", value), _doubleType => this.convFn("from-float", value), _stringType => this.convFn("str", value), arrayType => compose(value, v => [
796
795
  this.conv("list"),
797
796
  "(",
798
797
  makeLambda(this.deserializer(identity, arrayType.items)).source,
@@ -800,7 +799,7 @@ class JSONPythonRenderer extends PythonRenderer {
800
799
  v,
801
800
  ")"
802
801
  ]), classType => compose(value, {
803
- lambda: Source_1.singleWord(this.nameForNamedType(classType), ".from_dict"),
802
+ lambda: (0, Source_1.singleWord)(this.nameForNamedType(classType), ".from_dict"),
804
803
  value: undefined
805
804
  }), mapType => compose(value, v => [
806
805
  this.conv("dict"),
@@ -809,13 +808,13 @@ class JSONPythonRenderer extends PythonRenderer {
809
808
  ", ",
810
809
  v,
811
810
  ")"
812
- ]), enumType => compose(value, { lambda: Source_1.singleWord(this.nameForNamedType(enumType)), value: undefined }), unionType => {
811
+ ]), enumType => compose(value, { lambda: (0, Source_1.singleWord)(this.nameForNamedType(enumType)), value: undefined }), unionType => {
813
812
  // FIXME: handle via transformers
814
813
  const deserializers = Array.from(unionType.members).map(m => makeLambda(this.deserializer(identity, m)).source);
815
814
  return compose(value, v => [
816
815
  this.conv("union"),
817
816
  "([",
818
- collection_utils_1.arrayIntercalate(", ", deserializers),
817
+ (0, collection_utils_1.arrayIntercalate)(", ", deserializers),
819
818
  "], ",
820
819
  v,
821
820
  ")"
@@ -828,16 +827,16 @@ class JSONPythonRenderer extends PythonRenderer {
828
827
  if (transformedStringType.kind === "uuid") {
829
828
  return compose(value, v => [this.withImport("uuid", "UUID"), "(", v, ")"]);
830
829
  }
831
- return Support_1.panic(`Transformed type ${transformedStringType.kind} not supported`);
830
+ return (0, Support_1.panic)(`Transformed type ${transformedStringType.kind} not supported`);
832
831
  });
833
832
  }
834
833
  serializer(value, t) {
835
- const xf = Transformers_1.transformationForType(t);
834
+ const xf = (0, Transformers_1.transformationForType)(t);
836
835
  if (xf !== undefined) {
837
836
  const reverse = xf.reverse;
838
837
  return this.transformer(value, reverse.transformer, reverse.targetType);
839
838
  }
840
- return TypeUtils_1.matchType(t, _anyType => value, _nullType => this.convFn("none", value), _boolType => this.convFn("bool", value), _integerType => this.convFn("int", value), _doubleType => this.convFn("to-float", value), _stringType => this.convFn("str", value), arrayType => compose(value, v => [
839
+ return (0, TypeUtils_1.matchType)(t, _anyType => value, _nullType => this.convFn("none", value), _boolType => this.convFn("bool", value), _integerType => this.convFn("int", value), _doubleType => this.convFn("to-float", value), _stringType => this.convFn("str", value), arrayType => compose(value, v => [
841
840
  this.conv("list"),
842
841
  "(",
843
842
  makeLambda(this.serializer(identity, arrayType.items)).source,
@@ -856,7 +855,7 @@ class JSONPythonRenderer extends PythonRenderer {
856
855
  return compose(value, v => [
857
856
  this.conv("union"),
858
857
  "([",
859
- collection_utils_1.arrayIntercalate(", ", serializers),
858
+ (0, collection_utils_1.arrayIntercalate)(", ", serializers),
860
859
  "], ",
861
860
  v,
862
861
  ")"
@@ -868,7 +867,7 @@ class JSONPythonRenderer extends PythonRenderer {
868
867
  if (transformedStringType.kind === "uuid") {
869
868
  return compose(value, v => ["str(", v, ")"]);
870
869
  }
871
- return Support_1.panic(`Transformed type ${transformedStringType.kind} not supported`);
870
+ return (0, Support_1.panic)(`Transformed type ${transformedStringType.kind} not supported`);
872
871
  });
873
872
  }
874
873
  emitClassMembers(t) {
@@ -884,7 +883,7 @@ class JSONPythonRenderer extends PythonRenderer {
884
883
  this.emitLine(name, " = ", makeValue(this.deserializer(property, cp.type)));
885
884
  args.push(name);
886
885
  });
887
- this.emitLine("return ", className, "(", collection_utils_1.arrayIntercalate(", ", args), ")");
886
+ this.emitLine("return ", className, "(", (0, collection_utils_1.arrayIntercalate)(", ", args), ")");
888
887
  });
889
888
  this.ensureBlankLine();
890
889
  this.emitBlock(["def to_dict(self)", this.typeHint(" -> dict"), ":"], () => {
@@ -949,13 +948,13 @@ class JSONPythonRenderer extends PythonRenderer {
949
948
  ""
950
949
  ]);
951
950
  this.forEachTopLevel("none", (_, name) => {
952
- const { fromDict } = Support_1.defined(this._topLevelConverterNames.get(name));
951
+ const { fromDict } = (0, Support_1.defined)(this._topLevelConverterNames.get(name));
953
952
  this.emitLine(this.commentLineStart, " result = ", fromDict, "(json.loads(json_string))");
954
953
  });
955
954
  }
956
955
  emitClosingCode() {
957
956
  this.forEachTopLevel(["interposing", 2], (t, name) => {
958
- const { fromDict, toDict } = Support_1.defined(this._topLevelConverterNames.get(name));
957
+ const { fromDict, toDict } = (0, Support_1.defined)(this._topLevelConverterNames.get(name));
959
958
  const pythonType = this.pythonType(t);
960
959
  this.emitBlock(["def ", fromDict, "(", this.typingDecl("s", "Any"), ")", this.typeHint(" -> ", pythonType), ":"], () => {
961
960
  this.emitLine("return ", makeValue(this.deserializer({ value: "s" }, t)));
@@ -39,13 +39,13 @@ export declare class RustRenderer extends ConvenienceRenderer {
39
39
  protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
40
40
  protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
41
41
  protected forbiddenForEnumCases(_e: EnumType, _enumName: Name): ForbiddenWordsInfo;
42
- protected readonly commentLineStart: string;
42
+ protected get commentLineStart(): string;
43
43
  private nullableRustType;
44
44
  protected isImplicitCycleBreaker(t: Type): boolean;
45
45
  private rustType;
46
46
  private breakCycle;
47
47
  private emitRenameAttribute;
48
- private readonly visibility;
48
+ private get visibility();
49
49
  protected emitStructDefinition(c: ClassType, className: Name): void;
50
50
  protected emitBlock(line: Sourcelike, f: () => void): void;
51
51
  protected emitUnion(u: UnionType, unionName: Name): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RustRenderer = exports.RustTargetLanguage = exports.rustOptions = exports.Visibility = exports.Density = void 0;
3
4
  const collection_utils_1 = require("collection-utils");
4
5
  const TargetLanguage_1 = require("../TargetLanguage");
5
6
  const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
@@ -37,7 +38,7 @@ exports.rustOptions = {
37
38
  };
38
39
  class RustTargetLanguage extends TargetLanguage_1.TargetLanguage {
39
40
  makeRenderer(renderContext, untypedOptionValues) {
40
- return new RustRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.rustOptions, untypedOptionValues));
41
+ return new RustRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.rustOptions, untypedOptionValues));
41
42
  }
42
43
  constructor() {
43
44
  super("Rust", ["rust", "rs", "rustlang"], "rs");
@@ -120,36 +121,37 @@ const keywords = [
120
121
  "union"
121
122
  ];
122
123
  const isAsciiLetterOrUnderscoreOrDigit = (codePoint) => {
123
- if (!Strings_1.isAscii(codePoint)) {
124
+ if (!(0, Strings_1.isAscii)(codePoint)) {
124
125
  return false;
125
126
  }
126
- return Strings_1.isLetterOrUnderscoreOrDigit(codePoint);
127
+ return (0, Strings_1.isLetterOrUnderscoreOrDigit)(codePoint);
127
128
  };
128
129
  const isAsciiLetterOrUnderscore = (codePoint) => {
129
- if (!Strings_1.isAscii(codePoint)) {
130
+ if (!(0, Strings_1.isAscii)(codePoint)) {
130
131
  return false;
131
132
  }
132
- return Strings_1.isLetterOrUnderscore(codePoint);
133
+ return (0, Strings_1.isLetterOrUnderscore)(codePoint);
133
134
  };
134
- const legalizeName = Strings_1.legalizeCharacters(isAsciiLetterOrUnderscoreOrDigit);
135
+ const legalizeName = (0, Strings_1.legalizeCharacters)(isAsciiLetterOrUnderscoreOrDigit);
135
136
  function rustStyle(original, isSnakeCase) {
136
- const words = Strings_1.splitIntoWords(original);
137
+ const words = (0, Strings_1.splitIntoWords)(original);
137
138
  const wordStyle = isSnakeCase ? Strings_1.allLowerWordStyle : Strings_1.firstUpperWordStyle;
138
- const combined = Strings_1.combineWords(words, legalizeName, wordStyle, wordStyle, wordStyle, wordStyle, isSnakeCase ? "_" : "", isAsciiLetterOrUnderscore);
139
+ const combined = (0, Strings_1.combineWords)(words, legalizeName, wordStyle, wordStyle, wordStyle, wordStyle, isSnakeCase ? "_" : "", isAsciiLetterOrUnderscore);
139
140
  return combined === "_" ? "_underscore" : combined;
140
141
  }
141
- const snakeNamingFunction = Naming_1.funPrefixNamer("default", (original) => rustStyle(original, true));
142
- const camelNamingFunction = Naming_1.funPrefixNamer("camel", (original) => rustStyle(original, false));
142
+ const snakeNamingFunction = (0, Naming_1.funPrefixNamer)("default", (original) => rustStyle(original, true));
143
+ const camelNamingFunction = (0, Naming_1.funPrefixNamer)("camel", (original) => rustStyle(original, false));
143
144
  const standardUnicodeRustEscape = (codePoint) => {
144
145
  if (codePoint <= 0xffff) {
145
- return "\\u{" + Strings_1.intToHex(codePoint, 4) + "}";
146
+ return "\\u{" + (0, Strings_1.intToHex)(codePoint, 4) + "}";
146
147
  }
147
148
  else {
148
- return "\\u{" + Strings_1.intToHex(codePoint, 6) + "}";
149
+ return "\\u{" + (0, Strings_1.intToHex)(codePoint, 6) + "}";
149
150
  }
150
151
  };
151
- const rustStringEscape = Strings_1.utf32ConcatMap(Strings_1.escapeNonPrintableMapper(Strings_1.isPrintable, standardUnicodeRustEscape));
152
+ const rustStringEscape = (0, Strings_1.utf32ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isPrintable, standardUnicodeRustEscape));
152
153
  class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
154
+ _options;
153
155
  constructor(targetLanguage, renderContext, _options) {
154
156
  super(targetLanguage, renderContext);
155
157
  this._options = _options;
@@ -189,11 +191,11 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
189
191
  return kind === "array" || kind === "map";
190
192
  }
191
193
  rustType(t, withIssues = false) {
192
- return TypeUtils_1.matchType(t, _anyType => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, "Option<serde_json::Value>"), _nullType => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, "Option<serde_json::Value>"), _boolType => "bool", _integerType => "i64", _doubleType => "f64", _stringType => "String", arrayType => ["Vec<", this.rustType(arrayType.items, withIssues), ">"], classType => this.nameForNamedType(classType), mapType => ["HashMap<String, ", this.rustType(mapType.values, withIssues), ">"], enumType => this.nameForNamedType(enumType), unionType => {
193
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
194
+ return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, "Option<serde_json::Value>"), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, "Option<serde_json::Value>"), _boolType => "bool", _integerType => "i64", _doubleType => "f64", _stringType => "String", arrayType => ["Vec<", this.rustType(arrayType.items, withIssues), ">"], classType => this.nameForNamedType(classType), mapType => ["HashMap<String, ", this.rustType(mapType.values, withIssues), ">"], enumType => this.nameForNamedType(enumType), unionType => {
195
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
194
196
  if (nullable !== null)
195
197
  return this.nullableRustType(nullable, withIssues);
196
- const [hasNull] = TypeUtils_1.removeNullFromUnion(unionType);
198
+ const [hasNull] = (0, TypeUtils_1.removeNullFromUnion)(unionType);
197
199
  const isCycleBreaker = this.isCycleBreakerType(unionType);
198
200
  const name = isCycleBreaker
199
201
  ? ["Box<", this.nameForNamedType(unionType), ">"]
@@ -239,14 +241,14 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
239
241
  this.emitLine("}");
240
242
  }
241
243
  emitUnion(u, unionName) {
242
- const isMaybeWithSingleType = TypeUtils_1.nullableFromUnion(u);
244
+ const isMaybeWithSingleType = (0, TypeUtils_1.nullableFromUnion)(u);
243
245
  if (isMaybeWithSingleType !== null) {
244
246
  return;
245
247
  }
246
248
  this.emitDescription(this.descriptionForType(u));
247
249
  this.emitLine("#[derive(", this._options.deriveDebug ? "Debug, " : "", "Serialize, Deserialize)]");
248
250
  this.emitLine("#[serde(untagged)]");
249
- const [, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
251
+ const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
250
252
  const blankLines = this._options.density === Density.Dense ? "none" : "interposing";
251
253
  this.emitBlock(["pub enum ", unionName], () => this.forEachUnionMember(u, nonNulls, blankLines, null, (fieldName, t) => {
252
254
  const rustType = this.breakCycle(t, true);
@@ -270,7 +272,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
270
272
  this.emitCommentLines(this.leadingComments);
271
273
  return;
272
274
  }
273
- const topLevelName = Support_1.defined(collection_utils_1.mapFirst(this.topLevels)).getCombinedName();
275
+ const topLevelName = (0, Support_1.defined)((0, collection_utils_1.mapFirst)(this.topLevels)).getCombinedName();
274
276
  this.emitMultiline(`// Example code that deserializes and serializes the model.
275
277
  // extern crate serde;
276
278
  // #[macro_use]
@@ -38,13 +38,13 @@ export interface SwiftProperty {
38
38
  export declare class SwiftTargetLanguage extends TargetLanguage {
39
39
  constructor();
40
40
  protected getOptions(): Option<any>[];
41
- readonly stringTypeMapping: StringTypeMapping;
42
- readonly supportsOptionalClassProperties: boolean;
43
- readonly supportsUnionsWithBothNumberTypes: boolean;
41
+ get stringTypeMapping(): StringTypeMapping;
42
+ get supportsOptionalClassProperties(): boolean;
43
+ get supportsUnionsWithBothNumberTypes(): boolean;
44
44
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
45
45
  [name: string]: any;
46
46
  }): SwiftRenderer;
47
- readonly dateTimeRecognizer: DateTimeRecognizer;
47
+ get dateTimeRecognizer(): DateTimeRecognizer;
48
48
  }
49
49
  export declare class SwiftRenderer extends ConvenienceRenderer {
50
50
  private readonly _options;
@@ -65,7 +65,7 @@ export declare class SwiftRenderer extends ConvenienceRenderer {
65
65
  private emitBlock;
66
66
  private emitBlockWithAccess;
67
67
  private justTypesCase;
68
- private readonly lowerNamingFunction;
68
+ private get lowerNamingFunction();
69
69
  protected swiftPropertyType(p: ClassProperty): Sourcelike;
70
70
  protected swiftType(t: Type, withIssues?: boolean, noOptional?: boolean): Sourcelike;
71
71
  protected proposedUnionMemberNameForTypeKind(kind: TypeKind): string | null;
@@ -75,8 +75,8 @@ export declare class SwiftRenderer extends ConvenienceRenderer {
75
75
  protected getProtocolsArray(_t: Type, isClass: boolean): string[];
76
76
  private getProtocolString;
77
77
  private getEnumPropertyGroups;
78
- private readonly accessLevel;
79
- private readonly objcMembersDeclaration;
78
+ private get accessLevel();
79
+ private get objcMembersDeclaration();
80
80
  protected startFile(basename: Sourcelike): void;
81
81
  protected endFile(): void;
82
82
  protected propertyLinesDefinition(name: Name, parameter: ClassProperty): Sourcelike;