fumadocs-openapi 10.10.1 → 10.10.3
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 +16 -8
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +239 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +187 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +136 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +41 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +124 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +109 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +30 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +46 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +36 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +49 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +242 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +247 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +210 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +100 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +41 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +112 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +8 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +146 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +5 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +18 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +11 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +99 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +30 -0
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +315 -0
- package/dist/ui/schema/client.js +70 -69
- package/dist/utils/document/process.js +7 -12
- package/package.json +4 -7
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/general/create-limiter.js +0 -43
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/is-object.js +0 -27
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/object/prevent-pollution.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/queue/queue.js +0 -106
- package/dist/node_modules/.pnpm/@scalar_helpers@0.8.0/node_modules/@scalar/helpers/dist/string/generate-hash.js +0 -120
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/bundle.js +0 -357
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/fetch-urls/index.js +0 -73
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/node.js +0 -3
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/parse-yaml/index.js +0 -1
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/plugins/read-files/index.js +0 -51
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/bundle/value-generator.js +0 -102
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/convert-to-local-ref.js +0 -24
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/escape-json-pointer.js +0 -11
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-schemas.js +0 -44
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-segments-from-path.js +0 -10
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/get-value-by-path.js +0 -42
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-file-path.js +0 -23
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-http-url.js +0 -23
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-json-object.js +0 -28
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/is-yaml.js +0 -21
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/normalize.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/resolve-reference-path.js +0 -30
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/set-value-at-path.js +0 -70
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/to-relative-path.js +0 -33
- package/dist/node_modules/.pnpm/@scalar_json-magic@0.12.14/node_modules/@scalar/json-magic/dist/helpers/unescape-json-pointer.js +0 -12
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -19
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -430
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-collection.js +0 -50
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-node.js +0 -85
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/compose-scalar.js +0 -57
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/composer.js +0 -193
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -82
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +0 -174
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +0 -40
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-end.js +0 -36
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +0 -153
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +0 -203
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/resolve-props.js +0 -105
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-contains-newline.js +0 -27
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +0 -25
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +0 -10
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/compose/util-map-includes.js +0 -10
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/Document.js +0 -277
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/anchors.js +0 -62
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -38
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/createNode.js +0 -61
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/doc/directives.js +0 -163
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/errors.js +0 -48
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/index.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/log.js +0 -6
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Alias.js +0 -92
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Collection.js +0 -117
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Node.js +0 -32
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Pair.js +0 -29
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/Scalar.js +0 -24
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLMap.js +0 -106
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +0 -104
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +0 -49
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js +0 -33
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/toJS.js +0 -35
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-scalar.js +0 -3
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst-visit.js +0 -89
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/cst.js +0 -40
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/lexer.js +0 -529
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/line-counter.js +0 -45
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/parse/parser.js +0 -859
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/public-api.js +0 -44
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/Schema.js +0 -27
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/map.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/null.js +0 -13
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/seq.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/common/string.js +0 -14
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/bool.js +0 -17
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/float.js +0 -38
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/int.js +0 -37
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/core/schema.js +0 -23
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/json/schema.js +0 -61
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/tags.js +0 -81
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +0 -52
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +0 -24
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +0 -41
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +0 -70
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +0 -60
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +0 -56
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -39
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +0 -65
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +0 -79
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +0 -111
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringify.js +0 -105
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +0 -116
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyComment.js +0 -16
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +0 -59
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +0 -19
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyPair.js +0 -95
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/stringifyString.js +0 -222
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/visit.js +0 -187
- package/dist/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/index.js +0 -16
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { cwd, getHash, resolve, safePointerToPath, stripHash } from "./util/url.js";
|
|
2
|
+
import { isHandledError } from "./util/errors.js";
|
|
3
|
+
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
|
+
import Pointer from "./pointer.js";
|
|
5
|
+
import $Ref from "./ref.js";
|
|
6
|
+
import parse from "./parse.js";
|
|
7
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js
|
|
8
|
+
/**
|
|
9
|
+
* Crawls the JSON schema, finds all external JSON references, and resolves their values.
|
|
10
|
+
* This method does not mutate the JSON schema. The resolved values are added to {@link $RefParser#$refs}.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: We only care about EXTERNAL references here. INTERNAL references are only relevant when dereferencing.
|
|
13
|
+
*
|
|
14
|
+
* @returns
|
|
15
|
+
* The promise resolves once all JSON references in the schema have been resolved,
|
|
16
|
+
* including nested references that are contained in externally-referenced files.
|
|
17
|
+
*/
|
|
18
|
+
function resolveExternal(parser, options) {
|
|
19
|
+
if (!options.resolve?.external) return Promise.resolve();
|
|
20
|
+
try {
|
|
21
|
+
const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
|
|
22
|
+
const promises = crawl(parser.schema, parser.$refs._root$Ref.path + "#", rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, parser.$refs, options);
|
|
23
|
+
return Promise.all(promises);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return Promise.reject(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Recursively crawls the given value, and resolves any external JSON references.
|
|
30
|
+
*
|
|
31
|
+
* @param obj - The value to crawl. If it's not an object or array, it will be ignored.
|
|
32
|
+
* @param path - The full path of `obj`, possibly with a JSON Pointer in the hash
|
|
33
|
+
* @param {boolean} external - Whether `obj` was found in an external document.
|
|
34
|
+
* @param $refs
|
|
35
|
+
* @param options
|
|
36
|
+
* @param seen - Internal.
|
|
37
|
+
*
|
|
38
|
+
* @returns
|
|
39
|
+
* Returns an array of promises. There will be one promise for each JSON reference in `obj`.
|
|
40
|
+
* If `obj` does not contain any JSON references, then the array will be empty.
|
|
41
|
+
* If any of the JSON references point to files that contain additional JSON references,
|
|
42
|
+
* then the corresponding promise will internally reference an array of promises.
|
|
43
|
+
*/
|
|
44
|
+
function crawl(obj, path, scopeBase, dynamicIdScope, $refs, options, seen, external) {
|
|
45
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
46
|
+
let promises = [];
|
|
47
|
+
if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !seen.has(obj)) {
|
|
48
|
+
seen.add(obj);
|
|
49
|
+
const currentScopeBase = scopeBase;
|
|
50
|
+
if ($Ref.isExternal$Ref(obj)) promises.push(resolve$Ref(obj, path, currentScopeBase, dynamicIdScope, $refs, options));
|
|
51
|
+
const keys = Object.keys(obj);
|
|
52
|
+
for (const key of keys) {
|
|
53
|
+
const keyPath = Pointer.join(path, key);
|
|
54
|
+
const value = obj[key];
|
|
55
|
+
const childScopeBase = dynamicIdScope && value && typeof value === "object" && !ArrayBuffer.isView(value) ? getSchemaBasePath(currentScopeBase, value) : currentScopeBase;
|
|
56
|
+
promises = promises.concat(crawl(value, keyPath, childScopeBase, dynamicIdScope, $refs, options, seen, external));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return promises;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolves the given JSON Reference, and then crawls the resulting value.
|
|
63
|
+
*
|
|
64
|
+
* @param $ref - The JSON Reference to resolve
|
|
65
|
+
* @param path - The full path of `$ref`, possibly with a JSON Pointer in the hash
|
|
66
|
+
* @param $refs
|
|
67
|
+
* @param options
|
|
68
|
+
*
|
|
69
|
+
* @returns
|
|
70
|
+
* The promise resolves once all JSON references in the object have been resolved,
|
|
71
|
+
* including nested references that are contained in externally-referenced files.
|
|
72
|
+
*/
|
|
73
|
+
async function resolve$Ref($ref, path, scopeBase, dynamicIdScope, $refs, options) {
|
|
74
|
+
const resolutionBase = options.dereference?.externalReferenceResolution === "root" ? cwd() : dynamicIdScope ? scopeBase : path;
|
|
75
|
+
const resolvedPath = resolve(resolutionBase, $ref.$ref);
|
|
76
|
+
const withoutHash = stripHash(resolvedPath);
|
|
77
|
+
const ref = $refs._get$Ref(withoutHash);
|
|
78
|
+
if (ref) return Promise.resolve(ref.value);
|
|
79
|
+
try {
|
|
80
|
+
const reference = $ref.$ref;
|
|
81
|
+
const parseTarget = {
|
|
82
|
+
url: resolvedPath,
|
|
83
|
+
baseUrl: resolutionBase
|
|
84
|
+
};
|
|
85
|
+
if (typeof reference === "string") parseTarget.reference = reference;
|
|
86
|
+
const result = await parse(parseTarget, $refs, options);
|
|
87
|
+
const parsedRef = $refs._get$Ref(withoutHash);
|
|
88
|
+
const promises = crawl(result, withoutHash + "#", withoutHash, parsedRef?.dynamicIdScope ?? false, $refs, options, /* @__PURE__ */ new Set(), true);
|
|
89
|
+
return Promise.all(promises);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (!options?.continueOnError || !isHandledError(err)) throw err;
|
|
92
|
+
if ($refs._$refs[withoutHash]) {
|
|
93
|
+
err.source = decodeURI(stripHash(path));
|
|
94
|
+
err.path = safePointerToPath(getHash(path));
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { resolveExternal as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isFileSystemPath, toFileSystemPath } from "../util/url.js";
|
|
2
|
+
import { ResolverError } from "../util/errors.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js
|
|
4
|
+
var file_default = {
|
|
5
|
+
/**
|
|
6
|
+
* The order that this resolver will run, in relation to other resolvers.
|
|
7
|
+
*/
|
|
8
|
+
order: 100,
|
|
9
|
+
/**
|
|
10
|
+
* Determines whether this resolver can read a given file reference.
|
|
11
|
+
* Resolvers that return true will be tried, in order, until one successfully resolves the file.
|
|
12
|
+
* Resolvers that return false will not be given a chance to resolve the file.
|
|
13
|
+
*/
|
|
14
|
+
canRead(file) {
|
|
15
|
+
return isFileSystemPath(file.url);
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Reads the given file and returns its raw contents as a Buffer.
|
|
19
|
+
*/
|
|
20
|
+
async read(file) {
|
|
21
|
+
let path;
|
|
22
|
+
const fs = await import("fs");
|
|
23
|
+
try {
|
|
24
|
+
path = toFileSystemPath(file.url);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
const e = err;
|
|
27
|
+
e.message = `Malformed URI: ${file.url}: ${e.message}`;
|
|
28
|
+
throw new ResolverError(e, file.url);
|
|
29
|
+
}
|
|
30
|
+
if (path.endsWith("/") || path.endsWith("\\")) path = path.slice(0, -1);
|
|
31
|
+
try {
|
|
32
|
+
return await fs.promises.readFile(path);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
const e = err;
|
|
35
|
+
e.message = `Error opening file ${path}: ${e.message}`;
|
|
36
|
+
throw new ResolverError(e, path);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { file_default as default };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { isHttp, isUnsafeUrl, parse, resolve } from "../util/url.js";
|
|
2
|
+
import { ResolverError } from "../util/errors.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js
|
|
4
|
+
var http_default = {
|
|
5
|
+
/**
|
|
6
|
+
* The order that this resolver will run, in relation to other resolvers.
|
|
7
|
+
*/
|
|
8
|
+
order: 200,
|
|
9
|
+
/**
|
|
10
|
+
* HTTP headers to send when downloading files.
|
|
11
|
+
*
|
|
12
|
+
* @example:
|
|
13
|
+
* {
|
|
14
|
+
* "User-Agent": "JSON Schema $Ref Parser",
|
|
15
|
+
* Accept: "application/json"
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
headers: null,
|
|
19
|
+
/**
|
|
20
|
+
* HTTP request timeout (in milliseconds).
|
|
21
|
+
*/
|
|
22
|
+
timeout: 6e4,
|
|
23
|
+
/**
|
|
24
|
+
* The maximum number of HTTP redirects to follow.
|
|
25
|
+
* To disable automatic following of redirects, set this to zero.
|
|
26
|
+
*/
|
|
27
|
+
redirects: 5,
|
|
28
|
+
/**
|
|
29
|
+
* The `withCredentials` option of XMLHttpRequest.
|
|
30
|
+
* Set this to `true` if you're downloading files from a CORS-enabled server that requires authentication
|
|
31
|
+
*/
|
|
32
|
+
withCredentials: false,
|
|
33
|
+
/**
|
|
34
|
+
* Set this to `false` if you want to allow unsafe URLs (e.g., `127.0.0.1`, localhost, and other internal URLs).
|
|
35
|
+
*/
|
|
36
|
+
safeUrlResolver: true,
|
|
37
|
+
/**
|
|
38
|
+
* Determines whether this resolver can read a given file reference.
|
|
39
|
+
* Resolvers that return true will be tried in order, until one successfully resolves the file.
|
|
40
|
+
* Resolvers that return false will not be given a chance to resolve the file.
|
|
41
|
+
*/
|
|
42
|
+
canRead(file) {
|
|
43
|
+
return isHttp(file.url) && (!this.safeUrlResolver || !isUnsafeUrl(file.url));
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Reads the given URL and returns its raw contents as a Buffer.
|
|
47
|
+
*/
|
|
48
|
+
read(file) {
|
|
49
|
+
const u = parse(file.url);
|
|
50
|
+
if (typeof window !== "undefined" && !u.protocol) u.protocol = parse(location.href).protocol;
|
|
51
|
+
return download(u, this);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Downloads the given file.
|
|
56
|
+
* @returns
|
|
57
|
+
* The promise resolves with the raw downloaded data, or rejects if there is an HTTP error.
|
|
58
|
+
*/
|
|
59
|
+
async function download(u, httpOptions, _redirects) {
|
|
60
|
+
u = parse(u);
|
|
61
|
+
const redirects = _redirects || [];
|
|
62
|
+
redirects.push(u.href);
|
|
63
|
+
try {
|
|
64
|
+
const res = await get(u, httpOptions);
|
|
65
|
+
if (res.status >= 400) {
|
|
66
|
+
const error = /* @__PURE__ */ new Error(`HTTP ERROR ${res.status}`);
|
|
67
|
+
error.status = res.status;
|
|
68
|
+
throw error;
|
|
69
|
+
} else if (res.status >= 300) if (!Number.isNaN(httpOptions.redirects) && redirects.length > httpOptions.redirects) {
|
|
70
|
+
const error = /* @__PURE__ */ new Error(`Error downloading ${redirects[0]}. \nToo many redirects: \n ${redirects.join(" \n ")}`);
|
|
71
|
+
error.status = res.status;
|
|
72
|
+
throw new ResolverError(error);
|
|
73
|
+
} else if (!("location" in res.headers) || !res.headers.location) {
|
|
74
|
+
const error = /* @__PURE__ */ new Error(`HTTP ${res.status} redirect with no location header`);
|
|
75
|
+
error.status = res.status;
|
|
76
|
+
throw error;
|
|
77
|
+
} else return download(resolve(u.href, res.headers.location), httpOptions, redirects);
|
|
78
|
+
else {
|
|
79
|
+
if (res.body) {
|
|
80
|
+
const buf = await res.arrayBuffer();
|
|
81
|
+
return Buffer.from(buf);
|
|
82
|
+
}
|
|
83
|
+
return Buffer.alloc(0);
|
|
84
|
+
}
|
|
85
|
+
} catch (err) {
|
|
86
|
+
const e = err;
|
|
87
|
+
e.message = `Error downloading ${u.href}: ${e.message}`;
|
|
88
|
+
throw new ResolverError(e, u.href);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Sends an HTTP GET request.
|
|
93
|
+
* The promise resolves with the HTTP Response object.
|
|
94
|
+
*/
|
|
95
|
+
async function get(u, httpOptions) {
|
|
96
|
+
let controller;
|
|
97
|
+
let timeoutId;
|
|
98
|
+
if (httpOptions.timeout && typeof AbortController !== "undefined") {
|
|
99
|
+
controller = new AbortController();
|
|
100
|
+
timeoutId = setTimeout(() => controller.abort(), httpOptions.timeout);
|
|
101
|
+
}
|
|
102
|
+
const response = await fetch(u, {
|
|
103
|
+
method: "GET",
|
|
104
|
+
headers: httpOptions.headers || {},
|
|
105
|
+
credentials: httpOptions.withCredentials ? "include" : "same-origin",
|
|
106
|
+
signal: controller ? controller.signal : null
|
|
107
|
+
});
|
|
108
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { http_default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js
|
|
2
|
+
const win32Sep = "\\";
|
|
3
|
+
function convertPathToPosix(filePath) {
|
|
4
|
+
if (filePath.startsWith("\\\\?\\")) return filePath;
|
|
5
|
+
return filePath.split(win32Sep).join("/");
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { convertPathToPosix as default };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { getHash, stripHash, toFileSystemPath } from "./url.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js
|
|
3
|
+
const nonJsonTypes = [
|
|
4
|
+
"function",
|
|
5
|
+
"symbol",
|
|
6
|
+
"undefined"
|
|
7
|
+
];
|
|
8
|
+
const protectedProps = [
|
|
9
|
+
"constructor",
|
|
10
|
+
"prototype",
|
|
11
|
+
"__proto__"
|
|
12
|
+
];
|
|
13
|
+
const objectPrototype = Object.getPrototypeOf({});
|
|
14
|
+
/**
|
|
15
|
+
* Custom JSON serializer for Error objects.
|
|
16
|
+
* Returns all built-in error properties, as well as extended properties.
|
|
17
|
+
*/
|
|
18
|
+
function toJSON() {
|
|
19
|
+
const pojo = {};
|
|
20
|
+
const error = this;
|
|
21
|
+
for (const key of getDeepKeys(error)) if (typeof key === "string") {
|
|
22
|
+
const value = error[key];
|
|
23
|
+
const type = typeof value;
|
|
24
|
+
if (!nonJsonTypes.includes(type)) pojo[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return pojo;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns own, inherited, enumerable, non-enumerable, string, and symbol keys of `obj`.
|
|
30
|
+
* Does NOT return members of the base Object prototype, or the specified omitted keys.
|
|
31
|
+
*/
|
|
32
|
+
function getDeepKeys(obj, omit = []) {
|
|
33
|
+
let keys = [];
|
|
34
|
+
while (obj && obj !== objectPrototype) {
|
|
35
|
+
keys = keys.concat(Object.getOwnPropertyNames(obj), Object.getOwnPropertySymbols(obj));
|
|
36
|
+
obj = Object.getPrototypeOf(obj);
|
|
37
|
+
}
|
|
38
|
+
const uniqueKeys = new Set(keys);
|
|
39
|
+
for (const key of omit.concat(protectedProps)) uniqueKeys.delete(key);
|
|
40
|
+
return uniqueKeys;
|
|
41
|
+
}
|
|
42
|
+
var JSONParserError = class extends Error {
|
|
43
|
+
name;
|
|
44
|
+
message;
|
|
45
|
+
source;
|
|
46
|
+
path;
|
|
47
|
+
code;
|
|
48
|
+
constructor(message, source) {
|
|
49
|
+
super();
|
|
50
|
+
this.code = "EUNKNOWN";
|
|
51
|
+
this.name = "JSONParserError";
|
|
52
|
+
this.message = message;
|
|
53
|
+
this.source = source;
|
|
54
|
+
this.path = null;
|
|
55
|
+
}
|
|
56
|
+
toJSON = toJSON.bind(this);
|
|
57
|
+
get footprint() {
|
|
58
|
+
return `${this.path}+${this.source}+${this.code}+${this.message}`;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var JSONParserErrorGroup = class JSONParserErrorGroup extends Error {
|
|
62
|
+
files;
|
|
63
|
+
constructor(parser) {
|
|
64
|
+
super();
|
|
65
|
+
this.files = parser;
|
|
66
|
+
this.name = "JSONParserErrorGroup";
|
|
67
|
+
this.message = `${this.errors.length} error${this.errors.length > 1 ? "s" : ""} occurred while reading '${toFileSystemPath(parser.$refs._root$Ref.path)}'`;
|
|
68
|
+
}
|
|
69
|
+
toJSON = toJSON.bind(this);
|
|
70
|
+
static getParserErrors(parser) {
|
|
71
|
+
const errors = [];
|
|
72
|
+
for (const $ref of Object.values(parser.$refs._$refs)) if ($ref.errors) errors.push(...$ref.errors);
|
|
73
|
+
return errors;
|
|
74
|
+
}
|
|
75
|
+
get errors() {
|
|
76
|
+
return JSONParserErrorGroup.getParserErrors(this.files);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var ParserError = class extends JSONParserError {
|
|
80
|
+
code = "EPARSER";
|
|
81
|
+
name = "ParserError";
|
|
82
|
+
constructor(message, source) {
|
|
83
|
+
super(`Error parsing ${source}: ${message}`, source);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var UnmatchedParserError = class extends JSONParserError {
|
|
87
|
+
code = "EUNMATCHEDPARSER";
|
|
88
|
+
name = "UnmatchedParserError";
|
|
89
|
+
constructor(source) {
|
|
90
|
+
super(`Could not find parser for "${source}"`, source);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var ResolverError = class extends JSONParserError {
|
|
94
|
+
code = "ERESOLVER";
|
|
95
|
+
name = "ResolverError";
|
|
96
|
+
ioErrorCode;
|
|
97
|
+
constructor(ex, source) {
|
|
98
|
+
super(ex.message || `Error reading file "${source}"`, source);
|
|
99
|
+
if ("code" in ex) this.ioErrorCode = String(ex.code);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var UnmatchedResolverError = class extends JSONParserError {
|
|
103
|
+
code = "EUNMATCHEDRESOLVER";
|
|
104
|
+
name = "UnmatchedResolverError";
|
|
105
|
+
constructor(source) {
|
|
106
|
+
super(`Could not find resolver for "${source}"`, source);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var MissingPointerError = class extends JSONParserError {
|
|
110
|
+
code = "EMISSINGPOINTER";
|
|
111
|
+
name = "MissingPointerError";
|
|
112
|
+
targetToken;
|
|
113
|
+
targetRef;
|
|
114
|
+
targetFound;
|
|
115
|
+
parentPath;
|
|
116
|
+
constructor(token, path, targetRef, targetFound, parentPath) {
|
|
117
|
+
super(`Missing $ref pointer "${getHash(path)}". Token "${token}" does not exist.`, stripHash(path));
|
|
118
|
+
this.targetToken = token;
|
|
119
|
+
this.targetRef = targetRef;
|
|
120
|
+
this.targetFound = targetFound;
|
|
121
|
+
this.parentPath = parentPath;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
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
|
+
var InvalidPointerError = class extends JSONParserError {
|
|
132
|
+
code = "EUNMATCHEDRESOLVER";
|
|
133
|
+
name = "InvalidPointerError";
|
|
134
|
+
constructor(pointer, path) {
|
|
135
|
+
super(`Invalid $ref pointer "${pointer}". Pointers must begin with "#/"`, stripHash(path));
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
function isHandledError(err) {
|
|
139
|
+
return err instanceof JSONParserError || err instanceof JSONParserErrorGroup;
|
|
140
|
+
}
|
|
141
|
+
function normalizeError(err) {
|
|
142
|
+
if (err.path === null) err.path = [];
|
|
143
|
+
return err;
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
export { InvalidPointerError, JSONParserError, JSONParserErrorGroup, MissingPointerError, ParserError, ResolverError, TimeoutError, UnmatchedParserError, UnmatchedResolverError, isHandledError, normalizeError };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js
|
|
2
|
+
const isWindowsConst = /^win/.test(globalThis.process ? globalThis.process.platform : "");
|
|
3
|
+
const isWindows = () => isWindowsConst;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { isWindows };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import next_default from "./next.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js
|
|
3
|
+
function maybe(cb, promise) {
|
|
4
|
+
if (cb) {
|
|
5
|
+
promise.then(function(result) {
|
|
6
|
+
next_default(function() {
|
|
7
|
+
cb(null, result);
|
|
8
|
+
});
|
|
9
|
+
}, function(err) {
|
|
10
|
+
next_default(function() {
|
|
11
|
+
cb(err);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
} else return promise;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { maybe as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js
|
|
2
|
+
function makeNext() {
|
|
3
|
+
if (typeof process === "object" && typeof process.nextTick === "function") return process.nextTick;
|
|
4
|
+
else if (typeof setImmediate === "function") return setImmediate;
|
|
5
|
+
else return function next(f) {
|
|
6
|
+
setTimeout(f, 0);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
var next_default = makeNext();
|
|
10
|
+
//#endregion
|
|
11
|
+
export { next_default as default };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js
|
|
2
|
+
/**
|
|
3
|
+
* Returns the given plugins as an array, rather than an object map.
|
|
4
|
+
* All other methods in this module expect an array of plugins rather than an object map.
|
|
5
|
+
*
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
function all(plugins) {
|
|
9
|
+
return Object.keys(plugins || {}).filter((key) => {
|
|
10
|
+
return typeof plugins[key] === "object";
|
|
11
|
+
}).map((key) => {
|
|
12
|
+
plugins[key].name = key;
|
|
13
|
+
return plugins[key];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Filters the given plugins, returning only the ones return `true` for the given method.
|
|
18
|
+
*/
|
|
19
|
+
function filter(plugins, method, file, callback, $refs) {
|
|
20
|
+
return plugins.filter((plugin) => {
|
|
21
|
+
return !!getResult(plugin, method, file, callback, $refs);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sorts the given plugins, in place, by their `order` property.
|
|
26
|
+
*/
|
|
27
|
+
function sort(plugins) {
|
|
28
|
+
for (const plugin of plugins) plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
|
|
29
|
+
return plugins.sort((a, b) => {
|
|
30
|
+
return a.order - b.order;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs the specified method of the given plugins, in order, until one of them returns a successful result.
|
|
35
|
+
* Each method can return a synchronous value, a Promise, or call an error-first callback.
|
|
36
|
+
* If the promise resolves successfully, or the callback is called without an error, then the result
|
|
37
|
+
* is immediately returned and no further plugins are called.
|
|
38
|
+
* If the promise rejects, or the callback is called with an error, then the next plugin is called.
|
|
39
|
+
* If ALL plugins fail, then the last error is thrown.
|
|
40
|
+
*/
|
|
41
|
+
async function run(plugins, method, file, $refs) {
|
|
42
|
+
let plugin;
|
|
43
|
+
let lastError;
|
|
44
|
+
let index = 0;
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
runNextPlugin();
|
|
47
|
+
function runNextPlugin() {
|
|
48
|
+
plugin = plugins[index++];
|
|
49
|
+
if (!plugin) return reject(lastError);
|
|
50
|
+
try {
|
|
51
|
+
const result = getResult(plugin, method, file, callback, $refs);
|
|
52
|
+
if (result && typeof result.then === "function") result.then(onSuccess, onError);
|
|
53
|
+
else if (result !== void 0) onSuccess(result);
|
|
54
|
+
else if (index === plugins.length) throw new Error("No promise has been returned or callback has been called.");
|
|
55
|
+
} catch (e) {
|
|
56
|
+
onError(e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function callback(err, result) {
|
|
60
|
+
if (err) onError(err);
|
|
61
|
+
else onSuccess(result);
|
|
62
|
+
}
|
|
63
|
+
function onSuccess(result) {
|
|
64
|
+
resolve({
|
|
65
|
+
plugin,
|
|
66
|
+
result
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function onError(error) {
|
|
70
|
+
lastError = {
|
|
71
|
+
plugin,
|
|
72
|
+
error
|
|
73
|
+
};
|
|
74
|
+
runNextPlugin();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns the value of the given property.
|
|
80
|
+
* If the property is a function, then the result of the function is returned.
|
|
81
|
+
* If the value is a RegExp, then it will be tested against the file URL.
|
|
82
|
+
* If the value is an array, then it will be compared against the file extension.
|
|
83
|
+
*/
|
|
84
|
+
function getResult(obj, prop, file, callback, $refs) {
|
|
85
|
+
const value = obj[prop];
|
|
86
|
+
if (typeof value === "function") return value.apply(obj, [
|
|
87
|
+
file,
|
|
88
|
+
callback,
|
|
89
|
+
$refs
|
|
90
|
+
]);
|
|
91
|
+
if (!callback) {
|
|
92
|
+
if (value instanceof RegExp) return value.test(file.url);
|
|
93
|
+
else if (typeof value === "string") return value === file.extension;
|
|
94
|
+
else if (Array.isArray(value)) return value.indexOf(file.extension) !== -1;
|
|
95
|
+
}
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { all, filter, run, sort };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolve } from "./url.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@apidevtools+json-schema-ref-parser@15.3.5_@types+json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js
|
|
3
|
+
function getSchemaBasePath(basePath, value) {
|
|
4
|
+
const schemaId = getSchemaId(value);
|
|
5
|
+
return schemaId ? resolve(basePath, schemaId) : basePath;
|
|
6
|
+
}
|
|
7
|
+
function usesDynamicIdScope(value) {
|
|
8
|
+
if (!value || typeof value !== "object" || ArrayBuffer.isView(value)) return false;
|
|
9
|
+
const schema = value.$schema;
|
|
10
|
+
if (typeof schema === "string" && (schema.includes("draft/2019-09/") || schema.includes("draft/2020-12/") || schema.includes("oas/3.1/"))) return true;
|
|
11
|
+
const openapi = value.openapi;
|
|
12
|
+
return typeof openapi === "string" && /^3\.1(?:\.|$)/.test(openapi);
|
|
13
|
+
}
|
|
14
|
+
function registerSchemaResources($refs, basePath, value, pathType, dynamicIdScope = false) {
|
|
15
|
+
if (!dynamicIdScope) return;
|
|
16
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17
|
+
const visit = (node, scopeBase) => {
|
|
18
|
+
if (!node || typeof node !== "object" || ArrayBuffer.isView(node) || seen.has(node)) return;
|
|
19
|
+
seen.add(node);
|
|
20
|
+
const nextScopeBase = getSchemaBasePath(scopeBase, node);
|
|
21
|
+
if (nextScopeBase !== scopeBase) $refs._addAlias(nextScopeBase, node, pathType, dynamicIdScope);
|
|
22
|
+
for (const key of Object.keys(node)) visit(node[key], nextScopeBase);
|
|
23
|
+
};
|
|
24
|
+
visit(value, basePath);
|
|
25
|
+
}
|
|
26
|
+
function getSchemaId(value) {
|
|
27
|
+
if (value && typeof value === "object" && "$id" in value && typeof value.$id === "string" && value.$id.length > 0) return value.$id;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getSchemaBasePath, registerSchemaResources, usesDynamicIdScope };
|