fumadocs-openapi 10.10.1 → 10.10.2
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/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/utils/document/process.js +7 -12
- package/package.json +6 -9
- 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,124 @@
|
|
|
1
|
+
import json_default from "./parsers/json.js";
|
|
2
|
+
import yaml_default from "./parsers/yaml.js";
|
|
3
|
+
import text_default from "./parsers/text.js";
|
|
4
|
+
import binary_default from "./parsers/binary.js";
|
|
5
|
+
import file_default from "./resolvers/file.js";
|
|
6
|
+
import http_default from "./resolvers/http.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/options.js
|
|
8
|
+
const getJsonSchemaRefParserDefaultOptions = () => {
|
|
9
|
+
return {
|
|
10
|
+
/**
|
|
11
|
+
* Determines how different types of files will be parsed.
|
|
12
|
+
*
|
|
13
|
+
* You can add additional parsers of your own, replace an existing one with
|
|
14
|
+
* your own implementation, or disable any parser by setting it to false.
|
|
15
|
+
*/
|
|
16
|
+
parse: {
|
|
17
|
+
json: { ...json_default },
|
|
18
|
+
yaml: { ...yaml_default },
|
|
19
|
+
text: { ...text_default },
|
|
20
|
+
binary: { ...binary_default }
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Determines how JSON References will be resolved.
|
|
24
|
+
*
|
|
25
|
+
* You can add additional resolvers of your own, replace an existing one with
|
|
26
|
+
* your own implementation, or disable any resolver by setting it to false.
|
|
27
|
+
*/
|
|
28
|
+
resolve: {
|
|
29
|
+
file: { ...file_default },
|
|
30
|
+
http: { ...http_default },
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether external $ref pointers will be resolved.
|
|
33
|
+
* If this option is disabled, then none of above resolvers will be called.
|
|
34
|
+
* Instead, external $ref pointers will simply be ignored.
|
|
35
|
+
*
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
external: true
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* By default, JSON Schema $Ref Parser throws the first error it encounters. Setting `continueOnError` to `true`
|
|
42
|
+
* causes it to keep processing as much as possible and then throw a single error that contains all errors
|
|
43
|
+
* that were encountered.
|
|
44
|
+
*/
|
|
45
|
+
continueOnError: false,
|
|
46
|
+
/**
|
|
47
|
+
* Determines the types of JSON references that are allowed.
|
|
48
|
+
*/
|
|
49
|
+
bundle: {
|
|
50
|
+
/**
|
|
51
|
+
* A function, called for each path, which can return true to stop this path and all
|
|
52
|
+
* subpaths from being processed further. This is useful in schemas where some
|
|
53
|
+
* subpaths contain literal $ref keys that should not be changed.
|
|
54
|
+
*
|
|
55
|
+
* @type {function}
|
|
56
|
+
*/
|
|
57
|
+
excludedPathMatcher: () => false },
|
|
58
|
+
/**
|
|
59
|
+
* Determines the types of JSON references that are allowed.
|
|
60
|
+
*/
|
|
61
|
+
dereference: {
|
|
62
|
+
/**
|
|
63
|
+
* Dereference circular (recursive) JSON references?
|
|
64
|
+
* If false, then a {@link ReferenceError} will be thrown if a circular reference is found.
|
|
65
|
+
* If "ignore", then circular references will not be dereferenced.
|
|
66
|
+
*
|
|
67
|
+
* @type {boolean|string}
|
|
68
|
+
*/
|
|
69
|
+
circular: true,
|
|
70
|
+
/**
|
|
71
|
+
* A function, called for each path, which can return true to stop this path and all
|
|
72
|
+
* subpaths from being dereferenced further. This is useful in schemas where some
|
|
73
|
+
* subpaths contain literal $ref keys that should not be dereferenced.
|
|
74
|
+
*
|
|
75
|
+
* @type {function}
|
|
76
|
+
*/
|
|
77
|
+
excludedPathMatcher: () => false,
|
|
78
|
+
referenceResolution: "relative",
|
|
79
|
+
mergeKeys: true
|
|
80
|
+
},
|
|
81
|
+
mutateInputSchema: true
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const getNewOptions = (options) => {
|
|
85
|
+
const newOptions = getJsonSchemaRefParserDefaultOptions();
|
|
86
|
+
if (options) merge(newOptions, options);
|
|
87
|
+
return newOptions;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Merges the properties of the source object into the target object.
|
|
91
|
+
*
|
|
92
|
+
* @param target - The object that we're populating
|
|
93
|
+
* @param source - The options that are being merged
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
function merge(target, source) {
|
|
97
|
+
if (isMergeable(source)) {
|
|
98
|
+
const keys = Object.keys(source).filter((key) => ![
|
|
99
|
+
"__proto__",
|
|
100
|
+
"constructor",
|
|
101
|
+
"prototype"
|
|
102
|
+
].includes(key));
|
|
103
|
+
for (let i = 0; i < keys.length; i++) {
|
|
104
|
+
const key = keys[i];
|
|
105
|
+
const sourceSetting = source[key];
|
|
106
|
+
const targetSetting = target[key];
|
|
107
|
+
if (isMergeable(sourceSetting)) target[key] = merge(targetSetting || {}, sourceSetting);
|
|
108
|
+
else if (sourceSetting !== void 0) target[key] = sourceSetting;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return target;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether the given value can be merged,
|
|
115
|
+
* or if it is a scalar value that should just override the target value.
|
|
116
|
+
*
|
|
117
|
+
* @param val
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
function isMergeable(val) {
|
|
121
|
+
return val && typeof val === "object" && !Array.isArray(val) && !(val instanceof RegExp) && !(val instanceof Date);
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { getJsonSchemaRefParserDefaultOptions, getNewOptions };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getExtension } from "./util/url.js";
|
|
2
|
+
import { ParserError, ResolverError, UnmatchedParserError, UnmatchedResolverError, isHandledError } from "./util/errors.js";
|
|
3
|
+
import { registerSchemaResources, usesDynamicIdScope } from "./util/schema-resources.js";
|
|
4
|
+
import { all, filter, run, sort } from "./util/plugins.js";
|
|
5
|
+
//#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/parse.js
|
|
6
|
+
/**
|
|
7
|
+
* Reads and parses the specified file path or URL.
|
|
8
|
+
*/
|
|
9
|
+
async function parse(target, $refs, options) {
|
|
10
|
+
let path = typeof target === "string" ? target : target.url;
|
|
11
|
+
const baseUrl = typeof target === "string" ? void 0 : target.baseUrl;
|
|
12
|
+
let reference = typeof target === "string" ? void 0 : target.reference;
|
|
13
|
+
const hashIndex = path.indexOf("#");
|
|
14
|
+
let hash = "";
|
|
15
|
+
if (hashIndex >= 0) {
|
|
16
|
+
hash = path.substring(hashIndex);
|
|
17
|
+
path = path.substring(0, hashIndex);
|
|
18
|
+
}
|
|
19
|
+
if (reference) {
|
|
20
|
+
const referenceHashIndex = reference.indexOf("#");
|
|
21
|
+
if (referenceHashIndex >= 0) reference = reference.substring(0, referenceHashIndex);
|
|
22
|
+
}
|
|
23
|
+
const $ref = $refs._add(path);
|
|
24
|
+
const file = {
|
|
25
|
+
url: path,
|
|
26
|
+
hash,
|
|
27
|
+
extension: getExtension(path),
|
|
28
|
+
...reference !== void 0 ? { reference } : {},
|
|
29
|
+
...baseUrl !== void 0 ? { baseUrl } : {}
|
|
30
|
+
};
|
|
31
|
+
try {
|
|
32
|
+
const resolver = await readFile(file, options, $refs);
|
|
33
|
+
$ref.pathType = resolver.plugin.name;
|
|
34
|
+
file.data = resolver.result;
|
|
35
|
+
const parser = await parseFile(file, options, $refs);
|
|
36
|
+
$ref.value = parser.result;
|
|
37
|
+
$ref.dynamicIdScope = usesDynamicIdScope($ref.value);
|
|
38
|
+
registerSchemaResources($refs, $ref.path, $ref.value, $ref.pathType, $ref.dynamicIdScope);
|
|
39
|
+
return parser.result;
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (isHandledError(err)) $ref.value = err;
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reads the given file, using the configured resolver plugins
|
|
47
|
+
*
|
|
48
|
+
* @param file - An object containing information about the referenced file
|
|
49
|
+
* @param file.url - The full URL of the referenced file
|
|
50
|
+
* @param file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
|
|
51
|
+
* @param options
|
|
52
|
+
* @param $refs
|
|
53
|
+
* @returns
|
|
54
|
+
* The promise resolves with the raw file contents and the resolver that was used.
|
|
55
|
+
*/
|
|
56
|
+
async function readFile(file, options, $refs) {
|
|
57
|
+
let resolvers = all(options.resolve);
|
|
58
|
+
resolvers = filter(resolvers, "canRead", file, void 0, $refs);
|
|
59
|
+
sort(resolvers);
|
|
60
|
+
try {
|
|
61
|
+
return await run(resolvers, "read", file, $refs);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (!err && options.continueOnError) throw new UnmatchedResolverError(file.url);
|
|
64
|
+
else if (!err || !("error" in err)) throw new SyntaxError(`Unable to resolve $ref pointer "${file.url}"`, { cause: err });
|
|
65
|
+
else if (err.error instanceof ResolverError) throw err.error;
|
|
66
|
+
else throw new ResolverError(err, file.url);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parses the given file's contents, using the configured parser plugins.
|
|
71
|
+
*
|
|
72
|
+
* @param file - An object containing information about the referenced file
|
|
73
|
+
* @param file.url - The full URL of the referenced file
|
|
74
|
+
* @param file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
|
|
75
|
+
* @param file.data - The file contents. This will be whatever data type was returned by the resolver
|
|
76
|
+
* @param options
|
|
77
|
+
* @param $refs
|
|
78
|
+
*
|
|
79
|
+
* @returns
|
|
80
|
+
* The promise resolves with the parsed file contents and the parser that was used.
|
|
81
|
+
*/
|
|
82
|
+
async function parseFile(file, options, $refs) {
|
|
83
|
+
const allParsers = all(options.parse);
|
|
84
|
+
const filteredParsers = filter(allParsers, "canParse", file);
|
|
85
|
+
const parsers = filteredParsers.length > 0 ? filteredParsers : allParsers;
|
|
86
|
+
sort(parsers);
|
|
87
|
+
try {
|
|
88
|
+
const parser = await run(parsers, "parse", file, $refs);
|
|
89
|
+
if (!parser.plugin.allowEmpty && isEmpty(parser.result)) throw new SyntaxError(`Error parsing "${file.url}" as ${parser.plugin.name}. \nParsed value is empty`);
|
|
90
|
+
else return parser;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
if (!err && options.continueOnError) throw new UnmatchedParserError(file.url);
|
|
93
|
+
else if (err && err.message && err.message.startsWith("Error parsing")) throw err;
|
|
94
|
+
else if (!err || !("error" in err)) throw new SyntaxError(`Unable to parse ${file.url}`, { cause: err });
|
|
95
|
+
else if (err.error instanceof ParserError) throw err.error;
|
|
96
|
+
else throw new ParserError(err.error.message, file.url);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Determines whether the parsed value is "empty".
|
|
101
|
+
*
|
|
102
|
+
* @param value
|
|
103
|
+
* @returns
|
|
104
|
+
*/
|
|
105
|
+
function isEmpty(value) {
|
|
106
|
+
return value === void 0 || typeof value === "object" && Object.keys(value).length === 0 || typeof value === "string" && value.trim().length === 0 || Buffer.isBuffer(value) && value.length === 0;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { parse as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
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/parsers/binary.js
|
|
2
|
+
const BINARY_REGEXP = /\.(jpeg|jpg|gif|png|bmp|ico)$/i;
|
|
3
|
+
var binary_default = {
|
|
4
|
+
/**
|
|
5
|
+
* The order that this parser will run, in relation to other parsers.
|
|
6
|
+
*/
|
|
7
|
+
order: 400,
|
|
8
|
+
/**
|
|
9
|
+
* Whether to allow "empty" files (zero bytes).
|
|
10
|
+
*/
|
|
11
|
+
allowEmpty: true,
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether this parser can parse a given file reference.
|
|
14
|
+
* Parsers that return true will be tried, in order, until one successfully parses the file.
|
|
15
|
+
* Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
|
|
16
|
+
* every parser will be tried.
|
|
17
|
+
*/
|
|
18
|
+
canParse(file) {
|
|
19
|
+
return Buffer.isBuffer(file.data) && BINARY_REGEXP.test(file.url);
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Parses the given data as a Buffer (byte array).
|
|
23
|
+
*/
|
|
24
|
+
parse(file) {
|
|
25
|
+
if (Buffer.isBuffer(file.data)) return file.data;
|
|
26
|
+
else return Buffer.from(file.data);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { binary_default as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ParserError } from "../util/errors.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/parsers/json.js
|
|
3
|
+
var json_default = {
|
|
4
|
+
/**
|
|
5
|
+
* The order that this parser will run, in relation to other parsers.
|
|
6
|
+
*/
|
|
7
|
+
order: 100,
|
|
8
|
+
/**
|
|
9
|
+
* Whether to allow "empty" files. This includes zero-byte files, as well as empty JSON objects.
|
|
10
|
+
*/
|
|
11
|
+
allowEmpty: true,
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether this parser can parse a given file reference.
|
|
14
|
+
* Parsers that match will be tried, in order, until one successfully parses the file.
|
|
15
|
+
* Parsers that don't match will be skipped, UNLESS none of the parsers match, in which case
|
|
16
|
+
* every parser will be tried.
|
|
17
|
+
*/
|
|
18
|
+
canParse: ".json",
|
|
19
|
+
/**
|
|
20
|
+
* Allow JSON files with byte order marks (BOM)
|
|
21
|
+
*/
|
|
22
|
+
allowBOM: true,
|
|
23
|
+
/**
|
|
24
|
+
* Parses the given file as JSON
|
|
25
|
+
*/
|
|
26
|
+
async parse(file) {
|
|
27
|
+
let data = file.data;
|
|
28
|
+
if (Buffer.isBuffer(data)) data = data.toString();
|
|
29
|
+
if (typeof data === "string") if (data.trim().length === 0) return;
|
|
30
|
+
else try {
|
|
31
|
+
return JSON.parse(data);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
if (this.allowBOM) try {
|
|
34
|
+
const firstCurlyBrace = data.indexOf("{");
|
|
35
|
+
data = data.slice(firstCurlyBrace);
|
|
36
|
+
return JSON.parse(data);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new ParserError(e.message, file.url);
|
|
39
|
+
}
|
|
40
|
+
throw new ParserError(e.message, file.url);
|
|
41
|
+
}
|
|
42
|
+
else return data;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { json_default as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ParserError } from "../util/errors.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/parsers/text.js
|
|
3
|
+
const TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
|
|
4
|
+
var text_default = {
|
|
5
|
+
/**
|
|
6
|
+
* The order that this parser will run, in relation to other parsers.
|
|
7
|
+
*/
|
|
8
|
+
order: 300,
|
|
9
|
+
/**
|
|
10
|
+
* Whether to allow "empty" files (zero bytes).
|
|
11
|
+
*/
|
|
12
|
+
allowEmpty: true,
|
|
13
|
+
/**
|
|
14
|
+
* The encoding that the text is expected to be in.
|
|
15
|
+
*/
|
|
16
|
+
encoding: "utf8",
|
|
17
|
+
/**
|
|
18
|
+
* Determines whether this parser can parse a given file reference.
|
|
19
|
+
* Parsers that return true will be tried, in order, until one successfully parses the file.
|
|
20
|
+
* Parsers that return false will be skipped, UNLESS all parsers returned false, in which case
|
|
21
|
+
* every parser will be tried.
|
|
22
|
+
*/
|
|
23
|
+
canParse(file) {
|
|
24
|
+
return (typeof file.data === "string" || Buffer.isBuffer(file.data)) && TEXT_REGEXP.test(file.url);
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Parses the given file as text
|
|
28
|
+
*/
|
|
29
|
+
parse(file) {
|
|
30
|
+
if (typeof file.data === "string") return file.data;
|
|
31
|
+
else if (Buffer.isBuffer(file.data)) return file.data.toString(this.encoding);
|
|
32
|
+
else throw new ParserError("data is not text", file.url);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { text_default as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ParserError } from "../util/errors.js";
|
|
2
|
+
import yaml, { JSON_SCHEMA } from "js-yaml";
|
|
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/parsers/yaml.js
|
|
4
|
+
var yaml_default = {
|
|
5
|
+
/**
|
|
6
|
+
* The order that this parser will run, in relation to other parsers.
|
|
7
|
+
*/
|
|
8
|
+
order: 200,
|
|
9
|
+
/**
|
|
10
|
+
* Whether to allow "empty" files. This includes zero-byte files, as well as empty JSON objects.
|
|
11
|
+
*/
|
|
12
|
+
allowEmpty: true,
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether this parser can parse a given file reference.
|
|
15
|
+
* Parsers that match will be tried, in order, until one successfully parses the file.
|
|
16
|
+
* Parsers that don't match will be skipped, UNLESS none of the parsers match, in which case
|
|
17
|
+
* every parser will be tried.
|
|
18
|
+
*/
|
|
19
|
+
canParse: [
|
|
20
|
+
".yaml",
|
|
21
|
+
".yml",
|
|
22
|
+
".json"
|
|
23
|
+
],
|
|
24
|
+
/**
|
|
25
|
+
* Parses the given file as YAML
|
|
26
|
+
*
|
|
27
|
+
* @param file - An object containing information about the referenced file
|
|
28
|
+
* @param file.url - The full URL of the referenced file
|
|
29
|
+
* @param file.extension - The lowercased file extension (e.g. ".txt", ".html", etc.)
|
|
30
|
+
* @param file.data - The file contents. This will be whatever data type was returned by the resolver
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
async parse(file) {
|
|
34
|
+
let data = file.data;
|
|
35
|
+
if (Buffer.isBuffer(data)) data = data.toString();
|
|
36
|
+
if (typeof data === "string") try {
|
|
37
|
+
return yaml.load(data, { schema: JSON_SCHEMA });
|
|
38
|
+
} catch {
|
|
39
|
+
try {
|
|
40
|
+
return yaml.load(data);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new ParserError(e?.message || "Parser Error", file.url);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else return data;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { yaml_default as default };
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { getHash, resolve, stripHash } from "./util/url.js";
|
|
2
|
+
import { InvalidPointerError, JSONParserError, MissingPointerError, isHandledError } from "./util/errors.js";
|
|
3
|
+
import { getSchemaBasePath } from "./util/schema-resources.js";
|
|
4
|
+
import $Ref from "./ref.js";
|
|
5
|
+
//#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/pointer.js
|
|
6
|
+
const nullSymbol = Symbol("null");
|
|
7
|
+
const slashes = /\//g;
|
|
8
|
+
const tildes = /~/g;
|
|
9
|
+
const escapedSlash = /~1/g;
|
|
10
|
+
const escapedTilde = /~0/g;
|
|
11
|
+
/**
|
|
12
|
+
* This class represents a single JSON pointer and its resolved value.
|
|
13
|
+
*
|
|
14
|
+
* @param $ref
|
|
15
|
+
* @param path
|
|
16
|
+
* @param [friendlyPath] - The original user-specified path (used for error messages)
|
|
17
|
+
* @class
|
|
18
|
+
*/
|
|
19
|
+
var Pointer = class Pointer {
|
|
20
|
+
/**
|
|
21
|
+
* The {@link $Ref} object that contains this {@link Pointer} object.
|
|
22
|
+
*/
|
|
23
|
+
$ref;
|
|
24
|
+
/**
|
|
25
|
+
* The file path or URL, containing the JSON pointer in the hash.
|
|
26
|
+
* This path is relative to the path of the main JSON schema file.
|
|
27
|
+
*/
|
|
28
|
+
path;
|
|
29
|
+
/**
|
|
30
|
+
* The original path or URL, used for error messages.
|
|
31
|
+
*/
|
|
32
|
+
originalPath;
|
|
33
|
+
/**
|
|
34
|
+
* The current base URI used to resolve nested $ref pointers while walking this pointer.
|
|
35
|
+
*/
|
|
36
|
+
scopeBase;
|
|
37
|
+
/**
|
|
38
|
+
* The value of the JSON pointer.
|
|
39
|
+
* Can be any JSON type, not just objects. Unknown file types are represented as Buffers (byte arrays).
|
|
40
|
+
*/
|
|
41
|
+
value;
|
|
42
|
+
/**
|
|
43
|
+
* Indicates whether the pointer references itself.
|
|
44
|
+
*/
|
|
45
|
+
circular;
|
|
46
|
+
/**
|
|
47
|
+
* The number of indirect references that were traversed to resolve the value.
|
|
48
|
+
* Resolving a single pointer may require resolving multiple $Refs.
|
|
49
|
+
*/
|
|
50
|
+
indirections;
|
|
51
|
+
constructor($ref, path, friendlyPath) {
|
|
52
|
+
this.$ref = $ref;
|
|
53
|
+
this.path = path;
|
|
54
|
+
this.originalPath = friendlyPath || path;
|
|
55
|
+
this.scopeBase = $ref.path || stripHash(path);
|
|
56
|
+
this.value = void 0;
|
|
57
|
+
this.circular = false;
|
|
58
|
+
this.indirections = 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the value of a nested property within the given object.
|
|
62
|
+
*
|
|
63
|
+
* @param obj - The object that will be crawled
|
|
64
|
+
* @param options
|
|
65
|
+
* @param pathFromRoot - the path of place that initiated resolving
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
* Returns a JSON pointer whose {@link Pointer#value} is the resolved value.
|
|
69
|
+
* If resolving this value required resolving other JSON references, then
|
|
70
|
+
* the {@link Pointer#$ref} and {@link Pointer#path} will reflect the resolution path
|
|
71
|
+
* of the resolved value.
|
|
72
|
+
*/
|
|
73
|
+
resolve(obj, options, pathFromRoot) {
|
|
74
|
+
const tokens = Pointer.parse(this.path, this.originalPath);
|
|
75
|
+
const found = [];
|
|
76
|
+
this.value = unwrapOrThrow(obj);
|
|
77
|
+
if (this.$ref.dynamicIdScope && !isAliasedResource(this.$ref)) this.scopeBase = getSchemaBasePath(this.scopeBase, this.value);
|
|
78
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
79
|
+
const wasCircular = this.circular;
|
|
80
|
+
const isExtendedRef = $Ref.isExtended$Ref(this.value);
|
|
81
|
+
if (resolveIf$Ref(this, options, pathFromRoot)) this.path = Pointer.join(this.path, tokens.slice(i));
|
|
82
|
+
else if (!wasCircular && this.circular && isExtendedRef) this.circular = false;
|
|
83
|
+
const token = tokens[i];
|
|
84
|
+
if (this.value[token] === void 0 || this.value[token] === null && i === tokens.length - 1) {
|
|
85
|
+
let didFindSubstringSlashMatch = false;
|
|
86
|
+
for (let j = tokens.length - 1; j > i; j--) {
|
|
87
|
+
const joinedToken = tokens.slice(i, j + 1).join("/");
|
|
88
|
+
if (this.value[joinedToken] !== void 0) {
|
|
89
|
+
this.value = this.value[joinedToken];
|
|
90
|
+
i = j;
|
|
91
|
+
didFindSubstringSlashMatch = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (didFindSubstringSlashMatch) continue;
|
|
96
|
+
if (token in this.value && this.value[token] === null) {
|
|
97
|
+
this.value = nullSymbol;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
this.value = null;
|
|
101
|
+
const path = this.$ref.path || "";
|
|
102
|
+
const targetRef = this.path.replace(path, "");
|
|
103
|
+
const targetFound = Pointer.join("", found);
|
|
104
|
+
const parentPath = pathFromRoot?.replace(path, "");
|
|
105
|
+
throw new MissingPointerError(token, decodeURI(this.originalPath), targetRef, targetFound, parentPath);
|
|
106
|
+
} else this.value = this.value[token];
|
|
107
|
+
found.push(token);
|
|
108
|
+
if (this.$ref.dynamicIdScope) this.scopeBase = getSchemaBasePath(this.scopeBase, this.value);
|
|
109
|
+
}
|
|
110
|
+
const finalResolutionBase = this.$ref.dynamicIdScope ? this.scopeBase : this.path;
|
|
111
|
+
if (!this.value || this.value.$ref && resolve(finalResolutionBase, this.value.$ref) !== pathFromRoot) resolveIf$Ref(this, options, pathFromRoot);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sets the value of a nested property within the given object.
|
|
116
|
+
*
|
|
117
|
+
* @param obj - The object that will be crawled
|
|
118
|
+
* @param value - the value to assign
|
|
119
|
+
* @param options
|
|
120
|
+
*
|
|
121
|
+
* @returns
|
|
122
|
+
* Returns the modified object, or an entirely new object if the entire object is overwritten.
|
|
123
|
+
*/
|
|
124
|
+
set(obj, value, options) {
|
|
125
|
+
const tokens = Pointer.parse(this.path);
|
|
126
|
+
let token;
|
|
127
|
+
if (tokens.length === 0) {
|
|
128
|
+
this.value = value;
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
this.value = unwrapOrThrow(obj);
|
|
132
|
+
if (this.$ref.dynamicIdScope && !isAliasedResource(this.$ref)) this.scopeBase = getSchemaBasePath(this.scopeBase, this.value);
|
|
133
|
+
for (let i = 0; i < tokens.length - 1; i++) {
|
|
134
|
+
resolveIf$Ref(this, options);
|
|
135
|
+
token = tokens[i];
|
|
136
|
+
if (this.value && this.value[token] !== void 0) this.value = this.value[token];
|
|
137
|
+
else this.value = setValue(this, token, {});
|
|
138
|
+
if (this.$ref.dynamicIdScope) this.scopeBase = getSchemaBasePath(this.scopeBase, this.value);
|
|
139
|
+
}
|
|
140
|
+
resolveIf$Ref(this, options);
|
|
141
|
+
token = tokens[tokens.length - 1];
|
|
142
|
+
setValue(this, token, value);
|
|
143
|
+
return obj;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parses a JSON pointer (or a path containing a JSON pointer in the hash)
|
|
147
|
+
* and returns an array of the pointer's tokens.
|
|
148
|
+
* (e.g. "schema.json#/definitions/person/name" => ["definitions", "person", "name"])
|
|
149
|
+
*
|
|
150
|
+
* The pointer is parsed according to RFC 6901
|
|
151
|
+
* {@link https://tools.ietf.org/html/rfc6901#section-3}
|
|
152
|
+
*
|
|
153
|
+
* @param path
|
|
154
|
+
* @param [originalPath]
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
static parse(path, originalPath) {
|
|
158
|
+
const pointer = getHash(path).substring(1);
|
|
159
|
+
if (!pointer) return [];
|
|
160
|
+
const split = pointer.split("/");
|
|
161
|
+
for (let i = 0; i < split.length; i++) split[i] = split[i].replace(escapedSlash, "/").replace(escapedTilde, "~");
|
|
162
|
+
if (split[0] !== "") throw new InvalidPointerError(pointer, originalPath === void 0 ? path : originalPath);
|
|
163
|
+
return split.slice(1);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates a JSON pointer path, by joining one or more tokens to a base path.
|
|
167
|
+
*
|
|
168
|
+
* @param base - The base path (e.g. "schema.json#/definitions/person")
|
|
169
|
+
* @param tokens - The token(s) to append (e.g. ["name", "first"])
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
static join(base, tokens) {
|
|
173
|
+
if (base.indexOf("#") === -1) base += "#";
|
|
174
|
+
tokens = Array.isArray(tokens) ? tokens : [tokens];
|
|
175
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
176
|
+
const token = tokens[i];
|
|
177
|
+
base += "/" + token.replace(tildes, "~0").replace(slashes, "~1");
|
|
178
|
+
}
|
|
179
|
+
return base;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* If the given pointer's {@link Pointer#value} is a JSON reference,
|
|
184
|
+
* then the reference is resolved and {@link Pointer#value} is replaced with the resolved value.
|
|
185
|
+
* In addition, {@link Pointer#path} and {@link Pointer#$ref} are updated to reflect the
|
|
186
|
+
* resolution path of the new value.
|
|
187
|
+
*
|
|
188
|
+
* @param pointer
|
|
189
|
+
* @param options
|
|
190
|
+
* @param [pathFromRoot] - the path of place that initiated resolving
|
|
191
|
+
* @returns - Returns `true` if the resolution path changed
|
|
192
|
+
*/
|
|
193
|
+
function resolveIf$Ref(pointer, options, pathFromRoot) {
|
|
194
|
+
if ($Ref.isAllowed$Ref(pointer.value, options)) {
|
|
195
|
+
const $refPath = resolve(pointer.$ref.dynamicIdScope ? pointer.scopeBase : pointer.path, pointer.value.$ref);
|
|
196
|
+
if ($refPath === pointer.path && !isRootPath(pathFromRoot)) pointer.circular = true;
|
|
197
|
+
else {
|
|
198
|
+
const resolved = pointer.$ref.$refs._resolve($refPath, pointer.path, options);
|
|
199
|
+
if (resolved === null) return false;
|
|
200
|
+
pointer.indirections += resolved.indirections + 1;
|
|
201
|
+
if ($Ref.isExtended$Ref(pointer.value)) {
|
|
202
|
+
pointer.value = $Ref.dereference(pointer.value, resolved.value, options);
|
|
203
|
+
return false;
|
|
204
|
+
} else {
|
|
205
|
+
pointer.$ref = resolved.$ref;
|
|
206
|
+
pointer.path = resolved.path;
|
|
207
|
+
pointer.value = resolved.value;
|
|
208
|
+
pointer.scopeBase = pointer.$ref.path;
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Sets the specified token value of the {@link Pointer#value}.
|
|
216
|
+
*
|
|
217
|
+
* The token is evaluated according to RFC 6901.
|
|
218
|
+
* {@link https://tools.ietf.org/html/rfc6901#section-4}
|
|
219
|
+
*
|
|
220
|
+
* @param pointer - The JSON Pointer whose value will be modified
|
|
221
|
+
* @param token - A JSON Pointer token that indicates how to modify `obj`
|
|
222
|
+
* @param value - The value to assign
|
|
223
|
+
* @returns - Returns the assigned value
|
|
224
|
+
*/
|
|
225
|
+
function setValue(pointer, token, value) {
|
|
226
|
+
if (pointer.value && typeof pointer.value === "object") if (token === "-" && Array.isArray(pointer.value)) pointer.value.push(value);
|
|
227
|
+
else pointer.value[token] = value;
|
|
228
|
+
else throw new JSONParserError(`Error assigning $ref pointer "${pointer.path}". \nCannot set "${token}" of a non-object.`);
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
function unwrapOrThrow(value) {
|
|
232
|
+
if (isHandledError(value)) throw value;
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
function isRootPath(pathFromRoot) {
|
|
236
|
+
return typeof pathFromRoot == "string" && Pointer.parse(pathFromRoot).length == 0;
|
|
237
|
+
}
|
|
238
|
+
function isAliasedResource($ref) {
|
|
239
|
+
return Boolean($ref.path && $ref.path in $ref.$refs._aliases);
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
export { Pointer as default, nullSymbol };
|