quicktype 17.0.4 → 17.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.
Files changed (139) hide show
  1. package/dist/cli/CompressedJSONFromStream.js +38 -26
  2. package/dist/cli/GraphQLIntrospection.js +41 -33
  3. package/dist/cli/TypeSource.d.ts +1 -1
  4. package/dist/cli/URLGrammar.js +3 -4
  5. package/dist/cli/index.js +364 -363
  6. package/dist/quicktype-core/Annotation.js +0 -2
  7. package/dist/quicktype-core/ConvenienceRenderer.d.ts +17 -17
  8. package/dist/quicktype-core/ConvenienceRenderer.js +81 -104
  9. package/dist/quicktype-core/DateTime.js +0 -1
  10. package/dist/quicktype-core/DeclarationIR.d.ts +1 -1
  11. package/dist/quicktype-core/DeclarationIR.js +10 -13
  12. package/dist/quicktype-core/EncodedMarkovChain.js +0 -1
  13. package/dist/quicktype-core/GatherNames.js +25 -47
  14. package/dist/quicktype-core/Graph.d.ts +2 -2
  15. package/dist/quicktype-core/Graph.js +19 -23
  16. package/dist/quicktype-core/GraphRewriting.d.ts +2 -2
  17. package/dist/quicktype-core/GraphRewriting.js +54 -65
  18. package/dist/quicktype-core/MakeTransformations.js +22 -23
  19. package/dist/quicktype-core/MarkovChain.d.ts +3 -3
  20. package/dist/quicktype-core/MarkovChain.js +8 -9
  21. package/dist/quicktype-core/Messages.d.ts +3 -3
  22. package/dist/quicktype-core/Messages.js +3 -8
  23. package/dist/quicktype-core/Naming.d.ts +11 -11
  24. package/dist/quicktype-core/Naming.js +61 -76
  25. package/dist/quicktype-core/Renderer.d.ts +6 -6
  26. package/dist/quicktype-core/Renderer.js +17 -34
  27. package/dist/quicktype-core/RendererOptions.d.ts +5 -5
  28. package/dist/quicktype-core/RendererOptions.js +3 -6
  29. package/dist/quicktype-core/Run.d.ts +9 -9
  30. package/dist/quicktype-core/Run.js +67 -72
  31. package/dist/quicktype-core/Source.d.ts +3 -3
  32. package/dist/quicktype-core/Source.js +18 -19
  33. package/dist/quicktype-core/TargetLanguage.d.ts +10 -10
  34. package/dist/quicktype-core/TargetLanguage.js +2 -6
  35. package/dist/quicktype-core/Transformers.d.ts +25 -25
  36. package/dist/quicktype-core/Transformers.js +66 -94
  37. package/dist/quicktype-core/Type.d.ts +43 -41
  38. package/dist/quicktype-core/Type.js +71 -96
  39. package/dist/quicktype-core/TypeBuilder.d.ts +2 -2
  40. package/dist/quicktype-core/TypeBuilder.js +47 -53
  41. package/dist/quicktype-core/TypeGraph.d.ts +4 -4
  42. package/dist/quicktype-core/TypeGraph.js +40 -49
  43. package/dist/quicktype-core/TypeUtils.d.ts +2 -2
  44. package/dist/quicktype-core/TypeUtils.js +22 -23
  45. package/dist/quicktype-core/UnifyClasses.js +12 -16
  46. package/dist/quicktype-core/UnionBuilder.d.ts +3 -3
  47. package/dist/quicktype-core/UnionBuilder.js +30 -33
  48. package/dist/quicktype-core/attributes/AccessorNames.d.ts +2 -2
  49. package/dist/quicktype-core/attributes/AccessorNames.js +17 -18
  50. package/dist/quicktype-core/attributes/Constraints.d.ts +3 -3
  51. package/dist/quicktype-core/attributes/Constraints.js +4 -8
  52. package/dist/quicktype-core/attributes/Description.js +5 -6
  53. package/dist/quicktype-core/attributes/EnumValues.js +3 -4
  54. package/dist/quicktype-core/attributes/StringTypes.d.ts +1 -1
  55. package/dist/quicktype-core/attributes/StringTypes.js +21 -24
  56. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +3 -3
  57. package/dist/quicktype-core/attributes/TypeAttributes.js +10 -12
  58. package/dist/quicktype-core/attributes/TypeNames.d.ts +9 -9
  59. package/dist/quicktype-core/attributes/TypeNames.js +21 -49
  60. package/dist/quicktype-core/attributes/URIAttributes.d.ts +1 -1
  61. package/dist/quicktype-core/attributes/URIAttributes.js +6 -10
  62. package/dist/quicktype-core/index.js +125 -128
  63. package/dist/quicktype-core/input/CompressedJSON.d.ts +7 -7
  64. package/dist/quicktype-core/input/CompressedJSON.js +54 -49
  65. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +13 -5
  66. package/dist/quicktype-core/input/Inference.d.ts +2 -2
  67. package/dist/quicktype-core/input/Inference.js +17 -25
  68. package/dist/quicktype-core/input/Inputs.d.ts +2 -2
  69. package/dist/quicktype-core/input/Inputs.js +54 -38
  70. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +11 -11
  71. package/dist/quicktype-core/input/JSONSchemaInput.js +523 -503
  72. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +1 -1
  73. package/dist/quicktype-core/input/JSONSchemaStore.js +35 -24
  74. package/dist/quicktype-core/input/PostmanCollection.js +1 -2
  75. package/dist/quicktype-core/input/io/NodeIO.js +44 -55
  76. package/dist/quicktype-core/input/io/get-stream/index.js +2 -6
  77. package/dist/quicktype-core/language/All.js +2 -3
  78. package/dist/quicktype-core/language/CPlusPlus.d.ts +12 -9
  79. package/dist/quicktype-core/language/CPlusPlus.js +249 -251
  80. package/dist/quicktype-core/language/CSharp.d.ts +7 -7
  81. package/dist/quicktype-core/language/CSharp.js +72 -82
  82. package/dist/quicktype-core/language/Crystal.d.ts +2 -2
  83. package/dist/quicktype-core/language/Crystal.js +17 -18
  84. package/dist/quicktype-core/language/Dart.d.ts +4 -4
  85. package/dist/quicktype-core/language/Dart.js +34 -36
  86. package/dist/quicktype-core/language/Elm.d.ts +6 -6
  87. package/dist/quicktype-core/language/Elm.js +45 -47
  88. package/dist/quicktype-core/language/Golang.d.ts +4 -4
  89. package/dist/quicktype-core/language/Golang.js +20 -23
  90. package/dist/quicktype-core/language/Haskell.d.ts +5 -5
  91. package/dist/quicktype-core/language/Haskell.js +23 -25
  92. package/dist/quicktype-core/language/JSONSchema.d.ts +3 -3
  93. package/dist/quicktype-core/language/JSONSchema.js +16 -17
  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 +17 -19
  98. package/dist/quicktype-core/language/JavaScriptPropTypes.js +13 -15
  99. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +11 -12
  100. package/dist/quicktype-core/language/Kotlin.d.ts +2 -2
  101. package/dist/quicktype-core/language/Kotlin.js +37 -39
  102. package/dist/quicktype-core/language/Objective-C.d.ts +3 -3
  103. package/dist/quicktype-core/language/Objective-C.js +41 -45
  104. package/dist/quicktype-core/language/Php.d.ts +2 -2
  105. package/dist/quicktype-core/language/Php.js +41 -66
  106. package/dist/quicktype-core/language/Pike.d.ts +1 -1
  107. package/dist/quicktype-core/language/Pike.js +17 -18
  108. package/dist/quicktype-core/language/Python.d.ts +8 -8
  109. package/dist/quicktype-core/language/Python.js +64 -63
  110. package/dist/quicktype-core/language/Rust.d.ts +2 -2
  111. package/dist/quicktype-core/language/Rust.js +19 -21
  112. package/dist/quicktype-core/language/Swift.d.ts +7 -7
  113. package/dist/quicktype-core/language/Swift.js +804 -807
  114. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +7 -7
  115. package/dist/quicktype-core/language/TypeScriptFlow.js +26 -28
  116. package/dist/quicktype-core/language/ruby/index.d.ts +4 -4
  117. package/dist/quicktype-core/language/ruby/index.js +24 -49
  118. package/dist/quicktype-core/language/ruby/keywords.js +0 -1
  119. package/dist/quicktype-core/rewrites/CombineClasses.js +8 -9
  120. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +1 -1
  121. package/dist/quicktype-core/rewrites/ExpandStrings.js +17 -18
  122. package/dist/quicktype-core/rewrites/FlattenStrings.js +6 -7
  123. package/dist/quicktype-core/rewrites/FlattenUnions.js +8 -9
  124. package/dist/quicktype-core/rewrites/InferMaps.js +10 -11
  125. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +7 -8
  126. package/dist/quicktype-core/rewrites/ResolveIntersections.js +67 -68
  127. package/dist/quicktype-core/support/Acronyms.js +1 -3
  128. package/dist/quicktype-core/support/Chance.js +0 -10
  129. package/dist/quicktype-core/support/Converters.js +0 -1
  130. package/dist/quicktype-core/support/Strings.d.ts +4 -4
  131. package/dist/quicktype-core/support/Strings.js +16 -17
  132. package/dist/quicktype-core/support/Support.d.ts +1 -1
  133. package/dist/quicktype-core/support/Support.js +6 -30
  134. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +4 -4
  135. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -1
  136. package/dist/quicktype-graphql-input/index.d.ts +1 -1
  137. package/dist/quicktype-graphql-input/index.js +212 -229
  138. package/dist/quicktype-typescript-input/index.js +4 -28
  139. package/package.json +19 -25
