fumadocs-openapi 10.2.2 → 10.2.3

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 (278) hide show
  1. package/dist/generate-file.d.ts +53 -49
  2. package/dist/generate-file.d.ts.map +1 -1
  3. package/dist/generate-file.js +88 -102
  4. package/dist/generate-file.js.map +1 -0
  5. package/dist/index.d.ts +6 -6
  6. package/dist/index.js +3 -1
  7. package/dist/playground/client.d.ts +88 -72
  8. package/dist/playground/client.d.ts.map +1 -1
  9. package/dist/playground/client.js +446 -296
  10. package/dist/playground/client.js.map +1 -0
  11. package/dist/playground/components/inputs.js +395 -172
  12. package/dist/playground/components/inputs.js.map +1 -0
  13. package/dist/playground/components/oauth-dialog.js +270 -174
  14. package/dist/playground/components/oauth-dialog.js.map +1 -0
  15. package/dist/playground/components/server-select.js +115 -55
  16. package/dist/playground/components/server-select.js.map +1 -0
  17. package/dist/playground/fetcher.d.ts +10 -18
  18. package/dist/playground/fetcher.d.ts.map +1 -1
  19. package/dist/playground/fetcher.js +67 -75
  20. package/dist/playground/fetcher.js.map +1 -0
  21. package/dist/playground/get-default-values.js +23 -26
  22. package/dist/playground/get-default-values.js.map +1 -0
  23. package/dist/playground/index.d.ts +23 -13
  24. package/dist/playground/index.d.ts.map +1 -1
  25. package/dist/playground/index.js +87 -91
  26. package/dist/playground/index.js.map +1 -0
  27. package/dist/playground/lazy.js +9 -2
  28. package/dist/playground/lazy.js.map +1 -0
  29. package/dist/playground/schema.d.ts +18 -55
  30. package/dist/playground/schema.d.ts.map +1 -1
  31. package/dist/playground/schema.js +117 -106
  32. package/dist/playground/schema.js.map +1 -0
  33. package/dist/playground/status-info.js +49 -37
  34. package/dist/playground/status-info.js.map +1 -0
  35. package/dist/requests/generators/csharp.js +40 -50
  36. package/dist/requests/generators/csharp.js.map +1 -0
  37. package/dist/requests/generators/curl.js +28 -27
  38. package/dist/requests/generators/curl.js.map +1 -0
  39. package/dist/requests/generators/go.js +39 -35
  40. package/dist/requests/generators/go.js.map +1 -0
  41. package/dist/requests/generators/index.js +49 -43
  42. package/dist/requests/generators/index.js.map +1 -0
  43. package/dist/requests/generators/java.js +56 -67
  44. package/dist/requests/generators/java.js.map +1 -0
  45. package/dist/requests/generators/javascript.js +38 -45
  46. package/dist/requests/generators/javascript.js.map +1 -0
  47. package/dist/requests/generators/python.js +33 -37
  48. package/dist/requests/generators/python.js.map +1 -0
  49. package/dist/requests/media/adapter.d.ts +38 -84
  50. package/dist/requests/media/adapter.d.ts.map +1 -1
  51. package/dist/requests/media/adapter.js +122 -169
  52. package/dist/requests/media/adapter.js.map +1 -0
  53. package/dist/requests/media/encode.d.ts +12 -7
  54. package/dist/requests/media/encode.d.ts.map +1 -1
  55. package/dist/requests/media/encode.js +129 -109
  56. package/dist/requests/media/encode.js.map +1 -0
  57. package/dist/requests/media/resolve-adapter.js +28 -28
  58. package/dist/requests/media/resolve-adapter.js.map +1 -0
  59. package/dist/requests/string-utils.js +28 -35
  60. package/dist/requests/string-utils.js.map +1 -0
  61. package/dist/requests/to-python-object.js +16 -28
  62. package/dist/requests/to-python-object.js.map +1 -0
  63. package/dist/requests/types.d.ts +25 -21
  64. package/dist/requests/types.d.ts.map +1 -1
  65. package/dist/scalar/client.js +57 -20
  66. package/dist/scalar/client.js.map +1 -0
  67. package/dist/scalar/index.d.ts +8 -2
  68. package/dist/scalar/index.d.ts.map +1 -1
  69. package/dist/scalar/index.js +29 -19
  70. package/dist/scalar/index.js.map +1 -0
  71. package/dist/server/create.d.ts +29 -25
  72. package/dist/server/create.d.ts.map +1 -1
  73. package/dist/server/create.js +42 -39
  74. package/dist/server/create.js.map +1 -0
  75. package/dist/server/index.d.ts +3 -3
  76. package/dist/server/index.js +4 -2
  77. package/dist/server/proxy.d.ts +28 -28
  78. package/dist/server/proxy.d.ts.map +1 -1
  79. package/dist/server/proxy.js +58 -75
  80. package/dist/server/proxy.js.map +1 -0
  81. package/dist/server/source-api.d.ts +32 -29
  82. package/dist/server/source-api.d.ts.map +1 -1
  83. package/dist/server/source-api.js +82 -75
  84. package/dist/server/source-api.js.map +1 -0
  85. package/dist/types.d.ts +41 -36
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/ui/api-page.d.ts +140 -136
  88. package/dist/ui/api-page.d.ts.map +1 -1
  89. package/dist/ui/api-page.js +134 -118
  90. package/dist/ui/api-page.js.map +1 -0
  91. package/dist/ui/client/index.d.ts +30 -26
  92. package/dist/ui/client/index.d.ts.map +1 -1
  93. package/dist/ui/client/index.js +8 -2
  94. package/dist/ui/client/index.js.map +1 -0
  95. package/dist/ui/client/storage-key.js +16 -10
  96. package/dist/ui/client/storage-key.js.map +1 -0
  97. package/dist/ui/components/accordion.js +40 -14
  98. package/dist/ui/components/accordion.js.map +1 -0
  99. package/dist/ui/components/dialog.js +51 -15
  100. package/dist/ui/components/dialog.js.map +1 -0
  101. package/dist/ui/components/input.js +18 -8
  102. package/dist/ui/components/input.js.map +1 -0
  103. package/dist/ui/components/method-label.js +38 -33
  104. package/dist/ui/components/method-label.js.map +1 -0
  105. package/dist/ui/components/select.js +66 -15
  106. package/dist/ui/components/select.js.map +1 -0
  107. package/dist/ui/contexts/api.js +96 -85
  108. package/dist/ui/contexts/api.js.map +1 -0
  109. package/dist/ui/contexts/api.lazy.js +9 -2
  110. package/dist/ui/contexts/api.lazy.js.map +1 -0
  111. package/dist/ui/index.d.ts +2 -2
  112. package/dist/ui/index.js +3 -1
  113. package/dist/ui/operation/client.js +65 -27
  114. package/dist/ui/operation/client.js.map +1 -0
  115. package/dist/ui/operation/index.js +403 -186
  116. package/dist/ui/operation/index.js.map +1 -0
  117. package/dist/ui/operation/request-tabs.d.ts +15 -16
  118. package/dist/ui/operation/request-tabs.d.ts.map +1 -1
  119. package/dist/ui/operation/request-tabs.js +151 -131
  120. package/dist/ui/operation/request-tabs.js.map +1 -0
  121. package/dist/ui/operation/response-tabs.d.ts +27 -28
  122. package/dist/ui/operation/response-tabs.d.ts.map +1 -1
  123. package/dist/ui/operation/response-tabs.js +73 -56
  124. package/dist/ui/operation/response-tabs.js.map +1 -0
  125. package/dist/ui/operation/usage-tabs/client.js +117 -88
  126. package/dist/ui/operation/usage-tabs/client.js.map +1 -0
  127. package/dist/ui/operation/usage-tabs/index.d.ts +22 -21
  128. package/dist/ui/operation/usage-tabs/index.d.ts.map +1 -1
  129. package/dist/ui/operation/usage-tabs/index.js +63 -48
  130. package/dist/ui/operation/usage-tabs/index.js.map +1 -0
  131. package/dist/ui/operation/usage-tabs/lazy.js +11 -4
  132. package/dist/ui/operation/usage-tabs/lazy.js.map +1 -0
  133. package/dist/ui/schema/client.d.ts +11 -7
  134. package/dist/ui/schema/client.d.ts.map +1 -1
  135. package/dist/ui/schema/client.js +213 -127
  136. package/dist/ui/schema/client.js.map +1 -0
  137. package/dist/ui/schema/index.d.ts +51 -50
  138. package/dist/ui/schema/index.d.ts.map +1 -1
  139. package/dist/ui/schema/index.js +225 -248
  140. package/dist/ui/schema/index.js.map +1 -0
  141. package/dist/ui/schema/lazy.js +9 -2
  142. package/dist/ui/schema/lazy.js.map +1 -0
  143. package/dist/utils/cn.js +3 -1
  144. package/dist/utils/deep-equal.js +18 -26
  145. package/dist/utils/deep-equal.js.map +1 -0
  146. package/dist/utils/get-typescript-schema.js +21 -19
  147. package/dist/utils/get-typescript-schema.js.map +1 -0
  148. package/dist/utils/id-to-title.js +13 -16
  149. package/dist/utils/id-to-title.js.map +1 -0
  150. package/dist/utils/lazy.js +13 -11
  151. package/dist/utils/lazy.js.map +1 -0
  152. package/dist/utils/merge-schema.js +130 -174
  153. package/dist/utils/merge-schema.js.map +1 -0
  154. package/dist/utils/pages/builder.d.ts +80 -76
  155. package/dist/utils/pages/builder.d.ts.map +1 -1
  156. package/dist/utils/pages/builder.js +101 -118
  157. package/dist/utils/pages/builder.js.map +1 -0
  158. package/dist/utils/pages/preset-auto.d.ts +58 -55
  159. package/dist/utils/pages/preset-auto.d.ts.map +1 -1
  160. package/dist/utils/pages/preset-auto.js +124 -137
  161. package/dist/utils/pages/preset-auto.js.map +1 -0
  162. package/dist/utils/pages/to-body.js +21 -18
  163. package/dist/utils/pages/to-body.js.map +1 -0
  164. package/dist/utils/pages/to-static-data.js +48 -40
  165. package/dist/utils/pages/to-static-data.js.map +1 -0
  166. package/dist/utils/pages/to-text.d.ts +43 -41
  167. package/dist/utils/pages/to-text.d.ts.map +1 -1
  168. package/dist/utils/pages/to-text.js +93 -126
  169. package/dist/utils/pages/to-text.js.map +1 -0
  170. package/dist/utils/process-document.d.ts +18 -19
  171. package/dist/utils/process-document.d.ts.map +1 -1
  172. package/dist/utils/process-document.js +43 -54
  173. package/dist/utils/process-document.js.map +1 -0
  174. package/dist/utils/remove-undefined.js +18 -18
  175. package/dist/utils/remove-undefined.js.map +1 -0
  176. package/dist/utils/schema-to-string.js +46 -64
  177. package/dist/utils/schema-to-string.js.map +1 -0
  178. package/dist/utils/schema.d.ts +11 -27
  179. package/dist/utils/schema.d.ts.map +1 -1
  180. package/dist/utils/schema.js +43 -44
  181. package/dist/utils/schema.js.map +1 -0
  182. package/dist/utils/url.js +35 -56
  183. package/dist/utils/url.js.map +1 -0
  184. package/dist/utils/use-query.js +39 -33
  185. package/dist/utils/use-query.js.map +1 -0
  186. package/package.json +33 -32
  187. package/dist/index.d.ts.map +0 -1
  188. package/dist/playground/components/inputs.d.ts +0 -25
  189. package/dist/playground/components/inputs.d.ts.map +0 -1
  190. package/dist/playground/components/oauth-dialog.d.ts +0 -13
  191. package/dist/playground/components/oauth-dialog.d.ts.map +0 -1
  192. package/dist/playground/components/server-select.d.ts +0 -3
  193. package/dist/playground/components/server-select.d.ts.map +0 -1
  194. package/dist/playground/get-default-values.d.ts +0 -3
  195. package/dist/playground/get-default-values.d.ts.map +0 -1
  196. package/dist/playground/lazy.d.ts +0 -2
  197. package/dist/playground/lazy.d.ts.map +0 -1
  198. package/dist/playground/status-info.d.ts +0 -8
  199. package/dist/playground/status-info.d.ts.map +0 -1
  200. package/dist/requests/generators/csharp.d.ts +0 -3
  201. package/dist/requests/generators/csharp.d.ts.map +0 -1
  202. package/dist/requests/generators/curl.d.ts +0 -3
  203. package/dist/requests/generators/curl.d.ts.map +0 -1
  204. package/dist/requests/generators/go.d.ts +0 -3
  205. package/dist/requests/generators/go.d.ts.map +0 -1
  206. package/dist/requests/generators/index.d.ts +0 -3
  207. package/dist/requests/generators/index.d.ts.map +0 -1
  208. package/dist/requests/generators/java.d.ts +0 -3
  209. package/dist/requests/generators/java.d.ts.map +0 -1
  210. package/dist/requests/generators/javascript.d.ts +0 -3
  211. package/dist/requests/generators/javascript.d.ts.map +0 -1
  212. package/dist/requests/generators/python.d.ts +0 -3
  213. package/dist/requests/generators/python.d.ts.map +0 -1
  214. package/dist/requests/media/resolve-adapter.d.ts +0 -19
  215. package/dist/requests/media/resolve-adapter.d.ts.map +0 -1
  216. package/dist/requests/string-utils.d.ts +0 -7
  217. package/dist/requests/string-utils.d.ts.map +0 -1
  218. package/dist/requests/to-python-object.d.ts +0 -2
  219. package/dist/requests/to-python-object.d.ts.map +0 -1
  220. package/dist/requests/types.js +0 -1
  221. package/dist/scalar/client.d.ts +0 -7
  222. package/dist/scalar/client.d.ts.map +0 -1
  223. package/dist/server/index.d.ts.map +0 -1
  224. package/dist/types.js +0 -1
  225. package/dist/ui/client/storage-key.d.ts +0 -9
  226. package/dist/ui/client/storage-key.d.ts.map +0 -1
  227. package/dist/ui/components/accordion.d.ts +0 -8
  228. package/dist/ui/components/accordion.d.ts.map +0 -1
  229. package/dist/ui/components/dialog.d.ts +0 -20
  230. package/dist/ui/components/dialog.d.ts.map +0 -1
  231. package/dist/ui/components/input.d.ts +0 -6
  232. package/dist/ui/components/input.d.ts.map +0 -1
  233. package/dist/ui/components/method-label.d.ts +0 -10
  234. package/dist/ui/components/method-label.d.ts.map +0 -1
  235. package/dist/ui/components/select.d.ts +0 -14
  236. package/dist/ui/components/select.d.ts.map +0 -1
  237. package/dist/ui/contexts/api.d.ts +0 -33
  238. package/dist/ui/contexts/api.d.ts.map +0 -1
  239. package/dist/ui/contexts/api.lazy.d.ts +0 -2
  240. package/dist/ui/contexts/api.lazy.d.ts.map +0 -1
  241. package/dist/ui/icons.d.ts +0 -49
  242. package/dist/ui/icons.d.ts.map +0 -1
  243. package/dist/ui/icons.js +0 -281
  244. package/dist/ui/index.d.ts.map +0 -1
  245. package/dist/ui/operation/client.d.ts +0 -19
  246. package/dist/ui/operation/client.d.ts.map +0 -1
  247. package/dist/ui/operation/index.d.ts +0 -12
  248. package/dist/ui/operation/index.d.ts.map +0 -1
  249. package/dist/ui/operation/usage-tabs/client.d.ts +0 -23
  250. package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
  251. package/dist/ui/operation/usage-tabs/lazy.d.ts +0 -4
  252. package/dist/ui/operation/usage-tabs/lazy.d.ts.map +0 -1
  253. package/dist/ui/schema/lazy.d.ts +0 -2
  254. package/dist/ui/schema/lazy.d.ts.map +0 -1
  255. package/dist/utils/cn.d.ts +0 -2
  256. package/dist/utils/cn.d.ts.map +0 -1
  257. package/dist/utils/deep-equal.d.ts +0 -2
  258. package/dist/utils/deep-equal.d.ts.map +0 -1
  259. package/dist/utils/get-typescript-schema.d.ts +0 -4
  260. package/dist/utils/get-typescript-schema.d.ts.map +0 -1
  261. package/dist/utils/id-to-title.d.ts +0 -2
  262. package/dist/utils/id-to-title.d.ts.map +0 -1
  263. package/dist/utils/lazy.d.ts +0 -5
  264. package/dist/utils/lazy.d.ts.map +0 -1
  265. package/dist/utils/merge-schema.d.ts +0 -7
  266. package/dist/utils/merge-schema.d.ts.map +0 -1
  267. package/dist/utils/pages/to-body.d.ts +0 -4
  268. package/dist/utils/pages/to-body.d.ts.map +0 -1
  269. package/dist/utils/pages/to-static-data.d.ts +0 -10
  270. package/dist/utils/pages/to-static-data.d.ts.map +0 -1
  271. package/dist/utils/remove-undefined.d.ts +0 -2
  272. package/dist/utils/remove-undefined.d.ts.map +0 -1
  273. package/dist/utils/schema-to-string.d.ts +0 -8
  274. package/dist/utils/schema-to-string.d.ts.map +0 -1
  275. package/dist/utils/url.d.ts +0 -11
  276. package/dist/utils/url.d.ts.map +0 -1
  277. package/dist/utils/use-query.d.ts +0 -8
  278. package/dist/utils/use-query.d.ts.map +0 -1
