quicktype 17.0.5 → 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 +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +283 -217
  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
@@ -14,12 +14,12 @@ export declare const goOptions: {
14
14
  export declare class GoTargetLanguage extends TargetLanguage {
15
15
  constructor();
16
16
  protected getOptions(): Option<any>[];
17
- readonly supportsUnionsWithBothNumberTypes: boolean;
18
- readonly supportsOptionalClassProperties: boolean;
17
+ get supportsUnionsWithBothNumberTypes(): boolean;
18
+ get supportsOptionalClassProperties(): boolean;
19
19
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
20
20
  [name: string]: any;
21
21
  }): GoRenderer;
22
- protected readonly defaultIndentation: string;
22
+ protected get defaultIndentation(): string;
23
23
  }
24
24
  export declare class GoRenderer extends ConvenienceRenderer {
25
25
  private readonly _options;
@@ -30,7 +30,7 @@ export declare class GoRenderer extends ConvenienceRenderer {
30
30
  protected namerForObjectProperty(): Namer;
31
31
  protected makeUnionMemberNamer(): Namer;
32
32
  protected makeEnumCaseNamer(): Namer;
33
- protected readonly enumCasesInGlobalNamespace: boolean;
33
+ protected get enumCasesInGlobalNamespace(): boolean;
34
34
  protected makeTopLevelDependencyNames(_: Type, topLevelName: Name): DependencyName[];
35
35
  protected startFile(basename: Sourcelike): void;
36
36
  protected endFile(): void;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoRenderer = exports.GoTargetLanguage = exports.goOptions = void 0;
3
4
  const Type_1 = require("../Type");
4
5
  const TypeUtils_1 = require("../TypeUtils");
5
6
  const Naming_1 = require("../Naming");
@@ -30,18 +31,18 @@ class GoTargetLanguage extends TargetLanguage_1.TargetLanguage {
30
31
  return true;
31
32
  }
32
33
  makeRenderer(renderContext, untypedOptionValues) {
33
- return new GoRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.goOptions, untypedOptionValues));
34
+ return new GoRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.goOptions, untypedOptionValues));
34
35
  }
35
36
  get defaultIndentation() {
36
37
  return "\t";
37
38
  }
38
39
  }
39
40
  exports.GoTargetLanguage = GoTargetLanguage;
