fumadocs-openapi 10.5.0 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +26 -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 +27 -7
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +51 -44
- 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/index.d.ts +1 -1
- 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.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/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 -2
- 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/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/index.d.ts +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 +5 -4
- 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
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
@source inline("border-x");
|
|
109
109
|
@source inline("border-y");
|
|
110
110
|
@source inline("both");
|
|
111
|
+
@source inline("bundled");
|
|
111
112
|
@source inline("but");
|
|
112
113
|
@source inline("button");
|
|
113
114
|
@source inline("buttonVariants");
|
|
@@ -139,6 +140,7 @@
|
|
|
139
140
|
@source inline("cloned");
|
|
140
141
|
@source inline("cn");
|
|
141
142
|
@source inline("code");
|
|
143
|
+
@source inline("codeProps");
|
|
142
144
|
@source inline("codeUsages");
|
|
143
145
|
@source inline("codegen");
|
|
144
146
|
@source inline("codegens");
|
|
@@ -195,10 +197,11 @@
|
|
|
195
197
|
@source inline("data-collapsible");
|
|
196
198
|
@source inline("data-object-search-input");
|
|
197
199
|
@source inline("data-placeholder:text-fd-muted-foreground");
|
|
200
|
+
@source inline("data-type");
|
|
198
201
|
@source inline("dataEngine");
|
|
199
202
|
@source inline("declare");
|
|
200
203
|
@source inline("default");
|
|
201
|
-
@source inline("
|
|
204
|
+
@source inline("defaultAdapters");
|
|
202
205
|
@source inline("defaultColor");
|
|
203
206
|
@source inline("defaultExampleId");
|
|
204
207
|
@source inline("defaultItem");
|
|
@@ -210,12 +213,13 @@
|
|
|
210
213
|
@source inline("definitions");
|
|
211
214
|
@source inline("deprecated");
|
|
212
215
|
@source inline("depth");
|
|
216
|
+
@source inline("dereferenceMap");
|
|
217
|
+
@source inline("dereferenceSync");
|
|
213
218
|
@source inline("dereferenced");
|
|
214
219
|
@source inline("description");
|
|
215
220
|
@source inline("descriptionNode");
|
|
216
221
|
@source inline("development");
|
|
217
222
|
@source inline("deviceAuthorization");
|
|
218
|
-
@source inline("directive");
|
|
219
223
|
@source inline("disable");
|
|
220
224
|
@source inline("disabled");
|
|
221
225
|
@source inline("disabled:cursor-not-allowed");
|
|
@@ -227,13 +231,13 @@
|
|
|
227
231
|
@source inline("divide-fd-border");
|
|
228
232
|
@source inline("divide-y");
|
|
229
233
|
@source inline("document");
|
|
234
|
+
@source inline("doesn");
|
|
230
235
|
@source inline("domain");
|
|
231
236
|
@source inline("duplicated");
|
|
232
237
|
@source inline("duration-200");
|
|
233
238
|
@source inline("dynamic");
|
|
234
239
|
@source inline("e");
|
|
235
240
|
@source inline("each");
|
|
236
|
-
@source inline("either");
|
|
237
241
|
@source inline("element");
|
|
238
242
|
@source inline("else");
|
|
239
243
|
@source inline("empty");
|
|
@@ -255,13 +259,13 @@
|
|
|
255
259
|
@source inline("eslint-disable-next-line");
|
|
256
260
|
@source inline("example");
|
|
257
261
|
@source inline("exampleId");
|
|
262
|
+
@source inline("exampleRequests");
|
|
258
263
|
@source inline("examples");
|
|
259
264
|
@source inline("exclusiveMax");
|
|
260
265
|
@source inline("exclusiveMin");
|
|
261
266
|
@source inline("expand");
|
|
262
267
|
@source inline("export");
|
|
263
268
|
@source inline("extends");
|
|
264
|
-
@source inline("extra");
|
|
265
269
|
@source inline("factory");
|
|
266
270
|
@source inline("fallback");
|
|
267
271
|
@source inline("false");
|
|
@@ -338,11 +342,13 @@
|
|
|
338
342
|
@source inline("generate");
|
|
339
343
|
@source inline("generateDefault");
|
|
340
344
|
@source inline("generateTypeScriptDefinitions");
|
|
345
|
+
@source inline("generateTypeScriptSchema");
|
|
341
346
|
@source inline("generated");
|
|
342
347
|
@source inline("generated/defined");
|
|
343
|
-
@source inline("generator");
|
|
344
348
|
@source inline("generators");
|
|
345
349
|
@source inline("getAPIPageProps");
|
|
350
|
+
@source inline("getClientAPIPageProps");
|
|
351
|
+
@source inline("getExampleRequests");
|
|
346
352
|
@source inline("getSchema");
|
|
347
353
|
@source inline("getSchemaId");
|
|
348
354
|
@source inline("getStatusInfo");
|
|
@@ -393,9 +399,9 @@
|
|
|
393
399
|
@source inline("idx");
|
|
394
400
|
@source inline("if");
|
|
395
401
|
@source inline("ignore");
|
|
402
|
+
@source inline("img");
|
|
396
403
|
@source inline("implicit");
|
|
397
404
|
@source inline("import");
|
|
398
|
-
@source inline("imported");
|
|
399
405
|
@source inline("imports");
|
|
400
406
|
@source inline("in");
|
|
401
407
|
@source inline("include");
|
|
@@ -434,6 +440,7 @@
|
|
|
434
440
|
@source inline("j");
|
|
435
441
|
@source inline("json");
|
|
436
442
|
@source inline("json-schema-typed");
|
|
443
|
+
@source inline("json-schema-typed/draft-2020-12");
|
|
437
444
|
@source inline("justify-between");
|
|
438
445
|
@source inline("justify-center");
|
|
439
446
|
@source inline("k");
|
|
@@ -444,7 +451,6 @@
|
|
|
444
451
|
@source inline("labelVariants");
|
|
445
452
|
@source inline("lang");
|
|
446
453
|
@source inline("langs");
|
|
447
|
-
@source inline("language");
|
|
448
454
|
@source inline("last");
|
|
449
455
|
@source inline("last:border-b");
|
|
450
456
|
@source inline("last:border-b-0");
|
|
@@ -473,15 +479,18 @@
|
|
|
473
479
|
@source inline("max-w-[600px]");
|
|
474
480
|
@source inline("max-w-full");
|
|
475
481
|
@source inline("max-w-lg");
|
|
482
|
+
@source inline("may");
|
|
476
483
|
@source inline("mb-2");
|
|
477
484
|
@source inline("mb-4");
|
|
478
485
|
@source inline("md");
|
|
486
|
+
@source inline("mdxComponents");
|
|
479
487
|
@source inline("me-auto");
|
|
480
488
|
@source inline("media");
|
|
481
489
|
@source inline("mediaAdapters");
|
|
482
490
|
@source inline("mediaType");
|
|
483
491
|
@source inline("merge");
|
|
484
492
|
@source inline("mergeAllOf");
|
|
493
|
+
@source inline("merged");
|
|
485
494
|
@source inline("message");
|
|
486
495
|
@source inline("meta");
|
|
487
496
|
@source inline("metaData");
|
|
@@ -521,6 +530,7 @@
|
|
|
521
530
|
@source inline("no-cache");
|
|
522
531
|
@source inline("node");
|
|
523
532
|
@source inline("node:path");
|
|
533
|
+
@source inline("non-RSC");
|
|
524
534
|
@source inline("non-string");
|
|
525
535
|
@source inline("not");
|
|
526
536
|
@source inline("not-last:pb-0");
|
|
@@ -580,7 +590,6 @@
|
|
|
580
590
|
@source inline("page");
|
|
581
591
|
@source inline("pageData");
|
|
582
592
|
@source inline("pages");
|
|
583
|
-
@source inline("panels");
|
|
584
593
|
@source inline("param");
|
|
585
594
|
@source inline("paramTypeKeys");
|
|
586
595
|
@source inline("parameter");
|
|
@@ -596,13 +605,13 @@
|
|
|
596
605
|
@source inline("password");
|
|
597
606
|
@source inline("path");
|
|
598
607
|
@source inline("pathItem");
|
|
599
|
-
@source inline("pathItems");
|
|
600
608
|
@source inline("pathName");
|
|
601
609
|
@source inline("pathNodes");
|
|
602
610
|
@source inline("pathParameters");
|
|
603
611
|
@source inline("paths");
|
|
604
612
|
@source inline("pattern");
|
|
605
613
|
@source inline("patternProperties");
|
|
614
|
+
@source inline("payload");
|
|
606
615
|
@source inline("pb-0");
|
|
607
616
|
@source inline("pb-2");
|
|
608
617
|
@source inline("pe-2");
|
|
@@ -616,7 +625,6 @@
|
|
|
616
625
|
@source inline("placeholder:text-fd-muted-foreground");
|
|
617
626
|
@source inline("placeholders");
|
|
618
627
|
@source inline("playground");
|
|
619
|
-
@source inline("playground/index.tsx");
|
|
620
628
|
@source inline("playgroundEnabled");
|
|
621
629
|
@source inline("playgrounds");
|
|
622
630
|
@source inline("please");
|
|
@@ -624,7 +632,6 @@
|
|
|
624
632
|
@source inline("position");
|
|
625
633
|
@source inline("pre");
|
|
626
634
|
@source inline("prefix");
|
|
627
|
-
@source inline("preprocessed");
|
|
628
635
|
@source inline("prev");
|
|
629
636
|
@source inline("prevProperties");
|
|
630
637
|
@source inline("prevent");
|
|
@@ -633,7 +640,6 @@
|
|
|
633
640
|
@source inline("primitive");
|
|
634
641
|
@source inline("processed");
|
|
635
642
|
@source inline("processor");
|
|
636
|
-
@source inline("programming");
|
|
637
643
|
@source inline("prop");
|
|
638
644
|
@source inline("properties");
|
|
639
645
|
@source inline("property");
|
|
@@ -668,6 +674,7 @@
|
|
|
668
674
|
@source inline("react");
|
|
669
675
|
@source inline("react-hook-form");
|
|
670
676
|
@source inline("react-hooks/exhaustive-deps");
|
|
677
|
+
@source inline("react-hooks/rules-of-hooks");
|
|
671
678
|
@source inline("react/jsx-runtime");
|
|
672
679
|
@source inline("read");
|
|
673
680
|
@source inline("readOnly");
|
|
@@ -694,7 +701,6 @@
|
|
|
694
701
|
@source inline("render");
|
|
695
702
|
@source inline("renderAPIExampleLayout");
|
|
696
703
|
@source inline("renderAPIExampleUsageTabs");
|
|
697
|
-
@source inline("renderBodyField");
|
|
698
704
|
@source inline("renderOperationLayout");
|
|
699
705
|
@source inline("renderPageLayout");
|
|
700
706
|
@source inline("renderParameterField");
|
|
@@ -719,12 +725,11 @@
|
|
|
719
725
|
@source inline("requests");
|
|
720
726
|
@source inline("required");
|
|
721
727
|
@source inline("res");
|
|
722
|
-
@source inline("resType");
|
|
723
728
|
@source inline("reset");
|
|
724
729
|
@source inline("resize-none");
|
|
725
|
-
@source inline("resolution");
|
|
726
730
|
@source inline("resolve");
|
|
727
731
|
@source inline("resolveMediaAdapter");
|
|
732
|
+
@source inline("resolveRefSync");
|
|
728
733
|
@source inline("resolveRequestData");
|
|
729
734
|
@source inline("resolved");
|
|
730
735
|
@source inline("resolvedTheme");
|
|
@@ -740,6 +745,7 @@
|
|
|
740
745
|
@source inline("rest");
|
|
741
746
|
@source inline("result");
|
|
742
747
|
@source inline("return");
|
|
748
|
+
@source inline("returned");
|
|
743
749
|
@source inline("root");
|
|
744
750
|
@source inline("rotate-90");
|
|
745
751
|
@source inline("rounded-lg");
|
|
@@ -794,9 +800,9 @@
|
|
|
794
800
|
@source inline("server-side");
|
|
795
801
|
@source inline("server-url");
|
|
796
802
|
@source inline("serverContext");
|
|
797
|
-
@source inline("serverRef");
|
|
798
803
|
@source inline("serverSchema");
|
|
799
804
|
@source inline("servers");
|
|
805
|
+
@source inline("set");
|
|
800
806
|
@source inline("setData");
|
|
801
807
|
@source inline("setError");
|
|
802
808
|
@source inline("setExample");
|
|
@@ -842,6 +848,7 @@
|
|
|
842
848
|
@source inline("slot");
|
|
843
849
|
@source inline("slotType");
|
|
844
850
|
@source inline("slots");
|
|
851
|
+
@source inline("slug");
|
|
845
852
|
@source inline("slugger");
|
|
846
853
|
@source inline("sm");
|
|
847
854
|
@source inline("sm:flex-row");
|
|
@@ -849,7 +856,6 @@
|
|
|
849
856
|
@source inline("sm:justify-end");
|
|
850
857
|
@source inline("sm:text-start");
|
|
851
858
|
@source inline("so");
|
|
852
|
-
@source inline("source");
|
|
853
859
|
@source inline("spec");
|
|
854
860
|
@source inline("specify");
|
|
855
861
|
@source inline("stack");
|
|
@@ -867,6 +873,7 @@
|
|
|
867
873
|
@source inline("step");
|
|
868
874
|
@source inline("stf");
|
|
869
875
|
@source inline("sticky");
|
|
876
|
+
@source inline("storageKey");
|
|
870
877
|
@source inline("storageKeyPrefix");
|
|
871
878
|
@source inline("storageKeys");
|
|
872
879
|
@source inline("store");
|
|
@@ -879,15 +886,14 @@
|
|
|
879
886
|
@source inline("submit");
|
|
880
887
|
@source inline("such");
|
|
881
888
|
@source inline("summary");
|
|
889
|
+
@source inline("support");
|
|
882
890
|
@source inline("supported");
|
|
883
|
-
@source inline("swallow");
|
|
884
891
|
@source inline("switch");
|
|
885
892
|
@source inline("t");
|
|
886
893
|
@source inline("tab");
|
|
887
894
|
@source inline("tabs");
|
|
888
895
|
@source inline("tag");
|
|
889
896
|
@source inline("takenIds");
|
|
890
|
-
@source inline("targetServer");
|
|
891
897
|
@source inline("testQuery");
|
|
892
898
|
@source inline("text");
|
|
893
899
|
@source inline("text-[0.8125rem]");
|
|
@@ -979,18 +985,17 @@
|
|
|
979
985
|
@source inline("useApiClientModal");
|
|
980
986
|
@source inline("useApiContext");
|
|
981
987
|
@source inline("useCopyButton");
|
|
982
|
-
@source inline("useExampleRequests");
|
|
983
988
|
@source inline("useFieldValue");
|
|
984
989
|
@source inline("useForm");
|
|
985
990
|
@source inline("useI18n");
|
|
986
991
|
@source inline("useMemo");
|
|
987
992
|
@source inline("useNamespace");
|
|
988
993
|
@source inline("useObject");
|
|
994
|
+
@source inline("useOperationContext");
|
|
989
995
|
@source inline("useQuery");
|
|
990
996
|
@source inline("useRef");
|
|
991
997
|
@source inline("useResolvedSchema");
|
|
992
998
|
@source inline("useServerContext");
|
|
993
|
-
@source inline("useServerSelectContext");
|
|
994
999
|
@source inline("useState");
|
|
995
1000
|
@source inline("useStf");
|
|
996
1001
|
@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,MAAMA,OAAK,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACxD,QAAM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AAM,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,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,wBAAwB;CAE1C,MAAM,SAAS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AAM;;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";
|
|
1
|
+
import { ParsedSchema } from "../utils/schema/index.js";
|
|
2
2
|
import { 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
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,6 +31,14 @@ 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)
|
|
@@ -39,11 +48,10 @@ interface PlaygroundClientOptions {
|
|
|
39
48
|
* Request timeout in seconds (default: 10s)
|
|
40
49
|
*/
|
|
41
50
|
requestTimeout?: number;
|
|
42
|
-
components?:
|
|
43
|
-
ResultDisplay
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}>;
|
|
51
|
+
components?: {
|
|
52
|
+
ResultDisplay?: FC<ResultDisplayProps>;
|
|
53
|
+
CollapsiblePanel?: FC<CollapsiblePanelProps>;
|
|
54
|
+
};
|
|
47
55
|
/**
|
|
48
56
|
* render the parameter inputs of API endpoint.
|
|
49
57
|
*
|
|
@@ -75,6 +83,8 @@ declare function PlaygroundClient({
|
|
|
75
83
|
readOnly,
|
|
76
84
|
...rest
|
|
77
85
|
}: PlaygroundClientProps): react_jsx_runtime0.JSX.Element;
|
|
86
|
+
declare const ParamTypes: readonly ["path", "header", "cookie", "query"];
|
|
87
|
+
type ParamType = (typeof ParamTypes)[number];
|
|
78
88
|
interface AuthField {
|
|
79
89
|
fieldName: FieldKey;
|
|
80
90
|
defaultValue: unknown;
|
|
@@ -82,6 +92,16 @@ interface AuthField {
|
|
|
82
92
|
children: ReactNode;
|
|
83
93
|
mapOutput?: (values: unknown) => unknown;
|
|
84
94
|
}
|
|
95
|
+
declare function DefaultResultDisplay({
|
|
96
|
+
data,
|
|
97
|
+
reset,
|
|
98
|
+
...rest
|
|
99
|
+
}: ResultDisplayProps): react_jsx_runtime0.JSX.Element;
|
|
100
|
+
declare function DefaultCollapsiblePanel({
|
|
101
|
+
title,
|
|
102
|
+
children,
|
|
103
|
+
...props
|
|
104
|
+
}: CollapsiblePanelProps): react_jsx_runtime0.JSX.Element;
|
|
85
105
|
declare const Custom: {
|
|
86
106
|
useController(fieldName: FieldKey, options?: {
|
|
87
107
|
defaultValue?: unknown;
|
|
@@ -91,5 +111,5 @@ declare const Custom: {
|
|
|
91
111
|
};
|
|
92
112
|
};
|
|
93
113
|
//#endregion
|
|
94
|
-
export { AuthField, Custom, FormValues, PlaygroundClientOptions, PlaygroundClientProps, PlaygroundClient as default };
|
|
114
|
+
export { AuthField, CollapsiblePanelProps, Custom, DefaultCollapsiblePanel, DefaultResultDisplay, FormValues, PlaygroundClientOptions, PlaygroundClientProps, ResultDisplayProps, PlaygroundClient as default };
|
|
95
115
|
//# 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,MAAA;EACR,MAAA,EAAQ,MAAA;EACR,IAAA;AAAA;AAAA,UAGe,qBAAA,SAA8B,cAAA,UAAwB,WAAA;EACrE,KAAA;EACA,MAAA;EACA,UAAA,GAAa,eAAA;EACb,UAAA,EAAY,aAAA;EACZ,IAAA;IACE,MAAA,EAAQ,YAAA;IACR,SAAA;EAAA;EAbF;;;EAkBA,UAAA,EAAY,MAAA,SAAe,YAAA;EAC3B,QAAA;AAAA;AAAA,UAGe,kBAAA,SAA2B,cAAA;EAC1C,IAAA,EAAM,WAAA;EACN,KAAA;AAAA;AA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