quicktype-core 23.0.4 → 23.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -39,6 +39,8 @@ export { JavaScriptPropTypesTargetLanguage, JavaScriptPropTypesRenderer, javaScr
39
39
  export { TypeScriptTargetLanguage, TypeScriptRenderer, FlowTargetLanguage, FlowRenderer, tsFlowOptions } from "./language/TypeScriptFlow";
40
40
  export { SwiftTargetLanguage, SwiftRenderer, swiftOptions } from "./language/Swift";
41
41
  export { KotlinTargetLanguage, KotlinRenderer, kotlinOptions } from "./language/Kotlin";
42
+ export { Scala3TargetLanguage, Scala3Renderer, scala3Options } from "./language/Scala3";
43
+ export { SmithyTargetLanguage, Smithy4sRenderer, SmithyOptions } from "./language/Smithy4s";
42
44
  export { ElmTargetLanguage, ElmRenderer, elmOptions } from "./language/Elm";
43
45
  export { JSONSchemaTargetLanguage, JSONSchemaRenderer } from "./language/JSONSchema";
44
46
  export { RustTargetLanguage, RustRenderer, rustOptions } from "./language/Rust";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ClassType = exports.ArrayType = exports.PrimitiveType = exports.Type = exports.messageAssert = exports.messageError = exports.QuickTypeError = exports.trainMarkovChain = exports.isLetterOrDigit = exports.legalizeCharacters = exports.allUpperWordStyle = exports.firstUpperWordStyle = exports.combineWords = exports.capitalize = exports.splitIntoWords = exports.inflateBase64 = exports.checkArray = exports.checkStringMap = exports.parseJSON = exports.assertNever = exports.defined = exports.assert = exports.panic = exports.IssueAnnotationData = exports.Namer = exports.funPrefixNamer = exports.Name = exports.parenIfNeeded = exports.singleWord = exports.modifySource = exports.languageNamed = exports.defaultTargetLanguages = exports.TargetLanguage = exports.getOptionValues = exports.Option = exports.Ref = exports.JSONSchemaInput = exports.jsonInputForTargetLanguage = exports.JSONInput = exports.InputData = exports.CompressedJSON = exports.inferenceFlagsObject = exports.defaultInferenceFlags = exports.inferenceFlagNames = exports.inferenceFlags = exports.combineRenderResults = exports.quicktype = exports.quicktypeMultiFileSync = exports.quicktypeMultiFile = exports.getTargetLanguage = void 0;
4
4
  exports.TypeScriptRenderer = exports.TypeScriptTargetLanguage = exports.javaScriptPropTypesOptions = exports.JavaScriptPropTypesRenderer = exports.JavaScriptPropTypesTargetLanguage = exports.javaScriptOptions = exports.JavaScriptRenderer = exports.JavaScriptTargetLanguage = exports.javaOptions = exports.JavaRenderer = exports.JavaTargetLanguage = exports.objcOptions = exports.ObjectiveCRenderer = exports.ObjectiveCTargetLanguage = exports.goOptions = exports.GoRenderer = exports.GoTargetLanguage = exports.pythonOptions = exports.PythonRenderer = exports.PythonTargetLanguage = exports.CSharpRenderer = exports.cSharpOptions = exports.CSharpTargetLanguage = exports.cPlusPlusOptions = exports.CPlusPlusRenderer = exports.CPlusPlusTargetLanguage = exports.uriTypeAttributeKind = exports.ConvenienceRenderer = exports.nullableFromUnion = exports.matchType = exports.removeNullFromUnion = exports.StringTypes = exports.namesTypeAttributeKind = exports.makeNamesTypeAttributes = exports.TypeNames = exports.emptyTypeAttributes = exports.TypeAttributeKind = exports.derefTypeRef = exports.TypeBuilder = exports.sourcesFromPostmanCollection = exports.JSONSchemaStore = exports.FetchingJSONSchemaStore = exports.readFromFileOrURL = exports.readableFromFileOrURL = exports.getStream = exports.ObjectType = exports.UnionType = exports.MapType = exports.EnumType = exports.ClassProperty = void 0;
5
- exports.dartOptions = exports.DartRenderer = exports.DartTargetLanguage = exports.haskellOptions = exports.HaskellRenderer = exports.HaskellTargetLanguage = exports.CrystalRenderer = exports.CrystalTargetLanguage = exports.rubyOptions = exports.RubyRenderer = exports.RubyTargetLanguage = exports.rustOptions = exports.RustRenderer = exports.RustTargetLanguage = exports.JSONSchemaRenderer = exports.JSONSchemaTargetLanguage = exports.elmOptions = exports.ElmRenderer = exports.ElmTargetLanguage = exports.kotlinOptions = exports.KotlinRenderer = exports.KotlinTargetLanguage = exports.swiftOptions = exports.SwiftRenderer = exports.SwiftTargetLanguage = exports.tsFlowOptions = exports.FlowRenderer = exports.FlowTargetLanguage = void 0;
5
+ exports.dartOptions = exports.DartRenderer = exports.DartTargetLanguage = exports.haskellOptions = exports.HaskellRenderer = exports.HaskellTargetLanguage = exports.CrystalRenderer = exports.CrystalTargetLanguage = exports.rubyOptions = exports.RubyRenderer = exports.RubyTargetLanguage = exports.rustOptions = exports.RustRenderer = exports.RustTargetLanguage = exports.JSONSchemaRenderer = exports.JSONSchemaTargetLanguage = exports.elmOptions = exports.ElmRenderer = exports.ElmTargetLanguage = exports.SmithyOptions = exports.Smithy4sRenderer = exports.SmithyTargetLanguage = exports.scala3Options = exports.Scala3Renderer = exports.Scala3TargetLanguage = exports.kotlinOptions = exports.KotlinRenderer = exports.KotlinTargetLanguage = exports.swiftOptions = exports.SwiftRenderer = exports.SwiftTargetLanguage = exports.tsFlowOptions = exports.FlowRenderer = exports.FlowTargetLanguage = void 0;
6
6
  var Run_1 = require("./Run");
7
7
  Object.defineProperty(exports, "getTargetLanguage", { enumerable: true, get: function () { return Run_1.getTargetLanguage; } });
8
8
  Object.defineProperty(exports, "quicktypeMultiFile", { enumerable: true, get: function () { return Run_1.quicktypeMultiFile; } });
@@ -152,6 +152,14 @@ var Kotlin_1 = require("./language/Kotlin");
152
152
  Object.defineProperty(exports, "KotlinTargetLanguage", { enumerable: true, get: function () { return Kotlin_1.KotlinTargetLanguage; } });
153
153
  Object.defineProperty(exports, "KotlinRenderer", { enumerable: true, get: function () { return Kotlin_1.KotlinRenderer; } });
154
154
  Object.defineProperty(exports, "kotlinOptions", { enumerable: true, get: function () { return Kotlin_1.kotlinOptions; } });
155
+ var Scala3_1 = require("./language/Scala3");
156
+ Object.defineProperty(exports, "Scala3TargetLanguage", { enumerable: true, get: function () { return Scala3_1.Scala3TargetLanguage; } });
157
+ Object.defineProperty(exports, "Scala3Renderer", { enumerable: true, get: function () { return Scala3_1.Scala3Renderer; } });
158
+ Object.defineProperty(exports, "scala3Options", { enumerable: true, get: function () { return Scala3_1.scala3Options; } });
159
+ var Smithy4s_1 = require("./language/Smithy4s");
160
+ Object.defineProperty(exports, "SmithyTargetLanguage", { enumerable: true, get: function () { return Smithy4s_1.SmithyTargetLanguage; } });
161
+ Object.defineProperty(exports, "Smithy4sRenderer", { enumerable: true, get: function () { return Smithy4s_1.Smithy4sRenderer; } });
162
+ Object.defineProperty(exports, "SmithyOptions", { enumerable: true, get: function () { return Smithy4s_1.SmithyOptions; } });
155
163
  var Elm_1 = require("./language/Elm");
156
164
  Object.defineProperty(exports, "ElmTargetLanguage", { enumerable: true, get: function () { return Elm_1.ElmTargetLanguage; } });
157
165
  Object.defineProperty(exports, "ElmRenderer", { enumerable: true, get: function () { return Elm_1.ElmRenderer; } });
@@ -12,6 +12,8 @@ const JavaScriptPropTypes_1 = require("./JavaScriptPropTypes");
12
12
  const TypeScriptFlow_1 = require("./TypeScriptFlow");
13
13
  const Swift_1 = require("./Swift");
14
14
  const Kotlin_1 = require("./Kotlin");
15
+ const Scala3_1 = require("./Scala3");
16
+ const Smithy4s_1 = require("./Smithy4s");
15
17
  const Elm_1 = require("./Elm");
16
18
  const JSONSchema_1 = require("./JSONSchema");
17
19
  const Rust_1 = require("./Rust");
@@ -35,6 +37,8 @@ exports.all = [
35
37
  new JavaScriptPropTypes_1.JavaScriptPropTypesTargetLanguage(),
36
38
  new TypeScriptFlow_1.FlowTargetLanguage(),
37
39
  new Swift_1.SwiftTargetLanguage(),
40
+ new Scala3_1.Scala3TargetLanguage(),
41
+ new Smithy4s_1.SmithyTargetLanguage(),
38
42
  new Kotlin_1.KotlinTargetLanguage(),
39
43
  new Elm_1.ElmTargetLanguage(),
40
44
  new JSONSchema_1.JSONSchemaTargetLanguage(),
@@ -765,7 +765,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
765
765
  const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u, true);
766
766
  (0, Support_2.assert)(nonNulls.size >= 2, "Variant not needed for less than two types.");
767
767
  const indirection = maybeNull !== null;
768
- const variant = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: !indirection, needsOptionalIndirection: !indirection, inJsonNamespace }, true, false);
768
+ const variant = this.cppTypeInOptional(nonNulls, {
769
+ needsForwardIndirection: !indirection,
770
+ needsOptionalIndirection: !indirection,
771
+ inJsonNamespace
772
+ }, true, false);
769
773
  if (!indirection) {
770
774
  return variant;
771
775
  }