40
- const namingFunction = Naming_1.funPrefixNamer("namer", goNameStyle);
41
- const legalizeName = Strings_1.legalizeCharacters(Strings_1.isLetterOrUnderscoreOrDigit);
41
+ const namingFunction = (0, Naming_1.funPrefixNamer)("namer", goNameStyle);
42
+ const legalizeName = (0, Strings_1.legalizeCharacters)(Strings_1.isLetterOrUnderscoreOrDigit);
42
43
  function goNameStyle(original) {
43
- const words = Strings_1.splitIntoWords(original);
44
- return Strings_1.combineWords(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", Strings_1.isLetterOrUnderscore);
44
+ const words = (0, Strings_1.splitIntoWords)(original);
45
+ return (0, Strings_1.combineWords)(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", Strings_1.isLetterOrUnderscore);
45
46
  }
46
47
  const primitiveValueTypeKinds = ["integer", "double", "bool", "string"];
47
48
  const compoundTypeKinds = ["array", "class", "map", "enum"];
@@ -56,10 +57,12 @@ function canOmitEmpty(cp) {
56
57
  return ["union", "null", "any"].indexOf(t.kind) < 0;
57
58
  }
58
59
  class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
60
+ _options;
61
+ _topLevelUnmarshalNames = new Map();
62
+ _currentFilename;
59
63
  constructor(targetLanguage, renderContext, _options) {
60
64
  super(targetLanguage, renderContext);
61
65
  this._options = _options;
62
- this._topLevelUnmarshalNames = new Map();
63
66
  }
64
67
  makeNamedTypeNamer() {
65
68
  return namingFunction;
@@ -86,7 +89,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
86
89
  if (this._options.multiFileOutput === false) {
87
90
  return;
88
91
  }
89
- Support_1.assert(this._currentFilename === undefined, "Previous file wasn't finished: " + this._currentFilename);
92
+ (0, Support_1.assert)(this._currentFilename === undefined, "Previous file wasn't finished: " + this._currentFilename);
90
93
  // FIXME: The filenames should actually be Sourcelikes, too
91
94
  this._currentFilename = `${this.sourcelikeToString(basename)}.go`.toLowerCase();
92
95
  this.initializeEmitContextForFilename(this._currentFilename);
@@ -96,7 +99,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
96
99
  if (this._options.multiFileOutput === false) {
97
100
  return;
98
101
  }
99
- this.finishFile(Support_1.defined(this._currentFilename));
102
+ this.finishFile((0, Support_1.defined)(this._currentFilename));
100
103
  this._currentFilename = undefined;
101
104
  }
102
105
  emitBlock(line, f) {
@@ -121,7 +124,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
121
124
  }
122
125
  propertyGoType(cp) {
123
126
  const t = cp.type;
124
- if (t instanceof Type_1.UnionType && TypeUtils_1.nullableFromUnion(t) === null) {
127
+ if (t instanceof Type_1.UnionType && (0, TypeUtils_1.nullableFromUnion)(t) === null) {
125
128
  return ["*", this.goType(t, true)];
126
129
  }
127
130
  if (cp.isOptional) {
@@ -130,10 +133,10 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
130
133
  return this.goType(t, true);
131
134
  }
132
135
  goType(t, withIssues = false) {
133
- return TypeUtils_1.matchType(t, _anyType => Source_1.maybeAnnotated(withIssues, Annotation_1.anyTypeIssueAnnotation, "interface{}"), _nullType => Source_1.maybeAnnotated(withIssues, Annotation_1.nullTypeIssueAnnotation, "interface{}"), _boolType => "bool", _integerType => "int64", _doubleType => "float64", _stringType => "string", arrayType => ["[]", this.goType(arrayType.items, withIssues)], classType => this.nameForNamedType(classType), mapType => {
136
+ return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, "interface{}"), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, "interface{}"), _boolType => "bool", _integerType => "int64", _doubleType => "float64", _stringType => "string", arrayType => ["[]", this.goType(arrayType.items, withIssues)], classType => this.nameForNamedType(classType), mapType => {
134
137
  let valueSource;
135
138
  const v = mapType.values;
136
- if (v instanceof Type_1.UnionType && TypeUtils_1.nullableFromUnion(v) === null) {
139
+ if (v instanceof Type_1.UnionType && (0, TypeUtils_1.nullableFromUnion)(v) === null) {
137
140
  valueSource = ["*", this.nameForNamedType(v)];
138
141
  }
139
142
  else {
@@ -141,7 +144,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
141
144
  }
142
145
  return ["map[string]", valueSource];
143
146
  }, enumType => this.nameForNamedType(enumType), unionType => {
144
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
147
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
145
148
  if (nullable !== null)
146
149
  return this.nullableGoType(nullable, withIssues);
147
150
  return this.nameForNamedType(unionType);
@@ -156,12 +159,12 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
156
159
  this.emitLineOnce("// This file was generated from JSON Schema using quicktype, do not modify it directly.");
157
160
  this.emitLineOnce("// To parse and unparse this JSON data, add this code to your project and do:");
158
161
  this.emitLineOnce("//");
159
- const ref = Source_1.modifySource(Strings_1.camelCase, name);
160
- this.emitLineOnce("// ", ref, ", err := ", Support_1.defined(this._topLevelUnmarshalNames.get(name)), "(bytes)");
162
+ const ref = (0, Source_1.modifySource)(Strings_1.camelCase, name);
163
+ this.emitLineOnce("// ", ref, ", err := ", (0, Support_1.defined)(this._topLevelUnmarshalNames.get(name)), "(bytes)");
161
164
  this.emitLineOnce("// bytes, err = ", ref, ".Marshal()");
162
165
  }
163
166
  this.emitPackageDefinitons(true);
164
- const unmarshalName = Support_1.defined(this._topLevelUnmarshalNames.get(name));
167
+ const unmarshalName = (0, Support_1.defined)(this._topLevelUnmarshalNames.get(name));
165
168
  if (this.namedTypeToNameForTopLevel(t) === undefined) {
166
169
  this.emitLine("type ", name, " ", this.goType(t));
167
170
  }
@@ -192,7 +195,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
192
195
  columns.push([
193
196
  [name, " "],
194
197
  [goType, " "],
195
- ['`json:"', Strings_1.stringEscape(jsonName), omitEmpty, '"`']
198
+ ['`json:"', (0, Strings_1.stringEscape)(jsonName), omitEmpty, '"`']
196
199
  ]);
197
200
  });
198
201
  this.emitDescription(this.descriptionForType(c));
@@ -206,7 +209,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
206
209
  this.emitLine("type ", enumName, " string");
207
210
  this.emitLine("const (");
208
211
  this.indent(() => this.forEachEnumCase(e, "none", (name, jsonName) => {
209
- this.emitLine(name, " ", enumName, ' = "', Strings_1.stringEscape(jsonName), '"');
212
+ this.emitLine(name, " ", enumName, ' = "', (0, Strings_1.stringEscape)(jsonName), '"');
210
213
  }));
211
214
  this.emitLine(")");
212
215
  this.endFile();
@@ -214,7 +217,7 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
214
217
  emitUnion(u, unionName) {
215
218
  this.startFile(unionName);
216
219
  this.emitPackageDefinitons(false);
217
- const [hasNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u);
220
+ const [hasNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
218
221
  const isNullableArg = hasNull !== null ? "true" : "false";
219
222
  const ifMember = (kind, ifNotMember, f) => {
220
223
  const maybeType = u.findMember(kind);
@@ -286,8 +289,8 @@ class GoRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
286
289
  this.emitLineOnce("// To parse and unparse this JSON data, add this code to your project and do:");
287
290
  this.forEachTopLevel("none", (_, name) => {
288
291
  this.emitLine("//");
289
- const ref = Source_1.modifySource(Strings_1.camelCase, name);
290
- this.emitLine("// ", ref, ", err := ", Support_1.defined(this._topLevelUnmarshalNames.get(name)), "(bytes)");
292
+ const ref = (0, Source_1.modifySource)(Strings_1.camelCase, name);
293
+ this.emitLine("// ", ref, ", err := ", (0, Support_1.defined)(this._topLevelUnmarshalNames.get(name)), "(bytes)");
291
294
  this.emitLine("// bytes, err = ", ref, ".Marshal()");
292
295
  });
293
296
  }
@@ -13,8 +13,8 @@ export declare const haskellOptions: {
13
13
  export declare class HaskellTargetLanguage extends TargetLanguage {
14
14
  constructor();
15
15
  protected getOptions(): Option<any>[];
16
- readonly supportsOptionalClassProperties: boolean;
17
- readonly supportsUnionsWithBothNumberTypes: boolean;
16
+ get supportsOptionalClassProperties(): boolean;
17
+ get supportsUnionsWithBothNumberTypes(): boolean;
18
18
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
19
19
  [name: string]: any;
20
20
  }): HaskellRenderer;
@@ -27,11 +27,11 @@ export declare class HaskellRenderer extends ConvenienceRenderer {
27
27
  protected namerForObjectProperty(): Namer;
28
28
  protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
29
29
  protected makeUnionMemberNamer(): Namer;
30
- protected readonly unionMembersInGlobalNamespace: boolean;
30
+ protected get unionMembersInGlobalNamespace(): boolean;
31
31
  protected makeEnumCaseNamer(): Namer;
32
- protected readonly enumCasesInGlobalNamespace: boolean;
32
+ protected get enumCasesInGlobalNamespace(): boolean;
33
33
  protected proposeUnionMemberName(u: UnionType, unionName: Name, fieldType: Type, lookup: (n: Name) => string): string;
34
- protected readonly commentLineStart: string;
34
+ protected get commentLineStart(): string;
35
35
  protected emitDescriptionBlock(lines: Sourcelike[]): void;
36
36
  private haskellType;
37
37
  private haskellProperty;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HaskellRenderer = exports.HaskellTargetLanguage = exports.haskellOptions = void 0;
3
4
  const collection_utils_1 = require("collection-utils");
4
5
  const TargetLanguage_1 = require("../TargetLanguage");
5
6
  const RendererOptions_1 = require("../RendererOptions");
@@ -30,7 +31,7 @@ class HaskellTargetLanguage extends TargetLanguage_1.TargetLanguage {
30
31
  return true;
31
32
  }
32
33
  makeRenderer(renderContext, untypedOptionValues) {
33
- return new HaskellRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.haskellOptions, untypedOptionValues));
34
+ return new HaskellRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.haskellOptions, untypedOptionValues));
34
35
  }
35
36
  }
36
37
  exports.HaskellTargetLanguage = HaskellTargetLanguage;
@@ -88,14 +89,15 @@ const forbiddenNames = [
88
89
  "Series",
89
90
  "Error"
90
91
  ];
91
- const legalizeName = Strings_1.legalizeCharacters(cp => Strings_1.isAscii(cp) && Strings_1.isLetterOrUnderscoreOrDigit(cp));
92
+ const legalizeName = (0, Strings_1.legalizeCharacters)(cp => (0, Strings_1.isAscii)(cp) && (0, Strings_1.isLetterOrUnderscoreOrDigit)(cp));
92
93
  function haskellNameStyle(original, upper) {
93
- const words = Strings_1.splitIntoWords(original);
94
- return Strings_1.combineWords(words, legalizeName, upper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, upper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, "", Strings_1.isLetterOrUnderscore);
94
+ const words = (0, Strings_1.splitIntoWords)(original);
95
+ return (0, Strings_1.combineWords)(words, legalizeName, upper ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.firstUpperWordStyle, upper ? Strings_1.allUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, "", Strings_1.isLetterOrUnderscore);
95
96
  }
96
- const upperNamingFunction = Naming_1.funPrefixNamer("upper", n => haskellNameStyle(n, true));
97
- const lowerNamingFunction = Naming_1.funPrefixNamer("lower", n => haskellNameStyle(n, false));
97
+ const upperNamingFunction = (0, Naming_1.funPrefixNamer)("upper", n => haskellNameStyle(n, true));
98
+ const lowerNamingFunction = (0, Naming_1.funPrefixNamer)("lower", n => haskellNameStyle(n, false));
98
99
  class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
100
+ _options;
99
101
  constructor(targetLanguage, renderContext, _options) {
100
102
  super(targetLanguage, renderContext);
101
103
  this._options = _options;
@@ -140,32 +142,32 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
140
142
  }
141
143
  }
142
144
  haskellType(t, noOptional = false) {
143
- return TypeUtils_1.matchType(t, _anyType => Source_1.multiWord(" ", "Maybe", "Text"), _nullType => Source_1.multiWord(" ", "Maybe", "Text"), _boolType => Source_1.singleWord("Bool"), _integerType => Source_1.singleWord("Int"), _doubleType => Source_1.singleWord("Float"), _stringType => Source_1.singleWord("Text"), arrayType => {
145
+ return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.multiWord)(" ", "Maybe", "Text"), _nullType => (0, Source_1.multiWord)(" ", "Maybe", "Text"), _boolType => (0, Source_1.singleWord)("Bool"), _integerType => (0, Source_1.singleWord)("Int"), _doubleType => (0, Source_1.singleWord)("Float"), _stringType => (0, Source_1.singleWord)("Text"), arrayType => {
144
146
  if (this._options.useList) {
145
- return Source_1.multiWord("", "[", Source_1.parenIfNeeded(this.haskellType(arrayType.items)), "]");
147
+ return (0, Source_1.multiWord)("", "[", (0, Source_1.parenIfNeeded)(this.haskellType(arrayType.items)), "]");
146
148
  }
147
- return Source_1.multiWord(" ", "Vector", Source_1.parenIfNeeded(this.haskellType(arrayType.items)));
148
- }, classType => Source_1.singleWord(this.nameForNamedType(classType)), mapType => Source_1.multiWord(" ", "HashMap Text", Source_1.parenIfNeeded(this.haskellType(mapType.values))), enumType => Source_1.singleWord(this.nameForNamedType(enumType)), unionType => {
149
- const nullable = TypeUtils_1.nullableFromUnion(unionType);
149
+ return (0, Source_1.multiWord)(" ", "Vector", (0, Source_1.parenIfNeeded)(this.haskellType(arrayType.items)));
150
+ }, classType => (0, Source_1.singleWord)(this.nameForNamedType(classType)), mapType => (0, Source_1.multiWord)(" ", "HashMap Text", (0, Source_1.parenIfNeeded)(this.haskellType(mapType.values))), enumType => (0, Source_1.singleWord)(this.nameForNamedType(enumType)), unionType => {
151
+ const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
150
152
  if (nullable !== null) {
151
153
  const nullableType = this.haskellType(nullable);
152
154
  if (noOptional)
153
155
  return nullableType;
154
- return Source_1.multiWord(" ", "Maybe", Source_1.parenIfNeeded(nullableType));
156
+ return (0, Source_1.multiWord)(" ", "Maybe", (0, Source_1.parenIfNeeded)(nullableType));
155
157
  }
156
- return Source_1.singleWord(this.nameForNamedType(unionType));
158
+ return (0, Source_1.singleWord)(this.nameForNamedType(unionType));
157
159
  });
158
160
  }
159
161
  haskellProperty(p) {
160
162
  if (p.isOptional) {
161
- return Source_1.multiWord(" ", "Maybe", Source_1.parenIfNeeded(this.haskellType(p.type, true))).source;
163
+ return (0, Source_1.multiWord)(" ", "Maybe", (0, Source_1.parenIfNeeded)(this.haskellType(p.type, true))).source;
162
164
  }
163
165
  else {
164
166
  return this.haskellType(p.type).source;
165
167
  }
166
168
  }
167
169
  encoderNameForType(t) {
168
- return TypeUtils_1.matchType(t, _anyType => Source_1.singleWord("String"), _nullType => Source_1.singleWord("Null"), _boolType => Source_1.singleWord("Bool"), _integerType => Source_1.singleWord("Number"), _doubleType => Source_1.singleWord("Number"), _stringType => Source_1.singleWord("String"), _arrayType => Source_1.singleWord("Array"), _classType => Source_1.singleWord("Object"), _mapType => Source_1.singleWord("Object"), _enumType => Source_1.singleWord("Object"), _unionType => Source_1.singleWord("Object"));
170
+ return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.singleWord)("String"), _nullType => (0, Source_1.singleWord)("Null"), _boolType => (0, Source_1.singleWord)("Bool"), _integerType => (0, Source_1.singleWord)("Number"), _doubleType => (0, Source_1.singleWord)("Number"), _stringType => (0, Source_1.singleWord)("String"), _arrayType => (0, Source_1.singleWord)("Array"), _classType => (0, Source_1.singleWord)("Object"), _mapType => (0, Source_1.singleWord)("Object"), _enumType => (0, Source_1.singleWord)("Object"), _unionType => (0, Source_1.singleWord)("Object"));
169
171
  }
