@digi-frontend/dgate-api-documentation 4.0.8 → 4.1.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/dist/index.cjs +37 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +37 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1592,7 +1592,7 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1592
1592
|
};
|
|
1593
1593
|
//#endregion
|
|
1594
1594
|
//#region src/view/components/ApiPage/index.tsx
|
|
1595
|
-
const APIPage = () => {
|
|
1595
|
+
const APIPage = ({ apiOverride }) => {
|
|
1596
1596
|
const [selectedUrl, setSelectedUrl] = useState("");
|
|
1597
1597
|
const { view: { selectedApi, focusedTag, setFocusedTag } } = useStore();
|
|
1598
1598
|
const [viewStyle, setViewStyle] = useState("grid");
|
|
@@ -1638,7 +1638,7 @@ const APIPage = () => {
|
|
|
1638
1638
|
vertical: true,
|
|
1639
1639
|
gap: token.margin,
|
|
1640
1640
|
children: [selectedApi && /* @__PURE__ */ jsx(ViewModeApiHeader, {
|
|
1641
|
-
api: selectedApi,
|
|
1641
|
+
api: apiOverride ?? selectedApi,
|
|
1642
1642
|
viewLayout: viewStyle,
|
|
1643
1643
|
onViewLayoutChange: setViewStyle
|
|
1644
1644
|
}), Object.entries(getEndpointsForSelectedUrl()).sort(([a], [b]) => {
|
|
@@ -7290,7 +7290,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7290
7290
|
if (!desc?.trim()) return Promise.resolve();
|
|
7291
7291
|
if (!link?.trim()) return Promise.reject(/* @__PURE__ */ new Error("External Docs Link is required when Description is filled"));
|
|
7292
7292
|
try {
|
|
7293
|
-
|
|
7293
|
+
if (!/^https?:\/\/[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:[0-9]{1,5})?(\/.*)?$/.test(link)) return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
7294
7294
|
return Promise.resolve();
|
|
7295
7295
|
} catch {
|
|
7296
7296
|
return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
@@ -8485,7 +8485,7 @@ const EndpointPage = () => {
|
|
|
8485
8485
|
};
|
|
8486
8486
|
//#endregion
|
|
8487
8487
|
//#region src/view/console/MainContent.tsx
|
|
8488
|
-
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage }) => {
|
|
8488
|
+
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage, apiOverride }) => {
|
|
8489
8489
|
const { focusedContent, transformedData } = useStore(({ view }) => view);
|
|
8490
8490
|
const { wrapSSR, cx, token } = useStyle("MainContent", (token, scope) => ({
|
|
8491
8491
|
[scope("inner-doc-container")]: {
|
|
@@ -8568,7 +8568,7 @@ const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage
|
|
|
8568
8568
|
children: "Reset Search"
|
|
8569
8569
|
})
|
|
8570
8570
|
]
|
|
8571
|
-
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ jsx(EndpointPage, {}) : /* @__PURE__ */ jsx(APIPage, {})
|
|
8571
|
+
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ jsx(EndpointPage, {}) : /* @__PURE__ */ jsx(APIPage, { apiOverride })
|
|
8572
8572
|
}));
|
|
8573
8573
|
};
|
|
8574
8574
|
//#endregion
|
|
@@ -8652,7 +8652,6 @@ function CodeboxSidebar$1() {
|
|
|
8652
8652
|
const queryParams = params.filter((p) => p.in === "query");
|
|
8653
8653
|
return [`curl --location '${serverUrl}${resolvedPath}${queryParams.length > 0 ? "?" + queryParams.map((p) => `${p.name}=sample-value`).join("&") : ""}'`, ...params.filter((p) => p.in === "header").map((p) => `--header '${p.name}: sample-value'`)];
|
|
8654
8654
|
})();
|
|
8655
|
-
const hasAnyParams = (selectedEndpoint?.parameters ?? []).some((p) => p.in === "header" || p.in === "path" || p.in === "query");
|
|
8656
8655
|
const { token: antdToken, theme: themeConfig } = theme.useToken();
|
|
8657
8656
|
const isDark = themeConfig.id == 1;
|
|
8658
8657
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8774,7 +8773,7 @@ function CodeboxSidebar$1() {
|
|
|
8774
8773
|
}));
|
|
8775
8774
|
return /* @__PURE__ */ jsxs("div", {
|
|
8776
8775
|
className: cx("container"),
|
|
8777
|
-
children: [
|
|
8776
|
+
children: [curlCommand && /* @__PURE__ */ jsxs("div", {
|
|
8778
8777
|
className: cx("rightCard", "rightCardRequest"),
|
|
8779
8778
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
8780
8779
|
className: cx("rightCardHeader"),
|
|
@@ -8978,6 +8977,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
8978
8977
|
const { useBreakpoint } = Grid;
|
|
8979
8978
|
const isMobile = !useBreakpoint().md;
|
|
8980
8979
|
const allEndpoints = useMemo(() => selectedApi ? Object.values(selectedApi.tags ?? {}).flat() : [], [selectedApi]);
|
|
8980
|
+
const viewModeApi = useMemo(() => {
|
|
8981
|
+
if (!selectedApi) return null;
|
|
8982
|
+
if (mode !== "view") return selectedApi;
|
|
8983
|
+
if (localApiName === selectedApi.title && localDescription === selectedApi.description) return selectedApi;
|
|
8984
|
+
return {
|
|
8985
|
+
...selectedApi,
|
|
8986
|
+
title: localApiName,
|
|
8987
|
+
description: localDescription
|
|
8988
|
+
};
|
|
8989
|
+
}, [
|
|
8990
|
+
mode,
|
|
8991
|
+
selectedApi,
|
|
8992
|
+
localApiName,
|
|
8993
|
+
localDescription
|
|
8994
|
+
]);
|
|
8981
8995
|
useEffect(() => {
|
|
8982
8996
|
return () => {
|
|
8983
8997
|
resetStore();
|
|
@@ -9282,6 +9296,12 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9282
9296
|
useEffect(() => {
|
|
9283
9297
|
if (mode !== "view" || !selectedEndpoint) return;
|
|
9284
9298
|
const epId = selectedEndpoint.id;
|
|
9299
|
+
const localName = endpointNames[epId];
|
|
9300
|
+
const localDesc = endpointDescs[epId];
|
|
9301
|
+
const localEpTags = endpointTags[epId];
|
|
9302
|
+
const patchedSummary = localName !== void 0 && localName !== selectedEndpoint.summary ? localName : selectedEndpoint.summary;
|
|
9303
|
+
const patchedDesc = localDesc !== void 0 && localDesc !== selectedEndpoint.description ? localDesc : selectedEndpoint.description;
|
|
9304
|
+
const patchedTags = localEpTags !== void 0 && JSON.stringify(localEpTags) !== JSON.stringify(selectedEndpoint.tags ?? []) ? localEpTags : selectedEndpoint.tags;
|
|
9285
9305
|
const openApiParams = (endpointParams[epId] ?? []).map((p) => ({
|
|
9286
9306
|
name: p.name,
|
|
9287
9307
|
in: p.in,
|
|
@@ -9292,7 +9312,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9292
9312
|
...p.enum && p.enum.length > 0 ? { enum: p.enum } : {}
|
|
9293
9313
|
}
|
|
9294
9314
|
}));
|
|
9295
|
-
if (JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams)) return;
|
|
9296
9315
|
const responseHeadersMap = (endpointResponseParams[epId] ?? []).reduce((acc, p) => {
|
|
9297
9316
|
acc[p.name] = {
|
|
9298
9317
|
schema: {
|
|
@@ -9308,14 +9327,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9308
9327
|
...resp,
|
|
9309
9328
|
headers: Object.keys(responseHeadersMap).length > 0 ? responseHeadersMap : resp.headers
|
|
9310
9329
|
}]));
|
|
9330
|
+
if (selectedEndpoint.summary === patchedSummary && selectedEndpoint.description === patchedDesc && JSON.stringify(selectedEndpoint.tags ?? []) === JSON.stringify(patchedTags ?? []) && JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams) && JSON.stringify(selectedEndpoint.responses) === JSON.stringify(patchedResponses)) return;
|
|
9311
9331
|
setSelectedEndpoint({
|
|
9312
9332
|
...selectedEndpoint,
|
|
9333
|
+
summary: patchedSummary,
|
|
9334
|
+
description: patchedDesc,
|
|
9335
|
+
tags: patchedTags,
|
|
9313
9336
|
parameters: openApiParams,
|
|
9314
9337
|
responses: patchedResponses
|
|
9315
9338
|
});
|
|
9316
9339
|
}, [
|
|
9317
9340
|
mode,
|
|
9318
9341
|
selectedEndpoint,
|
|
9342
|
+
endpointNames,
|
|
9343
|
+
endpointDescs,
|
|
9344
|
+
endpointTags,
|
|
9319
9345
|
endpointParams,
|
|
9320
9346
|
endpointResponseParams,
|
|
9321
9347
|
setSelectedEndpoint
|
|
@@ -9665,7 +9691,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9665
9691
|
/* @__PURE__ */ jsx("div", {
|
|
9666
9692
|
className: cx("section"),
|
|
9667
9693
|
children: /* @__PURE__ */ jsx(ApiDocumentationBar, {
|
|
9668
|
-
apiName:
|
|
9694
|
+
apiName: localApiName,
|
|
9669
9695
|
mode,
|
|
9670
9696
|
onModeChange: setMode,
|
|
9671
9697
|
onReset: () => setResetConfirmModal(true),
|
|
@@ -10024,7 +10050,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10024
10050
|
children: [/* @__PURE__ */ jsx(MainContent, {
|
|
10025
10051
|
handleVisitLandingPage: _handleVisitLandingPage,
|
|
10026
10052
|
handleResetSearch,
|
|
10027
|
-
searchEnabled: !!searchValue
|
|
10053
|
+
searchEnabled: !!searchValue,
|
|
10054
|
+
apiOverride: mode === "view" ? viewModeApi : void 0
|
|
10028
10055
|
}), !isMobile && focusedContent === "ENDPOINT" && /* @__PURE__ */ jsx(CodeboxSidebar$1, {})]
|
|
10029
10056
|
})]
|
|
10030
10057
|
}),
|