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,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inferTransformedStringTypeKindForString = exports.stringTypesTypeAttributeKind = exports.StringTypes = void 0;
|
|
4
|
-
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const TypeAttributes_1 = require("./TypeAttributes");
|
|
6
|
-
const Support_1 = require("../support/Support");
|
|
7
|
-
const TypeBuilder_1 = require("../TypeBuilder");
|
|
8
|
-
class StringTypes {
|
|
9
|
-
cases;
|
|
10
|
-
transformations;
|
|
11
|
-
static unrestricted = new StringTypes(undefined, new Set());
|
|
12
|
-
static fromCase(s, count) {
|
|
13
|
-
const caseMap = {};
|
|
14
|
-
caseMap[s] = count;
|
|
15
|
-
return new StringTypes(new Map([[s, count]]), new Set());
|
|
16
|
-
}
|
|
17
|
-
static fromCases(cases) {
|
|
18
|
-
const caseMap = {};
|
|
19
|
-
for (const s of cases) {
|
|
20
|
-
caseMap[s] = 1;
|
|
21
|
-
}
|
|
22
|
-
return new StringTypes(new Map(cases.map(s => [s, 1])), new Set());
|
|
23
|
-
}
|
|
24
|
-
// undefined means no restrictions
|
|
25
|
-
constructor(cases, transformations) {
|
|
26
|
-
this.cases = cases;
|
|
27
|
-
this.transformations = transformations;
|
|
28
|
-
if (cases === undefined) {
|
|
29
|
-
(0, Support_1.assert)(transformations.size === 0, "We can't have an unrestricted string that also allows transformations");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
get isRestricted() {
|
|
33
|
-
return this.cases !== undefined;
|
|
34
|
-
}
|
|
35
|
-
union(othersArray, startIndex) {
|
|
36
|
-
if (this.cases === undefined)
|
|
37
|
-
return this;
|
|
38
|
-
const cases = new Map(this.cases);
|
|
39
|
-
const transformations = new Set(this.transformations);
|
|
40
|
-
for (let i = startIndex; i < othersArray.length; i++) {
|
|
41
|
-
const other = othersArray[i];
|
|
42
|
-
if (other.cases === undefined)
|
|
43
|
-
return other;
|
|
44
|
-
(0, collection_utils_1.mapMergeWithInto)(cases, (x, y) => x + y, other.cases);
|
|
45
|
-
(0, collection_utils_1.setUnionInto)(transformations, other.transformations);
|
|
46
|
-
}
|
|
47
|
-
return new StringTypes(cases, transformations);
|
|
48
|
-
}
|
|
49
|
-
intersect(othersArray, startIndex) {
|
|
50
|
-
let cases = this.cases;
|
|
51
|
-
let transformations = this.transformations;
|
|
52
|
-
for (let i = startIndex; i < othersArray.length; i++) {
|
|
53
|
-
const other = othersArray[i];
|
|
54
|
-
if (cases === undefined) {
|
|
55
|
-
cases = (0, collection_utils_1.definedMap)(other.cases, m => new Map(m));
|
|
56
|
-
}
|
|
57
|
-
else if (other.cases !== undefined) {
|
|
58
|
-
const thisCases = cases;
|
|
59
|
-
const otherCases = other.cases;
|
|
60
|
-
cases = (0, collection_utils_1.mapMap)((0, collection_utils_1.setIntersect)(thisCases.keys(), new Set(otherCases.keys())).entries(), k => Math.min((0, Support_1.defined)(thisCases.get(k)), (0, Support_1.defined)(otherCases.get(k))));
|
|
61
|
-
}
|
|
62
|
-
transformations = (0, collection_utils_1.setIntersect)(transformations, other.transformations);
|
|
63
|
-
}
|
|
64
|
-
return new StringTypes(cases, transformations);
|
|
65
|
-
}
|
|
66
|
-
applyStringTypeMapping(mapping) {
|
|
67
|
-
if (!this.isRestricted)
|
|
68
|
-
return this;
|
|
69
|
-
const kinds = new Set();
|
|
70
|
-
for (const kind of this.transformations) {
|
|
71
|
-
const mapped = (0, TypeBuilder_1.stringTypeMappingGet)(mapping, kind);
|
|
72
|
-
if (mapped === "string")
|
|
73
|
-
return StringTypes.unrestricted;
|
|
74
|
-
kinds.add(mapped);
|
|
75
|
-
}
|
|
76
|
-
return new StringTypes(this.cases, new Set(kinds));
|
|
77
|
-
}
|
|
78
|
-
equals(other) {
|
|
79
|
-
if (!(other instanceof StringTypes))
|
|
80
|
-
return false;
|
|
81
|
-
return (0, collection_utils_1.areEqual)(this.cases, other.cases) && (0, collection_utils_1.areEqual)(this.transformations, other.transformations);
|
|
82
|
-
}
|
|
83
|
-
hashCode() {
|
|
84
|
-
let h = (0, collection_utils_1.hashCodeOf)(this.cases);
|
|
85
|
-
h = (0, collection_utils_1.addHashCode)(h, (0, collection_utils_1.hashCodeOf)(this.transformations));
|
|
86
|
-
return h;
|
|
87
|
-
}
|
|
88
|
-
toString() {
|
|
89
|
-
const parts = [];
|
|
90
|
-
const enumCases = this.cases;
|
|
91
|
-
if (enumCases === undefined) {
|
|
92
|
-
parts.push("unrestricted");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const firstKey = (0, collection_utils_1.iterableFirst)(enumCases.keys());
|
|
96
|
-
if (firstKey === undefined) {
|
|
97
|
-
parts.push("enum with no cases");
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
parts.push(`${enumCases.size.toString()} enums: ${firstKey} (${enumCases.get(firstKey)}), ...`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return parts.concat(Array.from(this.transformations)).join(",");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.StringTypes = StringTypes;
|
|
107
|
-
class StringTypesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
|
|
108
|
-
constructor() {
|
|
109
|
-
super("stringTypes");
|
|
110
|
-
}
|
|
111
|
-
get inIdentity() {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
requiresUniqueIdentity(st) {
|
|
115
|
-
return st.cases !== undefined && st.cases.size > 0;
|
|
116
|
-
}
|
|
117
|
-
combine(arr) {
|
|
118
|
-
(0, Support_1.assert)(arr.length > 0);
|
|
119
|
-
return arr[0].union(arr, 1);
|
|
120
|
-
}
|
|
121
|
-
intersect(arr) {
|
|
122
|
-
(0, Support_1.assert)(arr.length > 0);
|
|
123
|
-
return arr[0].intersect(arr, 1);
|
|
124
|
-
}
|
|
125
|
-
makeInferred(_) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
stringify(st) {
|
|
129
|
-
return st.toString();
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.stringTypesTypeAttributeKind = new StringTypesTypeAttributeKind();
|
|
133
|
-
const INTEGER_STRING = /^(0|-?[1-9]\d*)$/;
|
|
134
|
-
// We're restricting numbers to what's representable as 32 bit
|
|
135
|
-
// signed integers, to be on the safe side of most languages.
|
|
136
|
-
const MIN_INTEGER_STRING = 1 << 31;
|
|
137
|
-
const MAX_INTEGER_STRING = -(MIN_INTEGER_STRING + 1);
|
|
138
|
-
function isIntegerString(s) {
|
|
139
|
-
if (s.match(INTEGER_STRING) === null) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
const i = parseInt(s, 10);
|
|
143
|
-
return i >= MIN_INTEGER_STRING && i <= MAX_INTEGER_STRING;
|
|
144
|
-
}
|
|
145
|
-
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
146
|
-
function isUUID(s) {
|
|
147
|
-
return s.match(UUID) !== null;
|
|
148
|
-
}
|
|
149
|
-
// FIXME: This is obviously not a complete URI regex. The exclusion of
|
|
150
|
-
// `{}` is a hack to make `github-events.json` work, which contains URLs
|
|
151
|
-
// with those characters which ajv refuses to accept as `uri`.
|
|
152
|
-
const URI = /^(https?|ftp):\/\/[^{}]+$/;
|
|
153
|
-
function isURI(s) {
|
|
154
|
-
return s.match(URI) !== null;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* JSON inference calls this function to figure out whether a given string is to be
|
|
158
|
-
* transformed into a higher level type. Must return undefined if not, otherwise the
|
|
159
|
-
* type kind of the transformed string type.
|
|
160
|
-
*
|
|
161
|
-
* @param s The string for which to determine the transformed string type kind.
|
|
162
|
-
*/
|
|
163
|
-
function inferTransformedStringTypeKindForString(s, recognizer) {
|
|
164
|
-
if (s.length === 0 || "0123456789-abcdefth".indexOf(s[0]) < 0)
|
|
165
|
-
return undefined;
|
|
166
|
-
if (recognizer.isDate(s)) {
|
|
167
|
-
return "date";
|
|
168
|
-
}
|
|
169
|
-
else if (recognizer.isTime(s)) {
|
|
170
|
-
return "time";
|
|
171
|
-
}
|
|
172
|
-
else if (recognizer.isDateTime(s)) {
|
|
173
|
-
return "date-time";
|
|
174
|
-
}
|
|
175
|
-
else if (isIntegerString(s)) {
|
|
176
|
-
return "integer-string";
|
|
177
|
-
}
|
|
178
|
-
else if (s === "false" || s === "true") {
|
|
179
|
-
return "bool-string";
|
|
180
|
-
}
|
|
181
|
-
else if (isUUID(s)) {
|
|
182
|
-
return "uuid";
|
|
183
|
-
}
|
|
184
|
-
else if (isURI(s)) {
|
|
185
|
-
return "uri";
|
|
186
|
-
}
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
exports.inferTransformedStringTypeKindForString = inferTransformedStringTypeKindForString;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Type, TypeKind } from "../Type";
|
|
2
|
-
import { BaseGraphRewriteBuilder } from "../GraphRewriting";
|
|
3
|
-
export declare class TypeAttributeKind<T> {
|
|
4
|
-
readonly name: string;
|
|
5
|
-
constructor(name: string);
|
|
6
|
-
appliesToTypeKind(kind: TypeKind): boolean;
|
|
7
|
-
combine(_attrs: T[]): T | undefined;
|
|
8
|
-
intersect(attrs: T[]): T | undefined;
|
|
9
|
-
makeInferred(_: T): T | undefined;
|
|
10
|
-
increaseDistance(attrs: T): T | undefined;
|
|
11
|
-
addToSchema(_schema: {
|
|
12
|
-
[name: string]: unknown;
|
|
13
|
-
}, _t: Type, _attrs: T): void;
|
|
14
|
-
children(_: T): ReadonlySet<Type>;
|
|
15
|
-
stringify(_: T): string | undefined;
|
|
16
|
-
get inIdentity(): boolean;
|
|
17
|
-
requiresUniqueIdentity(_: T): boolean;
|
|
18
|
-
reconstitute<TBuilder extends BaseGraphRewriteBuilder>(_builder: TBuilder, a: T): T;
|
|
19
|
-
makeAttributes(value: T): TypeAttributes;
|
|
20
|
-
tryGetInAttributes(a: TypeAttributes): T | undefined;
|
|
21
|
-
private setInAttributes;
|
|
22
|
-
modifyInAttributes(a: TypeAttributes, modify: (value: T | undefined) => T | undefined): TypeAttributes;
|
|
23
|
-
setDefaultInAttributes(a: TypeAttributes, makeDefault: () => T): TypeAttributes;
|
|
24
|
-
removeInAttributes(a: TypeAttributes): TypeAttributes;
|
|
25
|
-
equals(other: any): boolean;
|
|
26
|
-
hashCode(): number;
|
|
27
|
-
}
|
|
28
|
-
export type TypeAttributes = ReadonlyMap<TypeAttributeKind<any>, any>;
|
|
29
|
-
export declare const emptyTypeAttributes: TypeAttributes;
|
|
30
|
-
export type CombinationKind = "union" | "intersect";
|
|
31
|
-
export declare function combineTypeAttributes(kind: CombinationKind, attributeArray: TypeAttributes[]): TypeAttributes;
|
|
32
|
-
export declare function combineTypeAttributes(kind: CombinationKind, a: TypeAttributes, b: TypeAttributes): TypeAttributes;
|
|
33
|
-
export declare function makeTypeAttributesInferred(attr: TypeAttributes): TypeAttributes;
|
|
34
|
-
export declare function increaseTypeAttributesDistance(attr: TypeAttributes): TypeAttributes;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.increaseTypeAttributesDistance = exports.makeTypeAttributesInferred = exports.combineTypeAttributes = exports.emptyTypeAttributes = exports.TypeAttributeKind = void 0;
|
|
4
|
-
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const Support_1 = require("../support/Support");
|
|
6
|
-
class TypeAttributeKind {
|
|
7
|
-
name;
|
|
8
|
-
constructor(name) {
|
|
9
|
-
this.name = name;
|
|
10
|
-
}
|
|
11
|
-
appliesToTypeKind(kind) {
|
|
12
|
-
return kind !== "any";
|
|
13
|
-
}
|
|
14
|
-
combine(_attrs) {
|
|
15
|
-
return (0, Support_1.panic)(`Cannot combine type attribute ${this.name}`);
|
|
16
|
-
}
|
|
17
|
-
intersect(attrs) {
|
|
18
|
-
return this.combine(attrs);
|
|
19
|
-
}
|
|
20
|
-
makeInferred(_) {
|
|
21
|
-
return (0, Support_1.panic)(`Cannot make type attribute ${this.name} inferred`);
|
|
22
|
-
}
|
|
23
|
-
increaseDistance(attrs) {
|
|
24
|
-
return attrs;
|
|
25
|
-
}
|
|
26
|
-
addToSchema(_schema, _t, _attrs) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
children(_) {
|
|
30
|
-
return new Set();
|
|
31
|
-
}
|
|
32
|
-
stringify(_) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
get inIdentity() {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
requiresUniqueIdentity(_) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
reconstitute(_builder, a) {
|
|
42
|
-
return a;
|
|
43
|
-
}
|
|
44
|
-
makeAttributes(value) {
|
|
45
|
-
const kvps = [[this, value]];
|
|
46
|
-
return new Map(kvps);
|
|
47
|
-
}
|
|
48
|
-
tryGetInAttributes(a) {
|
|
49
|
-
return a.get(this);
|
|
50
|
-
}
|
|
51
|
-
setInAttributes(a, value) {
|
|
52
|
-
// FIXME: This is potentially super slow
|
|
53
|
-
return new Map(a).set(this, value);
|
|
54
|
-
}
|
|
55
|
-
modifyInAttributes(a, modify) {
|
|
56
|
-
const modified = modify(this.tryGetInAttributes(a));
|
|
57
|
-
if (modified === undefined) {
|
|
58
|
-
// FIXME: This is potentially super slow
|
|
59
|
-
const result = new Map(a);
|
|
60
|
-
result.delete(this);
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
return this.setInAttributes(a, modified);
|
|
64
|
-
}
|
|
65
|
-
setDefaultInAttributes(a, makeDefault) {
|
|
66
|
-
if (this.tryGetInAttributes(a) !== undefined)
|
|
67
|
-
return a;
|
|
68
|
-
return this.modifyInAttributes(a, makeDefault);
|
|
69
|
-
}
|
|
70
|
-
removeInAttributes(a) {
|
|
71
|
-
return (0, collection_utils_1.mapFilter)(a, (_, k) => k !== this);
|
|
72
|
-
}
|
|
73
|
-
equals(other) {
|
|
74
|
-
if (!(other instanceof TypeAttributeKind)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return this.name === other.name;
|
|
78
|
-
}
|
|
79
|
-
hashCode() {
|
|
80
|
-
return (0, collection_utils_1.hashString)(this.name);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.TypeAttributeKind = TypeAttributeKind;
|
|
84
|
-
exports.emptyTypeAttributes = new Map();
|
|
85
|
-
function combineTypeAttributes(combinationKind, firstOrArray, second) {
|
|
86
|
-
const union = combinationKind === "union";
|
|
87
|
-
let attributeArray;
|
|
88
|
-
if (Array.isArray(firstOrArray)) {
|
|
89
|
-
attributeArray = firstOrArray;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (second === undefined) {
|
|
93
|
-
return (0, Support_1.panic)("Must have on array or two attributes");
|
|
94
|
-
}
|
|
95
|
-
attributeArray = [firstOrArray, second];
|
|
96
|
-
}
|
|
97
|
-
const attributesByKind = (0, collection_utils_1.mapTranspose)(attributeArray);
|
|
98
|
-
function combine(attrs, kind) {
|
|
99
|
-
(0, Support_1.assert)(attrs.length > 0, "Cannot combine zero type attributes");
|
|
100
|
-
if (attrs.length === 1)
|
|
101
|
-
return attrs[0];
|
|
102
|
-
if (union) {
|
|
103
|
-
return kind.combine(attrs);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return kind.intersect(attrs);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return (0, collection_utils_1.mapFilterMap)(attributesByKind, combine);
|
|
110
|
-
}
|
|
111
|
-
exports.combineTypeAttributes = combineTypeAttributes;
|
|
112
|
-
function makeTypeAttributesInferred(attr) {
|
|
113
|
-
return (0, collection_utils_1.mapFilterMap)(attr, (value, kind) => kind.makeInferred(value));
|
|
114
|
-
}
|
|
115
|
-
exports.makeTypeAttributesInferred = makeTypeAttributesInferred;
|
|
116
|
-
function increaseTypeAttributesDistance(attr) {
|
|
117
|
-
return (0, collection_utils_1.mapFilterMap)(attr, (value, kind) => kind.increaseDistance(value));
|
|
118
|
-
}
|
|
119
|
-
exports.increaseTypeAttributesDistance = increaseTypeAttributesDistance;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
|
2
|
-
export declare function initTypeNames(): void;
|
|
3
|
-
export type NameOrNames = string | TypeNames;
|
|
4
|
-
export declare const tooManyNamesThreshold = 1000;
|
|
5
|
-
export declare abstract class TypeNames {
|
|
6
|
-
readonly distance: number;
|
|
7
|
-
static makeWithDistance(names: ReadonlySet<string>, alternativeNames: ReadonlySet<string> | undefined, distance: number): TypeNames;
|
|
8
|
-
static make(names: ReadonlySet<string>, alternativeNames: ReadonlySet<string> | undefined, areInferred: boolean): TypeNames;
|
|
9
|
-
constructor(distance: number);
|
|
10
|
-
get areInferred(): boolean;
|
|
11
|
-
abstract get names(): ReadonlySet<string>;
|
|
12
|
-
abstract get combinedName(): string;
|
|
13
|
-
abstract get proposedNames(): ReadonlySet<string>;
|
|
14
|
-
abstract add(namesArray: TypeNames[], startIndex?: number): TypeNames;
|
|
15
|
-
abstract clearInferred(): TypeNames;
|
|
16
|
-
abstract makeInferred(): TypeNames;
|
|
17
|
-
abstract singularize(): TypeNames;
|
|
18
|
-
abstract toString(): string;
|
|
19
|
-
}
|
|
20
|
-
export declare class RegularTypeNames extends TypeNames {
|
|
21
|
-
readonly names: ReadonlySet<string>;
|
|
22
|
-
private readonly _alternativeNames;
|
|
23
|
-
constructor(names: ReadonlySet<string>, _alternativeNames: ReadonlySet<string> | undefined, distance: number);
|
|
24
|
-
add(namesArray: TypeNames[], startIndex?: number): TypeNames;
|
|
25
|
-
clearInferred(): TypeNames;
|
|
26
|
-
get combinedName(): string;
|
|
27
|
-
get proposedNames(): ReadonlySet<string>;
|
|
28
|
-
makeInferred(): TypeNames;
|
|
29
|
-
singularize(): TypeNames;
|
|
30
|
-
toString(): string;
|
|
31
|
-
}
|
|
32
|
-
export declare class TooManyTypeNames extends TypeNames {
|
|
33
|
-
readonly names: ReadonlySet<string>;
|
|
34
|
-
constructor(distance: number, name?: string);
|
|
35
|
-
get combinedName(): string;
|
|
36
|
-
get proposedNames(): ReadonlySet<string>;
|
|
37
|
-
add(namesArray: TypeNames[], startIndex?: number): TypeNames;
|
|
38
|
-
clearInferred(): TypeNames;
|
|
39
|
-
makeInferred(): TypeNames;
|
|
40
|
-
singularize(): TypeNames;
|
|
41
|
-
toString(): string;
|
|
42
|
-
}
|
|
43
|
-
export declare const namesTypeAttributeKind: TypeAttributeKind<TypeNames>;
|
|
44
|
-
export declare function modifyTypeNames(attributes: TypeAttributes, modifier: (tn: TypeNames | undefined) => TypeNames | undefined): TypeAttributes;
|
|
45
|
-
export declare function singularizeTypeNames(attributes: TypeAttributes): TypeAttributes;
|
|
46
|
-
export declare function makeNamesTypeAttributes(nameOrNames: NameOrNames, areNamesInferred?: boolean): TypeAttributes;
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makeNamesTypeAttributes = exports.singularizeTypeNames = exports.modifyTypeNames = exports.namesTypeAttributeKind = exports.TooManyTypeNames = exports.RegularTypeNames = exports.TypeNames = exports.tooManyNamesThreshold = exports.initTypeNames = void 0;
|
|
27
|
-
const pluralize = __importStar(require("pluralize"));
|
|
28
|
-
const collection_utils_1 = require("collection-utils");
|
|
29
|
-
const Support_1 = require("../support/Support");
|
|
30
|
-
const TypeAttributes_1 = require("./TypeAttributes");
|
|
31
|
-
const Strings_1 = require("../support/Strings");
|
|
32
|
-
const Chance_1 = require("../support/Chance");
|
|
33
|
-
let chance;
|
|
34
|
-
let usedRandomNames;
|
|
35
|
-
function initTypeNames() {
|
|
36
|
-
chance = new Chance_1.Chance(31415);
|
|
37
|
-
usedRandomNames = new Set();
|
|
38
|
-
}
|
|
39
|
-
exports.initTypeNames = initTypeNames;
|
|
40
|
-
initTypeNames();
|
|
41
|
-
function makeRandomName() {
|
|
42
|
-
for (;;) {
|
|
43
|
-
const name = `${chance.city()} ${chance.animal()}`;
|
|
44
|
-
if (usedRandomNames.has(name))
|
|
45
|
-
continue;
|
|
46
|
-
usedRandomNames.add(name);
|
|
47
|
-
return name;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// FIXME: In the case of overlapping prefixes and suffixes we will
|
|
51
|
-
// produce a name that includes the overlap twice. For example, for
|
|
52
|
-
// the names "aaa" and "aaaa" we have the common prefix "aaa" and the
|
|
53
|
-
// common suffix "aaa", so we will produce the combined name "aaaaaa".
|
|
54
|
-
function combineNames(names) {
|
|
55
|
-
let originalFirst = (0, collection_utils_1.iterableFirst)(names);
|
|
56
|
-
if (originalFirst === undefined) {
|
|
57
|
-
return (0, Support_1.panic)("Named type has no names");
|
|
58
|
-
}
|
|
59
|
-
if (names.size === 1) {
|
|
60
|
-
return originalFirst;
|
|
61
|
-
}
|
|
62
|
-
const namesSet = (0, collection_utils_1.setMap)(names, s => (0, Strings_1.splitIntoWords)(s)
|
|
63
|
-
.map(w => w.word.toLowerCase())
|
|
64
|
-
.join("_"));
|
|
65
|
-
const first = (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(namesSet));
|
|
66
|
-
if (namesSet.size === 1) {
|
|
67
|
-
return first;
|
|
68
|
-
}
|
|
69
|
-
let prefixLength = first.length;
|
|
70
|
-
let suffixLength = first.length;
|
|
71
|
-
for (const n of (0, collection_utils_1.iterableSkip)(namesSet, 1)) {
|
|
72
|
-
prefixLength = Math.min(prefixLength, n.length);
|
|
73
|
-
for (let i = 0; i < prefixLength; i++) {
|
|
74
|
-
if (first[i] !== n[i]) {
|
|
75
|
-
prefixLength = i;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
suffixLength = Math.min(suffixLength, n.length);
|
|
80
|
-
for (let i = 0; i < suffixLength; i++) {
|
|
81
|
-
if (first[first.length - i - 1] !== n[n.length - i - 1]) {
|
|
82
|
-
suffixLength = i;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const prefix = prefixLength > 2 ? first.slice(0, prefixLength) : "";
|
|
88
|
-
const suffix = suffixLength > 2 ? first.slice(first.length - suffixLength) : "";
|
|
89
|
-
const combined = prefix + suffix;
|
|
90
|
-
if (combined.length > 2) {
|
|
91
|
-
return combined;
|
|
92
|
-
}
|
|
93
|
-
return first;
|
|
94
|
-
}
|
|
95
|
-
exports.tooManyNamesThreshold = 1000;
|
|
96
|
-
class TypeNames {
|
|
97
|
-
distance;
|
|
98
|
-
static makeWithDistance(names, alternativeNames, distance) {
|
|
99
|
-
if (names.size >= exports.tooManyNamesThreshold) {
|
|
100
|
-
return new TooManyTypeNames(distance);
|
|
101
|
-
}
|
|
102
|
-
if (alternativeNames === undefined || alternativeNames.size > exports.tooManyNamesThreshold) {
|
|
103
|
-
alternativeNames = undefined;
|
|
104
|
-
}
|
|
105
|
-
return new RegularTypeNames(names, alternativeNames, distance);
|
|
106
|
-
}
|
|
107
|
-
static make(names, alternativeNames, areInferred) {
|
|
108
|
-
return TypeNames.makeWithDistance(names, alternativeNames, areInferred ? 1 : 0);
|
|
109
|
-
}
|
|
110
|
-
constructor(distance) {
|
|
111
|
-
this.distance = distance;
|
|
112
|
-
}
|
|
113
|
-
get areInferred() {
|
|
114
|
-
return this.distance > 0;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.TypeNames = TypeNames;
|
|
118
|
-
class RegularTypeNames extends TypeNames {
|
|
119
|
-
names;
|
|
120
|
-
_alternativeNames;
|
|
121
|
-
constructor(names, _alternativeNames, distance) {
|
|
122
|
-
super(distance);
|
|
123
|
-
this.names = names;
|
|
124
|
-
this._alternativeNames = _alternativeNames;
|
|
125
|
-
}
|
|
126
|
-
add(namesArray, startIndex = 0) {
|
|
127
|
-
let newNames = new Set(this.names);
|
|
128
|
-
let newDistance = this.distance;
|
|
129
|
-
let newAlternativeNames = (0, collection_utils_1.definedMap)(this._alternativeNames, s => new Set(s));
|
|
130
|
-
for (let i = startIndex; i < namesArray.length; i++) {
|
|
131
|
-
const other = namesArray[i];
|
|
132
|
-
if (other instanceof RegularTypeNames && other._alternativeNames !== undefined) {
|
|
133
|
-
if (newAlternativeNames === undefined) {
|
|
134
|
-
newAlternativeNames = new Set();
|
|
135
|
-
}
|
|
136
|
-
(0, collection_utils_1.setUnionInto)(newAlternativeNames, other._alternativeNames);
|
|
137
|
-
}
|
|
138
|
-
if (other.distance > newDistance)
|
|
139
|
-
continue;
|
|
140
|
-
if (!(other instanceof RegularTypeNames)) {
|
|
141
|
-
(0, Support_1.assert)(other instanceof TooManyTypeNames, "Unknown TypeNames instance");
|
|
142
|
-
// The other one is at most our distance, so let it sort it out
|
|
143
|
-
return other.add(namesArray, i + 1);
|
|
144
|
-
}
|
|
145
|
-
if (other.distance < newDistance) {
|
|
146
|
-
// The other one is closer, so take its names
|
|
147
|
-
newNames = new Set(other.names);
|
|
148
|
-
newDistance = other.distance;
|
|
149
|
-
newAlternativeNames = (0, collection_utils_1.definedMap)(other._alternativeNames, s => new Set(s));
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
// Same distance, merge them
|
|
153
|
-
(0, Support_1.assert)(other.distance === newDistance, "This should be the only case left");
|
|
154
|
-
(0, collection_utils_1.setUnionInto)(newNames, other.names);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return TypeNames.makeWithDistance(newNames, newAlternativeNames, newDistance);
|
|
158
|
-
}
|
|
159
|
-
clearInferred() {
|
|
160
|
-
const newNames = this.areInferred ? new Set() : this.names;
|
|
161
|
-
return TypeNames.makeWithDistance(newNames, new Set(), this.distance);
|
|
162
|
-
}
|
|
163
|
-
get combinedName() {
|
|
164
|
-
return combineNames(this.names);
|
|
165
|
-
}
|
|
166
|
-
get proposedNames() {
|
|
167
|
-
const set = new Set([this.combinedName]);
|
|
168
|
-
if (this._alternativeNames === undefined) {
|
|
169
|
-
return set;
|
|
170
|
-
}
|
|
171
|
-
(0, collection_utils_1.setUnionInto)(set, this._alternativeNames);
|
|
172
|
-
return set;
|
|
173
|
-
}
|
|
174
|
-
makeInferred() {
|
|
175
|
-
return TypeNames.makeWithDistance(this.names, this._alternativeNames, this.distance + 1);
|
|
176
|
-
}
|
|
177
|
-
singularize() {
|
|
178
|
-
return TypeNames.makeWithDistance((0, collection_utils_1.setMap)(this.names, pluralize.singular), (0, collection_utils_1.definedMap)(this._alternativeNames, an => (0, collection_utils_1.setMap)(an, pluralize.singular)), this.distance + 1);
|
|
179
|
-
}
|
|
180
|
-
toString() {
|
|
181
|
-
const inferred = this.areInferred ? `distance ${this.distance}` : "given";
|
|
182
|
-
const names = `${inferred} ${Array.from(this.names).join(",")}`;
|
|
183
|
-
if (this._alternativeNames === undefined) {
|
|
184
|
-
return names;
|
|
185
|
-
}
|
|
186
|
-
return `${names} (${Array.from(this._alternativeNames).join(",")})`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
exports.RegularTypeNames = RegularTypeNames;
|
|
190
|
-
class TooManyTypeNames extends TypeNames {
|
|
191
|
-
names;
|
|
192
|
-
constructor(distance, name) {
|
|
193
|
-
super(distance);
|
|
194
|
-
if (name === undefined) {
|
|
195
|
-
name = makeRandomName();
|
|
196
|
-
}
|
|
197
|
-
this.names = new Set([name]);
|
|
198
|
-
}
|
|
199
|
-
get combinedName() {
|
|
200
|
-
return (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(this.names));
|
|
201
|
-
}
|
|
202
|
-
get proposedNames() {
|
|
203
|
-
return this.names;
|
|
204
|
-
}
|
|
205
|
-
add(namesArray, startIndex = 0) {
|
|
206
|
-
if (!this.areInferred)
|
|
207
|
-
return this;
|
|
208
|
-
for (let i = startIndex; i < namesArray.length; i++) {
|
|
209
|
-
const other = namesArray[i];
|
|
210
|
-
if (other.distance < this.distance) {
|
|
211
|
-
return other.add(namesArray, i + 1);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return this;
|
|
215
|
-
}
|
|
216
|
-
clearInferred() {
|
|
217
|
-
if (!this.areInferred) {
|
|
218
|
-
return this;
|
|
219
|
-
}
|
|
220
|
-
return TypeNames.makeWithDistance(new Set(), new Set(), this.distance);
|
|
221
|
-
}
|
|
222
|
-
makeInferred() {
|
|
223
|
-
return new TooManyTypeNames(this.distance + 1, (0, collection_utils_1.iterableFirst)(this.names));
|
|
224
|
-
}
|
|
225
|
-
singularize() {
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
toString() {
|
|
229
|
-
return `too many ${this.combinedName}`;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
exports.TooManyTypeNames = TooManyTypeNames;
|
|
233
|
-
class TypeNamesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
|
|
234
|
-
constructor() {
|
|
235
|
-
super("names");
|
|
236
|
-
}
|
|
237
|
-
combine(namesArray) {
|
|
238
|
-
(0, Support_1.assert)(namesArray.length > 0, "Can't combine zero type names");
|
|
239
|
-
return namesArray[0].add(namesArray, 1);
|
|
240
|
-
}
|
|
241
|
-
makeInferred(tn) {
|
|
242
|
-
return tn.makeInferred();
|
|
243
|
-
}
|
|
244
|
-
increaseDistance(tn) {
|
|
245
|
-
return tn.makeInferred();
|
|
246
|
-
}
|
|
247
|
-
stringify(tn) {
|
|
248
|
-
return tn.toString();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.namesTypeAttributeKind = new TypeNamesTypeAttributeKind();
|
|
252
|
-
function modifyTypeNames(attributes, modifier) {
|
|
253
|
-
return exports.namesTypeAttributeKind.modifyInAttributes(attributes, modifier);
|
|
254
|
-
}
|
|
255
|
-
exports.modifyTypeNames = modifyTypeNames;
|
|
256
|
-
function singularizeTypeNames(attributes) {
|
|
257
|
-
return modifyTypeNames(attributes, maybeNames => {
|
|
258
|
-
if (maybeNames === undefined)
|
|
259
|
-
return undefined;
|
|
260
|
-
return maybeNames.singularize();
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
exports.singularizeTypeNames = singularizeTypeNames;
|
|
264
|
-
function makeNamesTypeAttributes(nameOrNames, areNamesInferred) {
|
|
265
|
-
let typeNames;
|
|
266
|
-
if (typeof nameOrNames === "string") {
|
|
267
|
-
typeNames = TypeNames.make(new Set([nameOrNames]), new Set(), (0, Support_1.defined)(areNamesInferred));
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
typeNames = nameOrNames;
|
|
271
|
-
}
|
|
272
|
-
return exports.namesTypeAttributeKind.makeAttributes(typeNames);
|
|
273
|
-
}
|
|
274
|
-
exports.makeNamesTypeAttributes = makeNamesTypeAttributes;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TypeAttributeKind, TypeAttributes } from "./TypeAttributes";
|
|
2
|
-
import { JSONSchemaType, JSONSchemaAttributes, Ref } from "../input/JSONSchemaInput";
|
|
3
|
-
import { JSONSchema } from "../input/JSONSchemaStore";
|
|
4
|
-
type URIAttributes = [ReadonlySet<string>, ReadonlySet<string>];
|
|
5
|
-
export declare const uriTypeAttributeKind: TypeAttributeKind<URIAttributes>;
|
|
6
|
-
export declare function uriInferenceAttributesProducer(s: string): TypeAttributes;
|
|
7
|
-
export declare function uriSchemaAttributesProducer(schema: JSONSchema, _ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
|
|
8
|
-
export {};
|