@@ -1,309 +1,459 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Fragment, lazy, useEffect, useMemo, useState, useEffectEvent, } from 'react';
4
- import { FormProvider, get, set, useController, useForm, useFormContext, } from 'react-hook-form';
5
- import { useApiContext } from '../ui/contexts/api.js';
6
- import { FieldInput, FieldSet, JsonInput, ObjectInput, } from './components/inputs.js';
7
- import { getStatusInfo } from './status-info.js';
8
- import { joinURL, resolveRequestData, resolveServerUrl, withBase, } from '../utils/url.js';
9
- import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
10
- import { MethodLabel } from '../ui/components/method-label.js';
11
- import { useQuery } from '../utils/use-query.js';
12
- import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from 'fumadocs-ui/components/ui/collapsible';
13
- import { X, ChevronDown, LoaderCircle } from '../ui/icons.js';
14
- import { encodeRequestData } from '../requests/media/encode.js';
15
- import { buttonVariants } from 'fumadocs-ui/components/ui/button';
16
- import { cn } from '../utils/cn.js';
17
- import { SchemaProvider, useResolvedSchema, } from '../playground/schema.js';
18
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '../ui/components/select.js';
19
- import { labelVariants } from '../ui/components/input.js';
20
- import ServerSelect from './components/server-select.js';
21
- import { useStorageKey } from '../ui/client/storage-key.js';
22
- import { useExampleRequests } from '../ui/operation/usage-tabs/client.js';
23
- const OauthDialog = lazy(() => import('./components/oauth-dialog.js').then((mod) => ({
24
- default: mod.OauthDialog,
25
- })));
26
- const OauthDialogTrigger = lazy(() => import('./components/oauth-dialog.js').then((mod) => ({
27
- default: mod.OauthDialogTrigger,
28
- })));
29
- export default function PlaygroundClient({ route, method = 'GET', securities, parameters = [], body, references, proxyUrl, writeOnly, readOnly, ...rest }) {
30
- const { example: exampleId, examples, setExampleData } = useExampleRequests();
31
- const storageKeys = useStorageKey();
32
- const fieldInfoMap = useMemo(() => new Map(), []);
33
- const { mediaAdapters, serverRef, client: { playground: { components: { ResultDisplay = DefaultResultDisplay } = {}, requestTimeout = 10, transformAuthInputs, } = {}, }, } = useApiContext();
34
- const [securityId, setSecurityId] = useState(0);
35
- const { inputs, mapInputs, initAuthValues } = useAuthInputs(securities[securityId], transformAuthInputs);
36
- const defaultValues = useMemo(() => {
37
- const requestData = examples.find((example) => example.id === exampleId)?.data;
38
- return {
39
- path: requestData?.path ?? {},
40
- query: requestData?.query ?? {},
41
- header: requestData?.header ?? {},
42
- body: requestData?.body ?? {},
43
- cookie: requestData?.cookie ?? {},
44
- };
45
- }, [examples, exampleId]);
46
- const form = useForm({
47
- defaultValues,
48
- });
49
- const testQuery = useQuery(async (input) => {
50
- const targetServer = serverRef.current;
51
- const fetcher = await import('./fetcher.js').then((mod) => mod.createBrowserFetcher(mediaAdapters, requestTimeout));
52
- input._encoded ?? (input._encoded = encodeRequestData({ ...mapInputs(input), method, bodyMediaType: body?.mediaType }, mediaAdapters, parameters));
53
- return fetcher.fetch(joinURL(withBase(targetServer
54
- ? resolveServerUrl(targetServer.url, targetServer.variables)
55
- : '/', window.location.origin), resolveRequestData(route, input._encoded)), {
56
- proxyUrl,
57
- ...input._encoded,
58
- });
59
- });
60
- const onUpdateDebounced = useEffectEvent((values) => {
61
- for (const item of inputs) {
62
- const value = get(values, item.fieldName);
63
- if (value) {
64
- localStorage.setItem(storageKeys.AuthField(item), JSON.stringify(value));
65
- }
66
- }
67
- const data = {
68
- ...mapInputs(values),
69
- method,
70
- bodyMediaType: body?.mediaType,
71
- };
72
- values._encoded ?? (values._encoded = encodeRequestData(data, mediaAdapters, parameters));
73
- setExampleData(data, values._encoded);
74
- });
75
- useEffect(() => {
76
- let timer = null;
77
- const subscription = form.subscribe({
78
- formState: {
79
- values: true,
80
- },
81
- callback({ values }) {
82
- // remove cached encoded request data
83
- delete values._encoded;
84
- if (timer)
85
- window.clearTimeout(timer);
86
- timer = window.setTimeout(() => onUpdateDebounced(values), timer ? 400 : 0);
87
- },
88
- });
89
- return () => subscription();
90
- // eslint-disable-next-line react-hooks/exhaustive-deps -- mounted once only
91
- }, []);
92
- useEffect(() => {
93
- form.reset(initAuthValues(defaultValues));
94
- return () => fieldInfoMap.clear();
95
- // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore other parts
96
- }, [defaultValues]);
97
- useEffect(() => {
98
- form.reset((values) => initAuthValues(values));
99
- return () => {
100
- form.reset((values) => {
101
- for (const item of inputs) {
102
- set(values, item.fieldName, undefined);
103
- }
104
- return values;
105
- });
106
- };
107
- // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore other parts
108
- }, [inputs]);
109
- const onSubmit = form.handleSubmit((value) => {
110
- testQuery.start(mapInputs(value));
111
- });
112
- return (_jsx(FormProvider, { ...form, children: _jsx(SchemaProvider, { fieldInfoMap: fieldInfoMap, references: references, writeOnly: writeOnly, readOnly: readOnly, children: _jsxs("form", { ...rest, className: cn('not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground', rest.className), onSubmit: onSubmit, children: [_jsx(ServerSelect, {}), _jsxs("div", { className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0", children: [_jsx(MethodLabel, { children: method }), _jsx(Route, { route: route, className: "flex-1" }), _jsx("button", { type: "submit", className: cn(buttonVariants({ color: 'primary', size: 'sm' }), 'w-14 py-1.5'), disabled: testQuery.isLoading, children: testQuery.isLoading ? (_jsx(LoaderCircle, { className: "size-4 animate-spin" })) : ('Send') })] }), securities.length > 0 && (_jsx(SecurityTabs, { securities: securities, securityId: securityId, setSecurityId: setSecurityId, children: inputs.map((input) => (_jsx(Fragment, { children: input.children }, input.fieldName))) })), _jsx(FormBody, { body: body, parameters: parameters }), testQuery.data ? (_jsx(ResultDisplay, { data: testQuery.data, reset: testQuery.reset })) : null] }) }) }));
2
+
3
+ import { joinURL, resolveRequestData, resolveServerUrl, withBase } from "../utils/url.js";
4
+ import { useStorageKey } from "../ui/client/storage-key.js";
5
+ import { useApiContext } from "../ui/contexts/api.js";
6
+ import { cn } from "../utils/cn.js";
7
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/components/select.js";
8
+ import { labelVariants } from "../ui/components/input.js";
9
+ import { SchemaProvider, useResolvedSchema } from "./schema.js";
10
+ import { FieldInput, FieldSet, JsonInput, ObjectInput } from "./components/inputs.js";
11
+ import { getStatusInfo } from "./status-info.js";
12
+ import { MethodLabel } from "../ui/components/method-label.js";
13
+ import { useQuery } from "../utils/use-query.js";
14
+ import { encodeRequestData } from "../requests/media/encode.js";
15
+ import ServerSelect from "./components/server-select.js";
16
+ import { useExampleRequests } from "../ui/operation/usage-tabs/client.js";
17
+ import { Fragment, lazy, useEffect, useEffectEvent, useMemo, useState } from "react";
18
+ import { FormProvider, get, set, useController, useForm, useFormContext } from "react-hook-form";
19
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
20
+ import { ChevronDown, LoaderCircle, X } from "lucide-react";
21
+ import { buttonVariants } from "fumadocs-ui/components/ui/button";
22
+ import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
23
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "fumadocs-ui/components/ui/collapsible";
24
+
25
+ //#region src/playground/client.tsx
26
+ const OauthDialog = lazy(() => import("./components/oauth-dialog.js").then((mod) => ({ default: mod.OauthDialog })));
27
+ const OauthDialogTrigger = lazy(() => import("./components/oauth-dialog.js").then((mod) => ({ default: mod.OauthDialogTrigger })));
28
+ function PlaygroundClient({ route, method = "GET", securities, parameters = [], body, references, proxyUrl, writeOnly, readOnly, ...rest }) {
29
+ const { example: exampleId, examples, setExampleData } = useExampleRequests();
30
+ const storageKeys = useStorageKey();
31
+ const fieldInfoMap = useMemo(() => /* @__PURE__ */ new Map(), []);
32
+ const { mediaAdapters, serverRef, client: { playground: { components: { ResultDisplay = DefaultResultDisplay } = {}, requestTimeout = 10, transformAuthInputs } = {} } } = useApiContext();
33
+ const [securityId, setSecurityId] = useState(0);
34
+ const { inputs, mapInputs, initAuthValues } = useAuthInputs(securities[securityId], transformAuthInputs);
35
+ const defaultValues = useMemo(() => {
36
+ const requestData = examples.find((example) => example.id === exampleId)?.data;
37
+ return {
38
+ path: requestData?.path ?? {},
39
+ query: requestData?.query ?? {},
40
+ header: requestData?.header ?? {},
41
+ body: requestData?.body ?? {},
42
+ cookie: requestData?.cookie ?? {}
43
+ };
44
+ }, [examples, exampleId]);
45
+ const form = useForm({ defaultValues });
46
+ const testQuery = useQuery(async (input) => {
47
+ const targetServer = serverRef.current;
48
+ const fetcher = await import("./fetcher.js").then((mod) => mod.createBrowserFetcher(mediaAdapters, requestTimeout));
49
+ input._encoded ??= encodeRequestData({
50
+ ...mapInputs(input),
51
+ method,
52
+ bodyMediaType: body?.mediaType
53
+ }, mediaAdapters, parameters);
54
+ return fetcher.fetch(joinURL(withBase(targetServer ? resolveServerUrl(targetServer.url, targetServer.variables) : "/", window.location.origin), resolveRequestData(route, input._encoded)), {
55
+ proxyUrl,
56
+ ...input._encoded
57
+ });
58
+ });
59
+ const onUpdateDebounced = useEffectEvent((values) => {
60
+ for (const item of inputs) {
61
+ const value = get(values, item.fieldName);
62
+ if (value) localStorage.setItem(storageKeys.AuthField(item), JSON.stringify(value));
63
+ }
64
+ const data = {
65
+ ...mapInputs(values),
66
+ method,
67
+ bodyMediaType: body?.mediaType
68
+ };
69
+ values._encoded ??= encodeRequestData(data, mediaAdapters, parameters);
70
+ setExampleData(data, values._encoded);
71
+ });
72
+ useEffect(() => {
73
+ let timer = null;
74
+ const subscription = form.subscribe({
75
+ formState: { values: true },
76
+ callback({ values }) {
77
+ delete values._encoded;
78
+ if (timer) window.clearTimeout(timer);
79
+ timer = window.setTimeout(() => onUpdateDebounced(values), timer ? 400 : 0);
80
+ }
81
+ });
82
+ return () => subscription();
83
+ }, []);
84
+ useEffect(() => {
85
+ form.reset(initAuthValues(defaultValues));
86
+ return () => fieldInfoMap.clear();
87
+ }, [defaultValues]);
88
+ useEffect(() => {
89
+ form.reset((values) => initAuthValues(values));
90
+ return () => {
91
+ form.reset((values) => {
92
+ for (const item of inputs) set(values, item.fieldName, void 0);
93
+ return values;
94
+ });
95
+ };
96
+ }, [inputs]);
97
+ const onSubmit = form.handleSubmit((value) => {
98
+ testQuery.start(mapInputs(value));
99
+ });
100
+ return /* @__PURE__ */ jsx(FormProvider, {
101
+ ...form,
102
+ children: /* @__PURE__ */ jsx(SchemaProvider, {
103
+ fieldInfoMap,
104
+ references,
105
+ writeOnly,
106
+ readOnly,
107
+ children: /* @__PURE__ */ jsxs("form", {
108
+ ...rest,
109
+ className: cn("not-prose flex flex-col rounded-xl border shadow-md overflow-hidden bg-fd-card text-fd-card-foreground", rest.className),
110
+ onSubmit,
111
+ children: [
112
+ /* @__PURE__ */ jsx(ServerSelect, {}),
113
+ /* @__PURE__ */ jsxs("div", {
114
+ className: "flex flex-row items-center gap-2 text-sm p-3 not-last:pb-0",
115
+ children: [
116
+ /* @__PURE__ */ jsx(MethodLabel, { children: method }),
117
+ /* @__PURE__ */ jsx(Route, {
118
+ route,
119
+ className: "flex-1"
120
+ }),
121
+ /* @__PURE__ */ jsx("button", {
122
+ type: "submit",
123
+ className: cn(buttonVariants({
124
+ color: "primary",
125
+ size: "sm"
126
+ }), "w-14 py-1.5"),
127
+ disabled: testQuery.isLoading,
128
+ children: testQuery.isLoading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }) : "Send"
129
+ })
130
+ ]
131
+ }),
132
+ securities.length > 0 && /* @__PURE__ */ jsx(SecurityTabs, {
133
+ securities,
134
+ securityId,
135
+ setSecurityId,
136
+ children: inputs.map((input) => /* @__PURE__ */ jsx(Fragment, { children: input.children }, input.fieldName))
137
+ }),
138
+ /* @__PURE__ */ jsx(FormBody, {
139
+ body,
140
+ parameters
141
+ }),
142
+ testQuery.data ? /* @__PURE__ */ jsx(ResultDisplay, {
143
+ data: testQuery.data,
144
+ reset: testQuery.reset
145
+ }) : null
146
+ ]
147
+ })
148
+ })
149
+ });
113
150
  }
114
- function SecurityTabs({ securities, setSecurityId, securityId, children, }) {
115
- const [open, setOpen] = useState(false);
116
- const form = useFormContext();
117
- const result = (_jsxs(CollapsiblePanel, { title: "Authorization", children: [_jsxs(Select, { value: securityId.toString(), onValueChange: (v) => setSecurityId(Number(v)), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: securities.map((security, i) => (_jsx(SelectItem, { value: i.toString(), children: security.map((item) => (_jsxs("div", { className: "max-w-[600px]", children: [_jsx("p", { className: "font-mono font-medium", children: item.id }), _jsx("p", { className: "text-fd-muted-foreground whitespace-pre-wrap", children: item.description })] }, item.id))) }, i))) })] }), children] }));
118
- for (let i = 0; i < securities.length; i++) {
119
- const security = securities[i];
120
- for (const item of security) {
121
- if (item.type === 'oauth2') {
122
- return (_jsx(OauthDialog, { scheme: item, scopes: item.scopes, open: open, setOpen: (v) => {
123
- setOpen(v);
124
- if (v) {
125
- setSecurityId(i);
126
- }
127
- }, setToken: (token) => form.setValue('header.Authorization', token), children: result }));
128
- }
129
- }
130
- }
131
- return result;
151
+ function SecurityTabs({ securities, setSecurityId, securityId, children }) {
152
+ const [open, setOpen] = useState(false);
153
+ const form = useFormContext();
154
+ const result = /* @__PURE__ */ jsxs(CollapsiblePanel, {
155
+ title: "Authorization",
156
+ children: [/* @__PURE__ */ jsxs(Select, {
157
+ value: securityId.toString(),
158
+ onValueChange: (v) => setSecurityId(Number(v)),
159
+ children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }), /* @__PURE__ */ jsx(SelectContent, { children: securities.map((security, i) => /* @__PURE__ */ jsx(SelectItem, {
160
+ value: i.toString(),
161
+ children: security.map((item) => /* @__PURE__ */ jsxs("div", {
162
+ className: "max-w-[600px]",
163
+ children: [/* @__PURE__ */ jsx("p", {
164
+ className: "font-mono font-medium",
165
+ children: item.id
166
+ }), /* @__PURE__ */ jsx("p", {
167
+ className: "text-fd-muted-foreground whitespace-pre-wrap",
168
+ children: item.description
169
+ })]
170
+ }, item.id))
171
+ }, i)) })]
172
+ }), children]
173
+ });
174
+ for (let i = 0; i < securities.length; i++) {
175
+ const security = securities[i];
176
+ for (const item of security) if (item.type === "oauth2") return /* @__PURE__ */ jsx(OauthDialog, {
177
+ scheme: item,
178
+ scopes: item.scopes,
179
+ open,
180
+ setOpen: (v) => {
181
+ setOpen(v);
182
+ if (v) setSecurityId(i);
183
+ },
184
+ setToken: (token) => form.setValue("header.Authorization", token),
185
+ children: result
186
+ });
187
+ }
188
+ return result;
132
189
  }
133
- const ParamTypes = ['path', 'header', 'cookie', 'query'];
134
- function FormBody({ parameters = [], body, }) {
135
- const { renderParameterField, renderBodyField } = useApiContext().client.playground ?? {};
136
- const panels = useMemo(() => {
137
- return ParamTypes.map((type) => {
138
- const items = parameters.filter((v) => v.in === type);
139
- if (items.length === 0)
140
- return;
141
- return (_jsx(CollapsiblePanel, { title: {
142
- header: 'Header',
143
- cookie: 'Cookies',
144
- query: 'Query',
145
- path: 'Path',
146
- }[type], children: items.map((field) => {
147
- const fieldName = `${type}.${field.name}`;
148
- if (renderParameterField) {
149
- return renderParameterField(fieldName, field);
150
- }
151
- const contentTypes = field.content && Object.keys(field.content);
152
- const schema = (field.content && contentTypes && contentTypes.length > 0
153
- ? field.content[contentTypes[0]].schema
154
- : field.schema);
155
- return (_jsx(FieldSet, { name: field.name, fieldName: fieldName, field: schema }, fieldName));
156
- }) }, type));
157
- });
158
- }, [parameters, renderParameterField]);
159
- return (_jsxs(_Fragment, { children: [panels, body && (_jsx(CollapsiblePanel, { title: "Body", children: renderBodyField ? (renderBodyField('body', body)) : (_jsx(BodyInput, { field: body.schema })) }))] }));
190
+ const ParamTypes = [
191
+ "path",
192
+ "header",
193
+ "cookie",
194
+ "query"
195
+ ];
196
+ function FormBody({ parameters = [], body }) {
197
+ const { renderParameterField, renderBodyField } = useApiContext().client.playground ?? {};
198
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [useMemo(() => {
199
+ return ParamTypes.map((type) => {
200
+ const items = parameters.filter((v) => v.in === type);
201
+ if (items.length === 0) return;
202
+ return /* @__PURE__ */ jsx(CollapsiblePanel, {
203
+ title: {
204
+ header: "Header",
205
+ cookie: "Cookies",
206
+ query: "Query",
207
+ path: "Path"
208
+ }[type],
209
+ children: items.map((field) => {
210
+ const fieldName = `${type}.${field.name}`;
211
+ if (renderParameterField) return renderParameterField(fieldName, field);
212
+ const contentTypes = field.content && Object.keys(field.content);
213
+ const schema = field.content && contentTypes && contentTypes.length > 0 ? field.content[contentTypes[0]].schema : field.schema;
214
+ return /* @__PURE__ */ jsx(FieldSet, {
215
+ name: field.name,
216
+ fieldName,
217
+ field: schema
218
+ }, fieldName);
219
+ })
220
+ }, type);
221
+ });
222
+ }, [parameters, renderParameterField]), body && /* @__PURE__ */ jsx(CollapsiblePanel, {
223
+ title: "Body",
224
+ children: renderBodyField ? renderBodyField("body", body) : /* @__PURE__ */ jsx(BodyInput, { field: body.schema })
225
+ })] });
160
226
  }
161
227
  function BodyInput({ field: _field }) {
162
- const field = useResolvedSchema(_field);
163
- const [isJson, setIsJson] = useState(false);
164
- if (field.format === 'binary')
165
- return _jsx(FieldSet, { field: field, fieldName: "body" });
166
- if (isJson)
167
- return (_jsxs(_Fragment, { children: [_jsx("button", { className: cn(buttonVariants({
168
- color: 'secondary',
169
- size: 'sm',
170
- className: 'w-fit font-mono p-2',
171
- })), onClick: () => setIsJson(false), type: "button", children: "Close JSON Editor" }), _jsx(JsonInput, { fieldName: "body" })] }));
172
- return (_jsx(FieldSet, { field: field, fieldName: "body", collapsible: false, name: _jsx("button", { type: "button", className: cn(buttonVariants({
173
- color: 'secondary',
174
- size: 'sm',
175
- className: 'p-2',
176
- })), onClick: () => setIsJson(true), children: "Open JSON Editor" }) }));
228
+ const field = useResolvedSchema(_field);
229
+ const [isJson, setIsJson] = useState(false);
230
+ if (field.format === "binary") return /* @__PURE__ */ jsx(FieldSet, {
231
+ field,
232
+ fieldName: "body"
233
+ });
234
+ if (isJson) return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
235
+ className: cn(buttonVariants({
236
+ color: "secondary",
237
+ size: "sm",
238
+ className: "w-fit font-mono p-2"
239
+ })),
240
+ onClick: () => setIsJson(false),
241
+ type: "button",
242
+ children: "Close JSON Editor"
243
+ }), /* @__PURE__ */ jsx(JsonInput, { fieldName: "body" })] });
244
+ return /* @__PURE__ */ jsx(FieldSet, {
245
+ field,
246
+ fieldName: "body",
247
+ collapsible: false,
248
+ name: /* @__PURE__ */ jsx("button", {
249
+ type: "button",
250
+ className: cn(buttonVariants({
251
+ color: "secondary",
252
+ size: "sm",
253
+ className: "p-2"
254
+ })),
255
+ onClick: () => setIsJson(true),
256
+ children: "Open JSON Editor"
257
+ })
258
+ });
177
259
  }
