@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,11 @@
|
|
|
1
|
+
import { decodeInternalRef } from "./ref.js";
|
|
2
|
+
import { isPlainObject } from "../utils/is-plain-object.js";
|
|
3
|
+
//#region src/schema/resolve-ref.ts
|
|
4
|
+
function resolveRefSync(ref, schema) {
|
|
5
|
+
let current = schema;
|
|
6
|
+
for (const seg of decodeInternalRef(ref)) if (isPlainObject(current)) current = current[seg];
|
|
7
|
+
else return;
|
|
8
|
+
return current;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { resolveRefSync };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/schema/sample.d.ts
|
|
2
|
+
interface JsonSchemaSampleOptions {
|
|
3
|
+
readonly skipNonRequired?: boolean;
|
|
4
|
+
readonly skipReadOnly?: boolean;
|
|
5
|
+
readonly skipWriteOnly?: boolean;
|
|
6
|
+
readonly quiet?: boolean;
|
|
7
|
+
readonly enablePatterns?: boolean;
|
|
8
|
+
readonly maxSampleDepth?: number;
|
|
9
|
+
}
|
|
10
|
+
declare function sample(schema: object, options?: JsonSchemaSampleOptions, spec?: object): unknown;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { JsonSchemaSampleOptions, sample };
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { isPlainObject } from "../utils/is-plain-object.js";
|
|
2
|
+
import { resolveRefSync } from "./resolve-ref.js";
|
|
3
|
+
import { require_deepmerge } from "../node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js";
|
|
4
|
+
const mergeDeep = (0, require_deepmerge().deepmerge)({
|
|
5
|
+
all: true,
|
|
6
|
+
isMergeableObject(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
const SKIP = Symbol("skip");
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
skipReadOnly: false,
|
|
13
|
+
maxSampleDepth: 15
|
|
14
|
+
};
|
|
15
|
+
let refResolving = {};
|
|
16
|
+
const seenObjectStack = [];
|
|
17
|
+
function clearCaches() {
|
|
18
|
+
refResolving = {};
|
|
19
|
+
seenObjectStack.length = 0;
|
|
20
|
+
}
|
|
21
|
+
function popStack(context) {
|
|
22
|
+
if (context) seenObjectStack.pop();
|
|
23
|
+
}
|
|
24
|
+
function inferType(schema) {
|
|
25
|
+
if (schema.type !== void 0) {
|
|
26
|
+
const t = schema.type;
|
|
27
|
+
return Array.isArray(t) ? t.length === 0 ? null : String(t[0]) : String(t);
|
|
28
|
+
}
|
|
29
|
+
for (const [kw, ty] of Object.entries({
|
|
30
|
+
multipleOf: "number",
|
|
31
|
+
maximum: "number",
|
|
32
|
+
exclusiveMaximum: "number",
|
|
33
|
+
minimum: "number",
|
|
34
|
+
exclusiveMinimum: "number",
|
|
35
|
+
maxLength: "string",
|
|
36
|
+
minLength: "string",
|
|
37
|
+
pattern: "string",
|
|
38
|
+
items: "array",
|
|
39
|
+
maxItems: "array",
|
|
40
|
+
minItems: "array",
|
|
41
|
+
uniqueItems: "array",
|
|
42
|
+
additionalItems: "array",
|
|
43
|
+
maxProperties: "object",
|
|
44
|
+
minProperties: "object",
|
|
45
|
+
required: "object",
|
|
46
|
+
additionalProperties: "object",
|
|
47
|
+
properties: "object",
|
|
48
|
+
patternProperties: "object",
|
|
49
|
+
dependencies: "object"
|
|
50
|
+
})) if (schema[kw] !== void 0) return ty;
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
function getCircularPlaceholder(type) {
|
|
54
|
+
if (type === "object") return {};
|
|
55
|
+
if (type === "array") return [];
|
|
56
|
+
}
|
|
57
|
+
function hashCode(str) {
|
|
58
|
+
let hash = 0;
|
|
59
|
+
for (let i = 0; i < str.length; i++) {
|
|
60
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
61
|
+
hash |= 0;
|
|
62
|
+
}
|
|
63
|
+
return hash;
|
|
64
|
+
}
|
|
65
|
+
function jsf32(a, b, c, d) {
|
|
66
|
+
return () => {
|
|
67
|
+
a |= 0;
|
|
68
|
+
b |= 0;
|
|
69
|
+
c |= 0;
|
|
70
|
+
d |= 0;
|
|
71
|
+
const t = a - (b << 27 | b >>> 5) | 0;
|
|
72
|
+
a = b ^ (c << 17 | c >>> 15);
|
|
73
|
+
b = c + d | 0;
|
|
74
|
+
c = d + t | 0;
|
|
75
|
+
d = a + t | 0;
|
|
76
|
+
return (d >>> 0) / 4294967296;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function uuidFromSeed(str) {
|
|
80
|
+
const hash = hashCode(str);
|
|
81
|
+
const random = jsf32(hash, hash, hash, hash);
|
|
82
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
83
|
+
const r = random() * 16 | 0;
|
|
84
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function toRFCDateTime(date, omitTime, omitDate, ms) {
|
|
88
|
+
const pad = (n) => n < 10 ? `0${n}` : `${n}`;
|
|
89
|
+
let res = omitDate ? "" : `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
|
90
|
+
if (!omitTime) {
|
|
91
|
+
res += `T${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}`;
|
|
92
|
+
if (ms) res += `.${(date.getUTCMilliseconds() / 1e3).toFixed(3).slice(2, 5)}`;
|
|
93
|
+
res += "Z";
|
|
94
|
+
}
|
|
95
|
+
return res;
|
|
96
|
+
}
|
|
97
|
+
function ensureMinLength(sample, min) {
|
|
98
|
+
if (min > sample.length) return sample.repeat(Math.trunc(min / sample.length) + 1).substring(0, min);
|
|
99
|
+
return sample;
|
|
100
|
+
}
|
|
101
|
+
function sampleBoolean() {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
function sampleNumber(schema) {
|
|
105
|
+
let res = 0;
|
|
106
|
+
if (schema.type === "number" && (schema.format === "float" || schema.format === "double")) res = .1;
|
|
107
|
+
const exMinB = typeof schema.exclusiveMinimum === "boolean";
|
|
108
|
+
const exMaxB = typeof schema.exclusiveMaximum === "boolean";
|
|
109
|
+
if (exMinB || exMaxB) {
|
|
110
|
+
if (schema.maximum != null && schema.minimum != null) {
|
|
111
|
+
const min = schema.minimum;
|
|
112
|
+
const max = schema.maximum;
|
|
113
|
+
res = schema.exclusiveMinimum ? Math.floor(min) + 1 : min;
|
|
114
|
+
if (schema.exclusiveMaximum && res >= max || !schema.exclusiveMaximum && res > max) res = (max + min) / 2;
|
|
115
|
+
return res;
|
|
116
|
+
}
|
|
117
|
+
if (schema.minimum != null) {
|
|
118
|
+
const min = schema.minimum;
|
|
119
|
+
return schema.exclusiveMinimum ? Math.floor(min) + 1 : min;
|
|
120
|
+
}
|
|
121
|
+
if (schema.maximum != null) {
|
|
122
|
+
const max = schema.maximum;
|
|
123
|
+
if (schema.exclusiveMaximum) return max > 0 ? 0 : Math.floor(max) - 1;
|
|
124
|
+
return max > 0 ? 0 : max;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
if (schema.minimum != null) return schema.minimum;
|
|
128
|
+
if (schema.exclusiveMinimum != null) {
|
|
129
|
+
res = Math.floor(schema.exclusiveMinimum) + 1;
|
|
130
|
+
if (res === schema.exclusiveMaximum) res = (res + Math.floor(schema.exclusiveMaximum) - 1) / 2;
|
|
131
|
+
} else if (schema.exclusiveMaximum != null) res = Math.floor(schema.exclusiveMaximum) - 1;
|
|
132
|
+
else if (schema.maximum != null) res = schema.maximum;
|
|
133
|
+
}
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
function defaultStringSample(min, max, pattern, enablePatterns) {
|
|
137
|
+
if (pattern && enablePatterns) return patternSample(pattern);
|
|
138
|
+
let res = ensureMinLength("string", min);
|
|
139
|
+
if (max != null && res.length > max) res = res.substring(0, max);
|
|
140
|
+
return res;
|
|
141
|
+
}
|
|
142
|
+
/** Minimal pattern sampler for `enablePatterns` (subset of openapi-sampler). */
|
|
143
|
+
function patternSample(pattern) {
|
|
144
|
+
const stripped = pattern.replace(/^\^?/, "").replace(/\$?$/, "");
|
|
145
|
+
const m = stripped.match(/^(.)\{(\d+)\}$/);
|
|
146
|
+
if (m) return m[1].repeat(parseInt(m[2], 10));
|
|
147
|
+
return stripped.length > 0 ? stripped : "x";
|
|
148
|
+
}
|
|
149
|
+
function sampleString(schema, options, _spec, context) {
|
|
150
|
+
const format = schema.format || "default";
|
|
151
|
+
const propertyName = context?.propertyName;
|
|
152
|
+
const min = schema.minLength ?? 0;
|
|
153
|
+
const max = schema.maxLength;
|
|
154
|
+
const pattern = schema.pattern;
|
|
155
|
+
const fixed = /* @__PURE__ */ new Date("2019-08-24T14:15:22.123Z");
|
|
156
|
+
const formats = {
|
|
157
|
+
email: () => "user@example.com",
|
|
158
|
+
"idn-email": () => "пошта@укр.нет",
|
|
159
|
+
password: () => {
|
|
160
|
+
let res = "pa$$word";
|
|
161
|
+
if (min > res.length) {
|
|
162
|
+
res += "_";
|
|
163
|
+
res += ensureMinLength("qwerty!@#$%^123456", min - res.length).substring(0, min - res.length);
|
|
164
|
+
}
|
|
165
|
+
return res;
|
|
166
|
+
},
|
|
167
|
+
"date-time": () => toRFCDateTime(fixed, false, false, false),
|
|
168
|
+
date: () => toRFCDateTime(fixed, true, false, false),
|
|
169
|
+
time: () => toRFCDateTime(fixed, false, true, false).slice(1),
|
|
170
|
+
ipv4: () => "192.168.0.1",
|
|
171
|
+
ipv6: () => "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
|
172
|
+
hostname: () => "example.com",
|
|
173
|
+
"idn-hostname": () => "приклад.укр",
|
|
174
|
+
uri: () => "http://example.com",
|
|
175
|
+
"uri-reference": () => "../dictionary",
|
|
176
|
+
"uri-template": () => "http://example.com/{endpoint}",
|
|
177
|
+
iri: () => "http://example.com/entity/1",
|
|
178
|
+
"iri-reference": () => "/entity/1",
|
|
179
|
+
uuid: () => uuidFromSeed(propertyName || "id"),
|
|
180
|
+
"json-pointer": () => "/json/pointer",
|
|
181
|
+
"relative-json-pointer": () => "1/relative/json/pointer",
|
|
182
|
+
regex: () => "/regex/",
|
|
183
|
+
default: () => defaultStringSample(min, max, pattern, options.enablePatterns)
|
|
184
|
+
};
|
|
185
|
+
return (formats[format] ?? formats.default)();
|
|
186
|
+
}
|
|
187
|
+
function sampleArray(schema, options, spec, context) {
|
|
188
|
+
const depth = context?.depth ?? 1;
|
|
189
|
+
let arrayLength = Math.min(schema.maxItems != null ? schema.maxItems : Number.POSITIVE_INFINITY, schema.minItems ?? 1);
|
|
190
|
+
const items = schema.prefixItems ?? schema.items ?? schema.contains;
|
|
191
|
+
if (Array.isArray(items)) arrayLength = Math.max(arrayLength, items.length);
|
|
192
|
+
const itemSchemaGetter = (i) => {
|
|
193
|
+
if (Array.isArray(items)) return items[i] ?? {};
|
|
194
|
+
return items ?? {};
|
|
195
|
+
};
|
|
196
|
+
const res = [];
|
|
197
|
+
if (!items) return res;
|
|
198
|
+
for (let i = 0; i < arrayLength; i++) {
|
|
199
|
+
const { value } = traverse(itemSchemaGetter(i), options, spec, {
|
|
200
|
+
depth: depth + 1,
|
|
201
|
+
propertyName: context?.propertyName
|
|
202
|
+
});
|
|
203
|
+
res.push(value);
|
|
204
|
+
}
|
|
205
|
+
return res;
|
|
206
|
+
}
|
|
207
|
+
function sampleObject(schema, options, spec, context) {
|
|
208
|
+
let res = {};
|
|
209
|
+
const depth = context?.depth ?? 1;
|
|
210
|
+
if (schema.properties && typeof schema.properties === "object") {
|
|
211
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
212
|
+
const requiredSet = new Set(required);
|
|
213
|
+
for (const propertyName of Object.keys(schema.properties)) {
|
|
214
|
+
if (options.skipNonRequired && !requiredSet.has(propertyName)) continue;
|
|
215
|
+
const propSchema = schema.properties[propertyName];
|
|
216
|
+
const sample = traverse(propSchema, options, spec, {
|
|
217
|
+
propertyName,
|
|
218
|
+
depth: depth + 1
|
|
219
|
+
});
|
|
220
|
+
if (options.skipReadOnly && sample.readOnly) {
|
|
221
|
+
if (context?.isAllOfChild) res[propertyName] = SKIP;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (options.skipWriteOnly && sample.writeOnly) {
|
|
225
|
+
if (context?.isAllOfChild) res[propertyName] = SKIP;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
res[propertyName] = sample.value;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
232
|
+
const ap = schema.additionalProperties;
|
|
233
|
+
const baseName = ap["x-additionalPropertiesName"] || "property";
|
|
234
|
+
res[`${String(baseName)}1`] = traverse(ap, options, spec, { depth: depth + 1 }).value;
|
|
235
|
+
res[`${String(baseName)}2`] = traverse(ap, options, spec, { depth: depth + 1 }).value;
|
|
236
|
+
}
|
|
237
|
+
if (schema.properties && typeof schema.properties === "object" && typeof schema.maxProperties === "number" && Object.keys(res).length > schema.maxProperties) {
|
|
238
|
+
const filtered = {};
|
|
239
|
+
let added = 0;
|
|
240
|
+
const req = Array.isArray(schema.required) ? schema.required : [];
|
|
241
|
+
for (const name of req) if (res[name] !== void 0) {
|
|
242
|
+
filtered[name] = res[name];
|
|
243
|
+
added++;
|
|
244
|
+
}
|
|
245
|
+
for (const name of Object.keys(res)) if (added < schema.maxProperties && !(name in filtered)) {
|
|
246
|
+
filtered[name] = res[name];
|
|
247
|
+
added++;
|
|
248
|
+
}
|
|
249
|
+
res = filtered;
|
|
250
|
+
}
|
|
251
|
+
return res;
|
|
252
|
+
}
|
|
253
|
+
function inferExample(schema) {
|
|
254
|
+
if (schema.const !== void 0) return schema.const;
|
|
255
|
+
if (Array.isArray(schema.examples) && schema.examples.length > 0) return schema.examples[0];
|
|
256
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) return schema.enum[0];
|
|
257
|
+
if (schema.default !== void 0) return schema.default;
|
|
258
|
+
}
|
|
259
|
+
function tryInferExample(schema) {
|
|
260
|
+
const example = inferExample(schema);
|
|
261
|
+
if (example !== void 0) return {
|
|
262
|
+
value: example,
|
|
263
|
+
readOnly: schema.readOnly,
|
|
264
|
+
writeOnly: schema.writeOnly,
|
|
265
|
+
type: null
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function allOfSample(into, children, options, spec, context) {
|
|
269
|
+
const res = traverse(into, options, spec);
|
|
270
|
+
const subSamples = [];
|
|
271
|
+
for (const subSchema of children) {
|
|
272
|
+
const { type, readOnly, writeOnly, value } = traverse({
|
|
273
|
+
type: res.type,
|
|
274
|
+
...subSchema
|
|
275
|
+
}, options, spec, {
|
|
276
|
+
...context,
|
|
277
|
+
depth: context?.depth ?? 1,
|
|
278
|
+
isAllOfChild: true
|
|
279
|
+
});
|
|
280
|
+
if (res.type && type && type !== res.type) {
|
|
281
|
+
if (!options.quiet) console.warn("allOf: schemas with different types can't be merged");
|
|
282
|
+
res.type = type;
|
|
283
|
+
}
|
|
284
|
+
res.type = res.type ?? type;
|
|
285
|
+
res.readOnly = res.readOnly || readOnly;
|
|
286
|
+
res.writeOnly = res.writeOnly || writeOnly;
|
|
287
|
+
if (value != null) subSamples.push(value);
|
|
288
|
+
}
|
|
289
|
+
if (res.type === "object") {
|
|
290
|
+
const merged = mergeDeep(res.value || {}, ...subSamples.filter((s) => typeof s === "object" && s !== null));
|
|
291
|
+
for (const key of Object.keys(merged)) if (merged[key] === SKIP) delete merged[key];
|
|
292
|
+
return {
|
|
293
|
+
...res,
|
|
294
|
+
value: merged
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (res.type === "array") {
|
|
298
|
+
if (!options.quiet) console.warn("OpenAPI Sampler: found allOf with \"array\" type. Result may be incorrect");
|
|
299
|
+
}
|
|
300
|
+
const last = subSamples[subSamples.length - 1];
|
|
301
|
+
return {
|
|
302
|
+
...res,
|
|
303
|
+
value: last != null ? last : res.value
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const typeSamplers = {
|
|
307
|
+
array: sampleArray,
|
|
308
|
+
boolean: sampleBoolean,
|
|
309
|
+
integer: sampleNumber,
|
|
310
|
+
number: sampleNumber,
|
|
311
|
+
object: sampleObject,
|
|
312
|
+
string: sampleString
|
|
313
|
+
};
|
|
314
|
+
function traverseOneOrAnyOf(parent, selectedSubSchema, options, spec, context) {
|
|
315
|
+
const inferred = tryInferExample(parent);
|
|
316
|
+
if (inferred !== void 0) return inferred;
|
|
317
|
+
const localExample = traverse({
|
|
318
|
+
...parent,
|
|
319
|
+
oneOf: void 0,
|
|
320
|
+
anyOf: void 0
|
|
321
|
+
}, options, spec, context);
|
|
322
|
+
const subExample = traverse(selectedSubSchema, options, spec, context);
|
|
323
|
+
if (typeof localExample.value === "object" && localExample.value !== null && typeof subExample.value === "object" && subExample.value !== null) {
|
|
324
|
+
const mergedExample = mergeDeep(localExample.value, subExample.value);
|
|
325
|
+
return {
|
|
326
|
+
...subExample,
|
|
327
|
+
value: mergedExample
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return subExample;
|
|
331
|
+
}
|
|
332
|
+
function traverse(schema, options, spec, context) {
|
|
333
|
+
if (context) {
|
|
334
|
+
if (seenObjectStack.includes(schema)) return {
|
|
335
|
+
value: getCircularPlaceholder(inferType(schema)),
|
|
336
|
+
type: null
|
|
337
|
+
};
|
|
338
|
+
seenObjectStack.push(schema);
|
|
339
|
+
}
|
|
340
|
+
if (context && (context.depth ?? 1) > options.maxSampleDepth) {
|
|
341
|
+
popStack(context);
|
|
342
|
+
return {
|
|
343
|
+
value: getCircularPlaceholder(inferType(schema)),
|
|
344
|
+
type: null
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (!isPlainObject(schema)) {
|
|
348
|
+
popStack(context);
|
|
349
|
+
return {
|
|
350
|
+
value: schema,
|
|
351
|
+
type: null
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const s = schema;
|
|
355
|
+
if (typeof s.$ref === "string") {
|
|
356
|
+
if (spec == null) throw new Error("Your schema contains $ref. You must provide full specification in the third parameter.");
|
|
357
|
+
const ref = decodeURIComponent(s.$ref);
|
|
358
|
+
if (!ref.startsWith("#")) throw new Error("Your schema contains $ref. Only in-document references (`#/…`) are supported.");
|
|
359
|
+
if (refResolving[ref]) {
|
|
360
|
+
const referencedType = inferType(resolveRefSync(ref, spec) ?? {});
|
|
361
|
+
popStack(context);
|
|
362
|
+
return {
|
|
363
|
+
value: getCircularPlaceholder(referencedType),
|
|
364
|
+
type: null
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
refResolving[ref] = true;
|
|
368
|
+
const referenced = resolveRefSync(ref, spec);
|
|
369
|
+
if (referenced === void 0) {
|
|
370
|
+
refResolving[ref] = false;
|
|
371
|
+
popStack(context);
|
|
372
|
+
throw new Error(`Could not resolve $ref: ${s.$ref}`);
|
|
373
|
+
}
|
|
374
|
+
const result = traverse(referenced, options, spec, context);
|
|
375
|
+
refResolving[ref] = false;
|
|
376
|
+
popStack(context);
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
if (s.example !== void 0) {
|
|
380
|
+
popStack(context);
|
|
381
|
+
return {
|
|
382
|
+
value: s.example,
|
|
383
|
+
readOnly: s.readOnly,
|
|
384
|
+
writeOnly: s.writeOnly,
|
|
385
|
+
type: s.type
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
if (s.allOf !== void 0) {
|
|
389
|
+
popStack(context);
|
|
390
|
+
return tryInferExample(s) ?? allOfSample({
|
|
391
|
+
...s,
|
|
392
|
+
allOf: void 0
|
|
393
|
+
}, s.allOf, options, spec, context);
|
|
394
|
+
}
|
|
395
|
+
if (s.oneOf && Array.isArray(s.oneOf) && s.oneOf.length > 0) {
|
|
396
|
+
if (s.anyOf && !options.quiet) console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf");
|
|
397
|
+
popStack(context);
|
|
398
|
+
return traverseOneOrAnyOf(s, Object.assign({
|
|
399
|
+
readOnly: s.readOnly,
|
|
400
|
+
writeOnly: s.writeOnly
|
|
401
|
+
}, s.oneOf[0]), options, spec, context);
|
|
402
|
+
}
|
|
403
|
+
if (s.anyOf && Array.isArray(s.anyOf) && s.anyOf.length > 0) {
|
|
404
|
+
popStack(context);
|
|
405
|
+
return traverseOneOrAnyOf(s, Object.assign({
|
|
406
|
+
readOnly: s.readOnly,
|
|
407
|
+
writeOnly: s.writeOnly
|
|
408
|
+
}, s.anyOf[0]), options, spec, context);
|
|
409
|
+
}
|
|
410
|
+
if (s.if && s.then) {
|
|
411
|
+
popStack(context);
|
|
412
|
+
const { if: ifSchema, then, ...rest } = s;
|
|
413
|
+
return traverse(mergeDeep(rest, ifSchema, then), options, spec, context);
|
|
414
|
+
}
|
|
415
|
+
let example = inferExample(s);
|
|
416
|
+
let type = null;
|
|
417
|
+
if (example === void 0) {
|
|
418
|
+
example = null;
|
|
419
|
+
type = s.type;
|
|
420
|
+
if (Array.isArray(type) && type.length > 0) type = type[0];
|
|
421
|
+
if (!type) type = inferType(s);
|
|
422
|
+
const sampler = type ? typeSamplers[type] : void 0;
|
|
423
|
+
if (sampler) example = sampler(s, options, spec, context);
|
|
424
|
+
}
|
|
425
|
+
popStack(context);
|
|
426
|
+
return {
|
|
427
|
+
value: example,
|
|
428
|
+
readOnly: s.readOnly,
|
|
429
|
+
writeOnly: s.writeOnly,
|
|
430
|
+
type
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function sample(schema, options, spec) {
|
|
434
|
+
const opts = {
|
|
435
|
+
...defaultOptions,
|
|
436
|
+
...options
|
|
437
|
+
};
|
|
438
|
+
clearCaches();
|
|
439
|
+
return traverse(schema, opts, spec).value;
|
|
440
|
+
}
|
|
441
|
+
//#endregion
|
|
442
|
+
export { sample };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParsedSchema, SchemaResolver } from "./index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/schema/to-string.d.ts
|
|
4
|
+
declare enum FormatFlags {
|
|
5
|
+
None = 0,
|
|
6
|
+
UseAlias = 1
|
|
7
|
+
}
|
|
8
|
+
declare function schemaToString(value: ParsedSchema, resolver?: SchemaResolver, flags?: FormatFlags): string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { FormatFlags, schemaToString };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/schema/to-string.ts
|
|
2
|
+
let FormatFlags = /* @__PURE__ */ function(FormatFlags) {
|
|
3
|
+
FormatFlags[FormatFlags["None"] = 0] = "None";
|
|
4
|
+
FormatFlags[FormatFlags["UseAlias"] = 1] = "UseAlias";
|
|
5
|
+
return FormatFlags;
|
|
6
|
+
}({});
|
|
7
|
+
function schemaToString(value, resolver, flags = 0) {
|
|
8
|
+
function union(union, sep, flags) {
|
|
9
|
+
const members = /* @__PURE__ */ new Set();
|
|
10
|
+
const out = [];
|
|
11
|
+
let nullable = false;
|
|
12
|
+
for (const item of union) {
|
|
13
|
+
const result = run(item, flags | 1);
|
|
14
|
+
if (result === "null") nullable = true;
|
|
15
|
+
else if (result !== "unknown" && !members.has(result)) {
|
|
16
|
+
out.push(result);
|
|
17
|
+
members.add(result);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (nullable) out.push("null");
|
|
21
|
+
return out.join(sep);
|
|
22
|
+
}
|
|
23
|
+
function run(input, flags) {
|
|
24
|
+
const { dereferenced: schema, $ref: rawRef } = resolver?.(input) ?? { dereferenced: input };
|
|
25
|
+
if (schema === true) return "any";
|
|
26
|
+
else if (schema === false) return "never";
|
|
27
|
+
if ((flags & 1) === 1) {
|
|
28
|
+
if (schema.title) return schema.title;
|
|
29
|
+
if (typeof rawRef === "string") {
|
|
30
|
+
const ref = rawRef.split("/");
|
|
31
|
+
if (ref.length > 0) return ref[ref.length - 1];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(schema.type)) return union(schema.type.map((type) => ({
|
|
35
|
+
...schema,
|
|
36
|
+
type
|
|
37
|
+
})), " | ", flags);
|
|
38
|
+
if (schema.type === "array") return `array<${schema.items ? run(schema.items, flags | 1) : "unknown"}>`;
|
|
39
|
+
if (schema.oneOf && schema.anyOf) return `(${union(schema.oneOf, " | ", flags)}) & (${union(schema.anyOf, " | ", flags)})`;
|
|
40
|
+
const or = schema.oneOf ?? schema.anyOf;
|
|
41
|
+
if (or) return union(or, " | ", flags);
|
|
42
|
+
if (schema.allOf) return union(schema.allOf, " & ", flags);
|
|
43
|
+
if (schema.not) return `not (${run(schema.not, flags)})`;
|
|
44
|
+
if (schema.type === "string" && schema.format === "binary") return "file";
|
|
45
|
+
if (typeof schema.type === "string") return schema.type;
|
|
46
|
+
return "unknown";
|
|
47
|
+
}
|
|
48
|
+
return run(value, flags);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { FormatFlags, schemaToString };
|
package/dist/utils/cn.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
2
|
+
//#region src/utils/deep-equal.ts
|
|
3
|
+
function deepEqual(a, b) {
|
|
4
|
+
if (a === b) return true;
|
|
5
|
+
if (a == null || b == null) return false;
|
|
6
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
7
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
8
|
+
if (a.length !== b.length) return false;
|
|
9
|
+
return a.every((item, index) => deepEqual(item, b[index]));
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(a) || Array.isArray(b)) return false;
|
|
12
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
13
|
+
const keysA = Object.keys(a);
|
|
14
|
+
const keysB = Object.keys(b);
|
|
15
|
+
if (keysA.length !== keysB.length) return false;
|
|
16
|
+
return keysA.every((key) => key in b && deepEqual(a[key], b[key]));
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { deepEqual };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/utils/id-to-title.ts
|
|
2
|
+
function idToTitle(id) {
|
|
3
|
+
let result = [];
|
|
4
|
+
for (const c of id) if (result.length === 0) result.push(c.toLocaleUpperCase());
|
|
5
|
+
else if (c === ".") result = [];
|
|
6
|
+
else if (/^[A-Z]$/.test(c) && result.at(-1) !== " ") result.push(" ", c);
|
|
7
|
+
else if (c === "-") result.push(" ");
|
|
8
|
+
else result.push(c);
|
|
9
|
+
return result.join("");
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { idToTitle };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/utils/is-plain-object.ts
|
|
2
|
+
function isPlainObject(value) {
|
|
3
|
+
if (typeof value !== "object" || value === null) return false;
|
|
4
|
+
const prototype = Object.getPrototypeOf(value);
|
|
5
|
+
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isPlainObject };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/utils/merge-refs.ts
|
|
2
|
+
function mergeRefs(...refs) {
|
|
3
|
+
return (value) => {
|
|
4
|
+
refs.forEach((ref) => {
|
|
5
|
+
if (typeof ref === "function") ref(value);
|
|
6
|
+
else if (ref != null) ref.current = value;
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { mergeRefs };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/utils/url.ts
|
|
2
|
+
function joinURL(base, pathname) {
|
|
3
|
+
if (pathname.startsWith("/")) pathname = pathname.slice(1);
|
|
4
|
+
if (base.endsWith("/")) base = base.slice(0, -1);
|
|
5
|
+
if (pathname.length > 0) return base + "/" + pathname;
|
|
6
|
+
else return base;
|
|
7
|
+
}
|
|
8
|
+
function resolveServerUrl(template, variables) {
|
|
9
|
+
for (const [key, value] of Object.entries(variables)) template = template.replaceAll(`{${key}}`, value);
|
|
10
|
+
return template;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { joinURL, resolveServerUrl };
|