@digi-frontend/dgate-api-documentation 2.0.1-test.1 → 2.0.1-test.11

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/dist/index.cjs CHANGED
@@ -5,6 +5,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ };
8
17
  var __copyProps = (to, from, except, desc) => {
9
18
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
19
  key = keys[i];
@@ -19,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
28
  value: mod,
20
29
  enumerable: true
21
30
  }) : target, mod));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
32
 
23
33
  //#endregion
24
34
  const zustand = __toESM(require("zustand"));
@@ -35,8 +45,8 @@ const __ant_design_nextjs_registry = __toESM(require("@ant-design/nextjs-registr
35
45
  const createViewSlice = (set) => ({ view: {
36
46
  selectedNodeKey: null,
37
47
  expandedKeys: ["custom-auth", "api-name-01"],
38
- originalData: null,
39
- transformedData: null,
48
+ originalData: [],
49
+ transformedData: [],
40
50
  selectedApi: null,
41
51
  selectedEndpoint: null,
42
52
  setSelectedNode: (key) => set((state) => {
@@ -112,6 +122,7 @@ const createStore = (set) => ({
112
122
  ...createEditorSlice(set)
113
123
  });
114
124
  const useStore = (0, zustand.create)()((0, zustand_middleware.devtools)((0, zustand_middleware_immer.immer)(createStore), { name: "dgate-docs-store" }));
125
+ var store_default = useStore;
115
126
 
116
127
  //#endregion
117
128
  //#region src/hooks/useStyle.ts
@@ -503,391 +514,563 @@ var token = {
503
514
 
504
515
  //#endregion
505
516
  //#region src/view/helper/sidebar.utils.ts
506
- const methodColors = {
507
- GET: {
508
- bg: token.colorPrimaryBgHover,
509
- color: token.colorPrimary
510
- },
511
- POST: {
512
- bg: token["green.1"],
513
- color: token.colorSuccess
514
- },
515
- DELETE: {
516
- bg: token.colorErrorBg,
517
- color: token.colorError
518
- },
519
- PUT: {
520
- bg: token.colorWarningBg,
521
- color: token.colorWarning
522
- },
523
- PATCH: {
524
- bg: token["volcano.5"],
525
- color: token.colorWhite
526
- },
527
- OPTIONS: {
528
- bg: token["geekblue.2"],
529
- color: token["geekblue.6"]
530
- },
531
- HEAD: {
532
- bg: token["purple.1"],
533
- color: token["purple.5"]
534
- },
535
- TRACE: {
536
- bg: token["cyan.1"],
537
- color: token["cyan.5"]
538
- }
539
- };
540
- const buildTreeDataStructure = (data) => {
541
- if (!data) return [];
542
- return data.map((api) => {
543
- return {
544
- title: api.title,
545
- key: api.id,
546
- selectable: true,
547
- data: api,
548
- children: Object.entries(api.tags).map(([tag, endpoints]) => {
549
- const tagId = `tag-${(0, nanoid.nanoid)(8)}`;
550
- return {
551
- title: tag,
552
- key: tagId,
553
- selectable: false,
554
- data: {
555
- tagName: tag,
556
- apiData: api
557
- },
558
- children: endpoints.map((endpoint) => {
559
- return {
560
- title: endpoint.summary,
561
- key: endpoint.id,
562
- isLeaf: true,
563
- selectable: true,
564
- method: endpoint.method,
565
- data: {
566
- endpoint,
567
- api,
568
- tagName: tag
569
- }
570
- };
571
- })
572
- };
573
- })
574
- };
575
- });
576
- };
577
- const findNodeByKey = (nodes, targetKey) => {
578
- for (const node of nodes) {
579
- if (node.key === targetKey) return node;
580
- if (node.children && node.children.length > 0) {
581
- const found = findNodeByKey(node.children, targetKey);
582
- if (found) return found;
583
- }
584
- }
585
- return null;
586
- };
587
- const isApiSectionHighlighted = (apiKey, selectedNode, treeDataStructure) => {
588
- if (!selectedNode || selectedNode.length === 0) return false;
589
- const selectedKey = selectedNode[0];
590
- if (selectedKey === apiKey) return false;
591
- const findNodeParentApi = (nodes, targetKey) => {
592
- for (const node of nodes) if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
593
- const apiId = node.key;
594
- if (node.children) for (const child of node.children) {
595
- if (child.key === targetKey) return apiId;
596
- if (child.children) {
597
- for (const grandChild of child.children) if (grandChild.key === targetKey) return apiId;
598
- }
599
- }
517
+ var methodColors, buildTreeDataStructure, findNodeByKey, isApiSectionHighlighted, getAllTreeKeys, filterTreeData, getParentKey, getSidebarStyles;
518
+ var init_sidebar_utils = __esm({ "src/view/helper/sidebar.utils.ts": (() => {
519
+ methodColors = {
520
+ GET: {
521
+ bg: token.colorPrimaryBgHover,
522
+ color: token.colorPrimary
523
+ },
524
+ POST: {
525
+ bg: token["green.1"],
526
+ color: token.colorSuccess
527
+ },
528
+ DELETE: {
529
+ bg: token.colorErrorBg,
530
+ color: token.colorError
531
+ },
532
+ PUT: {
533
+ bg: token.colorWarningBg,
534
+ color: token.colorWarning
535
+ },
536
+ PATCH: {
537
+ bg: token["volcano.5"],
538
+ color: token.colorWhite
539
+ },
540
+ OPTIONS: {
541
+ bg: token["geekblue.2"],
542
+ color: token["geekblue.6"]
543
+ },
544
+ HEAD: {
545
+ bg: token["purple.1"],
546
+ color: token["purple.5"]
547
+ },
548
+ TRACE: {
549
+ bg: token["cyan.1"],
550
+ color: token["cyan.5"]
600
551
  }
601
- return null;
602
552
  };
603
- const parentApiKey = findNodeParentApi(treeDataStructure, selectedKey);
604
- return parentApiKey === apiKey;
605
- };
606
- const getAllTreeKeys = (data) => {
607
- const keys = [];
608
- const traverse = (nodes) => {
609
- nodes.forEach((node) => {
610
- keys.push(node.key);
611
- if (node.children && node.children.length > 0) traverse(node.children);
553
+ buildTreeDataStructure = (data) => {
554
+ if (!data) return [];
555
+ return data.map((api) => {
556
+ return {
557
+ title: api.title,
558
+ key: api.id,
559
+ selectable: true,
560
+ data: api,
561
+ children: Object.entries(api.tags).map(([tag, endpoints]) => {
562
+ const tagId = `tag-${(0, nanoid.nanoid)(8)}`;
563
+ return {
564
+ title: tag,
565
+ key: tagId,
566
+ selectable: false,
567
+ data: {
568
+ tagName: tag,
569
+ apiData: api
570
+ },
571
+ children: endpoints.map((endpoint) => {
572
+ return {
573
+ title: endpoint.summary,
574
+ key: endpoint.id,
575
+ isLeaf: true,
576
+ selectable: true,
577
+ method: endpoint.method,
578
+ data: {
579
+ endpoint,
580
+ api,
581
+ tagName: tag
582
+ }
583
+ };
584
+ })
585
+ };
586
+ })
587
+ };
612
588
  });
613
589
  };
614
- traverse(data);
615
- return keys;
616
- };
617
- const filterTreeData = (data, searchText) => {
618
- if (!searchText) return data;
619
- const findOriginalNode = (nodes, key) => {
590
+ findNodeByKey = (nodes, targetKey) => {
620
591
  for (const node of nodes) {
621
- if (node.key === key) return node;
622
- if (node.children) {
623
- const found = findOriginalNode(node.children, key);
592
+ if (node.key === targetKey) return node;
593
+ if (node.children && node.children.length > 0) {
594
+ const found = findNodeByKey(node.children, targetKey);
624
595
  if (found) return found;
625
596
  }
626
597
  }
627
598
  return null;
628
599
  };
629
- const filterNode = (node) => {
630
- let titleText = "";
631
- const originalNode = findOriginalNode(data, node.key);
632
- if (originalNode && typeof originalNode.title === "string") titleText = originalNode.title;
633
- else if (typeof node.title === "string") titleText = node.title;
634
- let searchableText = titleText;
635
- if (node.isLeaf && node.method) searchableText = `${node.method} ${titleText}`.toLowerCase();
636
- else searchableText = titleText.toLowerCase();
637
- const searchLower = searchText.toLowerCase();
638
- const matchesSearch = searchableText.includes(searchLower);
639
- if (node.children) {
640
- const filteredChildren = node.children.map((child) => filterNode(child)).filter((child) => child !== null);
641
- if (matchesSearch || filteredChildren.length > 0) return {
642
- ...node,
643
- children: filteredChildren
644
- };
645
- } else if (matchesSearch) return node;
600
+ isApiSectionHighlighted = (apiKey, selectedNode, treeDataStructure) => {
601
+ if (!selectedNode || selectedNode.length === 0) return false;
602
+ const selectedKey = selectedNode[0];
603
+ if (selectedKey === apiKey) return false;
604
+ const findNodeParentApi = (nodes, targetKey) => {
605
+ for (const node of nodes) if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
606
+ const apiId = node.key;
607
+ if (node.children) for (const child of node.children) {
608
+ if (child.key === targetKey) return apiId;
609
+ if (child.children) {
610
+ for (const grandChild of child.children) if (grandChild.key === targetKey) return apiId;
611
+ }
612
+ }
613
+ }
614
+ return null;
615
+ };
616
+ const parentApiKey = findNodeParentApi(treeDataStructure, selectedKey);
617
+ return parentApiKey === apiKey;
618
+ };
619
+ getAllTreeKeys = (data) => {
620
+ const keys = [];
621
+ const traverse = (nodes) => {
622
+ nodes.forEach((node) => {
623
+ keys.push(node.key);
624
+ if (node.children && node.children.length > 0) traverse(node.children);
625
+ });
626
+ };
627
+ traverse(data);
628
+ return keys;
629
+ };
630
+ filterTreeData = (data, searchText) => {
631
+ if (!searchText) return data;
632
+ const findOriginalNode = (nodes, key) => {
633
+ for (const node of nodes) {
634
+ if (node.key === key) return node;
635
+ if (node.children) {
636
+ const found = findOriginalNode(node.children, key);
637
+ if (found) return found;
638
+ }
639
+ }
640
+ return null;
641
+ };
642
+ const filterNode = (node) => {
643
+ let titleText = "";
644
+ const originalNode = findOriginalNode(data, node.key);
645
+ if (originalNode && typeof originalNode.title === "string") titleText = originalNode.title;
646
+ else if (typeof node.title === "string") titleText = node.title;
647
+ let searchableText = titleText;
648
+ if (node.isLeaf && node.method) searchableText = `${node.method} ${titleText}`.toLowerCase();
649
+ else searchableText = titleText.toLowerCase();
650
+ const searchLower = searchText.toLowerCase();
651
+ const matchesSearch = searchableText.includes(searchLower);
652
+ if (node.children) {
653
+ const filteredChildren = node.children.map((child) => filterNode(child)).filter((child) => child !== null);
654
+ if (matchesSearch || filteredChildren.length > 0) return {
655
+ ...node,
656
+ children: filteredChildren
657
+ };
658
+ } else if (matchesSearch) return node;
659
+ return null;
660
+ };
661
+ return data.map((node) => filterNode(node)).filter((node) => node !== null);
662
+ };
663
+ getParentKey = (key, tree) => {
664
+ for (let i = 0; i < tree.length; i++) {
665
+ const node = tree[i];
666
+ if (node.children) {
667
+ if (node.children.some((item) => item.key === key)) return node.key;
668
+ const parent = getParentKey(key, node.children);
669
+ if (parent) return parent;
670
+ }
671
+ }
646
672
  return null;
647
673
  };
648
- return data.map((node) => filterNode(node)).filter((node) => node !== null);
649
- };
650
- const getSidebarStyles = (token$1, scope) => ({
651
- [scope("sider")]: {
652
- backgroundColor: token$1.colorBgContainer,
653
- maxWidth: "17.5rem",
654
- overflowY: "auto",
655
- overflowX: "clip"
656
- },
657
- [scope("content")]: { padding: token$1.padding },
658
- [scope("controls")]: {
659
- display: "flex",
660
- gap: token$1.marginXS,
661
- marginBottom: token$1.marginSM
662
- },
663
- [scope("search-input")]: { flex: 1 },
664
- [scope("tree")]: {
665
- backgroundColor: "transparent",
666
- "& .ant-tree-node-content-wrapper": {
667
- overflow: "hidden",
668
- width: "100%",
674
+ getSidebarStyles = (token$1, scope) => ({
675
+ [scope("sider")]: {
676
+ backgroundColor: token$1.colorBgContainer,
677
+ maxWidth: "17.5rem",
678
+ overflowY: "auto",
679
+ overflowX: "clip"
680
+ },
681
+ [scope("content")]: { padding: token$1.padding },
682
+ [scope("controls")]: {
669
683
  display: "flex",
670
- alignItems: "center"
684
+ gap: token$1.marginXS,
685
+ marginBottom: token$1.marginSM
671
686
  },
672
- "& .ant-tree-title": {
673
- width: "100%",
674
- overflow: "hidden",
687
+ [scope("search-input")]: { flex: 1 },
688
+ [scope("tree")]: {
689
+ backgroundColor: "transparent",
690
+ "& .ant-tree-node-content-wrapper": {
691
+ overflow: "hidden",
692
+ width: "100%",
693
+ display: "flex",
694
+ alignItems: "center"
695
+ },
696
+ "& .ant-tree-title": {
697
+ width: "100%",
698
+ overflow: "hidden",
699
+ display: "flex",
700
+ alignItems: "center",
701
+ marginBlock: "auto"
702
+ },
703
+ "& .ant-tree-treenode": {
704
+ width: "100%",
705
+ padding: 0
706
+ },
707
+ "& .ant-tree-node-content-wrapper:hover": { backgroundColor: token$1.colorFillTertiary }
708
+ },
709
+ [scope("endpoint-item")]: {
675
710
  display: "flex",
676
711
  alignItems: "center",
677
- marginBlock: "auto"
678
- },
679
- "& .ant-tree-treenode": {
712
+ gap: token$1.marginXS,
680
713
  width: "100%",
681
- padding: 0
714
+ maxWidth: "100%",
715
+ minWidth: "100%"
682
716
  },
683
- "& .ant-tree-node-content-wrapper:hover": { backgroundColor: token$1.colorFillTertiary }
684
- },
685
- [scope("endpoint-item")]: {
686
- display: "flex",
687
- alignItems: "center",
688
- gap: token$1.marginXS,
689
- width: "100%",
690
- maxWidth: "100%",
691
- minWidth: "100%"
692
- },
693
- [scope("method-tag")]: {
694
- minWidth: "3.75rem",
695
- textAlign: "center",
696
- border: "none"
697
- },
698
- [scope("endpoint-text")]: {
699
- flex: 1,
700
- maxWidth: "100%"
701
- },
702
- [scope("tag-title")]: {
703
- color: token$1.colorText,
704
- maxWidth: "100%",
705
- display: "block"
706
- },
707
- [scope("api-title")]: {
708
- color: token$1.colorText,
709
- maxWidth: "100%",
710
- display: "block",
711
- padding: 0,
712
- margin: 0,
713
- "&.highlighted": { color: token$1.colorPrimary }
714
- },
715
- [scope("create-text")]: { color: token$1.colorTextSecondary }
716
- });
717
+ [scope("method-tag")]: {
718
+ minWidth: "3.75rem",
719
+ textAlign: "center",
720
+ border: "none"
721
+ },
722
+ [scope("endpoint-text")]: {
723
+ flex: 1,
724
+ maxWidth: "100%"
725
+ },
726
+ [scope("tag-title")]: {
727
+ color: token$1.colorText,
728
+ maxWidth: "100%",
729
+ display: "block"
730
+ },
731
+ [scope("api-title")]: {
732
+ color: token$1.colorText,
733
+ maxWidth: "100%",
734
+ display: "block",
735
+ padding: 0,
736
+ margin: 0,
737
+ "&.highlighted": { color: token$1.colorPrimary }
738
+ },
739
+ [scope("create-text")]: { color: token$1.colorTextSecondary }
740
+ });
741
+ }) });
717
742
 
718
743
  //#endregion
719
744
  //#region src/view/helper/sidebar.components.tsx
720
- const { Text } = antd.Typography;
721
- const EndpointItem = ({ method, title, cx }) => {
722
- const methodStyle = methodColors[method];
723
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
724
- className: cx("endpoint-item"),
725
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, {
726
- className: cx("method-tag"),
727
- style: {
728
- backgroundColor: methodStyle?.bg,
729
- color: methodStyle?.color,
730
- border: "none"
731
- },
732
- children: method
733
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
734
- className: cx("endpoint-text"),
735
- ellipsis: { tooltip: title },
736
- style: { flex: 1 },
737
- children: title
738
- })]
739
- });
740
- };
741
- const convertToRenderableTreeData = (treeDataStructure, selectedNode, cx) => {
742
- const renderNode = (node) => {
743
- let title;
744
- if (node.isLeaf && node.method) title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointItem, {
745
- method: node.method,
746
- title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
747
- cx
745
+ var Text, EndpointItem, convertToRenderableTreeData;
746
+ var init_sidebar_components = __esm({ "src/view/helper/sidebar.components.tsx": (() => {
747
+ init_sidebar_utils();
748
+ ({Text} = antd.Typography);
749
+ EndpointItem = ({ method, title, cx }) => {
750
+ const methodStyle = methodColors[method];
751
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
752
+ className: cx("endpoint-item"),
753
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, {
754
+ className: cx("method-tag"),
755
+ style: {
756
+ backgroundColor: methodStyle?.bg,
757
+ color: methodStyle?.color,
758
+ border: "none"
759
+ },
760
+ children: method
761
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
762
+ className: cx("endpoint-text"),
763
+ ellipsis: { tooltip: title },
764
+ style: { flex: 1 },
765
+ children: title
766
+ })]
748
767
  });
749
- else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
750
- const isHighlighted = isApiSectionHighlighted(node.key, selectedNode, treeDataStructure);
751
- title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
752
- className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
768
+ };
769
+ convertToRenderableTreeData = (treeDataStructure, selectedNode, cx) => {
770
+ const renderNode = (node) => {
771
+ let title;
772
+ if (node.isLeaf && node.method) title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointItem, {
773
+ method: node.method,
774
+ title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
775
+ cx
776
+ });
777
+ else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
778
+ const isHighlighted = isApiSectionHighlighted(node.key, selectedNode, treeDataStructure);
779
+ title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
780
+ className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
781
+ ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
782
+ children: node.title
783
+ });
784
+ } else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
785
+ className: cx("tag-title"),
753
786
  ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
754
787
  children: node.title
755
788
  });
756
- } else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
757
- className: cx("tag-title"),
758
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
759
- children: node.title
760
- });
761
- return {
762
- ...node,
763
- title,
764
- children: node.children ? node.children.map(renderNode) : void 0
789
+ return {
790
+ ...node,
791
+ title,
792
+ children: node.children ? node.children.map(renderNode) : void 0
793
+ };
765
794
  };
795
+ return treeDataStructure.map(renderNode);
766
796
  };
767
- return treeDataStructure.map(renderNode);
768
- };
797
+ }) });
798
+
799
+ //#endregion
800
+ //#region src/view/helper/index.ts
801
+ var helper_exports = {};
802
+ __export(helper_exports, {
803
+ EndpointItem: () => EndpointItem,
804
+ buildTreeDataStructure: () => buildTreeDataStructure,
805
+ convertToRenderableTreeData: () => convertToRenderableTreeData,
806
+ filterTreeData: () => filterTreeData,
807
+ findNodeByKey: () => findNodeByKey,
808
+ getAllTreeKeys: () => getAllTreeKeys,
809
+ getParentKey: () => getParentKey,
810
+ getSidebarStyles: () => getSidebarStyles,
811
+ isApiSectionHighlighted: () => isApiSectionHighlighted,
812
+ methodColors: () => methodColors
813
+ });
814
+ var init_helper = __esm({ "src/view/helper/index.ts": (() => {
815
+ init_sidebar_utils();
816
+ init_sidebar_components();
817
+ }) });
769
818
 
770
819
  //#endregion
771
820
  //#region src/view/components/Sidebar.tsx
772
821
  const { Sider } = antd.Layout;
773
- const Sidebar = () => {
774
- const expandedKeys = useStore((state) => state.view.expandedKeys);
775
- const setExpandedKeys = useStore((state) => state.view.setExpandedKeys);
776
- const setSelectedApi = useStore((state) => state.view.setSelectedApi);
777
- const setSelectedEndpoint = useStore((state) => state.view.setSelectedEndpoint);
778
- const [selectedNode, setSelectedNodeState] = (0, react.useState)();
779
- const transformedData = useStore((state) => state.view.transformedData);
780
- const builtTreeData = (0, react.useMemo)(() => buildTreeDataStructure(transformedData), [transformedData]);
781
- const [searchValue, setSearchValue] = (0, react.useState)("");
782
- const [autoExpandParent, setAutoExpandParent] = (0, react.useState)(true);
783
- const { wrapSSR, cx } = useStyle("Sidebar", getSidebarStyles);
784
- const handleSearch = (value) => {
785
- if (value) {
786
- const allKeys = getAllTreeKeys(builtTreeData);
787
- setExpandedKeys(allKeys);
788
- setSearchValue(value);
789
- setAutoExpandParent(true);
790
- } else {
791
- setSearchValue(value);
792
- setAutoExpandParent(false);
822
+ const safeHelperCall = (fn, args, functionName) => {
823
+ try {
824
+ if (!fn) {
825
+ console.error(`[Sidebar] Function ${functionName} is not available`);
826
+ return null;
793
827
  }
794
- };
795
- const renderTreeData = (0, react.useMemo)(() => {
796
- return convertToRenderableTreeData(builtTreeData, selectedNode, cx);
797
- }, [
798
- builtTreeData,
799
- selectedNode,
800
- cx
801
- ]);
802
- const filteredTreeData = (0, react.useMemo)(() => {
803
- if (!searchValue) return renderTreeData;
804
- const filteredOriginal = filterTreeData(builtTreeData, searchValue);
805
- return convertToRenderableTreeData(filteredOriginal, selectedNode, cx);
806
- }, [
807
- builtTreeData,
808
- searchValue,
809
- selectedNode,
810
- cx
811
- ]);
812
- const collapseAll = () => {
813
- setExpandedKeys([]);
814
- };
815
- const handleNodeSelection = (nodeData, nodeKey) => {
816
- if (!nodeData) return null;
817
- if (nodeKey.startsWith("endpoint-")) {
818
- const endpointNodeData = nodeData;
819
- setSelectedEndpoint(endpointNodeData.endpoint);
820
- setSelectedApi(endpointNodeData.api);
821
- return {
822
- type: "endpoint",
823
- endpoint: endpointNodeData.endpoint,
824
- api: endpointNodeData.api,
825
- tag: endpointNodeData.tagName
826
- };
827
- } else if (nodeKey.startsWith("api-") || nodeKey === "custom-auth") {
828
- const apiData = nodeData;
829
- setSelectedApi(apiData);
830
- setSelectedEndpoint(null);
831
- return {
832
- type: "api",
833
- api: apiData
834
- };
835
- } else {
836
- const tagData = nodeData;
837
- return {
838
- type: "tag",
839
- tag: tagData.tagName,
840
- api: tagData.apiData
841
- };
828
+ const result = fn(...args);
829
+ console.log(`[Sidebar] ${functionName} executed successfully`);
830
+ return result;
831
+ } catch (error) {
832
+ console.error(`[Sidebar] Error in ${functionName}:`, error);
833
+ return null;
834
+ }
835
+ };
836
+ const Sidebar = () => {
837
+ try {
838
+ let getAllTreeKeys$1, filterTreeData$1, getSidebarStyles$1, convertToRenderableTreeData$1, buildTreeDataStructure$1, findNodeByKey$1;
839
+ try {
840
+ const helperImports = (init_helper(), __toCommonJS(helper_exports));
841
+ getAllTreeKeys$1 = helperImports.getAllTreeKeys;
842
+ filterTreeData$1 = helperImports.filterTreeData;
843
+ getSidebarStyles$1 = helperImports.getSidebarStyles;
844
+ convertToRenderableTreeData$1 = helperImports.convertToRenderableTreeData;
845
+ buildTreeDataStructure$1 = helperImports.buildTreeDataStructure;
846
+ findNodeByKey$1 = helperImports.findNodeByKey;
847
+ console.log("[Sidebar] Helper functions imported successfully");
848
+ } catch (error) {
849
+ console.error("[Sidebar] Error importing helper functions:", error);
850
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sider, {
851
+ width: 280,
852
+ style: {
853
+ backgroundColor: "#f5f5f5",
854
+ border: "1px solid orange"
855
+ },
856
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
857
+ style: { padding: 16 },
858
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
859
+ style: {
860
+ color: "#fa8c16",
861
+ margin: 0
862
+ },
863
+ children: "Import Error"
864
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
865
+ style: {
866
+ fontSize: "12px",
867
+ color: "#666",
868
+ margin: "8px 0 0 0"
869
+ },
870
+ children: "Could not import helper functions. Check console."
871
+ })]
872
+ })
873
+ });
842
874
  }
843
- };
844
- const onTreeNodeSelect = (selectedKeys) => {
845
- const stringKeys = selectedKeys.map((key) => String(key));
846
- if (stringKeys.length === 0) {
847
- setSelectedNodeState([]);
848
- setSelectedApi(null);
849
- setSelectedEndpoint(null);
850
- return;
875
+ const expandedKeys = useStore((state) => state.view.expandedKeys);
876
+ const setExpandedKeys = useStore((state) => state.view.setExpandedKeys);
877
+ const setSelectedApi = useStore((state) => state.view.setSelectedApi);
878
+ const setSelectedEndpoint = useStore((state) => state.view.setSelectedEndpoint);
879
+ const [selectedNode, setSelectedNodeState] = (0, react.useState)();
880
+ const transformedData = useStore((state) => state.view.transformedData);
881
+ console.log("[Sidebar] Store access successful, transformedData:", transformedData);
882
+ const builtTreeData = (0, react.useMemo)(() => {
883
+ console.log("[Sidebar] Building tree data...");
884
+ return safeHelperCall(buildTreeDataStructure$1, [transformedData], "buildTreeDataStructure") || [];
885
+ }, [transformedData, buildTreeDataStructure$1]);
886
+ const [searchValue, setSearchValue] = (0, react.useState)("");
887
+ const [autoExpandParent, setAutoExpandParent] = (0, react.useState)(true);
888
+ let wrapSSR, cx;
889
+ try {
890
+ const styleResult = useStyle("Sidebar", getSidebarStyles$1);
891
+ wrapSSR = styleResult.wrapSSR;
892
+ cx = styleResult.cx;
893
+ console.log("[Sidebar] useStyle executed successfully");
894
+ } catch (error) {
895
+ console.error("[Sidebar] Error in useStyle:", error);
896
+ wrapSSR = (children) => children;
897
+ cx = (className) => className;
851
898
  }
852
- const selectedKey = stringKeys[0];
853
- const selectedNode$1 = findNodeByKey(builtTreeData, selectedKey);
854
- if (selectedNode$1) handleNodeSelection(selectedNode$1.data, selectedKey);
855
- setSelectedNodeState(stringKeys);
856
- };
857
- return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sider, {
858
- width: 280,
859
- className: cx("sider"),
860
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
861
- className: cx("content"),
862
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
863
- className: cx("controls"),
864
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input, {
865
- placeholder: "Search by APIs or Endpoints",
866
- value: searchValue,
867
- onChange: (e) => handleSearch(e.target.value),
868
- allowClear: true,
869
- className: cx("search-input")
870
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
871
- onClick: collapseAll,
872
- title: "Collapse All",
873
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Minify_default, {})
874
- })]
875
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tree, {
876
- showLine: { showLeafIcon: false },
877
- showIcon: false,
878
- expandedKeys,
879
- autoExpandParent,
880
- selectedKeys: selectedNode,
881
- onSelect: onTreeNodeSelect,
882
- onExpand: (expandedKeysValue) => {
883
- setExpandedKeys(expandedKeysValue);
899
+ const handleSearch = (value) => {
900
+ try {
901
+ if (value) {
902
+ const allKeys = safeHelperCall(getAllTreeKeys$1, [builtTreeData], "getAllTreeKeys") || [];
903
+ setExpandedKeys(allKeys);
904
+ setSearchValue(value);
905
+ setAutoExpandParent(true);
906
+ } else {
907
+ setSearchValue(value);
884
908
  setAutoExpandParent(false);
885
- },
886
- treeData: filteredTreeData,
887
- className: cx("tree")
888
- })]
889
- })
890
- }));
909
+ }
910
+ } catch (error) {
911
+ console.error("[Sidebar] Error in handleSearch:", error);
912
+ }
913
+ };
914
+ const renderTreeData = (0, react.useMemo)(() => {
915
+ console.log("[Sidebar] Converting to renderable tree data...");
916
+ return safeHelperCall(convertToRenderableTreeData$1, [
917
+ builtTreeData,
918
+ selectedNode,
919
+ cx
920
+ ], "convertToRenderableTreeData") || [];
921
+ }, [
922
+ builtTreeData,
923
+ selectedNode,
924
+ cx,
925
+ convertToRenderableTreeData$1
926
+ ]);
927
+ const filteredTreeData = (0, react.useMemo)(() => {
928
+ try {
929
+ if (!searchValue) return renderTreeData;
930
+ console.log("[Sidebar] Filtering tree data...");
931
+ const filteredOriginal = safeHelperCall(filterTreeData$1, [builtTreeData, searchValue], "filterTreeData") || [];
932
+ return safeHelperCall(convertToRenderableTreeData$1, [
933
+ filteredOriginal,
934
+ selectedNode,
935
+ cx
936
+ ], "convertToRenderableTreeData for filtered") || [];
937
+ } catch (error) {
938
+ console.error("[Sidebar] Error in filteredTreeData:", error);
939
+ return [];
940
+ }
941
+ }, [
942
+ builtTreeData,
943
+ searchValue,
944
+ selectedNode,
945
+ cx,
946
+ renderTreeData,
947
+ filterTreeData$1,
948
+ convertToRenderableTreeData$1
949
+ ]);
950
+ const collapseAll = () => {
951
+ try {
952
+ setExpandedKeys([]);
953
+ } catch (error) {
954
+ console.error("[Sidebar] Error in collapseAll:", error);
955
+ }
956
+ };
957
+ const handleNodeSelection = (nodeData, nodeKey) => {
958
+ try {
959
+ if (!nodeData) return null;
960
+ if (nodeKey.startsWith("endpoint-")) {
961
+ const endpointNodeData = nodeData;
962
+ setSelectedEndpoint(endpointNodeData.endpoint);
963
+ setSelectedApi(endpointNodeData.api);
964
+ return {
965
+ type: "endpoint",
966
+ endpoint: endpointNodeData.endpoint,
967
+ api: endpointNodeData.api,
968
+ tag: endpointNodeData.tagName
969
+ };
970
+ } else if (nodeKey.startsWith("api-") || nodeKey === "custom-auth") {
971
+ const apiData = nodeData;
972
+ setSelectedApi(apiData);
973
+ setSelectedEndpoint(null);
974
+ return {
975
+ type: "api",
976
+ api: apiData
977
+ };
978
+ } else {
979
+ const tagData = nodeData;
980
+ return {
981
+ type: "tag",
982
+ tag: tagData.tagName,
983
+ api: tagData.apiData
984
+ };
985
+ }
986
+ } catch (error) {
987
+ console.error("[Sidebar] Error in handleNodeSelection:", error);
988
+ return null;
989
+ }
990
+ };
991
+ const onTreeNodeSelect = (selectedKeys) => {
992
+ try {
993
+ const stringKeys = selectedKeys.map((key) => String(key));
994
+ console.log("[Sidebar] onTreeNodeSelect called with:", stringKeys);
995
+ if (stringKeys.length === 0) {
996
+ setSelectedNodeState([]);
997
+ setSelectedApi(null);
998
+ setSelectedEndpoint(null);
999
+ return;
1000
+ }
1001
+ const selectedKey = stringKeys[0];
1002
+ const selectedNode$1 = safeHelperCall(findNodeByKey$1, [builtTreeData, selectedKey], "findNodeByKey");
1003
+ if (selectedNode$1) handleNodeSelection(selectedNode$1.data, selectedKey);
1004
+ setSelectedNodeState(stringKeys);
1005
+ } catch (error) {
1006
+ console.error("[Sidebar] Error in onTreeNodeSelect:", error);
1007
+ }
1008
+ };
1009
+ return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sider, {
1010
+ width: 280,
1011
+ className: cx("sider"),
1012
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1013
+ className: cx("content"),
1014
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1015
+ className: cx("controls"),
1016
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input, {
1017
+ placeholder: "Search by APIs or Endpoints",
1018
+ value: searchValue,
1019
+ onChange: (e) => handleSearch(e.target.value),
1020
+ allowClear: true,
1021
+ className: cx("search-input")
1022
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
1023
+ onClick: collapseAll,
1024
+ title: "Collapse All",
1025
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Minify_default, {})
1026
+ })]
1027
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tree, {
1028
+ showLine: { showLeafIcon: false },
1029
+ showIcon: false,
1030
+ expandedKeys,
1031
+ autoExpandParent,
1032
+ selectedKeys: selectedNode,
1033
+ onSelect: onTreeNodeSelect,
1034
+ onExpand: (expandedKeysValue) => {
1035
+ try {
1036
+ setExpandedKeys(expandedKeysValue);
1037
+ setAutoExpandParent(false);
1038
+ } catch (error) {
1039
+ console.error("[Sidebar] Error in onExpand:", error);
1040
+ }
1041
+ },
1042
+ treeData: filteredTreeData,
1043
+ className: cx("tree")
1044
+ })]
1045
+ })
1046
+ }));
1047
+ } catch (error) {
1048
+ console.error("[Sidebar] Critical error in Sidebar component:", error);
1049
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sider, {
1050
+ width: 280,
1051
+ style: {
1052
+ backgroundColor: "#f5f5f5",
1053
+ border: "1px solid red"
1054
+ },
1055
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1056
+ style: { padding: 16 },
1057
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
1058
+ style: {
1059
+ color: "#ff4d4f",
1060
+ margin: 0
1061
+ },
1062
+ children: "Sidebar Error"
1063
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1064
+ style: {
1065
+ fontSize: "12px",
1066
+ color: "#666",
1067
+ margin: "8px 0 0 0"
1068
+ },
1069
+ children: "Critical error occurred. Check console."
1070
+ })]
1071
+ })
1072
+ });
1073
+ }
891
1074
  };