178
260
  function useAuthInputs(securities, transform) {
179
- const storageKeys = useStorageKey();
180
- const inputs = useMemo(() => {
181
- const result = [];
182
- if (!securities)
183
- return result;
184
- for (const security of securities) {
185
- if (security.type === 'http' && security.scheme === 'basic') {
186
- const fieldName = `header.Authorization`;
187
- result.push({
188
- fieldName,
189
- original: security,
190
- defaultValue: {
191
- username: '',
192
- password: '',
193
- },
194
- mapOutput(out) {
195
- if (out && typeof out === 'object') {
196
- return `Basic ${btoa(`${'username' in out ? out.username : ''}:${'password' in out ? out.password : ''}`)}`;
197
- }
198
- return out;
199
- },
200
- children: (_jsx(ObjectInput, { field: {
201
- type: 'object',
202
- properties: {
203
- username: {
204
- type: 'string',
205
- },
206
- password: {
207
- type: 'string',
208
- },
209
- },
210
- required: ['username', 'password'],
211
- }, fieldName: fieldName })),
212
- });
213
- }
214
- else if (security.type === 'oauth2') {
215
- const fieldName = 'header.Authorization';
216
- result.push({
217
- fieldName: fieldName,
218
- original: security,
219
- defaultValue: 'Bearer ',
220
- children: (_jsxs("fieldset", { className: "flex flex-col gap-2", children: [_jsx("label", { htmlFor: fieldName, className: cn(labelVariants()), children: "Access Token" }), _jsxs("div", { className: "flex gap-2", children: [_jsx(FieldInput, { fieldName: fieldName, isRequired: true, field: {
221
- type: 'string',
222
- }, className: "flex-1" }), _jsx(OauthDialogTrigger, { type: "button", className: cn(buttonVariants({
223
- size: 'sm',
224
- color: 'secondary',
225
- })), children: "Authorize" })] })] })),
226
- });
227
- }
228
- else if (security.type === 'http') {
229
- const fieldName = 'header.Authorization';
230
- result.push({
231
- fieldName: fieldName,
232
- original: security,
233
- defaultValue: 'Bearer ',
234
- children: (_jsx(FieldSet, { name: "Authorization (header)", fieldName: fieldName, isRequired: true, field: {
235
- type: 'string',
236
- } })),
237
- });
238
- }
239
- else if (security.type === 'apiKey') {
240
- const fieldName = `${security.in}.${security.name}`;
241
- result.push({
242
- fieldName,
243
- defaultValue: '',
244
- original: security,
245
- children: (_jsx(FieldSet, { fieldName: fieldName, name: `${security.name} (${security.in})`, isRequired: true, field: {
246
- type: 'string',
247
- } })),
248
- });
249
- }
250
- else {
251
- const fieldName = 'header.Authorization';
252
- result.push({
253
- fieldName,
254
- defaultValue: '',
255
- original: security,
256
- children: (_jsxs(_Fragment, { children: [_jsx(FieldSet, { name: "Authorization (header)", isRequired: true, fieldName: fieldName, field: {
257
- type: 'string',
258
- } }), _jsx("p", { className: "text-fd-muted-foreground text-xs", children: "OpenID Connect is not supported at the moment, you can still set an access token here." })] })),
259
- });
260
- }
261
- }
262
- return transform ? transform(result) : result;
263
- }, [securities, transform]);
264
- const mapInputs = (values) => {
265
- const cloned = structuredClone(values);
266
- for (const item of inputs) {
267
- if (!item.mapOutput)
268
- continue;
269
- set(cloned, item.fieldName, item.mapOutput(get(cloned, item.fieldName)));
270
- }
271
- return cloned;
272
- };
273
- const initAuthValues = (values) => {
274
- for (const item of inputs) {
275
- const stored = localStorage.getItem(storageKeys.AuthField(item));
276
- if (stored) {
277
- const parsed = JSON.parse(stored);
278
- if (typeof parsed === typeof item.defaultValue) {
279
- set(values, item.fieldName, parsed);
280
- continue;
281
- }
282
- }
283
- set(values, item.fieldName, item.defaultValue);
284
- }
285
- return values;
286
- };
287
- return { inputs, mapInputs, initAuthValues };
261
+ const storageKeys = useStorageKey();
262
+ const inputs = useMemo(() => {
263
+ const result = [];
264
+ if (!securities) return result;
265
+ for (const security of securities) if (security.type === "http" && security.scheme === "basic") {
266
+ const fieldName = `header.Authorization`;
267
+ result.push({
268
+ fieldName,
269
+ original: security,
270
+ defaultValue: {
271
+ username: "",
272
+ password: ""
273
+ },
274
+ mapOutput(out) {
275
+ if (out && typeof out === "object") return `Basic ${btoa(`${"username" in out ? out.username : ""}:${"password" in out ? out.password : ""}`)}`;
276
+ return out;
277
+ },
278
+ children: /* @__PURE__ */ jsx(ObjectInput, {
279
+ field: {
280
+ type: "object",
281
+ properties: {
282
+ username: { type: "string" },
283
+ password: { type: "string" }
284
+ },
285
+ required: ["username", "password"]
286
+ },
287
+ fieldName
288
+ })
289
+ });
290
+ } else if (security.type === "oauth2") {
291
+ const fieldName = "header.Authorization";
292
+ result.push({
293
+ fieldName,
294
+ original: security,
295
+ defaultValue: "Bearer ",
296
+ children: /* @__PURE__ */ jsxs("fieldset", {
297
+ className: "flex flex-col gap-2",
298
+ children: [/* @__PURE__ */ jsx("label", {
299
+ htmlFor: fieldName,
300
+ className: cn(labelVariants()),
301
+ children: "Access Token"
302
+ }), /* @__PURE__ */ jsxs("div", {
303
+ className: "flex gap-2",
304
+ children: [/* @__PURE__ */ jsx(FieldInput, {
305
+ fieldName,
306
+ isRequired: true,
307
+ field: { type: "string" },
308
+ className: "flex-1"
309
+ }), /* @__PURE__ */ jsx(OauthDialogTrigger, {
310
+ type: "button",
311
+ className: cn(buttonVariants({
312
+ size: "sm",
313
+ color: "secondary"
314
+ })),
315
+ children: "Authorize"
316
+ })]
317
+ })]
318
+ })
319
+ });
320
+ } else if (security.type === "http") {
321
+ const fieldName = "header.Authorization";
322
+ result.push({
323
+ fieldName,
324
+ original: security,
325
+ defaultValue: "Bearer ",
326
+ children: /* @__PURE__ */ jsx(FieldSet, {
327
+ name: "Authorization (header)",
328
+ fieldName,
329
+ isRequired: true,
330
+ field: { type: "string" }
331
+ })
332
+ });
333
+ } else if (security.type === "apiKey") {
334
+ const fieldName = `${security.in}.${security.name}`;
335
+ result.push({
336
+ fieldName,
337
+ defaultValue: "",
338
+ original: security,
339
+ children: /* @__PURE__ */ jsx(FieldSet, {
340
+ fieldName,
341
+ name: `${security.name} (${security.in})`,
342
+ isRequired: true,
343
+ field: { type: "string" }
344
+ })
345
+ });
346
+ } else {
347
+ const fieldName = "header.Authorization";
348
+ result.push({
349
+ fieldName,
350
+ defaultValue: "",
351
+ original: security,
352
+ children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(FieldSet, {
353
+ name: "Authorization (header)",
354
+ isRequired: true,
355
+ fieldName,
356
+ field: { type: "string" }
357
+ }), /* @__PURE__ */ jsx("p", {
358
+ className: "text-fd-muted-foreground text-xs",
359
+ children: "OpenID Connect is not supported at the moment, you can still set an access token here."
360
+ })] })
361
+ });
362
+ }
363
+ return transform ? transform(result) : result;
364
+ }, [securities, transform]);
365
+ const mapInputs = (values) => {
366
+ const cloned = structuredClone(values);
367
+ for (const item of inputs) {
368
+ if (!item.mapOutput) continue;
369
+ set(cloned, item.fieldName, item.mapOutput(get(cloned, item.fieldName)));
370
+ }
371
+ return cloned;
372
+ };
373
+ const initAuthValues = (values) => {
374
+ for (const item of inputs) {
375
+ const stored = localStorage.getItem(storageKeys.AuthField(item));
376
+ if (stored) {
377
+ const parsed = JSON.parse(stored);
378
+ if (typeof parsed === typeof item.defaultValue) {
379
+ set(values, item.fieldName, parsed);
380
+ continue;
381
+ }
382
+ }
383
+ set(values, item.fieldName, item.defaultValue);
384
+ }
385
+ return values;
386
+ };
387
+ return {
388
+ inputs,
389
+ mapInputs,
390
+ initAuthValues
391
+ };
288
392
  }