170
172
  emitTopLevelDefinition(t, topLevelName) {
171
173
  this.emitLine("type ", topLevelName, " = ", this.haskellType(t).source);
@@ -223,7 +225,7 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
223
225
  this.emitLine(equalsOrPipe, " ", constructor);
224
226
  }
225
227
  else {
226
- this.emitLine(equalsOrPipe, " ", constructor, " ", Source_1.parenIfNeeded(this.haskellType(t)));
228
+ this.emitLine(equalsOrPipe, " ", constructor, " ", (0, Source_1.parenIfNeeded)(this.haskellType(t)));
227
229
  }
228
230
  onFirst = false;
229
231
  });
@@ -259,7 +261,7 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
259
261
  this.emitLine("object");
260
262
  let onFirst = true;
261
263
  this.forEachClassProperty(c, "none", (name, jsonName) => {
262
- this.emitLine(onFirst ? "[ " : ", ", '"', Strings_1.stringEscape(jsonName), '" .= ', name, className);
264
+ this.emitLine(onFirst ? "[ " : ", ", '"', (0, Strings_1.stringEscape)(jsonName), '" .= ', name, className);
263
265
  onFirst = false;
264
266
  });
265
267
  if (onFirst) {
@@ -282,7 +284,7 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
282
284
  let onFirst = true;
283
285
  this.forEachClassProperty(c, "none", (_, jsonName, p) => {
284
286
  const operator = p.isOptional ? ".:?" : ".:";
285
- this.emitLine(onFirst ? "<$> " : "<*> ", "v ", operator, ' "', Strings_1.stringEscape(jsonName), '"');
287
+ this.emitLine(onFirst ? "<$> " : "<*> ", "v ", operator, ' "', (0, Strings_1.stringEscape)(jsonName), '"');
286
288
  onFirst = false;
287
289
  });
288
290
  });