@@ -19,7 +19,7 @@ export declare const tsFlowOptions: {
19
19
  };
20
20
  export declare abstract class TypeScriptFlowBaseTargetLanguage extends JavaScriptTargetLanguage {
21
21
  protected getOptions(): Option<any>[];
22
- get supportsOptionalClassProperties(): boolean;
22
+ readonly supportsOptionalClassProperties: boolean;
23
23
  protected abstract makeRenderer(renderContext: RenderContext, untypedOptionValues: {
24
24
  [name: string]: any;
25
25
  }): JavaScriptRenderer;
@@ -44,9 +44,9 @@ export declare abstract class TypeScriptFlowBaseRenderer extends JavaScriptRende
44
44
  protected emitUsageComments(): void;
45
45
  protected deserializerFunctionLine(t: Type, name: Name): Sourcelike;
46
46
  protected serializerFunctionLine(t: Type, name: Name): Sourcelike;
47
- protected get moduleLine(): string | undefined;
48
- protected get castFunctionLines(): [string, string];
49
- protected get typeAnnotations(): JavaScriptTypeAnnotations;
47
+ protected readonly moduleLine: string | undefined;
48
+ protected readonly castFunctionLines: [string, string];
49
+ protected readonly typeAnnotations: JavaScriptTypeAnnotations;
50
50
  protected emitConvertModule(): void;
51
51
  protected emitConvertModuleHelpers(): void;
52
52
  protected emitModuleExports(): void;
@@ -55,8 +55,8 @@ export declare class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
55
55
  protected forbiddenNamesForGlobalNamespace(): string[];
56
56
  protected deserializerFunctionLine(t: Type, name: Name): Sourcelike;
57
57
  protected serializerFunctionLine(t: Type, name: Name): Sourcelike;
58
- protected get moduleLine(): string | undefined;
59
- protected get typeAnnotations(): JavaScriptTypeAnnotations;
58
+ protected readonly moduleLine: string | undefined;
59
+ protected readonly typeAnnotations: JavaScriptTypeAnnotations;
60
60
  protected emitModuleExports(): void;
61
61
  protected emitUsageImportComment(): void;
62
62
  protected emitEnum(e: EnumType, enumName: Name): void;
@@ -70,7 +70,7 @@ export declare class FlowTargetLanguage extends TypeScriptFlowBaseTargetLanguage
70
70
  }
