@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.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]) => {
|
|
@@ -6754,7 +6754,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
6754
6754
|
height: 32
|
|
6755
6755
|
}),
|
|
6756
6756
|
disabled: tag.isDefault,
|
|
6757
|
-
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name),
|
|
6757
|
+
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name, tags.findIndex((t) => t.name === tag.name)),
|
|
6758
6758
|
style: {
|
|
6759
6759
|
width: 40,
|
|
6760
6760
|
height: 40,
|
|
@@ -6930,7 +6930,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
6930
6930
|
height: 32
|
|
6931
6931
|
}),
|
|
6932
6932
|
disabled: tag.isDefault,
|
|
6933
|
-
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name),
|
|
6933
|
+
onClick: () => !tag.isDefault && onDeleteTag?.(tag.name, tags.findIndex((t) => t.name === tag.name)),
|
|
6934
6934
|
style: {
|
|
6935
6935
|
width: 40,
|
|
6936
6936
|
height: 40,
|
|
@@ -6973,7 +6973,7 @@ const TagsSection = ({ tags, collapsed, onToggleCollapse, onAddTag, onEditTag, o
|
|
|
6973
6973
|
const TAG_NAME_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
6974
6974
|
const TAG_DESC_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
6975
6975
|
const EXTERNAL_DOCS_DESC_REGEX = /^[A-Za-z0-9_\s-]+$/;
|
|
6976
|
-
const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag }) => {
|
|
6976
|
+
const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag, existingTags }) => {
|
|
6977
6977
|
const [form] = Form.useForm();
|
|
6978
6978
|
const [messageApi, contextHolder] = message.useMessage();
|
|
6979
6979
|
const [confirmModalOpen, setConfirmModalOpen] = useState(false);
|
|
@@ -7104,7 +7104,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7104
7104
|
}
|
|
7105
7105
|
}));
|
|
7106
7106
|
const isLinkEnabled = Boolean(extDocsDesc?.trim());
|
|
7107
|
-
const isAddEnabled = !!(tagNameValue && TAG_NAME_REGEX.test(tagNameValue));
|
|
7107
|
+
const isAddEnabled = !!(tagNameValue && TAG_NAME_REGEX.test(tagNameValue)) && !form.getFieldsError().some((field) => field.errors.length > 0);
|
|
7108
7108
|
useEffect(() => {
|
|
7109
7109
|
if (open && mode === "edit" && initialValues) form.setFieldsValue(initialValues);
|
|
7110
7110
|
if (!open) form.resetFields();
|
|
@@ -7214,7 +7214,13 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7214
7214
|
{
|
|
7215
7215
|
pattern: TAG_NAME_REGEX,
|
|
7216
7216
|
message: "Only letters, numbers, spaces, underscores, and hyphens"
|
|
7217
|
-
}
|
|
7217
|
+
},
|
|
7218
|
+
{ validator: (_, value) => {
|
|
7219
|
+
if (!value || !existingTags?.length) return Promise.resolve();
|
|
7220
|
+
const originalName = initialValues?.name;
|
|
7221
|
+
if (existingTags.some((t) => t.name.toLowerCase() === value.toLowerCase() && t.name.toLowerCase() !== originalName?.toLowerCase())) return Promise.reject(/* @__PURE__ */ new Error("Tag name already exists"));
|
|
7222
|
+
return Promise.resolve();
|
|
7223
|
+
} }
|
|
7218
7224
|
],
|
|
7219
7225
|
children: /* @__PURE__ */ jsx(Input, {
|
|
7220
7226
|
showCount: true,
|
|
@@ -7290,7 +7296,7 @@ const AddTagDrawer = ({ open, onClose, mode, initialValues, onAddTag, onEditTag
|
|
|
7290
7296
|
if (!desc?.trim()) return Promise.resolve();
|
|
7291
7297
|
if (!link?.trim()) return Promise.reject(/* @__PURE__ */ new Error("External Docs Link is required when Description is filled"));
|
|
7292
7298
|
try {
|
|
7293
|
-
|
|
7299
|
+
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
7300
|
return Promise.resolve();
|
|
7295
7301
|
} catch {
|
|
7296
7302
|
return Promise.reject(/* @__PURE__ */ new Error("Please enter a valid URL"));
|
|
@@ -8485,7 +8491,7 @@ const EndpointPage = () => {
|
|
|
8485
8491
|
};
|
|
8486
8492
|
//#endregion
|
|
8487
8493
|
//#region src/view/console/MainContent.tsx
|
|
8488
|
-
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage }) => {
|
|
8494
|
+
const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage, apiOverride }) => {
|
|
8489
8495
|
const { focusedContent, transformedData } = useStore(({ view }) => view);
|
|
8490
8496
|
const { wrapSSR, cx, token } = useStyle("MainContent", (token, scope) => ({
|
|
8491
8497
|
[scope("inner-doc-container")]: {
|
|
@@ -8568,7 +8574,7 @@ const MainContent = ({ searchEnabled, handleResetSearch, handleVisitLandingPage
|
|
|
8568
8574
|
children: "Reset Search"
|
|
8569
8575
|
})
|
|
8570
8576
|
]
|
|
8571
|
-
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ jsx(EndpointPage, {}) : /* @__PURE__ */ jsx(APIPage, {})
|
|
8577
|
+
}) : focusedContent === "ENDPOINT" ? /* @__PURE__ */ jsx(EndpointPage, {}) : /* @__PURE__ */ jsx(APIPage, { apiOverride })
|
|
8572
8578
|
}));
|
|
8573
8579
|
};
|
|
8574
8580
|
//#endregion
|
|
@@ -8652,7 +8658,6 @@ function CodeboxSidebar$1() {
|
|
|
8652
8658
|
const queryParams = params.filter((p) => p.in === "query");
|
|
8653
8659
|
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
8660
|
})();
|
|
8655
|
-
const hasAnyParams = (selectedEndpoint?.parameters ?? []).some((p) => p.in === "header" || p.in === "path" || p.in === "query");
|
|
8656
8661
|
const { token: antdToken, theme: themeConfig } = theme.useToken();
|
|
8657
8662
|
const isDark = themeConfig.id == 1;
|
|
8658
8663
|
const headerBg = isDark ? antdToken.colorBgElevated : "#1d2856";
|
|
@@ -8774,7 +8779,7 @@ function CodeboxSidebar$1() {
|
|
|
8774
8779
|
}));
|
|
8775
8780
|
return /* @__PURE__ */ jsxs("div", {
|
|
8776
8781
|
className: cx("container"),
|
|
8777
|
-
children: [
|
|
8782
|
+
children: [curlCommand && /* @__PURE__ */ jsxs("div", {
|
|
8778
8783
|
className: cx("rightCard", "rightCardRequest"),
|
|
8779
8784
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
8780
8785
|
className: cx("rightCardHeader"),
|
|
@@ -8968,7 +8973,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
8968
8973
|
});
|
|
8969
8974
|
const [deleteTagModal, setDeleteTagModal] = useState({
|
|
8970
8975
|
open: false,
|
|
8971
|
-
|
|
8976
|
+
tagIndex: -1
|
|
8972
8977
|
});
|
|
8973
8978
|
const [localTags, setLocalTags] = useState([]);
|
|
8974
8979
|
const [messageApi, contextHolder] = message.useMessage();
|
|
@@ -8978,6 +8983,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
8978
8983
|
const { useBreakpoint } = Grid;
|
|
8979
8984
|
const isMobile = !useBreakpoint().md;
|
|
8980
8985
|
const allEndpoints = useMemo(() => selectedApi ? Object.values(selectedApi.tags ?? {}).flat() : [], [selectedApi]);
|
|
8986
|
+
const viewModeApi = useMemo(() => {
|
|
8987
|
+
if (!selectedApi) return null;
|
|
8988
|
+
if (mode !== "view") return selectedApi;
|
|
8989
|
+
if (localApiName === selectedApi.title && localDescription === selectedApi.description) return selectedApi;
|
|
8990
|
+
return {
|
|
8991
|
+
...selectedApi,
|
|
8992
|
+
title: localApiName,
|
|
8993
|
+
description: localDescription
|
|
8994
|
+
};
|
|
8995
|
+
}, [
|
|
8996
|
+
mode,
|
|
8997
|
+
selectedApi,
|
|
8998
|
+
localApiName,
|
|
8999
|
+
localDescription
|
|
9000
|
+
]);
|
|
8981
9001
|
useEffect(() => {
|
|
8982
9002
|
return () => {
|
|
8983
9003
|
resetStore();
|
|
@@ -9130,7 +9150,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9130
9150
|
externalDocsDescription: t.externalDocs?.description,
|
|
9131
9151
|
isDefault: t.name.toLowerCase() === "default"
|
|
9132
9152
|
})) ?? [];
|
|
9133
|
-
|
|
9153
|
+
const hasDefault = mapped.some((t) => t.isDefault);
|
|
9154
|
+
const hasDefaultInMapped = mapped.some((t) => t.name.toLowerCase() === "default");
|
|
9155
|
+
if (!hasDefault && !hasDefaultInMapped && selectedApi.tags["default"]) mapped.push({
|
|
9134
9156
|
name: "default",
|
|
9135
9157
|
isDefault: true
|
|
9136
9158
|
});
|
|
@@ -9282,6 +9304,12 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9282
9304
|
useEffect(() => {
|
|
9283
9305
|
if (mode !== "view" || !selectedEndpoint) return;
|
|
9284
9306
|
const epId = selectedEndpoint.id;
|
|
9307
|
+
const localName = endpointNames[epId];
|
|
9308
|
+
const localDesc = endpointDescs[epId];
|
|
9309
|
+
const localEpTags = endpointTags[epId];
|
|
9310
|
+
const patchedSummary = localName !== void 0 && localName !== selectedEndpoint.summary ? localName : selectedEndpoint.summary;
|
|
9311
|
+
const patchedDesc = localDesc !== void 0 && localDesc !== selectedEndpoint.description ? localDesc : selectedEndpoint.description;
|
|
9312
|
+
const patchedTags = localEpTags !== void 0 && JSON.stringify(localEpTags) !== JSON.stringify(selectedEndpoint.tags ?? []) ? localEpTags : selectedEndpoint.tags;
|
|
9285
9313
|
const openApiParams = (endpointParams[epId] ?? []).map((p) => ({
|
|
9286
9314
|
name: p.name,
|
|
9287
9315
|
in: p.in,
|
|
@@ -9292,7 +9320,6 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9292
9320
|
...p.enum && p.enum.length > 0 ? { enum: p.enum } : {}
|
|
9293
9321
|
}
|
|
9294
9322
|
}));
|
|
9295
|
-
if (JSON.stringify(selectedEndpoint.parameters ?? []) === JSON.stringify(openApiParams)) return;
|
|
9296
9323
|
const responseHeadersMap = (endpointResponseParams[epId] ?? []).reduce((acc, p) => {
|
|
9297
9324
|
acc[p.name] = {
|
|
9298
9325
|
schema: {
|
|
@@ -9308,14 +9335,21 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9308
9335
|
...resp,
|
|
9309
9336
|
headers: Object.keys(responseHeadersMap).length > 0 ? responseHeadersMap : resp.headers
|
|
9310
9337
|
}]));
|
|
9338
|
+
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
9339
|
setSelectedEndpoint({
|
|
9312
9340
|
...selectedEndpoint,
|
|
9341
|
+
summary: patchedSummary,
|
|
9342
|
+
description: patchedDesc,
|
|
9343
|
+
tags: patchedTags,
|
|
9313
9344
|
parameters: openApiParams,
|
|
9314
9345
|
responses: patchedResponses
|
|
9315
9346
|
});
|
|
9316
9347
|
}, [
|
|
9317
9348
|
mode,
|
|
9318
9349
|
selectedEndpoint,
|
|
9350
|
+
endpointNames,
|
|
9351
|
+
endpointDescs,
|
|
9352
|
+
endpointTags,
|
|
9319
9353
|
endpointParams,
|
|
9320
9354
|
endpointResponseParams,
|
|
9321
9355
|
setSelectedEndpoint
|
|
@@ -9343,11 +9377,13 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9343
9377
|
setBannerVisible(true);
|
|
9344
9378
|
};
|
|
9345
9379
|
const handleDeleteTagConfirm = () => {
|
|
9346
|
-
|
|
9347
|
-
|
|
9380
|
+
if (deleteTagModal.tagIndex < 0) return;
|
|
9381
|
+
const tagName = localTags[deleteTagModal.tagIndex]?.name ?? "Tag";
|
|
9382
|
+
setLocalTags((prev) => prev.filter((_, index) => index !== deleteTagModal.tagIndex));
|
|
9383
|
+
messageApi.success(`${tagName} tag has been deleted successfully.`);
|
|
9348
9384
|
setDeleteTagModal({
|
|
9349
9385
|
open: false,
|
|
9350
|
-
|
|
9386
|
+
tagIndex: -1
|
|
9351
9387
|
});
|
|
9352
9388
|
setBannerVisible(true);
|
|
9353
9389
|
};
|
|
@@ -9665,7 +9701,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9665
9701
|
/* @__PURE__ */ jsx("div", {
|
|
9666
9702
|
className: cx("section"),
|
|
9667
9703
|
children: /* @__PURE__ */ jsx(ApiDocumentationBar, {
|
|
9668
|
-
apiName:
|
|
9704
|
+
apiName: localApiName,
|
|
9669
9705
|
mode,
|
|
9670
9706
|
onModeChange: setMode,
|
|
9671
9707
|
onReset: () => setResetConfirmModal(true),
|
|
@@ -9746,9 +9782,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9746
9782
|
externalDocsLink: tag.externalDocsUrl
|
|
9747
9783
|
}
|
|
9748
9784
|
}),
|
|
9749
|
-
onDeleteTag: (
|
|
9785
|
+
onDeleteTag: (_tagName, tagIndex) => setDeleteTagModal({
|
|
9750
9786
|
open: true,
|
|
9751
|
-
|
|
9787
|
+
tagIndex
|
|
9752
9788
|
})
|
|
9753
9789
|
})
|
|
9754
9790
|
}),
|
|
@@ -9908,9 +9944,9 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
9908
9944
|
externalDocsLink: tag.externalDocsUrl
|
|
9909
9945
|
}
|
|
9910
9946
|
}),
|
|
9911
|
-
onDeleteTag: (
|
|
9947
|
+
onDeleteTag: (_tagName, tagIndex) => setDeleteTagModal({
|
|
9912
9948
|
open: true,
|
|
9913
|
-
|
|
9949
|
+
tagIndex
|
|
9914
9950
|
})
|
|
9915
9951
|
})
|
|
9916
9952
|
}),
|
|
@@ -10024,7 +10060,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10024
10060
|
children: [/* @__PURE__ */ jsx(MainContent, {
|
|
10025
10061
|
handleVisitLandingPage: _handleVisitLandingPage,
|
|
10026
10062
|
handleResetSearch,
|
|
10027
|
-
searchEnabled: !!searchValue
|
|
10063
|
+
searchEnabled: !!searchValue,
|
|
10064
|
+
apiOverride: mode === "view" ? viewModeApi : void 0
|
|
10028
10065
|
}), !isMobile && focusedContent === "ENDPOINT" && /* @__PURE__ */ jsx(CodeboxSidebar$1, {})]
|
|
10029
10066
|
})]
|
|
10030
10067
|
}),
|
|
@@ -10037,7 +10074,8 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10037
10074
|
mode: "add"
|
|
10038
10075
|
}),
|
|
10039
10076
|
onAddTag: handleAddTag,
|
|
10040
|
-
onEditTag: handleUpdateTag
|
|
10077
|
+
onEditTag: handleUpdateTag,
|
|
10078
|
+
existingTags: localTags
|
|
10041
10079
|
}),
|
|
10042
10080
|
/* @__PURE__ */ jsxs(Modal, {
|
|
10043
10081
|
open: saveConfirmModal,
|
|
@@ -10181,7 +10219,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10181
10219
|
open: deleteTagModal.open,
|
|
10182
10220
|
onCancel: () => setDeleteTagModal({
|
|
10183
10221
|
open: false,
|
|
10184
|
-
|
|
10222
|
+
tagIndex: -1
|
|
10185
10223
|
}),
|
|
10186
10224
|
centered: true,
|
|
10187
10225
|
title: null,
|
|
@@ -10207,14 +10245,14 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10207
10245
|
className: cx("deleteModalTitle"),
|
|
10208
10246
|
children: [
|
|
10209
10247
|
"Delete ",
|
|
10210
|
-
deleteTagModal.
|
|
10248
|
+
localTags[deleteTagModal.tagIndex]?.name ?? "Tag",
|
|
10211
10249
|
" tag"
|
|
10212
10250
|
]
|
|
10213
10251
|
}), /* @__PURE__ */ jsx("button", {
|
|
10214
10252
|
className: cx("deleteModalCloseBtn"),
|
|
10215
10253
|
onClick: () => setDeleteTagModal({
|
|
10216
10254
|
open: false,
|
|
10217
|
-
|
|
10255
|
+
tagIndex: -1
|
|
10218
10256
|
}),
|
|
10219
10257
|
"aria-label": "Close",
|
|
10220
10258
|
children: "×"
|
|
@@ -10226,7 +10264,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10226
10264
|
className: cx("deleteModalContentText"),
|
|
10227
10265
|
children: [
|
|
10228
10266
|
"Are you sure you want to delete ",
|
|
10229
|
-
deleteTagModal.
|
|
10267
|
+
localTags[deleteTagModal.tagIndex]?.name ?? "Tag",
|
|
10230
10268
|
" tag?"
|
|
10231
10269
|
]
|
|
10232
10270
|
})
|
|
@@ -10237,7 +10275,7 @@ const ConsoleDocumentationLayout = ({ data, preSelectedApi, handleVisitLandingPa
|
|
|
10237
10275
|
size: "middle",
|
|
10238
10276
|
onClick: () => setDeleteTagModal({
|
|
10239
10277
|
open: false,
|
|
10240
|
-
|
|
10278
|
+
tagIndex: -1
|
|
10241
10279
|
}),
|
|
10242
10280
|
style: {
|
|
10243
10281
|
borderRadius: 8,
|