@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.cjs
CHANGED
|
@@ -1621,7 +1621,7 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1621
1621
|
};
|
|
1622
1622
|
//#endregion
|
|
1623
1623
|
//#region src/view/components/ApiPage/index.tsx
|
|
1624
|
-
const APIPage = () => {
|
|
1624
|
+
const APIPage = ({ apiOverride }) => {
|
|
1625
1625
|
const [selectedUrl, setSelectedUrl] = (0, react$1.useState)("");
|
|
1626
1626
|
const { view: { selectedApi, focusedTag, setFocusedTag } } = useStore();
|
|
1627
1627
|
const [viewStyle, setViewStyle] = (0, react$1.useState)("grid");
|
|
@@ -1667,7 +1667,7 @@ const APIPage = () => {
|
|
|
1667
1667
|
vertical: true,
|
|
1668
1668
|
gap: token.margin,
|
|
1669
1669
|
children: [selectedApi && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewModeApiHeader, {
|
|
1670
|
-
api: selectedApi,
|
|
1670
|
+
api: apiOverride ?? selectedApi,
|
|
1671
1671
|
viewLayout: viewStyle,
|
|
1672
1672
|
onViewLayoutChange: setViewStyle
|
|
1673
1673
|
}), Object.entries(getEndpointsForSelectedUrl()).sort(([a], [b]) => {
|
|
@@ -7319,7 +7319,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7319
7319
|
if (!desc?.trim()) return Promise.resolve();
|
|
7320
7320
|
if (!link?.trim()) return Promise.reject(/* @__PURE__ */ new Error("External Docs Link is required when Description is filled"));
|
|
7321
7321
|
try {
|
|
7322
|
-
|
|
7322
|
+
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"));
|
|
7323
7323
|
return Promise.resolve();
|
|
7324
7324
|
} catch {
|
|
7325
7325
|
return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
@@ -8514,7 +8514,7 @@ const EndpointPage = () => {
|
|
|
8514
8514
|
};
|
|
8515
8515
|
//#endregion
|
|
8516
8516
|
//#region src/view/console/MainContent.tsx
|
|
8517
|
-
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage }) => {
|
|
8517
|
+
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage, apiOverride }) => {
|
|
8518
8518
|
const { focusedContent, transformedData } = useStore(({ view }) => view);
|
|
8519
8519
|
const { wrapSSR, cx, token } = useStyle("MainContent", (token, scope) => ({
|
|
8520
8520
|
[scope("inner-doc-container")]: {
|
|
@@ -8597,7 +8597,7 @@ const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage
|
|
|
8597
8597
|
children: "Reset Search"
|
|
8598
8598
|
})
|
|
8599
8599
|
]
|
|
8600
|
-
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPage, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(APIPage, {})
|
|
8600
|
+
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPage, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(APIPage, { apiOverride })
|
|
8601
8601
|
}));
|
|
8602
8602
|
};
|
|
8603
8603
|
//#endregion
|
|
@@ -8681,7 +8681,6 @@ function CodeboxSidebar$1() {
|
|
|
8681
8681
|
const queryParams = params.filter((p) => p.in === "query");
|
|
8682
8682
|
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'`)];
|
|
8683
8683
|
})();
|
|
8684
|
-
const hasAnyParams = (selectedEndpoint?.parameters ?? []).some((p) => p.in === "header" || p.in === "path" || p.in === "query");
|
|
8685
8684
|
const { token: antdToken, theme: themeConfig } = antd.theme.useToken();
|
|
8686
8685
|
const isDark = themeConfig.id == 1;
|
|
8687
8686
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8803,7 +8802,7 @@ function CodeboxSidebar$1() {
|
|
|
8803
8802
|
}));
|
|
8804
8803
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8805
8804
|
className: cx("container"),
|
|
8806
|
-
children: [
|
|
8805
|
+
children: [curlCommand && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8807
8806
|
className: cx("rightCard", "rightCardRequest"),
|
|
8808
8807
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8809
8808
|
className: cx("rightCardHeader"),
|
|
@@ -9007,6 +9006,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9007
9006
|
const { useBreakpoint } = antd.Grid;
|
|
9008
9007
|
const isMobile = !useBreakpoint().md;
|
|
9009
9008
|
const allEndpoints = (0, react$1.useMemo)(() => selectedApi ? Object.values(selectedApi.tags ?? {}).flat() : [], [selectedApi]);
|
|
9009
|
+
const viewModeApi = (0, react$1.useMemo)(() => {
|
|
9010
|
+
if (!selectedApi) return null;
|
|
9011
|
+
if (mode !== "view") return selectedApi;
|
|
9012
|
+
if (localApiName === selectedApi.title && localDescription === selectedApi.description) return selectedApi;
|
|
9013
|
+
return {
|
|
9014
|
+
...selectedApi,
|
|
9015
|
+
title: localApiName,
|
|
9016
|
+
description: localDescription
|
|
9017
|
+
};
|
|
9018
|
+
}, [
|
|
9019
|
+
mode,
|
|
9020
|
+
selectedApi,
|
|
9021
|
+
localApiName,
|
|
9022
|
+
localDescription
|
|
9023
|
+
]);
|
|
9010
9024
|
(0, react$1.useEffect)(() => {
|
|
9011
9025
|
return () => {
|
|
9012
9026
|
resetStore();
|
|
@@ -9311,6 +9325,12 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9311
9325
|
(0, react$1.useEffect)(() => {
|
|
9312
9326
|
if (mode !== "view" || !selectedEndpoint) return;
|
|
9313
9327
|
const epId = selectedEndpoint.id;
|
|
9328
|
+
const localName = endpointNames[epId];
|
|
9329
|
+
const localDesc = endpointDescs[epId];
|
|
9330
|
+
const localEpTags = endpointTags[epId];
|
|
9331
|
+
const patchedSummary = localName !== void 0 && localName !== selectedEndpoint.summary ? localName : selectedEndpoint.summary;
|
|
9332
|
+
const patchedDesc = localDesc !== void 0 && localDesc !== selectedEndpoint.description ? localDesc : selectedEndpoint.description;
|
|
9333
|
+
const patchedTags = localEpTags !== void 0 && JSON.stringify(localEpTags) !== JSON.stringify(selectedEndpoint.tags ?? []) ? localEpTags : selectedEndpoint.tags;
|
|
9314
9334
|
const openApiParams = (endpointParams[epId] ?? []).map((p) => ({
|
|
9315
9335
|
name: p.name,
|
|
9316
9336
|
in: p.in,
|
|
@@ -9321,7 +9341,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9321
9341
|
...p.enum && p.enum.length > 0 ? { enum: p.enum } : {}
|
|
9322
9342
|
}
|
|
9323
9343
|
}));
|
|
9324
|
-
if (JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams)) return;
|
|
9325
9344
|
const responseHeadersMap = (endpointResponseParams[epId] ?? []).reduce((acc, p) => {
|
|
9326
9345
|
acc[p.name] = {
|
|
9327
9346
|
schema: {
|
|
@@ -9337,14 +9356,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9337
9356
|
...resp,
|
|
9338
9357
|
headers: Object.keys(responseHeadersMap).length > 0 ? responseHeadersMap : resp.headers
|
|
9339
9358
|
}]));
|
|
9359
|
+
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;
|
|
9340
9360
|
setSelectedEndpoint({
|
|
9341
9361
|
...selectedEndpoint,
|
|
9362
|
+
summary: patchedSummary,
|
|
9363
|
+
description: patchedDesc,
|
|
9364
|
+
tags: patchedTags,
|
|
9342
9365
|
parameters: openApiParams,
|
|
9343
9366
|
responses: patchedResponses
|
|
9344
9367
|
});
|
|
9345
9368
|
}, [
|
|
9346
9369
|
mode,
|
|
9347
9370
|
selectedEndpoint,
|
|
9371
|
+
endpointNames,
|
|
9372
|
+
endpointDescs,
|
|
9373
|
+
endpointTags,
|
|
9348
9374
|
endpointParams,
|
|
9349
9375
|
endpointResponseParams,
|
|
9350
9376
|
setSelectedEndpoint
|
|
@@ -9694,7 +9720,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9694
9720
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9695
9721
|
className: cx("section"),
|
|
9696
9722
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiDocumentationBar, {
|
|
9697
|
-
apiName:
|
|
9723
|
+
apiName: localApiName,
|
|
9698
9724
|
mode,
|
|
9699
9725
|
onModeChange: setMode,
|
|
9700
9726
|
onReset: () => setResetConfirmModal(true),
|
|
@@ -10053,7 +10079,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10053
10079
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {
|
|
10054
10080
|
handleVisitLandingPage: _handleVisitLandingPage,
|
|
10055
10081
|
handleResetSearch,
|
|
10056
|
-
searchEnabled: !!searchValue
|
|
10082
|
+
searchEnabled: !!searchValue,
|
|
10083
|
+
apiOverride: mode === "view" ? viewModeApi : void 0
|
|
10057
10084
|
}), !isMobile && focusedContent === "ENDPOINT" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeboxSidebar$1, {})]
|
|
10058
10085
|
})]
|
|
10059
10086
|
}),
|