289
393
  function Route({ route, ...props }) {
290
- return (_jsx("div", { ...props, className: cn('flex flex-row items-center gap-0.5 overflow-auto text-nowrap', props.className), children: route.split('/').map((part, index) => (_jsxs(Fragment, { children: [index > 0 && _jsx("span", { className: "text-fd-muted-foreground", children: "/" }), part.startsWith('{') && part.endsWith('}') ? (_jsx("code", { className: "bg-fd-primary/10 text-fd-primary", children: part })) : (_jsx("code", { className: "text-fd-foreground", children: part }))] }, index))) }));
394
+ return /* @__PURE__ */ jsx("div", {
395
+ ...props,
396
+ className: cn("flex flex-row items-center gap-0.5 overflow-auto text-nowrap", props.className),
397
+ children: route.split("/").map((part, index) => /* @__PURE__ */ jsxs(Fragment, { children: [index > 0 && /* @__PURE__ */ jsx("span", {
398
+ className: "text-fd-muted-foreground",
399
+ children: "/"
400
+ }), part.startsWith("{") && part.endsWith("}") ? /* @__PURE__ */ jsx("code", {
401
+ className: "bg-fd-primary/10 text-fd-primary",
402
+ children: part
403
+ }) : /* @__PURE__ */ jsx("code", {
404
+ className: "text-fd-foreground",
405
+ children: part
406
+ })] }, index))
407
+ });
291
408
  }
