@fumadocs/api-docs 0.0.1
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/LICENSE +21 -0
- package/css/generated/shared.css +1 -0
- package/css/preset.css +1 -0
- package/dist/.translations/index.d.ts +28 -0
- package/dist/.translations/keys.js +28 -0
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/auto-anchor/client.d.ts +16 -0
- package/dist/auto-anchor/client.js +20 -0
- package/dist/auto-anchor/index.d.ts +9 -0
- package/dist/auto-anchor/index.js +17 -0
- package/dist/codegen.d.ts +38 -0
- package/dist/codegen.js +35 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +67 -0
- package/dist/components/dialog.d.ts +39 -0
- package/dist/components/dialog.js +61 -0
- package/dist/components/input.d.ts +8 -0
- package/dist/components/input.js +17 -0
- package/dist/components/playground/inputs.d.ts +50 -0
- package/dist/components/playground/inputs.js +426 -0
- package/dist/components/playground/schema.d.ts +66 -0
- package/dist/components/playground/schema.js +144 -0
- package/dist/components/schema/client.d.ts +17 -0
- package/dist/components/schema/client.js +415 -0
- package/dist/components/schema/index.d.ts +102 -0
- package/dist/components/schema/index.js +276 -0
- package/dist/components/select-tab.d.ts +33 -0
- package/dist/components/select-tab.js +56 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.js +72 -0
- package/dist/components/spinner.d.ts +7 -0
- package/dist/components/spinner.js +14 -0
- package/dist/i18n.d.ts +7 -0
- package/dist/i18n.js +7 -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/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.d.ts +157 -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.d.ts +166 -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.d.ts +96 -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.d.ts +190 -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.d.ts +134 -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/types/index.d.ts +133 -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.d.ts +34 -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/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +108 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +110 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +138 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +674 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +141 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +102 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +223 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +133 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +61 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +146 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +48 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +172 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +31 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +433 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +113 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +72 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +583 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +42 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +50 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +20 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +51 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +36 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +19 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +85 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +12 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +25 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +12 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +57 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +96 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +29 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +89 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +87 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +16 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +62 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +60 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +34 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +31 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +51 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +61 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +52 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +41 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +130 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +14 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +112 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +101 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +14 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +35 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +46 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +45 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +22 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +20 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +15 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +10 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +23 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +19 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +13 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +46 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +59 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +17 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +49 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +48 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +18 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +33 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +47 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +28 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +27 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +38 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +72 -0
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +70 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +33 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +236 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +187 -0
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +282 -0
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +78 -0
- package/dist/schema/bundle.d.ts +2 -0
- package/dist/schema/bundle.js +2 -0
- package/dist/schema/dereference.d.ts +19 -0
- package/dist/schema/dereference.js +49 -0
- package/dist/schema/index.d.ts +21 -0
- package/dist/schema/index.js +0 -0
- package/dist/schema/merge.d.ts +12 -0
- package/dist/schema/merge.js +156 -0
- package/dist/schema/ref.d.ts +20 -0
- package/dist/schema/ref.js +43 -0
- package/dist/schema/resolve-ref.d.ts +4 -0
- package/dist/schema/resolve-ref.js +11 -0
- package/dist/schema/sample.d.ts +12 -0
- package/dist/schema/sample.js +442 -0
- package/dist/schema/to-string.d.ts +10 -0
- package/dist/schema/to-string.js +51 -0
- package/dist/utils/cn.js +2 -0
- package/dist/utils/deep-equal.js +21 -0
- package/dist/utils/id-to-title.d.ts +4 -0
- package/dist/utils/id-to-title.js +12 -0
- package/dist/utils/is-plain-object.js +8 -0
- package/dist/utils/merge-refs.js +11 -0
- package/dist/utils/url.d.ts +5 -0
- package/dist/utils/url.js +13 -0
- package/package.json +105 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js
|
|
3
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
/** @type {(value: string) => boolean} */
|
|
5
|
+
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
6
|
+
/** @type {(value: string) => boolean} */
|
|
7
|
+
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
8
|
+
/**
|
|
9
|
+
* @param {Array<string>} input
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
function stringArrayToHexStripped(input) {
|
|
13
|
+
let acc = "";
|
|
14
|
+
let code = 0;
|
|
15
|
+
let i = 0;
|
|
16
|
+
for (i = 0; i < input.length; i++) {
|
|
17
|
+
code = input[i].charCodeAt(0);
|
|
18
|
+
if (code === 48) continue;
|
|
19
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
|
|
20
|
+
acc += input[i];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
for (i += 1; i < input.length; i++) {
|
|
24
|
+
code = input[i].charCodeAt(0);
|
|
25
|
+
if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
|
|
26
|
+
acc += input[i];
|
|
27
|
+
}
|
|
28
|
+
return acc;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} GetIPV6Result
|
|
32
|
+
* @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
|
|
33
|
+
* @property {string} address - The parsed IPv6 address.
|
|
34
|
+
* @property {string} [zone] - The zone identifier, if present.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} value
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
const nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
|
|
41
|
+
/**
|
|
42
|
+
* @param {Array<string>} buffer
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
function consumeIsZone(buffer) {
|
|
46
|
+
buffer.length = 0;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @param {Array<string>} buffer
|
|
51
|
+
* @param {Array<string>} address
|
|
52
|
+
* @param {GetIPV6Result} output
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
function consumeHextets(buffer, address, output) {
|
|
56
|
+
if (buffer.length) {
|
|
57
|
+
const hex = stringArrayToHexStripped(buffer);
|
|
58
|
+
if (hex !== "") address.push(hex);
|
|
59
|
+
else {
|
|
60
|
+
output.error = true;
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
buffer.length = 0;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @param {string} input
|
|
69
|
+
* @returns {GetIPV6Result}
|
|
70
|
+
*/
|
|
71
|
+
function getIPV6(input) {
|
|
72
|
+
let tokenCount = 0;
|
|
73
|
+
const output = {
|
|
74
|
+
error: false,
|
|
75
|
+
address: "",
|
|
76
|
+
zone: ""
|
|
77
|
+
};
|
|
78
|
+
/** @type {Array<string>} */
|
|
79
|
+
const address = [];
|
|
80
|
+
/** @type {Array<string>} */
|
|
81
|
+
const buffer = [];
|
|
82
|
+
let endipv6Encountered = false;
|
|
83
|
+
let endIpv6 = false;
|
|
84
|
+
let consume = consumeHextets;
|
|
85
|
+
for (let i = 0; i < input.length; i++) {
|
|
86
|
+
const cursor = input[i];
|
|
87
|
+
if (cursor === "[" || cursor === "]") continue;
|
|
88
|
+
if (cursor === ":") {
|
|
89
|
+
if (endipv6Encountered === true) endIpv6 = true;
|
|
90
|
+
if (!consume(buffer, address, output)) break;
|
|
91
|
+
if (++tokenCount > 7) {
|
|
92
|
+
output.error = true;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (i > 0 && input[i - 1] === ":") endipv6Encountered = true;
|
|
96
|
+
address.push(":");
|
|
97
|
+
continue;
|
|
98
|
+
} else if (cursor === "%") {
|
|
99
|
+
if (!consume(buffer, address, output)) break;
|
|
100
|
+
consume = consumeIsZone;
|
|
101
|
+
} else {
|
|
102
|
+
buffer.push(cursor);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (buffer.length) if (consume === consumeIsZone) output.zone = buffer.join("");
|
|
107
|
+
else if (endIpv6) address.push(buffer.join(""));
|
|
108
|
+
else address.push(stringArrayToHexStripped(buffer));
|
|
109
|
+
output.address = address.join("");
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @typedef {Object} NormalizeIPv6Result
|
|
114
|
+
* @property {string} host - The normalized host.
|
|
115
|
+
* @property {string} [escapedHost] - The escaped host.
|
|
116
|
+
* @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} host
|
|
120
|
+
* @returns {NormalizeIPv6Result}
|
|
121
|
+
*/
|
|
122
|
+
function normalizeIPv6(host) {
|
|
123
|
+
if (findToken(host, ":") < 2) return {
|
|
124
|
+
host,
|
|
125
|
+
isIPV6: false
|
|
126
|
+
};
|
|
127
|
+
const ipv6 = getIPV6(host);
|
|
128
|
+
if (!ipv6.error) {
|
|
129
|
+
let newHost = ipv6.address;
|
|
130
|
+
let escapedHost = ipv6.address;
|
|
131
|
+
if (ipv6.zone) {
|
|
132
|
+
newHost += "%" + ipv6.zone;
|
|
133
|
+
escapedHost += "%25" + ipv6.zone;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
host: newHost,
|
|
137
|
+
isIPV6: true,
|
|
138
|
+
escapedHost
|
|
139
|
+
};
|
|
140
|
+
} else return {
|
|
141
|
+
host,
|
|
142
|
+
isIPV6: false
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @param {string} str
|
|
147
|
+
* @param {string} token
|
|
148
|
+
* @returns {number}
|
|
149
|
+
*/
|
|
150
|
+
function findToken(str, token) {
|
|
151
|
+
let ind = 0;
|
|
152
|
+
for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
|
|
153
|
+
return ind;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @param {string} path
|
|
157
|
+
* @returns {string}
|
|
158
|
+
*
|
|
159
|
+
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
|
160
|
+
*/
|
|
161
|
+
function removeDotSegments(path) {
|
|
162
|
+
let input = path;
|
|
163
|
+
const output = [];
|
|
164
|
+
let nextSlash = -1;
|
|
165
|
+
let len = 0;
|
|
166
|
+
while (len = input.length) {
|
|
167
|
+
if (len === 1) if (input === ".") break;
|
|
168
|
+
else if (input === "/") {
|
|
169
|
+
output.push("/");
|
|
170
|
+
break;
|
|
171
|
+
} else {
|
|
172
|
+
output.push(input);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
else if (len === 2) {
|
|
176
|
+
if (input[0] === ".") {
|
|
177
|
+
if (input[1] === ".") break;
|
|
178
|
+
else if (input[1] === "/") {
|
|
179
|
+
input = input.slice(2);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
} else if (input[0] === "/") {
|
|
183
|
+
if (input[1] === "." || input[1] === "/") {
|
|
184
|
+
output.push("/");
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else if (len === 3) {
|
|
189
|
+
if (input === "/..") {
|
|
190
|
+
if (output.length !== 0) output.pop();
|
|
191
|
+
output.push("/");
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (input[0] === ".") {
|
|
196
|
+
if (input[1] === ".") {
|
|
197
|
+
if (input[2] === "/") {
|
|
198
|
+
input = input.slice(3);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
} else if (input[1] === "/") {
|
|
202
|
+
input = input.slice(2);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
} else if (input[0] === "/") {
|
|
206
|
+
if (input[1] === ".") {
|
|
207
|
+
if (input[2] === "/") {
|
|
208
|
+
input = input.slice(2);
|
|
209
|
+
continue;
|
|
210
|
+
} else if (input[2] === ".") {
|
|
211
|
+
if (input[3] === "/") {
|
|
212
|
+
input = input.slice(3);
|
|
213
|
+
if (output.length !== 0) output.pop();
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if ((nextSlash = input.indexOf("/", 1)) === -1) {
|
|
220
|
+
output.push(input);
|
|
221
|
+
break;
|
|
222
|
+
} else {
|
|
223
|
+
output.push(input.slice(0, nextSlash));
|
|
224
|
+
input = input.slice(nextSlash);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return output.join("");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* @param {import('../types/index').URIComponent} component
|
|
231
|
+
* @param {boolean} esc
|
|
232
|
+
* @returns {import('../types/index').URIComponent}
|
|
233
|
+
*/
|
|
234
|
+
function normalizeComponentEncoding(component, esc) {
|
|
235
|
+
const func = esc !== true ? escape : unescape;
|
|
236
|
+
if (component.scheme !== void 0) component.scheme = func(component.scheme);
|
|
237
|
+
if (component.userinfo !== void 0) component.userinfo = func(component.userinfo);
|
|
238
|
+
if (component.host !== void 0) component.host = func(component.host);
|
|
239
|
+
if (component.path !== void 0) component.path = func(component.path);
|
|
240
|
+
if (component.query !== void 0) component.query = func(component.query);
|
|
241
|
+
if (component.fragment !== void 0) component.fragment = func(component.fragment);
|
|
242
|
+
return component;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @param {import('../types/index').URIComponent} component
|
|
246
|
+
* @returns {string|undefined}
|
|
247
|
+
*/
|
|
248
|
+
function recomposeAuthority(component) {
|
|
249
|
+
const uriTokens = [];
|
|
250
|
+
if (component.userinfo !== void 0) {
|
|
251
|
+
uriTokens.push(component.userinfo);
|
|
252
|
+
uriTokens.push("@");
|
|
253
|
+
}
|
|
254
|
+
if (component.host !== void 0) {
|
|
255
|
+
let host = unescape(component.host);
|
|
256
|
+
if (!isIPv4(host)) {
|
|
257
|
+
const ipV6res = normalizeIPv6(host);
|
|
258
|
+
if (ipV6res.isIPV6 === true) host = `[${ipV6res.escapedHost}]`;
|
|
259
|
+
else host = component.host;
|
|
260
|
+
}
|
|
261
|
+
uriTokens.push(host);
|
|
262
|
+
}
|
|
263
|
+
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
264
|
+
uriTokens.push(":");
|
|
265
|
+
uriTokens.push(String(component.port));
|
|
266
|
+
}
|
|
267
|
+
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
268
|
+
}
|
|
269
|
+
module.exports = {
|
|
270
|
+
nonSimpleDomain,
|
|
271
|
+
recomposeAuthority,
|
|
272
|
+
normalizeComponentEncoding,
|
|
273
|
+
removeDotSegments,
|
|
274
|
+
isIPv4,
|
|
275
|
+
isUUID,
|
|
276
|
+
normalizeIPv6,
|
|
277
|
+
stringArrayToHexStripped
|
|
278
|
+
};
|
|
279
|
+
}));
|
|
280
|
+
//#endregion
|
|
281
|
+
export default require_utils();
|
|
282
|
+
export { require_utils };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js
|
|
3
|
+
var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
var traverse = module.exports = function(schema, opts, cb) {
|
|
5
|
+
if (typeof opts == "function") {
|
|
6
|
+
cb = opts;
|
|
7
|
+
opts = {};
|
|
8
|
+
}
|
|
9
|
+
cb = opts.cb || cb;
|
|
10
|
+
var pre = typeof cb == "function" ? cb : cb.pre || function() {};
|
|
11
|
+
var post = cb.post || function() {};
|
|
12
|
+
_traverse(opts, pre, post, schema, "", schema);
|
|
13
|
+
};
|
|
14
|
+
traverse.keywords = {
|
|
15
|
+
additionalItems: true,
|
|
16
|
+
items: true,
|
|
17
|
+
contains: true,
|
|
18
|
+
additionalProperties: true,
|
|
19
|
+
propertyNames: true,
|
|
20
|
+
not: true,
|
|
21
|
+
if: true,
|
|
22
|
+
then: true,
|
|
23
|
+
else: true
|
|
24
|
+
};
|
|
25
|
+
traverse.arrayKeywords = {
|
|
26
|
+
items: true,
|
|
27
|
+
allOf: true,
|
|
28
|
+
anyOf: true,
|
|
29
|
+
oneOf: true
|
|
30
|
+
};
|
|
31
|
+
traverse.propsKeywords = {
|
|
32
|
+
$defs: true,
|
|
33
|
+
definitions: true,
|
|
34
|
+
properties: true,
|
|
35
|
+
patternProperties: true,
|
|
36
|
+
dependencies: true
|
|
37
|
+
};
|
|
38
|
+
traverse.skipKeywords = {
|
|
39
|
+
default: true,
|
|
40
|
+
enum: true,
|
|
41
|
+
const: true,
|
|
42
|
+
required: true,
|
|
43
|
+
maximum: true,
|
|
44
|
+
minimum: true,
|
|
45
|
+
exclusiveMaximum: true,
|
|
46
|
+
exclusiveMinimum: true,
|
|
47
|
+
multipleOf: true,
|
|
48
|
+
maxLength: true,
|
|
49
|
+
minLength: true,
|
|
50
|
+
pattern: true,
|
|
51
|
+
format: true,
|
|
52
|
+
maxItems: true,
|
|
53
|
+
minItems: true,
|
|
54
|
+
uniqueItems: true,
|
|
55
|
+
maxProperties: true,
|
|
56
|
+
minProperties: true
|
|
57
|
+
};
|
|
58
|
+
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
59
|
+
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
60
|
+
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
61
|
+
for (var key in schema) {
|
|
62
|
+
var sch = schema[key];
|
|
63
|
+
if (Array.isArray(sch)) {
|
|
64
|
+
if (key in traverse.arrayKeywords) for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema, i);
|
|
65
|
+
} else if (key in traverse.propsKeywords) {
|
|
66
|
+
if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
|
|
67
|
+
} else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) _traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
|
|
68
|
+
}
|
|
69
|
+
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function escapeJsonPtr(str) {
|
|
73
|
+
return str.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
//#endregion
|
|
77
|
+
export default require_json_schema_traverse();
|
|
78
|
+
export { require_json_schema_traverse };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NoReferenceSwallow } from "./index.js";
|
|
2
|
+
import { JSONSchema } from "json-schema-typed/draft-2020-12";
|
|
3
|
+
|
|
4
|
+
//#region src/schema/dereference.d.ts
|
|
5
|
+
interface DereferenceOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Return `true` to keep the Reference Object at `pointer` without inlining.
|
|
8
|
+
*/
|
|
9
|
+
preserveRef?: (pointer: string) => boolean;
|
|
10
|
+
setOriginalRef?: (schema: JSONSchema, ref: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves all $ref pointers in a schema and returns a new schema without any $ref pointers,
|
|
14
|
+
* except at locations where `preserveRef` returns `true`.
|
|
15
|
+
*/
|
|
16
|
+
declare function dereferenceSync(schema: JSONSchema, options?: DereferenceOptions): JSONSchema;
|
|
17
|
+
declare function dereferenceShallow<T>(schema: T, full: unknown): NoReferenceSwallow<T>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { DereferenceOptions, dereferenceShallow, dereferenceSync };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { appendInternalRefPath } from "./ref.js";
|
|
2
|
+
import { isPlainObject } from "../utils/is-plain-object.js";
|
|
3
|
+
import { resolveRefSync } from "./resolve-ref.js";
|
|
4
|
+
//#region src/schema/dereference.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves all $ref pointers in a schema and returns a new schema without any $ref pointers,
|
|
7
|
+
* except at locations where `preserveRef` returns `true`.
|
|
8
|
+
*/
|
|
9
|
+
function dereferenceSync(schema, options = {}) {
|
|
10
|
+
const { preserveRef, setOriginalRef = () => {} } = options;
|
|
11
|
+
if (typeof schema === "boolean") return schema;
|
|
12
|
+
const visitedNodes = /* @__PURE__ */ new Set();
|
|
13
|
+
const cloned = structuredClone(schema);
|
|
14
|
+
function resolve(current, pointer) {
|
|
15
|
+
if (visitedNodes.has(current)) return current;
|
|
16
|
+
visitedNodes.add(current);
|
|
17
|
+
if (Array.isArray(current)) for (let index = 0; index < current.length; index++) current[index] = resolve(current[index], appendInternalRefPath(pointer, index));
|
|
18
|
+
else if (isPlainObject(current)) {
|
|
19
|
+
if (typeof current.$ref === "string") {
|
|
20
|
+
if (preserveRef?.(pointer)) return current;
|
|
21
|
+
const ref = current["$ref"];
|
|
22
|
+
delete current["$ref"];
|
|
23
|
+
const resolved = resolve(resolveRefSync(ref, cloned), pointer);
|
|
24
|
+
setOriginalRef(resolved, ref);
|
|
25
|
+
setOriginalRef(current, ref);
|
|
26
|
+
if (typeof resolved === "boolean") throw new Error("invalid schema");
|
|
27
|
+
for (const k in resolved) if (!(k in current)) current[k] = resolved[k];
|
|
28
|
+
}
|
|
29
|
+
for (const key in current) current[key] = resolve(current[key], appendInternalRefPath(pointer, key));
|
|
30
|
+
}
|
|
31
|
+
return current;
|
|
32
|
+
}
|
|
33
|
+
return resolve(cloned, "#");
|
|
34
|
+
}
|
|
35
|
+
function dereferenceShallow(schema, full) {
|
|
36
|
+
if (isPlainObject(schema)) {
|
|
37
|
+
if (typeof schema.$ref !== "string") return schema;
|
|
38
|
+
const { $ref, ...rest } = schema;
|
|
39
|
+
const resolved = dereferenceShallow(resolveRefSync($ref, full), full);
|
|
40
|
+
if (typeof resolved !== "object") throw new Error(`invalid schema referenced via "${$ref}"`);
|
|
41
|
+
return {
|
|
42
|
+
...resolved,
|
|
43
|
+
...rest
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return schema;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { dereferenceShallow, dereferenceSync };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JSONSchema } from "json-schema-typed/draft-2020-12";
|
|
2
|
+
|
|
3
|
+
//#region src/schema/index.d.ts
|
|
4
|
+
type ReferenceObject = {
|
|
5
|
+
$ref: string;
|
|
6
|
+
};
|
|
7
|
+
type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? { [K in keyof T]: NoReference<T[K]> } : T;
|
|
8
|
+
type NoReferenceSwallow<T> = T extends ReferenceObject ? Exclude<T, ReferenceObject> : T;
|
|
9
|
+
type ParsedSchema = (JSONSchema & {
|
|
10
|
+
'x-playground-lazy'?: boolean;
|
|
11
|
+
discriminator?: {
|
|
12
|
+
propertyName?: string;
|
|
13
|
+
mapping?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
}) | boolean;
|
|
16
|
+
type SchemaResolver = (schema: ParsedSchema) => {
|
|
17
|
+
/** shallowly dereferenced schema */dereferenced: ParsedSchema; /** the ref value (if dereferenced) */
|
|
18
|
+
$ref?: string;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { NoReference, NoReferenceSwallow, ParsedSchema, SchemaResolver };
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ParsedSchema } from "./index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/schema/merge.d.ts
|
|
4
|
+
interface Options {
|
|
5
|
+
dereference?: (schema: ParsedSchema) => ParsedSchema | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Merge `allOf` object schema
|
|
9
|
+
*/
|
|
10
|
+
declare function mergeAllOf(schema: ParsedSchema, options?: Options): ParsedSchema;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { mergeAllOf };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { deepEqual } from "../utils/deep-equal.js";
|
|
2
|
+
//#region src/schema/merge.ts
|
|
3
|
+
/**
|
|
4
|
+
* Merge `allOf` object schema
|
|
5
|
+
*/
|
|
6
|
+
function mergeAllOf(schema, options = {}) {
|
|
7
|
+
if (typeof schema === "boolean") return schema;
|
|
8
|
+
const { dereference } = options;
|
|
9
|
+
if (dereference && "$ref" in schema && typeof schema.$ref === "string") schema = dereference(schema) ?? schema;
|
|
10
|
+
if (typeof schema === "boolean" || !schema.allOf) return schema;
|
|
11
|
+
const { allOf, ...rest } = schema;
|
|
12
|
+
let result = rest;
|
|
13
|
+
for (const item of allOf) result = intersection(result, item, options);
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
function intersection(a, b, options) {
|
|
17
|
+
a = mergeAllOf(a, options);
|
|
18
|
+
b = mergeAllOf(b, options);
|
|
19
|
+
if (typeof a === "boolean" && typeof b === "boolean") return a && b;
|
|
20
|
+
if (typeof a === "boolean") return a;
|
|
21
|
+
if (typeof b === "boolean") return b;
|
|
22
|
+
for (const unionField of ["anyOf", "oneOf"]) {
|
|
23
|
+
if (a[unionField] === void 0 && b[unionField] !== void 0) return {
|
|
24
|
+
...b,
|
|
25
|
+
[unionField]: b[unionField].map((item) => intersection(item, a, options))
|
|
26
|
+
};
|
|
27
|
+
if (a[unionField] !== void 0 && b[unionField] === void 0) return {
|
|
28
|
+
...a,
|
|
29
|
+
[unionField]: a[unionField].map((item) => intersection(item, b, options))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const result = { ...a };
|
|
33
|
+
for (const _k in b) {
|
|
34
|
+
const key = _k;
|
|
35
|
+
switch (key) {
|
|
36
|
+
case "$id":
|
|
37
|
+
case "$comment":
|
|
38
|
+
case "description":
|
|
39
|
+
case "examples":
|
|
40
|
+
case "allOf":
|
|
41
|
+
case "writeOnly":
|
|
42
|
+
case "readOnly": break;
|
|
43
|
+
case "title": {
|
|
44
|
+
const value = b[key];
|
|
45
|
+
if (value === void 0) break;
|
|
46
|
+
if (result[key]) result[key] = `${result[key]} & ${value}`;
|
|
47
|
+
else result[key] = value;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "minItems":
|
|
51
|
+
case "minimum":
|
|
52
|
+
case "exclusiveMinimum":
|
|
53
|
+
case "minProperties":
|
|
54
|
+
case "minContains":
|
|
55
|
+
case "minLength": {
|
|
56
|
+
const value = b[key];
|
|
57
|
+
if (value === void 0) break;
|
|
58
|
+
result[key] = result[key] === void 0 ? value : Math.max(result[key], value);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case "maxContains":
|
|
62
|
+
case "maxItems":
|
|
63
|
+
case "maxLength":
|
|
64
|
+
case "maxProperties":
|
|
65
|
+
case "maximum":
|
|
66
|
+
case "exclusiveMaximum": {
|
|
67
|
+
const value = b[key];
|
|
68
|
+
if (value === void 0) break;
|
|
69
|
+
result[key] = result[key] === void 0 ? value : Math.min(result[key], value);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "enum": {
|
|
73
|
+
const value = b[key];
|
|
74
|
+
if (value === void 0) break;
|
|
75
|
+
result[key] = result[key] === void 0 ? value : intersectArray(result[key], value);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "anyOf":
|
|
79
|
+
case "oneOf": {
|
|
80
|
+
const value = b[key];
|
|
81
|
+
if (value !== void 0 && result[key] !== void 0) {
|
|
82
|
+
const product = [];
|
|
83
|
+
for (const aItem of result[key]) for (const bItem of value) {
|
|
84
|
+
const merged = intersection(aItem, bItem, options);
|
|
85
|
+
if (merged !== false) product.push(merged);
|
|
86
|
+
}
|
|
87
|
+
result[key] = product;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "format":
|
|
92
|
+
case "const":
|
|
93
|
+
case "type": {
|
|
94
|
+
const value = b[key];
|
|
95
|
+
if (value === void 0) break;
|
|
96
|
+
result[key] ??= value;
|
|
97
|
+
if (!deepEqual(result[key], value)) return false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case "required": {
|
|
101
|
+
const value = b[key];
|
|
102
|
+
if (value === void 0) break;
|
|
103
|
+
result[key] = [...result[key] ?? [], ...value];
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "properties":
|
|
107
|
+
case "patternProperties": {
|
|
108
|
+
const value = b[key];
|
|
109
|
+
if (value === void 0) break;
|
|
110
|
+
if (result[key] === void 0) {
|
|
111
|
+
result[key] = value;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
const out = {};
|
|
115
|
+
const allProps = /* @__PURE__ */ new Set();
|
|
116
|
+
for (const k in result[key]) allProps.add(k);
|
|
117
|
+
for (const k in value) allProps.add(k);
|
|
118
|
+
for (const prop of allProps) {
|
|
119
|
+
const aProp = result[key][prop];
|
|
120
|
+
const bProp = value[prop];
|
|
121
|
+
if (aProp === void 0) out[prop] = bProp;
|
|
122
|
+
else if (bProp === void 0) out[prop] = aProp;
|
|
123
|
+
else out[prop] = intersection(aProp, bProp, options);
|
|
124
|
+
}
|
|
125
|
+
result[key] = out;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "additionalProperties":
|
|
129
|
+
case "additionalItems":
|
|
130
|
+
case "contains":
|
|
131
|
+
case "items": {
|
|
132
|
+
const value = b[key];
|
|
133
|
+
if (value === void 0) break;
|
|
134
|
+
result[key] = result[key] === void 0 ? value : intersection(result[key], value, options);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "not": {
|
|
138
|
+
const value = b[key];
|
|
139
|
+
if (value === void 0) break;
|
|
140
|
+
if (result[key] && value) result.not = { anyOf: [result[key], value] };
|
|
141
|
+
else if (value) result.not = value;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
default: result[key] = b[key];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
function intersectArray(a, b) {
|
|
150
|
+
const out = /* @__PURE__ */ new Set();
|
|
151
|
+
for (const item of a) if (b.includes(item)) out.add(item);
|
|
152
|
+
for (const item of b) if (a.includes(item)) out.add(item);
|
|
153
|
+
return Array.from(out);
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
export { mergeAllOf };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/schema/ref.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* RFC 6901 reference-token encoding for JSON Pointer fragments used in in-document `$ref` (`#/…`).
|
|
4
|
+
*
|
|
5
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6901
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Build an in-document `$ref` string from logical path segments (e.g. `['components','schemas','Pet']` → `#/components/schemas/Pet`).
|
|
9
|
+
*/
|
|
10
|
+
declare function encodeInternalRef(segments: readonly string[]): string;
|
|
11
|
+
/**
|
|
12
|
+
* Append a segment to an in-document JSON Pointer (e.g. `#` + `components` → `#/components`).
|
|
13
|
+
*/
|
|
14
|
+
declare function appendInternalRefPath(base: string, segment: string | number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Parse an in-document `$ref` (`#/…`) into decoded path segments for walking the root document.
|
|
17
|
+
*/
|
|
18
|
+
declare function decodeInternalRef(ref: string): string[];
|
|
19
|
+
//#endregion
|
|
20
|
+
export { appendInternalRefPath, decodeInternalRef, encodeInternalRef };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/schema/ref.ts
|
|
2
|
+
/**
|
|
3
|
+
* RFC 6901 reference-token encoding for JSON Pointer fragments used in in-document `$ref` (`#/…`).
|
|
4
|
+
*
|
|
5
|
+
* @see https://datatracker.ietf.org/doc/html/rfc6901
|
|
6
|
+
*/
|
|
7
|
+
function encodeSegment(segment) {
|
|
8
|
+
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
9
|
+
}
|
|
10
|
+
function decodeSegment(segment) {
|
|
11
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build an in-document `$ref` string from logical path segments (e.g. `['components','schemas','Pet']` → `#/components/schemas/Pet`).
|
|
15
|
+
*/
|
|
16
|
+
function encodeInternalRef(segments) {
|
|
17
|
+
if (segments.length === 0) return "#/";
|
|
18
|
+
return `#/${segments.map(encodeSegment).join("/")}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Append a segment to an in-document JSON Pointer (e.g. `#` + `components` → `#/components`).
|
|
22
|
+
*/
|
|
23
|
+
function appendInternalRefPath(base, segment) {
|
|
24
|
+
const encoded = encodeSegment(String(segment));
|
|
25
|
+
if (base === "#") return `#/${encoded}`;
|
|
26
|
+
return `${base}/${encoded}`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse an in-document `$ref` (`#/…`) into decoded path segments for walking the root document.
|
|
30
|
+
*/
|
|
31
|
+
function decodeInternalRef(ref) {
|
|
32
|
+
if (!ref.startsWith("#")) throw new Error("expected in-document $ref starting with `#`");
|
|
33
|
+
const raw = ref.slice(1);
|
|
34
|
+
const out = [];
|
|
35
|
+
if (raw.length === 0) return out;
|
|
36
|
+
for (const token of raw.split("/")) {
|
|
37
|
+
if (token.length === 0) continue;
|
|
38
|
+
out.push(decodeSegment(token));
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { appendInternalRefPath, decodeInternalRef, encodeInternalRef };
|