@@ -298,7 +300,7 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
298
300
  this.emitLine("instance ToJSON ", enumName, " where");
299
301
  this.indent(() => {
300
302
  this.forEachEnumCase(e, "none", (name, jsonName) => {
301
- this.emitLine("toJSON ", name, enumName, ' = "', Strings_1.stringEscape(jsonName), '"');
303
+ this.emitLine("toJSON ", name, enumName, ' = "', (0, Strings_1.stringEscape)(jsonName), '"');
302
304
  });
303
305
  });
304
306
  }
@@ -310,7 +312,7 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
310
312
  this.emitLine("where");
311
313
  this.indent(() => {
312
314
  this.forEachEnumCase(e, "none", (name, jsonName) => {
313
- this.emitLine('parseText "', Strings_1.stringEscape(jsonName), '" = return ', name, enumName);
315
+ this.emitLine('parseText "', (0, Strings_1.stringEscape)(jsonName), '" = return ', name, enumName);
314
316
  });
315
317
  });
316
318
  });
@@ -361,15 +363,15 @@ class HaskellRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
361
363
  exports.push([name, " (..)"]);
362
364
  });
363
365
  this.forEachObject("none", (t, name) => {
364
- if (!collection_utils_1.mapContains(this.topLevels, t))
366
+ if (!(0, collection_utils_1.mapContains)(this.topLevels, t))
365
367
  exports.push([name, " (..)"]);
366
368
  });
