quicktype 18.0.5 → 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 { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
2
|
-
import { Name, Namer } from "../Naming";
|
|
3
|
-
import { Option } from "../RendererOptions";
|
|
4
|
-
import { RenderContext } from "../Renderer";
|
|
5
|
-
import { MultiWord } from "../Source";
|
|
6
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
7
|
-
import { Type, ClassType, EnumType, UnionType } from "../Type";
|
|
8
|
-
export declare const pikeOptions: {};
|
|
9
|
-
export declare class PikeTargetLanguage extends TargetLanguage {
|
|
10
|
-
constructor();
|
|
11
|
-
protected getOptions(): Option<any>[];
|
|
12
|
-
protected makeRenderer(renderContext: RenderContext): PikeRenderer;
|
|
13
|
-
}
|
|
14
|
-
export declare class PikeRenderer extends ConvenienceRenderer {
|
|
15
|
-
protected emitSourceStructure(): void;
|
|
16
|
-
protected get enumCasesInGlobalNamespace(): boolean;
|
|
17
|
-
protected makeEnumCaseNamer(): Namer;
|
|
18
|
-
protected makeNamedTypeNamer(): Namer;
|
|
19
|
-
protected makeUnionMemberNamer(): Namer;
|
|
20
|
-
protected namerForObjectProperty(): Namer;
|
|
21
|
-
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
22
|
-
protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
|
|
23
|
-
protected forbiddenForEnumCases(_e: EnumType, _enumName: Name): ForbiddenWordsInfo;
|
|
24
|
-
protected forbiddenForUnionMembers(_u: UnionType, _unionName: Name): ForbiddenWordsInfo;
|
|
25
|
-
protected sourceFor(t: Type): MultiWord;
|
|
26
|
-
protected emitClassDefinition(c: ClassType, className: Name): void;
|
|
27
|
-
protected emitEnum(e: EnumType, enumName: Name): void;
|
|
28
|
-
protected emitUnion(u: UnionType, unionName: Name): void;
|
|
29
|
-
private emitBlock;
|
|
30
|
-
private emitMappingBlock;
|
|
31
|
-
private emitClassMembers;
|
|
32
|
-
private emitInformationComment;
|
|
33
|
-
private emitTopLevelTypedef;
|
|
34
|
-
private emitTopLevelConverter;
|
|
35
|
-
private emitEncodingFunction;
|
|
36
|
-
private emitDecodingFunction;
|
|
37
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PikeRenderer = exports.PikeTargetLanguage = exports.pikeOptions = void 0;
|
|
4
|
-
const ConvenienceRenderer_1 = require("../ConvenienceRenderer");
|
|
5
|
-
const Naming_1 = require("../Naming");
|
|
6
|
-
const Source_1 = require("../Source");
|
|
7
|
-
const TargetLanguage_1 = require("../TargetLanguage");
|
|
8
|
-
const Type_1 = require("../Type");
|
|
9
|
-
const TypeUtils_1 = require("../TypeUtils");
|
|
10
|
-
const Strings_1 = require("../support/Strings");
|
|
11
|
-
exports.pikeOptions = {};
|
|
12
|
-
const keywords = [
|
|
13
|
-
"auto",
|
|
14
|
-
"nomask",
|
|
15
|
-
"final",
|
|
16
|
-
"static",
|
|
17
|
-
"extern",
|
|
18
|
-
"private",
|
|
19
|
-
"local",
|
|
20
|
-
"public",
|
|
21
|
-
"protected",
|
|
22
|
-
"inline",
|
|
23
|
-
"optional",
|
|
24
|
-
"variant",
|
|
25
|
-
"void",
|
|
26
|
-
"mixed",
|
|
27
|
-
"array",
|
|
28
|
-
"__attribute__",
|
|
29
|
-
"__deprecated__",
|
|
30
|
-
"mapping",
|
|
31
|
-
"multiset",
|
|
32
|
-
"object",
|
|
33
|
-
"function",
|
|
34
|
-
"__func__",
|
|
35
|
-
"program",
|
|
36
|
-
"string",
|
|
37
|
-
"float",
|
|
38
|
-
"int",
|
|
39
|
-
"enum",
|
|
40
|
-
"typedef",
|
|
41
|
-
"if",
|
|
42
|
-
"do",
|
|
43
|
-
"for",
|
|
44
|
-
"while",
|
|
45
|
-
"else",
|
|
46
|
-
"foreach",
|
|
47
|
-
"catch",
|
|
48
|
-
"gauge",
|
|
49
|
-
"class",
|
|
50
|
-
"break",
|
|
51
|
-
"case",
|
|
52
|
-
"const",
|
|
53
|
-
"constant",
|
|
54
|
-
"continue",
|
|
55
|
-
"default",
|
|
56
|
-
"import",
|
|
57
|
-
"inherit",
|
|
58
|
-
"lambda",
|
|
59
|
-
"predef",
|
|
60
|
-
"return",
|
|
61
|
-
"sscanf",
|
|
62
|
-
"switch",
|
|
63
|
-
"typeof",
|
|
64
|
-
"global"
|
|
65
|
-
];
|
|
66
|
-
const legalizeName = (0, Strings_1.legalizeCharacters)(Strings_1.isLetterOrUnderscoreOrDigit);
|
|
67
|
-
const enumNamingFunction = (0, Naming_1.funPrefixNamer)("enumNamer", (0, Strings_1.makeNameStyle)("upper-underscore", legalizeName));
|
|
68
|
-
const namingFunction = (0, Naming_1.funPrefixNamer)("genericNamer", (0, Strings_1.makeNameStyle)("underscore", legalizeName));
|
|
69
|
-
const namedTypeNamingFunction = (0, Naming_1.funPrefixNamer)("typeNamer", (0, Strings_1.makeNameStyle)("pascal", legalizeName));
|
|
70
|
-
class PikeTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
71
|
-
constructor() {
|
|
72
|
-
super("Pike", ["pike", "pikelang"], "pmod");
|
|
73
|
-
}
|
|
74
|
-
getOptions() {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
makeRenderer(renderContext) {
|
|
78
|
-
return new PikeRenderer(this, renderContext);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.PikeTargetLanguage = PikeTargetLanguage;
|
|
82
|
-
class PikeRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
83
|
-
emitSourceStructure() {
|
|
84
|
-
this.emitInformationComment();
|
|
85
|
-
this.ensureBlankLine();
|
|
86
|
-
this.forEachTopLevel("leading", (t, name) => {
|
|
87
|
-
this.emitTopLevelTypedef(t, name);
|
|
88
|
-
this.ensureBlankLine();
|
|
89
|
-
this.emitTopLevelConverter(t, name);
|
|
90
|
-
this.ensureBlankLine();
|
|
91
|
-
}, t => this.namedTypeToNameForTopLevel(t) === undefined);
|
|
92
|
-
this.ensureBlankLine();
|
|
93
|
-
this.forEachNamedType("leading-and-interposing", (c, className) => this.emitClassDefinition(c, className), (e, n) => this.emitEnum(e, n), (u, n) => this.emitUnion(u, n));
|
|
94
|
-
}
|
|
95
|
-
get enumCasesInGlobalNamespace() {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
makeEnumCaseNamer() {
|
|
99
|
-
return enumNamingFunction;
|
|
100
|
-
}
|
|
101
|
-
makeNamedTypeNamer() {
|
|
102
|
-
return namedTypeNamingFunction;
|
|
103
|
-
}
|
|
104
|
-
makeUnionMemberNamer() {
|
|
105
|
-
return namingFunction;
|
|
106
|
-
}
|
|
107
|
-
namerForObjectProperty() {
|
|
108
|
-
return namingFunction;
|
|
109
|
-
}
|
|
110
|
-
forbiddenNamesForGlobalNamespace() {
|
|
111
|
-
return [...keywords];
|
|
112
|
-
}
|
|
113
|
-
forbiddenForObjectProperties(_c, _className) {
|
|
114
|
-
return { names: [], includeGlobalForbidden: true };
|
|
115
|
-
}
|
|
116
|
-
forbiddenForEnumCases(_e, _enumName) {
|
|
117
|
-
return { names: [], includeGlobalForbidden: true };
|
|
118
|
-
}
|
|
119
|
-
forbiddenForUnionMembers(_u, _unionName) {
|
|
120
|
-
return { names: [], includeGlobalForbidden: true };
|
|
121
|
-
}
|
|
122
|
-
sourceFor(t) {
|
|
123
|
-
if (["class", "object", "enum"].indexOf(t.kind) >= 0) {
|
|
124
|
-
return (0, Source_1.singleWord)(this.nameForNamedType(t));
|
|
125
|
-
}
|
|
126
|
-
return (0, TypeUtils_1.matchType)(t, _anyType => (0, Source_1.singleWord)("mixed"), _nullType => (0, Source_1.singleWord)("mixed"), _boolType => (0, Source_1.singleWord)("bool"), _integerType => (0, Source_1.singleWord)("int"), _doubleType => (0, Source_1.singleWord)("float"), _stringType => (0, Source_1.singleWord)("string"), arrayType => (0, Source_1.singleWord)(["array(", this.sourceFor(arrayType.items).source, ")"]), _classType => (0, Source_1.singleWord)(this.nameForNamedType(_classType)), mapType => {
|
|
127
|
-
let valueSource;
|
|
128
|
-
const v = mapType.values;
|
|
129
|
-
valueSource = this.sourceFor(v).source;
|
|
130
|
-
return (0, Source_1.singleWord)(["mapping(string:", valueSource, ")"]);
|
|
131
|
-
}, _enumType => (0, Source_1.singleWord)("enum"), unionType => {
|
|
132
|
-
if ((0, TypeUtils_1.nullableFromUnion)(unionType) !== null) {
|
|
133
|
-
const children = Array.from(unionType.getChildren()).map(c => (0, Source_1.parenIfNeeded)(this.sourceFor(c)));
|
|
134
|
-
return (0, Source_1.multiWord)("|", ...children);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return (0, Source_1.singleWord)(this.nameForNamedType(unionType));
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
emitClassDefinition(c, className) {
|
|
142
|
-
this.emitDescription(this.descriptionForType(c));
|
|
143
|
-
this.emitBlock(["class ", className], () => {
|
|
144
|
-
this.emitClassMembers(c);
|
|
145
|
-
this.ensureBlankLine();
|
|
146
|
-
this.emitEncodingFunction(c);
|
|
147
|
-
});
|
|
148
|
-
this.ensureBlankLine();
|
|
149
|
-
this.emitDecodingFunction(className, c);
|
|
150
|
-
}
|
|
151
|
-
emitEnum(e, enumName) {
|
|
152
|
-
this.emitBlock([e.kind, " ", enumName], () => {
|
|
153
|
-
let table = [];
|
|
154
|
-
this.forEachEnumCase(e, "none", (name, jsonName) => {
|
|
155
|
-
table.push([
|
|
156
|
-
[name, ' = "', (0, Strings_1.stringEscape)(jsonName), '", '],
|
|
157
|
-
['// json: "', jsonName, '"']
|
|
158
|
-
]);
|
|
159
|
-
});
|
|
160
|
-
this.emitTable(table);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
emitUnion(u, unionName) {
|
|
164
|
-
const isMaybeWithSingleType = (0, TypeUtils_1.nullableFromUnion)(u);
|
|
165
|
-
if (isMaybeWithSingleType !== null) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.emitDescription(this.descriptionForType(u));
|
|
169
|
-
const [, nonNulls] = (0, TypeUtils_1.removeNullFromUnion)(u);
|
|
170
|
-
let types = [];
|
|
171
|
-
this.forEachUnionMember(u, nonNulls, "none", null, (_name, t) => {
|
|
172
|
-
const pikeType = this.sourceFor(t).source;
|
|
173
|
-
types.push([pikeType]);
|
|
174
|
-
});
|
|
175
|
-
this.emitLine([
|
|
176
|
-
"typedef ",
|
|
177
|
-
types.map(r => r.map(sl => this.sourcelikeToString(sl))).join("|"),
|
|
178
|
-
" ",
|
|
179
|
-
unionName,
|
|
180
|
-
";"
|
|
181
|
-
]);
|
|
182
|
-
this.ensureBlankLine();
|
|
183
|
-
this.emitBlock([unionName, " ", unionName, "_from_JSON(mixed json)"], () => {
|
|
184
|
-
this.emitLine(["return json;"]);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
emitBlock(line, f, opening = " {", closing = "}") {
|
|
188
|
-
this.emitLine(line, opening);
|
|
189
|
-
this.indent(f);
|
|
190
|
-
this.emitLine(closing);
|
|
191
|
-
}
|
|
192
|
-
emitMappingBlock(line, f) {
|
|
193
|
-
this.emitBlock(line, f, "([", "]);");
|
|
194
|
-
}
|
|
195
|
-
emitClassMembers(c) {
|
|
196
|
-
let table = [];
|
|
197
|
-
this.forEachClassProperty(c, "none", (name, jsonName, p) => {
|
|
198
|
-
const pikeType = this.sourceFor(p.type).source;
|
|
199
|
-
table.push([
|
|
200
|
-
[pikeType, " "],
|
|
201
|
-
[name, "; "],
|
|
202
|
-
['// json: "', jsonName, '"']
|
|
203
|
-
]);
|
|
204
|
-
});
|
|
205
|
-
this.emitTable(table);
|
|
206
|
-
}
|
|
207
|
-
emitInformationComment() {
|
|
208
|
-
this.emitCommentLines([
|
|
209
|
-
"This source has been automatically generated by quicktype.",
|
|
210
|
-
"( https://github.com/quicktype/quicktype )",
|
|
211
|
-
"",
|
|
212
|
-
"To use this code, simply import it into your project as a Pike module.",
|
|
213
|
-
"To JSON-encode your object, you can pass it to `Standards.JSON.encode`",
|
|
214
|
-
"or call `encode_json` on it.",
|
|
215
|
-
"",
|
|
216
|
-
"To decode a JSON string, first pass it to `Standards.JSON.decode`,",
|
|
217
|
-
"and then pass the result to `<YourClass>_from_JSON`.",
|
|
218
|
-
"It will return an instance of <YourClass>.",
|
|
219
|
-
"Bear in mind that these functions have unexpected behavior,",
|
|
220
|
-
"and will likely throw an error, if the JSON string does not",
|
|
221
|
-
"match the expected interface, even if the JSON itself is valid."
|
|
222
|
-
], "// ");
|
|
223
|
-
}
|
|
224
|
-
emitTopLevelTypedef(t, name) {
|
|
225
|
-
this.emitLine("typedef ", this.sourceFor(t).source, " ", name, ";");
|
|
226
|
-
}
|
|
227
|
-
emitTopLevelConverter(t, name) {
|
|
228
|
-
this.emitBlock([name, " ", name, "_from_JSON(mixed json)"], () => {
|
|
229
|
-
if (t instanceof Type_1.PrimitiveType) {
|
|
230
|
-
this.emitLine(["return json;"]);
|
|
231
|
-
}
|
|
232
|
-
else if (t instanceof Type_1.ArrayType) {
|
|
233
|
-
if (t.items instanceof Type_1.PrimitiveType)
|
|
234
|
-
this.emitLine(["return json;"]);
|
|
235
|
-
else
|
|
236
|
-
this.emitLine(["return map(json, ", this.sourceFor(t.items).source, "_from_JSON);"]);
|
|
237
|
-
}
|
|
238
|
-
else if (t instanceof Type_1.MapType) {
|
|
239
|
-
const type = this.sourceFor(t.values).source;
|
|
240
|
-
this.emitLine(["mapping(string:", type, ") retval = ([]);"]);
|
|
241
|
-
let assignmentRval;
|
|
242
|
-
if (t.values instanceof Type_1.PrimitiveType)
|
|
243
|
-
assignmentRval = ["(", type, ") v"];
|
|
244
|
-
else
|
|
245
|
-
assignmentRval = [type, "_from_JSON(v)"];
|
|
246
|
-
this.emitBlock(["foreach (json; string k; mixed v)"], () => {
|
|
247
|
-
this.emitLine(["retval[k] = ", assignmentRval, ";"]);
|
|
248
|
-
});
|
|
249
|
-
this.emitLine(["return retval;"]);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
emitEncodingFunction(c) {
|
|
254
|
-
this.emitBlock(["string encode_json()"], () => {
|
|
255
|
-
this.emitMappingBlock(["mapping(string:mixed) json = "], () => {
|
|
256
|
-
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
257
|
-
this.emitLine(['"', (0, Strings_1.stringEscape)(jsonName), '" : ', name, ","]);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
this.ensureBlankLine();
|
|
261
|
-
this.emitLine(["return Standards.JSON.encode(json);"]);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
emitDecodingFunction(className, c) {
|
|
265
|
-
this.emitBlock([className, " ", className, "_from_JSON(mixed json)"], () => {
|
|
266
|
-
this.emitLine([className, " retval = ", className, "();"]);
|
|
267
|
-
this.ensureBlankLine();
|
|
268
|
-
this.forEachClassProperty(c, "none", (name, jsonName) => {
|
|
269
|
-
this.emitLine(["retval.", name, ' = json["', (0, Strings_1.stringEscape)(jsonName), '"];']);
|
|
270
|
-
});
|
|
271
|
-
this.ensureBlankLine();
|
|
272
|
-
this.emitLine(["return retval;"]);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
exports.PikeRenderer = PikeRenderer;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { TargetLanguage } from "../TargetLanguage";
|
|
2
|
-
import { StringTypeMapping } from "../TypeBuilder";
|
|
3
|
-
import { Type, EnumType, ClassType, ClassProperty } from "../Type";
|
|
4
|
-
import { RenderContext } from "../Renderer";
|
|
5
|
-
import { Option, OptionValues, EnumOption, BooleanOption } from "../RendererOptions";
|
|
6
|
-
import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
|
|
7
|
-
import { Namer, Name, DependencyName } from "../Naming";
|
|
8
|
-
import { Sourcelike, MultiWord } from "../Source";
|
|
9
|
-
import { Transformer } from "../Transformers";
|
|
10
|
-
export type PythonFeatures = {
|
|
11
|
-
typeHints: boolean;
|
|
12
|
-
dataClasses: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare const pythonOptions: {
|
|
15
|
-
features: EnumOption<PythonFeatures>;
|
|
16
|
-
justTypes: BooleanOption;
|
|
17
|
-
nicePropertyNames: BooleanOption;
|
|
18
|
-
};
|
|
19
|
-
export declare class PythonTargetLanguage extends TargetLanguage {
|
|
20
|
-
protected getOptions(): Option<any>[];
|
|
21
|
-
get stringTypeMapping(): StringTypeMapping;
|
|
22
|
-
get supportsUnionsWithBothNumberTypes(): boolean;
|
|
23
|
-
get supportsOptionalClassProperties(): boolean;
|
|
24
|
-
needsTransformerForType(t: Type): boolean;
|
|
25
|
-
protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
|
|
26
|
-
[name: string]: any;
|
|
27
|
-
}): PythonRenderer;
|
|
28
|
-
}
|
|
29
|
-
export declare class PythonRenderer extends ConvenienceRenderer {
|
|
30
|
-
protected readonly pyOptions: OptionValues<typeof pythonOptions>;
|
|
31
|
-
private readonly imports;
|
|
32
|
-
private readonly declaredTypes;
|
|
33
|
-
constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, pyOptions: OptionValues<typeof pythonOptions>);
|
|
34
|
-
protected forbiddenNamesForGlobalNamespace(): string[];
|
|
35
|
-
protected forbiddenForObjectProperties(_: ClassType, _classNamed: Name): ForbiddenWordsInfo;
|
|
36
|
-
protected makeNamedTypeNamer(): Namer;
|
|
37
|
-
protected namerForObjectProperty(): Namer;
|
|
38
|
-
protected makeUnionMemberNamer(): null;
|
|
39
|
-
protected makeEnumCaseNamer(): Namer;
|
|
40
|
-
protected get commentLineStart(): string;
|
|
41
|
-
protected emitDescriptionBlock(lines: Sourcelike[]): void;
|
|
42
|
-
protected get needsTypeDeclarationBeforeUse(): boolean;
|
|
43
|
-
protected canBeForwardDeclared(t: Type): boolean;
|
|
44
|
-
protected emitBlock(line: Sourcelike, f: () => void): void;
|
|
45
|
-
protected string(s: string): Sourcelike;
|
|
46
|
-
protected withImport(module: string, name: string): Sourcelike;
|
|
47
|
-
protected withTyping(name: string): Sourcelike;
|
|
48
|
-
protected namedType(t: Type): Sourcelike;
|
|
49
|
-
protected pythonType(t: Type): Sourcelike;
|
|
50
|
-
protected declarationLine(t: Type): Sourcelike;
|
|
51
|
-
protected declareType<T extends Type>(t: T, emitter: () => void): void;
|
|
52
|
-
protected emitClassMembers(t: ClassType): void;
|
|
53
|
-
protected typeHint(...sl: Sourcelike[]): Sourcelike;
|
|
54
|
-
protected typingDecl(name: Sourcelike, type: string): Sourcelike;
|
|
55
|
-
protected typingReturn(type: string): Sourcelike;
|
|
56
|
-
protected sortClassProperties(properties: ReadonlyMap<string, ClassProperty>, propertyNames: ReadonlyMap<string, Name>): ReadonlyMap<string, ClassProperty>;
|
|
57
|
-
protected emitClass(t: ClassType): void;
|
|
58
|
-
protected emitEnum(t: EnumType): void;
|
|
59
|
-
protected emitImports(): void;
|
|
60
|
-
protected emitSupportCode(): void;
|
|
61
|
-
protected emitClosingCode(): void;
|
|
62
|
-
protected emitSourceStructure(_givenOutputFilename: string): void;
|
|
63
|
-
}
|
|
64
|
-
export type ConverterFunction = "none" | "bool" | "int" | "from-float" | "to-float" | "str" | "to-enum" | "list" | "to-class" | "dict" | "union" | "from-datetime" | "from-stringified-bool" | "is-type";
|
|
65
|
-
export type ValueOrLambda = {
|
|
66
|
-
value: Sourcelike | undefined;
|
|
67
|
-
lambda?: MultiWord;
|
|
68
|
-
};
|
|
69
|
-
export declare class JSONPythonRenderer extends PythonRenderer {
|
|
70
|
-
private readonly _deserializerFunctions;
|
|
71
|
-
private readonly _converterNamer;
|
|
72
|
-
private readonly _topLevelConverterNames;
|
|
73
|
-
private _haveTypeVar;
|
|
74
|
-
private _haveEnumTypeVar;
|
|
75
|
-
private _haveDateutil;
|
|
76
|
-
protected emitTypeVar(tvar: string, constraints: Sourcelike): void;
|
|
77
|
-
protected typeVar(): string;
|
|
78
|
-
protected enumTypeVar(): string;
|
|
79
|
-
protected cast(type: Sourcelike, v: Sourcelike): Sourcelike;
|
|
80
|
-
protected emitNoneConverter(): void;
|
|
81
|
-
protected emitBoolConverter(): void;
|
|
82
|
-
protected emitIntConverter(): void;
|
|
83
|
-
protected emitFromFloatConverter(): void;
|
|
84
|
-
protected emitToFloatConverter(): void;
|
|
85
|
-
protected emitStrConverter(): void;
|
|
86
|
-
protected emitToEnumConverter(): void;
|
|
87
|
-
protected emitListConverter(): void;
|
|
88
|
-
protected emitToClassConverter(): void;
|
|
89
|
-
protected emitDictConverter(): void;
|
|
90
|
-
protected emitUnionConverter(): void;
|
|
91
|
-
protected emitFromDatetimeConverter(): void;
|
|
92
|
-
protected emitFromStringifiedBoolConverter(): void;
|
|
93
|
-
protected emitIsTypeConverter(): void;
|
|
94
|
-
protected emitConverter(cf: ConverterFunction): void;
|
|
95
|
-
protected conv(cf: ConverterFunction): Sourcelike;
|
|
96
|
-
protected convFn(cf: ConverterFunction, arg: ValueOrLambda): ValueOrLambda;
|
|
97
|
-
protected typeObject(t: Type): Sourcelike;
|
|
98
|
-
protected transformer(inputTransformer: ValueOrLambda, xfer: Transformer, targetType: Type): ValueOrLambda;
|
|
99
|
-
protected deserializer(value: ValueOrLambda, t: Type): ValueOrLambda;
|
|
100
|
-
protected serializer(value: ValueOrLambda, t: Type): ValueOrLambda;
|
|
101
|
-
protected emitClassMembers(t: ClassType): void;
|
|
102
|
-
protected emitImports(): void;
|
|
103
|
-
protected emitSupportCode(): void;
|
|
104
|
-
protected makeTopLevelDependencyNames(_t: Type, topLevelName: Name): DependencyName[];
|
|
105
|
-
protected emitDefaultLeadingComments(): void;
|
|
106
|
-
protected emitClosingCode(): void;
|
|
107
|
-
}
|