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