367
369
  this.forEachEnum("none", (t, name) => {
368
- if (!collection_utils_1.mapContains(this.topLevels, t))
370
+ if (!(0, collection_utils_1.mapContains)(this.topLevels, t))
369
371
  exports.push([name, " (..)"]);
370
372
  });
371
373
  this.forEachUnion("none", (t, name) => {
372
- if (!collection_utils_1.mapContains(this.topLevels, t))
374
+ if (!(0, collection_utils_1.mapContains)(this.topLevels, t))
373
375
  exports.push([name, " (..)"]);
374
376
  });
375
377
  this.emitLanguageExtensions("StrictData");
@@ -7,9 +7,9 @@ import { RenderContext } from "../Renderer";
7
7
  export declare class JSONSchemaTargetLanguage extends TargetLanguage {
8
8
  constructor();
9
9
  protected getOptions(): Option<any>[];
10
- readonly stringTypeMapping: StringTypeMapping;
11
- readonly supportsOptionalClassProperties: boolean;
12
- readonly supportsFullObjectType: boolean;
10
+ get stringTypeMapping(): StringTypeMapping;
11
+ get supportsOptionalClassProperties(): boolean;
12
+ get supportsFullObjectType(): boolean;
13
13
  protected makeRenderer(renderContext: RenderContext, _untypedOptionValues: {
14
14
  [name: string]: any;
15
15
  }): JSONSchemaRenderer;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JSONSchemaRenderer = exports.JSONSchemaTargetLanguage = void 0;
3
4
  const collection_utils_1 = require("collection-utils");
4
5
  const TargetLanguage_1 = require("../TargetLanguage");
5
6
  const Type_1 = require("../Type");
@@ -18,7 +19,7 @@ class JSONSchemaTargetLanguage extends TargetLanguage_1.TargetLanguage {
18
19
  return [];
19
20
  }
20
21
  get stringTypeMapping() {
21
- return TypeBuilder_1.getNoStringTypeMapping();
22
+ return (0, TypeBuilder_1.getNoStringTypeMapping)();
22
23
  }
23
24
  get supportsOptionalClassProperties() {
24
25
  return true;
@@ -31,11 +32,11 @@ class JSONSchemaTargetLanguage extends TargetLanguage_1.TargetLanguage {
31
32
  }
32
33
  }
33
34
  exports.JSONSchemaTargetLanguage = JSONSchemaTargetLanguage;
34
- const namingFunction = Naming_1.funPrefixNamer("namer", jsonNameStyle);
35
- const legalizeName = Strings_1.legalizeCharacters(cp => cp >= 32 && cp < 128 && cp !== 0x2f /* slash */);
35
+ const namingFunction = (0, Naming_1.funPrefixNamer)("namer", jsonNameStyle);
36
+ const legalizeName = (0, Strings_1.legalizeCharacters)(cp => cp >= 32 && cp < 128 && cp !== 0x2f /* slash */);
36
37
  function jsonNameStyle(original) {
37
- const words = Strings_1.splitIntoWords(original);
38
- return Strings_1.combineWords(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", _ => true);
38
+ const words = (0, Strings_1.splitIntoWords)(original);
39
+ return (0, Strings_1.combineWords)(words, legalizeName, Strings_1.firstUpperWordStyle, Strings_1.firstUpperWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", _ => true);
39
40
  }
40
41
  class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
41
42
  makeNamedTypeNamer() {
@@ -51,12 +52,12 @@ class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
51
52
  return null;
52
53
  }
53
54
  nameForType(t) {
54
- return Support_1.defined(this.names.get(this.nameForNamedType(t)));
55
+ return (0, Support_1.defined)(this.names.get(this.nameForNamedType(t)));
55
56
  }
56
57
  makeOneOf(types) {
57
- const first = collection_utils_1.iterableFirst(types);
58
+ const first = (0, collection_utils_1.iterableFirst)(types);
58
59
  if (first === undefined) {
59
- return Support_1.panic("Must have at least one type for oneOf");
60
+ return (0, Support_1.panic)("Must have at least one type for oneOf");
60
61
  }
61
62
  if (types.size === 1) {
62
63
  return this.schemaForType(first);
@@ -73,8 +74,8 @@ class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
73
74
  }
74
75
  }
75
76
  schemaForType(t) {
76
- const schema = TypeUtils_1.matchTypeExhaustive(t, _noneType => {
77
- return Support_1.panic("none type should have been replaced");
77
+ const schema = (0, TypeUtils_1.matchTypeExhaustive)(t, _noneType => {
78
+ return (0, Support_1.panic)("none type should have been replaced");
78
79
  }, _anyType => ({}), _nullType => ({ type: "null" }), _boolType => ({ type: "boolean" }), _integerType => ({ type: "integer" }), _doubleType => ({ type: "number" }), _stringType => ({ type: "string" }), arrayType => ({ type: "array", items: this.schemaForType(arrayType.items) }), classType => this.makeRef(classType), mapType => this.definitionForObject(mapType, undefined), objectType => this.makeRef(objectType), enumType => this.makeRef(enumType), unionType => {
79
80
  if (this.unionNeedsName(unionType)) {
80
81
  return this.makeRef(unionType);
@@ -85,7 +86,7 @@ class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
85
86
  }, transformedStringType => {
86
87
  const target = Type_1.transformedStringTypeTargetTypeKindsMap.get(transformedStringType.kind);
87
88
  if (target === undefined) {
88
- return Support_1.panic(`Unknown transformed string type ${transformedStringType.kind}`);
89
+ return (0, Support_1.panic)(`Unknown transformed string type ${transformedStringType.kind}`);
89
90
  }
90
91
  return { type: "string", format: target.jsonSchema };
91
92
  });
@@ -107,7 +108,7 @@ class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
107
108
  for (const [name, p] of o.getProperties()) {
108
109
  const prop = this.schemaForType(p.type);
109
110
  if (prop.description === undefined) {
110
- Description_1.addDescriptionToSchema(prop, this.descriptionForClassProperty(o, name));
111
+ (0, Description_1.addDescriptionToSchema)(prop, this.descriptionForClassProperty(o, name));
111
112
  }
112
113
  props[name] = prop;
113
114
  if (!p.isOptional) {
@@ -144,21 +145,21 @@ class JSONSchemaRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
144
145
  }
145
146
  emitSourceStructure() {
146
147
  // FIXME: Find a good way to do multiple top-levels. Maybe multiple files?
147
- const topLevelType = this.topLevels.size === 1 ? this.schemaForType(Support_1.defined(collection_utils_1.mapFirst(this.topLevels))) : {};
148
+ const topLevelType = this.topLevels.size === 1 ? this.schemaForType((0, Support_1.defined)((0, collection_utils_1.mapFirst)(this.topLevels))) : {};
148
149
  const schema = Object.assign({ $schema: "http://json-schema.org/draft-06/schema#" }, topLevelType);
149
150
  const definitions = {};
150
151
  this.forEachObject("none", (o, name) => {
151
- const title = Support_1.defined(this.names.get(name));
152
+ const title = (0, Support_1.defined)(this.names.get(name));
152
153
  definitions[title] = this.definitionForObject(o, title);
153
154
  });
154
155
  this.forEachUnion("none", (u, name) => {
155
156
  if (!this.unionNeedsName(u))
156
157
  return;
157
- const title = Support_1.defined(this.names.get(name));
158
+ const title = (0, Support_1.defined)(this.names.get(name));
158
159
  definitions[title] = this.definitionForUnion(u, title);
159
160
  });
160
161
  this.forEachEnum("none", (e, name) => {
161
- const title = Support_1.defined(this.names.get(name));
162
+ const title = (0, Support_1.defined)(this.names.get(name));
162
163
  definitions[title] = this.definitionForEnum(e, title);
163
164
  });
164
165
  schema.definitions = definitions;
@@ -19,11 +19,11 @@ export declare const javaOptions: {
19
19
  export declare class JavaTargetLanguage extends TargetLanguage {
20
20
  constructor();
21
21
  protected getOptions(): Option<any>[];
22
- readonly supportsUnionsWithBothNumberTypes: boolean;
22
+ get supportsUnionsWithBothNumberTypes(): boolean;
23
23
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
24
24
  [name: string]: any;
25
25
  }): JavaRenderer;
26
- readonly stringTypeMapping: StringTypeMapping;
26
+ get stringTypeMapping(): StringTypeMapping;
27
27
  }
28
28
  export declare const stringEscape: (s: string) => string;
29
29
  export declare function javaNameStyle(startWithUpper: boolean, upperUnderscore: boolean, original: string, acronymsStyle?: (s: string) => string): string;