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.
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,8 +0,0 @@
1
- import { StringMap } from "../support/Support";
2
- export type JSONSchema = StringMap | boolean;
3
- export declare abstract class JSONSchemaStore {
4
- private readonly _schemas;
5
- private add;
6
- abstract fetch(_address: string): Promise<JSONSchema | undefined>;
7
- get(address: string, debugPrint: boolean): Promise<JSONSchema | undefined>;
8
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSONSchemaStore = void 0;
4
- const Support_1 = require("../support/Support");
5
- class JSONSchemaStore {
6
- _schemas = new Map();
7
- add(address, schema) {
8
- (0, Support_1.assert)(!this._schemas.has(address), "Cannot set a schema for an address twice");
9
- this._schemas.set(address, schema);
10
- }
11
- async get(address, debugPrint) {
12
- let schema = this._schemas.get(address);
13
- if (schema !== undefined) {
14
- return schema;
15
- }
16
- if (debugPrint) {
17
- console.log(`trying to fetch ${address}`);
18
- }
19
- try {
20
- schema = await this.fetch(address);
21
- }
22
- catch { }
23
- if (schema === undefined) {
24
- if (debugPrint) {
25
- console.log(`couldn't fetch ${address}`);
26
- }
27
- return undefined;
28
- }
29
- if (debugPrint) {
30
- console.log(`successully fetched ${address}`);
31
- }
32
- this.add(address, schema);
33
- return schema;
34
- }
35
- }
36
- exports.JSONSchemaStore = JSONSchemaStore;
@@ -1,5 +0,0 @@
1
- import { JSONSourceData } from "./Inputs";
2
- export declare function sourcesFromPostmanCollection(collectionJSON: string, collectionJSONAddress?: string): {
3
- sources: JSONSourceData<string>[];
4
- description: string | undefined;
5
- };
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sourcesFromPostmanCollection = void 0;
4
- const Support_1 = require("../support/Support");
5
- function isValidJSON(s) {
6
- try {
7
- JSON.parse(s);
8
- return true;
9
- }
10
- catch (error) {
11
- return false;
12
- }
13
- }
14
- function sourcesFromPostmanCollection(collectionJSON, collectionJSONAddress) {
15
- const sources = [];
16
- const descriptions = [];
17
- function processCollection(c) {
18
- if (typeof c !== "object")
19
- return;
20
- if (Array.isArray(c.item)) {
21
- for (const item of c.item) {
22
- processCollection(item);
23
- }
24
- if (typeof c.info === "object" && typeof c.info.description === "string") {
25
- descriptions.push(c.info.description);
26
- }
27
- }
28
- if (typeof c.name === "string" && Array.isArray(c.response)) {
29
- const samples = [];
30
- for (const r of c.response) {
31
- if (typeof r === "object" && typeof r.body === "string" && isValidJSON(r.body)) {
32
- samples.push(r.body);
33
- }
34
- }
35
- if (samples.length > 0) {
36
- const source = { name: c.name, samples };
37
- const sourceDescription = [c.name];
38
- if (typeof c.request === "object") {
39
- const { method, url } = c.request;
40
- if (method !== undefined && typeof url === "object" && url.raw !== undefined) {
41
- sourceDescription.push(`${method} ${url.raw}`);
42
- }
43
- }
44
- if (typeof c.request === "object" && typeof c.request.description === "string") {
45
- sourceDescription.push(c.request.description);
46
- }
47
- source.description = sourceDescription.length === 0 ? undefined : sourceDescription.join("\n\n");
48
- sources.push(source);
49
- }
50
- }
51
- }
52
- processCollection((0, Support_1.parseJSON)(collectionJSON, "Postman collection", collectionJSONAddress));
53
- const joinedDescription = descriptions.join("\n\n").trim();
54
- let description = undefined;
55
- if (joinedDescription !== "") {
56
- description = joinedDescription;
57
- }
58
- return { sources, description };
59
- }
60
- exports.sourcesFromPostmanCollection = sourcesFromPostmanCollection;
@@ -1,3 +0,0 @@
1
- import { Readable } from "readable-stream";
2
- export declare function readableFromFileOrURL(fileOrURL: string, httpHeaders?: string[]): Promise<Readable>;
3
- export declare function readFromFileOrURL(fileOrURL: string, httpHeaders?: string[]): Promise<string>;
@@ -1,87 +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.readFromFileOrURL = exports.readableFromFileOrURL = void 0;
27
- const fs = __importStar(require("fs"));
28
- const browser_or_node_1 = require("browser-or-node");
29
- const get_stream_1 = require("./get-stream");
30
- const ts_necessities_1 = require("@glideapps/ts-necessities");
31
- const index_1 = require("../../index");
32
- // The typings for this module are screwy
33
- const isURL = require("is-url");
34
- const fetch = require("isomorphic-fetch");
35
- function parseHeaders(httpHeaders) {
36
- if (!Array.isArray(httpHeaders)) {
37
- return {};
38
- }
39
- return httpHeaders.reduce(function (result, httpHeader) {
40
- if (httpHeader !== undefined && httpHeader.length > 0) {
41
- const split = httpHeader.indexOf(":");
42
- if (split < 0) {
43
- return (0, index_1.panic)(`Could not parse HTTP header "${httpHeader}".`);
44
- }
45
- const key = httpHeader.slice(0, split).trim();
46
- const value = httpHeader.slice(split + 1).trim();
47
- result[key] = value;
48
- }
49
- return result;
50
- }, {});
51
- }
52
- async function readableFromFileOrURL(fileOrURL, httpHeaders) {
53
- try {
54
- if (isURL(fileOrURL)) {
55
- const response = await fetch(fileOrURL, {
56
- headers: parseHeaders(httpHeaders)
57
- });
58
- return response.body;
59
- }
60
- else if (browser_or_node_1.isNode) {
61
- if (fileOrURL === "-") {
62
- // Cast node readable to isomorphic readable from readable-stream
63
- return process.stdin;
64
- }
65
- const filePath = fs.lstatSync(fileOrURL).isSymbolicLink() ? fs.readlinkSync(fileOrURL) : fileOrURL;
66
- if (fs.existsSync(filePath)) {
67
- // Cast node readable to isomorphic readable from readable-stream
68
- return fs.createReadStream(filePath, "utf8");
69
- }
70
- }
71
- }
72
- catch (e) {
73
- return (0, index_1.messageError)("MiscReadError", { fileOrURL, message: (0, ts_necessities_1.exceptionToString)(e) });
74
- }
75
- return (0, index_1.messageError)("DriverInputFileDoesNotExist", { filename: fileOrURL });
76
- }
77
- exports.readableFromFileOrURL = readableFromFileOrURL;
78
- async function readFromFileOrURL(fileOrURL, httpHeaders) {
79
- const readable = await readableFromFileOrURL(fileOrURL, httpHeaders);
80
- try {
81
- return await (0, get_stream_1.getStream)(readable);
82
- }
83
- catch (e) {
84
- return (0, index_1.messageError)("MiscReadError", { fileOrURL, message: (0, ts_necessities_1.exceptionToString)(e) });
85
- }
86
- }
87
- exports.readFromFileOrURL = readFromFileOrURL;
@@ -1,2 +0,0 @@
1
- import { Options } from ".";
2
- export default function bufferStream(opts: Options): any;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const readable_stream_1 = require("readable-stream");
4
- function bufferStream(opts) {
5
- opts = Object.assign({}, opts);
6
- const array = opts.array;
7
- let encoding = opts.encoding;
8
- const buffer = encoding === "buffer";
9
- let objectMode = false;
10
- if (array) {
11
- objectMode = !(encoding || buffer);
12
- }
13
- else {
14
- encoding = encoding || "utf8";
15
- }
16
- if (buffer) {
17
- encoding = undefined;
18
- }
19
- let len = 0;
20
- const ret = [];
21
- const stream = new readable_stream_1.PassThrough({
22
- objectMode
23
- });
24
- if (encoding) {
25
- stream.setEncoding(encoding);
26
- }
27
- stream.on("data", (chunk) => {
28
- ret.push(chunk);
29
- if (objectMode) {
30
- len = ret.length;
31
- }
32
- else {
33
- len += chunk.length;
34
- }
35
- });
36
- stream.getBufferedValue = () => {
37
- if (array) {
38
- return ret;
39
- }
40
- return buffer ? Buffer.concat(ret, len) : ret.join("");
41
- };
42
- stream.getBufferedLength = () => len;
43
- return stream;
44
- }
45
- exports.default = bufferStream;
@@ -1,9 +0,0 @@
1
- import { Readable } from "readable-stream";
2
- export interface Options {
3
- maxBuffer?: number;
4
- array?: boolean;
5
- encoding?: string;
6
- }
7
- export declare function getStream(inputStream: Readable, opts?: Options): Promise<any>;
8
- export declare function buffer(stream: Readable, opts?: Options): void;
9
- export declare function array(stream: Readable, opts?: Options): void;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.array = exports.buffer = exports.getStream = void 0;
7
- const buffer_stream_1 = __importDefault(require("./buffer-stream"));
8
- function getStream(inputStream, opts = {}) {
9
- if (!inputStream) {
10
- return Promise.reject(new Error("Expected a stream"));
11
- }
12
- opts = Object.assign({ maxBuffer: Infinity }, opts);
13
- const maxBuffer = opts.maxBuffer || Infinity;
14
- let stream;
15
- let clean;
16
- const p = new Promise((resolve, reject) => {
17
- const error = (err) => {
18
- if (err) {
19
- // null check
20
- err.bufferedData = stream.getBufferedValue();
21
- }
22
- reject(err);
23
- };
24
- stream = (0, buffer_stream_1.default)(opts);
25
- inputStream.once("error", error);
26
- inputStream.pipe(stream);
27
- stream.on("data", () => {
28
- if (stream.getBufferedLength() > maxBuffer) {
29
- reject(new Error("maxBuffer exceeded"));
30
- }
31
- });
32
- stream.once("error", error);
33
- stream.on("end", resolve);
34
- clean = () => {
35
- // some streams doesn't implement the `stream.Readable` interface correctly
36
- if (inputStream.unpipe) {
37
- inputStream.unpipe(stream);
38
- }
39
- };
40
- });
41
- p.then(clean, clean);
42
- return p.then(() => stream.getBufferedValue());
43
- }
44
- exports.getStream = getStream;
45
- function buffer(stream, opts = {}) {
46
- getStream(stream, Object.assign({}, opts, { encoding: "buffer" }));
47
- }
48
- exports.buffer = buffer;
49
- function array(stream, opts = {}) {
50
- getStream(stream, Object.assign({}, opts, { array: true }));
51
- }
52
- exports.array = array;
@@ -1,3 +0,0 @@
1
- import { TargetLanguage } from "../TargetLanguage";
2
- export declare const all: TargetLanguage[];
3
- export declare function languageNamed(name: string, targetLanguages?: TargetLanguage[]): TargetLanguage | undefined;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.languageNamed = exports.all = void 0;
4
- const collection_utils_1 = require("collection-utils");
5
- const CSharp_1 = require("./CSharp");
6
- const Golang_1 = require("./Golang");
7
- const CPlusPlus_1 = require("./CPlusPlus");
8
- const Objective_C_1 = require("./Objective-C");
9
- const Java_1 = require("./Java");
10
- const JavaScript_1 = require("./JavaScript");
11
- const JavaScriptPropTypes_1 = require("./JavaScriptPropTypes");
12
- const TypeScriptFlow_1 = require("./TypeScriptFlow");
13
- const Swift_1 = require("./Swift");
14
- const Kotlin_1 = require("./Kotlin");
15
- const Elm_1 = require("./Elm");
16
- const JSONSchema_1 = require("./JSONSchema");
17
- const Rust_1 = require("./Rust");
18
- const Crystal_1 = require("./Crystal");
19
- const ruby_1 = require("./ruby");
20
- const Dart_1 = require("./Dart");
21
- const Python_1 = require("./Python");
22
- const Pike_1 = require("./Pike");
23
- const Haskell_1 = require("./Haskell");
24
- const Php_1 = require("./Php");
25
- exports.all = [
26
- new CSharp_1.CSharpTargetLanguage(),
27
- new Golang_1.GoTargetLanguage(),
28
- new Rust_1.RustTargetLanguage(),
29
- new Crystal_1.CrystalTargetLanguage(),
30
- new CPlusPlus_1.CPlusPlusTargetLanguage(),
31
- new Objective_C_1.ObjectiveCTargetLanguage(),
32
- new Java_1.JavaTargetLanguage(),
33
- new TypeScriptFlow_1.TypeScriptTargetLanguage(),
34
- new JavaScript_1.JavaScriptTargetLanguage(),
35
- new JavaScriptPropTypes_1.JavaScriptPropTypesTargetLanguage(),
36
- new TypeScriptFlow_1.FlowTargetLanguage(),
37
- new Swift_1.SwiftTargetLanguage(),
38
- new Kotlin_1.KotlinTargetLanguage(),
39
- new Elm_1.ElmTargetLanguage(),
40
- new JSONSchema_1.JSONSchemaTargetLanguage(),
41
- new ruby_1.RubyTargetLanguage(),
42
- new Dart_1.DartTargetLanguage(),
43
- new Python_1.PythonTargetLanguage("Python", ["python", "py"], "py"),
44
- new Pike_1.PikeTargetLanguage(),
45
- new Haskell_1.HaskellTargetLanguage(),
46
- new Php_1.PhpTargetLanguage()
47
- ];
48
- function languageNamed(name, targetLanguages) {
49
- if (targetLanguages === undefined) {
50
- targetLanguages = exports.all;
51
- }
52
- const maybeTargetLanguage = (0, collection_utils_1.iterableFind)(targetLanguages, l => l.names.indexOf(name) >= 0 || l.displayName === name);
53
- if (maybeTargetLanguage !== undefined)
54
- return maybeTargetLanguage;
55
- return (0, collection_utils_1.iterableFind)(targetLanguages, l => l.extension === name);
56
- }
57
- exports.languageNamed = languageNamed;
@@ -1,241 +0,0 @@
1
- import { TargetLanguage } from "../TargetLanguage";
2
- import { Type, TypeKind, ClassType, ClassProperty, EnumType, UnionType } from "../Type";
3
- import { Name, Namer } from "../Naming";
4
- import { Sourcelike } from "../Source";
5
- import { NamingStyle } from "../support/Strings";
6
- import { ConvenienceRenderer, ForbiddenWordsInfo } from "../ConvenienceRenderer";
7
- import { StringOption, EnumOption, BooleanOption, Option, OptionValues } from "../RendererOptions";
8
- import { Declaration } from "../DeclarationIR";
9
- import { RenderContext } from "../Renderer";
10
- export declare const cPlusPlusOptions: {
11
- typeSourceStyle: EnumOption<boolean>;
12
- includeLocation: EnumOption<boolean>;
13
- codeFormat: EnumOption<boolean>;
14
- wstring: EnumOption<boolean>;
15
- westConst: EnumOption<boolean>;
16
- justTypes: BooleanOption;
17
- namespace: StringOption;
18
- enumType: StringOption;
19
- typeNamingStyle: EnumOption<NamingStyle>;
20
- memberNamingStyle: EnumOption<NamingStyle>;
21
- enumeratorNamingStyle: EnumOption<NamingStyle>;
22
- boost: BooleanOption;
23
- hideNullOptional: BooleanOption;
24
- };
25
- export declare class CPlusPlusTargetLanguage extends TargetLanguage {
26
- constructor(displayName?: string, names?: string[], extension?: string);
27
- protected getOptions(): Option<any>[];
28
- get supportsUnionsWithBothNumberTypes(): boolean;
29
- get supportsOptionalClassProperties(): boolean;
30
- protected makeRenderer(renderContext: RenderContext, untypedOptionValues: {
31
- [name: string]: any;
32
- }): CPlusPlusRenderer;
33
- }
34
- /**
35
- * To be able to support circles in multiple files -
36
- * e.g. class#A using class#B using class#A (obviously not directly,
37
- * but in vector or in variant) we can forward declare them;
38
- */
39
- export declare enum IncludeKind {
40
- ForwardDeclare = 0,
41
- Include = 1
42
- }
43
- export declare enum GlobalNames {
44
- ClassMemberConstraints = 0,
45
- ClassMemberConstraintException = 1,
46
- ValueTooLowException = 2,
47
- ValueTooHighException = 3,
48
- ValueTooShortException = 4,
49
- ValueTooLongException = 5,
50
- InvalidPatternException = 6,
51
- CheckConstraint = 7
52
- }
53
- export declare enum MemberNames {
54
- MinValue = 0,
55
- GetMinValue = 1,
56
- SetMinValue = 2,
57
- MaxValue = 3,
58
- GetMaxValue = 4,
59
- SetMaxValue = 5,
60
- MinLength = 6,
61
- GetMinLength = 7,
62
- SetMinLength = 8,
63
- MaxLength = 9,
64
- GetMaxLength = 10,
65
- SetMaxLength = 11,
66
- Pattern = 12,
67
- GetPattern = 13,
68
- SetPattern = 14
69
- }
70
- type ConstraintMember = {
71
- name: MemberNames;
72
- getter: MemberNames;
73
- setter: MemberNames;
74
- cppType: string;
75
- cppConstType?: string;
76
- };
77
- export type IncludeRecord = {
78
- kind: IncludeKind | undefined /** How to include that */;
79
- typeKind: TypeKind | undefined /** What exactly to include */;
80
- };
81
- export type TypeRecord = {
82
- name: Name;
83
- type: Type;
84
- level: number;
85
- variant: boolean;
86
- forceInclude: boolean;
87
- };
88
- /**
89
- * We map each and every unique type to a include kind, e.g. how
90
- * to include the given type
91
- */
92
- export type IncludeMap = Map<string, IncludeRecord>;
93
- export type TypeContext = {
94
- needsForwardIndirection: boolean;
95
- needsOptionalIndirection: boolean;
96
- inJsonNamespace: boolean;
97
- };
98
- declare class WrappingCode {
99
- private _start;
100
- private _end;
101
- constructor(start: Sourcelike[], end: Sourcelike[]);
102
- wrap(qualifier: Sourcelike, inner: Sourcelike): Sourcelike;
103
- }
104
- export declare class CPlusPlusRenderer extends ConvenienceRenderer {
105
- private readonly _options;
106
- /**
107
- * For forward declaration practically
108
- */
109
- private _enumType;
110
- private _generatedFiles;
111
- private _currentFilename;
112
- private _allTypeNames;
113
- private readonly _gettersAndSettersForPropertyName;
114
- private readonly _namespaceNames;
115
- private _memberNameStyle;
116
- private _namedTypeNameStyle;
117
- private _generatedGlobalNames;
118
- private _generatedMemberNames;
119
- private _forbiddenGlobalNames;
120
- private readonly _memberNamingFunction;
121
- private _stringType;
122
- private _optionalType;
123
- private _nulloptType;
124
- private _variantType;
125
- private _variantIndexMethodName;
126
- protected readonly typeNamingStyle: NamingStyle;
127
- protected readonly enumeratorNamingStyle: NamingStyle;
128
- constructor(targetLanguage: TargetLanguage, renderContext: RenderContext, _options: OptionValues<typeof cPlusPlusOptions>);
129
- protected getConstraintMembers(): ConstraintMember[];
130
- protected lookupGlobalName(type: GlobalNames): string;
131
- protected lookupMemberName(type: MemberNames): string;
132
- protected addGlobalName(type: GlobalNames): void;
133
- protected addMemberName(type: MemberNames): void;
134
- protected setupGlobalNames(): void;
135
- protected forbiddenNamesForGlobalNamespace(): string[];
136
- protected forbiddenForObjectProperties(_c: ClassType, _className: Name): ForbiddenWordsInfo;
137
- protected forbiddenForEnumCases(_e: EnumType, _enumName: Name): ForbiddenWordsInfo;
138
- protected makeNamedTypeNamer(): Namer;
139
- protected namerForObjectProperty(): Namer;
140
- protected makeUnionMemberNamer(): null;
141
- protected makeEnumCaseNamer(): Namer;
142
- protected makeNamesForPropertyGetterAndSetter(_c: ClassType, _className: Name, _p: ClassProperty, _jsonName: string, name: Name): [Name, Name, Name];
143
- protected makePropertyDependencyNames(c: ClassType, className: Name, p: ClassProperty, jsonName: string, name: Name): Name[];
144
- protected withConst(s: Sourcelike): Sourcelike;
145
- protected emitInclude(global: boolean, name: Sourcelike): void;
146
- protected startFile(basename: Sourcelike, includeHelper?: boolean): void;
147
- protected finishFile(): void;
148
- protected get needsTypeDeclarationBeforeUse(): boolean;
149
- protected canBeForwardDeclared(t: Type): boolean;
150
- protected emitDescriptionBlock(lines: Sourcelike[]): void;
151
- protected emitBlock(line: Sourcelike, withSemicolon: boolean, f: () => void, withIndent?: boolean): void;
152
- protected emitNamespaces(namespaceNames: Iterable<string>, f: () => void): void;
153
- protected cppTypeInOptional(nonNulls: ReadonlySet<Type>, ctx: TypeContext, withIssues: boolean, forceNarrowString: boolean): Sourcelike;
154
- protected variantType(u: UnionType, inJsonNamespace: boolean): Sourcelike;
155
- protected ourQualifier(inJsonNamespace: boolean): Sourcelike;
156
- protected jsonQualifier(inJsonNamespace: boolean): Sourcelike;
157
- protected variantIndirection(needIndirection: boolean, typeSrc: Sourcelike): Sourcelike;
158
- protected cppType(t: Type, ctx: TypeContext, withIssues: boolean, forceNarrowString: boolean, isOptional: boolean): Sourcelike;
159
- /**
160
- * similar to cppType, it practically gathers all the generated types within
161
- * 't'. It also records, whether a given sub-type is part of a variant or not.
162
- */
163
- protected generatedTypes(isClassMember: boolean, theType: Type): TypeRecord[];
164
- protected constraintMember(jsonName: string): string;
165
- protected emitMember(cppType: Sourcelike, name: Sourcelike): void;
166
- protected emitClassMembers(c: ClassType, constraints: Map<string, Sourcelike> | undefined): void;
167
- protected generateClassConstraints(c: ClassType): Map<string, Sourcelike> | undefined;
168
- protected emitClass(c: ClassType, className: Name): void;
169
- protected emitTopLevelHeaders(t: Type, className: Name): void;
170
- protected emitClassHeaders(className: Name): void;
171
- protected emitTopLevelFunction(t: Type, className: Name): void;
172
- protected emitClassFunctions(c: ClassType, className: Name): void;
173
- protected emitEnum(e: EnumType, enumName: Name): void;
174
- protected emitUnionTypedefs(u: UnionType, unionName: Name): void;
175
- protected emitUnionHeaders(u: UnionType): void;
176
- protected emitUnionFunctions(u: UnionType): void;
177
- protected emitEnumHeaders(enumName: Name): void;
178
- private isLargeEnum;
179
- protected emitEnumFunctions(e: EnumType, enumName: Name): void;
180
- protected emitTopLevelTypedef(t: Type, name: Name): void;
181
- protected emitAllUnionFunctions(): void;
182
- protected emitAllUnionHeaders(): void;
183
- protected emitOptionalHelpers(): void;
184
- protected emitDeclaration(decl: Declaration): void;
185
- protected emitGetterSetter(t: string, getterName: string, setterName: string, memberName: string): void;
186
- protected emitConstraintClasses(): void;
187
- protected emitHelperFunctions(): void;
188
- protected emitExtraIncludes(): void;
189
- protected emitHelper(): void;
190
- protected emitTypes(): void;
191
- protected gatherUserNamespaceForwardDecls(): Sourcelike[];
192
- protected gatherNlohmannNamespaceForwardDecls(): Sourcelike[];
193
- protected emitUserNamespaceImpls(): void;
194
- protected emitNlohmannNamespaceImpls(): void;
195
- protected emitGenerators(): void;
196
- protected emitSingleSourceStructure(proposedFilename: string): void;
197
- protected updateIncludes(isClassMember: boolean, includes: IncludeMap, propertyType: Type, _defName: string): void;
198
- protected emitIncludes(c: ClassType | UnionType | EnumType, defName: string): void;
199
- protected emitDefinition(d: ClassType | EnumType | UnionType, defName: Name): void;
200
- protected emitMultiSourceStructure(proposedFilename: string): void;
201
- protected emitSourceStructure(proposedFilename: string): void;
202
- protected isConversionRequired(t: Type): boolean;
203
- NarrowString: {
204
- wrapEncodingChange(_qualifier: Sourcelike[], _fromType: Sourcelike, _toType: Sourcelike, inner: Sourcelike): Sourcelike;
205
- emitHelperFunctions(): void;
206
- _stringType: string;
207
- _constStringType: string;
208
- _smatch: string;
209
- _regex: string;
210
- _stringLiteralPrefix: string;
211
- _toString: WrappingCode;
212
- _encodingClass: Sourcelike;
213
- _encodingFunction: Sourcelike;
214
- getType(): string;
215
- getConstType(): string;
216
- getSMatch(): string;
217
- getRegex(): string;
218
- createStringLiteral(inner: Sourcelike): Sourcelike;
219
- wrapToString(inner: Sourcelike): Sourcelike;
220
- };
221
- WideString: {
222
- superThis: CPlusPlusRenderer;
223
- wrapEncodingChange(qualifier: Sourcelike[], fromType: Sourcelike, toType: Sourcelike, inner: Sourcelike): Sourcelike;
224
- emitHelperFunctions(): void;
225
- _stringType: string;
226
- _constStringType: string;
227
- _smatch: string;
228
- _regex: string;
229
- _stringLiteralPrefix: string;
230
- _toString: WrappingCode;
231
- _encodingClass: Sourcelike;
232
- _encodingFunction: Sourcelike;
233
- getType(): string;
234
- getConstType(): string;
235
- getSMatch(): string;
236
- getRegex(): string;
237
- createStringLiteral(inner: Sourcelike): Sourcelike;
238
- wrapToString(inner: Sourcelike): Sourcelike;
239
- };
240
- }
241
- export {};