quicktype-core 23.0.46 → 23.0.48

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.
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.descriptionAttributeProducer = exports.propertyDescriptionsTypeAttributeKind = exports.descriptionTypeAttributeKind = exports.addDescriptionToSchema = void 0;
4
4
  const collection_utils_1 = require("collection-utils");
5
+ // There's a cyclic import here. Ignoring now because it requires a large refactor.
6
+ // skipcq: JS-E1008
5
7
  const TypeAttributes_1 = require("./TypeAttributes");
8
+ // FIXME: This is a circular import
6
9
  const JSONSchemaInput_1 = require("../input/JSONSchemaInput");
7
10
  function addDescriptionToSchema(schema, description) {
8
11
  if (description === undefined)
@@ -2,8 +2,8 @@ import URI from "urijs";
2
2
  import { TypeBuilder } from "../TypeBuilder";
3
3
  import { TypeAttributes } from "../attributes/TypeAttributes";
4
4
  import { JSONSchema, JSONSchemaStore } from "./JSONSchemaStore";
5
- import { RunContext } from "../Run";
6
- import { Input } from "./Inputs";
5
+ import { type RunContext } from "../Run";
6
+ import { type Input } from "./Inputs";
7
7
  export declare enum PathElementKind {
8
8
  Root = 0,
9
9
  KeyOrIndex = 1,
@@ -23,6 +23,8 @@ const TypeAttributes_1 = require("../attributes/TypeAttributes");
23
23
  const JSONSchemaStore_1 = require("./JSONSchemaStore");
24
24
  const Messages_1 = require("../Messages");
25
25
  const StringTypes_1 = require("../attributes/StringTypes");
26
+ // There's a cyclic import here. Ignoring now because it requires a large refactor.
27
+ // skipcq: JS-E1008
26
28
  const Description_1 = require("../attributes/Description");
27
29
  const AccessorNames_1 = require("../attributes/AccessorNames");
28
30
  const EnumValues_1 = require("../attributes/EnumValues");
@@ -102,8 +102,8 @@ export type TypeContext = {
102
102
  inJsonNamespace: boolean;
103
103
  };
104
104
  declare class WrappingCode {
105
- private readonly _start;
106
- private readonly _end;
105
+ private readonly start;
106
+ private readonly end;
107
107
  constructor(start: Sourcelike[], end: Sourcelike[]);
108
108
  wrap(qualifier: Sourcelike, inner: Sourcelike): Sourcelike;
109
109
  }
@@ -273,23 +273,23 @@ function addQualifier(qualifier, qualified) {
273
273
  }
274
274
  class WrappingCode {
275
275
  constructor(start, end) {
276
- this._start = start;
277
- this._end = end;
276
+ this.start = start;
277
+ this.end = end;
278
278
  }
279
279
  wrap(qualifier, inner) {
280
- return [addQualifier(qualifier, this._start), inner, this._end];
280
+ return [addQualifier(qualifier, this.start), inner, this.end];
281
281
  }
282
282
  }
283
283
  class BaseString {
284
284
  constructor(stringType, constStringType, smatch, regex, stringLiteralPrefix, toString, encodingClass, encodingFunction) {
285
- (this._stringType = stringType),
286
- (this._constStringType = constStringType),
287
- (this._smatch = smatch),
288
- (this._regex = regex),
289
- (this._stringLiteralPrefix = stringLiteralPrefix),
290
- (this._toString = toString),
291
- (this._encodingClass = encodingClass),
292
- (this._encodingFunction = encodingFunction);
285
+ this._stringType = stringType;
286
+ this._constStringType = constStringType;
287
+ this._smatch = smatch;
288
+ this._regex = regex;
289
+ this._stringLiteralPrefix = stringLiteralPrefix;
290
+ this._toString = toString;
291
+ this._encodingClass = encodingClass;
292
+ this._encodingFunction = encodingFunction;
293
293
  }
294
294
  getType() {
295
295
  return this._stringType;
@@ -900,7 +900,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
900
900
  type: t,
901
901
  level: l,
902
902
  variant: isVariant,
903
- forceInclude: forceInclude
903
+ forceInclude
904
904
  });
905
905
  }
906
906
  else if (t instanceof Type_1.MapType) {
@@ -937,7 +937,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
937
937
  type: t,
938
938
  level: l,
939
939
  variant: true,
940
- forceInclude: forceInclude
940
+ forceInclude
941
941
  });
