quicktype 18.0.6 → 19.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
  3. package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
  4. package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
  5. package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
  6. package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
  7. package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
  8. package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
  9. package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
  10. package/dist/{cli/index.d.ts → index.d.ts} +1 -1
  11. package/dist/{cli/index.js → index.js} +4 -5
  12. package/package.json +61 -77
  13. package/dist/quicktype-core/Annotation.d.ts +0 -8
  14. package/dist/quicktype-core/Annotation.js +0 -16
  15. package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
  16. package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
  17. package/dist/quicktype-core/DateTime.d.ts +0 -10
  18. package/dist/quicktype-core/DateTime.js +0 -57
  19. package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
  20. package/dist/quicktype-core/DeclarationIR.js +0 -167
  21. package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
  22. package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
  23. package/dist/quicktype-core/GatherNames.d.ts +0 -2
  24. package/dist/quicktype-core/GatherNames.js +0 -333
  25. package/dist/quicktype-core/Graph.d.ts +0 -12
  26. package/dist/quicktype-core/Graph.js +0 -220
  27. package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
  28. package/dist/quicktype-core/GraphRewriting.js +0 -421
  29. package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
  30. package/dist/quicktype-core/MakeTransformations.js +0 -193
  31. package/dist/quicktype-core/MarkovChain.d.ts +0 -15
  32. package/dist/quicktype-core/MarkovChain.js +0 -154
  33. package/dist/quicktype-core/Messages.d.ts +0 -294
  34. package/dist/quicktype-core/Messages.js +0 -105
  35. package/dist/quicktype-core/Naming.d.ts +0 -64
  36. package/dist/quicktype-core/Naming.js +0 -356
  37. package/dist/quicktype-core/Renderer.d.ts +0 -50
  38. package/dist/quicktype-core/Renderer.js +0 -274
  39. package/dist/quicktype-core/RendererOptions.d.ts +0 -71
  40. package/dist/quicktype-core/RendererOptions.js +0 -141
  41. package/dist/quicktype-core/Run.d.ts +0 -174
  42. package/dist/quicktype-core/Run.js +0 -393
  43. package/dist/quicktype-core/Source.d.ts +0 -65
  44. package/dist/quicktype-core/Source.js +0 -204
  45. package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
  46. package/dist/quicktype-core/TargetLanguage.js +0 -66
  47. package/dist/quicktype-core/Transformers.d.ts +0 -209
  48. package/dist/quicktype-core/Transformers.js +0 -836
  49. package/dist/quicktype-core/Type.d.ts +0 -206
  50. package/dist/quicktype-core/Type.js +0 -716
  51. package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
  52. package/dist/quicktype-core/TypeBuilder.js +0 -324
  53. package/dist/quicktype-core/TypeGraph.d.ts +0 -75
  54. package/dist/quicktype-core/TypeGraph.js +0 -420
  55. package/dist/quicktype-core/TypeUtils.d.ts +0 -33
  56. package/dist/quicktype-core/TypeUtils.js +0 -230
  57. package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
  58. package/dist/quicktype-core/UnifyClasses.js +0 -159
  59. package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
  60. package/dist/quicktype-core/UnionBuilder.js +0 -282
  61. package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
  62. package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
  63. package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
  64. package/dist/quicktype-core/attributes/Constraints.js +0 -172
  65. package/dist/quicktype-core/attributes/Description.d.ts +0 -9
  66. package/dist/quicktype-core/attributes/Description.js +0 -97
  67. package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
  68. package/dist/quicktype-core/attributes/EnumValues.js +0 -31
  69. package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
  70. package/dist/quicktype-core/attributes/StringTypes.js +0 -189
  71. package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
  72. package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
  73. package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
  74. package/dist/quicktype-core/attributes/TypeNames.js +0 -274
  75. package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
  76. package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
  77. package/dist/quicktype-core/index.d.ts +0 -48
  78. package/dist/quicktype-core/index.js +0 -180
  79. package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
  80. package/dist/quicktype-core/input/CompressedJSON.js +0 -276
  81. package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
  82. package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
  83. package/dist/quicktype-core/input/Inference.d.ts +0 -22
  84. package/dist/quicktype-core/input/Inference.js +0 -240
  85. package/dist/quicktype-core/input/Inputs.d.ts +0 -48
  86. package/dist/quicktype-core/input/Inputs.js +0 -145
  87. package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
  88. package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
  89. package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
  90. package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
  91. package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
  92. package/dist/quicktype-core/input/PostmanCollection.js +0 -60
  93. package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
  94. package/dist/quicktype-core/input/io/NodeIO.js +0 -87
  95. package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
  96. package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
  97. package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
  98. package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
  99. package/dist/quicktype-core/language/All.d.ts +0 -3
  100. package/dist/quicktype-core/language/All.js +0 -57
  101. package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
  102. package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
  103. package/dist/quicktype-core/language/CSharp.d.ts +0 -201
  104. package/dist/quicktype-core/language/CSharp.js +0 -1850
  105. package/dist/quicktype-core/language/Crystal.d.ts +0 -37
  106. package/dist/quicktype-core/language/Crystal.js +0 -337
  107. package/dist/quicktype-core/language/Dart.d.ts +0 -66
  108. package/dist/quicktype-core/language/Dart.js +0 -576
  109. package/dist/quicktype-core/language/Elm.d.ts +0 -58
  110. package/dist/quicktype-core/language/Elm.js +0 -522
  111. package/dist/quicktype-core/language/Golang.d.ts +0 -51
  112. package/dist/quicktype-core/language/Golang.js +0 -460
  113. package/dist/quicktype-core/language/Haskell.d.ts +0 -56
  114. package/dist/quicktype-core/language/Haskell.js +0 -411
  115. package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
  116. package/dist/quicktype-core/language/JSONSchema.js +0 -169
  117. package/dist/quicktype-core/language/Java.d.ts +0 -125
  118. package/dist/quicktype-core/language/Java.js +0 -1081
  119. package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
  120. package/dist/quicktype-core/language/JavaScript.js +0 -435
  121. package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
  122. package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
  123. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
  124. package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
  125. package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
  126. package/dist/quicktype-core/language/Kotlin.js +0 -832
  127. package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
  128. package/dist/quicktype-core/language/Objective-C.js +0 -777
  129. package/dist/quicktype-core/language/Php.d.ts +0 -80
  130. package/dist/quicktype-core/language/Php.js +0 -702
  131. package/dist/quicktype-core/language/Pike.d.ts +0 -37
  132. package/dist/quicktype-core/language/Pike.js +0 -276
  133. package/dist/quicktype-core/language/Python.d.ts +0 -107
  134. package/dist/quicktype-core/language/Python.js +0 -969
  135. package/dist/quicktype-core/language/Rust.d.ts +0 -56
  136. package/dist/quicktype-core/language/Rust.js +0 -309
  137. package/dist/quicktype-core/language/Swift.d.ts +0 -96
  138. package/dist/quicktype-core/language/Swift.js +0 -1211
  139. package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
  140. package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
  141. package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
  142. package/dist/quicktype-core/language/ruby/index.js +0 -557
  143. package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
  144. package/dist/quicktype-core/language/ruby/keywords.js +0 -358
  145. package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
  146. package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
  147. package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
  148. package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
  149. package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
  150. package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
  151. package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
  152. package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
  153. package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
  154. package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
  155. package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
  156. package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
  157. package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
  158. package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
  159. package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
  160. package/dist/quicktype-core/support/Acronyms.js +0 -1128
  161. package/dist/quicktype-core/support/Chance.d.ts +0 -38
  162. package/dist/quicktype-core/support/Chance.js +0 -2146
  163. package/dist/quicktype-core/support/Converters.d.ts +0 -6
  164. package/dist/quicktype-core/support/Converters.js +0 -16
  165. package/dist/quicktype-core/support/Strings.d.ts +0 -44
  166. package/dist/quicktype-core/support/Strings.js +0 -525
  167. package/dist/quicktype-core/support/Support.d.ts +0 -29
  168. package/dist/quicktype-core/support/Support.js +0 -162
  169. package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
  170. package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
  171. package/dist/quicktype-graphql-input/index.d.ts +0 -17
  172. package/dist/quicktype-graphql-input/index.js +0 -407
  173. package/dist/quicktype-typescript-input/index.d.ts +0 -2
  174. package/dist/quicktype-typescript-input/index.js +0 -98
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.accessorNamesAttributeProducer = exports.makeAccessorNames = exports.unionMemberName = exports.makeUnionMemberNamesAttribute = exports.unionMemberNamesTypeAttributeKind = exports.makeUnionIdentifierAttribute = exports.unionIdentifierTypeAttributeKind = exports.getAccessorName = exports.enumCaseNames = exports.objectPropertyNames = exports.lookupKey = exports.accessorNamesTypeAttributeKind = 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 Messages_1 = require("../Messages");
8
- class AccessorNamesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
9
- constructor() {
10
- super("accessorNames");
11
- }
12
- makeInferred(_) {
13
- return undefined;
14
- }
15
- }
16
- exports.accessorNamesTypeAttributeKind = new AccessorNamesTypeAttributeKind();
17
- // Returns [name, isFixed].
18
- function getFromEntry(entry, language) {
19
- if (typeof entry === "string")
20
- return [entry, false];
21
- const maybeForLanguage = entry.get(language);
22
- if (maybeForLanguage !== undefined)
23
- return [maybeForLanguage, true];
24
- const maybeWildcard = entry.get("*");
25
- if (maybeWildcard !== undefined)
26
- return [maybeWildcard, false];
27
- return undefined;
28
- }
29
- function lookupKey(accessors, key, language) {
30
- const entry = accessors.get(key);
31
- if (entry === undefined)
32
- return undefined;
33
- return getFromEntry(entry, language);
34
- }
35
- exports.lookupKey = lookupKey;
36
- function objectPropertyNames(o, language) {
37
- const accessors = exports.accessorNamesTypeAttributeKind.tryGetInAttributes(o.getAttributes());
38
- const map = o.getProperties();
39
- if (accessors === undefined)
40
- return (0, collection_utils_1.mapMap)(map, _ => undefined);
41
- return (0, collection_utils_1.mapMap)(map, (_cp, n) => lookupKey(accessors, n, language));
42
- }
43
- exports.objectPropertyNames = objectPropertyNames;
44
- function enumCaseNames(e, language) {
45
- const accessors = exports.accessorNamesTypeAttributeKind.tryGetInAttributes(e.getAttributes());
46
- if (accessors === undefined)
47
- return (0, collection_utils_1.mapMap)(e.cases.entries(), _ => undefined);
48
- return (0, collection_utils_1.mapMap)(e.cases.entries(), c => lookupKey(accessors, c, language));
49
- }
50
- exports.enumCaseNames = enumCaseNames;
51
- function getAccessorName(names, original) {
52
- const maybeName = names.get(original);
53
- if (maybeName === undefined)
54
- return [undefined, false];
55
- return maybeName;
56
- }
57
- exports.getAccessorName = getAccessorName;
58
- // Union members can be recombined and reordered, and unions are combined as well, so
59
- // we can't just store an array of accessor entries in a union, one array entry for each
60
- // union member. Instead, we give each union in the origin type graph a union identifier,
61
- // and each union member type gets a map from union identifiers to accessor entries.
62
- // That way, no matter how the types are recombined, if we find a union member, we can look
63
- // up its union's identifier(s), and then look up the member's accessor entries for that
64
- // identifier. Of course we might find more than one, potentially conflicting.
65
- class UnionIdentifierTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
66
- constructor() {
67
- super("unionIdentifier");
68
- }
69
- combine(arr) {
70
- return (0, collection_utils_1.setUnionManyInto)(new Set(), arr);
71
- }
72
- makeInferred(_) {
73
- return new Set();
74
- }
75
- }
76
- exports.unionIdentifierTypeAttributeKind = new UnionIdentifierTypeAttributeKind();
77
- let nextUnionIdentifier = 0;
78
- function makeUnionIdentifierAttribute() {
79
- const attributes = exports.unionIdentifierTypeAttributeKind.makeAttributes(new Set([nextUnionIdentifier]));
80
- nextUnionIdentifier += 1;
81
- return attributes;
82
- }
83
- exports.makeUnionIdentifierAttribute = makeUnionIdentifierAttribute;
84
- class UnionMemberNamesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
85
- constructor() {
86
- super("unionMemberNames");
87
- }
88
- combine(arr) {
89
- const result = new Map();
90
- for (const m of arr) {
91
- (0, collection_utils_1.mapMergeInto)(result, m);
92
- }
93
- return result;
94
- }
95
- }
96
- exports.unionMemberNamesTypeAttributeKind = new UnionMemberNamesTypeAttributeKind();
97
- function makeUnionMemberNamesAttribute(unionAttributes, entry) {
98
- const identifiers = (0, Support_1.defined)(exports.unionIdentifierTypeAttributeKind.tryGetInAttributes(unionAttributes));
99
- const map = (0, collection_utils_1.mapFromIterable)(identifiers, _ => entry);
100
- return exports.unionMemberNamesTypeAttributeKind.makeAttributes(map);
101
- }
102
- exports.makeUnionMemberNamesAttribute = makeUnionMemberNamesAttribute;
103
- function unionMemberName(u, member, language) {
104
- const identifiers = exports.unionIdentifierTypeAttributeKind.tryGetInAttributes(u.getAttributes());
105
- if (identifiers === undefined)
106
- return [undefined, false];
107
- const memberNames = exports.unionMemberNamesTypeAttributeKind.tryGetInAttributes(member.getAttributes());
108
- if (memberNames === undefined)
109
- return [undefined, false];
110
- const names = new Set();
111
- const fixedNames = new Set();
112
- for (const i of identifiers) {
113
- const maybeEntry = memberNames.get(i);
114
- if (maybeEntry === undefined)
115
- continue;
116
- const maybeName = getFromEntry(maybeEntry, language);
117
- if (maybeName === undefined)
118
- continue;
119
- const [name, isNameFixed] = maybeName;
120
- if (isNameFixed) {
121
- fixedNames.add(name);
122
- }
123
- else {
124
- names.add(name);
125
- }
126
- }
127
- let size;
128
- let isFixed;
129
- let first = (0, collection_utils_1.iterableFirst)(fixedNames);
130
- if (first !== undefined) {
131
- size = fixedNames.size;
132
- isFixed = true;
133
- }
134
- else {
135
- first = (0, collection_utils_1.iterableFirst)(names);
136
- if (first === undefined)
137
- return [undefined, false];
138
- size = names.size;
139
- isFixed = false;
140
- }
141
- (0, Messages_1.messageAssert)(size === 1, "SchemaMoreThanOneUnionMemberName", { names: Array.from(names) });
142
- return [first, isFixed];
143
- }
144
- exports.unionMemberName = unionMemberName;
145
- function isAccessorEntry(x) {
146
- if (typeof x === "string") {
147
- return true;
148
- }
149
- return (0, Support_1.isStringMap)(x, (v) => typeof v === "string");
150
- }
151
- function makeAccessorEntry(ae) {
152
- if (typeof ae === "string")
153
- return ae;
154
- return (0, collection_utils_1.mapFromObject)(ae);
155
- }
156
- function makeAccessorNames(x) {
157
- // FIXME: Do proper error reporting
158
- const stringMap = (0, Support_1.checkStringMap)(x, isAccessorEntry);
159
- return (0, collection_utils_1.mapMap)((0, collection_utils_1.mapFromObject)(stringMap), makeAccessorEntry);
160
- }
161
- exports.makeAccessorNames = makeAccessorNames;
162
- function accessorNamesAttributeProducer(schema, canonicalRef, _types, cases) {
163
- if (typeof schema !== "object")
164
- return undefined;
165
- const maybeAccessors = schema["qt-accessors"];
166
- if (maybeAccessors === undefined)
167
- return undefined;
168
- if (cases === undefined) {
169
- return { forType: exports.accessorNamesTypeAttributeKind.makeAttributes(makeAccessorNames(maybeAccessors)) };
170
- }
171
- else {
172
- const identifierAttribute = makeUnionIdentifierAttribute();
173
- const accessors = (0, Support_1.checkArray)(maybeAccessors, isAccessorEntry);
174
- (0, Messages_1.messageAssert)(cases.length === accessors.length, "SchemaWrongAccessorEntryArrayLength", {
175
- operation: "oneOf",
176
- ref: canonicalRef.push("oneOf")
177
- });
178
- const caseAttributes = accessors.map(accessor => makeUnionMemberNamesAttribute(identifierAttribute, makeAccessorEntry(accessor)));
179
- return { forUnion: identifierAttribute, forCases: caseAttributes };
180
- }
181
- }
182
- exports.accessorNamesAttributeProducer = accessorNamesAttributeProducer;
@@ -1,38 +0,0 @@
1
- import { Type, TypeKind } from "../Type";
2
- import { TypeAttributeKind } from "./TypeAttributes";
3
- import { JSONSchemaType, JSONSchemaAttributes, Ref } from "../input/JSONSchemaInput";
4
- import { JSONSchema } from "../input/JSONSchemaStore";
5
- export type MinMaxConstraint = [number | undefined, number | undefined];
6
- export declare class MinMaxConstraintTypeAttributeKind extends TypeAttributeKind<MinMaxConstraint> {
7
- private _typeKinds;
8
- private _minSchemaProperty;
9
- private _maxSchemaProperty;
10
- constructor(name: string, _typeKinds: Set<TypeKind>, _minSchemaProperty: string, _maxSchemaProperty: string);
11
- get inIdentity(): boolean;
12
- combine(arr: MinMaxConstraint[]): MinMaxConstraint | undefined;
13
- intersect(arr: MinMaxConstraint[]): MinMaxConstraint | undefined;
14
- makeInferred(_: MinMaxConstraint): undefined;
15
- addToSchema(schema: {
16
- [name: string]: unknown;
17
- }, t: Type, attr: MinMaxConstraint): void;
18
- stringify([min, max]: MinMaxConstraint): string;
19
- }
20
- export declare const minMaxTypeAttributeKind: TypeAttributeKind<MinMaxConstraint>;
21
- export declare const minMaxLengthTypeAttributeKind: TypeAttributeKind<MinMaxConstraint>;
22
- export declare function minMaxAttributeProducer(schema: JSONSchema, _ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
23
- export declare function minMaxLengthAttributeProducer(schema: JSONSchema, _ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
24
- export declare function minMaxValueForType(t: Type): MinMaxConstraint | undefined;
25
- export declare function minMaxLengthForType(t: Type): MinMaxConstraint | undefined;
26
- export declare class PatternTypeAttributeKind extends TypeAttributeKind<string> {
27
- constructor();
28
- get inIdentity(): boolean;
29
- combine(arr: string[]): string;
30
- intersect(_arr: string[]): string | undefined;
31
- makeInferred(_: string): undefined;
32
- addToSchema(schema: {
33
- [name: string]: unknown;
34
- }, t: Type, attr: string): void;
35
- }
36
- export declare const patternTypeAttributeKind: TypeAttributeKind<string>;
37
- export declare function patternAttributeProducer(schema: JSONSchema, _ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
38
- export declare function patternForType(t: Type): string | undefined;
@@ -1,172 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patternForType = exports.patternAttributeProducer = exports.patternTypeAttributeKind = exports.PatternTypeAttributeKind = exports.minMaxLengthForType = exports.minMaxValueForType = exports.minMaxLengthAttributeProducer = exports.minMaxAttributeProducer = exports.minMaxLengthTypeAttributeKind = exports.minMaxTypeAttributeKind = exports.MinMaxConstraintTypeAttributeKind = void 0;
4
- const TypeAttributes_1 = require("./TypeAttributes");
5
- const Support_1 = require("../support/Support");
6
- const Messages_1 = require("../Messages");
7
- function checkMinMaxConstraint(minmax) {
8
- const [min, max] = minmax;
9
- if (typeof min === "number" && typeof max === "number" && min > max) {
10
- return (0, Messages_1.messageError)("MiscInvalidMinMaxConstraint", { min, max });
11
- }
12
- if (min === undefined && max === undefined) {
13
- return undefined;
14
- }
15
- return minmax;
16
- }
17
- class MinMaxConstraintTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
18
- _typeKinds;
19
- _minSchemaProperty;
20
- _maxSchemaProperty;
21
- constructor(name, _typeKinds, _minSchemaProperty, _maxSchemaProperty) {
22
- super(name);
23
- this._typeKinds = _typeKinds;
24
- this._minSchemaProperty = _minSchemaProperty;
25
- this._maxSchemaProperty = _maxSchemaProperty;
26
- }
27
- get inIdentity() {
28
- return true;
29
- }
30
- combine(arr) {
31
- (0, Support_1.assert)(arr.length > 0);
32
- let [min, max] = arr[0];
33
- for (let i = 1; i < arr.length; i++) {
34
- const [otherMin, otherMax] = arr[i];
35
- if (typeof min === "number" && typeof otherMin === "number") {
36
- min = Math.min(min, otherMin);
37
- }
38
- else {
39
- min = undefined;
40
- }
41
- if (typeof max === "number" && typeof otherMax === "number") {
42
- max = Math.max(max, otherMax);
43
- }
44
- else {
45
- max = undefined;
46
- }
47
- }
48
- return checkMinMaxConstraint([min, max]);
49
- }
50
- intersect(arr) {
51
- (0, Support_1.assert)(arr.length > 0);
52
- let [min, max] = arr[0];
53
- for (let i = 1; i < arr.length; i++) {
54
- const [otherMin, otherMax] = arr[i];
55
- if (typeof min === "number" && typeof otherMin === "number") {
56
- min = Math.max(min, otherMin);
57
- }
58
- else if (min === undefined) {
59
- min = otherMin;
60
- }
61
- if (typeof max === "number" && typeof otherMax === "number") {
62
- max = Math.min(max, otherMax);
63
- }
64
- else if (max === undefined) {
65
- max = otherMax;
66
- }
67
- }
68
- return checkMinMaxConstraint([min, max]);
69
- }
70
- makeInferred(_) {
71
- return undefined;
72
- }
73
- addToSchema(schema, t, attr) {
74
- if (this._typeKinds.has(t.kind))
75
- return;
76
- const [min, max] = attr;
77
- if (min !== undefined) {
78
- schema[this._minSchemaProperty] = min;
79
- }
80
- if (max !== undefined) {
81
- schema[this._maxSchemaProperty] = max;
82
- }
83
- }
84
- stringify([min, max]) {
85
- return `${min}-${max}`;
86
- }
87
- }
88
- exports.MinMaxConstraintTypeAttributeKind = MinMaxConstraintTypeAttributeKind;
89
- exports.minMaxTypeAttributeKind = new MinMaxConstraintTypeAttributeKind("minMax", new Set(["integer", "double"]), "minimum", "maximum");
90
- exports.minMaxLengthTypeAttributeKind = new MinMaxConstraintTypeAttributeKind("minMaxLength", new Set(["string"]), "minLength", "maxLength");
91
- function producer(schema, minProperty, maxProperty) {
92
- if (!(typeof schema === "object"))
93
- return undefined;
94
- let min = undefined;
95
- let max = undefined;
96
- if (typeof schema[minProperty] === "number") {
97
- min = schema[minProperty];
98
- }
99
- if (typeof schema[maxProperty] === "number") {
100
- max = schema[maxProperty];
101
- }
102
- if (min === undefined && max === undefined)
103
- return undefined;
104
- return [min, max];
105
- }
106
- function minMaxAttributeProducer(schema, _ref, types) {
107
- if (!types.has("number") && !types.has("integer"))
108
- return undefined;
109
- const maybeMinMax = producer(schema, "minimum", "maximum");
110
- if (maybeMinMax === undefined)
111
- return undefined;
112
- return { forNumber: exports.minMaxTypeAttributeKind.makeAttributes(maybeMinMax) };
113
- }
114
- exports.minMaxAttributeProducer = minMaxAttributeProducer;
115
- function minMaxLengthAttributeProducer(schema, _ref, types) {
116
- if (!types.has("string"))
117
- return undefined;
118
- const maybeMinMaxLength = producer(schema, "minLength", "maxLength");
119
- if (maybeMinMaxLength === undefined)
120
- return undefined;
121
- return { forString: exports.minMaxLengthTypeAttributeKind.makeAttributes(maybeMinMaxLength) };
122
- }
123
- exports.minMaxLengthAttributeProducer = minMaxLengthAttributeProducer;
124
- function minMaxValueForType(t) {
125
- return exports.minMaxTypeAttributeKind.tryGetInAttributes(t.getAttributes());
126
- }
127
- exports.minMaxValueForType = minMaxValueForType;
128
- function minMaxLengthForType(t) {
129
- return exports.minMaxLengthTypeAttributeKind.tryGetInAttributes(t.getAttributes());
130
- }
131
- exports.minMaxLengthForType = minMaxLengthForType;
132
- class PatternTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
133
- constructor() {
134
- super("pattern");
135
- }
136
- get inIdentity() {
137
- return true;
138
- }
139
- combine(arr) {
140
- (0, Support_1.assert)(arr.length > 0);
141
- return arr.map(p => `(${p})`).join("|");
142
- }
143
- intersect(_arr) {
144
- /** FIXME!!! what is the intersection of regexps? */
145
- return undefined;
146
- }
147
- makeInferred(_) {
148
- return undefined;
149
- }
150
- addToSchema(schema, t, attr) {
151
- if (t.kind !== "string")
152
- return;
153
- schema.pattern = attr;
154
- }
155
- }
156
- exports.PatternTypeAttributeKind = PatternTypeAttributeKind;
157
- exports.patternTypeAttributeKind = new PatternTypeAttributeKind();
158
- function patternAttributeProducer(schema, _ref, types) {
159
- if (!(typeof schema === "object"))
160
- return undefined;
161
- if (!types.has("string"))
162
- return undefined;
163
- const patt = schema.pattern;
164
- if (typeof patt !== "string")
165
- return undefined;
166
- return { forString: exports.patternTypeAttributeKind.makeAttributes(patt) };
167
- }
168
- exports.patternAttributeProducer = patternAttributeProducer;
169
- function patternForType(t) {
170
- return exports.patternTypeAttributeKind.tryGetInAttributes(t.getAttributes());
171
- }
172
- exports.patternForType = patternForType;
@@ -1,9 +0,0 @@
1
- import { TypeAttributeKind } from "./TypeAttributes";
2
- import { JSONSchemaType, Ref, JSONSchemaAttributes } from "../input/JSONSchemaInput";
3
- import { JSONSchema } from "../input/JSONSchemaStore";
4
- export declare function addDescriptionToSchema(schema: {
5
- [name: string]: unknown;
6
- }, description: Iterable<string> | undefined): void;
7
- export declare const descriptionTypeAttributeKind: TypeAttributeKind<ReadonlySet<string>>;
8
- export declare const propertyDescriptionsTypeAttributeKind: TypeAttributeKind<Map<string, ReadonlySet<string>>>;
9
- export declare function descriptionAttributeProducer(schema: JSONSchema, ref: Ref, types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.descriptionAttributeProducer = exports.propertyDescriptionsTypeAttributeKind = exports.descriptionTypeAttributeKind = exports.addDescriptionToSchema = void 0;
4
- const collection_utils_1 = require("collection-utils");
5
- const TypeAttributes_1 = require("./TypeAttributes");
6
- const JSONSchemaInput_1 = require("../input/JSONSchemaInput");
7
- function addDescriptionToSchema(schema, description) {
8
- if (description === undefined)
9
- return;
10
- schema.description = Array.from(description).join("\n");
11
- }
12
- exports.addDescriptionToSchema = addDescriptionToSchema;
13
- class DescriptionTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
14
- constructor() {
15
- super("description");
16
- }
17
- combine(attrs) {
18
- return (0, collection_utils_1.setUnionManyInto)(new Set(), attrs);
19
- }
20
- makeInferred(_) {
21
- return undefined;
22
- }
23
- addToSchema(schema, _t, attrs) {
24
- addDescriptionToSchema(schema, attrs);
25
- }
26
- stringify(descriptions) {
27
- let result = (0, collection_utils_1.iterableFirst)(descriptions);
28
- if (result === undefined)
29
- return undefined;
30
- if (result.length > 5 + 3) {
31
- result = `${result.slice(0, 5)}...`;
32
- }
33
- if (descriptions.size > 1) {
34
- result = `${result}, ...`;
35
- }
36
- return result;
37
- }
38
- }
39
- exports.descriptionTypeAttributeKind = new DescriptionTypeAttributeKind();
40
- class PropertyDescriptionsTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
41
- constructor() {
42
- super("propertyDescriptions");
43
- }
44
- combine(attrs) {
45
- // FIXME: Implement this with mutable sets
46
- const result = new Map();
47
- for (const attr of attrs) {
48
- (0, collection_utils_1.mapMergeWithInto)(result, (sa, sb) => (0, collection_utils_1.setUnion)(sa, sb), attr);
49
- }
50
- return result;
51
- }
52
- makeInferred(_) {
53
- return undefined;
54
- }
55
- stringify(propertyDescriptions) {
56
- if (propertyDescriptions.size === 0)
57
- return undefined;
58
- return `prop descs: ${propertyDescriptions.size}`;
59
- }
60
- }
61
- exports.propertyDescriptionsTypeAttributeKind = new PropertyDescriptionsTypeAttributeKind();
62
- function isPropertiesKey(el) {
63
- return el.kind === JSONSchemaInput_1.PathElementKind.KeyOrIndex && el.key === "properties";
64
- }
65
- function descriptionAttributeProducer(schema, ref, types) {
66
- if (!(typeof schema === "object"))
67
- return undefined;
68
- let description = TypeAttributes_1.emptyTypeAttributes;
69
- let propertyDescription = TypeAttributes_1.emptyTypeAttributes;
70
- const pathLength = ref.path.length;
71
- if (types.has("object") ||
72
- (0, collection_utils_1.setSubtract)(types, ["null"]).size > 1 ||
73
- schema.enum !== undefined ||
74
- pathLength < 2 ||
75
- !isPropertiesKey(ref.path[pathLength - 2])) {
76
- const maybeDescription = schema.description;
77
- if (typeof maybeDescription === "string") {
78
- description = exports.descriptionTypeAttributeKind.makeAttributes(new Set([maybeDescription]));
79
- }
80
- }
81
- if (types.has("object") && typeof schema.properties === "object") {
82
- const propertyDescriptions = (0, collection_utils_1.mapFilterMap)((0, collection_utils_1.mapFromObject)(schema.properties), propSchema => {
83
- if (typeof propSchema === "object") {
84
- const desc = propSchema.description;
85
- if (typeof desc === "string") {
86
- return new Set([desc]);
87
- }
88
- }
89
- return undefined;
90
- });
91
- if (propertyDescriptions.size > 0) {
92
- propertyDescription = exports.propertyDescriptionsTypeAttributeKind.makeAttributes(propertyDescriptions);
93
- }
94
- }
95
- return { forType: description, forObject: propertyDescription };
96
- }
97
- exports.descriptionAttributeProducer = descriptionAttributeProducer;
@@ -1,8 +0,0 @@
1
- import { AccessorNames } from "./AccessorNames";
2
- import { EnumType } from "../Type";
3
- import { TypeAttributeKind } from "./TypeAttributes";
4
- import { JSONSchema } from "../input/JSONSchemaStore";
5
- import { Ref, JSONSchemaType, JSONSchemaAttributes } from "../input/JSONSchemaInput";
6
- export declare const enumValuesTypeAttributeKind: TypeAttributeKind<AccessorNames>;
7
- export declare function enumCaseValues(e: EnumType, language: string): Map<string, [string, boolean] | undefined>;
8
- export declare function enumValuesAttributeProducer(schema: JSONSchema, _canonicalRef: Ref | undefined, _types: Set<JSONSchemaType>): JSONSchemaAttributes | undefined;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enumValuesAttributeProducer = exports.enumCaseValues = exports.enumValuesTypeAttributeKind = void 0;
4
- const collection_utils_1 = require("collection-utils");
5
- const AccessorNames_1 = require("./AccessorNames");
6
- const TypeAttributes_1 = require("./TypeAttributes");
7
- class EnumValuesTypeAttributeKind extends TypeAttributes_1.TypeAttributeKind {
8
- constructor() {
9
- super("enumValues");
10
- }
11
- makeInferred(_) {
12
- return undefined;
13
- }
14
- }
15
- exports.enumValuesTypeAttributeKind = new EnumValuesTypeAttributeKind();
16
- function enumCaseValues(e, language) {
17
- const enumValues = exports.enumValuesTypeAttributeKind.tryGetInAttributes(e.getAttributes());
18
- if (enumValues === undefined)
19
- return (0, collection_utils_1.mapMap)(e.cases.entries(), _ => undefined);
20
- return (0, collection_utils_1.mapMap)(e.cases.entries(), c => (0, AccessorNames_1.lookupKey)(enumValues, c, language));
21
- }
22
- exports.enumCaseValues = enumCaseValues;
23
- function enumValuesAttributeProducer(schema, _canonicalRef, _types) {
24
- if (typeof schema !== "object")
25
- return undefined;
26
- const maybeEnumValues = schema["qt-enum-values"];
27
- if (maybeEnumValues === undefined)
28
- return undefined;
29
- return { forType: exports.enumValuesTypeAttributeKind.makeAttributes((0, AccessorNames_1.makeAccessorNames)(maybeEnumValues)) };
30
- }
31
- exports.enumValuesAttributeProducer = enumValuesAttributeProducer;
@@ -1,28 +0,0 @@
1
- import { TypeAttributeKind } from "./TypeAttributes";
2
- import { StringTypeMapping } from "../TypeBuilder";
3
- import { TransformedStringTypeKind } from "../Type";
4
- import { DateTimeRecognizer } from "../DateTime";
5
- export declare class StringTypes {
6
- readonly cases: ReadonlyMap<string, number> | undefined;
7
- readonly transformations: ReadonlySet<TransformedStringTypeKind>;
8
- static readonly unrestricted: StringTypes;
9
- static fromCase(s: string, count: number): StringTypes;
10
- static fromCases(cases: string[]): StringTypes;
11
- constructor(cases: ReadonlyMap<string, number> | undefined, transformations: ReadonlySet<TransformedStringTypeKind>);
12
- get isRestricted(): boolean;
13
- union(othersArray: StringTypes[], startIndex: number): StringTypes;
14
- intersect(othersArray: StringTypes[], startIndex: number): StringTypes;
15
- applyStringTypeMapping(mapping: StringTypeMapping): StringTypes;
16
- equals(other: any): boolean;
17
- hashCode(): number;
18
- toString(): string;
19
- }
20
- export declare const stringTypesTypeAttributeKind: TypeAttributeKind<StringTypes>;
21
- /**
22
- * JSON inference calls this function to figure out whether a given string is to be
23
- * transformed into a higher level type. Must return undefined if not, otherwise the
24
- * type kind of the transformed string type.
25
- *
26
- * @param s The string for which to determine the transformed string type kind.
27
- */
28
- export declare function inferTransformedStringTypeKindForString(s: string, recognizer: DateTimeRecognizer): TransformedStringTypeKind | undefined;