quicktype 18.0.6 → 19.0.4

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 (174) hide show
  1. package/README.md +1 -1
  2. package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
  3. package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
  4. package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
  5. package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
  6. package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
  7. package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
  8. package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
  9. package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
  10. package/dist/{cli/index.d.ts → index.d.ts} +1 -1
  11. package/dist/{cli/index.js → index.js} +4 -5
  12. package/package.json +61 -77
  13. package/dist/quicktype-core/Annotation.d.ts +0 -8
  14. package/dist/quicktype-core/Annotation.js +0 -16
  15. package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
  16. package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
  17. package/dist/quicktype-core/DateTime.d.ts +0 -10
  18. package/dist/quicktype-core/DateTime.js +0 -57
  19. package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
  20. package/dist/quicktype-core/DeclarationIR.js +0 -167
  21. package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
  22. package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
  23. package/dist/quicktype-core/GatherNames.d.ts +0 -2
  24. package/dist/quicktype-core/GatherNames.js +0 -333
  25. package/dist/quicktype-core/Graph.d.ts +0 -12
  26. package/dist/quicktype-core/Graph.js +0 -220
  27. package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
  28. package/dist/quicktype-core/GraphRewriting.js +0 -421
  29. package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
  30. package/dist/quicktype-core/MakeTransformations.js +0 -193
  31. package/dist/quicktype-core/MarkovChain.d.ts +0 -15
  32. package/dist/quicktype-core/MarkovChain.js +0 -154
  33. package/dist/quicktype-core/Messages.d.ts +0 -294
  34. package/dist/quicktype-core/Messages.js +0 -105
  35. package/dist/quicktype-core/Naming.d.ts +0 -64
  36. package/dist/quicktype-core/Naming.js +0 -356
  37. package/dist/quicktype-core/Renderer.d.ts +0 -50
  38. package/dist/quicktype-core/Renderer.js +0 -274
  39. package/dist/quicktype-core/RendererOptions.d.ts +0 -71
  40. package/dist/quicktype-core/RendererOptions.js +0 -141
  41. package/dist/quicktype-core/Run.d.ts +0 -174
  42. package/dist/quicktype-core/Run.js +0 -393
  43. package/dist/quicktype-core/Source.d.ts +0 -65
  44. package/dist/quicktype-core/Source.js +0 -204
  45. package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
  46. package/dist/quicktype-core/TargetLanguage.js +0 -66
  47. package/dist/quicktype-core/Transformers.d.ts +0 -209
  48. package/dist/quicktype-core/Transformers.js +0 -836
  49. package/dist/quicktype-core/Type.d.ts +0 -206
  50. package/dist/quicktype-core/Type.js +0 -716
  51. package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
  52. package/dist/quicktype-core/TypeBuilder.js +0 -324
  53. package/dist/quicktype-core/TypeGraph.d.ts +0 -75
  54. package/dist/quicktype-core/TypeGraph.js +0 -420
  55. package/dist/quicktype-core/TypeUtils.d.ts +0 -33
  56. package/dist/quicktype-core/TypeUtils.js +0 -230
  57. package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
  58. package/dist/quicktype-core/UnifyClasses.js +0 -159
  59. package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
  60. package/dist/quicktype-core/UnionBuilder.js +0 -282
  61. package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
  62. package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
  63. package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
  64. package/dist/quicktype-core/attributes/Constraints.js +0 -172
  65. package/dist/quicktype-core/attributes/Description.d.ts +0 -9
  66. package/dist/quicktype-core/attributes/Description.js +0 -97
  67. package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
  68. package/dist/quicktype-core/attributes/EnumValues.js +0 -31
  69. package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
  70. package/dist/quicktype-core/attributes/StringTypes.js +0 -189
  71. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
  72. package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
  73. package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
  74. package/dist/quicktype-core/attributes/TypeNames.js +0 -274
  75. package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
  76. package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
  77. package/dist/quicktype-core/index.d.ts +0 -48
  78. package/dist/quicktype-core/index.js +0 -180
  79. package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
  80. package/dist/quicktype-core/input/CompressedJSON.js +0 -276
  81. package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
  82. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
  83. package/dist/quicktype-core/input/Inference.d.ts +0 -22
  84. package/dist/quicktype-core/input/Inference.js +0 -240
  85. package/dist/quicktype-core/input/Inputs.d.ts +0 -48
  86. package/dist/quicktype-core/input/Inputs.js +0 -145
  87. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
  88. package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
  89. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
  90. package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
  91. package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
  92. package/dist/quicktype-core/input/PostmanCollection.js +0 -60
  93. package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
  94. package/dist/quicktype-core/input/io/NodeIO.js +0 -87
  95. package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
  96. package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
  97. package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
  98. package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
  99. package/dist/quicktype-core/language/All.d.ts +0 -3
  100. package/dist/quicktype-core/language/All.js +0 -57
  101. package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
  102. package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
  103. package/dist/quicktype-core/language/CSharp.d.ts +0 -201
  104. package/dist/quicktype-core/language/CSharp.js +0 -1850
  105. package/dist/quicktype-core/language/Crystal.d.ts +0 -37
  106. package/dist/quicktype-core/language/Crystal.js +0 -337
  107. package/dist/quicktype-core/language/Dart.d.ts +0 -66
  108. package/dist/quicktype-core/language/Dart.js +0 -576
  109. package/dist/quicktype-core/language/Elm.d.ts +0 -58
  110. package/dist/quicktype-core/language/Elm.js +0 -522
  111. package/dist/quicktype-core/language/Golang.d.ts +0 -51
  112. package/dist/quicktype-core/language/Golang.js +0 -460
  113. package/dist/quicktype-core/language/Haskell.d.ts +0 -56
  114. package/dist/quicktype-core/language/Haskell.js +0 -411
  115. package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
  116. package/dist/quicktype-core/language/JSONSchema.js +0 -169
  117. package/dist/quicktype-core/language/Java.d.ts +0 -125
  118. package/dist/quicktype-core/language/Java.js +0 -1081
  119. package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
  120. package/dist/quicktype-core/language/JavaScript.js +0 -435
  121. package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
  122. package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
  123. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
  124. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
  125. package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
  126. package/dist/quicktype-core/language/Kotlin.js +0 -832
  127. package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
  128. package/dist/quicktype-core/language/Objective-C.js +0 -777
  129. package/dist/quicktype-core/language/Php.d.ts +0 -80
  130. package/dist/quicktype-core/language/Php.js +0 -702
  131. package/dist/quicktype-core/language/Pike.d.ts +0 -37
  132. package/dist/quicktype-core/language/Pike.js +0 -276
  133. package/dist/quicktype-core/language/Python.d.ts +0 -107
  134. package/dist/quicktype-core/language/Python.js +0 -969
  135. package/dist/quicktype-core/language/Rust.d.ts +0 -56
  136. package/dist/quicktype-core/language/Rust.js +0 -309
  137. package/dist/quicktype-core/language/Swift.d.ts +0 -96
  138. package/dist/quicktype-core/language/Swift.js +0 -1211
  139. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
  140. package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
  141. package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
  142. package/dist/quicktype-core/language/ruby/index.js +0 -557
  143. package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
  144. package/dist/quicktype-core/language/ruby/keywords.js +0 -358
  145. package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
  146. package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
  147. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
  148. package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
  149. package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
  150. package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
  151. package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
  152. package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
  153. package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
  154. package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
  155. package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
  156. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
  157. package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
  158. package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
  159. package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
  160. package/dist/quicktype-core/support/Acronyms.js +0 -1128
  161. package/dist/quicktype-core/support/Chance.d.ts +0 -38
  162. package/dist/quicktype-core/support/Chance.js +0 -2146
  163. package/dist/quicktype-core/support/Converters.d.ts +0 -6
  164. package/dist/quicktype-core/support/Converters.js +0 -16
  165. package/dist/quicktype-core/support/Strings.d.ts +0 -44
  166. package/dist/quicktype-core/support/Strings.js +0 -525
  167. package/dist/quicktype-core/support/Support.d.ts +0 -29
  168. package/dist/quicktype-core/support/Support.js +0 -162
  169. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
  170. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
  171. package/dist/quicktype-graphql-input/index.d.ts +0 -17
  172. package/dist/quicktype-graphql-input/index.js +0 -407
  173. package/dist/quicktype-typescript-input/index.d.ts +0 -2
  174. package/dist/quicktype-typescript-input/index.js +0 -98