@@ -814,7 +818,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
814
818
  }
815
819
  }, arrayType => [
816
820
  "std::vector<",
817
- this.cppType(arrayType.items, { needsForwardIndirection: false, needsOptionalIndirection: true, inJsonNamespace }, withIssues, forceNarrowString, false),
821
+ this.cppType(arrayType.items, {
822
+ needsForwardIndirection: false,
823
+ needsOptionalIndirection: true,
824
+ inJsonNamespace
825
+ }, withIssues, forceNarrowString, false),
818
826
  ">"
819
827
  ], classType => this.variantIndirection(classType, ctx.needsForwardIndirection && this.isForwardDeclaredType(classType) && !isOptional, [this.ourQualifier(inJsonNamespace), this.nameForNamedType(classType)]), mapType => {
820
828
  let keyType = this._stringType.getType();
@@ -825,14 +833,22 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
825
833
  "std::map<",
826
834
  keyType,
827
835
  ", ",
828
- this.cppType(mapType.values, { needsForwardIndirection: false, needsOptionalIndirection: true, inJsonNamespace }, withIssues, forceNarrowString, false),
836
+ this.cppType(mapType.values, {
837
+ needsForwardIndirection: false,
838
+ needsOptionalIndirection: true,
839
+ inJsonNamespace
840
+ }, withIssues, forceNarrowString, false),
829
841
  ">"
830
842
  ];
