@digi-frontend/dgate-api-documentation 4.0.7 → 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 +49 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +49 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,6 @@ let react_syntax_highlighter_dist_esm_languages_hljs_json_js = require("react-sy
|
|
|
41
41
|
react_syntax_highlighter_dist_esm_languages_hljs_json_js = __toESM(react_syntax_highlighter_dist_esm_languages_hljs_json_js, 1);
|
|
42
42
|
let react_syntax_highlighter_dist_esm_styles_hljs_index_js = require("react-syntax-highlighter/dist/esm/styles/hljs/index.js");
|
|
43
43
|
react_syntax_highlighter_dist_esm_styles_hljs_index_js = __toESM(react_syntax_highlighter_dist_esm_styles_hljs_index_js, 1);
|
|
44
|
-
let nanoid = require("nanoid");
|
|
45
44
|
//#region src/store/slices/view.ts
|
|
46
45
|
const createViewSlice = (set) => ({ view: {
|
|
47
46
|
selectedNodeKey: null,
|
|
@@ -1622,7 +1621,7 @@ const ViewModeApiHeader = ({ api, viewLayout, onViewLayoutChange }) => {
|
|
|
1622
1621
|
};
|
|
1623
1622
|
//#endregion
|
|
1624
1623
|
//#region src/view/components/ApiPage/index.tsx
|
|
1625
|
-
const APIPage = () => {
|
|
1624
|
+
const APIPage = ({ apiOverride }) => {
|
|
1626
1625
|
const [selectedUrl, setSelectedUrl] = (0, react$1.useState)("");
|
|
1627
1626
|
const { view: { selectedApi, focusedTag, setFocusedTag } } = useStore();
|
|
1628
1627
|
const [viewStyle, setViewStyle] = (0, react$1.useState)("grid");
|
|
@@ -1668,7 +1667,7 @@ const APIPage = () => {
|
|
|
1668
1667
|
vertical: true,
|
|
1669
1668
|
gap: token.margin,
|
|
1670
1669
|
children: [selectedApi && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewModeApiHeader, {
|
|
1671
|
-
api: selectedApi,
|
|
1670
|
+
api: apiOverride ?? selectedApi,
|
|
1672
1671
|
viewLayout: viewStyle,
|
|
1673
1672
|
onViewLayoutChange: setViewStyle
|
|
1674
1673
|
}), Object.entries(getEndpointsForSelectedUrl()).sort(([a], [b]) => {
|
|
@@ -7320,7 +7319,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7320
7319
|
if (!desc?.trim()) return Promise.resolve();
|
|
7321
7320
|
if (!link?.trim()) return Promise.reject(/* @__PURE__ */ new Error("External Docs Link is required when Description is filled"));
|
|
7322
7321
|
try {
|
|
7323
|
-
|
|
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"));
|
|
7324
7323
|
return Promise.resolve();
|
|
7325
7324
|
} catch {
|
|
7326
7325
|
return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
@@ -8515,7 +8514,7 @@ const EndpointPage = () => {
|
|
|
8515
8514
|
};
|
|
8516
8515
|
//#endregion
|
|
8517
8516
|
//#region src/view/console/MainContent.tsx
|
|
8518
|
-
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage }) => {
|
|
8517
|
+
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage, apiOverride }) => {
|
|
8519
8518
|
const { focusedContent, transformedData } = useStore(({ view }) => view);
|
|
8520
8519
|
const { wrapSSR, cx, token } = useStyle("MainContent", (token, scope) => ({
|
|
8521
8520
|
[scope("inner-doc-container")]: {
|
|
@@ -8598,7 +8597,7 @@ const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage
|
|
|
8598
8597
|
children: "Reset Search"
|
|
8599
8598
|
})
|
|
8600
8599
|
]
|
|
8601
|
-
}) : 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 })
|
|
8602
8601
|
}));
|
|
8603
8602
|
};
|
|
8604
8603
|
//#endregion
|
|
@@ -8682,7 +8681,6 @@ function CodeboxSidebar$1() {
|
|
|
8682
8681
|
const queryParams = params.filter((p) => p.in === "query");
|
|
8683
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'`)];
|
|
8684
8683
|
})();
|
|
8685
|
-
const hasAnyParams = (selectedEndpoint?.parameters ?? []).some((p) => p.in === "header" || p.in === "path" || p.in === "query");
|
|
8686
8684
|
const { token: antdToken, theme: themeConfig } = antd.theme.useToken();
|
|
8687
8685
|
const isDark = themeConfig.id == 1;
|
|
8688
8686
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8804,7 +8802,7 @@ function CodeboxSidebar$1() {
|
|
|
8804
8802
|
}));
|
|
8805
8803
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8806
8804
|
className: cx("container"),
|
|
8807
|
-
children: [
|
|
8805
|
+
children: [curlCommand && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8808
8806
|
className: cx("rightCard", "rightCardRequest"),
|
|
8809
8807
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8810
8808
|
className: cx("rightCardHeader"),
|
|
@@ -8859,6 +8857,15 @@ function CodeboxSidebar$1() {
|
|
|
8859
8857
|
}
|
|
8860
8858
|
//#endregion
|
|
8861
8859
|
//#region src/view/helper/mutate.ts
|
|
8860
|
+
/**
|
|
8861
|
+
* Simple deterministic string hash (djb2 variant).
|
|
8862
|
+
* Produces a stable, short base-36 hash for the same input.
|
|
8863
|
+
*/
|
|
8864
|
+
const stableHash = (input) => {
|
|
8865
|
+
let hash = 5381;
|
|
8866
|
+
for (let i = 0; i < input.length; i++) hash = (hash << 5) + hash + input.charCodeAt(i);
|
|
8867
|
+
return (hash >>> 0).toString(36);
|
|
8868
|
+
};
|
|
8862
8869
|
const resolveSchema = (schema, components) => {
|
|
8863
8870
|
if (!schema) return void 0;
|
|
8864
8871
|
if (!schema.$ref) return schema;
|
|
@@ -8921,14 +8928,14 @@ const transformOpenApiToDocs = (api) => {
|
|
|
8921
8928
|
if (!groupedPathsByTags[tag]) groupedPathsByTags[tag] = [];
|
|
8922
8929
|
groupedPathsByTags[tag].push({
|
|
8923
8930
|
...entry,
|
|
8924
|
-
id: `endpoint-${(
|
|
8931
|
+
id: `endpoint-${stableHash(entry.method + "-" + entry.path)}`
|
|
8925
8932
|
});
|
|
8926
8933
|
});
|
|
8927
8934
|
else {
|
|
8928
8935
|
if (!groupedPathsByTags.default) groupedPathsByTags.default = [];
|
|
8929
8936
|
groupedPathsByTags.default.push({
|
|
8930
8937
|
...entry,
|
|
8931
|
-
id: `endpoint-${(
|
|
8938
|
+
id: `endpoint-${stableHash(entry.method + "-" + entry.path)}`
|
|
8932
8939
|
});
|
|
8933
8940
|
}
|
|
8934
8941
|
}
|
|
@@ -8942,7 +8949,7 @@ const transformOpenApiToDocs = (api) => {
|
|
|
8942
8949
|
}, {});
|
|
8943
8950
|
return {
|
|
8944
8951
|
...api.info,
|
|
8945
|
-
id: `api-${
|
|
8952
|
+
id: `api-${contextPath ?? "unknown"}`,
|
|
8946
8953
|
contextPath,
|
|
8947
8954
|
tags: sortedGroupedPathsByTags,
|
|
8948
8955
|
servers: api.servers,
|
|
@@ -8999,6 +9006,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
8999
9006
|
const { useBreakpoint } = antd.Grid;
|
|
9000
9007
|
const isMobile = !useBreakpoint().md;
|
|
9001
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
|
+
]);
|
|
9002
9024
|
(0, react$1.useEffect)(() => {
|
|
9003
9025
|
return () => {
|
|
9004
9026
|
resetStore();
|
|
@@ -9303,6 +9325,12 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9303
9325
|
(0, react$1.useEffect)(() => {
|
|
9304
9326
|
if (mode !== "view" || !selectedEndpoint) return;
|
|
9305
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;
|
|
9306
9334
|
const openApiParams = (endpointParams[epId] ?? []).map((p) => ({
|
|
9307
9335
|
name: p.name,
|
|
9308
9336
|
in: p.in,
|
|
@@ -9313,7 +9341,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9313
9341
|
...p.enum && p.enum.length > 0 ? { enum: p.enum } : {}
|
|
9314
9342
|
}
|
|
9315
9343
|
}));
|
|
9316
|
-
if (JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams)) return;
|
|
9317
9344
|
const responseHeadersMap = (endpointResponseParams[epId] ?? []).reduce((acc, p) => {
|
|
9318
9345
|
acc[p.name] = {
|
|
9319
9346
|
schema: {
|
|
@@ -9329,14 +9356,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9329
9356
|
...resp,
|
|
9330
9357
|
headers: Object.keys(responseHeadersMap).length > 0 ? responseHeadersMap : resp.headers
|
|
9331
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;
|
|
9332
9360
|
setSelectedEndpoint({
|
|
9333
9361
|
...selectedEndpoint,
|
|
9362
|
+
summary: patchedSummary,
|
|
9363
|
+
description: patchedDesc,
|
|
9364
|
+
tags: patchedTags,
|
|
9334
9365
|
parameters: openApiParams,
|
|
9335
9366
|
responses: patchedResponses
|
|
9336
9367
|
});
|
|
9337
9368
|
}, [
|
|
9338
9369
|
mode,
|
|
9339
9370
|
selectedEndpoint,
|
|
9371
|
+
endpointNames,
|
|
9372
|
+
endpointDescs,
|
|
9373
|
+
endpointTags,
|
|
9340
9374
|
endpointParams,
|
|
9341
9375
|
endpointResponseParams,
|
|
9342
9376
|
setSelectedEndpoint
|
|
@@ -9686,7 +9720,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9686
9720
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9687
9721
|
className: cx("section"),
|
|
9688
9722
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiDocumentationBar, {
|
|
9689
|
-
apiName:
|
|
9723
|
+
apiName: localApiName,
|
|
9690
9724
|
mode,
|
|
9691
9725
|
onModeChange: setMode,
|
|
9692
9726
|
onReset: () => setResetConfirmModal(true),
|
|
@@ -10045,7 +10079,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10045
10079
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {
|
|
10046
10080
|
handleVisitLandingPage: _handleVisitLandingPage,
|
|
10047
10081
|
handleResetSearch,
|
|
10048
|
-
searchEnabled: !!searchValue
|
|
10082
|
+
searchEnabled: !!searchValue,
|
|
10083
|
+
apiOverride: mode === "view" ? viewModeApi : void 0
|
|
10049
10084
|
}), !isMobile && focusedContent === "ENDPOINT" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeboxSidebar$1, {})]
|
|
10050
10085
|
})]
|
|
10051
10086
|
}),
|