942
942
  /** intentional "fall-through", add all subtypes as well - but forced include */
943
943
  }
@@ -953,7 +953,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
953
953
  return result;
954
954
  }
955
955
  constraintMember(jsonName) {
956
- return this._memberNameStyle(jsonName + "Constraint");
956
+ return this._memberNameStyle(`${jsonName}Constraint`);
957
957
  }
958
958
  emitMember(cppType, name) {
959
959
  this.emitLine(cppType, " ", name, ";");
@@ -1180,7 +1180,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1180
1180
  this.emitBlock(["inline void from_json(", this.withConst("json"), " & j, ", ourQualifier, className, "& x)"], false, () => {
1181
1181
  this.forEachClassProperty(c, "none", (name, json, p) => {
1182
1182
  const [, , setterName] = (0, Support_1.defined)(this._gettersAndSettersForPropertyName.get(name));
1183
- const t = p.type;
1183
+ const propType = p.type;
1184
1184
  let assignment;
1185
1185
  if (this._options.codeFormat) {
1186
1186
  assignment = new WrappingCode(["x.", setterName, "("], [")"]);
@@ -1188,7 +1188,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1188
1188
  else {
1189
1189
  assignment = new WrappingCode(["x.", name, " = "], []);
1190
1190
  }
1191
- if (t.kind === "null" || t.kind === "any") {
1191
+ if (propType.kind === "null" || propType.kind === "any") {
1192
1192
  this.emitLine(assignment.wrap([], [
1193
1193
  ourQualifier,
1194
1194
  "get_untyped(j, ",
@@ -1197,15 +1197,15 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1197
1197
  ]), ";");
1198
1198
  return;
1199
1199
  }
1200
- if (p.isOptional || t instanceof Type_1.UnionType) {
1200
+ if (p.isOptional || propType instanceof Type_1.UnionType) {
1201
1201
  const [nullOrOptional, typeSet] = (function () {
1202
- if (t instanceof Type_1.UnionType) {
1203
- const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(t, true);
1202
+ if (propType instanceof Type_1.UnionType) {
1203
+ const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(propType, true);
1204
1204
  return [maybeNull !== null || p.isOptional, nonNulls];
1205
1205
  }
1206
1206
  else {
1207
1207
  const set = new Set();
1208
- set.add(t);
1208
+ set.add(propType);
1209
1209
  return [true, set];
1210
1210
  }
1211
1211
  })();
@@ -1221,9 +1221,9 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1221
1221
  inJsonNamespace: false
1222
1222
  }, false, false);
1223
1223
  this.emitLine(assignment.wrap([], [
1224
- this._stringType.wrapEncodingChange([ourQualifier], [this.optionalType(t), "<", cppType, ">"], [this.optionalType(t), "<", toType, ">"], [
1224
+ this._stringType.wrapEncodingChange([ourQualifier], [this.optionalType(propType), "<", cppType, ">"], [this.optionalType(propType), "<", toType, ">"], [
1225
1225
  ourQualifier,
1226
- `get_${this.optionalTypeLabel(t)}_optional<`,
1226
+ `get_${this.optionalTypeLabel(propType)}_optional<`,
1227
1227
  cppType,
1228
1228
  ">(j, ",
1229
1229
  this._stringType.wrapEncodingChange([ourQualifier], this._stringType.getType(), this.NarrowString.getType(), [this._stringType.createStringLiteral([(0, Strings_1.stringEscape)(json)])]),
@@ -1233,12 +1233,12 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1233
1233
  return;
1234
1234
  }
1235
1235
  }
1236
- cppType = this.cppType(t, {
1236
+ cppType = this.cppType(propType, {
1237
1237
  needsForwardIndirection: true,
1238
1238
  needsOptionalIndirection: true,
1239
1239
  inJsonNamespace: false
1240
1240
  }, false, true, p.isOptional);
1241
- toType = this.cppType(t, {
1241
+ toType = this.cppType(propType, {
1242
1242
  needsForwardIndirection: true,
1243
1243
  needsOptionalIndirection: true,
1244
1244
  inJsonNamespace: false
@@ -1256,13 +1256,13 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1256
1256
  this.emitBlock(["inline void to_json(json & j, ", this.withConst([ourQualifier, className]), " & x)"], false, () => {
1257
1257
  this.emitLine("j = json::object();");
1258
1258
  this.forEachClassProperty(c, "none", (name, json, p) => {
1259
- const t = p.type;
1260
- cppType = this.cppType(t, {
1259
+ const propType = p.type;
1260
+ cppType = this.cppType(propType, {
1261
1261
  needsForwardIndirection: true,
1262
1262
  needsOptionalIndirection: true,
1263
1263
  inJsonNamespace: false
1264
1264
  }, false, false, p.isOptional);
1265
- toType = this.cppType(t, {
1265
+ toType = this.cppType(propType, {
1266
1266
  needsForwardIndirection: true,
1267
1267
  needsOptionalIndirection: true,
1268
1268
  inJsonNamespace: false
@@ -1523,23 +1523,23 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1523
1523
  }
1524
1524
  }
1525
1525
  else if (decl.kind === "define") {
1526
- const t = decl.type;
1527
- const name = this.nameForNamedType(t);
1528
- if (t instanceof Type_1.ClassType) {
1529
- this.emitClass(t, name);
1526
+ const type = decl.type;
1527
+ const name = this.nameForNamedType(type);
1528
+ if (type instanceof Type_1.ClassType) {
1529
+ this.emitClass(type, name);
1530
1530
  }
1531
- else if (t instanceof Type_1.EnumType) {
1532
- this.emitEnum(t, name);
1531
+ else if (type instanceof Type_1.EnumType) {
1532
+ this.emitEnum(type, name);
1533
1533
  }
1534
- else if (t instanceof Type_1.UnionType) {
1535
- this.emitUnionTypedefs(t, name);
1534
+ else if (type instanceof Type_1.UnionType) {
1535
+ this.emitUnionTypedefs(type, name);
1536
1536
  }
1537
1537
  else {
1538
- return (0, Support_1.panic)(`Cannot declare type ${t.kind}`);
1538
+ (0, Support_1.panic)(`Cannot declare type ${type.kind}`);
1539
1539
  }
1540
1540
  }
1541
1541
  else {
1542
- return (0, Support_1.assertNever)(decl.kind);
1542
+ (0, Support_1.assertNever)(decl.kind);
1543
1543
  }
1544
1544
  }
1545
1545
  emitGetterSetter(t, getterName, setterName, memberName) {
@@ -1695,8 +1695,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1695
1695
  });
1696
1696
  untypedMacroName += "HELPER";
1697
1697
  optionalMacroName += "HELPER";
1698
- this.emitLine("#ifndef " + untypedMacroName);
1699
- this.emitLine("#define " + untypedMacroName);
1698
+ this.emitLine(`#ifndef ${untypedMacroName}`);
1699
+ this.emitLine(`#define ${untypedMacroName}`);
1700
1700
  this.emitBlock(["inline json get_untyped(", this.withConst("json"), " & j, ", this.withConst("char"), " * property)"], false, () => {
1701
1701
  this.emitBlock(["if (j.find(property) != j.end())"], false, () => {
1702
1702
  this.emitLine("return j.at(property).get<json>();");
@@ -1711,8 +1711,8 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1711
1711
  this.ensureBlankLine();
1712
1712
  if (this.haveUnions || this.haveOptionalProperties) {
1713
1713
  this.ensureBlankLine();
1714
- this.emitLine("#ifndef " + optionalMacroName);
1715
- this.emitLine("#define " + optionalMacroName);
1714
+ this.emitLine(`#ifndef ${optionalMacroName}`);
1715
+ this.emitLine(`#define ${optionalMacroName}`);
1716
1716
  const emitGetOptional = (optionalType, label) => {
1717
1717
  this.emitLine("template <typename T>");
1718
1718
  this.emitBlock([
@@ -1752,28 +1752,28 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1752
1752
  this.ensureBlankLine();
1753
1753
  if (this._options.codeFormat) {
1754
1754
  if (this._options.boost) {
1755
- this.emitInclude(true, `boost/optional.hpp`);
1755
+ this.emitInclude(true, "boost/optional.hpp");
1756
1756
  }
1757
1757
  else {
1758
- this.emitInclude(true, `optional`);
1758
+ this.emitInclude(true, "optional");
1759
1759
  }
1760
- this.emitInclude(true, `stdexcept`);
1761
- this.emitInclude(true, `regex`);
1760
+ this.emitInclude(true, "stdexcept");
1761
+ this.emitInclude(true, "regex");
1762
1762
  }
1763
1763
  if (this._options.wstring) {
1764
- this.emitInclude(true, `codecvt`);
1765
- this.emitInclude(true, `locale`);
1764
+ this.emitInclude(true, "codecvt");
1765
+ this.emitInclude(true, "locale");
1766
1766
  }
1767
1767
  // Include unordered_map if contains large enums
1768
1768
  if (Array.from(this.enums).some(enumType => this.isLargeEnum(enumType))) {
1769
- this.emitInclude(true, `unordered_map`);
1769
+ this.emitInclude(true, "unordered_map");
1770
1770
  }
1771
1771
  this.ensureBlankLine();
1772
1772
  }
1773
1773
  emitHelper() {
1774
1774
  this.startFile("helper.hpp", false);
1775
1775
  this.emitExtraIncludes();
1776
- this.emitInclude(true, `sstream`);
1776
+ this.emitInclude(true, "sstream");
1777
1777
  this.ensureBlankLine();
1778
1778
  this.emitNamespaces(this._namespaceNames, () => {
1779
1779
  this.emitLine("using nlohmann::json;");
@@ -1833,13 +1833,13 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1833
1833
  else {
1834
1834
  const userNamespaceForwardDecls = this.gatherUserNamespaceForwardDecls();
1835
1835
  const nlohmannNamespaceForwardDecls = this.gatherNlohmannNamespaceForwardDecls();
1836
- if (userNamespaceForwardDecls.length == 0 && nlohmannNamespaceForwardDecls.length > 0) {
1836
+ if (userNamespaceForwardDecls.length === 0 && nlohmannNamespaceForwardDecls.length > 0) {
1837
1837
  this.emitNamespaces(["nlohmann"], () => {
1838
1838
  this.emitGatheredSource(nlohmannNamespaceForwardDecls);
1839
1839
  this.emitNlohmannNamespaceImpls();
1840
1840
  });
1841
1841
  }
1842
- else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length == 0) {
1842
+ else if (userNamespaceForwardDecls.length > 0 && nlohmannNamespaceForwardDecls.length === 0) {
1843
1843
  this.emitNamespaces(this._namespaceNames, () => {
1844
1844
  this.emitGatheredSource(userNamespaceForwardDecls);
1845
1845
  this.emitUserNamespaceImpls();
@@ -1996,7 +1996,7 @@ class CPlusPlusRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
1996
1996
  }
1997
1997
  }
1998
1998
  emitDefinition(d, defName) {
1999
- const name = this.sourcelikeToString(defName) + ".hpp";
1999
+ const name = `${this.sourcelikeToString(defName)}.hpp`;
2000
2000
  this.startFile(name, true);
2001
2001
  this._generatedFiles.add(name);
2002
2002
  this.emitIncludes(d, this.sourcelikeToString(defName));
@@ -215,10 +215,16 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
215
215
  this.emitPackageDefinitons(false);
216
216
  this.emitDescription(this.descriptionForType(e));
217
217
  this.emitLine("type ", enumName, " string");
218
+ this.ensureBlankLine();
218
219
  this.emitLine("const (");
219
- this.indent(() => this.forEachEnumCase(e, "none", (name, jsonName) => {
220
- this.emitLine(name, " ", enumName, ' = "', (0, Strings_1.stringEscape)(jsonName), '"');
221
- }));
220
+ let columns = [];
221
+ this.forEachEnumCase(e, "none", (name, jsonName) => {
222
+ columns.push([
223
+ [name, " "],
224
+ [enumName, ' = "', (0, Strings_1.stringEscape)(jsonName), '"']
225
+ ]);
226
+ });
227
+ this.indent(() => this.emitTable(columns));
222
228
  this.emitLine(")");
223
229
  this.endFile();
224
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.46",
3
+ "version": "23.0.48",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",