831
843
  }, enumType => [this.ourQualifier(inJsonNamespace), this.nameForNamedType(enumType)], unionType => {
832
844
  const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
833
845
  if (nullable !== null) {
834
846
  isOptional = true;
835
- return this.cppType(nullable, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace }, withIssues, forceNarrowString, false);
847
+ return this.cppType(nullable, {
848
+ needsForwardIndirection: false,
849
+ needsOptionalIndirection: false,
850
+ inJsonNamespace
851
+ }, withIssues, forceNarrowString, false);
836
852
  }
837
853
  else {
838
854
  return [this.ourQualifier(inJsonNamespace), this.nameForNamedType(unionType)];
@@ -920,7 +936,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
920
936
  if (this._options.codeFormat) {
921
937
  this.emitLine("private:");
922
938
  this.forEachClassProperty(c, "none", (name, jsonName, property) => {
923
- this.emitMember(this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional), name);
939
+ this.emitMember(this.cppType(property.type, {
940
+ needsForwardIndirection: true,
941
+ needsOptionalIndirection: true,
942
+ inJsonNamespace: false
943
+ }, true, false, property.isOptional), name);
924
944
  if (constraints !== undefined && constraints.has(jsonName)) {
925
945
  /** FIXME!!! NameStyle will/can collide with other Names */
926
946
  const cnst = this.lookupGlobalName(GlobalNames.ClassMemberConstraints);
@@ -933,11 +953,19 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
933
953
  this.forEachClassProperty(c, "none", (name, jsonName, property) => {
934
954
  this.emitDescription(this.descriptionForClassProperty(c, jsonName));
935
955
  if (!this._options.codeFormat) {
936
- this.emitMember(this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional), name);
956
+ this.emitMember(this.cppType(property.type, {
957
+ needsForwardIndirection: true,
958
+ needsOptionalIndirection: true,
959
+ inJsonNamespace: false
960
+ }, true, false, property.isOptional), name);
937
961
  }
938
962
  else {
939
963
  const [getterName, mutableGetterName, setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
940
- const rendered = this.cppType(property.type, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, property.isOptional);
964
+ const rendered = this.cppType(property.type, {
965
+ needsForwardIndirection: true,
966
+ needsOptionalIndirection: true,
967
+ inJsonNamespace: false
968
+ }, true, false, property.isOptional);
941
969
  /**
942
970
  * fix for optional type -> e.g. unique_ptrs can't be copied
943
971
  * One might as why the "this->xxx = value". Simple if we have
@@ -1067,8 +1095,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1067
1095
  className,
1068
1096
  "& x)"
1069
1097
  ], false, () => {
1070
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1071
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
1098
+ cppType = this.cppType(t, {
1099
+ needsForwardIndirection: true,
1100
+ needsOptionalIndirection: true,
1101
+ inJsonNamespace: true
1102
+ }, false, true, false);
1103
+ toType = this.cppType(t, {
1104
+ needsForwardIndirection: true,
1105
+ needsOptionalIndirection: true,
1106
+ inJsonNamespace: true
1107
+ }, false, false, false);
1072
1108
  this.emitLine([
1073
1109
  "x = ",
1074
1110
  this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
@@ -1087,8 +1123,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1087
1123
  this.withConst([ourQualifier, className]),
1088
1124
  " & x)"
1089
1125
  ], false, () => {
1090
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
1091
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1126
+ cppType = this.cppType(t, {
1127
+ needsForwardIndirection: true,
1128
+ needsOptionalIndirection: true,
1129
+ inJsonNamespace: true
1130
+ }, false, false, false);
1131
+ toType = this.cppType(t, {
1132
+ needsForwardIndirection: true,
1133
+ needsOptionalIndirection: true,
1134
+ inJsonNamespace: true
1135
+ }, false, true, false);
1092
1136
  this.emitLine([
1093
1137
  "j = ",
1094
1138
  this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, "x"),
@@ -1157,8 +1201,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1157
1201
  return;
1158
1202
  }
1159
1203
  }
1160
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
1161
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1204
+ cppType = this.cppType(t, {
1205
+ needsForwardIndirection: true,
1206
+ needsOptionalIndirection: true,
1207
+ inJsonNamespace: false
1208
+ }, false, true, p.isOptional);
1209
+ toType = this.cppType(t, {
1210
+ needsForwardIndirection: true,
1211
+ needsOptionalIndirection: true,
1212
+ inJsonNamespace: false
1213
+ }, false, false, p.isOptional);
1162
1214
  this.emitLine(assignment.wrap([], this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
1163
1215
  "j.at(",
1164
1216
  this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])),
@@ -1173,8 +1225,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1173
1225
  this.emitLine("j = json::object();");
1174
1226
  this.forEachClassProperty(c, "none", (name, json, p) => {
1175
1227
  const t = p.type;
1176
- cppType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, false, p.isOptional);
1177
- toType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, false, true, p.isOptional);
1228
+ cppType = this.cppType(t, {
1229
+ needsForwardIndirection: true,
1230
+ needsOptionalIndirection: true,
1231
+ inJsonNamespace: false
1232
+ }, false, false, p.isOptional);
1233
+ toType = this.cppType(t, {
1234
+ needsForwardIndirection: true,
1235
+ needsOptionalIndirection: true,
1236
+ inJsonNamespace: false
1237
+ }, false, true, p.isOptional);
1178
1238
  const [getterName, ,] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
1179
1239
  let getter;
1180
1240
  if (this._options.codeFormat) {
@@ -1232,7 +1292,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1232
1292
  // but it's nontrivial to detect that (consider variant<string, variant<map<string, string>, int>> which
1233
1293
  // does need an adl_serializer specialization) so we'll just specialize every time.
1234
1294
  const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1235
- const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1295
+ const variantType = this.cppTypeInOptional(nonNulls, {
1296
+ needsForwardIndirection: false,
1297
+ needsOptionalIndirection: false,
1298
+ inJsonNamespace: true
1299
+ }, false, false);
1236
1300
  this.emitLine("template <>");
1237
1301
  this.emitBlock(["struct adl_serializer<", variantType, ">"], true, () => {
1238
1302
  this.emitLine("static void from_json(", this.withConst("json"), " & j, ", variantType, " & x);");
@@ -1253,7 +1317,11 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1253
1317
  ["enum", "is_string"]
1254
1318
  ];
1255
1319
  const nonNulls = (0, TypeUtils_1.removeNullFromUnion)(u, true)[1];
1256
- const variantType = this.cppTypeInOptional(nonNulls, { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false);
1320
+ const variantType = this.cppTypeInOptional(nonNulls, {
1321
+ needsForwardIndirection: false,
1322
+ needsOptionalIndirection: false,
1323
+ inJsonNamespace: true
1324
+ }, false, false);
1257
1325
  this.emitBlock([
1258
1326
  "inline void adl_serializer<",
1259
1327
  variantType,
@@ -1270,8 +1338,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1270
1338
  continue;
1271
1339
  this.emitLine(onFirst ? "if" : "else if", " (j.", func, "())");
1272
1340
  this.indent(() => {
1273
- const cppType = this.cppType(typeForKind, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
1274
- let toType = this.cppType(typeForKind, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
1341
+ const cppType = this.cppType(typeForKind, {
1342
+ needsForwardIndirection: true,
1343
+ needsOptionalIndirection: true,
1344
+ inJsonNamespace: true
1345
+ }, false, true, false);
1346
+ let toType = this.cppType(typeForKind, {
1347
+ needsForwardIndirection: true,
1348
+ needsOptionalIndirection: true,
1349
+ inJsonNamespace: true
1350
+ }, false, false, false);
1275
1351
  this.emitLine("x = ", this._stringType.wrapEncodingChange([ourQualifier], cppType, toType, [
1276
1352
  "j.get<",
1277
1353
  cppType,
@@ -1280,7 +1356,6 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1280
1356
  });
1281
1357
  onFirst = false;
1282
1358
  }
1283
- // this.emitLine('else throw "Could not deserialize";');
1284
1359
  this.emitLine('else throw std::runtime_error("Could not deserialise!");');
1285
1360
  });
1286
1361
  this.ensureBlankLine();
@@ -1309,7 +1384,6 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1309
1384
  });
1310
1385
  i++;
1311
1386
  }
1312
- // this.emitLine('default: throw "Input JSON does not conform to schema";');
1313
1387
  this.emitLine('default: throw std::runtime_error("Input JSON does not conform to schema!");');
1314
1388
  });
1315
1389
  });
@@ -1352,7 +1426,6 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1352
1426
  this.emitLine(maybeElse, "if (j == ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), ") x = ", ourQualifier, enumName, "::", name, ";");
1353
1427
  onFirst = false;
1354
1428
  });
1355
- // this.emitLine('else throw "Input JSON does not conform to schema";');
1356
1429
  this.emitLine('else { throw std::runtime_error("Input JSON does not conform to schema!"); }');
1357
1430
  }
1358
1431
  });
@@ -1362,19 +1435,30 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1362
1435
  this.forEachEnumCase(e, "none", (name, jsonName) => {
1363
1436
  this.emitLine("case ", ourQualifier, enumName, "::", name, ": j = ", this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(jsonName)])]), "; break;");
1364
1437
  });
1365
- // this.emitLine('default: throw "This should not happen";');
1366
1438
  this.emitLine('default: throw std::runtime_error("This should not happen");');
1367
1439
  });
1368
1440
  });
1369
1441
  }
1370
1442
  emitTopLevelTypedef(t, name) {
1371
- this.emitLine("using ", name, " = ", this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: false }, true, false, false), ";");
1443
+ this.emitLine("using ", name, " = ", this.cppType(t, {
1444
+ needsForwardIndirection: true,
1445
+ needsOptionalIndirection: true,
1446
+ inJsonNamespace: false
1447
+ }, true, false, false), ";");
1372
1448
  }
1373
1449
  emitAllUnionFunctions() {
1374
- this.forEachUniqueUnion("leading-and-interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionFunctions(u));
1450
+ this.forEachUniqueUnion("leading-and-interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], {
1451
+ needsForwardIndirection: false,
1452
+ needsOptionalIndirection: false,
1453
+ inJsonNamespace: true
1454
+ }, false, false)), (u) => this.emitUnionFunctions(u));
1375
1455
  }
1376
1456
  emitAllUnionHeaders() {
1377
- this.forEachUniqueUnion("interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], { needsForwardIndirection: false, needsOptionalIndirection: false, inJsonNamespace: true }, false, false)), (u) => this.emitUnionHeaders(u));
1457
+ this.forEachUniqueUnion("interposing", u => this.sourcelikeToString(this.cppTypeInOptional((0, TypeUtils_1.removeNullFromUnion)(u, true)[1], {
1458
+ needsForwardIndirection: false,
1459
+ needsOptionalIndirection: false,
1460
+ inJsonNamespace: true
1461
+ }, false, false)), (u) => this.emitUnionHeaders(u));
1378
1462
  }
1379
1463
  emitOptionalHelpers() {
1380
1464
  this.emitLine("#ifndef NLOHMANN_OPT_HELPER");
@@ -1956,8 +2040,16 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1956
2040
  }
1957
2041
  }
1958
2042
  isConversionRequired(t) {
1959
- let originalType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, false, false);
1960
- let newType = this.cppType(t, { needsForwardIndirection: true, needsOptionalIndirection: true, inJsonNamespace: true }, false, true, false);
2043
+ let originalType = this.cppType(t, {
2044
+ needsForwardIndirection: true,
2045
+ needsOptionalIndirection: true,
2046
+ inJsonNamespace: true
2047
+ }, false, false, false);
2048
+ let newType = this.cppType(t, {
2049
+ needsForwardIndirection: true,
2050
+ needsOptionalIndirection: true,
2051
+ inJsonNamespace: true
2052
+ }, false, true, false);
1961
2053
  return originalType !== newType;
1962
2054
  }
1963
2055
  }
@@ -0,0 +1,77 @@
1
+ import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
2
+ import { Name, Namer } from "../Naming";
3
+ import { EnumOption, Option, StringOption, OptionValues } from "../RendererOptions";
4
+ import { Sourcelike } from "../Source";
5
+ import { TargetLanguage } from "../TargetLanguage";
6
+ import { ArrayType, ClassType, EnumType, MapType, ObjectType, Type, UnionType } from "../Type";
7
+ import { RenderContext } from "../Renderer";
8
+ export declare enum Framework {
9
+ None = 0,
10
+ Upickle = 1,
11
+ Circe = 2
12
+ }
13
+ export declare const scala3Options: {
14
+ framework: EnumOption<Framework>;
15
+ packageName: StringOption;
16
+ };
17
+ export declare class Scala3Renderer extends ConvenienceRenderer {
18
+ protected readonly _scalaOptions: OptionValues<typeof scala3Options>;
19
+ constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _scalaOptions: OptionValues<typeof scala3Options>);
20
+ protected forbiddenNamesForGlobalNamespace(): string[];
21
+ protected forbiddenForObjectProperties(_: ObjectType, _classNamed: Name): ForbiddenWordsInfo;
22
+ protected forbiddenForEnumCases(_: EnumType, _enumName: Name): ForbiddenWordsInfo;
23
+ protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
24
+ protected topLevelNameStyle(rawName: string): string;
25
+ protected makeNamedTypeNamer(): Namer;
26
+ protected namerForObjectProperty(): Namer;
27
+ protected makeUnionMemberNamer(): Namer;
28
+ protected makeEnumCaseNamer(): Namer;
29
+ protected emitDescriptionBlock(lines: Sourcelike[]): void;
30
+ protected emitBlock(line: Sourcelike, f: () => void, delimiter?: "curly" | "paren" | "lambda" | "none"): void;
31
+ protected anySourceType(optional: boolean): Sourcelike;
32
+ protected arrayType(arrayType: ArrayType, withIssues?: boolean): Sourcelike;
33
+ protected mapType(mapType: MapType, withIssues?: boolean): Sourcelike;
34
+ protected scalaType(t: Type, withIssues?: boolean, noOptional?: boolean): Sourcelike;
35
+ protected emitUsageHeader(): void;
36
+ protected emitHeader(): void;
37
+ protected emitTopLevelArray(t: ArrayType, name: Name): void;
38
+ protected emitTopLevelMap(t: MapType, name: Name): void;
39
+ protected emitEmptyClassDefinition(c: ClassType, className: Name): void;
40
+ protected emitClassDefinition(c: ClassType, className: Name): void;
41
+ protected emitClassDefinitionMethods(): void;
42
+ protected emitEnumDefinition(e: EnumType, enumName: Name): void;
43
+ protected emitUnionDefinition(u: UnionType, unionName: Name): void;
44
+ protected emitSourceStructure(): void;
45
+ }
46
+ export declare class UpickleRenderer extends Scala3Renderer {
47
+ protected emitClassDefinitionMethods(): void;
48
+ protected emitHeader(): void;
49
+ }
50
+ export declare class Smithy4sRenderer extends Scala3Renderer {
51
+ protected emitHeader(): void;
52
+ protected emitTopLevelArray(t: ArrayType, name: Name): void;
53
+ protected emitTopLevelMap(t: MapType, name: Name): void;
54
+ protected emitEmptyClassDefinition(c: ClassType, className: Name): void;
55
+ protected emitEnumDefinition(e: EnumType, enumName: Name): void;
56
+ }
57
+ export declare class CirceRenderer extends Scala3Renderer {
58
+ seenUnionTypes: Array<string>;
59
+ protected circeEncoderForType(t: Type, _?: boolean, noOptional?: boolean, paramName?: string): Sourcelike;
60
+ protected emitEmptyClassDefinition(c: ClassType, className: Name): void;
61
+ protected anySourceType(optional: boolean): Sourcelike;
62
+ protected emitClassDefinitionMethods(): void;
63
+ protected emitEnumDefinition(e: EnumType, enumName: Name): void;
64
+ protected emitHeader(): void;
65
+ protected emitTopLevelArray(t: ArrayType, name: Name): void;
66
+ protected emitTopLevelMap(t: MapType, name: Name): void;
67
+ protected emitUnionDefinition(u: UnionType, unionName: Name): void;
68
+ }
69
+ export declare class Scala3TargetLanguage extends TargetLanguage {
70
+ constructor();
71
+ protected getOptions(): Option<any>[];
72
+ get supportsOptionalClassProperties(): boolean;
73
+ get supportsUnionsWithBothNumberTypes(): boolean;
74
+ protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
75
+ [name: string]: any;
76
+ }): ConvenienceRenderer;
77
+ }