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,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.test = exports.generate = exports.evaluate = exports.evaluateFull = exports.load = exports.train = void 0;
|
|
4
|
-
const Support_1 = require("./support/Support");
|
|
5
|
-
const EncodedMarkovChain_1 = require("./EncodedMarkovChain");
|
|
6
|
-
function makeTrie() {
|
|
7
|
-
const arr = [];
|
|
8
|
-
for (let i = 0; i < 128; i++) {
|
|
9
|
-
arr.push(null);
|
|
10
|
-
}
|
|
11
|
-
return { count: 0, arr };
|
|
12
|
-
}
|
|
13
|
-
function lookup(t, seq, i) {
|
|
14
|
-
if (i >= seq.length) {
|
|
15
|
-
return t;
|
|
16
|
-
}
|
|
17
|
-
let first = seq.charCodeAt(i);
|
|
18
|
-
if (first >= 128) {
|
|
19
|
-
first = 0;
|
|
20
|
-
}
|
|
21
|
-
const n = t.arr[first];
|
|
22
|
-
if (n === null) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
if (typeof n === "object") {
|
|
26
|
-
return lookup(n, seq, i + 1);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return n / t.count;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function increment(t, seq, i) {
|
|
33
|
-
let first = seq.charCodeAt(i);
|
|
34
|
-
if (first >= 128) {
|
|
35
|
-
first = 0;
|
|
36
|
-
}
|
|
37
|
-
if (i >= seq.length - 1) {
|
|
38
|
-
if (typeof t !== "object") {
|
|
39
|
-
return (0, Support_1.panic)("Malformed trie");
|
|
40
|
-
}
|
|
41
|
-
let n = t.arr[first];
|
|
42
|
-
if (n === null) {
|
|
43
|
-
n = 0;
|
|
44
|
-
}
|
|
45
|
-
else if (typeof n === "object") {
|
|
46
|
-
return (0, Support_1.panic)("Malformed trie");
|
|
47
|
-
}
|
|
48
|
-
t.arr[first] = n + 1;
|
|
49
|
-
t.count += 1;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
let st = t.arr[first];
|
|
53
|
-
if (st === null) {
|
|
54
|
-
t.arr[first] = st = makeTrie();
|
|
55
|
-
}
|
|
56
|
-
if (typeof st !== "object") {
|
|
57
|
-
return (0, Support_1.panic)("Malformed trie");
|
|
58
|
-
}
|
|
59
|
-
return increment(st, seq, i + 1);
|
|
60
|
-
}
|
|
61
|
-
function train(lines, depth) {
|
|
62
|
-
const trie = makeTrie();
|
|
63
|
-
for (const l of lines) {
|
|
64
|
-
for (let i = depth; i <= l.length; i++) {
|
|
65
|
-
increment(trie, l.slice(i - depth, i), 0);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return { trie, depth };
|
|
69
|
-
}
|
|
70
|
-
exports.train = train;
|
|
71
|
-
function load() {
|
|
72
|
-
return JSON.parse((0, Support_1.inflateBase64)(EncodedMarkovChain_1.encodedMarkovChain));
|
|
73
|
-
}
|
|
74
|
-
exports.load = load;
|
|
75
|
-
function evaluateFull(mc, word) {
|
|
76
|
-
const { trie, depth } = mc;
|
|
77
|
-
if (word.length < depth) {
|
|
78
|
-
return [1, []];
|
|
79
|
-
}
|
|
80
|
-
let p = 1;
|
|
81
|
-
const scores = [];
|
|
82
|
-
for (let i = depth; i <= word.length; i++) {
|
|
83
|
-
let cp = lookup(trie, word.slice(i - depth, i), 0);
|
|
84
|
-
if (typeof cp === "object") {
|
|
85
|
-
return (0, Support_1.panic)("Did we mess up the depth?");
|
|
86
|
-
}
|
|
87
|
-
if (cp === undefined) {
|
|
88
|
-
cp = 0.0001;
|
|
89
|
-
}
|
|
90
|
-
scores.push(cp);
|
|
91
|
-
p = p * cp;
|
|
92
|
-
}
|
|
93
|
-
return [Math.pow(p, 1 / (word.length - depth + 1)), scores];
|
|
94
|
-
}
|
|
95
|
-
exports.evaluateFull = evaluateFull;
|
|
96
|
-
function evaluate(mc, word) {
|
|
97
|
-
return evaluateFull(mc, word)[0];
|
|
98
|
-
}
|
|
99
|
-
exports.evaluate = evaluate;
|
|
100
|
-
function randomInt(lower, upper) {
|
|
101
|
-
const range = upper - lower;
|
|
102
|
-
return lower + Math.floor(Math.random() * range);
|
|
103
|
-
}
|
|
104
|
-
function generate(mc, state, unseenWeight) {
|
|
105
|
-
(0, Support_1.assert)(state.length === mc.depth - 1, "State and chain length don't match up");
|
|
106
|
-
const t = lookup(mc.trie, state, 0);
|
|
107
|
-
if (typeof t === "number") {
|
|
108
|
-
return (0, Support_1.panic)("Wrong depth?");
|
|
109
|
-
}
|
|
110
|
-
if (t === undefined) {
|
|
111
|
-
return String.fromCharCode(randomInt(32, 127));
|
|
112
|
-
}
|
|
113
|
-
const counts = t.arr.map((x, i) => (x === null ? (i === 0 ? 0 : unseenWeight) : x));
|
|
114
|
-
let n = 0;
|
|
115
|
-
for (const c of counts) {
|
|
116
|
-
n += c;
|
|
117
|
-
}
|
|
118
|
-
const r = randomInt(0, n);
|
|
119
|
-
let sum = 0;
|
|
120
|
-
for (let i = 0; i < counts.length; i++) {
|
|
121
|
-
sum += counts[i];
|
|
122
|
-
if (r < sum) {
|
|
123
|
-
return String.fromCharCode(i);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return (0, Support_1.panic)("We screwed up bookkeeping, or randomInt");
|
|
127
|
-
}
|
|
128
|
-
exports.generate = generate;
|
|
129
|
-
function testWord(mc, word) {
|
|
130
|
-
console.log(`"${word}": ${evaluate(mc, word)}`);
|
|
131
|
-
}
|
|
132
|
-
function test() {
|
|
133
|
-
const mc = load();
|
|
134
|
-
testWord(mc, "url");
|
|
135
|
-
testWord(mc, "json");
|
|
136
|
-
testWord(mc, "my_property");
|
|
137
|
-
testWord(mc, "ordinary");
|
|
138
|
-
testWord(mc, "different");
|
|
139
|
-
testWord(mc, "189512");
|
|
140
|
-
testWord(mc, "2BTZIqw0ntH9MvilQ3ewNY");
|
|
141
|
-
testWord(mc, "0uBTNdNGb2OY5lou41iYL52LcDq2");
|
|
142
|
-
testWord(mc, "-KpqHmWuDOUnr1hmAhxp");
|
|
143
|
-
testWord(mc, "granularity");
|
|
144
|
-
testWord(mc, "coverage");
|
|
145
|
-
testWord(mc, "postingFrequency");
|
|
146
|
-
testWord(mc, "dataFrequency");
|
|
147
|
-
testWord(mc, "units");
|
|
148
|
-
testWord(mc, "datasetOwner");
|
|
149
|
-
testWord(mc, "organization");
|
|
150
|
-
testWord(mc, "timePeriod");
|
|
151
|
-
testWord(mc, "contactInformation");
|
|
152
|
-
testWord(mc, "\ud83d\udebe \ud83c\udd92 \ud83c\udd93 \ud83c\udd95 \ud83c\udd96 \ud83c\udd97 \ud83c\udd99 \ud83c\udfe7");
|
|
153
|
-
}
|
|
154
|
-
exports.test = test;
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { StringMap } from "./support/Support";
|
|
2
|
-
import { Ref } from "./input/JSONSchemaInput";
|
|
3
|
-
export type ErrorProperties = {
|
|
4
|
-
kind: "InternalError";
|
|
5
|
-
properties: {
|
|
6
|
-
message: string;
|
|
7
|
-
};
|
|
8
|
-
} | {
|
|
9
|
-
kind: "MiscJSONParseError";
|
|
10
|
-
properties: {
|
|
11
|
-
description: string;
|
|
12
|
-
address: string;
|
|
13
|
-
message: string;
|
|
14
|
-
};
|
|
15
|
-
} | {
|
|
16
|
-
kind: "MiscReadError";
|
|
17
|
-
properties: {
|
|
18
|
-
fileOrURL: string;
|
|
19
|
-
message: string;
|
|
20
|
-
};
|
|
21
|
-
} | {
|
|
22
|
-
kind: "MiscUnicodeHighSurrogateWithoutLowSurrogate";
|
|
23
|
-
properties: {};
|
|
24
|
-
} | {
|
|
25
|
-
kind: "MiscInvalidMinMaxConstraint";
|
|
26
|
-
properties: {
|
|
27
|
-
min: number;
|
|
28
|
-
max: number;
|
|
29
|
-
};
|
|
30
|
-
} | {
|
|
31
|
-
kind: "InferenceJSONReferenceNotRooted";
|
|
32
|
-
properties: {
|
|
33
|
-
reference: string;
|
|
34
|
-
};
|
|
35
|
-
} | {
|
|
36
|
-
kind: "InferenceJSONReferenceToUnion";
|
|
37
|
-
properties: {
|
|
38
|
-
reference: string;
|
|
39
|
-
};
|
|
40
|
-
} | {
|
|
41
|
-
kind: "InferenceJSONReferenceWrongProperty";
|
|
42
|
-
properties: {
|
|
43
|
-
reference: string;
|
|
44
|
-
};
|
|
45
|
-
} | {
|
|
46
|
-
kind: "InferenceJSONReferenceInvalidArrayIndex";
|
|
47
|
-
properties: {
|
|
48
|
-
reference: string;
|
|
49
|
-
};
|
|
50
|
-
} | {
|
|
51
|
-
kind: "SchemaArrayIsInvalidSchema";
|
|
52
|
-
properties: {
|
|
53
|
-
ref: Ref;
|
|
54
|
-
};
|
|
55
|
-
} | {
|
|
56
|
-
kind: "SchemaNullIsInvalidSchema";
|
|
57
|
-
properties: {
|
|
58
|
-
ref: Ref;
|
|
59
|
-
};
|
|
60
|
-
} | {
|
|
61
|
-
kind: "SchemaRefMustBeString";
|
|
62
|
-
properties: {
|
|
63
|
-
actual: string;
|
|
64
|
-
ref: Ref;
|
|
65
|
-
};
|
|
66
|
-
} | {
|
|
67
|
-
kind: "SchemaAdditionalTypesForbidRequired";
|
|
68
|
-
properties: {
|
|
69
|
-
ref: Ref;
|
|
70
|
-
};
|
|
71
|
-
} | {
|
|
72
|
-
kind: "SchemaNoTypeSpecified";
|
|
73
|
-
properties: {
|
|
74
|
-
ref: Ref;
|
|
75
|
-
};
|
|
76
|
-
} | {
|
|
77
|
-
kind: "SchemaInvalidType";
|
|
78
|
-
properties: {
|
|
79
|
-
type: string;
|
|
80
|
-
ref: Ref;
|
|
81
|
-
};
|
|
82
|
-
} | {
|
|
83
|
-
kind: "SchemaFalseNotSupported";
|
|
84
|
-
properties: {
|
|
85
|
-
ref: Ref;
|
|
86
|
-
};
|
|
87
|
-
} | {
|
|
88
|
-
kind: "SchemaInvalidJSONSchemaType";
|
|
89
|
-
properties: {
|
|
90
|
-
type: string;
|
|
91
|
-
ref: Ref;
|
|
92
|
-
};
|
|
93
|
-
} | {
|
|
94
|
-
kind: "SchemaRequiredMustBeStringOrStringArray";
|
|
95
|
-
properties: {
|
|
96
|
-
actual: any;
|
|
97
|
-
ref: Ref;
|
|
98
|
-
};
|
|
99
|
-
} | {
|
|
100
|
-
kind: "SchemaRequiredElementMustBeString";
|
|
101
|
-
properties: {
|
|
102
|
-
element: any;
|
|
103
|
-
ref: Ref;
|
|
104
|
-
};
|
|
105
|
-
} | {
|
|
106
|
-
kind: "SchemaTypeMustBeStringOrStringArray";
|
|
107
|
-
properties: {
|
|
108
|
-
actual: any;
|
|
109
|
-
};
|
|
110
|
-
} | {
|
|
111
|
-
kind: "SchemaTypeElementMustBeString";
|
|
112
|
-
properties: {
|
|
113
|
-
element: any;
|
|
114
|
-
ref: Ref;
|
|
115
|
-
};
|
|
116
|
-
} | {
|
|
117
|
-
kind: "SchemaArrayItemsMustBeStringOrArray";
|
|
118
|
-
properties: {
|
|
119
|
-
actual: any;
|
|
120
|
-
ref: Ref;
|
|
121
|
-
};
|
|
122
|
-
} | {
|
|
123
|
-
kind: "SchemaIDMustHaveAddress";
|
|
124
|
-
properties: {
|
|
125
|
-
id: string;
|
|
126
|
-
ref: Ref;
|
|
127
|
-
};
|
|
128
|
-
} | {
|
|
129
|
-
kind: "SchemaWrongAccessorEntryArrayLength";
|
|
130
|
-
properties: {
|
|
131
|
-
operation: string;
|
|
132
|
-
ref: Ref;
|
|
133
|
-
};
|
|
134
|
-
} | {
|
|
135
|
-
kind: "SchemaSetOperationCasesIsNotArray";
|
|
136
|
-
properties: {
|
|
137
|
-
operation: string;
|
|
138
|
-
cases: any;
|
|
139
|
-
ref: Ref;
|
|
140
|
-
};
|
|
141
|
-
} | {
|
|
142
|
-
kind: "SchemaMoreThanOneUnionMemberName";
|
|
143
|
-
properties: {
|
|
144
|
-
names: string[];
|
|
145
|
-
};
|
|
146
|
-
} | {
|
|
147
|
-
kind: "SchemaCannotGetTypesFromBoolean";
|
|
148
|
-
properties: {
|
|
149
|
-
ref: string;
|
|
150
|
-
};
|
|
151
|
-
} | {
|
|
152
|
-
kind: "SchemaCannotIndexArrayWithNonNumber";
|
|
153
|
-
properties: {
|
|
154
|
-
actual: string;
|
|
155
|
-
ref: Ref;
|
|
156
|
-
};
|
|
157
|
-
} | {
|
|
158
|
-
kind: "SchemaIndexNotInArray";
|
|
159
|
-
properties: {
|
|
160
|
-
index: number;
|
|
161
|
-
ref: Ref;
|
|
162
|
-
};
|
|
163
|
-
} | {
|
|
164
|
-
kind: "SchemaKeyNotInObject";
|
|
165
|
-
properties: {
|
|
166
|
-
key: string;
|
|
167
|
-
ref: Ref;
|
|
168
|
-
};
|
|
169
|
-
} | {
|
|
170
|
-
kind: "SchemaFetchError";
|
|
171
|
-
properties: {
|
|
172
|
-
address: string;
|
|
173
|
-
base: Ref;
|
|
174
|
-
};
|
|
175
|
-
} | {
|
|
176
|
-
kind: "SchemaFetchErrorTopLevel";
|
|
177
|
-
properties: {
|
|
178
|
-
address: string;
|
|
179
|
-
};
|
|
180
|
-
} | {
|
|
181
|
-
kind: "SchemaFetchErrorAdditional";
|
|
182
|
-
properties: {
|
|
183
|
-
address: string;
|
|
184
|
-
};
|
|
185
|
-
} | {
|
|
186
|
-
kind: "GraphQLNoQueriesDefined";
|
|
187
|
-
properties: {};
|
|
188
|
-
} | {
|
|
189
|
-
kind: "DriverUnknownSourceLanguage";
|
|
190
|
-
properties: {
|
|
191
|
-
lang: string;
|
|
192
|
-
};
|
|
193
|
-
} | {
|
|
194
|
-
kind: "DriverUnknownOutputLanguage";
|
|
195
|
-
properties: {
|
|
196
|
-
lang: string;
|
|
197
|
-
};
|
|
198
|
-
} | {
|
|
199
|
-
kind: "DriverMoreThanOneInputGiven";
|
|
200
|
-
properties: {
|
|
201
|
-
topLevel: string;
|
|
202
|
-
};
|
|
203
|
-
} | {
|
|
204
|
-
kind: "DriverCannotInferNameForSchema";
|
|
205
|
-
properties: {
|
|
206
|
-
uri: string;
|
|
207
|
-
};
|
|
208
|
-
} | {
|
|
209
|
-
kind: "DriverNoGraphQLQueryGiven";
|
|
210
|
-
properties: {};
|
|
211
|
-
} | {
|
|
212
|
-
kind: "DriverNoGraphQLSchemaInDir";
|
|
213
|
-
properties: {
|
|
214
|
-
dir: string;
|
|
215
|
-
};
|
|
216
|
-
} | {
|
|
217
|
-
kind: "DriverMoreThanOneGraphQLSchemaInDir";
|
|
218
|
-
properties: {
|
|
219
|
-
dir: string;
|
|
220
|
-
};
|
|
221
|
-
} | {
|
|
222
|
-
kind: "DriverSourceLangMustBeGraphQL";
|
|
223
|
-
properties: {};
|
|
224
|
-
} | {
|
|
225
|
-
kind: "DriverGraphQLSchemaNeeded";
|
|
226
|
-
properties: {};
|
|
227
|
-
} | {
|
|
228
|
-
kind: "DriverInputFileDoesNotExist";
|
|
229
|
-
properties: {
|
|
230
|
-
filename: string;
|
|
231
|
-
};
|
|
232
|
-
} | {
|
|
233
|
-
kind: "DriverCannotMixJSONWithOtherSamples";
|
|
234
|
-
properties: {
|
|
235
|
-
dir: string;
|
|
236
|
-
};
|
|
237
|
-
} | {
|
|
238
|
-
kind: "DriverCannotMixNonJSONInputs";
|
|
239
|
-
properties: {
|
|
240
|
-
dir: string;
|
|
241
|
-
};
|
|
242
|
-
} | {
|
|
243
|
-
kind: "DriverUnknownDebugOption";
|
|
244
|
-
properties: {
|
|
245
|
-
option: string;
|
|
246
|
-
};
|
|
247
|
-
} | {
|
|
248
|
-
kind: "DriverNoLanguageOrExtension";
|
|
249
|
-
properties: {};
|
|
250
|
-
} | {
|
|
251
|
-
kind: "DriverCLIOptionParsingFailed";
|
|
252
|
-
properties: {
|
|
253
|
-
message: string;
|
|
254
|
-
};
|
|
255
|
-
} | {
|
|
256
|
-
kind: "IRNoForwardDeclarableTypeInCycle";
|
|
257
|
-
properties: {};
|
|
258
|
-
} | {
|
|
259
|
-
kind: "IRTypeAttributesNotPropagated";
|
|
260
|
-
properties: {
|
|
261
|
-
count: number;
|
|
262
|
-
indexes: number[];
|
|
263
|
-
};
|
|
264
|
-
} | {
|
|
265
|
-
kind: "IRNoEmptyUnions";
|
|
266
|
-
properties: {};
|
|
267
|
-
} | {
|
|
268
|
-
kind: "RendererUnknownOptionValue";
|
|
269
|
-
properties: {
|
|
270
|
-
value: string;
|
|
271
|
-
name: string;
|
|
272
|
-
};
|
|
273
|
-
} | {
|
|
274
|
-
kind: "TypeScriptCompilerError";
|
|
275
|
-
properties: {
|
|
276
|
-
message: string;
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
export type ErrorKinds = ErrorProperties extends {
|
|
280
|
-
kind: infer K;
|
|
281
|
-
} ? K : never;
|
|
282
|
-
export type ErrorPropertiesForName<K> = Extract<ErrorProperties, {
|
|
283
|
-
kind: K;
|
|
284
|
-
}> extends {
|
|
285
|
-
properties: infer P;
|
|
286
|
-
} ? P : never;
|
|
287
|
-
export declare class QuickTypeError extends Error {
|
|
288
|
-
readonly errorMessage: string;
|
|
289
|
-
readonly messageName: string;
|
|
290
|
-
readonly properties: StringMap;
|
|
291
|
-
constructor(errorMessage: string, messageName: string, userMessage: string, properties: StringMap);
|
|
292
|
-
}
|
|
293
|
-
export declare function messageError<N extends ErrorKinds>(kind: N, properties: ErrorPropertiesForName<N>): never;
|
|
294
|
-
export declare function messageAssert<N extends ErrorKinds>(assertion: boolean, kind: N, properties: ErrorPropertiesForName<N>): void;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messageAssert = exports.messageError = exports.QuickTypeError = void 0;
|
|
4
|
-
const errorMessages = {
|
|
5
|
-
InternalError: "Internal error: ${message}",
|
|
6
|
-
// Misc
|
|
7
|
-
MiscJSONParseError: "Syntax error in ${description} JSON ${address}: ${message}",
|
|
8
|
-
MiscReadError: "Cannot read from file or URL ${fileOrURL}: ${message}",
|
|
9
|
-
MiscUnicodeHighSurrogateWithoutLowSurrogate: "Malformed unicode: High surrogate not followed by low surrogate",
|
|
10
|
-
MiscInvalidMinMaxConstraint: "Invalid min-max constraint: ${min}-${max}",
|
|
11
|
-
// Inference
|
|
12
|
-
InferenceJSONReferenceNotRooted: "JSON reference doesn't start with '#/': ${reference}",
|
|
13
|
-
InferenceJSONReferenceToUnion: "JSON reference points to a union type: ${reference}",
|
|
14
|
-
InferenceJSONReferenceWrongProperty: "JSON reference points to a non-existant property: ${reference}",
|
|
15
|
-
InferenceJSONReferenceInvalidArrayIndex: "JSON reference uses invalid array index: ${reference}",
|
|
16
|
-
// JSON Schema input
|
|
17
|
-
SchemaArrayIsInvalidSchema: "An array is not a valid JSON Schema at ${ref}",
|
|
18
|
-
SchemaNullIsInvalidSchema: "null is not a valid JSON Schema at ${ref}",
|
|
19
|
-
SchemaRefMustBeString: "$ref must be a string, but is an ${actual} at ${ref}",
|
|
20
|
-
SchemaAdditionalTypesForbidRequired: "Can't have non-specified required properties but forbidden additionalTypes at ${ref}",
|
|
21
|
-
SchemaNoTypeSpecified: "JSON Schema must specify at least one type at ${ref}",
|
|
22
|
-
SchemaInvalidType: "Invalid type ${type} in JSON Schema at ${ref}",
|
|
23
|
-
SchemaFalseNotSupported: 'Schema "false" is not supported at ${ref}',
|
|
24
|
-
SchemaInvalidJSONSchemaType: "Value of type ${type} is not valid JSON Schema at ${ref}",
|
|
25
|
-
SchemaRequiredMustBeStringOrStringArray: "`required` must be string or array of strings, but is ${actual} at ${ref}",
|
|
26
|
-
SchemaRequiredElementMustBeString: "`required` must contain only strings, but it has ${element}, at ${ref}",
|
|
27
|
-
SchemaTypeMustBeStringOrStringArray: "`type` must be string or array of strings, but is ${actual}",
|
|
28
|
-
SchemaTypeElementMustBeString: "`type` must contain only strings, but it has ${element}",
|
|
29
|
-
SchemaArrayItemsMustBeStringOrArray: "Array items must be an array or an object, but is ${actual}",
|
|
30
|
-
SchemaIDMustHaveAddress: "$id ${id} doesn't have an address at ${ref}",
|
|
31
|
-
SchemaWrongAccessorEntryArrayLength: "Accessor entry array must have the same number of entries as the ${operation} at ${ref}",
|
|
32
|
-
SchemaSetOperationCasesIsNotArray: "${operation} cases must be an array, but is ${cases}, at ${ref}",
|
|
33
|
-
SchemaMoreThanOneUnionMemberName: "More than one name given for union member: ${names}",
|
|
34
|
-
SchemaCannotGetTypesFromBoolean: "Schema value to get top-level types from must be an object, but is boolean, at ${ref}",
|
|
35
|
-
SchemaCannotIndexArrayWithNonNumber: "Trying to index array in schema with key that is not a number, but is ${actual} at ${ref}",
|
|
36
|
-
SchemaIndexNotInArray: "Index ${index} out of range of schema array at ${ref}",
|
|
37
|
-
SchemaKeyNotInObject: "Key ${key} not in schema object at ${ref}",
|
|
38
|
-
SchemaFetchError: "Could not fetch schema ${address}, referred to from ${base}",
|
|
39
|
-
SchemaFetchErrorTopLevel: "Could not fetch top-level schema ${address}",
|
|
40
|
-
SchemaFetchErrorAdditional: "Could not fetch additional schema ${address}",
|
|
41
|
-
// GraphQL input
|
|
42
|
-
GraphQLNoQueriesDefined: "GraphQL file doesn't have any queries defined.",
|
|
43
|
-
// Driver
|
|
44
|
-
DriverUnknownSourceLanguage: "Unknown source language ${lang}",
|
|
45
|
-
DriverUnknownOutputLanguage: "Unknown output language ${lang}",
|
|
46
|
-
DriverMoreThanOneInputGiven: "More than one input given for top-level ${topLevel}",
|
|
47
|
-
DriverCannotInferNameForSchema: "Cannot infer name for schema ${uri}",
|
|
48
|
-
DriverNoGraphQLQueryGiven: "Please specify at least one GraphQL query as input",
|
|
49
|
-
DriverNoGraphQLSchemaInDir: "No GraphQL schema in ${dir}",
|
|
50
|
-
DriverMoreThanOneGraphQLSchemaInDir: "More than one GraphQL schema in ${dir}",
|
|
51
|
-
DriverSourceLangMustBeGraphQL: "If a GraphQL schema is specified, the source language must be GraphQL",
|
|
52
|
-
DriverGraphQLSchemaNeeded: "Please specify a GraphQL schema with --graphql-schema or --graphql-introspect",
|
|
53
|
-
DriverInputFileDoesNotExist: "Input file ${filename} does not exist",
|
|
54
|
-
DriverCannotMixJSONWithOtherSamples: "Cannot mix JSON samples with JSON Schems, GraphQL, or TypeScript in input subdirectory ${dir}",
|
|
55
|
-
DriverCannotMixNonJSONInputs: "Cannot mix JSON Schema, GraphQL, and TypeScript in an input subdirectory ${dir}",
|
|
56
|
-
DriverUnknownDebugOption: "Unknown debug option ${option}",
|
|
57
|
-
DriverNoLanguageOrExtension: "Please specify a language (--lang) or an output file extension",
|
|
58
|
-
DriverCLIOptionParsingFailed: "Option parsing failed: ${message}",
|
|
59
|
-
// IR
|
|
60
|
-
IRNoForwardDeclarableTypeInCycle: "Cannot resolve cycle because it doesn't contain types that can be forward declared",
|
|
61
|
-
IRTypeAttributesNotPropagated: "Type attributes for ${count} types were not carried over to the new graph: ${indexes}",
|
|
62
|
-
IRNoEmptyUnions: "Trying to make an empty union - do you have an impossible type in your schema?",
|
|
63
|
-
// Rendering
|
|
64
|
-
RendererUnknownOptionValue: "Unknown value ${value} for option ${name}",
|
|
65
|
-
// TypeScript input
|
|
66
|
-
TypeScriptCompilerError: "TypeScript error: ${message}"
|
|
67
|
-
};
|
|
68
|
-
class QuickTypeError extends Error {
|
|
69
|
-
errorMessage;
|
|
70
|
-
messageName;
|
|
71
|
-
properties;
|
|
72
|
-
constructor(errorMessage, messageName, userMessage, properties) {
|
|
73
|
-
super(userMessage);
|
|
74
|
-
this.errorMessage = errorMessage;
|
|
75
|
-
this.messageName = messageName;
|
|
76
|
-
this.properties = properties;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.QuickTypeError = QuickTypeError;
|
|
80
|
-
function messageError(kind, properties) {
|
|
81
|
-
const message = errorMessages[kind];
|
|
82
|
-
let userMessage = message;
|
|
83
|
-
const propertiesMap = properties;
|
|
84
|
-
for (const name of Object.getOwnPropertyNames(propertiesMap)) {
|
|
85
|
-
let value = propertiesMap[name];
|
|
86
|
-
if (typeof value === "object" && typeof value.toString === "function") {
|
|
87
|
-
value = value.toString();
|
|
88
|
-
}
|
|
89
|
-
else if (typeof value.message === "string") {
|
|
90
|
-
value = value.message;
|
|
91
|
-
}
|
|
92
|
-
else if (typeof value !== "string") {
|
|
93
|
-
value = JSON.stringify(value);
|
|
94
|
-
}
|
|
95
|
-
userMessage = userMessage.replace("${" + name + "}", value);
|
|
96
|
-
}
|
|
97
|
-
throw new QuickTypeError(message, kind, userMessage, propertiesMap);
|
|
98
|
-
}
|
|
99
|
-
exports.messageError = messageError;
|
|
100
|
-
function messageAssert(assertion, kind, properties) {
|
|
101
|
-
if (assertion)
|
|
102
|
-
return;
|
|
103
|
-
return messageError(kind, properties);
|
|
104
|
-
}
|
|
105
|
-
exports.messageAssert = messageAssert;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
export declare class Namespace {
|
|
2
|
-
readonly forbiddenNamespaces: ReadonlySet<Namespace>;
|
|
3
|
-
readonly additionalForbidden: ReadonlySet<Name>;
|
|
4
|
-
private readonly _children;
|
|
5
|
-
private readonly _members;
|
|
6
|
-
constructor(_name: string, parent: Namespace | undefined, forbiddenNamespaces: Iterable<Namespace>, additionalForbidden: Iterable<Name>);
|
|
7
|
-
private addChild;
|
|
8
|
-
get children(): ReadonlySet<Namespace>;
|
|
9
|
-
get members(): ReadonlySet<Name>;
|
|
10
|
-
get forbiddenNameds(): ReadonlySet<Name>;
|
|
11
|
-
add<TName extends Name>(named: TName): TName;
|
|
12
|
-
}
|
|
13
|
-
export type NameStyle = (rawName: string) => string;
|
|
14
|
-
export declare class Namer {
|
|
15
|
-
readonly name: string;
|
|
16
|
-
readonly nameStyle: NameStyle;
|
|
17
|
-
private readonly _prefixes;
|
|
18
|
-
constructor(name: string, nameStyle: NameStyle, prefixes: string[]);
|
|
19
|
-
assignNames(names: ReadonlyMap<Name, string>, forbiddenNamesIterable: Iterable<string>, namesToAssignIterable: Iterable<Name>): ReadonlyMap<Name, string>;
|
|
20
|
-
}
|
|
21
|
-
export declare function funPrefixNamer(name: string, nameStyle: NameStyle): Namer;
|
|
22
|
-
export declare abstract class Name {
|
|
23
|
-
private readonly _namingFunction;
|
|
24
|
-
readonly order: number;
|
|
25
|
-
private readonly _associates;
|
|
26
|
-
constructor(_namingFunction: Namer | undefined, order: number);
|
|
27
|
-
addAssociate(associate: AssociatedName): void;
|
|
28
|
-
abstract get dependencies(): ReadonlyArray<Name>;
|
|
29
|
-
isFixed(): this is FixedName;
|
|
30
|
-
get namingFunction(): Namer;
|
|
31
|
-
abstract proposeUnstyledNames(names: ReadonlyMap<Name, string>): ReadonlySet<string>;
|
|
32
|
-
firstProposedName(names: ReadonlyMap<Name, string>): string;
|
|
33
|
-
nameAssignments(forbiddenNames: ReadonlySet<string>, assignedName: string): ReadonlyMap<Name, string> | null;
|
|
34
|
-
}
|
|
35
|
-
export declare class FixedName extends Name {
|
|
36
|
-
private readonly _fixedName;
|
|
37
|
-
constructor(_fixedName: string);
|
|
38
|
-
get dependencies(): ReadonlyArray<Name>;
|
|
39
|
-
addAssociate(_: AssociatedName): never;
|
|
40
|
-
get fixedName(): string;
|
|
41
|
-
proposeUnstyledNames(_?: ReadonlyMap<Name, string>): ReadonlySet<string>;
|
|
42
|
-
}
|
|
43
|
-
export declare class SimpleName extends Name {
|
|
44
|
-
private readonly _unstyledNames;
|
|
45
|
-
constructor(unstyledNames: Iterable<string>, namingFunction: Namer, order: number);
|
|
46
|
-
get dependencies(): ReadonlyArray<Name>;
|
|
47
|
-
proposeUnstyledNames(_?: ReadonlyMap<Name, string>): ReadonlySet<string>;
|
|
48
|
-
}
|
|
49
|
-
export declare class AssociatedName extends Name {
|
|
50
|
-
private readonly _sponsor;
|
|
51
|
-
readonly getName: (sponsorName: string) => string;
|
|
52
|
-
constructor(_sponsor: Name, order: number, getName: (sponsorName: string) => string);
|
|
53
|
-
get dependencies(): ReadonlyArray<Name>;
|
|
54
|
-
proposeUnstyledNames(_?: ReadonlyMap<Name, string>): never;
|
|
55
|
-
}
|
|
56
|
-
export declare class DependencyName extends Name {
|
|
57
|
-
private readonly _proposeUnstyledName;
|
|
58
|
-
private readonly _dependencies;
|
|
59
|
-
constructor(namingFunction: Namer | undefined, order: number, _proposeUnstyledName: (lookup: (n: Name) => string) => string);
|
|
60
|
-
get dependencies(): ReadonlyArray<Name>;
|
|
61
|
-
proposeUnstyledNames(names: ReadonlyMap<Name, string>): ReadonlySet<string>;
|
|
62
|
-
}
|
|
63
|
-
export declare function keywordNamespace(name: string, keywords: string[]): Namespace;
|
|
64
|
-
export declare function assignNames(rootNamespaces: Iterable<Namespace>): ReadonlyMap<Name, string>;
|