71
71
  export declare class FlowRenderer extends TypeScriptFlowBaseRenderer {
72
72
  protected forbiddenNamesForGlobalNamespace(): string[];
73
- protected get typeAnnotations(): JavaScriptTypeAnnotations;
73
+ protected readonly typeAnnotations: JavaScriptTypeAnnotations;
74
74
  protected emitEnum(e: EnumType, enumName: Name): void;
75
75
  protected emitClassBlock(c: ClassType, className: Name): void;
76
76
  protected emitSourceStructure(): void;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowRenderer = exports.FlowTargetLanguage = exports.TypeScriptRenderer = exports.TypeScriptFlowBaseRenderer = exports.TypeScriptTargetLanguage = exports.TypeScriptFlowBaseTargetLanguage = exports.tsFlowOptions = void 0;
4
3
  const Type_1 = require("../Type");
5
4
  const TypeUtils_1 = require("../TypeUtils");
6
5
  const Strings_1 = require("../support/Strings");
@@ -48,23 +47,23 @@ class TypeScriptTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
48
47
  super("TypeScript", ["typescript", "ts", "tsx"], "ts");
49
48
  }
50
49
  makeRenderer(renderContext, untypedOptionValues) {
51
- return new TypeScriptRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.tsFlowOptions, untypedOptionValues));
50
+ return new TypeScriptRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.tsFlowOptions, untypedOptionValues));
52
51
  }
53
52
  }
54
53
  exports.TypeScriptTargetLanguage = TypeScriptTargetLanguage;
55
54
  function quotePropertyName(original) {
56
- const escaped = (0, Strings_1.utf16StringEscape)(original);
55
+ const escaped = Strings_1.utf16StringEscape(original);
57
56
  const quoted = `"${escaped}"`;
58
57
  if (original.length === 0) {
59
58
  return quoted;
60
59
  }
61
- else if (!(0, JavaScriptUnicodeMaps_1.isES3IdentifierStart)(original.codePointAt(0))) {
60
+ else if (!JavaScriptUnicodeMaps_1.isES3IdentifierStart(original.codePointAt(0))) {
62
61
  return quoted;
63
62
  }
64
63
  else if (escaped !== original) {
65
64
  return quoted;
66
65
  }
67
- else if ((0, JavaScript_1.legalizeName)(original) !== original) {
66
+ else if (JavaScript_1.legalizeName(original) !== original) {
68
67
  return quoted;
69
68
  }
70
69
  else {
@@ -72,14 +71,13 @@ function quotePropertyName(original) {
72
71
  }
73
72
  }
74
73
  class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
75
- _tsFlowOptions;
76
74
  constructor(targetLanguage, renderContext, _tsFlowOptions) {
77
75
  super(targetLanguage, renderContext, _tsFlowOptions);
78
76
  this._tsFlowOptions = _tsFlowOptions;
79
77
  }
80
78
  namerForObjectProperty() {
81
79
  if (this._tsFlowOptions.nicePropertyNames) {
82
- return (0, Naming_1.funPrefixNamer)("properties", s => this.nameStyle(s, false));
80
+ return Naming_1.funPrefixNamer("properties", s => this.nameStyle(s, false));
83
81
  }
84
82
  else {
85
83
  return super.namerForObjectProperty();
@@ -87,37 +85,37 @@ class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
87
85
  }
88
86
  sourceFor(t) {
89
87
  if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
90
- return (0, Source_1.singleWord)(this.nameForNamedType(t));
88
+ return Source_1.singleWord(this.nameForNamedType(t));
91
89
  }
92
- return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.singleWord)("any"), _nullType => (0, Source_1.singleWord)("null"), _boolType => (0, Source_1.singleWord)("boolean"), _integerType => (0, Source_1.singleWord)("number"), _doubleType => (0, Source_1.singleWord)("number"), _stringType => (0, Source_1.singleWord)("string"), arrayType => {
90
+ return TypeUtils_1.matchType(t, _anyType => Source_1.singleWord("any"), _nullType => Source_1.singleWord("null"), _boolType => Source_1.singleWord("boolean"), _integerType => Source_1.singleWord("number"), _doubleType => Source_1.singleWord("number"), _stringType => Source_1.singleWord("string"), arrayType => {
93
91
  const itemType = this.sourceFor(arrayType.items);
94
92
  if ((arrayType.items instanceof Type_1.UnionType && !this._tsFlowOptions.declareUnions) ||
95
93
  arrayType.items instanceof Type_1.ArrayType) {
96
- return (0, Source_1.singleWord)(["Array<", itemType.source, ">"]);
94
+ return Source_1.singleWord(["Array<", itemType.source, ">"]);
97
95
  }
98
96
  else {
99
- return (0, Source_1.singleWord)([(0, Source_1.parenIfNeeded)(itemType), "[]"]);
97
+ return Source_1.singleWord([Source_1.parenIfNeeded(itemType), "[]"]);
100
98
  }
101
- }, _classType => (0, Support_1.panic)("We handled this above"), mapType => (0, Source_1.singleWord)(["{ [key: string]: ", this.sourceFor(mapType.values).source, " }"]), _enumType => (0, Support_1.panic)("We handled this above"), unionType => {
102
- if (!this._tsFlowOptions.declareUnions || (0, TypeUtils_1.nullableFromUnion)(unionType) !== null) {
103
- const children = Array.from(unionType.getChildren()).map(c => (0, Source_1.parenIfNeeded)(this.sourceFor(c)));
104
- return (0, Source_1.multiWord)(" | ", ...children);
99
+ }, _classType => Support_1.panic("We handled this above"), mapType => Source_1.singleWord(["{ [key: string]: ", this.sourceFor(mapType.values).source, " }"]), _enumType => Support_1.panic("We handled this above"), unionType => {
100
+ if (!this._tsFlowOptions.declareUnions || TypeUtils_1.nullableFromUnion(unionType) !== null) {
101
+ const children = Array.from(unionType.getChildren()).map(c => Source_1.parenIfNeeded(this.sourceFor(c)));
102
+ return Source_1.multiWord(" | ", ...children);
105
103
  }
106
104
  else {
107
- return (0, Source_1.singleWord)(this.nameForNamedType(unionType));
105
+ return Source_1.singleWord(this.nameForNamedType(unionType));
108
106
  }
109
107
  }, transformedStringType => {
110
108
  if (transformedStringType.kind === "date-time") {
111
- return (0, Source_1.singleWord)("Date");
109
+ return Source_1.singleWord("Date");
112
110
  }
113
- return (0, Source_1.singleWord)("string");
111
+ return Source_1.singleWord("string");
114
112
  });
115
113
  }
116
114
  emitClassBlockBody(c) {
117
115
  this.emitPropertyTable(c, (name, _jsonName, p) => {
118
116
  const t = p.type;
119
117
  return [
120
- [(0, Source_1.modifySource)(quotePropertyName, name), p.isOptional ? "?" : "", ": "],
118
+ [Source_1.modifySource(quotePropertyName, name), p.isOptional ? "?" : "", ": "],
121
119
  [this.sourceFor(t).source, ";"]
122
120
  ];
123
121
  });
@@ -135,7 +133,7 @@ class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
135
133
  return;
136
134
  }
137
135
  this.emitDescription(this.descriptionForType(u));
138
- const children = (0, Source_1.multiWord)(" | ", ...Array.from(u.getChildren()).map(c => (0, Source_1.parenIfNeeded)(this.sourceFor(c))));
136
+ const children = Source_1.multiWord(" | ", ...Array.from(u.getChildren()).map(c => Source_1.parenIfNeeded(this.sourceFor(c))));
139
137
  this.emitLine("export type ", unionName, " = ", children.source, ";");
140
138
  }
141
139
  emitTypes() {
@@ -151,7 +149,7 @@ class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
151
149
  return ["function to", name, "(json: ", jsonType, "): ", this.sourceFor(t).source];
152
150
  }
153
151
  serializerFunctionLine(t, name) {
154
- const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
152
+ const camelCaseName = Source_1.modifySource(Strings_1.camelCase, name);
155
153
  const returnType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
156
154
  return ["function ", camelCaseName, "ToJson(value: ", this.sourceFor(t).source, "): ", returnType];
157
155
  }
@@ -193,7 +191,7 @@ class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
193
191
  return ["public static to", name, "(json: ", jsonType, "): ", this.sourceFor(t).source];
194
192
  }
195
193
  serializerFunctionLine(t, name) {
196
- const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
194
+ const camelCaseName = Source_1.modifySource(Strings_1.camelCase, name);
197
195
  const returnType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
198
196
  return ["public static ", camelCaseName, "ToJson(value: ", this.sourceFor(t).source, "): ", returnType];
199
197
  }
@@ -219,17 +217,17 @@ class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
219
217
  let items = "";
220
218
  e.cases.forEach(item => {
221
219
  if (items === "") {
222
- items += `"${(0, Strings_1.utf16StringEscape)(item)}"`;
220
+ items += `"${Strings_1.utf16StringEscape(item)}"`;
223
221
  return;
224
222
  }
225
- items += ` | "${(0, Strings_1.utf16StringEscape)(item)}"`;
223
+ items += ` | "${Strings_1.utf16StringEscape(item)}"`;
226
224
  });
227
225
  this.emitLine("export type ", enumName, " = ", items, ";");
228
226
  }
229
227
  else {
230
228
  this.emitBlock(["export enum ", enumName, " "], "", () => {
231
229
  this.forEachEnumCase(e, "none", (name, jsonName) => {
232
- this.emitLine(name, ` = "${(0, Strings_1.utf16StringEscape)(jsonName)}",`);
230
+ this.emitLine(name, ` = "${Strings_1.utf16StringEscape(jsonName)}",`);
233
231
  });
234
232
  });
235
233
  }
@@ -246,7 +244,7 @@ class FlowTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
246
244
  super("Flow", ["flow"], "js");
247
245
  }
