@digi-frontend/dgate-api-documentation 4.0.8 → 4.1.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 +68 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +68 -30
- 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]) => {
|
|
@@ -6783,7 +6783,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
6783
6783
|
height: 32
|
|
6784
6784
|
}),
|
|
6785
6785
|
disabled: tag.isDefault,
|
|
6786
|
-
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name),
|
|
6786
|
+
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name, tags.findIndex((t) => t.name === tag.name)),
|
|
6787
6787
|
style: {
|
|
6788
6788
|
width: 40,
|
|
6789
6789
|
height: 40,
|
|
@@ -6959,7 +6959,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
6959
6959
|
height: 32
|
|
6960
6960
|
}),
|
|
6961
6961
|
disabled: tag.isDefault,
|
|
6962
|
-
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name),
|
|
6962
|
+
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name, tags.findIndex((t) => t.name === tag.name)),
|
|
6963
6963
|
style: {
|
|
6964
6964
|
width: 40,
|
|
6965
6965
|
height: 40,
|
|
@@ -7002,7 +7002,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
7002
7002
|
const TAG_NAME_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
7003
7003
|
const TAG_DESC_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
7004
7004
|
const EXTERNAL_DOCS_DESC_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
7005
|
-
const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag }) => {
|
|
7005
|
+
const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag, existingTags }) => {
|
|
7006
7006
|
const [form] = antd.Form.useForm();
|
|
7007
7007
|
const [messageApi, contextHolder] = antd.message.useMessage();
|
|
7008
7008
|
const [confirmModalOpen, setConfirmModalOpen] = (0, react$1.useState)(false);
|
|
@@ -7133,7 +7133,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7133
7133
|
}
|
|
7134
7134
|
}));
|
|
7135
7135
|
const isLinkEnabled = Boolean(extDocsDesc?.trim());
|
|
7136
|
-
const isAddEnabled = !!(tagNameValue && TAG_NAME_REGEX.test(tagNameValue));
|
|
7136
|
+
const isAddEnabled = !!(tagNameValue && TAG_NAME_REGEX.test(tagNameValue)) && !form.getFieldsError().some((field) => field.errors.length > 0);
|
|
7137
7137
|
(0, react$1.useEffect)(() => {
|
|
7138
7138
|
if (open && mode === "edit" && initialValues) form.setFieldsValue(initialValues);
|
|
7139
7139
|
if (!open) form.resetFields();
|
|
@@ -7243,7 +7243,13 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7243
7243
|
{
|
|
7244
7244
|
pattern: TAG_NAME_REGEX,
|
|
7245
7245
|
message: "Only letters, numbers, spaces, underscores, and hyphens"
|
|
7246
|
-
}
|
|
7246
|
+
},
|
|
7247
|
+
{ validator: (_, value) => {
|
|
7248
|
+
if (!value || !existingTags?.length) return Promise.resolve();
|
|
7249
|
+
const originalName = initialValues?.name;
|
|
7250
|
+
if (existingTags.some((t) => t.name.toLowerCase() === value.toLowerCase() && t.name.toLowerCase() !== originalName?.toLowerCase())) return Promise.reject(/* @__PURE__ */ new Error("Tag name already exists"));
|
|
7251
|
+
return Promise.resolve();
|
|
7252
|
+
} }
|
|
7247
7253
|
],
|
|
7248
7254
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input, {
|
|
7249
7255
|
showCount: true,
|
|
@@ -7319,7 +7325,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7319
7325
|
if (!desc?.trim()) return Promise.resolve();
|
|
7320
7326
|
if (!link?.trim()) return Promise.reject(/* @__PURE__ */ new Error("External Docs Link is required when Description is filled"));
|
|
7321
7327
|
try {
|
|
7322
|
-
|
|
7328
|
+
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
7329
|
return Promise.resolve();
|
|
7324
7330
|
} catch {
|
|
7325
7331
|
return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
@@ -8514,7 +8520,7 @@ const EndpointPage = () => {
|
|
|
8514
8520
|
};
|
|
8515
8521
|
//#endregion
|
|
8516
8522
|
//#region src/view/console/MainContent.tsx
|
|
8517
|
-
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage }) => {
|
|
8523
|
+
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage, apiOverride }) => {
|
|
8518
8524
|
const { focusedContent, transformedData } = useStore(({ view }) => view);
|
|
8519
8525
|
const { wrapSSR, cx, token } = useStyle("MainContent", (token, scope) => ({
|
|
8520
8526
|
[scope("inner-doc-container")]: {
|
|
@@ -8597,7 +8603,7 @@ const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage
|
|
|
8597
8603
|
children: "Reset Search"
|
|
8598
8604
|
})
|
|
8599
8605
|
]
|
|
8600
|
-
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPage, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(APIPage, {})
|
|
8606
|
+
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPage, {}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(APIPage, { apiOverride })
|
|
8601
8607
|
}));
|
|
8602
8608
|
};
|
|
8603
8609
|
//#endregion
|
|
@@ -8681,7 +8687,6 @@ function CodeboxSidebar$1() {
|
|
|
8681
8687
|
const queryParams = params.filter((p) => p.in === "query");
|
|
8682
8688
|
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
8689
|
})();
|
|
8684
|
-
const hasAnyParams = (selectedEndpoint?.parameters ?? []).some((p) => p.in === "header" || p.in === "path" || p.in === "query");
|
|
8685
8690
|
const { token: antdToken, theme: themeConfig } = antd.theme.useToken();
|
|
8686
8691
|
const isDark = themeConfig.id == 1;
|
|
8687
8692
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8803,7 +8808,7 @@ function CodeboxSidebar$1() {
|
|
|
8803
8808
|
}));
|
|
8804
8809
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8805
8810
|
className: cx("container"),
|
|
8806
|
-
children: [
|
|
8811
|
+
children: [curlCommand && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8807
8812
|
className: cx("rightCard", "rightCardRequest"),
|
|
8808
8813
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
8809
8814
|
className: cx("rightCardHeader"),
|
|
@@ -8997,7 +9002,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
8997
9002
|
});
|
|
8998
9003
|
const [deleteTagModal, setDeleteTagModal] = (0, react$1.useState)({
|
|
8999
9004
|
open: false,
|
|
9000
|
-
|
|
9005
|
+
tagIndex: -1
|
|
9001
9006
|
});
|
|
9002
9007
|
const [localTags, setLocalTags] = (0, react$1.useState)([]);
|
|
9003
9008
|
const [messageApi, contextHolder] = antd.message.useMessage();
|
|
@@ -9007,6 +9012,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9007
9012
|
const { useBreakpoint } = antd.Grid;
|
|
9008
9013
|
const isMobile = !useBreakpoint().md;
|
|
9009
9014
|
const allEndpoints = (0, react$1.useMemo)(() => selectedApi ? Object.values(selectedApi.tags ?? {}).flat() : [], [selectedApi]);
|
|
9015
|
+
const viewModeApi = (0, react$1.useMemo)(() => {
|
|
9016
|
+
if (!selectedApi) return null;
|
|
9017
|
+
if (mode !== "view") return selectedApi;
|
|
9018
|
+
if (localApiName === selectedApi.title && localDescription === selectedApi.description) return selectedApi;
|
|
9019
|
+
return {
|
|
9020
|
+
...selectedApi,
|
|
9021
|
+
title: localApiName,
|
|
9022
|
+
description: localDescription
|
|
9023
|
+
};
|
|
9024
|
+
}, [
|
|
9025
|
+
mode,
|
|
9026
|
+
selectedApi,
|
|
9027
|
+
localApiName,
|
|
9028
|
+
localDescription
|
|
9029
|
+
]);
|
|
9010
9030
|
(0, react$1.useEffect)(() => {
|
|
9011
9031
|
return () => {
|
|
9012
9032
|
resetStore();
|
|
@@ -9159,7 +9179,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9159
9179
|
externalDocsDescription: t.externalDocs?.description,
|
|
9160
9180
|
isDefault: t.name.toLowerCase() === "default"
|
|
9161
9181
|
})) ?? [];
|
|
9162
|
-
|
|
9182
|
+
const hasDefault = mapped.some((t) => t.isDefault);
|
|
9183
|
+
const hasDefaultInMapped = mapped.some((t) => t.name.toLowerCase() === "default");
|
|
9184
|
+
if (!hasDefault && !hasDefaultInMapped && selectedApi.tags["default"]) mapped.push({
|
|
9163
9185
|
name: "default",
|
|
9164
9186
|
isDefault: true
|
|
9165
9187
|
});
|
|
@@ -9311,6 +9333,12 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9311
9333
|
(0, react$1.useEffect)(() => {
|
|
9312
9334
|
if (mode !== "view" || !selectedEndpoint) return;
|
|
9313
9335
|
const epId = selectedEndpoint.id;
|
|
9336
|
+
const localName = endpointNames[epId];
|
|
9337
|
+
const localDesc = endpointDescs[epId];
|
|
9338
|
+
const localEpTags = endpointTags[epId];
|
|
9339
|
+
const patchedSummary = localName !== void 0 && localName !== selectedEndpoint.summary ? localName : selectedEndpoint.summary;
|
|
9340
|
+
const patchedDesc = localDesc !== void 0 && localDesc !== selectedEndpoint.description ? localDesc : selectedEndpoint.description;
|
|
9341
|
+
const patchedTags = localEpTags !== void 0 && JSON.stringify(localEpTags) !== JSON.stringify(selectedEndpoint.tags ?? []) ? localEpTags : selectedEndpoint.tags;
|
|
9314
9342
|
const openApiParams = (endpointParams[epId] ?? []).map((p) => ({
|
|
9315
9343
|
name: p.name,
|
|
9316
9344
|
in: p.in,
|
|
@@ -9321,7 +9349,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9321
9349
|
...p.enum && p.enum.length > 0 ? { enum: p.enum } : {}
|
|
9322
9350
|
}
|
|
9323
9351
|
}));
|
|
9324
|
-
if (JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams)) return;
|
|
9325
9352
|
const responseHeadersMap = (endpointResponseParams[epId] ?? []).reduce((acc, p) => {
|
|
9326
9353
|
acc[p.name] = {
|
|
9327
9354
|
schema: {
|
|
@@ -9337,14 +9364,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9337
9364
|
...resp,
|
|
9338
9365
|
headers: Object.keys(responseHeadersMap).length > 0 ? responseHeadersMap : resp.headers
|
|
9339
9366
|
}]));
|
|
9367
|
+
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
9368
|
setSelectedEndpoint({
|
|
9341
9369
|
...selectedEndpoint,
|
|
9370
|
+
summary: patchedSummary,
|
|
9371
|
+
description: patchedDesc,
|
|
9372
|
+
tags: patchedTags,
|
|
9342
9373
|
parameters: openApiParams,
|
|
9343
9374
|
responses: patchedResponses
|
|
9344
9375
|
});
|
|
9345
9376
|
}, [
|
|
9346
9377
|
mode,
|
|
9347
9378
|
selectedEndpoint,
|
|
9379
|
+
endpointNames,
|
|
9380
|
+
endpointDescs,
|
|
9381
|
+
endpointTags,
|
|
9348
9382
|
endpointParams,
|
|
9349
9383
|
endpointResponseParams,
|
|
9350
9384
|
setSelectedEndpoint
|
|
@@ -9372,11 +9406,13 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9372
9406
|
setBannerVisible(true);
|
|
9373
9407
|
};
|
|
9374
9408
|
const handleDeleteTagConfirm = () => {
|
|
9375
|
-
|
|
9376
|
-
|
|
9409
|
+
if (deleteTagModal.tagIndex < 0) return;
|
|
9410
|
+
const tagName = localTags[deleteTagModal.tagIndex]?.name ?? "Tag";
|
|
9411
|
+
setLocalTags((prev) => prev.filter((_, index) => index !== deleteTagModal.tagIndex));
|
|
9412
|
+
messageApi.success(`${tagName} tag has been deleted successfully.`);
|
|
9377
9413
|
setDeleteTagModal({
|
|
9378
9414
|
open: false,
|
|
9379
|
-
|
|
9415
|
+
tagIndex: -1
|
|
9380
9416
|
});
|
|
9381
9417
|
setBannerVisible(true);
|
|
9382
9418
|
};
|
|
@@ -9694,7 +9730,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9694
9730
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9695
9731
|
className: cx("section"),
|
|
9696
9732
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiDocumentationBar, {
|
|
9697
|
-
apiName:
|
|
9733
|
+
apiName: localApiName,
|
|
9698
9734
|
mode,
|
|
9699
9735
|
onModeChange: setMode,
|
|
9700
9736
|
onReset: () => setResetConfirmModal(true),
|
|
@@ -9775,9 +9811,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9775
9811
|
externalDocsLink: tag.externalDocsUrl
|
|
9776
9812
|
}
|
|
9777
9813
|
}),
|
|
9778
|
-
onDeleteTag: (
|
|
9814
|
+
onDeleteTag: (_tagName, tagIndex) => setDeleteTagModal({
|
|
9779
9815
|
open: true,
|
|
9780
|
-
|
|
9816
|
+
tagIndex
|
|
9781
9817
|
})
|
|
9782
9818
|
})
|
|
9783
9819
|
}),
|
|
@@ -9937,9 +9973,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9937
9973
|
externalDocsLink: tag.externalDocsUrl
|
|
9938
9974
|
}
|
|
9939
9975
|
}),
|
|
9940
|
-
onDeleteTag: (
|
|
9976
|
+
onDeleteTag: (_tagName, tagIndex) => setDeleteTagModal({
|
|
9941
9977
|
open: true,
|
|
9942
|
-
|
|
9978
|
+
tagIndex
|
|
9943
9979
|
})
|
|
9944
9980
|
})
|
|
9945
9981
|
}),
|
|
@@ -10053,7 +10089,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10053
10089
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {
|
|
10054
10090
|
handleVisitLandingPage: _handleVisitLandingPage,
|
|
10055
10091
|
handleResetSearch,
|
|
10056
|
-
searchEnabled: !!searchValue
|
|
10092
|
+
searchEnabled: !!searchValue,
|
|
10093
|
+
apiOverride: mode === "view" ? viewModeApi : void 0
|
|
10057
10094
|
}), !isMobile && focusedContent === "ENDPOINT" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeboxSidebar$1, {})]
|
|
10058
10095
|
})]
|
|
10059
10096
|
}),
|
|
@@ -10066,7 +10103,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10066
10103
|
mode: "add"
|
|
10067
10104
|
}),
|
|
10068
10105
|
onAddTag: handleAddTag,
|
|
10069
|
-
onEditTag: handleUpdateTag
|
|
10106
|
+
onEditTag: handleUpdateTag,
|
|
10107
|
+
existingTags: localTags
|
|
10070
10108
|
}),
|
|
10071
10109
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(antd.Modal, {
|
|
10072
10110
|
open: saveConfirmModal,
|
|
@@ -10210,7 +10248,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10210
10248
|
open: deleteTagModal.open,
|
|
10211
10249
|
onCancel: () => setDeleteTagModal({
|
|
10212
10250
|
open: false,
|
|
10213
|
-
|
|
10251
|
+
tagIndex: -1
|
|
10214
10252
|
}),
|
|
10215
10253
|
centered: true,
|
|
10216
10254
|
title: null,
|
|
@@ -10236,14 +10274,14 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10236
10274
|
className: cx("deleteModalTitle"),
|
|
10237
10275
|
children: [
|
|
10238
10276
|
"Delete ",
|
|
10239
|
-
deleteTagModal.
|
|
10277
|
+
localTags[deleteTagModal.tagIndex]?.name ?? "Tag",
|
|
10240
10278
|
" tag"
|
|
10241
10279
|
]
|
|
10242
10280
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
10243
10281
|
className: cx("deleteModalCloseBtn"),
|
|
10244
10282
|
onClick: () => setDeleteTagModal({
|
|
10245
10283
|
open: false,
|
|
10246
|
-
|
|
10284
|
+
tagIndex: -1
|
|
10247
10285
|
}),
|
|
10248
10286
|
"aria-label": "Close",
|
|
10249
10287
|
children: "×"
|
|
@@ -10255,7 +10293,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10255
10293
|
className: cx("deleteModalContentText"),
|
|
10256
10294
|
children: [
|
|
10257
10295
|
"Are you sure you want to delete ",
|
|
10258
|
-
deleteTagModal.
|
|
10296
|
+
localTags[deleteTagModal.tagIndex]?.name ?? "Tag",
|
|
10259
10297
|
" tag?"
|
|
10260
10298
|
]
|
|
10261
10299
|
})
|
|
@@ -10266,7 +10304,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10266
10304
|
size: "middle",
|
|
10267
10305
|
onClick: () => setDeleteTagModal({
|
|
10268
10306
|
open: false,
|
|
10269
|
-
|
|
10307
|
+
tagIndex: -1
|
|
10270
10308
|
}),
|
|
10271
10309
|
style: {
|
|
10272
10310
|
borderRadius: 8,
|