@fumadocs/api-docs 0.0.3 → 0.1.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/css/generated/shared.css +1 -1
- package/dist/components/accordion.d.ts +9 -6
- package/dist/components/accordion.js +16 -12
- package/dist/components/collapsible.d.ts +16 -0
- package/dist/components/collapsible.js +16 -0
- package/dist/components/dialog.d.ts +9 -9
- package/dist/components/dialog.js +12 -12
- package/dist/components/input.d.ts +8 -3
- package/dist/components/input.js +3 -4
- package/dist/components/playground/inputs.js +42 -30
- package/dist/components/popover.d.ts +15 -0
- package/dist/components/popover.js +23 -0
- package/dist/components/schema/client.js +34 -32
- package/dist/components/select-tab.js +3 -5
- package/dist/components/select.d.ts +46 -12
- package/dist/components/select.js +78 -66
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +1 -1
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -1
- package/dist/ref-parser/bundle.d.ts +10 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/bundle.js +76 -6
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/normalize-args.js +2 -2
- package/dist/ref-parser/options.d.ts +28 -0
- package/dist/ref-parser/options.js +27 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parse.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/json.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/parsers/yaml.js +6 -12
- package/dist/ref-parser/pointer.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/pointer.js +16 -54
- package/dist/ref-parser/ref.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/ref.js +7 -49
- package/dist/ref-parser/refs.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/refs.js +4 -41
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolve-external.js +3 -3
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/resolvers/file.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/types/index.d.ts +8 -40
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/convert-path-to-posix.js +1 -1
- package/dist/ref-parser/util/errors.d.ts +1 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/errors.js +16 -34
- package/dist/ref-parser/util/is-windows.js +5 -0
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/maybe.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/next.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/plugins.js +1 -1
- package/dist/{node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib → ref-parser}/util/schema-resources.js +1 -1
- package/dist/ref-parser/util/url.js +206 -0
- package/dist/schema/bundle.d.ts +1 -1
- package/dist/schema/bundle.js +1 -1
- package/dist/schema/ref.d.ts +3 -1
- package/dist/schema/ref.js +1 -1
- package/dist/schema/sample.js +5 -7
- package/dist/utils/cn.js +1 -1
- package/dist/utils/deep-merge.js +8 -0
- package/package.json +12 -14
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.d.ts +0 -157
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.d.ts +0 -166
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.d.ts +0 -96
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.d.ts +0 -190
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.d.ts +0 -134
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -121
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.d.ts +0 -34
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.6_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +0 -381
|
@@ -1,50 +1,18 @@
|
|
|
1
1
|
import { getHash, safePointerToPath, stripHash } from "./util/url.js";
|
|
2
2
|
import { InvalidPointerError, isHandledError, normalizeError } from "./util/errors.js";
|
|
3
3
|
import Pointer, { nullSymbol } from "./pointer.js";
|
|
4
|
-
|
|
4
|
+
import { isPlainObject } from "../utils/is-plain-object.js";
|
|
5
|
+
import { mergeDeep } from "../utils/deep-merge.js";
|
|
6
|
+
//#region src/ref-parser/ref.ts
|
|
5
7
|
/**
|
|
6
8
|
* This class represents a single JSON reference and its resolved value.
|
|
7
9
|
*
|
|
8
10
|
* @class
|
|
9
11
|
*/
|
|
10
12
|
var $Ref = class $Ref {
|
|
11
|
-
/**
|
|
12
|
-
* The file path or URL of the referenced file.
|
|
13
|
-
* This path is relative to the path of the main JSON schema file.
|
|
14
|
-
*
|
|
15
|
-
* This path does NOT contain document fragments (JSON pointers). It always references an ENTIRE file.
|
|
16
|
-
* Use methods such as {@link $Ref#get}, {@link $Ref#resolve}, and {@link $Ref#exists} to get
|
|
17
|
-
* specific JSON pointers within the file.
|
|
18
|
-
*
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
|
-
path;
|
|
22
|
-
/**
|
|
23
|
-
* The resolved value of the JSON reference.
|
|
24
|
-
* Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
|
|
25
|
-
*
|
|
26
|
-
* @type {?*}
|
|
27
|
-
*/
|
|
28
|
-
value;
|
|
29
|
-
/**
|
|
30
|
-
* The {@link $Refs} object that contains this {@link $Ref} object.
|
|
31
|
-
*
|
|
32
|
-
* @type {$Refs}
|
|
33
|
-
*/
|
|
34
|
-
$refs;
|
|
35
|
-
/**
|
|
36
|
-
* Indicates the type of {@link $Ref#path} (e.g. "file", "http", etc.)
|
|
37
|
-
*/
|
|
38
|
-
pathType;
|
|
39
|
-
/**
|
|
40
|
-
* Whether this document/resource should use JSON Schema 2019-09+ nested $id scope semantics.
|
|
41
|
-
*/
|
|
42
|
-
dynamicIdScope = false;
|
|
43
|
-
/**
|
|
44
|
-
* List of all errors. Undefined if no errors.
|
|
45
|
-
*/
|
|
46
|
-
errors = [];
|
|
47
13
|
constructor($refs) {
|
|
14
|
+
this.dynamicIdScope = false;
|
|
15
|
+
this.errors = [];
|
|
48
16
|
this.$refs = $refs;
|
|
49
17
|
}
|
|
50
18
|
/**
|
|
@@ -220,28 +188,18 @@ var $Ref = class $Ref {
|
|
|
220
188
|
* @param options - The options
|
|
221
189
|
* @returns - Returns the dereferenced value
|
|
222
190
|
*/
|
|
223
|
-
static dereference($ref, resolvedValue,
|
|
191
|
+
static dereference($ref, resolvedValue, _options) {
|
|
224
192
|
if (resolvedValue && typeof resolvedValue === "object" && $Ref.isExtended$Ref($ref)) {
|
|
225
193
|
const merged = {};
|
|
226
194
|
for (const key of Object.keys($ref)) if (key !== "$ref") merged[key] = $ref[key];
|
|
227
|
-
const mergeKeys = options?.dereference?.mergeKeys ?? true;
|
|
228
195
|
for (const _key of Object.keys(resolvedValue)) {
|
|
229
196
|
const key = _key;
|
|
230
197
|
if (!(key in merged)) merged[key] = resolvedValue[key];
|
|
231
|
-
else if (
|
|
198
|
+
else if (isPlainObject(merged[key]) && isPlainObject(resolvedValue[key])) merged[key] = mergeDeep(resolvedValue[key], merged[key]);
|
|
232
199
|
}
|
|
233
200
|
return merged;
|
|
234
201
|
} else return resolvedValue;
|
|
235
202
|
}
|
|
236
203
|
};
|
|
237
|
-
function deepMerge(target, source) {
|
|
238
|
-
if (typeof target !== "object" || target === null) return source;
|
|
239
|
-
if (typeof source !== "object" || source === null) return source;
|
|
240
|
-
const output = Array.isArray(target) ? [...target] : { ...target };
|
|
241
|
-
for (const key of Object.keys(source)) if (Array.isArray(source[key])) output[key] = [...source[key]];
|
|
242
|
-
else if (typeof source[key] === "object" && source[key] !== null) output[key] = deepMerge(target[key], source[key]);
|
|
243
|
-
else output[key] = source[key];
|
|
244
|
-
return output;
|
|
245
|
-
}
|
|
246
204
|
//#endregion
|
|
247
205
|
export { $Ref as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import convertPathToPosix from "./util/convert-path-to-posix.js";
|
|
2
2
|
import { resolve, stripHash, toFileSystemPath } from "./util/url.js";
|
|
3
3
|
import $Ref from "./ref.js";
|
|
4
|
-
//#region
|
|
4
|
+
//#region src/ref-parser/refs.ts
|
|
5
5
|
/**
|
|
6
6
|
* When you call the resolve method, the value that gets passed to the callback function (or Promise) is a $Refs object. This same object is accessible via the parser.$refs property of $RefParser objects.
|
|
7
7
|
*
|
|
@@ -10,12 +10,6 @@ import $Ref from "./ref.js";
|
|
|
10
10
|
* See https://apidevtools.com/json-schema-ref-parser/docs/refs.html
|
|
11
11
|
*/
|
|
12
12
|
var $Refs = class {
|
|
13
|
-
/**
|
|
14
|
-
* This property is true if the schema contains any circular references. You may want to check this property before serializing the dereferenced schema as JSON, since JSON.stringify() does not support circular references by default.
|
|
15
|
-
*
|
|
16
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/refs.html#circular
|
|
17
|
-
*/
|
|
18
|
-
circular;
|
|
19
13
|
/**
|
|
20
14
|
* Returns the paths/URLs of all the files in your schema (including the main schema file).
|
|
21
15
|
*
|
|
@@ -136,22 +130,10 @@ var $Refs = class {
|
|
|
136
130
|
if (!$ref) throw new Error(`Error resolving $ref pointer "${path}". \n"${stripHash(absPath)}" not found.`);
|
|
137
131
|
return $ref.resolve(absPath, options, path, pathFromRoot);
|
|
138
132
|
}
|
|
139
|
-
/**
|
|
140
|
-
* A map of paths/urls to {@link $Ref} objects
|
|
141
|
-
*
|
|
142
|
-
* @type {object}
|
|
143
|
-
* @protected
|
|
144
|
-
*/
|
|
145
|
-
_$refs = {};
|
|
146
|
-
_aliases = {};
|
|
147
|
-
/**
|
|
148
|
-
* The {@link $Ref} object that is the root of the JSON schema.
|
|
149
|
-
*
|
|
150
|
-
* @type {$Ref}
|
|
151
|
-
* @protected
|
|
152
|
-
*/
|
|
153
|
-
_root$Ref;
|
|
154
133
|
constructor() {
|
|
134
|
+
this._$refs = {};
|
|
135
|
+
this._aliases = {};
|
|
136
|
+
this.toJSON = this.values;
|
|
155
137
|
/**
|
|
156
138
|
* Indicates whether the schema contains any circular references.
|
|
157
139
|
*
|
|
@@ -162,25 +144,6 @@ var $Refs = class {
|
|
|
162
144
|
this._aliases = {};
|
|
163
145
|
this._root$Ref = null;
|
|
164
146
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Returns the paths of all the files/URLs that are referenced by the JSON schema,
|
|
167
|
-
* including the schema itself.
|
|
168
|
-
*
|
|
169
|
-
* @param [types] - Only return paths of the given types ("file", "http", etc.)
|
|
170
|
-
* @returns
|
|
171
|
-
*/
|
|
172
|
-
/**
|
|
173
|
-
* Returns the map of JSON references and their resolved values.
|
|
174
|
-
*
|
|
175
|
-
* @param [types] - Only return references of the given types ("file", "http", etc.)
|
|
176
|
-
* @returns
|
|
177
|
-
*/
|
|
178
|
-
/**
|
|
179
|
-
* Returns a POJO (plain old JavaScript object) for serialization as JSON.
|
|
180
|
-
*
|
|
181
|
-
* @returns {object}
|
|
182
|
-
*/
|
|
183
|
-
toJSON = this.values;
|
|
184
147
|
_getRef(path) {
|
|
185
148
|
const withoutHash = stripHash(path);
|
|
186
149
|
return this._$refs[withoutHash] || this._aliases[withoutHash];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHash, resolve, safePointerToPath, stripHash } from "./util/url.js";
|
|
2
2
|
import { isHandledError } from "./util/errors.js";
|
|
3
3
|
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
4
|
import Pointer from "./pointer.js";
|
|
5
5
|
import $Ref from "./ref.js";
|
|
6
6
|
import parse from "./parse.js";
|
|
7
|
-
//#region
|
|
7
|
+
//#region src/ref-parser/resolve-external.ts
|
|
8
8
|
/**
|
|
9
9
|
* Crawls the JSON schema, finds all external JSON references, and resolves their values.
|
|
10
10
|
* This method does not mutate the JSON schema. The resolved values are added to {@link $RefParser#$refs}.
|
|
@@ -71,7 +71,7 @@ function crawl(obj, path, scopeBase, dynamicIdScope, $refs, options, seen, exter
|
|
|
71
71
|
* including nested references that are contained in externally-referenced files.
|
|
72
72
|
*/
|
|
73
73
|
async function resolve$Ref($ref, path, scopeBase, dynamicIdScope, $refs, options) {
|
|
74
|
-
const resolutionBase =
|
|
74
|
+
const resolutionBase = dynamicIdScope ? scopeBase : path;
|
|
75
75
|
const resolvedPath = resolve(resolutionBase, $ref.$ref);
|
|
76
76
|
const withoutHash = stripHash(resolvedPath);
|
|
77
77
|
const ref = $refs._get$Ref(withoutHash);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isFileSystemPath, toFileSystemPath } from "../util/url.js";
|
|
2
2
|
import { ResolverError } from "../util/errors.js";
|
|
3
|
-
//#region
|
|
3
|
+
//#region src/ref-parser/resolvers/file.ts
|
|
4
4
|
var file_default = {
|
|
5
5
|
/**
|
|
6
6
|
* The order that this resolver will run, in relation to other resolvers.
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $
|
|
3
|
-
import { JSONSchema4, JSONSchema4Object, JSONSchema6, JSONSchema6Object, JSONSchema7, JSONSchema7Object } from "json-schema";
|
|
1
|
+
import { JSONSchema } from "json-schema-typed/draft-2020-12";
|
|
2
|
+
import { JSONSchema as JSONSchema$1 } from "json-schema-typed/draft-07";
|
|
4
3
|
|
|
5
|
-
//#region
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type SchemaCallback<S extends object = JSONSchema> = (err: Error | null, schema?: S | object | null) => any;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/options.html
|
|
12
|
-
*/
|
|
13
|
-
interface HTTPResolverOptions<S extends object = JSONSchema> extends Partial<ResolverOptions<S>> {
|
|
14
|
-
/**
|
|
15
|
-
* You can specify any HTTP headers that should be sent when downloading files. For example, some servers may require you to set the `Accept` or `Referrer` header.
|
|
16
|
-
*/
|
|
17
|
-
headers?: RequestInit["headers"] | null;
|
|
18
|
-
/**
|
|
19
|
-
* The amount of time (in milliseconds) to wait for a response from the server when downloading files. The default is 5 seconds.
|
|
20
|
-
*/
|
|
21
|
-
timeout?: number;
|
|
22
|
-
/**
|
|
23
|
-
* The maximum number of HTTP redirects to follow per file. The default is 5. To disable automatic following of redirects, set this to zero.
|
|
24
|
-
*/
|
|
25
|
-
redirects?: number;
|
|
26
|
-
/**
|
|
27
|
-
* Set this to `true` if you're downloading files from a CORS-enabled server that requires authentication
|
|
28
|
-
*/
|
|
29
|
-
withCredentials?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Set this to `false` if you want to allow unsafe URLs (e.g., `127.0.0.1`, localhost, and other internal URLs).
|
|
32
|
-
*/
|
|
33
|
-
safeUrlResolver?: boolean;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* JSON Schema `$Ref` Parser comes with built-in resolvers for HTTP and HTTPS URLs, as well as local filesystem paths (when running in Node.js). You can add your own custom resolvers to support additional protocols, or even replace any of the built-in resolvers with your own custom implementation.
|
|
37
|
-
*
|
|
38
|
-
* See https://apidevtools.com/json-schema-ref-parser/docs/plugins/resolvers.html
|
|
39
|
-
*/
|
|
40
|
-
interface ResolverOptions<S extends object = JSONSchema> {
|
|
4
|
+
//#region src/ref-parser/types/index.d.ts
|
|
5
|
+
type JSONSchemaObject = Exclude<JSONSchema$1, boolean> | Exclude<JSONSchema, boolean>;
|
|
6
|
+
type JSONSchema$2 = JSONSchemaObject;
|
|
7
|
+
type SchemaCallback<S extends object = JSONSchema$2> = (err: Error | null, schema?: S | object | null) => any;
|
|
8
|
+
interface ResolverOptions<S extends object = JSONSchema$2> {
|
|
41
9
|
name?: string;
|
|
42
10
|
/**
|
|
43
11
|
* All resolvers have an order property, even the built-in resolvers. If you don't specify an order property, then your resolver will run last. Specifying `order: 1`, like we did in this example, will make your resolver run first. Or you can squeeze your resolver in-between some of the built-in resolvers. For example, `order: 101` would make it run after the file resolver, but before the HTTP resolver. You can see the order of all the built-in resolvers by looking at their source code.
|
|
@@ -130,4 +98,4 @@ interface FileInfo {
|
|
|
130
98
|
data: string | Buffer;
|
|
131
99
|
}
|
|
132
100
|
//#endregion
|
|
133
|
-
export {
|
|
101
|
+
export { FileInfo, JSONSchema$2 as JSONSchema, JSONSchemaObject, Plugin, ResolverOptions, SchemaCallback };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region src/ref-parser/util/convert-path-to-posix.ts
|
|
2
2
|
const win32Sep = "\\";
|
|
3
3
|
function convertPathToPosix(filePath) {
|
|
4
4
|
if (filePath.startsWith("\\\\?\\")) return filePath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getHash, stripHash, toFileSystemPath } from "./url.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/util/errors.ts
|
|
3
3
|
const nonJsonTypes = [
|
|
4
4
|
"function",
|
|
5
5
|
"symbol",
|
|
@@ -40,33 +40,27 @@ function getDeepKeys(obj, omit = []) {
|
|
|
40
40
|
return uniqueKeys;
|
|
41
41
|
}
|
|
42
42
|
var JSONParserError = class extends Error {
|
|
43
|
-
name;
|
|
44
|
-
message;
|
|
45
|
-
source;
|
|
46
|
-
path;
|
|
47
|
-
code;
|
|
48
43
|
constructor(message, source) {
|
|
49
44
|
super();
|
|
45
|
+
this.toJSON = toJSON.bind(this);
|
|
50
46
|
this.code = "EUNKNOWN";
|
|
51
47
|
this.name = "JSONParserError";
|
|
52
48
|
this.message = message;
|
|
53
49
|
this.source = source;
|
|
54
50
|
this.path = null;
|
|
55
51
|
}
|
|
56
|
-
toJSON = toJSON.bind(this);
|
|
57
52
|
get footprint() {
|
|
58
53
|
return `${this.path}+${this.source}+${this.code}+${this.message}`;
|
|
59
54
|
}
|
|
60
55
|
};
|
|
61
56
|
var JSONParserErrorGroup = class JSONParserErrorGroup extends Error {
|
|
62
|
-
files;
|
|
63
57
|
constructor(parser) {
|
|
64
58
|
super();
|
|
59
|
+
this.toJSON = toJSON.bind(this);
|
|
65
60
|
this.files = parser;
|
|
66
61
|
this.name = "JSONParserErrorGroup";
|
|
67
62
|
this.message = `${this.errors.length} error${this.errors.length > 1 ? "s" : ""} occurred while reading '${toFileSystemPath(parser.$refs._root$Ref.path)}'`;
|
|
68
63
|
}
|
|
69
|
-
toJSON = toJSON.bind(this);
|
|
70
64
|
static getParserErrors(parser) {
|
|
71
65
|
const errors = [];
|
|
72
66
|
for (const $ref of Object.values(parser.$refs._$refs)) if ($ref.errors) errors.push(...$ref.errors);
|
|
@@ -77,62 +71,50 @@ var JSONParserErrorGroup = class JSONParserErrorGroup extends Error {
|
|
|
77
71
|
}
|
|
78
72
|
};
|
|
79
73
|
var ParserError = class extends JSONParserError {
|
|
80
|
-
code = "EPARSER";
|
|
81
|
-
name = "ParserError";
|
|
82
74
|
constructor(message, source) {
|
|
83
75
|
super(`Error parsing ${source}: ${message}`, source);
|
|
76
|
+
this.code = "EPARSER";
|
|
77
|
+
this.name = "ParserError";
|
|
84
78
|
}
|
|
85
79
|
};
|
|
86
80
|
var UnmatchedParserError = class extends JSONParserError {
|
|
87
|
-
code = "EUNMATCHEDPARSER";
|
|
88
|
-
name = "UnmatchedParserError";
|
|
89
81
|
constructor(source) {
|
|
90
82
|
super(`Could not find parser for "${source}"`, source);
|
|
83
|
+
this.code = "EUNMATCHEDPARSER";
|
|
84
|
+
this.name = "UnmatchedParserError";
|
|
91
85
|
}
|
|
92
86
|
};
|
|
93
87
|
var ResolverError = class extends JSONParserError {
|
|
94
|
-
code = "ERESOLVER";
|
|
95
|
-
name = "ResolverError";
|
|
96
|
-
ioErrorCode;
|
|
97
88
|
constructor(ex, source) {
|
|
98
89
|
super(ex.message || `Error reading file "${source}"`, source);
|
|
90
|
+
this.code = "ERESOLVER";
|
|
91
|
+
this.name = "ResolverError";
|
|
99
92
|
if ("code" in ex) this.ioErrorCode = String(ex.code);
|
|
100
93
|
}
|
|
101
94
|
};
|
|
102
95
|
var UnmatchedResolverError = class extends JSONParserError {
|
|
103
|
-
code = "EUNMATCHEDRESOLVER";
|
|
104
|
-
name = "UnmatchedResolverError";
|
|
105
96
|
constructor(source) {
|
|
106
97
|
super(`Could not find resolver for "${source}"`, source);
|
|
98
|
+
this.code = "EUNMATCHEDRESOLVER";
|
|
99
|
+
this.name = "UnmatchedResolverError";
|
|
107
100
|
}
|
|
108
101
|
};
|
|
109
102
|
var MissingPointerError = class extends JSONParserError {
|
|
110
|
-
code = "EMISSINGPOINTER";
|
|
111
|
-
name = "MissingPointerError";
|
|
112
|
-
targetToken;
|
|
113
|
-
targetRef;
|
|
114
|
-
targetFound;
|
|
115
|
-
parentPath;
|
|
116
103
|
constructor(token, path, targetRef, targetFound, parentPath) {
|
|
117
104
|
super(`Missing $ref pointer "${getHash(path)}". Token "${token}" does not exist.`, stripHash(path));
|
|
105
|
+
this.code = "EMISSINGPOINTER";
|
|
106
|
+
this.name = "MissingPointerError";
|
|
118
107
|
this.targetToken = token;
|
|
119
108
|
this.targetRef = targetRef;
|
|
120
109
|
this.targetFound = targetFound;
|
|
121
110
|
this.parentPath = parentPath;
|
|
122
111
|
}
|
|
123
112
|
};
|
|
124
|
-
var TimeoutError = class extends JSONParserError {
|
|
125
|
-
code = "ETIMEOUT";
|
|
126
|
-
name = "TimeoutError";
|
|
127
|
-
constructor(timeout) {
|
|
128
|
-
super(`Dereferencing timeout reached: ${timeout}ms`);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
113
|
var InvalidPointerError = class extends JSONParserError {
|
|
132
|
-
code = "EUNMATCHEDRESOLVER";
|
|
133
|
-
name = "InvalidPointerError";
|
|
134
114
|
constructor(pointer, path) {
|
|
135
115
|
super(`Invalid $ref pointer "${pointer}". Pointers must begin with "#/"`, stripHash(path));
|
|
116
|
+
this.code = "EUNMATCHEDRESOLVER";
|
|
117
|
+
this.name = "InvalidPointerError";
|
|
136
118
|
}
|
|
137
119
|
};
|
|
138
120
|
function isHandledError(err) {
|
|
@@ -143,4 +125,4 @@ function normalizeError(err) {
|
|
|
143
125
|
return err;
|
|
144
126
|
}
|
|
145
127
|
//#endregion
|
|
146
|
-
export { InvalidPointerError, JSONParserError, JSONParserErrorGroup, MissingPointerError, ParserError, ResolverError,
|
|
128
|
+
export { InvalidPointerError, JSONParserError, JSONParserErrorGroup, MissingPointerError, ParserError, ResolverError, UnmatchedParserError, UnmatchedResolverError, getDeepKeys, isHandledError, normalizeError, toJSON };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import next_default from "./next.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/util/maybe.ts
|
|
3
3
|
function maybe(cb, promise) {
|
|
4
4
|
if (cb) {
|
|
5
5
|
promise.then(function(result) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region src/ref-parser/util/next.ts
|
|
2
2
|
function makeNext() {
|
|
3
3
|
if (typeof process === "object" && typeof process.nextTick === "function") return process.nextTick;
|
|
4
4
|
else if (typeof setImmediate === "function") return setImmediate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region src/ref-parser/util/plugins.ts
|
|
2
2
|
/**
|
|
3
3
|
* Returns the given plugins as an array, rather than an object map.
|
|
4
4
|
* All other methods in this module expect an array of plugins rather than an object map.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "./url.js";
|
|
2
|
-
//#region
|
|
2
|
+
//#region src/ref-parser/util/schema-resources.ts
|
|
3
3
|
function getSchemaBasePath(basePath, value) {
|
|
4
4
|
const schemaId = getSchemaId(value);
|
|
5
5
|
return schemaId ? resolve(basePath, schemaId) : basePath;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import convertPathToPosix from "./convert-path-to-posix.js";
|
|
2
|
+
import { decodeInternalRef } from "../../schema/ref.js";
|
|
3
|
+
import { isWindows } from "./is-windows.js";
|
|
4
|
+
//#region src/ref-parser/util/url.ts
|
|
5
|
+
const forwardSlashPattern = /\//g;
|
|
6
|
+
const protocolPattern = /^(\w{2,}):\/\//i;
|
|
7
|
+
const isAbsoluteWin32Path = /^[a-zA-Z]:[\\/]/;
|
|
8
|
+
const urlEncodePatterns = [[/\?/g, "%3F"], [/#/g, "%23"]];
|
|
9
|
+
const urlDecodePatterns = [
|
|
10
|
+
/%23/g,
|
|
11
|
+
"#",
|
|
12
|
+
/%24/g,
|
|
13
|
+
"$",
|
|
14
|
+
/%26/g,
|
|
15
|
+
"&",
|
|
16
|
+
/%2C/g,
|
|
17
|
+
",",
|
|
18
|
+
/%40/g,
|
|
19
|
+
"@"
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
|
|
23
|
+
*
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function resolve(from, to) {
|
|
27
|
+
const fromUrl = new URL(convertPathToPosix(from), "https://aaa.nonexistanturl.com");
|
|
28
|
+
const resolvedUrl = new URL(convertPathToPosix(to), fromUrl);
|
|
29
|
+
const endSpaces = to.match(/(\s*)$/)?.[1] || "";
|
|
30
|
+
if (resolvedUrl.hostname === "aaa.nonexistanturl.com") {
|
|
31
|
+
const { pathname, search, hash } = resolvedUrl;
|
|
32
|
+
return pathname + search + decodeURIComponent(hash) + endSpaces;
|
|
33
|
+
}
|
|
34
|
+
const resolved = resolvedUrl.toString() + endSpaces;
|
|
35
|
+
if (resolved.includes("#")) {
|
|
36
|
+
const [base, hash] = resolved.split("#", 2);
|
|
37
|
+
return base + "#" + decodeURIComponent(hash || "");
|
|
38
|
+
}
|
|
39
|
+
return resolved;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the current working directory (in Node) or the current page URL (in browsers).
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
function cwd() {
|
|
47
|
+
if (typeof window !== "undefined" && window.location && window.location.href) {
|
|
48
|
+
const href = window.location.href;
|
|
49
|
+
if (!href || !href.startsWith("http")) try {
|
|
50
|
+
new URL(href);
|
|
51
|
+
return href;
|
|
52
|
+
} catch {
|
|
53
|
+
return "/";
|
|
54
|
+
}
|
|
55
|
+
return href;
|
|
56
|
+
}
|
|
57
|
+
if (typeof process !== "undefined" && process.cwd) {
|
|
58
|
+
const path = process.cwd();
|
|
59
|
+
const lastChar = path.slice(-1);
|
|
60
|
+
if (lastChar === "/" || lastChar === "\\") return path;
|
|
61
|
+
else return path + "/";
|
|
62
|
+
}
|
|
63
|
+
return "/";
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns the protocol of the given URL, or `undefined` if it has no protocol.
|
|
67
|
+
*
|
|
68
|
+
* @param path
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
function getProtocol(path) {
|
|
72
|
+
const match = protocolPattern.exec(path || "");
|
|
73
|
+
if (match) return match[1].toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the lowercased file extension of the given URL,
|
|
77
|
+
* or an empty string if it has no extension.
|
|
78
|
+
*
|
|
79
|
+
* @param path
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
function getExtension(path) {
|
|
83
|
+
const lastDot = path.lastIndexOf(".");
|
|
84
|
+
if (lastDot >= 0) return stripQuery(path.substring(lastDot).toLowerCase());
|
|
85
|
+
return "";
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Removes the query, if any, from the given path.
|
|
89
|
+
*
|
|
90
|
+
* @param path
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
function stripQuery(path) {
|
|
94
|
+
const queryIndex = path.indexOf("?");
|
|
95
|
+
if (queryIndex >= 0) path = path.substring(0, queryIndex);
|
|
96
|
+
return path;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns the hash (URL fragment), of the given path.
|
|
100
|
+
* If there is no hash, then the root hash ("#") is returned.
|
|
101
|
+
*
|
|
102
|
+
* @param path
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
function getHash(path) {
|
|
106
|
+
if (!path) return "#";
|
|
107
|
+
const hashIndex = path.indexOf("#");
|
|
108
|
+
if (hashIndex >= 0) return path.substring(hashIndex);
|
|
109
|
+
return "#";
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Removes the hash (URL fragment), if any, from the given path.
|
|
113
|
+
*
|
|
114
|
+
* @param path
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
function stripHash(path) {
|
|
118
|
+
if (!path) return "";
|
|
119
|
+
const hashIndex = path.indexOf("#");
|
|
120
|
+
if (hashIndex >= 0) path = path.substring(0, hashIndex);
|
|
121
|
+
return path;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Determines whether the given path is a filesystem path.
|
|
125
|
+
* This includes "file://" URLs.
|
|
126
|
+
*
|
|
127
|
+
* @param path
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
function isFileSystemPath(path) {
|
|
131
|
+
if (typeof window !== "undefined" || typeof process !== "undefined" && process.browser) return false;
|
|
132
|
+
const protocol = getProtocol(path);
|
|
133
|
+
return protocol === void 0 || protocol === "file";
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Converts a filesystem path to a properly-encoded URL.
|
|
137
|
+
*
|
|
138
|
+
* This is intended to handle situations where JSON Schema $Ref Parser is called
|
|
139
|
+
* with a filesystem path that contains characters which are not allowed in URLs.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* The following filesystem paths would be converted to the following URLs:
|
|
143
|
+
*
|
|
144
|
+
* <"!@#$%^&*+=?'>.json ==> %3C%22!@%23$%25%5E&*+=%3F\'%3E.json
|
|
145
|
+
* C:\\My Documents\\File (1).json ==> C:/My%20Documents/File%20(1).json
|
|
146
|
+
* file://Project #42/file.json ==> file://Project%20%2342/file.json
|
|
147
|
+
*
|
|
148
|
+
* @param path
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
function fromFileSystemPath(path) {
|
|
152
|
+
if (isWindows()) {
|
|
153
|
+
const projectDir = cwd();
|
|
154
|
+
const upperPath = path.toUpperCase();
|
|
155
|
+
const posixUpper = convertPathToPosix(projectDir).toUpperCase();
|
|
156
|
+
const hasProjectDir = upperPath.includes(posixUpper);
|
|
157
|
+
const hasProjectUri = upperPath.includes(posixUpper);
|
|
158
|
+
const isAbsolutePath = isAbsoluteWin32Path.test(path) || path.startsWith("http://") || path.startsWith("https://") || path.startsWith("file://");
|
|
159
|
+
if (!(hasProjectDir || hasProjectUri || isAbsolutePath) && !projectDir.startsWith("http")) {
|
|
160
|
+
const join = (a, b) => {
|
|
161
|
+
if (a.endsWith("/") || a.endsWith("\\")) return a + b;
|
|
162
|
+
else return a + "/" + b;
|
|
163
|
+
};
|
|
164
|
+
path = join(projectDir, path);
|
|
165
|
+
}
|
|
166
|
+
path = convertPathToPosix(path);
|
|
167
|
+
}
|
|
168
|
+
path = encodeURI(path);
|
|
169
|
+
for (const pattern of urlEncodePatterns) path = path.replace(pattern[0], pattern[1]);
|
|
170
|
+
return path;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Converts a URL to a local filesystem path.
|
|
174
|
+
*/
|
|
175
|
+
function toFileSystemPath(path, keepFileProtocol) {
|
|
176
|
+
path = path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25");
|
|
177
|
+
path = decodeURI(path);
|
|
178
|
+
for (let i = 0; i < urlDecodePatterns.length; i += 2) path = path.replace(urlDecodePatterns[i], urlDecodePatterns[i + 1]);
|
|
179
|
+
let isFileUrl = path.toLowerCase().startsWith("file://");
|
|
180
|
+
if (isFileUrl) {
|
|
181
|
+
path = path.replace(/^file:\/\//, "").replace(/^\//, "");
|
|
182
|
+
if (isWindows() && path[1] === "/") path = `${path[0]}:${path.substring(1)}`;
|
|
183
|
+
if (keepFileProtocol) path = "file:///" + path;
|
|
184
|
+
else {
|
|
185
|
+
isFileUrl = false;
|
|
186
|
+
path = isWindows() ? path : "/" + path;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (isWindows() && !isFileUrl) {
|
|
190
|
+
path = path.replace(forwardSlashPattern, "\\");
|
|
191
|
+
if (path.match(/^[a-z]:\\/i)) path = path[0].toUpperCase() + path.substring(1);
|
|
192
|
+
}
|
|
193
|
+
return path;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Converts a $ref pointer to a valid JSON Path.
|
|
197
|
+
*
|
|
198
|
+
* @param pointer
|
|
199
|
+
* @returns
|
|
200
|
+
*/
|
|
201
|
+
function safePointerToPath(pointer) {
|
|
202
|
+
if (pointer.length <= 1 || pointer[0] !== "#" || pointer[1] !== "/") return [];
|
|
203
|
+
return decodeInternalRef(pointer);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
export { cwd, fromFileSystemPath, getExtension, getHash, getProtocol, isFileSystemPath, resolve, safePointerToPath, stripHash, stripQuery, toFileSystemPath };
|
package/dist/schema/bundle.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bundle } from "../
|
|
1
|
+
import { bundle } from "../ref-parser/bundle.js";
|
|
2
2
|
export { bundle };
|
package/dist/schema/bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bundle } from "../
|
|
1
|
+
import { bundle } from "../ref-parser/bundle.js";
|
|
2
2
|
export { bundle };
|
package/dist/schema/ref.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @see https://datatracker.ietf.org/doc/html/rfc6901
|
|
6
6
|
*/
|
|
7
|
+
declare function encodeSegment(segment: string): string;
|
|
8
|
+
declare function decodeSegment(segment: string): string;
|
|
7
9
|
/**
|
|
8
10
|
* Build an in-document `$ref` string from logical path segments (e.g. `['components','schemas','Pet']` → `#/components/schemas/Pet`).
|
|
9
11
|
*/
|
|
@@ -17,4 +19,4 @@ declare function appendInternalRefPath(base: string, segment: string | number):
|
|
|
17
19
|
*/
|
|
18
20
|
declare function decodeInternalRef(ref: string): string[];
|
|
19
21
|
//#endregion
|
|
20
|
-
export { appendInternalRefPath, decodeInternalRef, encodeInternalRef };
|
|
22
|
+
export { appendInternalRefPath, decodeInternalRef, decodeSegment, encodeInternalRef, encodeSegment };
|
package/dist/schema/ref.js
CHANGED