892
1075
 
893
1076
  //#endregion
@@ -906,34 +1089,50 @@ const MainContent = () => {
906
1089
  };
907
1090
 
908
1091
  //#endregion
909
- //#region src/view/layout.tsx
910
- function ErrorBoundary({ children }) {
911
- const [error, setError] = (0, react.useState)(null);
912
- if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
913
- style: {
914
- color: "red",
915
- padding: 24
916
- },
917
- children: [
918
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "Something went wrong in DocumentationLayout." }),
919
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { children: error.message }),
920
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { children: error.stack })
921
- ]
922
- });
923
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorCatcher, {
924
- onError: setError,
925
- children
926
- });
927
- }
928
- var ErrorCatcher = class extends react.default.Component {
929
- componentDidCatch(error) {
930
- this.props.onError(error);
931
- }
932
- render() {
933
- return this.props.children;
1092
+ //#region src/view/helper/mutate.ts
1093
+ const transformOpenApiToDocs = (api) => {
1094
+ const groupedPathsByTags = { default: [] };
1095
+ const validTags = new Set(api?.tags?.map(({ name }) => name) || []);
1096
+ const contextPath = Object.keys(api.paths)[0];
1097
+ for (const [path, methods] of Object.entries(api.paths)) for (const [method, methodData] of Object.entries(methods)) {
1098
+ const entry = {
1099
+ ...methodData,
1100
+ method: method?.toUpperCase(),
1101
+ path
1102
+ };
1103
+ const resourceTags = methodData.tags ?? [];
1104
+ const matchedTags = resourceTags.filter((tag) => validTags.has(tag));
1105
+ if (matchedTags.length > 0) matchedTags.forEach((tag) => {
1106
+ if (!groupedPathsByTags[tag]) groupedPathsByTags[tag] = [];
1107
+ groupedPathsByTags[tag].push({
1108
+ ...entry,
1109
+ id: `endpoint-${(0, nanoid.nanoid)(8)}`
1110
+ });
1111
+ });
1112
+ else groupedPathsByTags.default.push({
1113
+ ...entry,
1114
+ id: `endpoint-${(0, nanoid.nanoid)(8)}`
1115
+ });
934
1116
  }
1117
+ return {
1118
+ ...api.info,
1119
+ id: `api-${(0, nanoid.nanoid)(8)}`,
1120
+ contextPath,
1121
+ tags: groupedPathsByTags,
1122
+ servers: api.servers
1123
+ };
935
1124
  };
936
- const DocumentationLayout = () => {
1125
+
1126
+ //#endregion
1127
+ //#region src/view/layout.tsx
1128
+ const DocumentationLayout = ({ data }) => {
1129
+ const { setOriginalData } = store_default(({ view }) => view);
1130
+ const { setTransformedData } = store_default(({ view }) => view);
1131
+ (0, react.useEffect)(() => {
1132
+ setOriginalData(data);
1133
+ const transformedData = data.map(transformOpenApiToDocs);
1134
+ setTransformedData(transformedData);
1135
+ }, [data]);
937
1136
  const { cx } = useStyle("DocumentationLayout", (token$1, scope) => ({
938
1137
  [scope("container")]: {
939
1138
  display: "flex",
@@ -951,13 +1150,13 @@ const DocumentationLayout = () => {
951
1150
  gap: token$1.marginLG
952
1151
  }
953
1152
  }));
954
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ant_design_nextjs_registry.AntdRegistry, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1153
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ant_design_nextjs_registry.AntdRegistry, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
955
1154
  className: cx("container"),
956
1155
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Header, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
957
1156
  className: cx("layout"),
958
1157
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {})]
959
1158
  })]
960
- }) }) });
1159
+ }) });
961
1160
  };
962
1161
 
963
1162
  //#endregion