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,37 +0,0 @@
|
|
|
1
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
2
|
-
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
3
|
-
import { Name, Namer } from "../Naming";
|
|
4
|
-
import { UnionType, Type, ClassType, EnumType } from "../Type";
|
|
5
|
-
import { Sourcelike } from "../Source";
|
|
6
|
-
import { Option } from "../RendererOptions";
|
|
7
|
-
import { RenderContext } from "../Renderer";
|
|
8
|
-
export declare class CrystalTargetLanguage extends TargetLanguage {
|
|
9
|
-
protected makeRenderer(renderContext: RenderContext): CrystalRenderer;
|
|
10
|
-
constructor();
|
|
11
|
-
protected get defaultIndentation(): string;
|
|
12
|
-
protected getOptions(): Option<any>[];
|
|
13
|
-
}
|
|
14
|
-
export declare class CrystalRenderer extends ConvenienceRenderer {
|
|
15
|
-
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext);
|
|
16
|
-
protected makeNamedTypeNamer(): Namer;
|
|
17
|
-
protected namerForObjectProperty(): Namer | null;
|
|
18
|
-
protected makeUnionMemberNamer(): Namer | null;
|
|
19
|
-
protected makeEnumCaseNamer(): Namer | null;
|
|
20
|
-
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
21
|
-
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
22
|
-
protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
|
|
23
|
-
protected forbiddenForEnumCases(_e: EnumType, _enumName: Name): ForbiddenWordsInfo;
|
|
24
|
-
protected get commentLineStart(): string;
|
|
25
|
-
private nullableCrystalType;
|
|
26
|
-
protected isImplicitCycleBreaker(t: Type): boolean;
|
|
27
|
-
private crystalType;
|
|
28
|
-
private breakCycle;
|
|
29
|
-
private emitRenameAttribute;
|
|
30
|
-
protected emitStructDefinition(c: ClassType, className: Name): void;
|
|
31
|
-
protected emitBlock(line: Sourcelike, f: () => void): void;
|
|
32
|
-
protected emitEnum(line: Sourcelike, f: () => void): void;
|
|
33
|
-
protected emitUnion(u: UnionType, unionName: Name): void;
|
|
34
|
-
protected emitTopLevelAlias(t: Type, name: Name): void;
|
|
35
|
-
protected emitLeadingComments(): void;
|
|
36
|
-
protected emitSourceStructure(): void;
|
|
37
|
-
}
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CrystalRenderer = exports.CrystalTargetLanguage = void 0;
|
|
4
|
-
const TargetLanguage_1 = require("../TargetLanguage");
|
|
5
|
-
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
6
|
-
const Strings_1 = require("../support/Strings");
|
|
7
|
-
const Naming_1 = require("../Naming");
|
|
8
|
-
const TypeUtils_1 = require("../TypeUtils");
|
|
9
|
-
const Source_1 = require("../Source");
|
|
10
|
-
const Annotation_1 = require("../Annotation");
|
|
11
|
-
class CrystalTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
12
|
-
makeRenderer(renderContext) {
|
|
13
|
-
return new CrystalRenderer(this, renderContext);
|
|
14
|
-
}
|
|
15
|
-
constructor() {
|
|
16
|
-
super("Crystal", ["crystal", "cr", "crystallang"], "cr");
|
|
17
|
-
}
|
|
18
|
-
get defaultIndentation() {
|
|
19
|
-
return " ";
|
|
20
|
-
}
|
|
21
|
-
getOptions() {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.CrystalTargetLanguage = CrystalTargetLanguage;
|
|
26
|
-
const keywords = [
|
|
27
|
-
"Any",
|
|
28
|
-
"Array",
|
|
29
|
-
"Atomic",
|
|
30
|
-
"Bool",
|
|
31
|
-
"Channel",
|
|
32
|
-
"Char",
|
|
33
|
-
"Class",
|
|
34
|
-
"Enum",
|
|
35
|
-
"Enumerable",
|
|
36
|
-
"Event",
|
|
37
|
-
"Extern",
|
|
38
|
-
"Exception",
|
|
39
|
-
"File",
|
|
40
|
-
"Float",
|
|
41
|
-
"Float32",
|
|
42
|
-
"Float64",
|
|
43
|
-
"GC",
|
|
44
|
-
"GZip",
|
|
45
|
-
"Hash",
|
|
46
|
-
"HTML",
|
|
47
|
-
"HTTP",
|
|
48
|
-
"Int",
|
|
49
|
-
"Int128",
|
|
50
|
-
"Int16",
|
|
51
|
-
"Int32",
|
|
52
|
-
"Int64",
|
|
53
|
-
"Int8",
|
|
54
|
-
"Iterable",
|
|
55
|
-
"Link",
|
|
56
|
-
"Logger",
|
|
57
|
-
"Math",
|
|
58
|
-
"Mutex",
|
|
59
|
-
"Nil",
|
|
60
|
-
"Number",
|
|
61
|
-
"JSON",
|
|
62
|
-
"IO",
|
|
63
|
-
"Object",
|
|
64
|
-
"Pointer",
|
|
65
|
-
"Proc",
|
|
66
|
-
"Process",
|
|
67
|
-
"Range",
|
|
68
|
-
"Random",
|
|
69
|
-
"Regex",
|
|
70
|
-
"Reference",
|
|
71
|
-
"Set",
|
|
72
|
-
"Signal",
|
|
73
|
-
"Slice",
|
|
74
|
-
"Spec",
|
|
75
|
-
"StaticArray",
|
|
76
|
-
"String",
|
|
77
|
-
"Struct",
|
|
78
|
-
"Symbol",
|
|
79
|
-
"System",
|
|
80
|
-
"TCPServer",
|
|
81
|
-
"TCPSocket",
|
|
82
|
-
"Socket",
|
|
83
|
-
"Tempfile",
|
|
84
|
-
"Termios",
|
|
85
|
-
"Time",
|
|
86
|
-
"Tuple",
|
|
87
|
-
"ThreadLocal",
|
|
88
|
-
"UDPSocket",
|
|
89
|
-
"UInt128",
|
|
90
|
-
"UInt16",
|
|
91
|
-
"UInt32",
|
|
92
|
-
"UInt64",
|
|
93
|
-
"UInt8",
|
|
94
|
-
"Union",
|
|
95
|
-
"UNIXServer",
|
|
96
|
-
"UNIXSocket",
|
|
97
|
-
"UUID",
|
|
98
|
-
"URI",
|
|
99
|
-
"VaList",
|
|
100
|
-
"Value",
|
|
101
|
-
"Void",
|
|
102
|
-
"WeakRef",
|
|
103
|
-
"XML",
|
|
104
|
-
"YAML",
|
|
105
|
-
"Zip",
|
|
106
|
-
"Zlib",
|
|
107
|
-
"abstract",
|
|
108
|
-
"alias",
|
|
109
|
-
"as",
|
|
110
|
-
"as?",
|
|
111
|
-
"asm",
|
|
112
|
-
"begin",
|
|
113
|
-
"break",
|
|
114
|
-
"case",
|
|
115
|
-
"class",
|
|
116
|
-
"def",
|
|
117
|
-
"do",
|
|
118
|
-
"else",
|
|
119
|
-
"elsif",
|
|
120
|
-
"end",
|
|
121
|
-
"ensure",
|
|
122
|
-
"enum",
|
|
123
|
-
"extend",
|
|
124
|
-
"false",
|
|
125
|
-
"for",
|
|
126
|
-
"fun",
|
|
127
|
-
"if",
|
|
128
|
-
"in",
|
|
129
|
-
"include",
|
|
130
|
-
"instance_sizeof",
|
|
131
|
-
"is_a?",
|
|
132
|
-
"lib",
|
|
133
|
-
"macro",
|
|
134
|
-
"module",
|
|
135
|
-
"next",
|
|
136
|
-
"nil",
|
|
137
|
-
"nil?",
|
|
138
|
-
"of",
|
|
139
|
-
"out",
|
|
140
|
-
"pointerof",
|
|
141
|
-
"private",
|
|
142
|
-
"protected",
|
|
143
|
-
"require",
|
|
144
|
-
"rescue",
|
|
145
|
-
"return",
|
|
146
|
-
"select",
|
|
147
|
-
"self",
|
|
148
|
-
"sizeof",
|
|
149
|
-
"struct",
|
|
150
|
-
"super",
|
|
151
|
-
"then",
|
|
152
|
-
"true",
|
|
153
|
-
"type",
|
|
154
|
-
"typeof",
|
|
155
|
-
"uninitialized",
|
|
156
|
-
"union",
|
|
157
|
-
"unless",
|
|
158
|
-
"until",
|
|
159
|
-
"when",
|
|
160
|
-
"while",
|
|
161
|
-
"with",
|
|
162
|
-
"yield"
|
|
163
|
-
];
|
|
164
|
-
function isAsciiLetterOrUnderscoreOrDigit(codePoint) {
|
|
165
|
-
if (!(0, Strings_1.isAscii)(codePoint)) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
return (0, Strings_1.isLetterOrUnderscoreOrDigit)(codePoint);
|
|
169
|
-
}
|
|
170
|
-
function isAsciiLetterOrUnderscore(codePoint) {
|
|
171
|
-
if (!(0, Strings_1.isAscii)(codePoint)) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
return (0, Strings_1.isLetterOrUnderscore)(codePoint);
|
|
175
|
-
}
|
|
176
|
-
const legalizeName = (0, Strings_1.legalizeCharacters)(isAsciiLetterOrUnderscoreOrDigit);
|
|
177
|
-
function crystalStyle(original, isSnakeCase) {
|
|
178
|
-
const words = (0, Strings_1.splitIntoWords)(original);
|
|
179
|
-
const wordStyle = isSnakeCase ? Strings_1.allLowerWordStyle : Strings_1.firstUpperWordStyle;
|
|
180
|
-
const combined = (0, Strings_1.combineWords)(words, legalizeName, wordStyle, wordStyle, wordStyle, wordStyle, isSnakeCase ? "_" : "", isAsciiLetterOrUnderscore);
|
|
181
|
-
return combined === "_" ? "_underscore" : combined;
|
|
182
|
-
}
|
|
183
|
-
const snakeNamingFunction = (0, Naming_1.funPrefixNamer)("default", (original) => crystalStyle(original, true));
|
|
184
|
-
const camelNamingFunction = (0, Naming_1.funPrefixNamer)("camel", (original) => crystalStyle(original, false));
|
|
185
|
-
function standardUnicodeCrystalEscape(codePoint) {
|
|
186
|
-
if (codePoint <= 0xffff) {
|
|
187
|
-
return "\\u{" + (0, Strings_1.intToHex)(codePoint, 4) + "}";
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
return "\\u{" + (0, Strings_1.intToHex)(codePoint, 6) + "}";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const crystalStringEscape = (0, Strings_1.utf32ConcatMap)((0, Strings_1.escapeNonPrintableMapper)(Strings_1.isPrintable, standardUnicodeCrystalEscape));
|
|
194
|
-
class CrystalRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
195
|
-
constructor(targetLanguage, renderContext) {
|
|
196
|
-
super(targetLanguage, renderContext);
|
|
197
|
-
}
|
|
198
|
-
makeNamedTypeNamer() {
|
|
199
|
-
return camelNamingFunction;
|
|
200
|
-
}
|
|
201
|
-
namerForObjectProperty() {
|
|
202
|
-
return snakeNamingFunction;
|
|
203
|
-
}
|
|
204
|
-
makeUnionMemberNamer() {
|
|
205
|
-
return camelNamingFunction;
|
|
206
|
-
}
|
|
207
|
-
makeEnumCaseNamer() {
|
|
208
|
-
return camelNamingFunction;
|
|
209
|
-
}
|
|
210
|
-
forbiddenNamesForGlobalNamespace() {
|
|
211
|
-
return keywords;
|
|
212
|
-
}
|
|
213
|
-
forbiddenForObjectProperties(_c, _className) {
|
|
214
|
-
return { names: [], includeGlobalForbidden: true };
|
|
215
|
-
}
|
|
216
|
-
forbiddenForUnionMembers(_u, _unionName) {
|
|
217
|
-
return { names: [], includeGlobalForbidden: true };
|
|
218
|
-
}
|
|
219
|
-
forbiddenForEnumCases(_e, _enumName) {
|
|
220
|
-
return { names: [], includeGlobalForbidden: true };
|
|
221
|
-
}
|
|
222
|
-
get commentLineStart() {
|
|
223
|
-
return "# ";
|
|
224
|
-
}
|
|
225
|
-
nullableCrystalType(t, withIssues) {
|
|
226
|
-
return [this.crystalType(t, withIssues), "?"];
|
|
227
|
-
}
|
|
228
|
-
isImplicitCycleBreaker(t) {
|
|
229
|
-
const kind = t.kind;
|
|
230
|
-
return kind === "array" || kind === "map";
|
|
231
|
-
}
|
|
232
|
-
crystalType(t, withIssues = false) {
|
|
233
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.anyTypeIssueAnnotation, "JSON::Any?"), _nullType => (0, Source_1.maybeAnnotated)(withIssues, Annotation_1.nullTypeIssueAnnotation, "Nil"), _boolType => "Bool", _integerType => "Int32", _doubleType => "Float64", _stringType => "String", arrayType => ["Array(", this.crystalType(arrayType.items, withIssues), ")"], classType => this.nameForNamedType(classType), mapType => ["Hash(String, ", this.crystalType(mapType.values, withIssues), ")"], _enumType => "String", unionType => {
|
|
234
|
-
const nullable = (0, TypeUtils_1.nullableFromUnion)(unionType);
|
|
235
|
-
if (nullable !== null)
|
|
236
|
-
return this.nullableCrystalType(nullable, withIssues);
|
|
237
|
-
const [hasNull] = (0, TypeUtils_1.removeNullFromUnion)(unionType);
|
|
238
|
-
const name = this.nameForNamedType(unionType);
|
|
239
|
-
return hasNull !== null ? [name, "?"] : name;
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
breakCycle(t, withIssues) {
|
|
243
|
-
return this.crystalType(t, withIssues);
|
|
244
|
-
}
|
|
245
|
-
emitRenameAttribute(propName, jsonName) {
|
|
246
|
-
const escapedName = crystalStringEscape(jsonName);
|
|
247
|
-
const namesDiffer = this.sourcelikeToString(propName) !== escapedName;
|
|
248
|
-
if (namesDiffer) {
|
|
249
|
-
this.emitLine('@[JSON::Field(key: "', escapedName, '")]');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
emitStructDefinition(c, className) {
|
|
253
|
-
this.emitDescription(this.descriptionForType(c));
|
|
254
|
-
const structBody = () => this.forEachClassProperty(c, "none", (name, jsonName, prop) => {
|
|
255
|
-
this.ensureBlankLine();
|
|
256
|
-
this.emitDescription(this.descriptionForClassProperty(c, jsonName));
|
|
257
|
-
this.emitRenameAttribute(name, jsonName);
|
|
258
|
-
this.emitLine("property ", name, " : ", this.crystalType(prop.type, true));
|
|
259
|
-
});
|
|
260
|
-
this.emitBlock(["class ", className], structBody);
|
|
261
|
-
}
|
|
262
|
-
emitBlock(line, f) {
|
|
263
|
-
this.emitLine(line);
|
|
264
|
-
this.indent(() => {
|
|
265
|
-
this.emitLine("include JSON::Serializable");
|
|
266
|
-
});
|
|
267
|
-
this.ensureBlankLine();
|
|
268
|
-
this.indent(f);
|
|
269
|
-
this.emitLine("end");
|
|
270
|
-
}
|
|
271
|
-
emitEnum(line, f) {
|
|
272
|
-
this.emitLine(line);
|
|
273
|
-
this.indent(f);
|
|
274
|
-
this.emitLine("end");
|
|
275
|
-
}
|
|
276
|
-
emitUnion(u, unionName) {
|
|
277
|
-
const isMaybeWithSingleType = (0, TypeUtils_1.nullableFromUnion)(u);
|
|
278
|
-
if (isMaybeWithSingleType !== null) {
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
this.emitDescription(this.descriptionForType(u));
|
|
282
|
-
const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
|
|
283
|
-
let types = [];
|
|
284
|
-
this.forEachUnionMember(u, nonNulls, "none", null, (_name, t) => {
|
|
285
|
-
const crystalType = this.breakCycle(t, true);
|
|
286
|
-
types.push([crystalType]);
|
|
287
|
-
});
|
|
288
|
-
this.emitLine([
|
|
289
|
-
"alias ",
|
|
290
|
-
unionName,
|
|
291
|
-
" = ",
|
|
292
|
-
types.map(r => r.map(sl => this.sourcelikeToString(sl))).join(" | ")
|
|
293
|
-
]);
|
|
294
|
-
}
|
|
295
|
-
emitTopLevelAlias(t, name) {
|
|
296
|
-
this.emitLine("alias ", name, " = ", this.crystalType(t));
|
|
297
|
-
}
|
|
298
|
-
emitLeadingComments() {
|
|
299
|
-
if (this.leadingComments !== undefined) {
|
|
300
|
-
this.emitCommentLines(this.leadingComments);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
this.emitMultiline(`# Example code that deserializes and serializes the model:
|
|
304
|
-
#
|
|
305
|
-
# require "json"
|
|
306
|
-
#
|
|
307
|
-
# class Location
|
|
308
|
-
# include JSON::Serializable
|
|
309
|
-
#
|
|
310
|
-
# @[JSON::Field(key: "lat")]
|
|
311
|
-
# property latitude : Float64
|
|
312
|
-
#
|
|
313
|
-
# @[JSON::Field(key: "lng")]
|
|
314
|
-
# property longitude : Float64
|
|
315
|
-
# end
|
|
316
|
-
#
|
|
317
|
-
# class House
|
|
318
|
-
# include JSON::Serializable
|
|
319
|
-
# property address : String
|
|
320
|
-
# property location : Location?
|
|
321
|
-
# end
|
|
322
|
-
#
|
|
323
|
-
# house = House.from_json(%({"address": "Crystal Road 1234", "location": {"lat": 12.3, "lng": 34.5}}))
|
|
324
|
-
# house.address # => "Crystal Road 1234"
|
|
325
|
-
# house.location # => #<Location:0x10cd93d80 @latitude=12.3, @longitude=34.5>
|
|
326
|
-
`);
|
|
327
|
-
}
|
|
328
|
-
emitSourceStructure() {
|
|
329
|
-
this.emitLeadingComments();
|
|
330
|
-
this.ensureBlankLine();
|
|
331
|
-
this.emitLine('require "json"');
|
|
332
|
-
this.forEachTopLevel("leading", (t, name) => this.emitTopLevelAlias(t, name), t => this.namedTypeToNameForTopLevel(t) === undefined);
|
|
333
|
-
this.forEachObject("leading-and-interposing", (c, name) => this.emitStructDefinition(c, name));
|
|
334
|
-
this.forEachUnion("leading-and-interposing", (u, name) => this.emitUnion(u, name));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
exports.CrystalRenderer = CrystalRenderer;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { ClassProperty, ClassType, EnumType, Type, UnionType } from "../Type";
|
|
2
|
-
import { Sourcelike } from "../Source";
|
|
3
|
-
import { StringTypeMapping } from "../TypeBuilder";
|
|
4
|
-
import { DependencyName, Name, Namer } from "../Naming";
|
|
5
|
-
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
6
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
7
|
-
import { BooleanOption, Option, OptionValues, StringOption } from "../RendererOptions";
|
|
8
|
-
import { RenderContext } from "../Renderer";
|
|
9
|
-
export declare const dartOptions: {
|
|
10
|
-
nullSafety: BooleanOption;
|
|
11
|
-
justTypes: BooleanOption;
|
|
12
|
-
codersInClass: BooleanOption;
|
|
13
|
-
methodNamesWithMap: BooleanOption;
|
|
14
|
-
requiredProperties: BooleanOption;
|
|
15
|
-
finalProperties: BooleanOption;
|
|
16
|
-
generateCopyWith: BooleanOption;
|
|
17
|
-
useFreezed: BooleanOption;
|
|
18
|
-
useHive: BooleanOption;
|
|
19
|
-
partName: StringOption;
|
|
20
|
-
};
|
|
21
|
-
export declare class DartTargetLanguage extends TargetLanguage {
|
|
22
|
-
constructor();
|
|
23
|
-
protected getOptions(): Option<any>[];
|
|
24
|
-
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
25
|
-
get stringTypeMapping(): StringTypeMapping;
|
|
26
|
-
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
27
|
-
[name: string]: any;
|
|
28
|
-
}): DartRenderer;
|
|
29
|
-
}
|
|
30
|
-
export declare class DartRenderer extends ConvenienceRenderer {
|
|
31
|
-
private readonly _options;
|
|
32
|
-
private readonly _gettersAndSettersForPropertyName;
|
|
33
|
-
private _needEnumValues;
|
|
34
|
-
private classCounter;
|
|
35
|
-
private classPropertyCounter;
|
|
36
|
-
private readonly _topLevelDependents;
|
|
37
|
-
private readonly _enumValues;
|
|
38
|
-
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof dartOptions>);
|
|
39
|
-
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
40
|
-
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
41
|
-
protected makeNamedTypeNamer(): Namer;
|
|
42
|
-
protected namerForObjectProperty(): Namer;
|
|
43
|
-
protected makeUnionMemberNamer(): Namer;
|
|
44
|
-
protected makeEnumCaseNamer(): Namer;
|
|
45
|
-
protected unionNeedsName(u: UnionType): boolean;
|
|
46
|
-
protected namedTypeToNameForTopLevel(type: Type): Type | undefined;
|
|
47
|
-
protected get toJson(): string;
|
|
48
|
-
protected get fromJson(): string;
|
|
49
|
-
protected makeTopLevelDependencyNames(_t: Type, name: Name): DependencyName[];
|
|
50
|
-
protected makeNamesForPropertyGetterAndSetter(_c: ClassType, _className: Name, _p: ClassProperty, _jsonName: string, name: Name): [Name, Name];
|
|
51
|
-
protected makePropertyDependencyNames(c: ClassType, className: Name, p: ClassProperty, jsonName: string, name: Name): Name[];
|
|
52
|
-
protected makeNamedTypeDependencyNames(t: Type, name: Name): DependencyName[];
|
|
53
|
-
protected emitFileHeader(): void;
|
|
54
|
-
protected emitDescriptionBlock(lines: Sourcelike[]): void;
|
|
55
|
-
protected emitBlock(line: Sourcelike, f: () => void): void;
|
|
56
|
-
protected dartType(t: Type, withIssues?: boolean): Sourcelike;
|
|
57
|
-
protected mapList(itemType: Sourcelike, list: Sourcelike, mapper: Sourcelike): Sourcelike;
|
|
58
|
-
protected mapMap(valueType: Sourcelike, map: Sourcelike, valueMapper: Sourcelike): Sourcelike;
|
|
59
|
-
protected fromDynamicExpression(t: Type, ...dynamic: Sourcelike[]): Sourcelike;
|
|
60
|
-
protected toDynamicExpression(t: Type, ...dynamic: Sourcelike[]): Sourcelike;
|
|
61
|
-
protected emitClassDefinition(c: ClassType, className: Name): void;
|
|
62
|
-
protected emitFreezedClassDefinition(c: ClassType, className: Name): void;
|
|
63
|
-
protected emitEnumDefinition(e: EnumType, enumName: Name): void;
|
|
64
|
-
protected emitEnumValues(): void;
|
|
65
|
-
protected emitSourceStructure(): void;
|
|
66
|
-
}
|