fumadocs-openapi 10.10.3 → 11.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/css/generated/shared.css +1 -1159
- package/css/preset.css +1 -0
- package/dist/.translations/index.d.ts +80 -0
- package/dist/.translations/keys.js +80 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -10
- package/dist/generate-file.d.ts +0 -4
- package/dist/generate-file.js +4 -5
- package/dist/i18n.d.ts +5 -100
- package/dist/i18n.js +8 -108
- package/dist/index.d.ts +4 -4
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +1 -1
- package/dist/playground/auth.js +4 -4
- package/dist/playground/client.d.ts +12 -21
- package/dist/playground/client.js +80 -59
- package/dist/playground/components/oauth-dialog.js +33 -33
- package/dist/playground/components/result-display.d.ts +1 -2
- package/dist/playground/components/result-display.js +7 -8
- package/dist/playground/components/server-select.js +11 -11
- package/dist/playground/status-info.js +29 -37
- package/dist/requests/generators/csharp.js +3 -3
- package/dist/requests/generators/curl.js +2 -2
- package/dist/requests/generators/go.js +2 -2
- package/dist/requests/generators/index.d.ts +28 -41
- package/dist/requests/generators/index.js +18 -35
- package/dist/requests/generators/java.js +2 -2
- package/dist/requests/generators/javascript.js +2 -2
- package/dist/requests/generators/python.js +2 -2
- package/dist/scalar/client.js +3 -2
- package/dist/scalar/index.d.ts +2 -2
- package/dist/scalar/index.js +10 -9
- package/dist/server/index.d.ts +23 -27
- package/dist/server/index.js +42 -38
- package/dist/server/proxy.d.ts +0 -6
- package/dist/server/proxy.js +2 -4
- package/dist/{_openapi/types.d.ts → types/openapi.d.ts} +127 -136
- package/dist/types.d.ts +14 -18
- package/dist/ui/base.d.ts +15 -162
- package/dist/ui/base.js +148 -107
- package/dist/ui/components/codeblock.js +6 -14
- package/dist/ui/components/heading.js +8 -4
- package/dist/ui/components/markdown.js +12 -0
- package/dist/ui/contexts/api.js +8 -26
- package/dist/ui/index.d.ts +204 -7
- package/dist/ui/index.js +10 -15
- package/dist/ui/operation/context.js +48 -0
- package/dist/ui/operation/index.js +168 -126
- package/dist/ui/operation/request-tabs.d.ts +10 -5
- package/dist/ui/operation/request-tabs.js +35 -22
- package/dist/ui/operation/response-tabs.d.ts +5 -2
- package/dist/ui/operation/response-tabs.js +22 -15
- package/dist/ui/operation/usage-tabs.js +144 -0
- package/dist/utils/document/dereference.d.ts +1 -1
- package/dist/utils/document/dereference.js +5 -8
- package/dist/utils/document/load.js +17 -0
- package/dist/utils/get-example-requests.d.ts +13 -0
- package/dist/{ui/operation → utils}/get-example-requests.js +31 -20
- package/dist/utils/pages/builder.d.ts +38 -10
- package/dist/utils/pages/builder.js +12 -10
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +15 -15
- package/dist/utils/pages/to-static-data.js +5 -4
- package/dist/utils/pages/to-text.d.ts +1 -0
- package/dist/utils/pages/to-text.js +21 -11
- package/dist/utils/remove-undefined.js +14 -9
- package/dist/utils/schema.d.ts +2 -0
- package/dist/utils/{schema/index.js → schema.js} +3 -30
- package/dist/{ui/client → utils}/storage-key.js +3 -3
- package/package.json +16 -29
- 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 +0 -239
- 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 +0 -187
- 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 +0 -136
- 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 +0 -41
- 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 +0 -124
- 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 +0 -109
- 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 +0 -30
- 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 +0 -46
- 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 +0 -36
- 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 +0 -49
- 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 +0 -242
- 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 +0 -247
- 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 +0 -210
- 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 +0 -100
- 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 +0 -41
- 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 +0 -112
- 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 +0 -8
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +0 -146
- 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 +0 -5
- 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 +0 -18
- 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 +0 -11
- 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 +0 -99
- 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 +0 -30
- 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 +0 -315
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +0 -108
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +0 -110
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +0 -138
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +0 -674
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +0 -141
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +0 -102
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +0 -223
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +0 -133
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +0 -146
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +0 -172
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +0 -433
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +0 -113
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +0 -583
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +0 -42
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +0 -50
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +0 -36
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +0 -85
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -57
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -96
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -29
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -89
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -87
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -62
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -60
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -34
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -52
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -41
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +0 -130
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +0 -112
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -101
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +0 -35
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +0 -45
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +0 -15
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +0 -10
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +0 -13
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -49
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -47
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -38
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -70
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +0 -33
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -236
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -187
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -282
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +0 -78
- package/dist/playground/components/inputs.js +0 -419
- package/dist/playground/components/spinner.js +0 -15
- package/dist/playground/schema.d.ts +0 -15
- package/dist/playground/schema.js +0 -144
- package/dist/ui/api-page.d.ts +0 -31
- package/dist/ui/api-page.js +0 -59
- package/dist/ui/client/boundary.d.ts +0 -11
- package/dist/ui/client/boundary.js +0 -17
- package/dist/ui/client/boundary.lazy.js +0 -19
- package/dist/ui/client/full.js +0 -13
- package/dist/ui/client/i18n.js +0 -16
- package/dist/ui/client/index.d.ts +0 -42
- package/dist/ui/client/index.js +0 -7
- package/dist/ui/components/accordion.js +0 -67
- package/dist/ui/components/codeblock.d.ts +0 -14
- package/dist/ui/components/dialog.js +0 -56
- package/dist/ui/components/input.js +0 -17
- package/dist/ui/components/select-tab.js +0 -56
- package/dist/ui/components/select.js +0 -71
- package/dist/ui/contexts/api.d.ts +0 -29
- package/dist/ui/create-client.d.ts +0 -26
- package/dist/ui/create-client.js +0 -125
- package/dist/ui/operation/client.js +0 -78
- package/dist/ui/operation/get-example-requests.d.ts +0 -11
- package/dist/ui/operation/usage-tabs/client.d.ts +0 -14
- package/dist/ui/operation/usage-tabs/client.js +0 -91
- package/dist/ui/operation/usage-tabs/index.js +0 -54
- package/dist/ui/schema/client.d.ts +0 -18
- package/dist/ui/schema/client.js +0 -410
- package/dist/ui/schema/index.d.ts +0 -61
- package/dist/ui/schema/index.js +0 -256
- package/dist/utils/auto-anchor.client.js +0 -20
- package/dist/utils/auto-anchor.js +0 -17
- package/dist/utils/deep-equal.js +0 -21
- package/dist/utils/document/process.d.ts +0 -6
- package/dist/utils/document/process.js +0 -18
- package/dist/utils/id-to-title.js +0 -12
- package/dist/utils/is-plain-object.js +0 -8
- package/dist/utils/merge-refs.js +0 -11
- package/dist/utils/schema/dereference.js +0 -45
- package/dist/utils/schema/index.d.ts +0 -18
- package/dist/utils/schema/merge.js +0 -156
- package/dist/utils/schema/pick.js +0 -44
- package/dist/utils/schema/ref.js +0 -35
- package/dist/utils/schema/resolve-ref.js +0 -11
- package/dist/utils/schema/sample.js +0 -442
- package/dist/utils/schema/to-string.d.ts +0 -1
- package/dist/utils/schema/to-string.js +0 -53
- package/dist/utils/url.js +0 -39
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RawRequestData, RequestData } from "../../requests/types.js";
|
|
2
|
-
//#region src/ui/operation/get-example-requests.d.ts
|
|
3
|
-
interface ExampleRequestItem {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
data: RawRequestData;
|
|
8
|
-
encoded: RequestData;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { ExampleRequestItem };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CodeUsageGenerator } from "../../../requests/generators/index.js";
|
|
2
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/ui/operation/usage-tabs/client.d.ts
|
|
5
|
-
declare function UsageTabsSelector(): _$react_jsx_runtime0.JSX.Element | null;
|
|
6
|
-
declare function UsageTab({
|
|
7
|
-
id,
|
|
8
|
-
lang,
|
|
9
|
-
_client
|
|
10
|
-
}: Pick<CodeUsageGenerator, 'lang' | '_client'> & {
|
|
11
|
-
id: string;
|
|
12
|
-
}): _$react_jsx_runtime0.JSX.Element | null;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { UsageTab, UsageTabsSelector };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { joinURL, resolveRequestData, resolveServerUrl, withBase } from "../../../utils/url.js";
|
|
3
|
-
import { useApiContext, useServerContext } from "../../contexts/api.js";
|
|
4
|
-
import { ClientCodeBlock } from "../../components/codeblock.js";
|
|
5
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../components/select.js";
|
|
6
|
-
import { useOperationContext } from "../client.js";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
//#region src/ui/operation/usage-tabs/client.tsx
|
|
10
|
-
function UsageTabsSelector() {
|
|
11
|
-
const { example: key, setExample: setKey, examples } = useOperationContext();
|
|
12
|
-
const { APIExampleSelector: Override } = useApiContext().client.operation ?? {};
|
|
13
|
-
if (Override) return /* @__PURE__ */ jsx(Override, {
|
|
14
|
-
items: examples,
|
|
15
|
-
value: key,
|
|
16
|
-
onValueChange: setKey
|
|
17
|
-
});
|
|
18
|
-
function renderItem(item) {
|
|
19
|
-
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
20
|
-
className: "font-medium text-sm",
|
|
21
|
-
children: item.name
|
|
22
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
23
|
-
className: "text-fd-muted-foreground",
|
|
24
|
-
children: item.description
|
|
25
|
-
})] });
|
|
26
|
-
}
|
|
27
|
-
if (examples.length === 1) return null;
|
|
28
|
-
const selected = examples.find((item) => item.id === key);
|
|
29
|
-
return /* @__PURE__ */ jsxs(Select, {
|
|
30
|
-
value: key,
|
|
31
|
-
onValueChange: setKey,
|
|
32
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
33
|
-
className: "not-prose mb-2",
|
|
34
|
-
children: selected && /* @__PURE__ */ jsx(SelectValue, {
|
|
35
|
-
asChild: true,
|
|
36
|
-
children: renderItem(selected)
|
|
37
|
-
})
|
|
38
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: examples.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
39
|
-
value: item.id,
|
|
40
|
-
children: renderItem(item)
|
|
41
|
-
}, item.id)) })]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function UsageTab({ id, lang, _client }) {
|
|
45
|
-
const { mediaAdapters, codeUsages } = useApiContext();
|
|
46
|
-
const { examples, example: selectedExampleId, route, addListener, removeListener } = useOperationContext();
|
|
47
|
-
const { server } = useServerContext();
|
|
48
|
-
const codegen = codeUsages.get(id);
|
|
49
|
-
const [mounted, setMounted] = useState(false);
|
|
50
|
-
const [data, setData] = useState(() => examples.find((example) => example.id === selectedExampleId)?.encoded);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const listener = (_, encoded) => setData(encoded);
|
|
53
|
-
addListener(listener);
|
|
54
|
-
setMounted(true);
|
|
55
|
-
return () => {
|
|
56
|
-
removeListener(listener);
|
|
57
|
-
};
|
|
58
|
-
}, [addListener, removeListener]);
|
|
59
|
-
const code = useMemo(() => {
|
|
60
|
-
if (!data) return;
|
|
61
|
-
const url = joinURL(server && mounted ? withBase(resolveServerUrl(server.url, server.variables), window.location.origin) : "https://example.com", resolveRequestData(route, data));
|
|
62
|
-
if (_client) {
|
|
63
|
-
const { generate, serverContext } = _client;
|
|
64
|
-
if (typeof generate === "string") return generate;
|
|
65
|
-
return generate(url, data, {
|
|
66
|
-
mediaAdapters,
|
|
67
|
-
server: serverContext
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (!codegen) return;
|
|
71
|
-
return codegen.generate(url, data, {
|
|
72
|
-
mediaAdapters,
|
|
73
|
-
server: null
|
|
74
|
-
});
|
|
75
|
-
}, [
|
|
76
|
-
data,
|
|
77
|
-
server,
|
|
78
|
-
route,
|
|
79
|
-
mounted,
|
|
80
|
-
_client,
|
|
81
|
-
codegen,
|
|
82
|
-
mediaAdapters
|
|
83
|
-
]);
|
|
84
|
-
if (!code) return null;
|
|
85
|
-
return /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
86
|
-
lang,
|
|
87
|
-
code
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
91
|
-
export { UsageTab, UsageTabsSelector };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createCodeUsageGeneratorRegistry } from "../../../requests/generators/index.js";
|
|
2
|
-
import { ResponseTabs } from "../response-tabs.js";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger } from "fumadocs-ui/components/codeblock";
|
|
6
|
-
//#region src/ui/operation/usage-tabs/index.tsx
|
|
7
|
-
function UsageTabs({ method, ctx }) {
|
|
8
|
-
let { renderAPIExampleUsageTabs, renderAPIExampleLayout } = ctx.content ?? {};
|
|
9
|
-
renderAPIExampleLayout ??= (slots) => {
|
|
10
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
-
className: "prose-no-margin",
|
|
12
|
-
children: [
|
|
13
|
-
slots.selector,
|
|
14
|
-
slots.usageTabs,
|
|
15
|
-
slots.responseTabs
|
|
16
|
-
]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
renderAPIExampleUsageTabs ??= (registry) => {
|
|
20
|
-
const map = Array.from(registry.map().entries());
|
|
21
|
-
if (map.length === 0) return null;
|
|
22
|
-
return /* @__PURE__ */ jsxs(CodeBlockTabs, {
|
|
23
|
-
groupId: "fumadocs_openapi_requests",
|
|
24
|
-
defaultValue: map[0][0],
|
|
25
|
-
children: [/* @__PURE__ */ jsx(CodeBlockTabsList, { children: map.map(([id, item]) => /* @__PURE__ */ jsx(CodeBlockTabsTrigger, {
|
|
26
|
-
value: id,
|
|
27
|
-
children: item.label ?? item.lang
|
|
28
|
-
}, id)) }), map.map(([id, item]) => /* @__PURE__ */ jsx(CodeBlockTab, {
|
|
29
|
-
value: id,
|
|
30
|
-
children: /* @__PURE__ */ jsx(ctx.clientBoundary.UsageTab, {
|
|
31
|
-
id,
|
|
32
|
-
lang: item.lang,
|
|
33
|
-
_client: item._client
|
|
34
|
-
})
|
|
35
|
-
}, id))]
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
const registry = useMemo(() => {
|
|
39
|
-
const registry = createCodeUsageGeneratorRegistry(ctx.codeUsages);
|
|
40
|
-
if (ctx.generateCodeSamples) for (const gen of ctx.generateCodeSamples(method)) registry.addInline(gen);
|
|
41
|
-
if (method["x-codeSamples"]) for (const sample of method["x-codeSamples"]) registry.addInline(sample);
|
|
42
|
-
return registry;
|
|
43
|
-
}, [ctx, method]);
|
|
44
|
-
return renderAPIExampleLayout({
|
|
45
|
-
selector: method["x-exclusiveCodeSample"] ? null : /* @__PURE__ */ jsx(ctx.clientBoundary.UsageTabsSelector, {}),
|
|
46
|
-
usageTabs: renderAPIExampleUsageTabs(registry, ctx),
|
|
47
|
-
responseTabs: /* @__PURE__ */ jsx(ResponseTabs, {
|
|
48
|
-
operation: method,
|
|
49
|
-
ctx
|
|
50
|
-
})
|
|
51
|
-
}, ctx);
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { UsageTabs };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SchemaUIGeneratedData } from "./index.js";
|
|
2
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/ui/schema/client.d.ts
|
|
5
|
-
interface SchemaUIProps {
|
|
6
|
-
name: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
as?: 'property' | 'body';
|
|
9
|
-
generated: SchemaUIGeneratedData;
|
|
10
|
-
}
|
|
11
|
-
declare function SchemaUI({
|
|
12
|
-
name,
|
|
13
|
-
required,
|
|
14
|
-
as,
|
|
15
|
-
generated
|
|
16
|
-
}: SchemaUIProps): _$react_jsx_runtime0.JSX.Element;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { SchemaUI, SchemaUIProps };
|
package/dist/ui/schema/client.js
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useTranslations } from "../client/i18n.js";
|
|
3
|
-
import { cn } from "../../utils/cn.js";
|
|
4
|
-
import { Badge } from "../components/method-label.js";
|
|
5
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../components/select.js";
|
|
6
|
-
import { useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
7
|
-
import { mergeRefs } from "../../utils/merge-refs.js";
|
|
8
|
-
import { Fragment, Suspense, createContext, use, useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
|
|
9
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { CheckIcon, FilterIcon, LinkIcon } from "lucide-react";
|
|
11
|
-
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
12
|
-
import { cva } from "class-variance-authority";
|
|
13
|
-
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
14
|
-
import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
|
|
15
|
-
//#region src/ui/schema/client.tsx
|
|
16
|
-
const typeVariants = cva("text-sm text-start text-fd-muted-foreground font-mono", { variants: { variant: { trigger: "underline hover:text-fd-accent-foreground data-[state=open]:text-fd-accent-foreground" } } });
|
|
17
|
-
const Context = createContext(null);
|
|
18
|
-
function useStates() {
|
|
19
|
-
return use(Context);
|
|
20
|
-
}
|
|
21
|
-
function SchemaUI({ name, required = false, as = "property", generated }) {
|
|
22
|
-
const rootId = useAnchorId([name]);
|
|
23
|
-
const [path, setPath] = useState(() => [{
|
|
24
|
-
$ref: generated.$root,
|
|
25
|
-
name
|
|
26
|
-
}]);
|
|
27
|
-
const ref = useRef(null);
|
|
28
|
-
const popoverRef = useCallback((element) => {
|
|
29
|
-
if (!element) return;
|
|
30
|
-
element.scrollTop = path.at(-1).scrollTop ?? 0;
|
|
31
|
-
const current = parseFloat(element.style.getPropertyValue("--min-height") || "200px");
|
|
32
|
-
element.style.setProperty("--min-height", Math.max(element.clientHeight + 2, current) + "px");
|
|
33
|
-
}, [path]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const url = new URL(window.location.href);
|
|
36
|
-
const param = url.searchParams.get("path");
|
|
37
|
-
if (url.hash !== `#${rootId}` || !param) return;
|
|
38
|
-
const decoded = decodePath(param, url.searchParams.get("s-highlight"));
|
|
39
|
-
if (!decoded || decoded.length === 0 || decoded.some((item) => !generated.refs[item.$ref])) return;
|
|
40
|
-
setPath(decoded);
|
|
41
|
-
if (!decoded.at(-1).highlighted) ref.current?.scrollIntoView({ behavior: "smooth" });
|
|
42
|
-
}, [rootId]);
|
|
43
|
-
return /* @__PURE__ */ jsx(Context, {
|
|
44
|
-
value: useMemo(() => ({
|
|
45
|
-
rootId,
|
|
46
|
-
path,
|
|
47
|
-
generated,
|
|
48
|
-
setPath,
|
|
49
|
-
renderTypeInfoTrigger: ({ $ref, children, pathName }) => /* @__PURE__ */ jsxs(Popover, {
|
|
50
|
-
open: path.length > 1 && path[1].$ref === $ref && path[1].name === pathName && !path[0].closed,
|
|
51
|
-
onOpenChange: (v) => {
|
|
52
|
-
if (v) setPath([{
|
|
53
|
-
...path[0],
|
|
54
|
-
closed: false
|
|
55
|
-
}, {
|
|
56
|
-
name: pathName,
|
|
57
|
-
$ref
|
|
58
|
-
}]);
|
|
59
|
-
else setPath(path.map((item, i) => i === 0 ? {
|
|
60
|
-
...item,
|
|
61
|
-
closed: true
|
|
62
|
-
} : item));
|
|
63
|
-
},
|
|
64
|
-
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
65
|
-
className: cn(typeVariants({ variant: "trigger" })),
|
|
66
|
-
children
|
|
67
|
-
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
68
|
-
ref: popoverRef,
|
|
69
|
-
collisionPadding: 10,
|
|
70
|
-
className: "w-[600px] max-w-(--radix-popover-content-available-width) min-h-(--min-height,200px) fd-scroll-container max-h-[460px] px-3 pt-0",
|
|
71
|
-
onScrollEnd: (e) => {
|
|
72
|
-
path.at(-1).scrollTop = e.target.scrollTop;
|
|
73
|
-
},
|
|
74
|
-
onOpenAutoFocus: (e) => {
|
|
75
|
-
const input = e.target.querySelector("input[data-object-search-input]");
|
|
76
|
-
if (!(input instanceof HTMLInputElement)) return;
|
|
77
|
-
input.focus({ preventScroll: true });
|
|
78
|
-
e.preventDefault();
|
|
79
|
-
},
|
|
80
|
-
children: /* @__PURE__ */ jsx(SchemaUIPopover, {})
|
|
81
|
-
})]
|
|
82
|
-
})
|
|
83
|
-
}), [
|
|
84
|
-
generated,
|
|
85
|
-
path,
|
|
86
|
-
rootId,
|
|
87
|
-
popoverRef
|
|
88
|
-
]),
|
|
89
|
-
children: as === "property" || generated.refs[generated.$root].type === "primitive" ? /* @__PURE__ */ jsx(ObjectProperty, {
|
|
90
|
-
ref,
|
|
91
|
-
id: rootId,
|
|
92
|
-
name,
|
|
93
|
-
$type: generated.$root,
|
|
94
|
-
parentPathIndex: 0,
|
|
95
|
-
required
|
|
96
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
97
|
-
id: rootId,
|
|
98
|
-
ref,
|
|
99
|
-
children: /* @__PURE__ */ jsx(PathItemBody, { pathIndex: 0 })
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function SchemaDescription({ schema, ...props }) {
|
|
104
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
105
|
-
...props,
|
|
106
|
-
className: cn("prose-no-margin py-4 empty:hidden", props.className),
|
|
107
|
-
children: [schema.description, schema.infoTags && schema.infoTags.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
108
|
-
className: "flex flex-row gap-2 flex-wrap mt-2 not-prose empty:hidden",
|
|
109
|
-
children: schema.infoTags.map((tag, i) => /* @__PURE__ */ jsx(InfoTag, { tag }, i))
|
|
110
|
-
})]
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function ObjectProperty({ name, $type, required, parentPathIndex, ...props }) {
|
|
114
|
-
const t = useTranslations();
|
|
115
|
-
const { path, generated: { refs }, rootId } = useStates();
|
|
116
|
-
const schema = refs[$type];
|
|
117
|
-
const parentItem = path[parentPathIndex];
|
|
118
|
-
const ref = useCallback((element) => {
|
|
119
|
-
if (!element || parentItem.highlighted !== name) return;
|
|
120
|
-
window.setTimeout(() => {
|
|
121
|
-
element.scrollIntoView({
|
|
122
|
-
behavior: "smooth",
|
|
123
|
-
block: "end"
|
|
124
|
-
});
|
|
125
|
-
delete parentItem.highlighted;
|
|
126
|
-
}, 300);
|
|
127
|
-
}, [parentItem, name]);
|
|
128
|
-
const [isChecked, onClick] = useCopyButton(() => {
|
|
129
|
-
const url = new URL(window.location.href);
|
|
130
|
-
url.hash = `#${rootId}`;
|
|
131
|
-
url.searchParams.set("s-highlight", name);
|
|
132
|
-
url.searchParams.set("path", encodePath(path));
|
|
133
|
-
return navigator.clipboard.writeText(url.href);
|
|
134
|
-
});
|
|
135
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
136
|
-
...props,
|
|
137
|
-
ref: mergeRefs(props.ref, ref),
|
|
138
|
-
className: cn("text-sm border-t py-4 scroll-m-20 first:border-t-0", props.className),
|
|
139
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
140
|
-
className: "flex flex-wrap items-center gap-2 not-prose",
|
|
141
|
-
children: [
|
|
142
|
-
/* @__PURE__ */ jsxs("span", {
|
|
143
|
-
className: "font-medium font-mono",
|
|
144
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
145
|
-
className: cn(parentItem.highlighted === name ? "bg-fd-primary text-fd-primary-foreground rounded-sm" : "text-fd-primary", schema.deprecated && "line-through opacity-80"),
|
|
146
|
-
children: name
|
|
147
|
-
}), required ? /* @__PURE__ */ jsx("span", {
|
|
148
|
-
className: "text-red-400",
|
|
149
|
-
children: "*"
|
|
150
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
151
|
-
className: "text-fd-muted-foreground",
|
|
152
|
-
children: "?"
|
|
153
|
-
})]
|
|
154
|
-
}),
|
|
155
|
-
schema.type === "primitive" ? /* @__PURE__ */ jsx("span", {
|
|
156
|
-
className: cn(typeVariants()),
|
|
157
|
-
children: schema.aliasName
|
|
158
|
-
}) : /* @__PURE__ */ jsx(TypeInfoTrigger, {
|
|
159
|
-
pathName: name,
|
|
160
|
-
$ref: $type,
|
|
161
|
-
children: schema.aliasName
|
|
162
|
-
}),
|
|
163
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
164
|
-
schema.deprecated && /* @__PURE__ */ jsx(Badge, {
|
|
165
|
-
color: "yellow",
|
|
166
|
-
className: "text-xs",
|
|
167
|
-
children: t.deprecated
|
|
168
|
-
}),
|
|
169
|
-
/* @__PURE__ */ jsx("button", {
|
|
170
|
-
className: cn(buttonVariants({
|
|
171
|
-
size: "icon-xs",
|
|
172
|
-
variant: "ghost"
|
|
173
|
-
}), "text-fd-muted-foreground [&_svg]:size-3.5"),
|
|
174
|
-
onClick,
|
|
175
|
-
children: isChecked ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(LinkIcon, {})
|
|
176
|
-
})
|
|
177
|
-
]
|
|
178
|
-
}), /* @__PURE__ */ jsx(SchemaDescription, {
|
|
179
|
-
schema,
|
|
180
|
-
className: "pb-0"
|
|
181
|
-
})]
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
function PathItemBody({ pathIndex, asSchema, tabDepth = 0, objectSearchOverrides }) {
|
|
185
|
-
const { path, setPath, generated: { refs } } = useStates();
|
|
186
|
-
const schema = asSchema ?? refs[path[pathIndex].$ref];
|
|
187
|
-
if ((schema.type === "or" || schema.type === "and") && schema.items.length > 0) {
|
|
188
|
-
const value = path[pathIndex].tabValues?.[tabDepth] ?? schema.items[0].$type;
|
|
189
|
-
const items = schema.items.map((item) => ({
|
|
190
|
-
label: /* @__PURE__ */ jsx("code", {
|
|
191
|
-
className: "text-xs font-medium",
|
|
192
|
-
children: item.name
|
|
193
|
-
}),
|
|
194
|
-
value: item.$type
|
|
195
|
-
}));
|
|
196
|
-
return /* @__PURE__ */ jsxs(Select, {
|
|
197
|
-
value,
|
|
198
|
-
onValueChange: (v) => {
|
|
199
|
-
const next = [...path];
|
|
200
|
-
(next[pathIndex].tabValues ??= []).splice(tabDepth, 1, v);
|
|
201
|
-
setPath(next);
|
|
202
|
-
},
|
|
203
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
204
|
-
className: "flex flex-row my-2 gap-2 items-center",
|
|
205
|
-
children: [
|
|
206
|
-
/* @__PURE__ */ jsx(SchemaDescription, {
|
|
207
|
-
schema,
|
|
208
|
-
className: "flex-1 py-0"
|
|
209
|
-
}),
|
|
210
|
-
/* @__PURE__ */ jsx(SelectTrigger, {
|
|
211
|
-
className: "not-prose w-fit min-w-0 mb-auto *:min-w-0",
|
|
212
|
-
children: /* @__PURE__ */ jsx(SelectValue, { children: items.find((item) => item.value === value)?.label })
|
|
213
|
-
}),
|
|
214
|
-
/* @__PURE__ */ jsx(SelectContent, { children: items.map(({ label, value }) => /* @__PURE__ */ jsx(SelectItem, {
|
|
215
|
-
value,
|
|
216
|
-
children: label
|
|
217
|
-
}, value)) })
|
|
218
|
-
]
|
|
219
|
-
}), /* @__PURE__ */ jsx(PathItemBody, {
|
|
220
|
-
asSchema: refs[value],
|
|
221
|
-
pathIndex,
|
|
222
|
-
tabDepth: tabDepth + 1
|
|
223
|
-
})]
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
if (schema.type === "object" && schema.props.length > 0) return /* @__PURE__ */ jsx(ObjectSearch, {
|
|
227
|
-
pathIndex,
|
|
228
|
-
schema,
|
|
229
|
-
...objectSearchOverrides,
|
|
230
|
-
children: /* @__PURE__ */ jsx(SchemaDescription, { schema })
|
|
231
|
-
});
|
|
232
|
-
if (schema.type === "array") return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SchemaDescription, { schema }), /* @__PURE__ */ jsx(ObjectProperty, {
|
|
233
|
-
name: "[index: integer]",
|
|
234
|
-
$type: schema.item.$type,
|
|
235
|
-
parentPathIndex: pathIndex
|
|
236
|
-
})] });
|
|
237
|
-
return /* @__PURE__ */ jsx(SchemaDescription, { schema });
|
|
238
|
-
}
|
|
239
|
-
function ObjectSearch({ variant = "default", schema, pathIndex, children }) {
|
|
240
|
-
const { path, setPath } = useStates();
|
|
241
|
-
const [search, setSearch] = useState("");
|
|
242
|
-
const deferredValue = useDeferredValue(search);
|
|
243
|
-
const firstItemRef = useRef(null);
|
|
244
|
-
const t = useTranslations();
|
|
245
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
246
|
-
/* @__PURE__ */ jsxs("div", {
|
|
247
|
-
className: cn("flex items-center bg-fd-secondary text-fd-secondary-foreground transition-colors", variant === "in-popover" && "sticky top-10 -mx-3 ps-3 border-b focus-within:[&_svg]:text-fd-primary", variant === "default" && "border rounded-md ps-2 shadow-sm focus-within:ring-2 focus-within:ring-fd-ring"),
|
|
248
|
-
children: [/* @__PURE__ */ jsx(FilterIcon, { className: "text-fd-muted-foreground size-3.5 transition-colors" }), /* @__PURE__ */ jsx("input", {
|
|
249
|
-
value: search,
|
|
250
|
-
"data-object-search-input": "",
|
|
251
|
-
onChange: (e) => setSearch(e.target.value),
|
|
252
|
-
placeholder: t.schemaFilterPropertiesPlaceholder,
|
|
253
|
-
className: "text-sm ps-2 py-2 flex-1 outline-none placeholder:text-fd-muted-foreground",
|
|
254
|
-
onKeyDown: (e) => {
|
|
255
|
-
if (e.key === "Enter") {
|
|
256
|
-
const item = firstItemRef.current;
|
|
257
|
-
if (item) setPath([...path, {
|
|
258
|
-
name: item.name,
|
|
259
|
-
$ref: item.$type
|
|
260
|
-
}]);
|
|
261
|
-
e.preventDefault();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
})]
|
|
265
|
-
}),
|
|
266
|
-
children,
|
|
267
|
-
/* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ObjectSearchContent, {
|
|
268
|
-
search: deferredValue,
|
|
269
|
-
properties: schema.props,
|
|
270
|
-
firstItemRef,
|
|
271
|
-
empty: () => /* @__PURE__ */ jsxs("p", {
|
|
272
|
-
className: "text-fd-muted-foreground text-sm mt-2! mb-0!",
|
|
273
|
-
children: [
|
|
274
|
-
t.schemaFilterPropertiesEmpty,
|
|
275
|
-
" ",
|
|
276
|
-
/* @__PURE__ */ jsx("span", {
|
|
277
|
-
className: "text-fd-foreground font-medium",
|
|
278
|
-
children: `"${deferredValue}"`
|
|
279
|
-
})
|
|
280
|
-
]
|
|
281
|
-
}),
|
|
282
|
-
render: (item) => /* @__PURE__ */ jsx(ObjectProperty, {
|
|
283
|
-
name: item.name,
|
|
284
|
-
$type: item.$type,
|
|
285
|
-
required: item.required,
|
|
286
|
-
parentPathIndex: pathIndex
|
|
287
|
-
}, item.name)
|
|
288
|
-
}) })
|
|
289
|
-
] });
|
|
290
|
-
}
|
|
291
|
-
function ObjectSearchContent({ search: rawSearch, firstItemRef, properties, empty, render }) {
|
|
292
|
-
const filtered = useMemo(() => {
|
|
293
|
-
const search = rawSearch.trim().toLowerCase();
|
|
294
|
-
return search.length > 0 ? properties.filter((prop) => prop.name.toLowerCase().includes(search)) : properties;
|
|
295
|
-
}, [properties, rawSearch]);
|
|
296
|
-
firstItemRef.current = filtered[0] ?? null;
|
|
297
|
-
if (filtered.length === 0) return empty();
|
|
298
|
-
return filtered.map(render);
|
|
299
|
-
}
|
|
300
|
-
function InfoTag({ tag }) {
|
|
301
|
-
const ref = useRef(null);
|
|
302
|
-
const [open, setOpen] = useState(false);
|
|
303
|
-
return /* @__PURE__ */ jsxs("button", {
|
|
304
|
-
className: "inline-flex text-start items-start gap-2 bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md max-w-full",
|
|
305
|
-
onClick: () => setOpen((prev) => !prev),
|
|
306
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
307
|
-
className: "font-medium",
|
|
308
|
-
children: tag.label
|
|
309
|
-
}), /* @__PURE__ */ jsx("code", {
|
|
310
|
-
ref,
|
|
311
|
-
className: cn("min-w-0 flex-1 text-fd-muted-foreground", open ? "wrap-break-word" : "truncate"),
|
|
312
|
-
children: tag.value
|
|
313
|
-
})]
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
function SchemaUIPopover() {
|
|
317
|
-
const states = useStates();
|
|
318
|
-
const { path, setPath } = states;
|
|
319
|
-
return /* @__PURE__ */ jsxs(Context, {
|
|
320
|
-
value: useMemo(() => ({
|
|
321
|
-
...states,
|
|
322
|
-
renderTypeInfoTrigger: ({ $ref, pathName, children }) => /* @__PURE__ */ jsx("button", {
|
|
323
|
-
className: cn(typeVariants({ variant: "trigger" })),
|
|
324
|
-
onClick: () => setPath([...path, {
|
|
325
|
-
name: pathName,
|
|
326
|
-
$ref
|
|
327
|
-
}]),
|
|
328
|
-
children
|
|
329
|
-
})
|
|
330
|
-
}), [states]),
|
|
331
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
332
|
-
className: "sticky top-0 -mx-3 flex overflow-x-auto overflow-y-hidden items-center text-sm font-medium font-mono bg-fd-secondary text-fd-secondary-foreground px-3 h-10 border-b z-20",
|
|
333
|
-
children: path.map((item, i) => {
|
|
334
|
-
if (i === 0) return;
|
|
335
|
-
const isDuplicated = path.some((other, j) => j !== i && other.$ref === item.$ref);
|
|
336
|
-
let text;
|
|
337
|
-
const indexItemMatch = /^\[(\w+): (\w+)]$/.exec(item.name);
|
|
338
|
-
if (indexItemMatch) text = `[${indexItemMatch[1]}]`;
|
|
339
|
-
else if (i > 1) text = `.${item.name}`;
|
|
340
|
-
else text = item.name;
|
|
341
|
-
return /* @__PURE__ */ jsx("button", {
|
|
342
|
-
onClick: () => setPath(path.slice(0, i + 1)),
|
|
343
|
-
className: cn("hover:underline hover:text-fd-accent-foreground", isDuplicated && "text-orange-400"),
|
|
344
|
-
children: text
|
|
345
|
-
}, i);
|
|
346
|
-
})
|
|
347
|
-
}), /* @__PURE__ */ jsx(PathItemBody, {
|
|
348
|
-
pathIndex: path.length - 1,
|
|
349
|
-
objectSearchOverrides: { variant: "in-popover" }
|
|
350
|
-
})]
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
function TypeInfoTrigger({ pathName, $ref, children }) {
|
|
354
|
-
const { generated: { refs }, renderTypeInfoTrigger } = useStates();
|
|
355
|
-
const schema = refs[$ref];
|
|
356
|
-
if (schema.type === "primitive" && !schema.description && (!schema.infoTags || schema.infoTags.length === 0)) return /* @__PURE__ */ jsx("span", {
|
|
357
|
-
className: cn(typeVariants()),
|
|
358
|
-
children
|
|
359
|
-
});
|
|
360
|
-
if (schema.type === "and" || schema.type === "or") {
|
|
361
|
-
const sep = schema.type === "and" ? "&" : "|";
|
|
362
|
-
return /* @__PURE__ */ jsx("span", {
|
|
363
|
-
className: cn(typeVariants(), "flex flex-row gap-2 items-center flex-wrap"),
|
|
364
|
-
children: schema.items.map((item, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", { children: sep }), /* @__PURE__ */ jsx(TypeInfoTrigger, {
|
|
365
|
-
pathName,
|
|
366
|
-
$ref: item.$type,
|
|
367
|
-
children: item.name
|
|
368
|
-
})] }, item.$type))
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
if (schema.type === "array") return /* @__PURE__ */ jsxs("span", {
|
|
372
|
-
className: cn(typeVariants(), "flex flex-row items-center flex-wrap"),
|
|
373
|
-
children: [
|
|
374
|
-
"array<",
|
|
375
|
-
/* @__PURE__ */ jsx(TypeInfoTrigger, {
|
|
376
|
-
pathName: `${pathName}[]`,
|
|
377
|
-
$ref: schema.item.$type,
|
|
378
|
-
children: refs[schema.item.$type].aliasName
|
|
379
|
-
}),
|
|
380
|
-
">"
|
|
381
|
-
]
|
|
382
|
-
});
|
|
383
|
-
return renderTypeInfoTrigger({
|
|
384
|
-
$ref,
|
|
385
|
-
pathName,
|
|
386
|
-
children
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
function encodePath(path) {
|
|
390
|
-
return path.map((item) => [
|
|
391
|
-
item.name,
|
|
392
|
-
item.$ref,
|
|
393
|
-
...item.tabValues ?? []
|
|
394
|
-
].join("\0")).join("|");
|
|
395
|
-
}
|
|
396
|
-
function decodePath(path, highlighted) {
|
|
397
|
-
const out = [];
|
|
398
|
-
for (const part of path.split("|")) {
|
|
399
|
-
const [name, $ref, ...tabValues] = part.split("\0");
|
|
400
|
-
out.push({
|
|
401
|
-
name,
|
|
402
|
-
$ref,
|
|
403
|
-
tabValues
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
if (highlighted && out.length > 0) out[out.length - 1].highlighted = highlighted;
|
|
407
|
-
return out;
|
|
408
|
-
}
|
|
409
|
-
//#endregion
|
|
410
|
-
export { SchemaUI };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { SchemaUIProps } from "./client.js";
|
|
2
|
-
import { ParsedSchema } from "../../utils/schema/index.js";
|
|
3
|
-
import { ReactNode } from "react";
|
|
4
|
-
//#region src/ui/schema/index.d.ts
|
|
5
|
-
interface FieldBase {
|
|
6
|
-
description?: ReactNode;
|
|
7
|
-
infoTags?: InfoTag[];
|
|
8
|
-
typeName: string;
|
|
9
|
-
aliasName: string;
|
|
10
|
-
deprecated?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface InfoTag {
|
|
13
|
-
label: ReactNode;
|
|
14
|
-
value: string;
|
|
15
|
-
}
|
|
16
|
-
interface SchemaDataObjectProperty {
|
|
17
|
-
name: string;
|
|
18
|
-
$type: string;
|
|
19
|
-
required: boolean;
|
|
20
|
-
}
|
|
21
|
-
type SchemaData = FieldBase & ({
|
|
22
|
-
type: 'primitive';
|
|
23
|
-
} | {
|
|
24
|
-
type: 'object';
|
|
25
|
-
props: SchemaDataObjectProperty[];
|
|
26
|
-
} | {
|
|
27
|
-
type: 'array';
|
|
28
|
-
item: {
|
|
29
|
-
$type: string;
|
|
30
|
-
};
|
|
31
|
-
} | {
|
|
32
|
-
type: 'or';
|
|
33
|
-
items: {
|
|
34
|
-
name: string;
|
|
35
|
-
$type: string;
|
|
36
|
-
}[];
|
|
37
|
-
} | {
|
|
38
|
-
type: 'and';
|
|
39
|
-
items: {
|
|
40
|
-
name: string;
|
|
41
|
-
$type: string;
|
|
42
|
-
}[];
|
|
43
|
-
});
|
|
44
|
-
interface SchemaUIOptions {
|
|
45
|
-
root: ParsedSchema;
|
|
46
|
-
client: Omit<SchemaUIProps, 'generated'>;
|
|
47
|
-
/**
|
|
48
|
-
* include read only props
|
|
49
|
-
*/
|
|
50
|
-
readOnly?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* include write only props
|
|
53
|
-
*/
|
|
54
|
-
writeOnly?: boolean;
|
|
55
|
-
}
|
|
56
|
-
interface SchemaUIGeneratedData {
|
|
57
|
-
$root: string;
|
|
58
|
-
refs: Record<string, SchemaData>;
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { SchemaUIGeneratedData, SchemaUIOptions };
|