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.
- package/README.md +1 -1
- package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
- package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
- package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
- package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
- package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
- package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
- package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
- package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
- package/dist/{cli/index.d.ts → index.d.ts} +1 -1
- package/dist/{cli/index.js → index.js} +4 -5
- package/package.json +61 -77
- package/dist/quicktype-core/Annotation.d.ts +0 -8
- package/dist/quicktype-core/Annotation.js +0 -16
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
- package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
- package/dist/quicktype-core/DateTime.d.ts +0 -10
- package/dist/quicktype-core/DateTime.js +0 -57
- package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
- package/dist/quicktype-core/DeclarationIR.js +0 -167
- package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
- package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
- package/dist/quicktype-core/GatherNames.d.ts +0 -2
- package/dist/quicktype-core/GatherNames.js +0 -333
- package/dist/quicktype-core/Graph.d.ts +0 -12
- package/dist/quicktype-core/Graph.js +0 -220
- package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
- package/dist/quicktype-core/GraphRewriting.js +0 -421
- package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
- package/dist/quicktype-core/MakeTransformations.js +0 -193
- package/dist/quicktype-core/MarkovChain.d.ts +0 -15
- package/dist/quicktype-core/MarkovChain.js +0 -154
- package/dist/quicktype-core/Messages.d.ts +0 -294
- package/dist/quicktype-core/Messages.js +0 -105
- package/dist/quicktype-core/Naming.d.ts +0 -64
- package/dist/quicktype-core/Naming.js +0 -356
- package/dist/quicktype-core/Renderer.d.ts +0 -50
- package/dist/quicktype-core/Renderer.js +0 -274
- package/dist/quicktype-core/RendererOptions.d.ts +0 -71
- package/dist/quicktype-core/RendererOptions.js +0 -141
- package/dist/quicktype-core/Run.d.ts +0 -174
- package/dist/quicktype-core/Run.js +0 -393
- package/dist/quicktype-core/Source.d.ts +0 -65
- package/dist/quicktype-core/Source.js +0 -204
- package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
- package/dist/quicktype-core/TargetLanguage.js +0 -66
- package/dist/quicktype-core/Transformers.d.ts +0 -209
- package/dist/quicktype-core/Transformers.js +0 -836
- package/dist/quicktype-core/Type.d.ts +0 -206
- package/dist/quicktype-core/Type.js +0 -716
- package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
- package/dist/quicktype-core/TypeBuilder.js +0 -324
- package/dist/quicktype-core/TypeGraph.d.ts +0 -75
- package/dist/quicktype-core/TypeGraph.js +0 -420
- package/dist/quicktype-core/TypeUtils.d.ts +0 -33
- package/dist/quicktype-core/TypeUtils.js +0 -230
- package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
- package/dist/quicktype-core/UnifyClasses.js +0 -159
- package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
- package/dist/quicktype-core/UnionBuilder.js +0 -282
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
- package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
- package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
- package/dist/quicktype-core/attributes/Constraints.js +0 -172
- package/dist/quicktype-core/attributes/Description.d.ts +0 -9
- package/dist/quicktype-core/attributes/Description.js +0 -97
- package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
- package/dist/quicktype-core/attributes/EnumValues.js +0 -31
- package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
- package/dist/quicktype-core/attributes/StringTypes.js +0 -189
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
- package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
- package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
- package/dist/quicktype-core/attributes/TypeNames.js +0 -274
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
- package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
- package/dist/quicktype-core/index.d.ts +0 -48
- package/dist/quicktype-core/index.js +0 -180
- package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
- package/dist/quicktype-core/input/CompressedJSON.js +0 -276
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
- package/dist/quicktype-core/input/Inference.d.ts +0 -22
- package/dist/quicktype-core/input/Inference.js +0 -240
- package/dist/quicktype-core/input/Inputs.d.ts +0 -48
- package/dist/quicktype-core/input/Inputs.js +0 -145
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
- package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
- package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
- package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
- package/dist/quicktype-core/input/PostmanCollection.js +0 -60
- package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
- package/dist/quicktype-core/input/io/NodeIO.js +0 -87
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
- package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
- package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
- package/dist/quicktype-core/language/All.d.ts +0 -3
- package/dist/quicktype-core/language/All.js +0 -57
- package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
- package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
- package/dist/quicktype-core/language/CSharp.d.ts +0 -201
- package/dist/quicktype-core/language/CSharp.js +0 -1850
- package/dist/quicktype-core/language/Crystal.d.ts +0 -37
- package/dist/quicktype-core/language/Crystal.js +0 -337
- package/dist/quicktype-core/language/Dart.d.ts +0 -66
- package/dist/quicktype-core/language/Dart.js +0 -576
- package/dist/quicktype-core/language/Elm.d.ts +0 -58
- package/dist/quicktype-core/language/Elm.js +0 -522
- package/dist/quicktype-core/language/Golang.d.ts +0 -51
- package/dist/quicktype-core/language/Golang.js +0 -460
- package/dist/quicktype-core/language/Haskell.d.ts +0 -56
- package/dist/quicktype-core/language/Haskell.js +0 -411
- package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
- package/dist/quicktype-core/language/JSONSchema.js +0 -169
- package/dist/quicktype-core/language/Java.d.ts +0 -125
- package/dist/quicktype-core/language/Java.js +0 -1081
- package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
- package/dist/quicktype-core/language/JavaScript.js +0 -435
- package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
- package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
- package/dist/quicktype-core/language/Kotlin.js +0 -832
- package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
- package/dist/quicktype-core/language/Objective-C.js +0 -777
- package/dist/quicktype-core/language/Php.d.ts +0 -80
- package/dist/quicktype-core/language/Php.js +0 -702
- package/dist/quicktype-core/language/Pike.d.ts +0 -37
- package/dist/quicktype-core/language/Pike.js +0 -276
- package/dist/quicktype-core/language/Python.d.ts +0 -107
- package/dist/quicktype-core/language/Python.js +0 -969
- package/dist/quicktype-core/language/Rust.d.ts +0 -56
- package/dist/quicktype-core/language/Rust.js +0 -309
- package/dist/quicktype-core/language/Swift.d.ts +0 -96
- package/dist/quicktype-core/language/Swift.js +0 -1211
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
- package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
- package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
- package/dist/quicktype-core/language/ruby/index.js +0 -557
- package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
- package/dist/quicktype-core/language/ruby/keywords.js +0 -358
- package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
- package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
- package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
- package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
- package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
- package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
- package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
- package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
- package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
- package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
- package/dist/quicktype-core/support/Acronyms.js +0 -1128
- package/dist/quicktype-core/support/Chance.d.ts +0 -38
- package/dist/quicktype-core/support/Chance.js +0 -2146
- package/dist/quicktype-core/support/Converters.d.ts +0 -6
- package/dist/quicktype-core/support/Converters.js +0 -16
- package/dist/quicktype-core/support/Strings.d.ts +0 -44
- package/dist/quicktype-core/support/Strings.js +0 -525
- package/dist/quicktype-core/support/Support.d.ts +0 -29
- package/dist/quicktype-core/support/Support.js +0 -162
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
- package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
- package/dist/quicktype-graphql-input/index.d.ts +0 -17
- package/dist/quicktype-graphql-input/index.js +0 -407
- package/dist/quicktype-typescript-input/index.d.ts +0 -2
- package/dist/quicktype-typescript-input/index.js +0 -98
|
@@ -1,576 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DartRenderer = exports.DartTargetLanguage = exports.dartOptions = void 0;
|
|
4
|
-
const Type_1 = require("../Type");
|
|
5
|
-
const TypeUtils_1 = require("../TypeUtils");
|
|
6
|
-
const Source_1 = require("../Source");
|
|
7
|
-
const Strings_1 = require("../support/Strings");
|
|
8
|
-
const Naming_1 = require("../Naming");
|
|
9
|
-
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
10
|
-
const TargetLanguage_1 = require("../TargetLanguage");
|
|
11
|
-
const RendererOptions_1 = require("../RendererOptions");
|
|
12
|
-
const Annotation_1 = require("../Annotation");
|
|
13
|
-
const Support_1 = require("../support/Support");
|
|
14
|
-
const collection_utils_1 = require("collection-utils");
|
|
15
|
-
exports.dartOptions = {
|
|
16
|
-
nullSafety: new RendererOptions_1.BooleanOption("null-safety", "Null Safety", true),
|
|
17
|
-
justTypes: new RendererOptions_1.BooleanOption("just-types", "Types only", false),
|
|
18
|
-
codersInClass: new RendererOptions_1.BooleanOption("coders-in-class", "Put encoder & decoder in Class", false),
|
|
19
|
-
methodNamesWithMap: new RendererOptions_1.BooleanOption("from-map", "Use method names fromMap() & toMap()", false, "secondary"),
|
|
20
|
-
requiredProperties: new RendererOptions_1.BooleanOption("required-props", "Make all properties required", false),
|
|
21
|
-
finalProperties: new RendererOptions_1.BooleanOption("final-props", "Make all properties final", false),
|
|
22
|
-
generateCopyWith: new RendererOptions_1.BooleanOption("copy-with", "Generate CopyWith method", false),
|
|
23
|
-
useFreezed: new RendererOptions_1.BooleanOption("use-freezed", "Generate class definitions with @freezed compatibility", false, "secondary"),
|
|
24
|
-
useHive: new RendererOptions_1.BooleanOption("use-hive", "Generate annotations for Hive type adapters", false, "secondary"),
|
|
25
|
-
partName: new RendererOptions_1.StringOption("part-name", "Use this name in `part` directive", "NAME", "", "secondary")
|
|
26
|
-
};
|
|
27
|
-
class DartTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
28
|
-
constructor() {
|
|
29
|
-
super("Dart", ["dart"], "dart");
|
|
30
|
-
}
|
|
31
|
-
getOptions() {
|
|
32
|
-
return [
|
|
33
|
-
exports.dartOptions.nullSafety,
|
|
34
|
-
exports.dartOptions.justTypes,
|
|
35
|
-
exports.dartOptions.codersInClass,
|
|
36
|
-
exports.dartOptions.methodNamesWithMap,
|
|
37
|
-
exports.dartOptions.requiredProperties,
|
|
38
|
-
exports.dartOptions.finalProperties,
|
|
39
|
-
exports.dartOptions.generateCopyWith,
|
|
40
|
-
exports.dartOptions.useFreezed,
|
|
41
|
-
exports.dartOptions.useHive,
|
|
42
|
-
exports.dartOptions.partName
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
get supportsUnionsWithBothNumberTypes() {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
get stringTypeMapping() {
|
|
49
|
-
const mapping = new Map();
|
|
50
|
-
mapping.set("date", "date");
|
|
51
|
-
mapping.set("date-time", "date-time");
|
|
52
|
-
// mapping.set("uuid", "uuid");
|
|
53
|
-
return mapping;
|
|
54
|
-
}
|
|
55
|
-
makeRenderer(renderContext, untypedOptionValues) {
|
|
56
|
-
const options = (0, RendererOptions_1.getOptionValues)(exports.dartOptions, untypedOptionValues);
|
|
57
|
-
return new DartRenderer(this, renderContext, options);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.DartTargetLanguage = DartTargetLanguage;
|
|
61
|
-
const keywords = [
|
|
62
|
-
"abstract",
|
|
63
|
-
"do",
|
|
64
|
-
"import",
|
|
65
|
-
"super",
|
|
66
|
-
"as",
|
|
67
|
-
"dynamic",
|
|
68
|
-
"in",
|
|
69
|
-
"switch",
|
|
70
|
-
"assert",
|
|
71
|
-
"else",
|
|
72
|
-
"interface",
|
|
73
|
-
"sync*",
|
|
74
|
-
"async",
|
|
75
|
-
"enum",
|
|
76
|
-
"is",
|
|
77
|
-
"this",
|
|
78
|
-
"async*",
|
|
79
|
-
"export",
|
|
80
|
-
"library",
|
|
81
|
-
"throw",
|
|
82
|
-
"await",
|
|
83
|
-
"external",
|
|
84
|
-
"mixin",
|
|
85
|
-
"true",
|
|
86
|
-
"break",
|
|
87
|
-
"extends",
|
|
88
|
-
"new",
|
|
89
|
-
"try",
|
|
90
|
-
"case",
|
|
91
|
-
"factory",
|
|
92
|
-
"null",
|
|
93
|
-
"typedef",
|
|
94
|
-
"catch",
|
|
95
|
-
"false",
|
|
96
|
-
"operator",
|
|
97
|
-
"var",
|
|
98
|
-
"class",
|
|
99
|
-
"final",
|
|
100
|
-
"part",
|
|
101
|
-
"void",
|
|
102
|
-
"const",
|
|
103
|
-
"finally",
|
|
104
|
-
"rethrow",
|
|
105
|
-
"while",
|
|
106
|
-
"continue",
|
|
107
|
-
"for",
|
|
108
|
-
"return",
|
|
109
|
-
"with",
|
|
110
|
-
"covariant",
|
|
111
|
-
"get",
|
|
112
|
-
"set",
|
|
113
|
-
"yield",
|
|
114
|
-
"default",
|
|
115
|
-
"if",
|
|
116
|
-
"static",
|
|
117
|
-
"yield*",
|
|
118
|
-
"deferred",
|
|
119
|
-
"implements",
|
|
120
|
-
"int",
|
|
121
|
-
"double",
|
|
122
|
-
"bool",
|
|
123
|
-
"Map",
|
|
124
|
-
"List",
|
|
125
|
-
"String",
|
|
126
|
-
"File",
|
|
127
|
-
"fromJson",
|
|
128
|
-
"toJson",
|
|
129
|
-
"fromMap",
|
|
130
|
-
"toMap"
|
|
131
|
-
];
|
|
132
|
-
const typeNamingFunction = (0, Naming_1.funPrefixNamer)("types", n => dartNameStyle(true, false, n));
|
|
133
|
-
const propertyNamingFunction = (0, Naming_1.funPrefixNamer)("properties", n => dartNameStyle(false, false, n));
|
|
134
|
-
const enumCaseNamingFunction = (0, Naming_1.funPrefixNamer)("enum-cases", n => dartNameStyle(true, true, n));
|
|
135
|
-
// Escape the dollar sign, which is used in string interpolation
|
|
136
|
-
const stringEscape = (0, Strings_1.utf16ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(cp => (0, Strings_1.isPrintable)(cp) && cp !== 0x24, Strings_1.standardUnicodeHexEscape));
|
|
137
|
-
function isStartCharacter(codePoint) {
|
|
138
|
-
if (codePoint === 0x5f)
|
|
139
|
-
return false; // underscore
|
|
140
|
-
return (0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isLetter)(codePoint);
|
|
141
|
-
}
|
|
142
|
-
function isPartCharacter(codePoint) {
|
|
143
|
-
return isStartCharacter(codePoint) || ((0, Strings_1.isAscii)(codePoint) && (0, Strings_1.isDigit)(codePoint));
|
|
144
|
-
}
|
|
145
|
-
const legalizeName = (0, Strings_1.utf16LegalizeCharacters)(isPartCharacter);
|
|
146
|
-
// FIXME: Handle acronyms consistently. In particular, that means that
|
|
147
|
-
// we have to use namers to produce the getter and setter names - we can't
|
|
148
|
-
// just capitalize and concatenate.
|
|
149
|
-
// https://stackoverflow.com/questions/8277355/naming-convention-for-upper-case-abbreviations
|
|
150
|
-
function dartNameStyle(startWithUpper, upperUnderscore, original) {
|
|
151
|
-
const words = (0, Strings_1.splitIntoWords)(original);
|
|
152
|
-
const firstWordStyle = upperUnderscore
|
|
153
|
-
? Strings_1.allUpperWordStyle
|
|
154
|
-
: startWithUpper
|
|
155
|
-
? Strings_1.firstUpperWordStyle
|
|
156
|
-
: Strings_1.allLowerWordStyle;
|
|
157
|
-
const restWordStyle = upperUnderscore ? Strings_1.allUpperWordStyle : Strings_1.firstUpperWordStyle;
|
|
158
|
-
return (0, Strings_1.combineWords)(words, legalizeName, firstWordStyle, restWordStyle, firstWordStyle, restWordStyle, upperUnderscore ? "_" : "", isStartCharacter);
|
|
159
|
-
}
|
|
160
|
-
class DartRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
161
|
-
_options;
|
|
162
|
-
_gettersAndSettersForPropertyName = new Map();
|
|
163
|
-
_needEnumValues = false;
|
|
164
|
-
classCounter = 0;
|
|
165
|
-
classPropertyCounter = 0;
|
|
166
|
-
_topLevelDependents = new Map();
|
|
167
|
-
_enumValues = new Map();
|
|
168
|
-
constructor(targetLanguage, renderContext, _options) {
|
|
169
|
-
super(targetLanguage, renderContext);
|
|
170
|
-
this._options = _options;
|
|
171
|
-
}
|
|
172
|
-
forbiddenNamesForGlobalNamespace() {
|
|
173
|
-
return keywords;
|
|
174
|
-
}
|
|
175
|
-
forbiddenForObjectProperties(_c, _className) {
|
|
176
|
-
return { names: [], includeGlobalForbidden: true };
|
|
177
|
-
}
|
|
178
|
-
makeNamedTypeNamer() {
|
|
179
|
-
return typeNamingFunction;
|
|
180
|
-
}
|
|
181
|
-
namerForObjectProperty() {
|
|
182
|
-
return propertyNamingFunction;
|
|
183
|
-
}
|
|
184
|
-
makeUnionMemberNamer() {
|
|
185
|
-
return propertyNamingFunction;
|
|
186
|
-
}
|
|
187
|
-
makeEnumCaseNamer() {
|
|
188
|
-
return enumCaseNamingFunction;
|
|
189
|
-
}
|
|
190
|
-
unionNeedsName(u) {
|
|
191
|
-
return (0, TypeUtils_1.nullableFromUnion)(u) === null;
|
|
192
|
-
}
|
|
193
|
-
namedTypeToNameForTopLevel(type) {
|
|
194
|
-
// If the top-level type doesn't contain any classes or unions
|
|
195
|
-
// we have to define a class just for the `FromJson` method, in
|
|
196
|
-
// emitFromJsonForTopLevel.
|
|
197
|
-
return (0, TypeUtils_1.directlyReachableSingleNamedType)(type);
|
|
198
|
-
}
|
|
199
|
-
get toJson() {
|
|
200
|
-
return `to${this._options.methodNamesWithMap ? "Map" : "Json"}`;
|
|
201
|
-
}
|
|
202
|
-
get fromJson() {
|
|
203
|
-
return `from${this._options.methodNamesWithMap ? "Map" : "Json"}`;
|
|
204
|
-
}
|
|
205
|
-
makeTopLevelDependencyNames(_t, name) {
|
|
206
|
-
const encoder = new Naming_1.DependencyName(propertyNamingFunction, name.order, lookup => `${lookup(name)}_${this.toJson}`);
|
|
207
|
-
const decoder = new Naming_1.DependencyName(propertyNamingFunction, name.order, lookup => `${lookup(name)}_${this.fromJson}`);
|
|
208
|
-
this._topLevelDependents.set(name, { encoder, decoder });
|
|
209
|
-
return [encoder, decoder];
|
|
210
|
-
}
|
|
211
|
-
makeNamesForPropertyGetterAndSetter(_c, _className, _p, _jsonName, name) {
|
|
212
|
-
const getterName = new Naming_1.DependencyName(propertyNamingFunction, name.order, lookup => `get_${lookup(name)}`);
|
|
213
|
-
const setterName = new Naming_1.DependencyName(propertyNamingFunction, name.order, lookup => `set_${lookup(name)}`);
|
|
214
|
-
return [getterName, setterName];
|
|
215
|
-
}
|
|
216
|
-
makePropertyDependencyNames(c, className, p, jsonName, name) {
|
|
217
|
-
const getterAndSetterNames = this.makeNamesForPropertyGetterAndSetter(c, className, p, jsonName, name);
|
|
218
|
-
this._gettersAndSettersForPropertyName.set(name, getterAndSetterNames);
|
|
219
|
-
return getterAndSetterNames;
|
|
220
|
-
}
|
|
221
|
-
makeNamedTypeDependencyNames(t, name) {
|
|
222
|
-
if (!(t instanceof Type_1.EnumType))
|
|
223
|
-
return [];
|
|
224
|
-
const enumValue = new Naming_1.DependencyName(propertyNamingFunction, name.order, lookup => `${lookup(name)}_values`);
|
|
225
|
-
this._enumValues.set(t, enumValue);
|
|
226
|
-
return [enumValue];
|
|
227
|
-
}
|
|
228
|
-
emitFileHeader() {
|
|
229
|
-
if (this.leadingComments !== undefined) {
|
|
230
|
-
this.emitCommentLines(this.leadingComments);
|
|
231
|
-
}
|
|
232
|
-
if (this._options.justTypes)
|
|
233
|
-
return;
|
|
234
|
-
this.emitLine("// To parse this JSON data, do");
|
|
235
|
-
this.emitLine("//");
|
|
236
|
-
this.forEachTopLevel("none", (_t, name) => {
|
|
237
|
-
const { decoder } = (0, Support_1.defined)(this._topLevelDependents.get(name));
|
|
238
|
-
this.emitLine("// final ", (0, Source_1.modifySource)(Strings_1.decapitalize, name), " = ", decoder, "(jsonString);");
|
|
239
|
-
});
|
|
240
|
-
this.ensureBlankLine();
|
|
241
|
-
if (this._options.requiredProperties) {
|
|
242
|
-
this.emitLine("import 'package:meta/meta.dart';");
|
|
243
|
-
}
|
|
244
|
-
if (this._options.useFreezed) {
|
|
245
|
-
this.emitLine("import 'package:freezed_annotation/freezed_annotation.dart';");
|
|
246
|
-
}
|
|
247
|
-
if (this._options.useHive) {
|
|
248
|
-
this.emitLine("import 'package:hive/hive.dart';");
|
|
249
|
-
}
|
|
250
|
-
this.emitLine("import 'dart:convert';");
|
|
251
|
-
if (this._options.useFreezed || this._options.useHive) {
|
|
252
|
-
this.ensureBlankLine();
|
|
253
|
-
const optionNameIsEmpty = this._options.partName.length === 0;
|
|
254
|
-
// FIXME: This should use a `Name`, not `modifySource`
|
|
255
|
-
const name = (0, Source_1.modifySource)(Strings_1.snakeCase, optionNameIsEmpty ? [...this.topLevels.keys()][0] : this._options.partName);
|
|
256
|
-
if (this._options.useFreezed) {
|
|
257
|
-
this.emitLine("part '", name, ".freezed.dart';");
|
|
258
|
-
}
|
|
259
|
-
if (!this._options.justTypes) {
|
|
260
|
-
this.emitLine("part '", name, ".g.dart';");
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
emitDescriptionBlock(lines) {
|
|
265
|
-
this.emitCommentLines(lines, "///", "");
|
|
266
|
-
}
|
|
267
|
-
emitBlock(line, f) {
|
|
268
|
-
this.emitLine(line, " {");
|
|
269
|
-
this.indent(f);
|
|
270
|
-
this.emitLine("}");
|
|
271
|
-
}
|
|
272
|
-
dartType(t, withIssues = false) {
|
|
273
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, "dynamic"), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, "dynamic"), _boolType => {
|
|
274
|
-
if (this._options.nullSafety) {
|
|
275
|
-
return ["bool", "?"];
|
|
276
|
-
}
|
|
277
|
-
return "bool";
|
|
278
|
-
}, _integerType => {
|
|
279
|
-
if (this._options.nullSafety) {
|
|
280
|
-
return ["int", "?"];
|
|
281
|
-
}
|
|
282
|
-
return "int";
|
|
283
|
-
}, _doubleType => {
|
|
284
|
-
if (this._options.nullSafety) {
|
|
285
|
-
return ["double", "?"];
|
|
286
|
-
}
|
|
287
|
-
return "double";
|
|
288
|
-
}, _stringType => {
|
|
289
|
-
if (this._options.nullSafety) {
|
|
290
|
-
return ["String", "?"];
|
|
291
|
-
}
|
|
292
|
-
return "String";
|
|
293
|
-
}, arrayType => {
|
|
294
|
-
if (this._options.nullSafety) {
|
|
295
|
-
return ["List<", this.dartType(arrayType.items, withIssues), ">", "?"];
|
|
296
|
-
}
|
|
297
|
-
return ["List<", this.dartType(arrayType.items, withIssues), ">"];
|
|
298
|
-
}, classType => {
|
|
299
|
-
if (this._options.nullSafety) {
|
|
300
|
-
return [this.nameForNamedType(classType), "?"];
|
|
301
|
-
}
|
|
302
|
-
return this.nameForNamedType(classType);
|
|
303
|
-
}, mapType => {
|
|
304
|
-
if (this._options.nullSafety) {
|
|
305
|
-
return [["Map<String, ", this.dartType(mapType.values, withIssues), ">"], "?"];
|
|
306
|
-
}
|
|
307
|
-
return ["Map<String, ", this.dartType(mapType.values, withIssues), ">"];
|
|
308
|
-
}, enumType => {
|
|
309
|
-
if (this._options.nullSafety) {
|
|
310
|
-
return [this.nameForNamedType(enumType), "?"];
|
|
311
|
-
}
|
|
312
|
-
return this.nameForNamedType(enumType);
|
|
313
|
-
}, unionType => {
|
|
314
|
-
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
315
|
-
if (maybeNullable === null) {
|
|
316
|
-
return "dynamic";
|
|
317
|
-
}
|
|
318
|
-
return this.dartType(maybeNullable, withIssues);
|
|
319
|
-
}, transformedStringType => {
|
|
320
|
-
switch (transformedStringType.kind) {
|
|
321
|
-
case "date-time":
|
|
322
|
-
case "date":
|
|
323
|
-
return this._options.nullSafety ? ["DateTime", "?"] : "DateTime";
|
|
324
|
-
default:
|
|
325
|
-
return this._options.nullSafety ? ["String", "?"] : "String";
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
mapList(itemType, list, mapper) {
|
|
330
|
-
if (this._options.nullSafety) {
|
|
331
|
-
return [list, " == null ? [] : ", "List<", itemType, ">.from(", list, "!.map((x) => ", mapper, "))"];
|
|
332
|
-
}
|
|
333
|
-
return ["List<", itemType, ">.from(", list, ".map((x) => ", mapper, "))"];
|
|
334
|
-
}
|
|
335
|
-
mapMap(valueType, map, valueMapper) {
|
|
336
|
-
if (this._options.nullSafety) {
|
|
337
|
-
return ["Map.from(", map, "!).map((k, v) => MapEntry<String, ", valueType, ">(k, ", valueMapper, "))"];
|
|
338
|
-
}
|
|
339
|
-
return ["Map.from(", map, ").map((k, v) => MapEntry<String, ", valueType, ">(k, ", valueMapper, "))"];
|
|
340
|
-
}
|
|
341
|
-
fromDynamicExpression(t, ...dynamic) {
|
|
342
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => dynamic, _nullType => dynamic, // FIXME: check null
|
|
343
|
-
// FIXME: check null
|
|
344
|
-
_boolType => dynamic, _integerType => dynamic, _doubleType => [dynamic, ".toDouble()"], _stringType => dynamic, arrayType => this.mapList(this.dartType(arrayType.items), dynamic, this.fromDynamicExpression(arrayType.items, "x")), classType => [this.nameForNamedType(classType), ".", this.fromJson, "(", dynamic, ")"], mapType => this.mapMap(this.dartType(mapType.values), dynamic, this.fromDynamicExpression(mapType.values, "v")), enumType => {
|
|
345
|
-
if (this._options.nullSafety) {
|
|
346
|
-
return [(0, Support_1.defined)(this._enumValues.get(enumType)), "!.map[", dynamic, "]"];
|
|
347
|
-
}
|
|
348
|
-
return [(0, Support_1.defined)(this._enumValues.get(enumType)), ".map[", dynamic, "]"];
|
|
349
|
-
}, unionType => {
|
|
350
|
-
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
351
|
-
if (maybeNullable === null) {
|
|
352
|
-
return dynamic;
|
|
353
|
-
}
|
|
354
|
-
if (maybeNullable.kind === "array") {
|
|
355
|
-
return [dynamic, " == null ? [] : ", this.fromDynamicExpression(maybeNullable, dynamic)];
|
|
356
|
-
}
|
|
357
|
-
return dynamic;
|
|
358
|
-
}, transformedStringType => {
|
|
359
|
-
switch (transformedStringType.kind) {
|
|
360
|
-
case "date-time":
|
|
361
|
-
case "date":
|
|
362
|
-
return ["DateTime.parse(", dynamic, ")"];
|
|
363
|
-
default:
|
|
364
|
-
return dynamic;
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
toDynamicExpression(t, ...dynamic) {
|
|
369
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => dynamic, _nullType => dynamic, _boolType => dynamic, _integerType => dynamic, _doubleType => dynamic, _stringType => dynamic, arrayType => this.mapList("dynamic", dynamic, this.toDynamicExpression(arrayType.items, "x")), _classType => {
|
|
370
|
-
if (this._options.nullSafety) {
|
|
371
|
-
return [dynamic, "!.", this.toJson, "()"];
|
|
372
|
-
}
|
|
373
|
-
return [dynamic, ".", this.toJson, "()"];
|
|
374
|
-
}, mapType => this.mapMap("dynamic", dynamic, this.toDynamicExpression(mapType.values, "v")), enumType => {
|
|
375
|
-
if (this._options.nullSafety) {
|
|
376
|
-
return [(0, Support_1.defined)(this._enumValues.get(enumType)), ".reverse![", dynamic, "]"];
|
|
377
|
-
}
|
|
378
|
-
return [(0, Support_1.defined)(this._enumValues.get(enumType)), ".reverse[", dynamic, "]"];
|
|
379
|
-
}, unionType => {
|
|
380
|
-
const maybeNullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
381
|
-
if (maybeNullable === null) {
|
|
382
|
-
return dynamic;
|
|
383
|
-
}
|
|
384
|
-
if (maybeNullable.kind === "array") {
|
|
385
|
-
return [dynamic, " == null ? [] : ", this.toDynamicExpression(maybeNullable, dynamic)];
|
|
386
|
-
}
|
|
387
|
-
return dynamic;
|
|
388
|
-
}, transformedStringType => {
|
|
389
|
-
switch (transformedStringType.kind) {
|
|
390
|
-
case "date-time":
|
|
391
|
-
if (this._options.nullSafety) {
|
|
392
|
-
return [dynamic, "?.toIso8601String()"];
|
|
393
|
-
}
|
|
394
|
-
return [dynamic, ".toIso8601String()"];
|
|
395
|
-
case "date":
|
|
396
|
-
if (this._options.nullSafety) {
|
|
397
|
-
return [
|
|
398
|
-
'"${',
|
|
399
|
-
dynamic,
|
|
400
|
-
"!.year.toString().padLeft(4, '0')",
|
|
401
|
-
"}-${",
|
|
402
|
-
dynamic,
|
|
403
|
-
"!.month.toString().padLeft(2, '0')}-${",
|
|
404
|
-
dynamic,
|
|
405
|
-
"!.day.toString().padLeft(2, '0')}\""
|
|
406
|
-
];
|
|
407
|
-
}
|
|
408
|
-
return [
|
|
409
|
-
'"${',
|
|
410
|
-
dynamic,
|
|
411
|
-
".year.toString().padLeft(4, '0')",
|
|
412
|
-
"}-${",
|
|
413
|
-
dynamic,
|
|
414
|
-
".month.toString().padLeft(2, '0')}-${",
|
|
415
|
-
dynamic,
|
|
416
|
-
".day.toString().padLeft(2, '0')}\""
|
|
417
|
-
];
|
|
418
|
-
default:
|
|
419
|
-
return dynamic;
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
emitClassDefinition(c, className) {
|
|
424
|
-
this.emitDescription(this.descriptionForType(c));
|
|
425
|
-
if (this._options.useHive) {
|
|
426
|
-
this.classCounter++;
|
|
427
|
-
this.emitLine(`@HiveType(typeId: ${this.classCounter})`);
|
|
428
|
-
this.classPropertyCounter = 0;
|
|
429
|
-
}
|
|
430
|
-
this.emitBlock(["class ", className], () => {
|
|
431
|
-
if (c.getProperties().size === 0) {
|
|
432
|
-
this.emitLine(className, "();");
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
this.emitLine(className, "({");
|
|
436
|
-
this.indent(() => {
|
|
437
|
-
this.forEachClassProperty(c, "none", (name, _, _p) => {
|
|
438
|
-
this.emitLine(this._options.requiredProperties ? "required " : "", "this.", name, ",");
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
this.emitLine("});");
|
|
442
|
-
this.ensureBlankLine();
|
|
443
|
-
this.forEachClassProperty(c, "none", (name, jsonName, p) => {
|
|
444
|
-
const description = this.descriptionForClassProperty(c, jsonName);
|
|
445
|
-
if (description !== undefined) {
|
|
446
|
-
this.emitDescription(description);
|
|
447
|
-
}
|
|
448
|
-
if (this._options.useHive) {
|
|
449
|
-
this.classPropertyCounter++;
|
|
450
|
-
this.emitLine(`@HiveField(${this.classPropertyCounter})`);
|
|
451
|
-
}
|
|
452
|
-
this.emitLine(this._options.finalProperties ? "final " : "", this.dartType(p.type, true), " ", name, ";");
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
if (this._options.generateCopyWith) {
|
|
456
|
-
this.ensureBlankLine();
|
|
457
|
-
this.emitLine(className, " copyWith({");
|
|
458
|
-
this.indent(() => {
|
|
459
|
-
this.forEachClassProperty(c, "none", (name, _, _p) => {
|
|
460
|
-
this.emitLine(this.dartType(_p.type, true), " ", name, ",");
|
|
461
|
-
});
|
|
462
|
-
});
|
|
463
|
-
this.emitLine("}) => ");
|
|
464
|
-
this.indent(() => {
|
|
465
|
-
this.emitLine(className, "(");
|
|
466
|
-
this.indent(() => {
|
|
467
|
-
this.forEachClassProperty(c, "none", (name, _, _p) => {
|
|
468
|
-
this.emitLine(name, ": ", name, " ?? ", "this.", name, ",");
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
this.emitLine(");");
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
if (this._options.justTypes)
|
|
475
|
-
return;
|
|
476
|
-
if (this._options.codersInClass) {
|
|
477
|
-
this.ensureBlankLine();
|
|
478
|
-
this.emitLine("factory ", className, ".from", this._options.methodNamesWithMap ? "Json" : "RawJson", "(String str) => ", className, ".", this.fromJson, "(json.decode(str));");
|
|
479
|
-
this.ensureBlankLine();
|
|
480
|
-
this.emitLine("String ", this._options.methodNamesWithMap ? "toJson() => " : "toRawJson() => ", "json.encode(", this.toJson, "());");
|
|
481
|
-
}
|
|
482
|
-
this.ensureBlankLine();
|
|
483
|
-
this.emitLine("factory ", className, ".", this.fromJson, "(Map<String, dynamic> json) => ", className, "(");
|
|
484
|
-
this.indent(() => {
|
|
485
|
-
this.forEachClassProperty(c, "none", (name, jsonName, property) => {
|
|
486
|
-
this.emitLine(name, ": ", this.fromDynamicExpression(property.type, 'json["', stringEscape(jsonName), '"]'), ",");
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
this.emitLine(");");
|
|
490
|
-
this.ensureBlankLine();
|
|
491
|
-
this.emitLine("Map<String, dynamic> ", this.toJson, "() => {");
|
|
492
|
-
this.indent(() => {
|
|
493
|
-
this.forEachClassProperty(c, "none", (name, jsonName, property) => {
|
|
494
|
-
this.emitLine('"', stringEscape(jsonName), '": ', this.toDynamicExpression(property.type, name), ",");
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
this.emitLine("};");
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
emitFreezedClassDefinition(c, className) {
|
|
501
|
-
this.emitDescription(this.descriptionForType(c));
|
|
502
|
-
this.emitLine("@freezed");
|
|
503
|
-
this.emitBlock(["class ", className, " with _$", className], () => {
|
|
504
|
-
if (c.getProperties().size === 0) {
|
|
505
|
-
this.emitLine("const factory ", className, "() = _", className, ";");
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
this.emitLine("const factory ", className, "({");
|
|
509
|
-
this.indent(() => {
|
|
510
|
-
this.forEachClassProperty(c, "none", (name, _, _p) => {
|
|
511
|
-
this.emitLine(this._options.requiredProperties ? "required " : "", this.dartType(_p.type, true), this._options.requiredProperties ? "" : "?", " ", name, ",");
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
this.emitLine("}) = _", className, ";");
|
|
515
|
-
}
|
|
516
|
-
if (this._options.justTypes)
|
|
517
|
-
return;
|
|
518
|
-
this.ensureBlankLine();
|
|
519
|
-
this.emitLine(
|
|
520
|
-
// factory PublicAnswer.fromJson(Map<String, dynamic> json) => _$PublicAnswerFromJson(json);
|
|
521
|
-
"factory ", className, ".fromJson(Map<String, dynamic> json) => ", "_$", className, "FromJson(json);");
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
emitEnumDefinition(e, enumName) {
|
|
525
|
-
const caseNames = Array.from(e.cases).map(c => this.nameForEnumCase(e, c));
|
|
526
|
-
this.emitDescription(this.descriptionForType(e));
|
|
527
|
-
this.emitLine("enum ", enumName, " { ", (0, collection_utils_1.arrayIntercalate)(", ", caseNames), " }");
|
|
528
|
-
if (this._options.justTypes)
|
|
529
|
-
return;
|
|
530
|
-
this.ensureBlankLine();
|
|
531
|
-
this.emitLine("final ", (0, Support_1.defined)(this._enumValues.get(e)), " = EnumValues({");
|
|
532
|
-
this.indent(() => {
|
|
533
|
-
this.forEachEnumCase(e, "none", (name, jsonName, pos) => {
|
|
534
|
-
const comma = pos === "first" || pos === "middle" ? "," : [];
|
|
535
|
-
this.emitLine('"', stringEscape(jsonName), '": ', enumName, ".", name, comma);
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
this.emitLine("});");
|
|
539
|
-
this._needEnumValues = true;
|
|
540
|
-
}
|
|
541
|
-
emitEnumValues() {
|
|
542
|
-
this.ensureBlankLine();
|
|
543
|
-
this.emitMultiline(`class EnumValues<T> {
|
|
544
|
-
Map<String, T> map;
|
|
545
|
-
Map<T, String>? reverseMap;
|
|
546
|
-
|
|
547
|
-
EnumValues(this.map);
|
|
548
|
-
|
|
549
|
-
Map<T, String>? get reverse {
|
|
550
|
-
reverseMap ??= map.map((k, v) => MapEntry(v, k));
|
|
551
|
-
return reverseMap;
|
|
552
|
-
}
|
|
553
|
-
}`);
|
|
554
|
-
}
|
|
555
|
-
emitSourceStructure() {
|
|
556
|
-
this.emitFileHeader();
|
|
557
|
-
if (!this._options.justTypes && !this._options.codersInClass) {
|
|
558
|
-
this.forEachTopLevel("leading-and-interposing", (t, name) => {
|
|
559
|
-
const { encoder, decoder } = (0, Support_1.defined)(this._topLevelDependents.get(name));
|
|
560
|
-
this.emitLine(this.dartType(t), " ", decoder, "(String str) => ", this.fromDynamicExpression(t, "json.decode(str)"), ";");
|
|
561
|
-
this.ensureBlankLine();
|
|
562
|
-
this.emitLine("String ", encoder, "(", this.dartType(t), " data) => json.encode(", this.toDynamicExpression(t, "data"), ");");
|
|
563
|
-
// this.emitBlock(["String ", encoder, "(", this.dartType(t), " data)"], () => {
|
|
564
|
-
// this.emitJsonEncoderBlock(t);
|
|
565
|
-
// });
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
this.forEachNamedType("leading-and-interposing", (c, n) => this._options.useFreezed ? this.emitFreezedClassDefinition(c, n) : this.emitClassDefinition(c, n), (e, n) => this.emitEnumDefinition(e, n), (_e, _n) => {
|
|
569
|
-
// We don't support this yet.
|
|
570
|
-
});
|
|
571
|
-
if (this._needEnumValues) {
|
|
572
|
-
this.emitEnumValues();
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
exports.DartRenderer = DartRenderer;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
2
|
-
import { EnumOption, StringOption, BooleanOption, Option, OptionValues } from "../RendererOptions";
|
|
3
|
-
import { Type, ClassType, UnionType } from "../Type";
|
|
4
|
-
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
5
|
-
import { Namer, Name, DependencyName } from "../Naming";
|
|
6
|
-
import { Sourcelike } from "../Source";
|
|
7
|
-
import { RenderContext } from "../Renderer";
|
|
8
|
-
export declare const elmOptions: {
|
|
9
|
-
justTypes: BooleanOption;
|
|
10
|
-
useList: EnumOption<boolean>;
|
|
11
|
-
moduleName: StringOption;
|
|
12
|
-
};
|
|
13
|
-
export declare class ElmTargetLanguage extends TargetLanguage {
|
|
14
|
-
constructor();
|
|
15
|
-
protected getOptions(): Option<any>[];
|
|
16
|
-
get supportsOptionalClassProperties(): boolean;
|
|
17
|
-
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
18
|
-
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
19
|
-
[name: string]: any;
|
|
20
|
-
}): ElmRenderer;
|
|
21
|
-
}
|
|
22
|
-
export declare class ElmRenderer extends ConvenienceRenderer {
|
|
23
|
-
private readonly _options;
|
|
24
|
-
private readonly _topLevelDependents;
|
|
25
|
-
private readonly _namedTypeDependents;
|
|
26
|
-
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof elmOptions>);
|
|
27
|
-
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
28
|
-
protected makeTopLevelDependencyNames(t: Type, topLevelName: Name): DependencyName[];
|
|
29
|
-
protected makeNamedTypeNamer(): Namer;
|
|
30
|
-
protected makeNamedTypeDependencyNames(_: Type, typeName: Name): DependencyName[];
|
|
31
|
-
protected namerForObjectProperty(): Namer;
|
|
32
|
-
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
33
|
-
protected makeUnionMemberNamer(): Namer;
|
|
34
|
-
protected get unionMembersInGlobalNamespace(): boolean;
|
|
35
|
-
protected makeEnumCaseNamer(): Namer;
|
|
36
|
-
protected get enumCasesInGlobalNamespace(): boolean;
|
|
37
|
-
protected proposeUnionMemberName(u: UnionType, unionName: Name, fieldType: Type, lookup: (n: Name) => string): string;
|
|
38
|
-
protected get commentLineStart(): string;
|
|
39
|
-
protected emitDescriptionBlock(lines: Sourcelike[]): void;
|
|
40
|
-
private get arrayType();
|
|
41
|
-
private elmType;
|
|
42
|
-
private elmProperty;
|
|
43
|
-
private decoderNameForNamedType;
|
|
44
|
-
private decoderNameForType;
|
|
45
|
-
private decoderNameForProperty;
|
|
46
|
-
private encoderNameForNamedType;
|
|
47
|
-
private encoderNameForType;
|
|
48
|
-
private encoderNameForProperty;
|
|
49
|
-
private emitTopLevelDefinition;
|
|
50
|
-
private emitClassDefinition;
|
|
51
|
-
private emitEnumDefinition;
|
|
52
|
-
private emitUnionDefinition;
|
|
53
|
-
private emitTopLevelFunctions;
|
|
54
|
-
private emitClassFunctions;
|
|
55
|
-
private emitEnumFunctions;
|
|
56
|
-
private emitUnionFunctions;
|
|
57
|
-
protected emitSourceStructure(): void;
|
|
58
|
-
}
|