quicktype-core 23.3.25 → 24.0.0
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/dist/input/JSONSchemaInput.js +4 -3
- package/dist/input/io/NodeIO.js +8 -7
- package/dist/language/All.d.ts +1 -0
- package/dist/language/All.js +7 -9
- package/dist/language/CSharp/language.d.ts +3 -3
- package/dist/language/JavaScript/language.d.ts +1 -1
- package/dist/language/Ruby/utils.d.ts +1 -1
- package/dist/language/Rust/language.d.ts +1 -1
- package/dist/language/Swift/language.d.ts +1 -1
- package/dist/language/TypeScriptFlow/language.d.ts +1 -1
- package/dist/support/WindowsPaths.d.ts +2 -0
- package/dist/support/WindowsPaths.js +42 -0
- package/package.json +6 -11
- package/dist/input/io/$fetch.d.ts +0 -3
- package/dist/input/io/$fetch.js +0 -11
|
@@ -25,6 +25,7 @@ const TypeNames_1 = require("../attributes/TypeNames");
|
|
|
25
25
|
const URIAttributes_1 = require("../attributes/URIAttributes");
|
|
26
26
|
const Messages_1 = require("../Messages");
|
|
27
27
|
const Support_1 = require("../support/Support");
|
|
28
|
+
const WindowsPaths_1 = require("../support/WindowsPaths");
|
|
28
29
|
const Type_1 = require("../Type");
|
|
29
30
|
const JSONSchemaStore_1 = require("./JSONSchemaStore");
|
|
30
31
|
const PathElement_1 = require("./PathElement");
|
|
@@ -78,13 +79,13 @@ function normalizeURI(uri) {
|
|
|
78
79
|
// JSONSchemaStore should take a URI, not a string, and if it reads from
|
|
79
80
|
// a file it can decode by itself.
|
|
80
81
|
if (typeof uri === "string") {
|
|
81
|
-
uri = new urijs_1.default(uri);
|
|
82
|
+
uri = new urijs_1.default((0, WindowsPaths_1.fixWindowsPath)(uri));
|
|
82
83
|
}
|
|
83
84
|
return new urijs_1.default(urijs_1.default.decode(uri.clone().normalize().toString()));
|
|
84
85
|
}
|
|
85
86
|
class Ref {
|
|
86
87
|
static root(address) {
|
|
87
|
-
const uri = (0, collection_utils_1.definedMap)(address, (a) => new urijs_1.default(a));
|
|
88
|
+
const uri = (0, collection_utils_1.definedMap)(address, (a) => new urijs_1.default((0, WindowsPaths_1.fixWindowsPath)(a)));
|
|
88
89
|
return new Ref(uri, []);
|
|
89
90
|
}
|
|
90
91
|
static parsePath(path) {
|
|
@@ -112,7 +113,7 @@ class Ref {
|
|
|
112
113
|
return new Ref(uri, elements);
|
|
113
114
|
}
|
|
114
115
|
static parse(ref) {
|
|
115
|
-
return Ref.parseURI(new urijs_1.default(ref), true);
|
|
116
|
+
return Ref.parseURI(new urijs_1.default((0, WindowsPaths_1.fixWindowsPath)(ref)), true);
|
|
116
117
|
}
|
|
117
118
|
constructor(addressURI, path) {
|
|
118
119
|
this.path = path;
|
package/dist/input/io/NodeIO.js
CHANGED
|
@@ -68,8 +68,8 @@ const is_url_1 = __importDefault(require("is-url"));
|
|
|
68
68
|
const readable_stream_1 = require("readable-stream");
|
|
69
69
|
const Messages_1 = require("../../Messages");
|
|
70
70
|
const Support_1 = require("../../support/Support");
|
|
71
|
+
const WindowsPaths_1 = require("../../support/WindowsPaths");
|
|
71
72
|
const get_stream_1 = require("./get-stream");
|
|
72
|
-
const _fetch_1 = require("./$fetch");
|
|
73
73
|
function parseHeaders(httpHeaders) {
|
|
74
74
|
if (!Array.isArray(httpHeaders)) {
|
|
75
75
|
return {};
|
|
@@ -107,10 +107,8 @@ function webStreamChunks(stream) {
|
|
|
107
107
|
// but @types/readable-stream doesn't declare it, hence this cast.
|
|
108
108
|
const ReadableWithFrom = readable_stream_1.Readable;
|
|
109
109
|
function readableFromResponseBody(body) {
|
|
110
|
-
// Native fetch
|
|
111
|
-
//
|
|
112
|
-
// to wrap it. The cross-fetch fallback (node-fetch) already returns a
|
|
113
|
-
// Node stream, which we pass through unchanged.
|
|
110
|
+
// Native fetch returns a WHATWG ReadableStream, which lacks the Node
|
|
111
|
+
// stream API that our consumers rely on, so we have to wrap it.
|
|
114
112
|
if (typeof body.getReader === "function") {
|
|
115
113
|
return ReadableWithFrom.from(webStreamChunks(body), { objectMode: false });
|
|
116
114
|
}
|
|
@@ -129,8 +127,11 @@ function resolveSymbolicLink(filePath) {
|
|
|
129
127
|
function readableFromFileOrURL(fileOrURL, httpHeaders) {
|
|
130
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
129
|
try {
|
|
132
|
-
if (
|
|
133
|
-
|
|
130
|
+
if (fileOrURL.startsWith("file://")) {
|
|
131
|
+
fileOrURL = (0, WindowsPaths_1.filePathFromFileURI)(fileOrURL);
|
|
132
|
+
}
|
|
133
|
+
else if ((0, is_url_1.default)(fileOrURL)) {
|
|
134
|
+
const response = yield globalThis.fetch(fileOrURL, {
|
|
134
135
|
headers: parseHeaders(httpHeaders),
|
|
135
136
|
});
|
|
136
137
|
return readableFromResponseBody((0, ts_necessities_1.defined)(response.body));
|
package/dist/language/All.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ import { FlowTargetLanguage, TypeScriptTargetLanguage } from "./TypeScriptFlow";
|
|
|
28
28
|
import { TypeScriptZodTargetLanguage } from "./TypeScriptZod";
|
|
29
29
|
export declare const all: readonly [CJSONTargetLanguage, CPlusPlusTargetLanguage, CrystalTargetLanguage, CSharpTargetLanguage, DartTargetLanguage, ElixirTargetLanguage, ElmTargetLanguage, FlowTargetLanguage, GoTargetLanguage, HaskellTargetLanguage, JavaTargetLanguage, JavaScriptTargetLanguage, JavaScriptPropTypesTargetLanguage, JSONSchemaTargetLanguage, KotlinTargetLanguage, ObjectiveCTargetLanguage, PhpTargetLanguage, PikeTargetLanguage, PythonTargetLanguage, RubyTargetLanguage, RustTargetLanguage, Scala3TargetLanguage, SmithyTargetLanguage, SwiftTargetLanguage, TypeScriptTargetLanguage, TypeScriptEffectSchemaTargetLanguage, TypeScriptZodTargetLanguage];
|
|
30
30
|
export declare function languageNamed<Name extends LanguageName>(name: Name, targetLanguages?: readonly TargetLanguage[]): LanguageNameMap[Name];
|
|
31
|
+
export declare function languageNamed(name: string, targetLanguages?: readonly TargetLanguage[]): TargetLanguage | undefined;
|
|
31
32
|
export declare function isLanguageName(maybeName: string): maybeName is LanguageName;
|
|
32
33
|
export declare function isLanguageDisplayName(maybeName: string): maybeName is LanguageDisplayName;
|
package/dist/language/All.js
CHANGED
|
@@ -61,17 +61,15 @@ exports.all = [
|
|
|
61
61
|
];
|
|
62
62
|
exports.all;
|
|
63
63
|
function languageNamed(name, targetLanguages = exports.all) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
// Names take precedence over extensions, so that e.g. "js" resolves
|
|
65
|
+
// to JavaScript, not to Flow (whose extension is "js").
|
|
66
|
+
const lowerName = name.toLowerCase();
|
|
67
|
+
const foundLanguage = targetLanguages.find((language) => language.names.includes(lowerName) ||
|
|
68
|
+
language.displayName.toLowerCase() === lowerName);
|
|
69
|
+
return (foundLanguage !== null && foundLanguage !== void 0 ? foundLanguage : targetLanguages.find((language) => language.extension.toLowerCase() === lowerName));
|
|
69
70
|
}
|
|
70
71
|
function isLanguageName(maybeName) {
|
|
71
|
-
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
72
|
+
return languageNamed(maybeName) !== undefined;
|
|
75
73
|
}
|
|
76
74
|
function isLanguageDisplayName(maybeName) {
|
|
77
75
|
if (exports.all.some((lang) => lang.displayName === maybeName)) {
|
|
@@ -58,7 +58,7 @@ export declare const cSharpOptions: {
|
|
|
58
58
|
readonly helpers: false;
|
|
59
59
|
readonly attributes: false;
|
|
60
60
|
};
|
|
61
|
-
}, "
|
|
61
|
+
}, "just-types" | "complete" | "attributes-only" | "just-types-and-namespace">;
|
|
62
62
|
readonly baseclass: EnumOption<"base-class", {
|
|
63
63
|
readonly EntityData: "EntityData";
|
|
64
64
|
readonly Object: undefined;
|
|
@@ -114,7 +114,7 @@ export declare const newtonsoftCSharpOptions: {
|
|
|
114
114
|
readonly helpers: false;
|
|
115
115
|
readonly attributes: false;
|
|
116
116
|
};
|
|
117
|
-
}, "
|
|
117
|
+
}, "just-types" | "complete" | "attributes-only" | "just-types-and-namespace">;
|
|
118
118
|
readonly baseclass: EnumOption<"base-class", {
|
|
119
119
|
readonly EntityData: "EntityData";
|
|
120
120
|
readonly Object: undefined;
|
|
@@ -170,7 +170,7 @@ export declare const systemTextJsonCSharpOptions: {
|
|
|
170
170
|
readonly helpers: false;
|
|
171
171
|
readonly attributes: false;
|
|
172
172
|
};
|
|
173
|
-
}, "
|
|
173
|
+
}, "just-types" | "complete" | "attributes-only" | "just-types-and-namespace">;
|
|
174
174
|
readonly baseclass: EnumOption<"base-class", {
|
|
175
175
|
readonly EntityData: "EntityData";
|
|
176
176
|
readonly Object: undefined;
|
|
@@ -21,7 +21,7 @@ export declare const javaScriptOptions: {
|
|
|
21
21
|
rawType: EnumOption<"raw-type", {
|
|
22
22
|
readonly json: "json";
|
|
23
23
|
readonly any: "any";
|
|
24
|
-
}, "
|
|
24
|
+
}, "any" | "json">;
|
|
25
25
|
};
|
|
26
26
|
export declare const javaScriptLanguageConfig: {
|
|
27
27
|
readonly displayName: "JavaScript";
|
|
@@ -3,7 +3,7 @@ export declare enum Strictness {
|
|
|
3
3
|
Coercible = "Coercible::",
|
|
4
4
|
None = "Types::"
|
|
5
5
|
}
|
|
6
|
-
export declare const forbiddenForObjectProperties: ("false" | "case" | "true" | "
|
|
6
|
+
export declare const forbiddenForObjectProperties: ("false" | "case" | "true" | "default" | "class" | "method" | "next" | "alias" | "type" | "clone" | "then" | "enum" | "end" | "module" | "and" | "break" | "do" | "else" | "for" | "if" | "not" | "or" | "return" | "try" | "while" | "optional" | "begin" | "def" | "elsif" | "ensure" | "extend" | "in" | "nil" | "rescue" | "self" | "super" | "unless" | "until" | "when" | "with" | "yield" | "hash" | "__ENCODING__" | "__FILE__" | "__LINE__" | "BEGIN" | "defined?" | "END" | "redo" | "retry" | "undef" | "__id__" | "__send__" | "define_singleton_method" | "display" | "dup" | "enum_for" | "freeze" | "inspect" | "instance_eval" | "instance_exec" | "instance_variable_defined?" | "instance_variable_get" | "instance_variable_set" | "instance_variables" | "itself" | "methods" | "object_id" | "private_methods" | "protected_methods" | "public_method" | "public_methods" | "public_send" | "remove_instance_variable" | "send" | "singleton_class" | "singleton_method" | "singleton_methods" | "taint" | "tap" | "to_enum" | "to_s" | "trust" | "untaint" | "untrust" | "call" | "constrained_type" | "constrained?" | "constrained" | "constructor" | "gem" | "meta" | "options" | "pristine" | "rule" | "safe" | "to_ast" | "to_json")[];
|
|
7
7
|
export declare const stringEscape: (s: string) => string;
|
|
8
8
|
export declare function simpleNameStyle(original: string, uppercase: boolean): string;
|
|
9
9
|
export declare function memberNameStyle(original: string): string;
|
|
@@ -13,7 +13,7 @@ export declare const rustOptions: {
|
|
|
13
13
|
readonly private: Visibility.Private;
|
|
14
14
|
readonly crate: Visibility.Crate;
|
|
15
15
|
readonly public: Visibility.Public;
|
|
16
|
-
}, "private" | "
|
|
16
|
+
}, "private" | "crate" | "public">;
|
|
17
17
|
readonly deriveDebug: BooleanOption<"derive-debug">;
|
|
18
18
|
readonly deriveClone: BooleanOption<"derive-clone">;
|
|
19
19
|
readonly derivePartialEq: BooleanOption<"derive-partial-eq">;
|
|
@@ -37,7 +37,7 @@ export declare const swiftOptions: {
|
|
|
37
37
|
accessLevel: EnumOption<"access-level", {
|
|
38
38
|
readonly internal: "internal";
|
|
39
39
|
readonly public: "public";
|
|
40
|
-
}, "
|
|
40
|
+
}, "public" | "internal">;
|
|
41
41
|
protocol: EnumOption<"protocol", {
|
|
42
42
|
readonly none: {
|
|
43
43
|
readonly equatable: false;
|
|
@@ -21,7 +21,7 @@ export declare const tsFlowOptions: {
|
|
|
21
21
|
rawType: import("../../RendererOptions").EnumOption<"raw-type", {
|
|
22
22
|
readonly json: "json";
|
|
23
23
|
readonly any: "any";
|
|
24
|
-
}, "
|
|
24
|
+
}, "any" | "json">;
|
|
25
25
|
} & {
|
|
26
26
|
justTypes: BooleanOption<"just-types">;
|
|
27
27
|
nicePropertyNames: BooleanOption<"nice-property-names">;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Windows absolute paths given as schema addresses are carried through the
|
|
3
|
+
// address machinery as "file:" URIs (issue #2869). These two functions are
|
|
4
|
+
// the two halves of that protocol: JSONSchemaInput converts Windows paths to
|
|
5
|
+
// "file:" URIs before urijs parses them, and NodeIO converts "file:" URIs
|
|
6
|
+
// back to file paths when it reads them from disk.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.fixWindowsPath = fixWindowsPath;
|
|
9
|
+
exports.filePathFromFileURI = filePathFromFileURI;
|
|
10
|
+
// Windows absolute paths are not valid URIs: urijs parses the drive letter
|
|
11
|
+
// of e.g. "C:\Users\me\top.schema.json" as a URI scheme (and lowercases it,
|
|
12
|
+
// and treats the backslashes as an opaque path), so relative refs resolve to
|
|
13
|
+
// bogus addresses (issue #2869). Convert drive-letter and UNC paths to
|
|
14
|
+
// "file:" URIs, which NodeIO knows how to read.
|
|
15
|
+
function fixWindowsPath(pathOrURI) {
|
|
16
|
+
if (/^[A-Za-z]:[/\\]/.test(pathOrURI)) {
|
|
17
|
+
// Drive-letter path, e.g. "C:\dir\x.json" -> "file:///C:/dir/x.json"
|
|
18
|
+
return `file:///${pathOrURI.replace(/\\/g, "/")}`;
|
|
19
|
+
}
|
|
20
|
+
if (pathOrURI.startsWith("\\\\")) {
|
|
21
|
+
// UNC path, e.g. "\\server\share\x.json" -> "file://server/share/x.json"
|
|
22
|
+
return `file:${pathOrURI.replace(/\\/g, "/")}`;
|
|
23
|
+
}
|
|
24
|
+
return pathOrURI;
|
|
25
|
+
}
|
|
26
|
+
// We don't use `url.fileURLToPath` because its result is platform-dependent:
|
|
27
|
+
// drive-letter URIs must also be readable on POSIX (as paths relative to the
|
|
28
|
+
// working directory), which is how the tests exercise this, and Node's fs
|
|
29
|
+
// accepts forward slashes on Windows anyway. The addresses were URI-decoded
|
|
30
|
+
// when they were normalized, so there's no percent-decoding to do here.
|
|
31
|
+
function filePathFromFileURI(fileURI) {
|
|
32
|
+
const path = fileURI.slice("file://".length);
|
|
33
|
+
if (/^\/[A-Za-z]:\//.test(path)) {
|
|
34
|
+
// Drive-letter path, e.g. "file:///C:/dir/x.json" -> "C:/dir/x.json"
|
|
35
|
+
return path.slice(1);
|
|
36
|
+
}
|
|
37
|
+
if (!path.startsWith("/")) {
|
|
38
|
+
// UNC path, e.g. "file://server/share/x.json" -> "//server/share/x.json"
|
|
39
|
+
return `//${path}`;
|
|
40
|
+
}
|
|
41
|
+
return path;
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quicktype-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0",
|
|
4
4
|
"description": "The quicktype engine as a library",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"repository": "https://github.com/glideapps/quicktype",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.0.0"
|
|
11
|
+
},
|
|
9
12
|
"scripts": {
|
|
10
13
|
"clean": "rm -rf dist node_modules *~",
|
|
11
|
-
"build": "tsc"
|
|
14
|
+
"build": "node ../../node_modules/typescript/bin/tsc"
|
|
12
15
|
},
|
|
13
16
|
"dependencies": {
|
|
14
17
|
"@glideapps/ts-necessities": "2.2.3",
|
|
15
18
|
"browser-or-node": "^3.0.0",
|
|
16
19
|
"collection-utils": "^1.0.1",
|
|
17
|
-
"cross-fetch": "^4.0.0",
|
|
18
20
|
"is-url": "^1.2.4",
|
|
19
21
|
"js-base64": "^3.7.7",
|
|
20
22
|
"lodash": "^4.18.1",
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@types/browser-or-node": "^1.3.2",
|
|
31
33
|
"@types/is-url": "^1.2.32",
|
|
32
|
-
"@types/node": "~
|
|
34
|
+
"@types/node": "~20.19.0",
|
|
33
35
|
"@types/pako": "^1.0.0",
|
|
34
36
|
"@types/pluralize": "0.0.30",
|
|
35
37
|
"@types/readable-stream": "4.0.10",
|
|
@@ -39,13 +41,6 @@
|
|
|
39
41
|
"command-line-args": "^5.2.1",
|
|
40
42
|
"typescript": "~5.8.3"
|
|
41
43
|
},
|
|
42
|
-
"overrides": {
|
|
43
|
-
"cross-fetch": {
|
|
44
|
-
"node-fetch": {
|
|
45
|
-
"whatwg-url": "^13.0.0"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
44
|
"files": [
|
|
50
45
|
"dist"
|
|
51
46
|
],
|
package/dist/input/io/$fetch.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.fetch = void 0;
|
|
5
|
-
let fetch;
|
|
6
|
-
try {
|
|
7
|
-
exports.fetch = fetch = (_a = global.fetch) !== null && _a !== void 0 ? _a : require("cross-fetch").default;
|
|
8
|
-
}
|
|
9
|
-
catch (_b) {
|
|
10
|
-
exports.fetch = fetch = require("cross-fetch").default;
|
|
11
|
-
}
|