quicktype 17.0.1 → 17.0.2

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