@@ -1,77 +0,0 @@
1
- import { Type, UnionType, ClassType, EnumType } from "../Type";
2
- import { Sourcelike, MultiWord } from "../Source";
3
- import { Name, Namer } from "../Naming";
4
- import { BooleanOption, Option, OptionValues } from "../RendererOptions";
5
- import { JavaScriptTargetLanguage, JavaScriptRenderer, JavaScriptTypeAnnotations } from "./JavaScript";
6
- import { TargetLanguage } from "../TargetLanguage";
7
- import { RenderContext } from "../Renderer";
8
- export declare const tsFlowOptions: {
9
- acronymStyle: import("../RendererOptions").EnumOption<import("../support/Acronyms").AcronymStyleOptions>;
10
- runtimeTypecheck: BooleanOption;
11
- runtimeTypecheckIgnoreUnknownProperties: BooleanOption;
12
- converters: import("../RendererOptions").EnumOption<import("../support/Converters").ConvertersOptions>;
13
- rawType: import("../RendererOptions").EnumOption<"any" | "json">;
14
- } & {
15
- justTypes: BooleanOption;
16
- nicePropertyNames: BooleanOption;
17
- declareUnions: BooleanOption;
18
- preferUnions: BooleanOption;
19
- };
20
- export declare abstract class TypeScriptFlowBaseTargetLanguage extends JavaScriptTargetLanguage {
21
- protected getOptions(): Option<any>[];
22
- get supportsOptionalClassProperties(): boolean;
23
- protected abstract makeRenderer(renderContext: RenderContext, untypedOptionValues: {
24
- [name: string]: any;
25
- }): JavaScriptRenderer;
26
- }
27
- export declare class TypeScriptTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
28
- constructor();
29
- protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
30
- [name: string]: any;
31
- }): TypeScriptRenderer;
32
- }
33
- export declare abstract class TypeScriptFlowBaseRenderer extends JavaScriptRenderer {
34
- protected readonly _tsFlowOptions: OptionValues<typeof tsFlowOptions>;
35
- constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _tsFlowOptions: OptionValues<typeof tsFlowOptions>);
36
- protected namerForObjectProperty(): Namer;
37
- protected sourceFor(t: Type): MultiWord;
38
- protected abstract emitEnum(e: EnumType, enumName: Name): void;
39
- protected abstract emitClassBlock(c: ClassType, className: Name): void;
40
- protected emitClassBlockBody(c: ClassType): void;
41
- private emitClass;
42
- emitUnion(u: UnionType, unionName: Name): void;
43
- protected emitTypes(): void;
44
- protected emitUsageComments(): void;
45
- protected deserializerFunctionLine(t: Type, name: Name): Sourcelike;
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;
50
- protected emitConvertModule(): void;
51
- protected emitConvertModuleHelpers(): void;
52
- protected emitModuleExports(): void;
53
- }
54
- export declare class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
55
- protected forbiddenNamesForGlobalNamespace(): string[];
56
- protected deserializerFunctionLine(t: Type, name: Name): Sourcelike;
57
- protected serializerFunctionLine(t: Type, name: Name): Sourcelike;
58
- protected get moduleLine(): string | undefined;
59
- protected get typeAnnotations(): JavaScriptTypeAnnotations;
60
- protected emitModuleExports(): void;
61
- protected emitUsageImportComment(): void;
62
- protected emitEnum(e: EnumType, enumName: Name): void;
63
- protected emitClassBlock(c: ClassType, className: Name): void;
64
- }
65
- export declare class FlowTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
66
- constructor();
67
- protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
68
- [name: string]: any;
69
- }): FlowRenderer;
70
- }
71
- export declare class FlowRenderer extends TypeScriptFlowBaseRenderer {
72
- protected forbiddenNamesForGlobalNamespace(): string[];
73
- protected get typeAnnotations(): JavaScriptTypeAnnotations;
74
- protected emitEnum(e: EnumType, enumName: Name): void;
75
- protected emitClassBlock(c: ClassType, className: Name): void;
76
- protected emitSourceStructure(): void;
77
- }
@@ -1,286 +0,0 @@
1
- "use strict";
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
- const Type_1 = require("../Type");
5
- const TypeUtils_1 = require("../TypeUtils");
6
- const Strings_1 = require("../support/Strings");
7
- const Source_1 = require("../Source");
8
- const Naming_1 = require("../Naming");
9
- const RendererOptions_1 = require("../RendererOptions");
10
- const JavaScript_1 = require("./JavaScript");
11
- const Support_1 = require("../support/Support");
12
- const JavaScriptUnicodeMaps_1 = require("./JavaScriptUnicodeMaps");
13
- exports.tsFlowOptions = Object.assign({}, JavaScript_1.javaScriptOptions, {
14
- justTypes: new RendererOptions_1.BooleanOption("just-types", "Interfaces only", false),
15
- nicePropertyNames: new RendererOptions_1.BooleanOption("nice-property-names", "Transform property names to be JavaScripty", false),
16
- declareUnions: new RendererOptions_1.BooleanOption("explicit-unions", "Explicitly name unions", false),
17
- preferUnions: new RendererOptions_1.BooleanOption("prefer-unions", "Use union type instead of enum", false)
18
- });
19
- const tsFlowTypeAnnotations = {
20
- any: ": any",
21
- anyArray: ": any[]",
22
- anyMap: ": { [k: string]: any }",
23
- string: ": string",
24
- stringArray: ": string[]",
25
- boolean: ": boolean"
26
- };
27
- class TypeScriptFlowBaseTargetLanguage extends JavaScript_1.JavaScriptTargetLanguage {
28
- getOptions() {
29
- return [
30
- exports.tsFlowOptions.justTypes,
31
- exports.tsFlowOptions.nicePropertyNames,
32
- exports.tsFlowOptions.declareUnions,
33
- exports.tsFlowOptions.runtimeTypecheck,
34
- exports.tsFlowOptions.runtimeTypecheckIgnoreUnknownProperties,
35
- exports.tsFlowOptions.acronymStyle,
36
- exports.tsFlowOptions.converters,
37
- exports.tsFlowOptions.rawType,
38
- exports.tsFlowOptions.preferUnions
39
- ];
40
- }
41
- get supportsOptionalClassProperties() {
42
- return true;
43
- }
44
- }
45
- exports.TypeScriptFlowBaseTargetLanguage = TypeScriptFlowBaseTargetLanguage;
46
- class TypeScriptTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
47
- constructor() {
48
- super("TypeScript", ["typescript", "ts", "tsx"], "ts");
49
- }
50
- makeRenderer(renderContext, untypedOptionValues) {
51
- return new TypeScriptRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.tsFlowOptions, untypedOptionValues));
52
- }
53
- }
54
- exports.TypeScriptTargetLanguage = TypeScriptTargetLanguage;
55
- function quotePropertyName(original) {
56
- const escaped = (0, Strings_1.utf16StringEscape)(original);
57
- const quoted = `"${escaped}"`;
58
- if (original.length === 0) {
59
- return quoted;
60
- }
61
- else if (!(0, JavaScriptUnicodeMaps_1.isES3IdentifierStart)(original.codePointAt(0))) {
62
- return quoted;
63
- }
64
- else if (escaped !== original) {
65
- return quoted;
66
- }
67
- else if ((0, JavaScript_1.legalizeName)(original) !== original) {
68
- return quoted;
69
- }
70
- else {
71
- return original;
72
- }
73
- }
74
- class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
75
- _tsFlowOptions;
76
- constructor(targetLanguage, renderContext, _tsFlowOptions) {
77
- super(targetLanguage, renderContext, _tsFlowOptions);
78
- this._tsFlowOptions = _tsFlowOptions;
79
- }
80
- namerForObjectProperty() {
81
- if (this._tsFlowOptions.nicePropertyNames) {
82
- return (0, Naming_1.funPrefixNamer)("properties", s => this.nameStyle(s, false));
83
- }
84
- else {
85
- return super.namerForObjectProperty();
86
- }
87
- }
88
- sourceFor(t) {
89
- if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
90
- return (0, Source_1.singleWord)(this.nameForNamedType(t));
91
- }
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 => {
93
- const itemType = this.sourceFor(arrayType.items);
94
- if ((arrayType.items instanceof Type_1.UnionType && !this._tsFlowOptions.declareUnions) ||
95
- arrayType.items instanceof Type_1.ArrayType) {
96
- return (0, Source_1.singleWord)(["Array<", itemType.source, ">"]);
97
- }
98
- else {
99
- return (0, Source_1.singleWord)([(0, Source_1.parenIfNeeded)(itemType), "[]"]);
100
- }
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);
105
- }
106
- else {
107
- return (0, Source_1.singleWord)(this.nameForNamedType(unionType));
108
- }
109
- }, transformedStringType => {
110
- if (transformedStringType.kind === "date-time") {
111
- return (0, Source_1.singleWord)("Date");
112
- }
113
- return (0, Source_1.singleWord)("string");
114
- });
115
- }
116
- emitClassBlockBody(c) {
117
- this.emitPropertyTable(c, (name, _jsonName, p) => {
118
- const t = p.type;
119
- return [
120
- [(0, Source_1.modifySource)(quotePropertyName, name), p.isOptional ? "?" : "", ": "],
121
- [this.sourceFor(t).source, ";"]
122
- ];
123
- });
124
- const additionalProperties = c.getAdditionalProperties();
125
- if (additionalProperties) {
126
- this.emitTable([["[property: string]", ": ", this.sourceFor(additionalProperties).source, ";"]]);
127
- }
128
- }
129
- emitClass(c, className) {
130
- this.emitDescription(this.descriptionForType(c));
131
- this.emitClassBlock(c, className);
132
- }
133
- emitUnion(u, unionName) {
134
- if (!this._tsFlowOptions.declareUnions) {
135
- return;
136
- }
137
- 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))));
139
- this.emitLine("export type ", unionName, " = ", children.source, ";");
140
- }
141
- emitTypes() {
142
- this.forEachNamedType("leading-and-interposing", (c, n) => this.emitClass(c, n), (e, n) => this.emitEnum(e, n), (u, n) => this.emitUnion(u, n));
143
- }
144
- emitUsageComments() {
145
- if (this._tsFlowOptions.justTypes)
146
- return;
147
- super.emitUsageComments();
148
- }
149
- deserializerFunctionLine(t, name) {
150
- const jsonType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
151
- return ["function to", name, "(json: ", jsonType, "): ", this.sourceFor(t).source];
152
- }
153
- serializerFunctionLine(t, name) {
154
- const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
155
- const returnType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
156
- return ["function ", camelCaseName, "ToJson(value: ", this.sourceFor(t).source, "): ", returnType];
157
- }
158
- get moduleLine() {
159
- return undefined;
160
- }
161
- get castFunctionLines() {
162
- return ["function cast<T>(val: any, typ: any): T", "function uncast<T>(val: T, typ: any): any"];
163
- }
164
- get typeAnnotations() {
165
- throw new Error("not implemented");
166
- }
167
- emitConvertModule() {
168
- if (this._tsFlowOptions.justTypes)
169
- return;
170
- super.emitConvertModule();
171
- }
172
- emitConvertModuleHelpers() {
173
- if (this._tsFlowOptions.justTypes)
174
- return;
175
- super.emitConvertModuleHelpers();
176
- }
177
- emitModuleExports() {
178
- if (this._tsFlowOptions.justTypes) {
179
- return;
180
- }
181
- else {
182
- super.emitModuleExports();
183
- }
184
- }
185
- }
186
- exports.TypeScriptFlowBaseRenderer = TypeScriptFlowBaseRenderer;
187
- class TypeScriptRenderer extends TypeScriptFlowBaseRenderer {
188
- forbiddenNamesForGlobalNamespace() {
189
- return ["Array", "Date"];
190
- }
191
- deserializerFunctionLine(t, name) {
192
- const jsonType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
193
- return ["public static to", name, "(json: ", jsonType, "): ", this.sourceFor(t).source];
194
- }
195
- serializerFunctionLine(t, name) {
196
- const camelCaseName = (0, Source_1.modifySource)(Strings_1.camelCase, name);
197
- const returnType = this._tsFlowOptions.rawType === "json" ? "string" : "any";
198
- return ["public static ", camelCaseName, "ToJson(value: ", this.sourceFor(t).source, "): ", returnType];
199
- }
200
- get moduleLine() {
201
- return "export class Convert";
202
- }
203
- get typeAnnotations() {
204
- return Object.assign({ never: ": never" }, tsFlowTypeAnnotations);
205
- }
206
- emitModuleExports() {
207
- return;
208
- }
209
- emitUsageImportComment() {
210
- const topLevelNames = [];
211
- this.forEachTopLevel("none", (_t, name) => {
212
- topLevelNames.push(", ", name);
213
- }, TypeUtils_1.isNamedType);
214
- this.emitLine("// import { Convert", topLevelNames, ' } from "./file";');
215
- }
216
- emitEnum(e, enumName) {
217
- this.emitDescription(this.descriptionForType(e));
218
- if (this._tsFlowOptions.preferUnions) {
219
- let items = "";
220
- e.cases.forEach(item => {
221
- if (items === "") {
222
- items += `"${(0, Strings_1.utf16StringEscape)(item)}"`;
223
- return;
224
- }
225
- items += ` | "${(0, Strings_1.utf16StringEscape)(item)}"`;
226
- });
227
- this.emitLine("export type ", enumName, " = ", items, ";");
228
- }
229
- else {
230
- this.emitBlock(["export enum ", enumName, " "], "", () => {
231
- this.forEachEnumCase(e, "none", (name, jsonName) => {
232
- this.emitLine(name, ` = "${(0, Strings_1.utf16StringEscape)(jsonName)}",`);
233
- });
234
- });
235
- }
236
- }
237
- emitClassBlock(c, className) {
238
- this.emitBlock(["export interface ", className, " "], "", () => {
239
- this.emitClassBlockBody(c);
240
- });
241
- }
242
- }
243
- exports.TypeScriptRenderer = TypeScriptRenderer;
244
- class FlowTargetLanguage extends TypeScriptFlowBaseTargetLanguage {
245
- constructor() {
246
- super("Flow", ["flow"], "js");
247
- }
248
- makeRenderer(renderContext, untypedOptionValues) {
249
- return new FlowRenderer(this, renderContext, (0, RendererOptions_1.getOptionValues)(exports.tsFlowOptions, untypedOptionValues));
250
- }
251
- }
252
- exports.FlowTargetLanguage = FlowTargetLanguage;
253
- class FlowRenderer extends TypeScriptFlowBaseRenderer {
254
- forbiddenNamesForGlobalNamespace() {
255
- return ["Class", "Date", "Object", "String", "Array", "JSON", "Error"];
256
- }
257
- get typeAnnotations() {
258
- return Object.assign({ never: "" }, tsFlowTypeAnnotations);
259
- }
260
- emitEnum(e, enumName) {
261
- this.emitDescription(this.descriptionForType(e));
262
- const lines = [];
263
- this.forEachEnumCase(e, "none", (_, jsonName) => {
264
- const maybeOr = lines.length === 0 ? " " : "| ";
265
- lines.push([maybeOr, '"', (0, Strings_1.utf16StringEscape)(jsonName), '"']);
266
- });
267
- (0, Support_1.defined)(lines[lines.length - 1]).push(";");
268
- this.emitLine("export type ", enumName, " =");
269
- this.indent(() => {
270
- for (const line of lines) {
271
- this.emitLine(line);
272
- }
273
- });
274
- }
275
- emitClassBlock(c, className) {
276
- this.emitBlock(["export type ", className, " = "], ";", () => {
277
- this.emitClassBlockBody(c);
278
- });
279
- }
280
- emitSourceStructure() {
281
- this.emitLine("// @flow");
282
- this.ensureBlankLine();
283
- super.emitSourceStructure();
284
- }
285
- }
286
- exports.FlowRenderer = FlowRenderer;
@@ -1,52 +0,0 @@
1
- import { Namer, Name } from "../../Naming";
2
- import { ConvenienceRenderer, ForbiddenWordsInfo } from "../../ConvenienceRenderer";
3
- import { TargetLanguage } from "../../TargetLanguage";
4
- import { Option, BooleanOption, EnumOption, OptionValues, StringOption } from "../../RendererOptions";
5
- import { Type, ClassType } from "../../Type";
6
- import { RenderContext } from "../../Renderer";
7
- export declare enum Strictness {
8
- Strict = "Strict::",
9
- Coercible = "Coercible::",
10
- None = "Types::"
11
- }
12
- export declare const rubyOptions: {
13
- justTypes: BooleanOption;
14
- strictness: EnumOption<Strictness>;
15
- namespace: StringOption;
16
- };
17
- export declare class RubyTargetLanguage extends TargetLanguage {
18
- constructor();
19
- protected getOptions(): Option<any>[];
20
- get supportsOptionalClassProperties(): boolean;
21
- protected get defaultIndentation(): string;
22
- protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
23
- [name: string]: any;
24
- }): RubyRenderer;
25
- }
26
- export declare class RubyRenderer extends ConvenienceRenderer {
27
- private readonly _options;
28
- constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof rubyOptions>);
29
- protected get commentLineStart(): string;
30
- protected get needsTypeDeclarationBeforeUse(): boolean;
31
- protected canBeForwardDeclared(t: Type): boolean;
32
- protected forbiddenNamesForGlobalNamespace(): string[];
33
- protected forbiddenForObjectProperties(_c: ClassType, _classNamed: Name): ForbiddenWordsInfo;
34
- protected makeNamedTypeNamer(): Namer;
35
- protected namerForObjectProperty(): Namer;
36
- protected makeUnionMemberNamer(): Namer;
37
- protected makeEnumCaseNamer(): Namer;
38
- private dryType;
39
- private exampleUse;
40
- private jsonSample;
41
- private fromDynamic;
42
- private toDynamic;
43
- private marshalsImplicitlyToDynamic;
44
- private propertyTypeMarshalsImplicitlyFromDynamic;
45
- private emitBlock;
46
- private emitModule;
47
- private emitClass;
48
- private emitEnum;
49
- private emitUnion;
50
- private emitTypesModule;
51
- protected emitSourceStructure(): void;
52
- }