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,45 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getPreferredType } from "../utils/schema
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useApiContext, useServerContext } from "../ui/contexts/api.js";
|
|
6
|
-
import { useTranslations } from "../ui/client/i18n.js";
|
|
2
|
+
import { getPreferredType } from "../utils/schema.js";
|
|
3
|
+
import { useStorageKey } from "../utils/storage-key.js";
|
|
4
|
+
import { useRenderContext, useServerContext } from "../ui/contexts/api.js";
|
|
7
5
|
import { cn } from "../utils/cn.js";
|
|
8
6
|
import { DefaultResultDisplay } from "./components/result-display.js";
|
|
7
|
+
import { pathnameFromRequest } from "../requests/generators/index.js";
|
|
9
8
|
import { MethodLabel } from "../ui/components/method-label.js";
|
|
10
9
|
import { useQuery } from "../utils/use-query.js";
|
|
11
10
|
import { encodeRequestData } from "../requests/media/encode.js";
|
|
12
|
-
import { dereferenceSwallow } from "../utils/schema/dereference.js";
|
|
13
|
-
import { SchemaProvider, anyFields, useResolvedSchema } from "./schema.js";
|
|
14
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/components/select.js";
|
|
15
|
-
import { labelVariants } from "../ui/components/input.js";
|
|
16
11
|
import ServerSelect from "./components/server-select.js";
|
|
17
|
-
import {
|
|
18
|
-
import { useOperationContext } from "../ui/operation/client.js";
|
|
12
|
+
import { useOperationContext } from "../ui/operation/context.js";
|
|
19
13
|
import { useAuth } from "./auth.js";
|
|
20
14
|
import { OAuthDialog, OAuthDialogContent, OAuthDialogTrigger } from "./components/oauth-dialog.js";
|
|
21
|
-
import {
|
|
15
|
+
import { dereferenceShallow } from "@fumadocs/api-docs/schema/dereference";
|
|
22
16
|
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
23
17
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
24
18
|
import { ChevronDown, LoaderCircle } from "lucide-react";
|
|
19
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
25
20
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
26
21
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "fumadocs-ui/components/ui/collapsible";
|
|
22
|
+
import { SchemaProvider, anyFields, useResolvedSchema } from "@fumadocs/api-docs/components/playground/schema";
|
|
23
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@fumadocs/api-docs/components/select";
|
|
24
|
+
import { labelVariants } from "@fumadocs/api-docs/components/input";
|
|
27
25
|
import { StfProvider, useDataEngine, useFieldValue, useListener, useStf } from "@fumari/stf";
|
|
26
|
+
import { joinURL, resolveServerUrl } from "@fumadocs/api-docs/utils/url";
|
|
28
27
|
import { arrayStartsWith, objectGet, objectSet, stringifyFieldKey } from "@fumari/stf/lib/utils";
|
|
28
|
+
import { FieldInput, FieldSet, JsonInput, ObjectInput } from "@fumadocs/api-docs/components/playground/inputs";
|
|
29
29
|
import { useOnChange } from "fumadocs-core/utils/use-on-change";
|
|
30
|
+
import { Spinner } from "@fumadocs/api-docs/components/spinner";
|
|
30
31
|
//#region src/playground/client.tsx
|
|
31
|
-
function PlaygroundClient({ route, method,
|
|
32
|
-
const t = useTranslations();
|
|
32
|
+
function PlaygroundClient({ route, method, operation, pathItem, writeOnly, readOnly, ...rest }) {
|
|
33
|
+
const t = useTranslations({ note: "playground" });
|
|
34
|
+
const ctx = useRenderContext();
|
|
35
|
+
const { bundled, dereferenced } = ctx.schema;
|
|
33
36
|
const { parameters, body } = useMemo(() => {
|
|
34
|
-
const
|
|
35
|
-
|
|
37
|
+
const parameters = [];
|
|
38
|
+
if (operation.parameters) for (const p of operation.parameters) parameters.push(dereferenceShallow(p, bundled));
|
|
39
|
+
if (pathItem.parameters) for (const p of pathItem.parameters) parameters.push(dereferenceShallow(p, bundled));
|
|
36
40
|
let body;
|
|
37
41
|
if (operation.requestBody) {
|
|
38
|
-
const content =
|
|
42
|
+
const content = dereferenceShallow(operation.requestBody, bundled).content;
|
|
39
43
|
const mediaType = content ? getPreferredType(content) : void 0;
|
|
40
44
|
if (content && mediaType) body = {
|
|
41
45
|
mediaType,
|
|
42
|
-
schema:
|
|
46
|
+
schema: dereferenceShallow(content[mediaType], bundled).schema ?? true
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
return {
|
|
@@ -47,13 +51,27 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
47
51
|
parameters
|
|
48
52
|
};
|
|
49
53
|
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
bundled,
|
|
55
|
+
operation,
|
|
56
|
+
pathItem
|
|
53
57
|
]);
|
|
58
|
+
const securityEntries = useMemo(() => {
|
|
59
|
+
const result = [];
|
|
60
|
+
const security = operation.security ?? dereferenced.security ?? [];
|
|
61
|
+
if (security.length === 0) return result;
|
|
62
|
+
for (const map of security) {
|
|
63
|
+
const list = [];
|
|
64
|
+
for (const [key, scopes] of Object.entries(map)) list.push({
|
|
65
|
+
id: key,
|
|
66
|
+
scopes
|
|
67
|
+
});
|
|
68
|
+
if (list.length > 0) result.push(list);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}, [dereferenced, operation.security]);
|
|
54
72
|
const { example: exampleId, examples, setExampleData } = useOperationContext();
|
|
55
73
|
const { server } = useServerContext();
|
|
56
|
-
const { mediaAdapters,
|
|
74
|
+
const { mediaAdapters, playground: { components: { ResultDisplay = DefaultResultDisplay, CollapsiblePanel = DefaultCollapsiblePanel } = {}, fetchOptions, renderBodyField } = {} } = useRenderContext();
|
|
57
75
|
const defaultValues = useMemo(() => {
|
|
58
76
|
const requestData = examples.find((example) => example.id === exampleId)?.data;
|
|
59
77
|
return {
|
|
@@ -65,10 +83,10 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
65
83
|
};
|
|
66
84
|
}, [examples, exampleId]);
|
|
67
85
|
const stf = useStf({ defaultValues });
|
|
68
|
-
const { inputs, requirementId, setRequirementId, mapInputs, initAuthInputs } = useAuthInputs(stf.dataEngine,
|
|
86
|
+
const { inputs, requirementId, setRequirementId, mapInputs, initAuthInputs } = useAuthInputs(stf.dataEngine, securityEntries);
|
|
69
87
|
const testQuery = useQuery(async (input) => {
|
|
70
88
|
const fetcher = await import("./fetcher.js").then((mod) => mod.createBrowserFetcher(mediaAdapters, {
|
|
71
|
-
proxyUrl,
|
|
89
|
+
proxyUrl: ctx.proxyUrl,
|
|
72
90
|
...fetchOptions
|
|
73
91
|
}));
|
|
74
92
|
const encoded = encodeRequestData({
|
|
@@ -76,7 +94,7 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
76
94
|
method,
|
|
77
95
|
bodyMediaType: body?.mediaType
|
|
78
96
|
}, mediaAdapters, parameters);
|
|
79
|
-
return fetcher.fetch(joinURL(
|
|
97
|
+
return fetcher.fetch(joinURL(new URL(server ? resolveServerUrl(server.url, server.variables) : "/", window.location.origin).href, pathnameFromRequest(route, encoded)), encoded);
|
|
80
98
|
});
|
|
81
99
|
const timerRef = useRef(null);
|
|
82
100
|
const stfSync = useRef(false);
|
|
@@ -112,7 +130,7 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
112
130
|
return /* @__PURE__ */ jsx(StfProvider, {
|
|
113
131
|
value: stf,
|
|
114
132
|
children: /* @__PURE__ */ jsx(SchemaProvider, {
|
|
115
|
-
|
|
133
|
+
docRoot: bundled,
|
|
116
134
|
writeOnly,
|
|
117
135
|
readOnly,
|
|
118
136
|
children: /* @__PURE__ */ jsxs("form", {
|
|
@@ -130,7 +148,7 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
130
148
|
/* @__PURE__ */ jsx(MethodLabel, { children: method }),
|
|
131
149
|
/* @__PURE__ */ jsx(Route, {
|
|
132
150
|
route,
|
|
133
|
-
className: cn("flex-1", deprecated && "line-through")
|
|
151
|
+
className: cn("flex-1", operation.deprecated && "line-through")
|
|
134
152
|
}),
|
|
135
153
|
/* @__PURE__ */ jsx("button", {
|
|
136
154
|
type: "submit",
|
|
@@ -139,7 +157,7 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
139
157
|
size: "sm"
|
|
140
158
|
}), "w-14 py-1.5"),
|
|
141
159
|
disabled: testQuery.isLoading,
|
|
142
|
-
children: testQuery.isLoading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }) : t
|
|
160
|
+
children: testQuery.isLoading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }) : t("Send")
|
|
143
161
|
})
|
|
144
162
|
]
|
|
145
163
|
}),
|
|
@@ -147,8 +165,8 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
147
165
|
data: testQuery.data,
|
|
148
166
|
reset: testQuery.reset
|
|
149
167
|
}) : null,
|
|
150
|
-
|
|
151
|
-
securities,
|
|
168
|
+
securityEntries.length > 0 && /* @__PURE__ */ jsx(SecurityRequirements, {
|
|
169
|
+
securities: securityEntries,
|
|
152
170
|
securityId: requirementId,
|
|
153
171
|
setSecurityId: setRequirementId,
|
|
154
172
|
children: inputs.map((input) => /* @__PURE__ */ jsx(Fragment, { children: input.children }, stringifyFieldKey(input.fieldName)))
|
|
@@ -156,7 +174,7 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
156
174
|
/* @__PURE__ */ jsx(ParametersForm, { parameters }),
|
|
157
175
|
body && /* @__PURE__ */ jsx(CollapsiblePanel, {
|
|
158
176
|
"data-type": "body",
|
|
159
|
-
title: t
|
|
177
|
+
title: t("Body"),
|
|
160
178
|
children: renderBodyField ? renderBodyField("body", body) : /* @__PURE__ */ jsx(BodyInput, { field: body.schema })
|
|
161
179
|
})
|
|
162
180
|
]
|
|
@@ -165,21 +183,21 @@ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly,
|
|
|
165
183
|
});
|
|
166
184
|
}
|
|
167
185
|
function SecurityRequirements({ securities, setSecurityId, securityId, children }) {
|
|
168
|
-
const t = useTranslations();
|
|
186
|
+
const t = useTranslations({ note: "playground" });
|
|
169
187
|
const { isLoading, error } = useAuth();
|
|
170
188
|
const defaultOpen = isLoading || error != null;
|
|
171
189
|
const [open, setOpen] = useState(defaultOpen);
|
|
172
|
-
const { CollapsiblePanel = DefaultCollapsiblePanel } =
|
|
190
|
+
const { CollapsiblePanel = DefaultCollapsiblePanel } = useRenderContext().playground?.components ?? {};
|
|
173
191
|
useOnChange(defaultOpen, () => {
|
|
174
192
|
if (defaultOpen) setOpen(true);
|
|
175
193
|
});
|
|
176
194
|
return /* @__PURE__ */ jsxs(CollapsiblePanel, {
|
|
177
|
-
title: /* @__PURE__ */ jsxs(Fragment$1, { children: [t
|
|
195
|
+
title: /* @__PURE__ */ jsxs(Fragment$1, { children: [t("Authorization"), isLoading && /* @__PURE__ */ jsxs("span", {
|
|
178
196
|
className: "border-s ps-2 inline-flex items-center gap-1.5 text-fd-muted-foreground text-xs font-mono",
|
|
179
197
|
children: [
|
|
180
198
|
/* @__PURE__ */ jsx(Spinner, {}),
|
|
181
199
|
" ",
|
|
182
|
-
t
|
|
200
|
+
t("Fetching token...")
|
|
183
201
|
]
|
|
184
202
|
})] }),
|
|
185
203
|
"data-type": "authorization",
|
|
@@ -190,7 +208,7 @@ function SecurityRequirements({ securities, setSecurityId, securityId, children
|
|
|
190
208
|
className: "p-2 border rounded-lg bg-fd-secondary",
|
|
191
209
|
children: [/* @__PURE__ */ jsx("p", {
|
|
192
210
|
className: "text-fd-muted-foreground font-medium mb-1",
|
|
193
|
-
children: t
|
|
211
|
+
children: t("Failed to fetch token")
|
|
194
212
|
}), /* @__PURE__ */ jsx("p", { children: String(error) })]
|
|
195
213
|
}),
|
|
196
214
|
/* @__PURE__ */ jsxs(Select, {
|
|
@@ -206,11 +224,12 @@ function SecurityRequirements({ securities, setSecurityId, securityId, children
|
|
|
206
224
|
});
|
|
207
225
|
}
|
|
208
226
|
function SecurityRequirement({ requirement }) {
|
|
209
|
-
const
|
|
227
|
+
const schemes = useRenderContext().schema.dereferenced.components?.securitySchemes;
|
|
210
228
|
return /* @__PURE__ */ jsx("div", {
|
|
211
229
|
className: "flex flex-col gap-2 max-w-[600px]",
|
|
212
230
|
children: requirement.map((item) => {
|
|
213
|
-
const scheme = schemes[item.id];
|
|
231
|
+
const scheme = schemes?.[item.id];
|
|
232
|
+
if (!scheme) return;
|
|
214
233
|
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
215
234
|
className: cn("font-mono font-medium", scheme.deprecated && "text-fd-muted-foreground line-through"),
|
|
216
235
|
children: item.id
|
|
@@ -228,7 +247,7 @@ const ParamTypes = [
|
|
|
228
247
|
"query"
|
|
229
248
|
];
|
|
230
249
|
function ParameterItem({ type, parameters }) {
|
|
231
|
-
const { renderParameterField } =
|
|
250
|
+
const { renderParameterField } = useRenderContext().playground ?? {};
|
|
232
251
|
return parameters.map((field) => {
|
|
233
252
|
const fieldName = [type, field.name];
|
|
234
253
|
if (renderParameterField) return renderParameterField(fieldName, field);
|
|
@@ -243,13 +262,13 @@ function ParameterItem({ type, parameters }) {
|
|
|
243
262
|
});
|
|
244
263
|
}
|
|
245
264
|
function ParametersForm({ parameters }) {
|
|
246
|
-
const { components: { CollapsiblePanel = DefaultCollapsiblePanel } = {} } =
|
|
247
|
-
const t = useTranslations();
|
|
265
|
+
const { components: { CollapsiblePanel = DefaultCollapsiblePanel } = {} } = useRenderContext().playground ?? {};
|
|
266
|
+
const t = useTranslations({ note: "playground" });
|
|
248
267
|
const displayNames = {
|
|
249
|
-
header: t
|
|
250
|
-
cookie: t
|
|
251
|
-
query: t
|
|
252
|
-
path: t
|
|
268
|
+
header: t("Header"),
|
|
269
|
+
cookie: t("Cookies"),
|
|
270
|
+
query: t("Query"),
|
|
271
|
+
path: t("Path")
|
|
253
272
|
};
|
|
254
273
|
return ParamTypes.map((type) => {
|
|
255
274
|
const items = parameters.filter((v) => v.in === type);
|
|
@@ -267,7 +286,7 @@ function ParametersForm({ parameters }) {
|
|
|
267
286
|
function BodyInput({ field: _field }) {
|
|
268
287
|
const field = useResolvedSchema(_field);
|
|
269
288
|
const [isJson, setIsJson] = useState(false);
|
|
270
|
-
const t = useTranslations();
|
|
289
|
+
const t = useTranslations({ note: "playground" });
|
|
271
290
|
if (field.format === "binary") return /* @__PURE__ */ jsx(FieldSet, {
|
|
272
291
|
field,
|
|
273
292
|
fieldName: ["body"],
|
|
@@ -281,7 +300,7 @@ function BodyInput({ field: _field }) {
|
|
|
281
300
|
})),
|
|
282
301
|
onClick: () => setIsJson(false),
|
|
283
302
|
type: "button",
|
|
284
|
-
children: t
|
|
303
|
+
children: t("Close JSON Editor")
|
|
285
304
|
}), /* @__PURE__ */ jsx(JsonInput, { fieldName: ["body"] })] });
|
|
286
305
|
return /* @__PURE__ */ jsx(FieldSet, {
|
|
287
306
|
field,
|
|
@@ -296,25 +315,27 @@ function BodyInput({ field: _field }) {
|
|
|
296
315
|
className: "p-2"
|
|
297
316
|
})),
|
|
298
317
|
onClick: () => setIsJson(true),
|
|
299
|
-
children: t
|
|
318
|
+
children: t("Open JSON Editor")
|
|
300
319
|
})
|
|
301
320
|
});
|
|
302
321
|
}
|
|
303
322
|
function useAuthInputs(engine, requirements) {
|
|
304
323
|
const authCtx = useAuth();
|
|
305
324
|
const storageKeys = useStorageKey();
|
|
306
|
-
const t = useTranslations();
|
|
307
|
-
const
|
|
325
|
+
const t = useTranslations({ note: "playground" });
|
|
326
|
+
const ctx = useRenderContext();
|
|
327
|
+
const schemes = ctx.schema.dereferenced.components?.securitySchemes;
|
|
328
|
+
const { transformAuthInputs } = ctx.playground ?? {};
|
|
308
329
|
const [requirementId, setRequirementId] = useState(() => {
|
|
309
|
-
if (requirements.length === 0) return -1;
|
|
330
|
+
if (!schemes || requirements.length === 0) return -1;
|
|
310
331
|
const idx = requirements.findIndex((s) => s.every((item) => !schemes[item.id].deprecated));
|
|
311
332
|
return idx !== -1 ? idx : 0;
|
|
312
333
|
});
|
|
313
334
|
const requirement = requirementId === -1 ? null : requirements[requirementId];
|
|
314
335
|
let inputs = useMemo(() => {
|
|
315
|
-
if (!requirement) return [];
|
|
336
|
+
if (!requirement || !schemes) return [];
|
|
316
337
|
return requirement.map((item) => {
|
|
317
|
-
const scheme = schemes[item.id];
|
|
338
|
+
const scheme = schemes?.[item.id];
|
|
318
339
|
if (scheme.type === "http" && scheme.scheme === "basic") {
|
|
319
340
|
const fieldName = ["header", "Authorization"];
|
|
320
341
|
return {
|
|
@@ -365,7 +386,7 @@ function useAuthInputs(engine, requirements) {
|
|
|
365
386
|
storageKey: storageKeys.AuthField(item.id),
|
|
366
387
|
defaultValue: "Bearer ",
|
|
367
388
|
children: /* @__PURE__ */ jsx(FieldSet, {
|
|
368
|
-
name: `${t
|
|
389
|
+
name: `${t("Authorization")} (${t("Header")})`,
|
|
369
390
|
fieldName,
|
|
370
391
|
field: { type: "string" }
|
|
371
392
|
})
|
|
@@ -392,12 +413,12 @@ function useAuthInputs(engine, requirements) {
|
|
|
392
413
|
defaultValue: "",
|
|
393
414
|
storageKey: storageKeys.AuthField(item.id),
|
|
394
415
|
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FieldSet, {
|
|
395
|
-
name: `${t
|
|
416
|
+
name: `${t("Authorization")} (${t("Header")})`,
|
|
396
417
|
fieldName,
|
|
397
418
|
field: { type: "string" }
|
|
398
419
|
}), /* @__PURE__ */ jsx("p", {
|
|
399
420
|
className: "text-fd-muted-foreground text-xs",
|
|
400
|
-
children: t.
|
|
421
|
+
children: t("OpenID Connect is not supported at the moment, you can still set an access token here.")
|
|
401
422
|
})] })
|
|
402
423
|
};
|
|
403
424
|
});
|
|
@@ -466,13 +487,13 @@ function useAuthInputs(engine, requirements) {
|
|
|
466
487
|
function OAuth2Input({ fieldName, security }) {
|
|
467
488
|
const [open, setOpen] = useState(false);
|
|
468
489
|
const engine = useDataEngine();
|
|
469
|
-
const t = useTranslations();
|
|
490
|
+
const t = useTranslations({ note: "playground" });
|
|
470
491
|
return /* @__PURE__ */ jsxs("fieldset", {
|
|
471
492
|
className: "flex flex-col gap-2",
|
|
472
493
|
children: [/* @__PURE__ */ jsx("label", {
|
|
473
494
|
htmlFor: stringifyFieldKey(fieldName),
|
|
474
495
|
className: cn(labelVariants()),
|
|
475
|
-
children: t
|
|
496
|
+
children: t("Access Token")
|
|
476
497
|
}), /* @__PURE__ */ jsxs("div", {
|
|
477
498
|
className: "flex gap-2",
|
|
478
499
|
children: [/* @__PURE__ */ jsx(FieldInput, {
|
|
@@ -488,7 +509,7 @@ function OAuth2Input({ fieldName, security }) {
|
|
|
488
509
|
size: "sm",
|
|
489
510
|
color: "secondary"
|
|
490
511
|
})),
|
|
491
|
-
children: t
|
|
512
|
+
children: t("Authorize")
|
|
492
513
|
}), /* @__PURE__ */ jsx(OAuthDialogContent, {
|
|
493
514
|
setOpen,
|
|
494
515
|
schemeId: security.id,
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useTranslations } from "../../ui/client/i18n.js";
|
|
1
|
+
import { useRenderContext } from "../../ui/contexts/api.js";
|
|
3
2
|
import { cn } from "../../utils/cn.js";
|
|
4
3
|
import { useQuery } from "../../utils/use-query.js";
|
|
5
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
6
|
-
import { Input, labelVariants } from "../../ui/components/input.js";
|
|
7
|
-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "../../ui/components/dialog.js";
|
|
8
4
|
import { useAuth } from "../auth.js";
|
|
9
5
|
import { useMemo, useState } from "react";
|
|
10
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
11
8
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
9
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@fumadocs/api-docs/components/select";
|
|
10
|
+
import { Input, labelVariants } from "@fumadocs/api-docs/components/input";
|
|
11
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@fumadocs/api-docs/components/dialog";
|
|
12
12
|
//#region src/playground/components/oauth-dialog.tsx
|
|
13
13
|
const OAuthDialog = Dialog;
|
|
14
14
|
function OAuthDialogContent(props) {
|
|
15
|
-
const t = useTranslations();
|
|
16
|
-
return /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t
|
|
15
|
+
const t = useTranslations({ note: "OAuth dialog" });
|
|
16
|
+
return /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("Authorization") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("Obtain the access token for API.") })] }), /* @__PURE__ */ jsx(Content, { ...props })] });
|
|
17
17
|
}
|
|
18
18
|
function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
19
|
-
const
|
|
19
|
+
const schemes = useRenderContext().schema.dereferenced.components?.securitySchemes;
|
|
20
20
|
const tokenInfo = useAuth().store[schemeId];
|
|
21
|
-
const scheme = schemes[schemeId];
|
|
21
|
+
const scheme = schemes?.[schemeId];
|
|
22
22
|
if (!scheme || scheme.type !== "oauth2") throw new Error("unexpected schemaId: must be type oauth2");
|
|
23
23
|
const [type, setType] = useState(() => {
|
|
24
24
|
return Object.keys(scheme.flows)[0];
|
|
25
25
|
});
|
|
26
|
-
const t = useTranslations();
|
|
26
|
+
const t = useTranslations({ note: "OAuth dialog" });
|
|
27
27
|
const allFlows = useMemo(() => ({
|
|
28
28
|
password: {
|
|
29
|
-
name: t
|
|
30
|
-
description: t.
|
|
29
|
+
name: t("Resource Owner Password Flow"),
|
|
30
|
+
description: t("Authenticate using username and password."),
|
|
31
31
|
supported: true
|
|
32
32
|
},
|
|
33
33
|
clientCredentials: {
|
|
34
|
-
name: t
|
|
35
|
-
description: t.
|
|
34
|
+
name: t("Client Credentials"),
|
|
35
|
+
description: t("Intended for the server-to-server authentication."),
|
|
36
36
|
supported: true
|
|
37
37
|
},
|
|
38
38
|
authorizationCode: {
|
|
39
|
-
name: t
|
|
40
|
-
description: t
|
|
39
|
+
name: t("Authorization code"),
|
|
40
|
+
description: t("Authenticate with 3rd party services"),
|
|
41
41
|
supported: true
|
|
42
42
|
},
|
|
43
43
|
implicit: {
|
|
44
|
-
name: t
|
|
45
|
-
description: t.
|
|
44
|
+
name: t("Implicit"),
|
|
45
|
+
description: t("Retrieve the access token directly."),
|
|
46
46
|
supported: true
|
|
47
47
|
},
|
|
48
48
|
deviceAuthorization: {
|
|
49
|
-
name: t
|
|
50
|
-
description: t.
|
|
49
|
+
name: t("Device Authorization"),
|
|
50
|
+
description: t("Authenticate with device."),
|
|
51
51
|
supported: false
|
|
52
52
|
}
|
|
53
53
|
}), [t]);
|
|
@@ -138,7 +138,7 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
138
138
|
/* @__PURE__ */ jsxs(Select, {
|
|
139
139
|
value: type ?? "",
|
|
140
140
|
onValueChange: setType,
|
|
141
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t
|
|
141
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("Select a flow") }) }), /* @__PURE__ */ jsx(SelectContent, { children: Object.keys(scheme.flows).map((key) => {
|
|
142
142
|
const { name, description } = allFlows[key];
|
|
143
143
|
return /* @__PURE__ */ jsxs(SelectItem, {
|
|
144
144
|
value: key,
|
|
@@ -158,16 +158,16 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
158
158
|
/* @__PURE__ */ jsx("label", {
|
|
159
159
|
htmlFor: "client_id",
|
|
160
160
|
className: cn(labelVariants()),
|
|
161
|
-
children: t
|
|
161
|
+
children: t("Client ID")
|
|
162
162
|
}),
|
|
163
163
|
/* @__PURE__ */ jsx("p", {
|
|
164
164
|
className: "text-fd-muted-foreground text-sm",
|
|
165
|
-
children: t.
|
|
165
|
+
children: t("The client ID of your OAuth application.")
|
|
166
166
|
}),
|
|
167
167
|
/* @__PURE__ */ jsx(Input, {
|
|
168
168
|
id: "client_id",
|
|
169
169
|
name: "clientId",
|
|
170
|
-
placeholder: t
|
|
170
|
+
placeholder: t("Enter value"),
|
|
171
171
|
type: "text",
|
|
172
172
|
autoComplete: "off",
|
|
173
173
|
disabled: isLoading,
|
|
@@ -182,16 +182,16 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
182
182
|
/* @__PURE__ */ jsx("label", {
|
|
183
183
|
htmlFor: "client_secret",
|
|
184
184
|
className: cn(labelVariants()),
|
|
185
|
-
children: t
|
|
185
|
+
children: t("Client Secret")
|
|
186
186
|
}),
|
|
187
187
|
/* @__PURE__ */ jsx("p", {
|
|
188
188
|
className: "text-fd-muted-foreground text-sm",
|
|
189
|
-
children: t.
|
|
189
|
+
children: t("The client secret of your OAuth application.")
|
|
190
190
|
}),
|
|
191
191
|
/* @__PURE__ */ jsx(Input, {
|
|
192
192
|
id: "client_secret",
|
|
193
193
|
name: "clientSecret",
|
|
194
|
-
placeholder: t
|
|
194
|
+
placeholder: t("Enter value"),
|
|
195
195
|
type: "password",
|
|
196
196
|
autoComplete: "off",
|
|
197
197
|
disabled: isLoading,
|
|
@@ -205,11 +205,11 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
205
205
|
children: [/* @__PURE__ */ jsx("label", {
|
|
206
206
|
htmlFor: "username",
|
|
207
207
|
className: cn(labelVariants()),
|
|
208
|
-
children: t
|
|
208
|
+
children: t("Username")
|
|
209
209
|
}), /* @__PURE__ */ jsx(Input, {
|
|
210
210
|
id: "username",
|
|
211
211
|
name: "username",
|
|
212
|
-
placeholder: t
|
|
212
|
+
placeholder: t("Enter value"),
|
|
213
213
|
type: "text",
|
|
214
214
|
autoComplete: "off",
|
|
215
215
|
disabled: isLoading,
|
|
@@ -221,11 +221,11 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
221
221
|
children: [/* @__PURE__ */ jsx("label", {
|
|
222
222
|
htmlFor: "password",
|
|
223
223
|
className: cn(labelVariants()),
|
|
224
|
-
children: t
|
|
224
|
+
children: t("Password")
|
|
225
225
|
}), /* @__PURE__ */ jsx(Input, {
|
|
226
226
|
id: "password",
|
|
227
227
|
name: "password",
|
|
228
|
-
placeholder: t
|
|
228
|
+
placeholder: t("Enter value"),
|
|
229
229
|
type: "password",
|
|
230
230
|
autoComplete: "off",
|
|
231
231
|
disabled: isLoading,
|
|
@@ -239,10 +239,10 @@ function Content({ schemeId, scopes, setToken, setOpen }) {
|
|
|
239
239
|
}) : null, /* @__PURE__ */ jsx("button", {
|
|
240
240
|
type: "submit",
|
|
241
241
|
className: cn(buttonVariants({ color: "primary" })),
|
|
242
|
-
children: t
|
|
242
|
+
children: t("Submit")
|
|
243
243
|
})] }) : /* @__PURE__ */ jsx("p", {
|
|
244
244
|
className: "text-fd-muted-foreground bg-fd-muted p-2 rounded-lg border",
|
|
245
|
-
children: t
|
|
245
|
+
children: t("Unsupported")
|
|
246
246
|
})
|
|
247
247
|
]
|
|
248
248
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FetchResult } from "../fetcher.js";
|
|
2
2
|
import { ComponentProps } from "react";
|
|
3
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/playground/components/result-display.d.ts
|
|
6
5
|
interface ResultDisplayProps extends ComponentProps<'div'> {
|
|
@@ -11,6 +10,6 @@ declare function DefaultResultDisplay({
|
|
|
11
10
|
data,
|
|
12
11
|
reset,
|
|
13
12
|
...rest
|
|
14
|
-
}: ResultDisplayProps):
|
|
13
|
+
}: ResultDisplayProps): import("react").JSX.Element;
|
|
15
14
|
//#endregion
|
|
16
15
|
export { DefaultResultDisplay, ResultDisplayProps };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useTranslations } from "../../ui/client/i18n.js";
|
|
3
2
|
import { useStatusInfo } from "../status-info.js";
|
|
4
3
|
import { cn } from "../../utils/cn.js";
|
|
5
4
|
import { ClientCodeBlock } from "../../ui/components/codeblock.js";
|
|
@@ -7,14 +6,14 @@ import { require_fast_content_type_parse } from "../../node_modules/.pnpm/fast-c
|
|
|
7
6
|
import { useEffect, useMemo, useState } from "react";
|
|
8
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
8
|
import { CircleX } from "lucide-react";
|
|
10
|
-
import {
|
|
9
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
11
10
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
12
11
|
import { cva } from "class-variance-authority";
|
|
13
12
|
//#region src/playground/components/result-display.tsx
|
|
14
13
|
var import_fast_content_type_parse = require_fast_content_type_parse();
|
|
15
14
|
const panelVariants = cva("flex flex-col gap-2 mt-2 px-3 py-2 border-y bg-fd-secondary text-fd-secondary-foreground");
|
|
16
15
|
function DefaultResultDisplay({ data, reset, ...rest }) {
|
|
17
|
-
const t = useTranslations();
|
|
16
|
+
const t = useTranslations({ note: "playground result display" });
|
|
18
17
|
if (data.type === "client_error") return /* @__PURE__ */ jsxs("div", {
|
|
19
18
|
...rest,
|
|
20
19
|
className: cn(panelVariants(), rest.className),
|
|
@@ -24,7 +23,7 @@ function DefaultResultDisplay({ data, reset, ...rest }) {
|
|
|
24
23
|
/* @__PURE__ */ jsx(CircleX, { className: "size-4 text-red-500" }),
|
|
25
24
|
/* @__PURE__ */ jsx("p", {
|
|
26
25
|
className: "text-sm font-medium me-auto",
|
|
27
|
-
children: t
|
|
26
|
+
children: t("Client Error")
|
|
28
27
|
}),
|
|
29
28
|
/* @__PURE__ */ jsx("button", {
|
|
30
29
|
type: "button",
|
|
@@ -33,7 +32,7 @@ function DefaultResultDisplay({ data, reset, ...rest }) {
|
|
|
33
32
|
variant: "outline"
|
|
34
33
|
})),
|
|
35
34
|
onClick: () => reset(),
|
|
36
|
-
children: t
|
|
35
|
+
children: t("Close")
|
|
37
36
|
})
|
|
38
37
|
]
|
|
39
38
|
}), /* @__PURE__ */ jsx("p", { children: data.message })]
|
|
@@ -60,7 +59,7 @@ function getTextFormat(mime) {
|
|
|
60
59
|
return null;
|
|
61
60
|
}
|
|
62
61
|
function ResponseResult({ data, reset, ...rest }) {
|
|
63
|
-
const t = useTranslations();
|
|
62
|
+
const t = useTranslations({ note: "playground result display" });
|
|
64
63
|
const statusInfo = useStatusInfo(data.status);
|
|
65
64
|
const { parameters, type } = useMemo(() => (0, import_fast_content_type_parse.safeParse)(data.headers.get("Content-Type") ?? "text/plain"), [data.headers]);
|
|
66
65
|
let content;
|
|
@@ -77,7 +76,7 @@ function ResponseResult({ data, reset, ...rest }) {
|
|
|
77
76
|
});
|
|
78
77
|
else content = /* @__PURE__ */ jsx("p", {
|
|
79
78
|
className: "p-2 border rounded-lg bg-fd-card text-fd-card-foreground",
|
|
80
|
-
children:
|
|
79
|
+
children: t("Binary response body, {length} bytes", { variables: { length: String(data.body.byteLength) } })
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -106,7 +105,7 @@ function ResponseResult({ data, reset, ...rest }) {
|
|
|
106
105
|
variant: "outline"
|
|
107
106
|
})),
|
|
108
107
|
onClick: () => reset(),
|
|
109
|
-
children: t
|
|
108
|
+
children: t("Close")
|
|
110
109
|
})
|
|
111
110
|
]
|
|
112
111
|
}), content]
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { resolveServerUrl, withBase } from "../../utils/url.js";
|
|
3
2
|
import { useServerContext } from "../../ui/contexts/api.js";
|
|
4
|
-
import { useTranslations } from "../../ui/client/i18n.js";
|
|
5
3
|
import { cn } from "../../utils/cn.js";
|
|
6
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
|
|
7
|
-
import { Input, labelVariants } from "../../ui/components/input.js";
|
|
8
|
-
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "../../ui/components/dialog.js";
|
|
9
4
|
import { useEffect, useRef, useState } from "react";
|
|
10
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
6
|
import { EditIcon } from "lucide-react";
|
|
7
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@fumadocs/api-docs/components/select";
|
|
9
|
+
import { Input, labelVariants } from "@fumadocs/api-docs/components/input";
|
|
10
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "@fumadocs/api-docs/components/dialog";
|
|
12
11
|
import { StfProvider, useFieldValue, useListener, useStf } from "@fumari/stf";
|
|
12
|
+
import { resolveServerUrl } from "@fumadocs/api-docs/utils/url";
|
|
13
13
|
//#region src/playground/components/server-select.tsx
|
|
14
14
|
function ServerSelect(props) {
|
|
15
15
|
const { servers, server, setServer, setServerVariables } = useServerContext();
|
|
16
16
|
const [open, setOpen] = useState(false);
|
|
17
17
|
const [isMounted, setIsMounted] = useState(false);
|
|
18
|
-
const t = useTranslations();
|
|
18
|
+
const t = useTranslations({ note: "playground server select" });
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
setIsMounted(true);
|
|
21
21
|
}, []);
|
|
@@ -30,16 +30,16 @@ function ServerSelect(props) {
|
|
|
30
30
|
children: [
|
|
31
31
|
/* @__PURE__ */ jsx("span", {
|
|
32
32
|
className: "px-2 py-0.5 -ms-2 font-medium rounded-lg border bg-fd-secondary text-fd-secondary-foreground shadow-sm",
|
|
33
|
-
children: server?.name ?? t
|
|
33
|
+
children: server?.name ?? t("Server URL")
|
|
34
34
|
}),
|
|
35
35
|
/* @__PURE__ */ jsx("code", {
|
|
36
36
|
className: "truncate min-w-0 flex-1",
|
|
37
|
-
children: isMounted ?
|
|
37
|
+
children: isMounted ? new URL(server ? resolveServerUrl(server.url, server.variables) : "/", window.location.origin).href : t("loading...")
|
|
38
38
|
}),
|
|
39
39
|
/* @__PURE__ */ jsx(EditIcon, { className: "size-4" })
|
|
40
40
|
]
|
|
41
41
|
}), /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
42
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t
|
|
42
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("Server URL") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("The base URL of your API endpoint.") })] }),
|
|
43
43
|
/* @__PURE__ */ jsxs(Select, {
|
|
44
44
|
value: server?.url,
|
|
45
45
|
onValueChange: setServer,
|
|
@@ -100,7 +100,7 @@ function ServerSelectContent({ defaultValues, onChange, schema }) {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
function Field({ fieldName, variable }) {
|
|
103
|
-
const t = useTranslations();
|
|
103
|
+
const t = useTranslations({ note: "playground server select" });
|
|
104
104
|
const [value, setValue] = useFieldValue([fieldName], { compute(currentValue) {
|
|
105
105
|
return typeof currentValue === "string" ? currentValue : void 0;
|
|
106
106
|
} });
|
|
@@ -119,7 +119,7 @@ function Field({ fieldName, variable }) {
|
|
|
119
119
|
id: fieldName,
|
|
120
120
|
value,
|
|
121
121
|
onChange: (e) => setValue(e.target.value),
|
|
122
|
-
placeholder: t
|
|
122
|
+
placeholder: t("Enter Value")
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|