248
246
  makeRenderer(renderContext, untypedOptionValues) {
249
- return new FlowRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.tsFlowOptions, untypedOptionValues));
247
+ return new FlowRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.tsFlowOptions, untypedOptionValues));
250
248
  }
251
249
  }
252
250
  exports.FlowTargetLanguage = FlowTargetLanguage;
@@ -262,9 +260,9 @@ class FlowRenderer extends TypeScriptFlowBaseRenderer {
262
260
  const lines = [];
263
261
  this.forEachEnumCase(e, "none", (_, jsonName) => {
264
262
  const maybeOr = lines.length === 0 ? " " : "| ";
265
- lines.push([maybeOr, '"', (0, Strings_1.utf16StringEscape)(jsonName), '"']);
263
+ lines.push([maybeOr, '"', Strings_1.utf16StringEscape(jsonName), '"']);
266
264
  });
267
- (0, Support_1.defined)(lines[lines.length - 1]).push(";");
265
+ Support_1.defined(lines[lines.length - 1]).push(";");
268
266
  this.emitLine("export type ", enumName, " =");
269
267
  this.indent(() => {
270
268
  for (const line of lines) {
@@ -17,8 +17,8 @@ export declare const rubyOptions: {
17
17
  export declare class RubyTargetLanguage extends TargetLanguage {
18
18
  constructor();
19
19
  protected getOptions(): Option<any>[];
20
- get supportsOptionalClassProperties(): boolean;
21
- protected get defaultIndentation(): string;
20
+ readonly supportsOptionalClassProperties: boolean;
21
+ protected readonly defaultIndentation: string;
22
22
  protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
23
23
  [name: string]: any;
24
24
  }): RubyRenderer;
@@ -26,8 +26,8 @@ export declare class RubyTargetLanguage extends TargetLanguage {
26
26
  export declare class RubyRenderer extends ConvenienceRenderer {
27
27
  private readonly _options;
28
28
  constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof rubyOptions>);
29
- protected get commentLineStart(): string;
30
- protected get needsTypeDeclarationBeforeUse(): boolean;
29
+ protected readonly commentLineStart: string;
30
+ protected readonly needsTypeDeclarationBeforeUse: boolean;
31
31
  protected canBeForwardDeclared(t: Type): boolean;
32
32
  protected forbiddenNamesForGlobalNamespace(): string[];
33
33
  protected forbiddenForObjectProperties(_c: ClassType, _classNamed: Name): ForbiddenWordsInfo;
@@ -1,44 +1,20 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.RubyRenderer = exports.RubyTargetLanguage = exports.rubyOptions = exports.Strictness = void 0;
27
3
  const unicode = require("unicode-properties");
28
4
  const Source_1 = require("../../Source");
29
5
  const Naming_1 = require("../../Naming");
30
6
  const ConvenienceRenderer_1 = require("../../ConvenienceRenderer");
31
7
  const TargetLanguage_1 = require("../../TargetLanguage");
32
8
  const RendererOptions_1 = require("../../RendererOptions");
33
- const keywords = __importStar(require("./keywords"));
9
+ const keywords = require("./keywords");
34
10
  const forbiddenForObjectProperties = Array.from(new Set([...keywords.keywords, ...keywords.reservedProperties]));
35
11
  const Type_1 = require("../../Type");
36
12
  const TypeUtils_1 = require("../../TypeUtils");
37
13
  const Strings_1 = require("../../support/Strings");
38
14
  function unicodeEscape(codePoint) {
39
- return "\\u{" + (0, Strings_1.intToHex)(codePoint, 0) + "}";
15
+ return "\\u{" + Strings_1.intToHex(codePoint, 0) + "}";
40
16
  }
41
- const stringEscape = (0, Strings_1.utf32ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isPrintable, unicodeEscape));
17
+ const stringEscape = Strings_1.utf32ConcatMap(Strings_1.escapeNonPrintableMapper(Strings_1.isPrintable, unicodeEscape));
42
18
  var Strictness;
43
19
  (function (Strictness) {
44
20
  Strictness["Strict"] = "Strict::";
@@ -68,7 +44,7 @@ class RubyTargetLanguage extends TargetLanguage_1.TargetLanguage {
68
44
  return " ";
69
45
  }
70
46
  makeRenderer(renderContext, untypedOptionValues) {
71
- return new RubyRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.rubyOptions, untypedOptionValues));
47
+ return new RubyRenderer(this, renderContext, RendererOptions_1.getOptionValues(exports.rubyOptions, untypedOptionValues));
72
48
  }
73
49
  }
74
50
  exports.RubyTargetLanguage = RubyTargetLanguage;
@@ -77,20 +53,19 @@ function isPartCharacter(utf16Unit) {
77
53
  const category = unicode.getCategory(utf16Unit);
78
54
  return ["Nd", "Pc", "Mn", "Mc"].indexOf(category) >= 0 || isStartCharacter(utf16Unit);
79
55
  }
80
- const legalizeName = (0, Strings_1.legalizeCharacters)(isPartCharacter);
56
+ const legalizeName = Strings_1.legalizeCharacters(isPartCharacter);
81
57
  function simpleNameStyle(original, uppercase) {
82
58
  if (/^[0-9]+$/.test(original)) {
83
59
  original = original + "N";
84
60
  }
85
- const words = (0, Strings_1.splitIntoWords)(original);
86
- return (0, Strings_1.combineWords)(words, legalizeName, uppercase ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, uppercase ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
61
+ const words = Strings_1.splitIntoWords(original);
62
+ return Strings_1.combineWords(words, legalizeName, uppercase ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, uppercase ? Strings_1.firstUpperWordStyle : Strings_1.allLowerWordStyle, Strings_1.allUpperWordStyle, Strings_1.allUpperWordStyle, "", isStartCharacter);
87
63
  }
88
64
  function memberNameStyle(original) {
89
- const words = (0, Strings_1.splitIntoWords)(original);
90
- return (0, Strings_1.combineWords)(words, legalizeName, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, "_", isStartCharacter);
65
+ const words = Strings_1.splitIntoWords(original);
66
+ return Strings_1.combineWords(words, legalizeName, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, Strings_1.allLowerWordStyle, "_", isStartCharacter);
91
67
  }
92
68
  class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
93
- _options;
94
69
  constructor(targetLanguage, renderContext, _options) {
95
70
  super(targetLanguage, renderContext);
96
71
  this._options = _options;
@@ -124,8 +99,8 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
124
99
  }
125
100
  dryType(t, isOptional = false) {
126
101
  const optional = isOptional ? ".optional" : "";
127
- return (0, TypeUtils_1.matchType)(t, _anyType => ["Types::Any", optional], _nullType => ["Types::Nil", optional], _boolType => ["Types::Bool", optional], _integerType => ["Types::Integer", optional], _doubleType => ["Types::Double", optional], _stringType => ["Types::String", optional], arrayType => ["Types.Array(", this.dryType(arrayType.items), ")", optional], classType => [this.nameForNamedType(classType), optional], mapType => ["Types::Hash.meta(of: ", this.dryType(mapType.values), ")", optional], enumType => ["Types::", this.nameForNamedType(enumType), optional], unionType => {
128
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
102
+ return TypeUtils_1.matchType(t, _anyType => ["Types::Any", optional], _nullType => ["Types::Nil", optional], _boolType => ["Types::Bool", optional], _integerType => ["Types::Integer", optional], _doubleType => ["Types::Double", optional], _stringType => ["Types::String", optional], arrayType => ["Types.Array(", this.dryType(arrayType.items), ")", optional], classType => [this.nameForNamedType(classType), optional], mapType => ["Types::Hash.meta(of: ", this.dryType(mapType.values), ")", optional], enumType => ["Types::", this.nameForNamedType(enumType), optional], unionType => {
103
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
129
104
  if (nullable !== null) {
130
105
  return [this.dryType(nullable), ".optional"];
131
106
  }
@@ -137,7 +112,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
137
112
  return exp;
138
113
  }
139
114
  const safeNav = optional ? "&" : "";
140
- return (0, TypeUtils_1.matchType)(t, _anyType => exp, _nullType => [exp, ".nil?"], _boolType => exp, _integerType => [exp, ".even?"], _doubleType => exp, _stringType => exp, arrayType => this.exampleUse(arrayType.items, [exp, safeNav, ".first"], depth), classType => {
115
+ return TypeUtils_1.matchType(t, _anyType => exp, _nullType => [exp, ".nil?"], _boolType => exp, _integerType => [exp, ".even?"], _doubleType => exp, _stringType => exp, arrayType => this.exampleUse(arrayType.items, [exp, safeNav, ".first"], depth), classType => {
141
116
  let info;
142
117
  this.forEachClassProperty(classType, "none", (name, _json, prop) => {
143
118
  if (["class", "map", "array"].indexOf(prop.type.kind) >= 0) {
@@ -164,7 +139,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
164
139
  }
165
140
  return exp;
166
141
  }, unionType => {
167
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
142
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
168
143
  if (nullable !== null) {
169
144
  if (["class", "map", "array"].indexOf(nullable.kind) >= 0) {
170
145
  return this.exampleUse(nullable, exp, depth, true);
@@ -195,7 +170,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
195
170
  const primitiveCast = [this.dryType(t, optional), "[", e, "]"];
196
171
  const primitive = castPrimitives ? primitiveCast : e;
197
172
  const safeAccess = optional ? "&" : "";
198
- return (0, TypeUtils_1.matchType)(t, _anyType => primitive, _nullType => primitive, _boolType => primitive, _integerType => primitive, _doubleType => primitive, _stringType => primitive, arrayType => [e, safeAccess, ".map { |x| ", this.fromDynamic(arrayType.items, "x", false, true), " }"], classType => {
173
+ return TypeUtils_1.matchType(t, _anyType => primitive, _nullType => primitive, _boolType => primitive, _integerType => primitive, _doubleType => primitive, _stringType => primitive, arrayType => [e, safeAccess, ".map { |x| ", this.fromDynamic(arrayType.items, "x", false, true), " }"], classType => {
199
174
  const expression = [this.nameForNamedType(classType), ".from_dynamic!(", e, ")"];
200
175
  return optional ? [e, " ? ", expression, " : nil"] : expression;
201
176
  }, mapType => [
@@ -210,7 +185,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
210
185
  const expression = ["Types::", this.nameForNamedType(enumType), "[", e, "]"];
211
186
  return optional ? [e, ".nil? ? nil : ", expression] : expression;
212
187
  }, unionType => {
213
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
188
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
214
189
  if (nullable !== null) {
215
190
  return this.fromDynamic(nullable, e, true);
216
191
  }
@@ -222,8 +197,8 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
222
197
  if (this.marshalsImplicitlyToDynamic(t)) {
223
198
  return e;
224
199
  }
225
- return (0, TypeUtils_1.matchType)(t, _anyType => e, _nullType => e, _boolType => e, _integerType => e, _doubleType => e, _stringType => e, arrayType => [e, optional ? "&" : "", ".map { |x| ", this.toDynamic(arrayType.items, "x"), " }"], _classType => [e, optional ? "&" : "", ".to_dynamic"], mapType => [e, optional ? "&" : "", ".map { |k, v| [k, ", this.toDynamic(mapType.values, "v"), "] }.to_h"], _enumType => e, unionType => {
226
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
200
+ return TypeUtils_1.matchType(t, _anyType => e, _nullType => e, _boolType => e, _integerType => e, _doubleType => e, _stringType => e, arrayType => [e, optional ? "&" : "", ".map { |x| ", this.toDynamic(arrayType.items, "x"), " }"], _classType => [e, optional ? "&" : "", ".to_dynamic"], mapType => [e, optional ? "&" : "", ".map { |k, v| [k, ", this.toDynamic(mapType.values, "v"), "] }.to_h"], _enumType => e, unionType => {
201
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
227
202
  if (nullable !== null) {
228
203
  return this.toDynamic(nullable, e, true);
229
204
  }
@@ -234,8 +209,8 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
234
209
  });
235
210
  }
236
211
  marshalsImplicitlyToDynamic(t) {
237
- return (0, TypeUtils_1.matchType)(t, _anyType => true, _nullType => true, _boolType => true, _integerType => true, _doubleType => true, _stringType => true, arrayType => this.marshalsImplicitlyToDynamic(arrayType.items), _classType => false, mapType => this.marshalsImplicitlyToDynamic(mapType.values), _enumType => true, unionType => {
238
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
212
+ return TypeUtils_1.matchType(t, _anyType => true, _nullType => true, _boolType => true, _integerType => true, _doubleType => true, _stringType => true, arrayType => this.marshalsImplicitlyToDynamic(arrayType.items), _classType => false, mapType => this.marshalsImplicitlyToDynamic(mapType.values), _enumType => true, unionType => {
213
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
239
214
  if (nullable !== null) {
240
215
  return this.marshalsImplicitlyToDynamic(nullable);
241
216
  }
@@ -246,10 +221,10 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
246
221
  // marshal implicitly. They are allowed to do this because they will
247
222
  // be checked in Dry::Struct.new
248
223
  propertyTypeMarshalsImplicitlyFromDynamic(t) {
249
- return (0, TypeUtils_1.matchType)(t, _anyType => true, _nullType => true, _boolType => true, _integerType => true, _doubleType => true, _stringType => true, arrayType => this.propertyTypeMarshalsImplicitlyFromDynamic(arrayType.items), _classType => false,
224
+ return TypeUtils_1.matchType(t, _anyType => true, _nullType => true, _boolType => true, _integerType => true, _doubleType => true, _stringType => true, arrayType => this.propertyTypeMarshalsImplicitlyFromDynamic(arrayType.items), _classType => false,
250
225
  // Map properties must be checked because Dry:Types doesn't have a generic Map
251
226
  _mapType => false, _enumType => true, unionType => {
252
- const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
227
+ const nullable = TypeUtils_1.nullableFromUnion(unionType);
253
228
  if (nullable !== null) {
254
229
  return this.propertyTypeMarshalsImplicitlyFromDynamic(nullable);
255
230
  }
@@ -389,7 +364,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
389
364
  return;
390
365
  }
391
366
  this.ensureBlankLine();
392
- const [maybeNull, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u, false);
367
+ const [maybeNull, nonNulls] = TypeUtils_1.removeNullFromUnion(u, false);
393
368
  this.emitBlock("def self.from_dynamic!(d)", () => {
394
369
  const memberNames = Array.from(u.getChildren()).map(member => this.nameForUnionMember(u, member));
395
370
  this.forEachUnionMember(u, u.getChildren(), "none", null, (name, t) => {
@@ -501,7 +476,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
501
476
  this.emitLine("# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:");
502
477
  this.emitLine("#");
503
478
  this.forEachTopLevel("none", (topLevel, name) => {
504
- const variable = (0, Source_1.modifySource)(Strings_1.snakeCase, name);
479
+ const variable = Source_1.modifySource(Strings_1.snakeCase, name);
505
480
  this.emitLine("# ", variable, " = ", name, ".from_json! ", this.jsonSample(topLevel));
506
481
  this.emitLine("# puts ", this.exampleUse(topLevel, variable));
507
482
  this.emitLine("#");
@@ -526,7 +501,7 @@ class RubyRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
526
501
  this.forEachNamedType("leading-and-interposing", (c, n) => this.emitClass(c, n), (e, n) => this.emitEnum(e, n), (u, n) => this.emitUnion(u, n));
527
502
  if (!this._options.justTypes) {
528
503
  this.forEachTopLevel("leading-and-interposing", (topLevel, name) => {
529
- const self = (0, Source_1.modifySource)(Strings_1.snakeCase, name);
504
+ const self = Source_1.modifySource(Strings_1.snakeCase, name);
530
505
  // The json gem defines to_json on maps and primitives, so we only need to supply
531
506
  // it for arrays.
532
507
  const needsToJsonDefined = "array" === topLevel.kind;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reservedProperties = exports.globals = exports.keywords = void 0;
4
3
  exports.keywords = [
5
4
  "__ENCODING__",
6
5
  "__FILE__",
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.combineClasses = void 0;
4
3
  const Type_1 = require("../Type");
5
4
  const TypeUtils_1 = require("../TypeUtils");
6
5
  const Support_1 = require("../support/Support");
@@ -10,7 +9,7 @@ const REQUIRED_OVERLAP = 3 / 4;
10
9
  // enums with strings, integers with doubles, maps with objects of
11
10
  // the correct type.
12
11
  function typeSetsCanBeCombined(s1, s2) {
13
- return (0, Type_1.setOperationCasesEqual)(s1, s2, true, (a, b) => a.structurallyCompatible(b, true));
12
+ return Type_1.setOperationCasesEqual(s1, s2, true, (a, b) => a.structurallyCompatible(b, true));
14
13
  }
15
14
  function canBeCombined(c1, c2, onlyWithSameProperties) {
16
15
  const p1 = c1.getProperties();
@@ -43,7 +42,7 @@ function canBeCombined(c1, c2, onlyWithSameProperties) {
43
42
  const minOverlap = Math.ceil(larger.size * REQUIRED_OVERLAP);
44
43
  maxFaults = smaller.size - minOverlap;
45
44
  }
46
- (0, Support_1.assert)(maxFaults >= 0, "Max faults negative");
45
+ Support_1.assert(maxFaults >= 0, "Max faults negative");
47
46
  const commonProperties = [];
48
47
  let faults = 0;
49
48
  for (const [name] of smaller) {
@@ -62,10 +61,10 @@ function canBeCombined(c1, c2, onlyWithSameProperties) {
62
61
  let ts = smaller.get(name);
63
62
  let tl = larger.get(name);
64
63
  if (ts === undefined || tl === undefined) {
65
- return (0, Support_1.panic)(`Both classes should have property ${name}`);
64
+ return Support_1.panic(`Both classes should have property ${name}`);
66
65
  }
67
- const tsCases = (0, TypeUtils_1.nonNullTypeCases)(ts.type);
68
- const tlCases = (0, TypeUtils_1.nonNullTypeCases)(tl.type);
66
+ const tsCases = TypeUtils_1.nonNullTypeCases(ts.type);
67
+ const tlCases = TypeUtils_1.nonNullTypeCases(tl.type);
69
68
  if (tsCases.size > 0 && tlCases.size > 0 && !typeSetsCanBeCombined(tsCases, tlCases)) {
70
69
  return false;
71
70
  }
@@ -116,9 +115,9 @@ function findSimilarityCliques(graph, onlyWithSameProperties, includeFixedClasse
116
115
  function combineClasses(ctx, graph, alphabetizeProperties, conflateNumbers, onlyWithSameProperties, debugPrintReconstitution) {
117
116
  const cliques = ctx.time(" find similarity cliques", () => findSimilarityCliques(graph, onlyWithSameProperties, false));
118
117
  function makeCliqueClass(clique, builder, forwardingRef) {
119
- (0, Support_1.assert)(clique.size > 0, "Clique can't be empty");
120
- const attributes = (0, TypeUtils_1.combineTypeAttributesOfTypes)("union", clique);
121
- return (0, UnifyClasses_1.unifyTypes)(clique, attributes, builder, (0, UnifyClasses_1.unionBuilderForUnification)(builder, false, false, conflateNumbers), conflateNumbers, forwardingRef);
118
+ Support_1.assert(clique.size > 0, "Clique can't be empty");
119
+ const attributes = TypeUtils_1.combineTypeAttributesOfTypes("union", clique);
120
+ return UnifyClasses_1.unifyTypes(clique, attributes, builder, UnifyClasses_1.unionBuilderForUnification(builder, false, false, conflateNumbers), conflateNumbers, forwardingRef);
122
121
  }
123
122
  return graph.rewrite("combine classes", ctx.stringTypeMapping, alphabetizeProperties, cliques, debugPrintReconstitution, makeCliqueClass);
124
123
  }
@@ -1,4 +1,4 @@
1
1
  import { TypeGraph } from "../TypeGraph";
2
2
  import { RunContext } from "../Run";
3
- export type EnumInference = "none" | "all" | "infer";
3
+ export declare type EnumInference = "none" | "all" | "infer";
4
4
  export declare function expandStrings(ctx: RunContext, graph: TypeGraph, inference: EnumInference): TypeGraph;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expandStrings = void 0;
4
3
  const collection_utils_1 = require("collection-utils");
5
4
  const TypeUtils_1 = require("../TypeUtils");
6
5
  const Support_1 = require("../support/Support");
@@ -14,7 +13,7 @@ function isOwnEnum({ numValues, cases }) {
14
13
  }
15
14
  function enumCasesOverlap(newCases, existingCases, newAreSubordinate) {
16
15
  const smaller = newAreSubordinate ? newCases.size : Math.min(newCases.size, existingCases.size);
17
- const overlap = (0, collection_utils_1.setIntersect)(newCases, existingCases).size;
16
+ const overlap = collection_utils_1.setIntersect(newCases, existingCases).size;
18
17
  return overlap >= smaller * REQUIRED_OVERLAP;
19
18
  }
20
19
  function isAlwaysEmptyString(cases) {
@@ -22,21 +21,21 @@ function isAlwaysEmptyString(cases) {
22
21
  }
23
22
  function expandStrings(ctx, graph, inference) {
24
23
  const stringTypeMapping = ctx.stringTypeMapping;
25
- const allStrings = Array.from(graph.allTypesUnordered()).filter(t => t.kind === "string" && (0, TypeUtils_1.stringTypesForType)(t).isRestricted);
24
+ const allStrings = Array.from(graph.allTypesUnordered()).filter(t => t.kind === "string" && TypeUtils_1.stringTypesForType(t).isRestricted);
26
25
  function makeEnumInfo(t) {
27
- const stringTypes = (0, TypeUtils_1.stringTypesForType)(t);
26
+ const stringTypes = TypeUtils_1.stringTypesForType(t);
28
27
  const mappedStringTypes = stringTypes.applyStringTypeMapping(stringTypeMapping);
29
28
  if (!mappedStringTypes.isRestricted)
30
29
  return undefined;
31
- const cases = (0, Support_1.defined)(mappedStringTypes.cases);
30
+ const cases = Support_1.defined(mappedStringTypes.cases);
32
31
  if (cases.size === 0)
33
32
  return undefined;
34
- const numValues = (0, collection_utils_1.iterableReduce)(cases.values(), 0, (a, b) => a + b);
33
+ const numValues = collection_utils_1.iterableReduce(cases.values(), 0, (a, b) => a + b);
35
34
  if (inference !== "all") {
36
35
  const keys = Array.from(cases.keys());
37
36
  if (isAlwaysEmptyString(keys))
38
37
  return undefined;
39
- const someCaseIsNotNumber = (0, collection_utils_1.iterableSome)(keys, key => /^(\-|\+)?[0-9]+(\.[0-9]+)?$/.test(key) === false);
38
+ const someCaseIsNotNumber = collection_utils_1.iterableSome(keys, key => /^(\-|\+)?[0-9]+(\.[0-9]+)?$/.test(key) === false);
40
39
  if (!someCaseIsNotNumber)
41
40
  return undefined;
42
41
  }
@@ -57,7 +56,7 @@ function expandStrings(ctx, graph, inference) {
57
56
  // First, make case sets for all the enums that stand on their own. If
58
57
  // we find some overlap (searching eagerly), make unions.
59
58
  for (const t of Array.from(enumInfos.keys())) {
60
- const enumInfo = (0, Support_1.defined)(enumInfos.get(t));
59
+ const enumInfo = Support_1.defined(enumInfos.get(t));
61
60
  const cases = enumInfo.cases;
62
61
  if (inference === "all") {
63
62
  enumSets.push(cases);
@@ -72,7 +71,7 @@ function expandStrings(ctx, graph, inference) {
72
71
  // Array.from(enumSets[index])
73
72
  // )}`
74
73
  // );
75
- enumSets[index] = (0, collection_utils_1.setUnion)(enumSets[index], cases);
74
+ enumSets[index] = collection_utils_1.setUnion(enumSets[index], cases);
76
75
  }
77
76
  else {
78
77
  // console.log(`adding new ${JSON.stringify(Array.from(cases))}`);
@@ -83,7 +82,7 @@ function expandStrings(ctx, graph, inference) {
83
82
  enumInfos.delete(t);
84
83
  }
85
84
  if (inference === "all") {
86
- (0, Support_1.assert)(enumInfos.size === 0);
85
+ Support_1.assert(enumInfos.size === 0);
87
86
  }
88
87
  // Now see if we can unify the rest with some a set we found in the
89
88
  // previous step.
@@ -97,22 +96,22 @@ function expandStrings(ctx, graph, inference) {
97
96
  // Array.from(enumSets[index])
98
97
  // )}`
99
98
  // );
100
- enumSets[index] = (0, collection_utils_1.setUnion)(enumSets[index], enumInfo.cases);
99
+ enumSets[index] = collection_utils_1.setUnion(enumSets[index], enumInfo.cases);
101
100
  }
102
101
  }
103
102
  }
104
103
  function replaceString(group, builder, forwardingRef) {
105
- (0, Support_1.assert)(group.size === 1);
106
- const t = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(group));
107
- const stringTypes = (0, TypeUtils_1.stringTypesForType)(t);
108
- const attributes = (0, collection_utils_1.mapFilter)(t.getAttributes(), a => a !== stringTypes);
104
+ Support_1.assert(group.size === 1);
105
+ const t = Support_1.defined(collection_utils_1.iterableFirst(group));
106
+ const stringTypes = TypeUtils_1.stringTypesForType(t);
107
+ const attributes = collection_utils_1.mapFilter(t.getAttributes(), a => a !== stringTypes);
109
108
  const mappedStringTypes = stringTypes.applyStringTypeMapping(stringTypeMapping);
110
109
  if (!mappedStringTypes.isRestricted) {
111
110
  return builder.getStringType(attributes, StringTypes_1.StringTypes.unrestricted, forwardingRef);
112
111
  }
113
112
  const setMatches = inference === "all" ? collection_utils_1.areEqual : collection_utils_1.setIsSuperset;
114
113
  const types = [];
115
- const cases = (0, Support_1.defined)(mappedStringTypes.cases);
114
+ const cases = Support_1.defined(mappedStringTypes.cases);
116
115
  if (cases.size > 0) {
117
116
  const keys = new Set(cases.keys());
118
117
  const fullCases = enumSets.find(s => setMatches(s, keys));
@@ -131,11 +130,11 @@ function expandStrings(ctx, graph, inference) {
131
130
  // both are rewritten via `getPrimitiveType` below without any attributes, they end up
132
131
  // being the same string type.
133
132
  if (types.length === 0 && transformations.size === 1) {
134
- const kind = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(transformations));
133
+ const kind = Support_1.defined(collection_utils_1.iterableFirst(transformations));
135
134
  return builder.getPrimitiveType(kind, attributes, forwardingRef);
136
135
  }
137
136
  types.push(...Array.from(transformations).map(k => builder.getPrimitiveType(k)));
138
- (0, Support_1.assert)(types.length > 0, "We got an empty string type");
137
+ Support_1.assert(types.length > 0, "We got an empty string type");
139
138
  return builder.getUnionType(attributes, new Set(types), forwardingRef);
140
139
  }
141
140
  return graph.rewrite("expand strings", stringTypeMapping, false, allStrings.map(t => [t]), ctx.debugPrintReconstitution, replaceString);