fumadocs-openapi 10.5.0 → 10.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +33 -21
- package/dist/generate-file.d.ts +10 -2
- package/dist/generate-file.d.ts.map +1 -1
- package/dist/generate-file.js +15 -3
- package/dist/generate-file.js.map +1 -1
- package/dist/playground/client.d.ts +32 -10
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +70 -60
- package/dist/playground/client.js.map +1 -1
- package/dist/playground/components/inputs.js +1 -1
- package/dist/playground/components/inputs.js.map +1 -1
- package/dist/playground/components/server-select.js +3 -4
- package/dist/playground/components/server-select.js.map +1 -1
- package/dist/playground/fetcher.d.ts +20 -1
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +28 -24
- package/dist/playground/fetcher.js.map +1 -1
- package/dist/playground/index.d.ts +3 -3
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +2 -2
- package/dist/playground/index.js.map +1 -1
- package/dist/playground/schema.d.ts +1 -0
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +10 -12
- package/dist/playground/schema.js.map +1 -1
- package/dist/requests/generators/python.d.ts +2 -1
- package/dist/requests/generators/python.d.ts.map +1 -1
- package/dist/requests/generators/python.js +13 -2
- package/dist/requests/generators/python.js.map +1 -1
- package/dist/scalar/index.d.ts +2 -1
- package/dist/scalar/index.d.ts.map +1 -1
- package/dist/server/create.d.ts +2 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/create.js +11 -8
- package/dist/server/create.js.map +1 -1
- package/dist/server/proxy.d.ts +5 -2
- package/dist/server/proxy.d.ts.map +1 -1
- package/dist/server/proxy.js +41 -31
- package/dist/server/proxy.js.map +1 -1
- package/dist/server/source-api.d.ts +2 -0
- package/dist/server/source-api.d.ts.map +1 -1
- package/dist/server/source-api.js +10 -1
- package/dist/server/source-api.js.map +1 -1
- package/dist/types.d.ts +2 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/api-page.d.ts +1 -3
- package/dist/ui/api-page.d.ts.map +1 -1
- package/dist/ui/api-page.js +4 -6
- package/dist/ui/api-page.js.map +1 -1
- package/dist/ui/base.d.ts +20 -16
- package/dist/ui/base.d.ts.map +1 -1
- package/dist/ui/base.js +18 -9
- package/dist/ui/base.js.map +1 -1
- package/dist/ui/{full.client.js → client/full.js} +3 -3
- package/dist/ui/client/full.js.map +1 -0
- package/dist/ui/client/index.d.ts +1 -1
- package/dist/ui/client/index.js.map +1 -1
- package/dist/ui/client/storage-key.js.map +1 -1
- package/dist/ui/components/codeblock.d.ts +2 -2
- package/dist/ui/components/codeblock.d.ts.map +1 -1
- package/dist/ui/components/server-tab.js +43 -0
- package/dist/ui/components/server-tab.js.map +1 -0
- package/dist/ui/contexts/api.js +18 -35
- package/dist/ui/contexts/api.js.map +1 -1
- package/dist/ui/create-client.d.ts +26 -0
- package/dist/ui/create-client.d.ts.map +1 -0
- package/dist/ui/create-client.js +132 -0
- package/dist/ui/create-client.js.map +1 -0
- package/dist/ui/index.d.ts +10 -2
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +21 -1
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/operation/client.js +44 -36
- package/dist/ui/operation/client.js.map +1 -1
- package/dist/ui/operation/{request-tabs.d.ts → get-example-requests.d.ts} +2 -4
- package/dist/ui/operation/get-example-requests.d.ts.map +1 -0
- package/dist/ui/operation/get-example-requests.js +83 -0
- package/dist/ui/operation/get-example-requests.js.map +1 -0
- package/dist/ui/operation/index.js +101 -63
- package/dist/ui/operation/index.js.map +1 -1
- package/dist/ui/operation/request-tabs.js +3 -81
- package/dist/ui/operation/request-tabs.js.map +1 -1
- package/dist/ui/operation/response-tabs.d.ts +1 -1
- package/dist/ui/operation/response-tabs.js +57 -54
- package/dist/ui/operation/response-tabs.js.map +1 -1
- package/dist/ui/operation/usage-tabs/client.js +7 -48
- package/dist/ui/operation/usage-tabs/client.js.map +1 -1
- package/dist/ui/operation/usage-tabs/index.js +14 -10
- package/dist/ui/operation/usage-tabs/index.js.map +1 -1
- package/dist/ui/operation/usage-tabs/lazy.js +1 -2
- package/dist/ui/operation/usage-tabs/lazy.js.map +1 -1
- package/dist/ui/schema/client.d.ts +0 -1
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/index.d.ts +1 -2
- package/dist/ui/schema/index.d.ts.map +1 -1
- package/dist/ui/schema/index.js +4 -2
- package/dist/ui/schema/index.js.map +1 -1
- package/dist/utils/pages/builder.d.ts +1 -1
- package/dist/utils/pages/builder.js +1 -1
- package/dist/utils/process-document.d.ts +1 -1
- package/dist/utils/process-document.js +1 -32
- package/dist/utils/process-document.js.map +1 -1
- package/dist/utils/schema/dereference.js +37 -0
- package/dist/utils/schema/dereference.js.map +1 -0
- package/dist/utils/{schema.d.ts → schema/index.d.ts} +3 -3
- package/dist/utils/schema/index.d.ts.map +1 -0
- package/dist/utils/{schema.js → schema/index.js} +3 -3
- package/dist/utils/schema/index.js.map +1 -0
- package/dist/utils/schema/resolve-ref.js +21 -0
- package/dist/utils/schema/resolve-ref.js.map +1 -0
- package/dist/utils/{schema-to-string.js → schema/to-string.js} +2 -2
- package/dist/utils/schema/to-string.js.map +1 -0
- package/package.json +10 -10
- package/dist/requests/to-python-object.js +0 -17
- package/dist/requests/to-python-object.js.map +0 -1
- package/dist/ui/full.client.js.map +0 -1
- package/dist/ui/full.d.ts +0 -11
- package/dist/ui/full.d.ts.map +0 -1
- package/dist/ui/full.js +0 -36
- package/dist/ui/full.js.map +0 -1
- package/dist/ui/operation/request-tabs.d.ts.map +0 -1
- package/dist/utils/schema-to-string.js.map +0 -1
- package/dist/utils/schema.d.ts.map +0 -1
- package/dist/utils/schema.js.map +0 -1
- /package/dist/utils/{schema-to-string.d.ts → schema/to-string.d.ts} +0 -0
package/css/generated/shared.css
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
@source inline("basic");
|
|
85
85
|
@source inline("be");
|
|
86
86
|
@source inline("because");
|
|
87
|
+
@source inline("before");
|
|
87
88
|
@source inline("between");
|
|
88
89
|
@source inline("bg-black/30");
|
|
89
90
|
@source inline("bg-fd-background/50");
|
|
@@ -108,6 +109,7 @@
|
|
|
108
109
|
@source inline("border-x");
|
|
109
110
|
@source inline("border-y");
|
|
110
111
|
@source inline("both");
|
|
112
|
+
@source inline("bundled");
|
|
111
113
|
@source inline("but");
|
|
112
114
|
@source inline("button");
|
|
113
115
|
@source inline("buttonVariants");
|
|
@@ -139,6 +141,7 @@
|
|
|
139
141
|
@source inline("cloned");
|
|
140
142
|
@source inline("cn");
|
|
141
143
|
@source inline("code");
|
|
144
|
+
@source inline("codeProps");
|
|
142
145
|
@source inline("codeUsages");
|
|
143
146
|
@source inline("codegen");
|
|
144
147
|
@source inline("codegens");
|
|
@@ -168,6 +171,7 @@
|
|
|
168
171
|
@source inline("createContext");
|
|
169
172
|
@source inline("createMethod");
|
|
170
173
|
@source inline("createRehypeCode");
|
|
174
|
+
@source inline("credentials");
|
|
171
175
|
@source inline("css");
|
|
172
176
|
@source inline("ctx");
|
|
173
177
|
@source inline("current");
|
|
@@ -195,10 +199,11 @@
|
|
|
195
199
|
@source inline("data-collapsible");
|
|
196
200
|
@source inline("data-object-search-input");
|
|
197
201
|
@source inline("data-placeholder:text-fd-muted-foreground");
|
|
202
|
+
@source inline("data-type");
|
|
198
203
|
@source inline("dataEngine");
|
|
199
204
|
@source inline("declare");
|
|
200
205
|
@source inline("default");
|
|
201
|
-
@source inline("
|
|
206
|
+
@source inline("defaultAdapters");
|
|
202
207
|
@source inline("defaultColor");
|
|
203
208
|
@source inline("defaultExampleId");
|
|
204
209
|
@source inline("defaultItem");
|
|
@@ -210,12 +215,13 @@
|
|
|
210
215
|
@source inline("definitions");
|
|
211
216
|
@source inline("deprecated");
|
|
212
217
|
@source inline("depth");
|
|
218
|
+
@source inline("dereferenceMap");
|
|
219
|
+
@source inline("dereferenceSync");
|
|
213
220
|
@source inline("dereferenced");
|
|
214
221
|
@source inline("description");
|
|
215
222
|
@source inline("descriptionNode");
|
|
216
223
|
@source inline("development");
|
|
217
224
|
@source inline("deviceAuthorization");
|
|
218
|
-
@source inline("directive");
|
|
219
225
|
@source inline("disable");
|
|
220
226
|
@source inline("disabled");
|
|
221
227
|
@source inline("disabled:cursor-not-allowed");
|
|
@@ -227,13 +233,13 @@
|
|
|
227
233
|
@source inline("divide-fd-border");
|
|
228
234
|
@source inline("divide-y");
|
|
229
235
|
@source inline("document");
|
|
236
|
+
@source inline("doesn");
|
|
230
237
|
@source inline("domain");
|
|
231
238
|
@source inline("duplicated");
|
|
232
239
|
@source inline("duration-200");
|
|
233
240
|
@source inline("dynamic");
|
|
234
241
|
@source inline("e");
|
|
235
242
|
@source inline("each");
|
|
236
|
-
@source inline("either");
|
|
237
243
|
@source inline("element");
|
|
238
244
|
@source inline("else");
|
|
239
245
|
@source inline("empty");
|
|
@@ -255,17 +261,18 @@
|
|
|
255
261
|
@source inline("eslint-disable-next-line");
|
|
256
262
|
@source inline("example");
|
|
257
263
|
@source inline("exampleId");
|
|
264
|
+
@source inline("exampleRequests");
|
|
258
265
|
@source inline("examples");
|
|
259
266
|
@source inline("exclusiveMax");
|
|
260
267
|
@source inline("exclusiveMin");
|
|
261
268
|
@source inline("expand");
|
|
262
269
|
@source inline("export");
|
|
263
270
|
@source inline("extends");
|
|
264
|
-
@source inline("extra");
|
|
265
271
|
@source inline("factory");
|
|
266
272
|
@source inline("fallback");
|
|
267
273
|
@source inline("false");
|
|
268
274
|
@source inline("fetch");
|
|
275
|
+
@source inline("fetchOptions");
|
|
269
276
|
@source inline("fetcher");
|
|
270
277
|
@source inline("fetchingToken");
|
|
271
278
|
@source inline("field");
|
|
@@ -338,11 +345,13 @@
|
|
|
338
345
|
@source inline("generate");
|
|
339
346
|
@source inline("generateDefault");
|
|
340
347
|
@source inline("generateTypeScriptDefinitions");
|
|
348
|
+
@source inline("generateTypeScriptSchema");
|
|
341
349
|
@source inline("generated");
|
|
342
350
|
@source inline("generated/defined");
|
|
343
|
-
@source inline("generator");
|
|
344
351
|
@source inline("generators");
|
|
345
352
|
@source inline("getAPIPageProps");
|
|
353
|
+
@source inline("getClientAPIPageProps");
|
|
354
|
+
@source inline("getExampleRequests");
|
|
346
355
|
@source inline("getSchema");
|
|
347
356
|
@source inline("getSchemaId");
|
|
348
357
|
@source inline("getStatusInfo");
|
|
@@ -393,9 +402,9 @@
|
|
|
393
402
|
@source inline("idx");
|
|
394
403
|
@source inline("if");
|
|
395
404
|
@source inline("ignore");
|
|
405
|
+
@source inline("img");
|
|
396
406
|
@source inline("implicit");
|
|
397
407
|
@source inline("import");
|
|
398
|
-
@source inline("imported");
|
|
399
408
|
@source inline("imports");
|
|
400
409
|
@source inline("in");
|
|
401
410
|
@source inline("include");
|
|
@@ -434,6 +443,7 @@
|
|
|
434
443
|
@source inline("j");
|
|
435
444
|
@source inline("json");
|
|
436
445
|
@source inline("json-schema-typed");
|
|
446
|
+
@source inline("json-schema-typed/draft-2020-12");
|
|
437
447
|
@source inline("justify-between");
|
|
438
448
|
@source inline("justify-center");
|
|
439
449
|
@source inline("k");
|
|
@@ -444,7 +454,6 @@
|
|
|
444
454
|
@source inline("labelVariants");
|
|
445
455
|
@source inline("lang");
|
|
446
456
|
@source inline("langs");
|
|
447
|
-
@source inline("language");
|
|
448
457
|
@source inline("last");
|
|
449
458
|
@source inline("last:border-b");
|
|
450
459
|
@source inline("last:border-b-0");
|
|
@@ -473,15 +482,18 @@
|
|
|
473
482
|
@source inline("max-w-[600px]");
|
|
474
483
|
@source inline("max-w-full");
|
|
475
484
|
@source inline("max-w-lg");
|
|
485
|
+
@source inline("may");
|
|
476
486
|
@source inline("mb-2");
|
|
477
487
|
@source inline("mb-4");
|
|
478
488
|
@source inline("md");
|
|
489
|
+
@source inline("mdxComponents");
|
|
479
490
|
@source inline("me-auto");
|
|
480
491
|
@source inline("media");
|
|
481
492
|
@source inline("mediaAdapters");
|
|
482
493
|
@source inline("mediaType");
|
|
483
494
|
@source inline("merge");
|
|
484
495
|
@source inline("mergeAllOf");
|
|
496
|
+
@source inline("merged");
|
|
485
497
|
@source inline("message");
|
|
486
498
|
@source inline("meta");
|
|
487
499
|
@source inline("metaData");
|
|
@@ -521,6 +533,7 @@
|
|
|
521
533
|
@source inline("no-cache");
|
|
522
534
|
@source inline("node");
|
|
523
535
|
@source inline("node:path");
|
|
536
|
+
@source inline("non-RSC");
|
|
524
537
|
@source inline("non-string");
|
|
525
538
|
@source inline("not");
|
|
526
539
|
@source inline("not-last:pb-0");
|
|
@@ -580,7 +593,6 @@
|
|
|
580
593
|
@source inline("page");
|
|
581
594
|
@source inline("pageData");
|
|
582
595
|
@source inline("pages");
|
|
583
|
-
@source inline("panels");
|
|
584
596
|
@source inline("param");
|
|
585
597
|
@source inline("paramTypeKeys");
|
|
586
598
|
@source inline("parameter");
|
|
@@ -596,13 +608,13 @@
|
|
|
596
608
|
@source inline("password");
|
|
597
609
|
@source inline("path");
|
|
598
610
|
@source inline("pathItem");
|
|
599
|
-
@source inline("pathItems");
|
|
600
611
|
@source inline("pathName");
|
|
601
612
|
@source inline("pathNodes");
|
|
602
613
|
@source inline("pathParameters");
|
|
603
614
|
@source inline("paths");
|
|
604
615
|
@source inline("pattern");
|
|
605
616
|
@source inline("patternProperties");
|
|
617
|
+
@source inline("payload");
|
|
606
618
|
@source inline("pb-0");
|
|
607
619
|
@source inline("pb-2");
|
|
608
620
|
@source inline("pe-2");
|
|
@@ -616,7 +628,6 @@
|
|
|
616
628
|
@source inline("placeholder:text-fd-muted-foreground");
|
|
617
629
|
@source inline("placeholders");
|
|
618
630
|
@source inline("playground");
|
|
619
|
-
@source inline("playground/index.tsx");
|
|
620
631
|
@source inline("playgroundEnabled");
|
|
621
632
|
@source inline("playgrounds");
|
|
622
633
|
@source inline("please");
|
|
@@ -624,7 +635,6 @@
|
|
|
624
635
|
@source inline("position");
|
|
625
636
|
@source inline("pre");
|
|
626
637
|
@source inline("prefix");
|
|
627
|
-
@source inline("preprocessed");
|
|
628
638
|
@source inline("prev");
|
|
629
639
|
@source inline("prevProperties");
|
|
630
640
|
@source inline("prevent");
|
|
@@ -633,12 +643,13 @@
|
|
|
633
643
|
@source inline("primitive");
|
|
634
644
|
@source inline("processed");
|
|
635
645
|
@source inline("processor");
|
|
636
|
-
@source inline("programming");
|
|
637
646
|
@source inline("prop");
|
|
638
647
|
@source inline("properties");
|
|
639
648
|
@source inline("property");
|
|
640
649
|
@source inline("props");
|
|
641
650
|
@source inline("prose-no-margin");
|
|
651
|
+
@source inline("proxy");
|
|
652
|
+
@source inline("proxyForwardCookie");
|
|
642
653
|
@source inline("proxyUrl");
|
|
643
654
|
@source inline("ps-2");
|
|
644
655
|
@source inline("ps-4.5");
|
|
@@ -668,6 +679,7 @@
|
|
|
668
679
|
@source inline("react");
|
|
669
680
|
@source inline("react-hook-form");
|
|
670
681
|
@source inline("react-hooks/exhaustive-deps");
|
|
682
|
+
@source inline("react-hooks/rules-of-hooks");
|
|
671
683
|
@source inline("react/jsx-runtime");
|
|
672
684
|
@source inline("read");
|
|
673
685
|
@source inline("readOnly");
|
|
@@ -694,7 +706,6 @@
|
|
|
694
706
|
@source inline("render");
|
|
695
707
|
@source inline("renderAPIExampleLayout");
|
|
696
708
|
@source inline("renderAPIExampleUsageTabs");
|
|
697
|
-
@source inline("renderBodyField");
|
|
698
709
|
@source inline("renderOperationLayout");
|
|
699
710
|
@source inline("renderPageLayout");
|
|
700
711
|
@source inline("renderParameterField");
|
|
@@ -714,17 +725,18 @@
|
|
|
714
725
|
@source inline("request-body");
|
|
715
726
|
@source inline("requestBody");
|
|
716
727
|
@source inline("requestData");
|
|
728
|
+
@source inline("requestInit");
|
|
717
729
|
@source inline("requestTabNameDefault");
|
|
718
730
|
@source inline("requestTimeout");
|
|
731
|
+
@source inline("requestUrl");
|
|
719
732
|
@source inline("requests");
|
|
720
733
|
@source inline("required");
|
|
721
734
|
@source inline("res");
|
|
722
|
-
@source inline("resType");
|
|
723
735
|
@source inline("reset");
|
|
724
736
|
@source inline("resize-none");
|
|
725
|
-
@source inline("resolution");
|
|
726
737
|
@source inline("resolve");
|
|
727
738
|
@source inline("resolveMediaAdapter");
|
|
739
|
+
@source inline("resolveRefSync");
|
|
728
740
|
@source inline("resolveRequestData");
|
|
729
741
|
@source inline("resolved");
|
|
730
742
|
@source inline("resolvedTheme");
|
|
@@ -740,6 +752,7 @@
|
|
|
740
752
|
@source inline("rest");
|
|
741
753
|
@source inline("result");
|
|
742
754
|
@source inline("return");
|
|
755
|
+
@source inline("returned");
|
|
743
756
|
@source inline("root");
|
|
744
757
|
@source inline("rotate-90");
|
|
745
758
|
@source inline("rounded-lg");
|
|
@@ -794,9 +807,9 @@
|
|
|
794
807
|
@source inline("server-side");
|
|
795
808
|
@source inline("server-url");
|
|
796
809
|
@source inline("serverContext");
|
|
797
|
-
@source inline("serverRef");
|
|
798
810
|
@source inline("serverSchema");
|
|
799
811
|
@source inline("servers");
|
|
812
|
+
@source inline("set");
|
|
800
813
|
@source inline("setData");
|
|
801
814
|
@source inline("setError");
|
|
802
815
|
@source inline("setExample");
|
|
@@ -842,6 +855,7 @@
|
|
|
842
855
|
@source inline("slot");
|
|
843
856
|
@source inline("slotType");
|
|
844
857
|
@source inline("slots");
|
|
858
|
+
@source inline("slug");
|
|
845
859
|
@source inline("slugger");
|
|
846
860
|
@source inline("sm");
|
|
847
861
|
@source inline("sm:flex-row");
|
|
@@ -849,7 +863,6 @@
|
|
|
849
863
|
@source inline("sm:justify-end");
|
|
850
864
|
@source inline("sm:text-start");
|
|
851
865
|
@source inline("so");
|
|
852
|
-
@source inline("source");
|
|
853
866
|
@source inline("spec");
|
|
854
867
|
@source inline("specify");
|
|
855
868
|
@source inline("stack");
|
|
@@ -867,6 +880,7 @@
|
|
|
867
880
|
@source inline("step");
|
|
868
881
|
@source inline("stf");
|
|
869
882
|
@source inline("sticky");
|
|
883
|
+
@source inline("storageKey");
|
|
870
884
|
@source inline("storageKeyPrefix");
|
|
871
885
|
@source inline("storageKeys");
|
|
872
886
|
@source inline("store");
|
|
@@ -879,15 +893,14 @@
|
|
|
879
893
|
@source inline("submit");
|
|
880
894
|
@source inline("such");
|
|
881
895
|
@source inline("summary");
|
|
896
|
+
@source inline("support");
|
|
882
897
|
@source inline("supported");
|
|
883
|
-
@source inline("swallow");
|
|
884
898
|
@source inline("switch");
|
|
885
899
|
@source inline("t");
|
|
886
900
|
@source inline("tab");
|
|
887
901
|
@source inline("tabs");
|
|
888
902
|
@source inline("tag");
|
|
889
903
|
@source inline("takenIds");
|
|
890
|
-
@source inline("targetServer");
|
|
891
904
|
@source inline("testQuery");
|
|
892
905
|
@source inline("text");
|
|
893
906
|
@source inline("text-[0.8125rem]");
|
|
@@ -979,18 +992,17 @@
|
|
|
979
992
|
@source inline("useApiClientModal");
|
|
980
993
|
@source inline("useApiContext");
|
|
981
994
|
@source inline("useCopyButton");
|
|
982
|
-
@source inline("useExampleRequests");
|
|
983
995
|
@source inline("useFieldValue");
|
|
984
996
|
@source inline("useForm");
|
|
985
997
|
@source inline("useI18n");
|
|
986
998
|
@source inline("useMemo");
|
|
987
999
|
@source inline("useNamespace");
|
|
988
1000
|
@source inline("useObject");
|
|
1001
|
+
@source inline("useOperationContext");
|
|
989
1002
|
@source inline("useQuery");
|
|
990
1003
|
@source inline("useRef");
|
|
991
1004
|
@source inline("useResolvedSchema");
|
|
992
1005
|
@source inline("useServerContext");
|
|
993
|
-
@source inline("useServerSelectContext");
|
|
994
1006
|
@source inline("useState");
|
|
995
1007
|
@source inline("useStf");
|
|
996
1008
|
@source inline("useStorageKey");
|
package/dist/generate-file.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenAPIServer } from "./server/create.js";
|
|
2
2
|
import { OutputEntry } from "./utils/pages/builder.js";
|
|
3
3
|
import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
|
|
4
|
+
import { DistributiveOmit } from "./types.js";
|
|
4
5
|
import { ProcessedDocument } from "./utils/process-document.js";
|
|
5
6
|
import { PagesToTextOptions } from "./utils/pages/to-text.js";
|
|
6
7
|
|
|
@@ -61,14 +62,21 @@ interface GenerateFilesConfig extends PagesToTextOptions {
|
|
|
61
62
|
interface MetaOptions {
|
|
62
63
|
groupStyle?: 'folder' | 'separator';
|
|
63
64
|
}
|
|
64
|
-
type Config = SchemaToPagesOptions & GenerateFilesConfig
|
|
65
|
+
type Config = SchemaToPagesOptions & GenerateFilesConfig & {
|
|
66
|
+
/**
|
|
67
|
+
* Re-generate when **schema files are changed**, ignores custom input functions & URLs.
|
|
68
|
+
*
|
|
69
|
+
* Note: it is recommended to configure & use `chokidar` on your own, this is only for simple cases.
|
|
70
|
+
*/
|
|
71
|
+
watch?: boolean;
|
|
72
|
+
};
|
|
65
73
|
interface BeforeWriteContext {
|
|
66
74
|
readonly generated: Record<string, OutputFile[]>;
|
|
67
75
|
readonly generatedEntries: Record<string, OutputEntry[]>;
|
|
68
76
|
readonly documents: Record<string, ProcessedDocument>;
|
|
69
77
|
}
|
|
70
78
|
declare function generateFiles(options: Config): Promise<void>;
|
|
71
|
-
declare function generateFilesOnly(options:
|
|
79
|
+
declare function generateFilesOnly(options: DistributiveOmit<Config, 'output'>): Promise<OutputFile[]>;
|
|
72
80
|
//#endregion
|
|
73
81
|
export { Config, OutputFile, generateFiles, generateFilesOnly };
|
|
74
82
|
//# sourceMappingURL=generate-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-file.d.ts","names":[],"sources":["../src/generate-file.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-file.d.ts","names":[],"sources":["../src/generate-file.ts"],"mappings":";;;;;;;;UAUiB,UAAA;EACf,IAAA;EACA,OAAA;AAAA;AAAA,UAGQ,WAAA;EACR,KAAA,EAAO,SAAA,OAAgB,GAAA,EAAK,kBAAA,KAAuB,SAAA;EALnD;;AAED;EAQC,GAAA,IACM,QAAA;IAEA,OAAA;IARC;;;IAYD,UAAA;EAAA;AAAA;AAAA,UAIE,SAAA;EAhBoB;EAkB5B,IAAA;EACA,KAAA;EACA,WAAA;EAdM;;;;;EAqBN,IAAA;AAAA;AAAA,UAGQ,mBAAA,SAA4B,kBAAA;EAdnB;;;EAkBjB,KAAA,EAAO,aAAA;EAPP;;;EAYA,MAAA;EAT4B;;;EAc5B,KAAA,GAAQ,WAAA;EAOS;;;;;EAAjB,IAAA,aAAiB,WAAA;EArBqC;;;EA0BtD,WAAA,IAAe,IAAA,EAAM,kBAAA,EAAoB,KAAA,EAAO,UAAA,cAAwB,OAAA;AAAA;AAAA,UAGhE,WAAA;EACR,UAAA;AAAA;AAAA,KAGU,MAAA,GAAS,oBAAA,GACnB,mBAAA;EARA;;;;;EAcE,KAAA;AAAA;AAAA,UAGM,kBAAA;EAAA,SACC,SAAA,EAAW,MAAA,SAAe,UAAA;EAAA,SAC1B,gBAAA,EAAkB,MAAA,SAAe,WAAA;EAAA,SACjC,SAAA,EAAW,MAAA,SAAe,iBAAA;AAAA;AAAA,iBAGf,aAAA,CAAc,OAAA,EAAS,MAAA,GAAS,OAAA;AAAA,iBA2BhC,iBAAA,CACpB,OAAA,EAAS,gBAAA,CAAiB,MAAA,cACzB,OAAA,CAAQ,UAAA"}
|
package/dist/generate-file.js
CHANGED
|
@@ -6,10 +6,21 @@ import * as path$1 from "node:path";
|
|
|
6
6
|
import { PathUtils, createGetUrl, getSlugs } from "fumadocs-core/source";
|
|
7
7
|
//#region src/generate-file.ts
|
|
8
8
|
async function generateFiles(options) {
|
|
9
|
+
if (options.watch) {
|
|
10
|
+
const { watch } = await import("chokidar");
|
|
11
|
+
const subOptions = {
|
|
12
|
+
...options,
|
|
13
|
+
watch: false
|
|
14
|
+
};
|
|
15
|
+
await generateFiles(subOptions);
|
|
16
|
+
const targets = options.input._getWatchPaths();
|
|
17
|
+
console.log(`[Fumadocs OpenAPI] watching ${targets.join(", ")}`);
|
|
18
|
+
watch(targets, { ignoreInitial: true }).on("all", () => generateFiles(subOptions));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
9
21
|
const files = await generateFilesOnly(options);
|
|
10
|
-
const { output } = options;
|
|
11
22
|
await Promise.all(files.map(async (file) => {
|
|
12
|
-
const filePath = path$1.join(output, file.path);
|
|
23
|
+
const filePath = path$1.join(options.output, file.path);
|
|
13
24
|
await mkdir(path$1.dirname(filePath), { recursive: true });
|
|
14
25
|
await writeFile(filePath, file.content);
|
|
15
26
|
console.log(`Generated: ${filePath}`);
|
|
@@ -25,7 +36,7 @@ async function generateFilesOnly(options) {
|
|
|
25
36
|
const preset = createAutoPreset(options);
|
|
26
37
|
for (const [id, schema] of entries) {
|
|
27
38
|
const entries = fromSchema(id, schema, preset);
|
|
28
|
-
const schemaFiles =
|
|
39
|
+
const schemaFiles = [];
|
|
29
40
|
generatedEntries[id] = entries;
|
|
30
41
|
function scan(entry) {
|
|
31
42
|
if (entry.type === "group") {
|
|
@@ -38,6 +49,7 @@ async function generateFilesOnly(options) {
|
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
51
|
for (const entry of entries) scan(entry);
|
|
52
|
+
generated[id] = schemaFiles;
|
|
41
53
|
files.push(...schemaFiles);
|
|
42
54
|
}
|
|
43
55
|
const context = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-file.js","names":["path"],"sources":["../src/generate-file.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { generateDocument, type PagesToTextOptions, toText } from './utils/pages/to-text';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport type { OpenAPIServer } from '@/server';\nimport { createGetUrl, getSlugs, PathUtils } from 'fumadocs-core/source';\nimport { createAutoPreset, type SchemaToPagesOptions } from '@/utils/pages/preset-auto';\nimport { fromSchema, type OutputGroup, type OutputEntry } from '@/utils/pages/builder';\n\nexport interface OutputFile {\n path: string;\n content: string;\n}\n\ninterface IndexConfig {\n items: IndexItem[] | ((ctx: BeforeWriteContext) => IndexItem[]);\n\n /**\n * Generate URLs for cards\n */\n url:\n | ((filePath: string) => string)\n | {\n baseUrl: string;\n /**\n * Base content directory\n */\n contentDir: string;\n };\n}\n\ninterface IndexItem {\n /** output path of index page */\n path: string;\n title?: string;\n description?: string;\n\n /**\n * Specify linked pages:\n * - items in `inputs` to include all generated pages of a specific schema.\n * - file paths (using forward slash).\n */\n only?: string[];\n}\n\ninterface GenerateFilesConfig extends PagesToTextOptions {\n /**\n * the OpenAPI server object\n */\n input: OpenAPIServer;\n\n /**\n * Output directory\n */\n output: string;\n\n /**\n * Generate index files with cards linking to generated pages.\n */\n index?: IndexConfig;\n\n /**\n * Generate `meta.json` files.\n *\n * Note: for flexibility, it's recommended to define them on your own.\n */\n meta?: boolean | MetaOptions;\n\n /**\n * Can add/change/remove output files before writing to file system\n **/\n beforeWrite?: (this: BeforeWriteContext, files: OutputFile[]) => void | Promise<void>;\n}\n\ninterface MetaOptions {\n groupStyle?: 'folder' | 'separator';\n}\n\nexport type Config = SchemaToPagesOptions & GenerateFilesConfig;\n\ninterface BeforeWriteContext {\n readonly generated: Record<string, OutputFile[]>;\n readonly generatedEntries: Record<string, OutputEntry[]>;\n readonly documents: Record<string, ProcessedDocument>;\n}\n\nexport async function generateFiles(options: Config): Promise<void> {\n const files = await generateFilesOnly(options);\n const { output } = options;\n\n await Promise.all(\n files.map(async (file) => {\n const filePath = path.join(output, file.path);\n\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, file.content);\n console.log(`Generated: ${filePath}`);\n }),\n );\n}\n\nexport async function generateFilesOnly(\n options: SchemaToPagesOptions & Omit<GenerateFilesConfig, 'output'>,\n): Promise<OutputFile[]> {\n const schemas = await options.input.getSchemas();\n\n const files: OutputFile[] = [];\n const generated: Record<string, OutputFile[]> = {};\n const generatedEntries: Record<string, OutputEntry[]> = {};\n\n const entries = Object.entries(schemas);\n if (entries.length === 0) {\n throw new Error('No input files found.');\n }\n const preset = createAutoPreset(options);\n for (const [id, schema] of entries) {\n const entries = fromSchema(id, schema, preset);\n const schemaFiles = (generated[id] ??= []);\n\n generatedEntries[id] = entries;\n function scan(entry: OutputEntry) {\n if (entry.type === 'group') {\n for (const child of entry.entries) scan(child);\n return;\n }\n\n schemaFiles.push({\n path: entry.path,\n content: toText(entry, schema, options),\n });\n }\n\n for (const entry of entries) scan(entry);\n files.push(...schemaFiles);\n }\n\n const context: BeforeWriteContext = {\n generated,\n generatedEntries,\n documents: schemas,\n };\n\n if (options.index) {\n files.push(...writeIndexFiles(context, options));\n }\n\n if (options.meta) {\n files.push(...generateMeta(context, options.meta === true ? {} : options.meta));\n }\n\n await options.beforeWrite?.call(context, files);\n return files;\n}\n\nfunction generateMeta(context: BeforeWriteContext, options: MetaOptions): OutputFile[] {\n const files: OutputFile[] = [];\n const { groupStyle = 'folder' } = options;\n\n function scan(entries: OutputEntry[], parent?: OutputGroup) {\n const pages: string[] = [];\n\n for (const entry of entries) {\n const relativePath = PathUtils.slash(\n parent ? path.relative(parent.path, entry.path) : entry.path,\n );\n\n if (entry.type === 'group') {\n scan(entry.entries, entry);\n\n if (groupStyle === 'folder') {\n pages.push(relativePath);\n } else {\n pages.push(`---${entry.info.title}---`, `...${relativePath}`);\n }\n } else {\n pages.push(relativePath.slice(0, -path.extname(entry.path).length));\n }\n }\n\n if (pages.length === 0) return;\n files.push({\n path: parent ? path.join(parent.path, 'meta.json') : 'meta.json',\n content: JSON.stringify(\n {\n title: parent?.info.title,\n description: parent?.info.description,\n pages,\n },\n null,\n 2,\n ),\n });\n }\n\n for (const entries of Object.values(context.generatedEntries)) {\n scan(entries);\n }\n\n return files;\n}\n\nfunction writeIndexFiles(\n context: BeforeWriteContext,\n options: SchemaToPagesOptions & Omit<GenerateFilesConfig, 'output'>,\n): OutputFile[] {\n const files: OutputFile[] = [];\n const { generatedEntries } = context;\n const pathToEntry = new Map<string, OutputEntry>();\n const { items, url } = options.index!;\n\n function indexEntry(entry: OutputEntry) {\n pathToEntry.set(PathUtils.slash(entry.path), entry);\n if (entry.type === 'group') {\n for (const child of entry.entries) {\n indexEntry(child);\n }\n }\n }\n\n let urlFn: (path: string) => string;\n if (typeof url === 'object') {\n const getUrl = createGetUrl(url.baseUrl);\n\n urlFn = (file) => getUrl(getSlugs(path.relative(url.contentDir, file)));\n } else {\n urlFn = url;\n }\n\n function fileContent(index: IndexItem): string {\n const content: string[] = [];\n content.push('<Cards>');\n const outputEntries: OutputEntry[] = [];\n const only = index.only ?? Object.keys(context.generated);\n\n for (const item of only) {\n if (generatedEntries[item]) {\n for (const entry of generatedEntries[item]) {\n outputEntries.push(entry);\n }\n } else {\n const match = pathToEntry.get(item);\n if (!match) {\n throw new Error(\n `${item} does not exist on \"input\", available: ${Object.keys(generatedEntries).join(', ')}.`,\n );\n }\n\n outputEntries.push(match);\n }\n }\n\n for (const entry of outputEntries) {\n // cannot link to groups\n if (entry.type === 'group') continue;\n const descriptionAttr = entry.info.description\n ? `description=${JSON.stringify(entry.info.description)} `\n : '';\n content.push(\n `<Card href=\"${urlFn(entry.path)}\" title=${JSON.stringify(entry.info.title)} ${descriptionAttr}/>`,\n );\n }\n\n content.push('</Cards>');\n return generateDocument(\n {\n title: index.title ?? 'Overview',\n description: index.description,\n },\n content.join('\\n'),\n options,\n );\n }\n\n for (const list of Object.values(context.generatedEntries)) {\n for (const item of list) indexEntry(item);\n }\n\n for (const item of typeof items === 'function' ? items(context) : items) {\n files.push({\n path: path.extname(item.path).length === 0 ? `${item.path}.mdx` : item.path,\n content: fileContent(item),\n });\n }\n\n return files;\n}\n"],"mappings":";;;;;;;AAsFA,eAAsB,cAAc,SAAgC;CAClE,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;CAC9C,MAAM,EAAE,WAAW;AAEnB,OAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;EACxB,MAAM,WAAWA,OAAK,KAAK,QAAQ,KAAK,KAAK;AAE7C,QAAM,MAA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AE;AAC5B,UAAQ,KAAK,UAAU;EACvB,MAAM,gBAA+B,EAAE;EACvC,MAAM,OAAO,MAAM,QAAQ,OAAO,KAAK,QAAQ,UAAU;AAEzD,OAAK,MAAM,QAAQ,KACjB,KAAI,iBAAiB,MACnB,MAAK,MAAM,SAAS,iBAAiB,MACnC,eAAc,KAAK,MAAM;OAEtB;GACL,MAAM,QAAQ,YAAY,IAAI,KAAK;AACnC,OAAI,CAAC,MACH,OAAM,IAAI,MACR,GAAG,KAAK,yCAAyC,OAAO,KAAK,iBAAiB,CAAC,KAAK,KAAK,CAAC,GAC3F;AAGH,iBAAc,KAAK,MAAM;;AAI7B,OAAK,MAAM,SAAS,eAAe;AAEjC,OAAI,MAAM,SAAS,QAAS;GAC5B,MAAM,kBAAkB,MAAM,KAAK,cAC/B,eAAe,KAAK,UAAU,MAAM,KAAK,YAAY,CAAC,KACtD;AACJ,WAAQ,KACN,eAAe,MAAM,MAAM,KAAK,CAAC,UAAU,KAAK,UAAU,MAAM,KAAK,MAAM,CAAC,GAAG,gBAAgB,IAChG;;AAGH,UAAQ,KAAK,WAAW;AACxB,SAAO,iBACL;GACE,OAAO,MAAM,SAAS;GACtB,aAAa,MAAM;GACpB,EACD,QAAQ,KAAK,KAAK,EAClB,QACD;;AAGH,MAAK,MAAM,QAAQ,OAAO,OAAO,QAAQ,iBAAiB,CACxD,MAAK,MAAM,QAAQ,KAAM,YAAW,KAAK;AAG3C,MAAK,MAAM,QAAQ,OAAO,UAAU,aAAa,MAAM,QAAQ,GAAG,MAChE,OAAM,KAAK;EACT,MAAMA,OAAK,QAAQ,KAAK,KAAK,CAAC,WAAW,IAAI,GAAG,KAAK,KAAK,QAAQ,KAAK;EACvE,SAAS,YAAY,KAAK;EAC3B,CAAC;AAGJ,QAAO"}
|
|
1
|
+
{"version":3,"file":"generate-file.js","names":["path"],"sources":["../src/generate-file.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { generateDocument, type PagesToTextOptions, toText } from './utils/pages/to-text';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport type { OpenAPIServer } from '@/server';\nimport { createGetUrl, getSlugs, PathUtils } from 'fumadocs-core/source';\nimport { createAutoPreset, type SchemaToPagesOptions } from '@/utils/pages/preset-auto';\nimport { fromSchema, type OutputGroup, type OutputEntry } from '@/utils/pages/builder';\nimport type { DistributiveOmit } from './types';\n\nexport interface OutputFile {\n path: string;\n content: string;\n}\n\ninterface IndexConfig {\n items: IndexItem[] | ((ctx: BeforeWriteContext) => IndexItem[]);\n\n /**\n * Generate URLs for cards\n */\n url:\n | ((filePath: string) => string)\n | {\n baseUrl: string;\n /**\n * Base content directory\n */\n contentDir: string;\n };\n}\n\ninterface IndexItem {\n /** output path of index page */\n path: string;\n title?: string;\n description?: string;\n\n /**\n * Specify linked pages:\n * - items in `inputs` to include all generated pages of a specific schema.\n * - file paths (using forward slash).\n */\n only?: string[];\n}\n\ninterface GenerateFilesConfig extends PagesToTextOptions {\n /**\n * the OpenAPI server object\n */\n input: OpenAPIServer;\n\n /**\n * Output directory\n */\n output: string;\n\n /**\n * Generate index files with cards linking to generated pages.\n */\n index?: IndexConfig;\n\n /**\n * Generate `meta.json` files.\n *\n * Note: for flexibility, it's recommended to define them on your own.\n */\n meta?: boolean | MetaOptions;\n\n /**\n * Can add/change/remove output files before writing to file system\n **/\n beforeWrite?: (this: BeforeWriteContext, files: OutputFile[]) => void | Promise<void>;\n}\n\ninterface MetaOptions {\n groupStyle?: 'folder' | 'separator';\n}\n\nexport type Config = SchemaToPagesOptions &\n GenerateFilesConfig & {\n /**\n * Re-generate when **schema files are changed**, ignores custom input functions & URLs.\n *\n * Note: it is recommended to configure & use `chokidar` on your own, this is only for simple cases.\n */\n watch?: boolean;\n };\n\ninterface BeforeWriteContext {\n readonly generated: Record<string, OutputFile[]>;\n readonly generatedEntries: Record<string, OutputEntry[]>;\n readonly documents: Record<string, ProcessedDocument>;\n}\n\nexport async function generateFiles(options: Config): Promise<void> {\n if (options.watch) {\n const { watch } = await import('chokidar');\n const subOptions: Config = { ...options, watch: false };\n\n await generateFiles(subOptions);\n const targets = options.input._getWatchPaths();\n console.log(`[Fumadocs OpenAPI] watching ${targets.join(', ')}`);\n watch(targets, {\n ignoreInitial: true,\n }).on('all', () => generateFiles(subOptions));\n return;\n }\n\n const files = await generateFilesOnly(options);\n\n await Promise.all(\n files.map(async (file) => {\n const filePath = path.join(options.output, file.path);\n\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, file.content);\n console.log(`Generated: ${filePath}`);\n }),\n );\n}\n\nexport async function generateFilesOnly(\n options: DistributiveOmit<Config, 'output'>,\n): Promise<OutputFile[]> {\n const schemas = await options.input.getSchemas();\n\n const files: OutputFile[] = [];\n const generated: Record<string, OutputFile[]> = {};\n const generatedEntries: Record<string, OutputEntry[]> = {};\n\n const entries = Object.entries(schemas);\n if (entries.length === 0) {\n throw new Error('No input files found.');\n }\n const preset = createAutoPreset(options);\n for (const [id, schema] of entries) {\n const entries = fromSchema(id, schema, preset);\n const schemaFiles: OutputFile[] = [];\n\n generatedEntries[id] = entries;\n function scan(entry: OutputEntry) {\n if (entry.type === 'group') {\n for (const child of entry.entries) scan(child);\n return;\n }\n\n schemaFiles.push({\n path: entry.path,\n content: toText(entry, schema, options),\n });\n }\n\n for (const entry of entries) scan(entry);\n generated[id] = schemaFiles;\n files.push(...schemaFiles);\n }\n\n const context: BeforeWriteContext = {\n generated,\n generatedEntries,\n documents: schemas,\n };\n\n if (options.index) {\n files.push(...writeIndexFiles(context, options));\n }\n\n if (options.meta) {\n files.push(...generateMeta(context, options.meta === true ? {} : options.meta));\n }\n\n await options.beforeWrite?.call(context, files);\n return files;\n}\n\nfunction generateMeta(context: BeforeWriteContext, options: MetaOptions): OutputFile[] {\n const files: OutputFile[] = [];\n const { groupStyle = 'folder' } = options;\n\n function scan(entries: OutputEntry[], parent?: OutputGroup) {\n const pages: string[] = [];\n\n for (const entry of entries) {\n const relativePath = PathUtils.slash(\n parent ? path.relative(parent.path, entry.path) : entry.path,\n );\n\n if (entry.type === 'group') {\n scan(entry.entries, entry);\n\n if (groupStyle === 'folder') {\n pages.push(relativePath);\n } else {\n pages.push(`---${entry.info.title}---`, `...${relativePath}`);\n }\n } else {\n pages.push(relativePath.slice(0, -path.extname(entry.path).length));\n }\n }\n\n if (pages.length === 0) return;\n files.push({\n path: parent ? path.join(parent.path, 'meta.json') : 'meta.json',\n content: JSON.stringify(\n {\n title: parent?.info.title,\n description: parent?.info.description,\n pages,\n },\n null,\n 2,\n ),\n });\n }\n\n for (const entries of Object.values(context.generatedEntries)) {\n scan(entries);\n }\n\n return files;\n}\n\nfunction writeIndexFiles(\n context: BeforeWriteContext,\n options: SchemaToPagesOptions & Omit<GenerateFilesConfig, 'output'>,\n): OutputFile[] {\n const files: OutputFile[] = [];\n const { generatedEntries } = context;\n const pathToEntry = new Map<string, OutputEntry>();\n const { items, url } = options.index!;\n\n function indexEntry(entry: OutputEntry) {\n pathToEntry.set(PathUtils.slash(entry.path), entry);\n if (entry.type === 'group') {\n for (const child of entry.entries) {\n indexEntry(child);\n }\n }\n }\n\n let urlFn: (path: string) => string;\n if (typeof url === 'object') {\n const getUrl = createGetUrl(url.baseUrl);\n\n urlFn = (file) => getUrl(getSlugs(path.relative(url.contentDir, file)));\n } else {\n urlFn = url;\n }\n\n function fileContent(index: IndexItem): string {\n const content: string[] = [];\n content.push('<Cards>');\n const outputEntries: OutputEntry[] = [];\n const only = index.only ?? Object.keys(context.generated);\n\n for (const item of only) {\n if (generatedEntries[item]) {\n for (const entry of generatedEntries[item]) {\n outputEntries.push(entry);\n }\n } else {\n const match = pathToEntry.get(item);\n if (!match) {\n throw new Error(\n `${item} does not exist on \"input\", available: ${Object.keys(generatedEntries).join(', ')}.`,\n );\n }\n\n outputEntries.push(match);\n }\n }\n\n for (const entry of outputEntries) {\n // cannot link to groups\n if (entry.type === 'group') continue;\n const descriptionAttr = entry.info.description\n ? `description=${JSON.stringify(entry.info.description)} `\n : '';\n content.push(\n `<Card href=\"${urlFn(entry.path)}\" title=${JSON.stringify(entry.info.title)} ${descriptionAttr}/>`,\n );\n }\n\n content.push('</Cards>');\n return generateDocument(\n {\n title: index.title ?? 'Overview',\n description: index.description,\n },\n content.join('\\n'),\n options,\n );\n }\n\n for (const list of Object.values(context.generatedEntries)) {\n for (const item of list) indexEntry(item);\n }\n\n for (const item of typeof items === 'function' ? items(context) : items) {\n files.push({\n path: path.extname(item.path).length === 0 ? `${item.path}.mdx` : item.path,\n content: fileContent(item),\n });\n }\n\n return files;\n}\n"],"mappings":";;;;;;;AA+FA,eAAsB,cAAc,SAAgC;AAClE,KAAI,QAAQ,OAAO;EACjB,MAAM,EAAE,UAAU,MAAM,OAAO;EAC/B,MAAM,aAAqB;GAAE,GAAG;GAAS,OAAO;GAAO;AAEvD,QAAM,cAAc,WAAW;EAC/B,MAAM,UAAU,QAAQ,MAAM,gBAAgB;AAC9C,UAAQ,IAAI,+BAA+B,QAAQ,KAAK,KAAK,GAAG;AAChE,QAAM,SAAS,EACb,eAAe,MAChB,CAAC,CAAC,GAAG,aAAa,cAAc,WAAW,CAAC;AAC7C;;CAGF,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;AAE9C,OAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;EACxB,MAAM,WAAWA,OAAK,KAAK,QAAQ,QAAQ,KAAK,KAAK;AAErD,QAAM,MAAMA,OAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACxD,QAAM,UAAU,UAAU,KAAK,QAAQ;AACvC,UAAQ,IAAI,cAAc,WAAW;GACrC,CACH;;AAGH,eAAsB,kBACpB,SACuB;CACvB,MAAM,UAAU,MAAM,QAAQ,MAAM,YAAY;CAEhD,MAAM,QAAsB,EAAE;CAC9B,MAAM,YAA0C,EAAE;CAClD,MAAM,mBAAkD,EAAE;CAE1D,MAAM,UAAU,OAAO,QAAQ,QAAQ;AACvC,KAAI,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AK,iBAAiB,CAAC,KAAK,KAAK,CAAC,GAC3F;AAGH,iBAAc,KAAK,MAAM;;AAI7B,OAAK,MAAM,SAAS,eAAe;AAEjC,OAAI,MAAM,SAAS,QAAS;GAC5B,MAAM,kBAAkB,MAAM,KAAK,cAC/B,eAAe,KAAK,UAAU,MAAM,KAAK,YAAY,CAAC,KACtD;AACJ,WAAQ,KACN,eAAe,MAAM,MAAM,KAAK,CAAC,UAAU,KAAK,UAAU,MAAM,KAAK,MAAM,CAAC,GAAG,gBAAgB,IAChG;;AAGH,UAAQ,KAAK,WAAW;AACxB,SAAO,iBACL;GACE,OAAO,MAAM,SAAS;GACtB,aAAa,MAAM;GACpB,EACD,QAAQ,KAAK,KAAK,EAClB,QACD;;AAGH,MAAK,MAAM,QAAQ,OAAO,OAAO,QAAQ,iBAAiB,CACxD,MAAK,MAAM,QAAQ,KAAM,YAAW,KAAK;AAG3C,MAAK,MAAM,QAAQ,OAAO,UAAU,aAAa,MAAM,QAAQ,GAAG,MAChE,OAAM,KAAK;EACT,MAAMA,OAAK,QAAQ,KAAK,KAAK,CAAC,WAAW,IAAI,GAAG,KAAK,KAAK,QAAQ,KAAK;EACvE,SAAS,YAAY,KAAK;EAC3B,CAAC;AAGJ,QAAO"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ParsedSchema } from "../utils/schema.js";
|
|
2
|
-
import { FetchResult } from "./fetcher.js";
|
|
1
|
+
import { ParsedSchema } from "../utils/schema/index.js";
|
|
2
|
+
import { BrowserFetcherOptions, FetchResult } from "./fetcher.js";
|
|
3
3
|
import { SecurityEntry } from "./index.js";
|
|
4
4
|
import { SchemaScope } from "./schema.js";
|
|
5
5
|
import { ParameterObject } from "../types.js";
|
|
6
6
|
import { ComponentProps, FC, ReactNode } from "react";
|
|
7
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
8
|
+
import { Collapsible } from "fumadocs-ui/components/ui/collapsible";
|
|
8
9
|
import { FieldKey } from "@fumari/stf";
|
|
9
10
|
|
|
10
11
|
//#region src/playground/client.d.ts
|
|
@@ -30,20 +31,29 @@ interface PlaygroundClientProps extends ComponentProps<'form'>, SchemaScope {
|
|
|
30
31
|
references: Record<string, ParsedSchema>;
|
|
31
32
|
proxyUrl?: string;
|
|
32
33
|
}
|
|
34
|
+
interface ResultDisplayProps extends ComponentProps<'div'> {
|
|
35
|
+
data: FetchResult;
|
|
36
|
+
reset: () => void;
|
|
37
|
+
}
|
|
38
|
+
interface CollapsiblePanelProps extends Omit<ComponentProps<typeof Collapsible>, 'title'> {
|
|
39
|
+
'data-type': 'authorization' | 'body' | ParamType;
|
|
40
|
+
title: ReactNode;
|
|
41
|
+
}
|
|
33
42
|
interface PlaygroundClientOptions {
|
|
34
43
|
/**
|
|
35
44
|
* transform fields for auth-specific parameters (e.g. header)
|
|
36
45
|
*/
|
|
37
46
|
transformAuthInputs?: (fields: AuthField[]) => AuthField[];
|
|
47
|
+
fetchOptions?: BrowserFetcherOptions;
|
|
38
48
|
/**
|
|
39
49
|
* Request timeout in seconds (default: 10s)
|
|
50
|
+
* @deprecated use `fetchOptions.requestTimeout` instead.
|
|
40
51
|
*/
|
|
41
52
|
requestTimeout?: number;
|
|
42
|
-
components?:
|
|
43
|
-
ResultDisplay
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}>;
|
|
53
|
+
components?: {
|
|
54
|
+
ResultDisplay?: FC<ResultDisplayProps>;
|
|
55
|
+
CollapsiblePanel?: FC<CollapsiblePanelProps>;
|
|
56
|
+
};
|
|
47
57
|
/**
|
|
48
58
|
* render the parameter inputs of API endpoint.
|
|
49
59
|
*
|
|
@@ -74,7 +84,9 @@ declare function PlaygroundClient({
|
|
|
74
84
|
writeOnly,
|
|
75
85
|
readOnly,
|
|
76
86
|
...rest
|
|
77
|
-
}: PlaygroundClientProps): react_jsx_runtime0.JSX.Element;
|
|
87
|
+
}: PlaygroundClientProps): _$react_jsx_runtime0.JSX.Element;
|
|
88
|
+
declare const ParamTypes: readonly ["path", "header", "cookie", "query"];
|
|
89
|
+
type ParamType = (typeof ParamTypes)[number];
|
|
78
90
|
interface AuthField {
|
|
79
91
|
fieldName: FieldKey;
|
|
80
92
|
defaultValue: unknown;
|
|
@@ -82,6 +94,16 @@ interface AuthField {
|
|
|
82
94
|
children: ReactNode;
|
|
83
95
|
mapOutput?: (values: unknown) => unknown;
|
|
84
96
|
}
|
|
97
|
+
declare function DefaultResultDisplay({
|
|
98
|
+
data,
|
|
99
|
+
reset,
|
|
100
|
+
...rest
|
|
101
|
+
}: ResultDisplayProps): _$react_jsx_runtime0.JSX.Element;
|
|
102
|
+
declare function DefaultCollapsiblePanel({
|
|
103
|
+
title,
|
|
104
|
+
children,
|
|
105
|
+
...props
|
|
106
|
+
}: CollapsiblePanelProps): _$react_jsx_runtime0.JSX.Element;
|
|
85
107
|
declare const Custom: {
|
|
86
108
|
useController(fieldName: FieldKey, options?: {
|
|
87
109
|
defaultValue?: unknown;
|
|
@@ -91,5 +113,5 @@ declare const Custom: {
|
|
|
91
113
|
};
|
|
92
114
|
};
|
|
93
115
|
//#endregion
|
|
94
|
-
export { AuthField, Custom, FormValues, PlaygroundClientOptions, PlaygroundClientProps, PlaygroundClient as default };
|
|
116
|
+
export { AuthField, CollapsiblePanelProps, Custom, DefaultCollapsiblePanel, DefaultResultDisplay, FormValues, PlaygroundClientOptions, PlaygroundClientProps, ResultDisplayProps, PlaygroundClient as default };
|
|
95
117
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/playground/client.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/playground/client.tsx"],"mappings":";;;;;;;;;;;UAwDiB,UAAA,SAAmB,MAAA;EAClC,IAAA,EAAM,MAAA;EACN,KAAA,EAAO,MAAA;EACP,MAAA,EAAQ,MAA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