292
- function DefaultResultDisplay({ data, reset, }) {
293
- const statusInfo = useMemo(() => getStatusInfo(data.status), [data.status]);
294
- const { shikiOptions } = useApiContext();
295
- return (_jsxs("div", { className: "flex flex-col gap-3 p-3", children: [_jsxs("div", { className: "flex justify-between items-center", children: [_jsxs("div", { className: "inline-flex items-center gap-1.5 text-sm font-medium text-fd-foreground", children: [_jsx(statusInfo.icon, { className: cn('size-4', statusInfo.color) }), statusInfo.description] }), _jsx("button", { type: "button", className: cn(buttonVariants({ size: 'icon-xs' }), 'p-0 text-fd-muted-foreground hover:text-fd-accent-foreground [&_svg]:size-3.5'), onClick: () => reset(), "aria-label": "Dismiss response", children: _jsx(X, {}) })] }), _jsx("p", { className: "text-sm text-fd-muted-foreground", children: data.status }), data.data !== undefined && (_jsx(DynamicCodeBlock, { lang: typeof data.data === 'string' && data.data.length > 50000
296
- ? 'text'
297
- : data.type, code: typeof data.data === 'string'
298
- ? data.data
299
- : JSON.stringify(data.data, null, 2), options: shikiOptions }))] }));
409
+ function DefaultResultDisplay({ data, reset }) {
410
+ const statusInfo = useMemo(() => getStatusInfo(data.status), [data.status]);
411
+ const { shikiOptions } = useApiContext();
412
+ return /* @__PURE__ */ jsxs("div", {
413
+ className: "flex flex-col gap-3 p-3",
414
+ children: [
415
+ /* @__PURE__ */ jsxs("div", {
416
+ className: "flex justify-between items-center",
417
+ children: [/* @__PURE__ */ jsxs("div", {
418
+ className: "inline-flex items-center gap-1.5 text-sm font-medium text-fd-foreground",
419
+ children: [/* @__PURE__ */ jsx(statusInfo.icon, { className: cn("size-4", statusInfo.color) }), statusInfo.description]
420
+ }), /* @__PURE__ */ jsx("button", {
421
+ type: "button",
422
+ className: cn(buttonVariants({ size: "icon-xs" }), "p-0 text-fd-muted-foreground hover:text-fd-accent-foreground [&_svg]:size-3.5"),
423
+ onClick: () => reset(),
424
+ "aria-label": "Dismiss response",
425
+ children: /* @__PURE__ */ jsx(X, {})
426
+ })]
427
+ }),
428
+ /* @__PURE__ */ jsx("p", {
429
+ className: "text-sm text-fd-muted-foreground",
430
+ children: data.status
431
+ }),
432
+ data.data !== void 0 && /* @__PURE__ */ jsx(DynamicCodeBlock, {
433
+ lang: typeof data.data === "string" && data.data.length > 5e4 ? "text" : data.type,
434
+ code: typeof data.data === "string" ? data.data : JSON.stringify(data.data, null, 2),
435
+ options: shikiOptions
436
+ })
437
+ ]
438
+ });
300
439
  }
301
440
  function CollapsiblePanel({ title, children, ...props }) {
302
- return (_jsxs(Collapsible, { ...props, className: "border-b last:border-b-0", children: [_jsxs(CollapsibleTrigger, { className: "group w-full flex items-center gap-2 p-3 text-sm font-medium", children: [title, _jsx(ChevronDown, { className: "ms-auto size-3.5 text-fd-muted-foreground group-data-[state=open]:rotate-180" })] }), _jsx(CollapsibleContent, { children: _jsx("div", { className: "flex flex-col gap-3 p-3 pt-1", children: children }) })] }));
441
+ return /* @__PURE__ */ jsxs(Collapsible, {
442
+ ...props,
443
+ className: "border-b last:border-b-0",
444
+ children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
445
+ className: "group w-full flex items-center gap-2 p-3 text-sm font-medium",
446
+ children: [title, /* @__PURE__ */ jsx(ChevronDown, { className: "ms-auto size-3.5 text-fd-muted-foreground group-data-[state=open]:rotate-180" })]
447
+ }), /* @__PURE__ */ jsx(CollapsibleContent, { children: /* @__PURE__ */ jsx("div", {
448
+ className: "flex flex-col gap-3 p-3 pt-1",
449
+ children
450
+ }) })]
451
+ });
303
452
  }
304
- // exports for customisations
305
- export const Custom = {
306
- useController(props) {
307
- return useController(props);
308
- },
309
- };
453
+ const Custom = { useController(props) {
454
+ return useController(props);
455
+ } };
456
+
457
+ //#endregion
458
+ export { Custom, PlaygroundClient as default };
459
+ //# sourceMappingURL=client.js.map