fumadocs-openapi 10.10.2 → 11.0.0

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