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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -112,7 +112,6 @@ const createStore = (set) => ({
112
112
  ...createEditorSlice(set)
113
113
  });
114
114
  const useStore = (0, zustand.create)()((0, zustand_middleware.devtools)((0, zustand_middleware_immer.immer)(createStore), { name: "dgate-docs-store" }));
115
- var store_default = useStore;
116
115
 
117
116
  //#endregion
118
117
  //#region src/hooks/useStyle.ts
@@ -907,50 +906,34 @@ const MainContent = () => {
907
906
  };
908
907
 
909
908
  //#endregion
910
- //#region src/view/helper/mutate.ts
911
- const transformOpenApiToDocs = (api) => {
912
- const groupedPathsByTags = { default: [] };
913
- const validTags = new Set(api?.tags?.map(({ name }) => name) || []);
914
- const contextPath = Object.keys(api.paths)[0];
915
- for (const [path, methods] of Object.entries(api.paths)) for (const [method, methodData] of Object.entries(methods)) {
916
- const entry = {
917
- ...methodData,
918
- method: method?.toUpperCase(),
919
- path
920
- };
921
- const resourceTags = methodData.tags ?? [];
922
- const matchedTags = resourceTags.filter((tag) => validTags.has(tag));
923
- if (matchedTags.length > 0) matchedTags.forEach((tag) => {
924
- if (!groupedPathsByTags[tag]) groupedPathsByTags[tag] = [];
925
- groupedPathsByTags[tag].push({
926
- ...entry,
927
- id: `endpoint-${(0, nanoid.nanoid)(8)}`
928
- });
929
- });
930
- else groupedPathsByTags.default.push({
931
- ...entry,
932
- id: `endpoint-${(0, nanoid.nanoid)(8)}`
933
- });
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;
934
934
  }
935
- return {
936
- ...api.info,
937
- id: `api-${(0, nanoid.nanoid)(8)}`,
938
- contextPath,
939
- tags: groupedPathsByTags,
940
- servers: api.servers
941
- };
942
935
  };
943
-
944
- //#endregion
945
- //#region src/view/layout.tsx
946
- const DocumentationLayout = ({ data }) => {
947
- const { setOriginalData } = store_default(({ view }) => view);
948
- const { setTransformedData } = store_default(({ view }) => view);
949
- (0, react.useEffect)(() => {
950
- setOriginalData(data);
951
- const transformedData = data.map(transformOpenApiToDocs);
952
- setTransformedData(transformedData);
953
- }, [data]);
936
+ const DocumentationLayout = () => {
954
937
  const { cx } = useStyle("DocumentationLayout", (token$1, scope) => ({
955
938
  [scope("container")]: {
956
939
  display: "flex",
@@ -968,13 +951,13 @@ const DocumentationLayout = ({ data }) => {
968
951
  gap: token$1.marginLG
969
952
  }
970
953
  }));
971
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ant_design_nextjs_registry.AntdRegistry, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
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", {
972
955
  className: cx("container"),
973
956
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Header, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
974
957
  className: cx("layout"),
975
958
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {})]
976
959
  })]
977
- }) });
960
+ }) }) });
978
961
  };
979
962
 
980
963
  //#endregion