@digi-frontend/dgate-api-documentation 2.0.1-test.1 → 2.0.1-test.10

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 CHANGED
@@ -28,15 +28,15 @@ const react = __toESM(require("react"));
28
28
  const antd = __toESM(require("antd"));
29
29
  const __ant_design_cssinjs = __toESM(require("@ant-design/cssinjs"));
30
30
  const react_jsx_runtime = __toESM(require("react/jsx-runtime"));
31
- const nanoid = __toESM(require("nanoid"));
32
31
  const __ant_design_nextjs_registry = __toESM(require("@ant-design/nextjs-registry"));
32
+ const nanoid = __toESM(require("nanoid"));
33
33
 
34
34
  //#region src/store/slices/view.ts
35
35
  const createViewSlice = (set) => ({ view: {
36
36
  selectedNodeKey: null,
37
37
  expandedKeys: ["custom-auth", "api-name-01"],
38
- originalData: null,
39
- transformedData: null,
38
+ originalData: [],
39
+ transformedData: [],
40
40
  selectedApi: null,
41
41
  selectedEndpoint: null,
42
42
  setSelectedNode: (key) => set((state) => {
@@ -112,23 +112,24 @@ const createStore = (set) => ({
112
112
  ...createEditorSlice(set)
113
113
  });
114
114
  const useStore = (0, zustand.create)()((0, zustand_middleware.devtools)((0, zustand_middleware_immer.immer)(createStore), { name: "dgate-docs-store" }));
115
+ var store_default = useStore;
115
116
 
116
117
  //#endregion
117
118
  //#region src/hooks/useStyle.ts
118
119
  function useStyle(componentName, stylesFn) {
119
- const { token: token$1, theme, hashId } = antd.theme.useToken();
120
+ const { token, theme, hashId } = antd.theme.useToken();
120
121
  const scope = (className) => `.${hashId}.${componentName}-${className}`;
121
122
  const cx = (...classes) => classes.map((cls) => `${componentName}-${cls} ${hashId}`).join(" ");
122
123
  const wrapSSR = (0, __ant_design_cssinjs.useStyleRegister)({
123
124
  theme,
124
- token: token$1,
125
+ token,
125
126
  path: [componentName]
126
- }, () => stylesFn(token$1, scope));
127
+ }, () => stylesFn(token, scope));
127
128
  return {
128
129
  wrapSSR,
129
130
  cx,
130
131
  scope,
131
- token: token$1,
132
+ token,
132
133
  hashId
133
134
  };
134
135
  }
@@ -137,808 +138,85 @@ function useStyle(componentName, stylesFn) {
137
138
  //#region src/view/components/Header.tsx
138
139
  const { Header: AntHeader } = antd.Layout;
139
140
  const Header = () => {
140
- const { wrapSSR, cx } = useStyle("Header", (token$1, scope) => ({ [scope("header")]: {
141
+ const { wrapSSR, cx } = useStyle("Header", (token, scope) => ({ [scope("header")]: {
141
142
  width: "100%",
142
143
  height: "4rem",
143
- backgroundColor: token$1.colorBgContainer
144
+ backgroundColor: token.colorBgContainer
144
145
  } }));
145
146
  return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AntHeader, { className: cx("header") }));
146
147
  };
147
148
 
148
- //#endregion
149
- //#region src/assets/Minify.svg
150
- var _path;
151
- function _extends() {
152
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
153
- for (var e = 1; e < arguments.length; e++) {
154
- var t = arguments[e];
155
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
156
- }
157
- return n;
158
- }, _extends.apply(null, arguments);
159
- }
160
- var SvgMinify = function SvgMinify$1(props) {
161
- return /* @__PURE__ */ react.createElement("svg", _extends({
162
- xmlns: "http://www.w3.org/2000/svg",
163
- width: 16,
164
- height: 16,
165
- fill: "none"
166
- }, props), _path || (_path = /* @__PURE__ */ react.createElement("path", {
167
- stroke: "currentcolor",
168
- d: "m6 11.334 2-2 2 2M6 4.666l2 2 2-2"
169
- })));
170
- };
171
- var Minify_default = SvgMinify;
172
-
173
- //#endregion
174
- //#region src/theme/light.json
175
- var token = {
176
- "brnadColor.1": "#f1f5fd",
177
- "brnadColor.2": "#e0e9f9",
178
- "brnadColor.3": "#c8d8f5",
179
- "brnadColor.4": "#a2bfee",
180
- "brnadColor.5": "#769de4",
181
- "brnadColor.6": "#4d75d9",
182
- "brnadColor.7": "#4261ce",
183
- "brnadColor.8": "#384fbd",
184
- "brnadColor.9": "#33419a",
185
- "brnadColor.10": "#20264b",
186
- "cyan.1": "#e6fffb",
187
- "cyan.2": "#b5f5ec",
188
- "cyan.3": "#87e8de",
189
- "cyan.4": "#5cdbd3",
190
- "cyan.5": "#36cfc9",
191
- "cyan.6": "#13c2c2",
192
- "cyan.7": "#08979c",
193
- "cyan.8": "#006d75",
194
- "cyan.9": "#00474f",
195
- "cyan.10": "#002329",
196
- "geekblue.1": "#f0f5ff",
197
- "geekblue.2": "#d6e4ff",
198
- "geekblue.3": "#adc6ff",
199
- "geekblue.4": "#85a5ff",
200
- "geekblue.5": "#597ef7",
201
- "geekblue.6": "#2f54eb",
202
- "geekblue.7": "#1d39c4",
203
- "geekblue.8": "#10239e",
204
- "geekblue.9": "#061178",
205
- "geekblue.10": "#030852",
206
- "gold.1": "#fffbe6",
207
- "gold.2": "#fff1b8",
208
- "gold.3": "#ffe58f",
209
- "gold.4": "#ffd666",
210
- "gold.5": "#ffc53d",
211
- "gold.6": "#faad14",
212
- "gold.7": "#d48806",
213
- "gold.8": "#ad6800",
214
- "gold.9": "#874d00",
215
- "gold.10": "#613400",
216
- "green.1": "#f6ffed",
217
- "green.2": "#d9f7be",
218
- "green.3": "#b7eb8f",
219
- "green.4": "#95de64",
220
- "green.5": "#73d13d",
221
- "green.6": "#52c41a",
222
- "green.7": "#389e0d",
223
- "green.8": "#237804",
224
- "green.9": "#135200",
225
- "green.10": "#092b00",
226
- "lime.1": "#fcffe6",
227
- "lime.2": "#f4ffb8",
228
- "lime.3": "#eaff8f",
229
- "lime.4": "#d3f261",
230
- "lime.5": "#bae637",
231
- "lime.6": "#a0d911",
232
- "lime.7": "#7cb305",
233
- "lime.8": "#5b8c00",
234
- "lime.9": "#3f6600",
235
- "lime.10": "#254000",
236
- "magenta.1": "#fff0f6",
237
- "magenta.2": "#ffd6e7",
238
- "magenta.3": "#ffadd2",
239
- "magenta.4": "#ff85c0",
240
- "magenta.5": "#f759ab",
241
- "magenta.6": "#eb2f96",
242
- "magenta.7": "#c41d7f",
243
- "magenta.8": "#9e1068",
244
- "magenta.9": "#780650",
245
- "magenta.10": "#520339",
246
- "orange.1": "#fff7e6",
247
- "orange.2": "#ffe7ba",
248
- "orange.3": "#ffd591",
249
- "orange.4": "#ffc069",
250
- "colorText": "rgba(0, 0, 0, 0.88)",
251
- "colorTextSecondary": "rgba(0, 0, 0, 0.65)",
252
- "orange.5": "#ffa940",
253
- "colorTextTertiary": "rgba(0, 0, 0, 0.45)",
254
- "colorTextQuaternary": "rgba(0, 0, 0, 0.25)",
255
- "orange.6": "#fa8c16",
256
- "orange.7": "#d46b08",
257
- "colorTextLightSolid": "#ffffff",
258
- "colorTextHeading": "rgba(0, 0, 0, 0.88)",
259
- "colorTextLabel": "rgba(0, 0, 0, 0.65)",
260
- "orange.8": "#ad4e00",
261
- "colorTextDescription": "rgba(0, 0, 0, 0.45)",
262
- "orange.9": "#873800",
263
- "colorTextDisabled": "rgba(0, 0, 0, 0.25)",
264
- "orange.10": "#612500",
265
- "purple.1": "#f9f0ff",
266
- "purple.2": "#efdbff",
267
- "purple.3": "#d3adf7",
268
- "colorTextPlaceholder": "rgba(0, 0, 0, 0.25)",
269
- "colorIcon": "rgba(0, 0, 0, 0.45)",
270
- "purple.4": "#b37feb",
271
- "colorIconHover": "rgba(0, 0, 0, 0.88)",
272
- "colorBgContainer": "#ffffff",
273
- "purple.5": "#9254de",
274
- "colorBgElevated": "#ffffff",
275
- "purple.6": "#722ed1",
276
- "colorBgLayout": "#f5f5f5",
277
- "purple.7": "#531dab",
278
- "colorBgMask": "rgba(0, 0, 0, 0.45)",
279
- "purple.8": "#391085",
280
- "colorBgSpotlight": "rgba(0, 0, 0, 0.85)",
281
- "purple.9": "#22075e",
282
- "colorBorder": "#d9d9d9",
283
- "purple.10": "#120338",
284
- "colorBorderSecondary": "#f0f0f0",
285
- "red.1": "#fff1f0",
286
- "colorFill": "rgba(0, 0, 0, 0.15)",
287
- "red.2": "#ffccc7",
288
- "colorFillSecondary": "rgba(0, 0, 0, 0.06)",
289
- "colorFillTertiary": "rgba(0, 0, 0, 0.04)",
290
- "colorFillQuaternary": "rgba(0, 0, 0, 0.02)",
291
- "red.3": "#ffa39e",
292
- "red.4": "#ff7875",
293
- "colorWhite": "#ffffff",
294
- "red.5": "#ff4d4f",
295
- "colorBgBase": "#ffffff",
296
- "red.6": "#f5222d",
297
- "colorTextBase": "#000000",
298
- "red.7": "#cf1322",
299
- "red.8": "#a8071a",
300
- "colorBgContainerDisabled": "rgba(0, 0, 0, 0.04)",
301
- "red.9": "#820014",
302
- "colorBgTextActive": "rgba(0, 0, 0, 0.15)",
303
- "red.10": "#5c0011",
304
- "colorBgTextHover": "rgba(0, 0, 0, 0.06)",
305
- "volcano.1": "#fff2e8",
306
- "colorBorderBg": "#ffffff",
307
- "volcano.2": "#ffd8bf",
308
- "colorFillContent": "rgba(0, 0, 0, 0.06)",
309
- "volcano.3": "#ffbb96",
310
- "colorFillContentHover": "rgba(0, 0, 0, 0.15)",
311
- "volcano.4": "#ff9c6e",
312
- "colorFillAlter": "rgba(0, 0, 0, 0.02)",
313
- "volcano.5": "#ff7a45",
314
- "volcano.6": "#fa541c",
315
- "volcano.7": "#d4380d",
316
- "transparent": "rgba(0, 0, 0, 0)",
317
- "colorSplit": "rgba(0, 0, 0, 0.06)",
318
- "yellow.1": "#feffe6",
319
- "volcano.8": "#ad2102",
320
- "yellow.2": "#ffffb8",
321
- "yellow.3": "#fffb8f",
322
- "volcano.9": "#871400",
323
- "yellow.4": "#fff566",
324
- "volcano.10": "#610b00",
325
- "yellow.5": "#ffec3d",
326
- "yellow.6": "#fadb14",
327
- "yellow.7": "#d4b106",
328
- "yellow.8": "#ad8b00",
329
- "yellow.9": "#876800",
330
- "yellow.10": "#614700",
331
- "colorPrimary": "#4d75d9",
332
- "colorSuccess": "#52c41a",
333
- "colorWarning": "#faad14",
334
- "colorInfo": "#4d75d9",
335
- "colorError": "#ff4d4f",
336
- "colorLink": "#4d75d9",
337
- "colorErrorBg": "#fff2f0",
338
- "colorErrorBgHover": "#fff1f0",
339
- "colorErrorBorder": "#ffccc7",
340
- "colorErrorBorderHover": "#ffa39e",
341
- "colorErrorHover": "#ff7875",
342
- "colorErrorActive": "#d9363e",
343
- "colorErrorTextHover": "#ff7875",
344
- "colorErrorText": "#ff4d4f",
345
- "colorErrorTextActive": "#d9363e",
346
- "colorLinkHover": "#769de4",
347
- "colorInfoBg": "#f1f5fd",
348
- "colorInfoBgHover": "#e0e9f9",
349
- "colorInfoBorder": "#c8d8f5",
350
- "colorInfoBorderHover": "#a2bfee",
351
- "colorInfoHover": "#769de4",
352
- "colorInfoActive": "#4261ce",
353
- "colorInfoTextHover": "#769de4",
354
- "colorInfoText": "#4d75d9",
355
- "colorInfoTextActive": "#4261ce",
356
- "colorLinkActive": "#4261ce",
357
- "colorPrimaryBg": "#f1f5fd",
358
- "colorPrimaryBgHover": "#e0e9f9",
359
- "colorPrimaryBorder": "#c8d8f5",
360
- "colorPrimaryBorderHover": "#a2bfee",
361
- "colorPrimaryHover": "#769de4",
362
- "colorPrimaryActive": "#4261ce",
363
- "colorPrimaryTextHover": "#769de4",
364
- "colorPrimaryText": "#4d75d9",
365
- "colorPrimaryTextActive": "#4261ce",
366
- "colorSuccessBg": "#f6ffed",
367
- "colorSuccessBgHover": "#d9f7be",
368
- "colorSuccessBorder": "#b7eb8f",
369
- "colorSuccessBorderHover": "#95de64",
370
- "colorSuccessHover": "#95de64",
371
- "colorSuccessActive": "#389e0d",
372
- "colorSuccessTextHover": "#73d13d",
373
- "colorSuccessText": "#52c41a",
374
- "colorSuccessTextActive": "#389e0d",
375
- "colorWarningBg": "#fffbe6",
376
- "colorWarningBgHover": "#fff1b8",
377
- "colorWarningBorder": "#ffe58f",
378
- "colorWarningBorderHover": "#ffd666",
379
- "colorWarningHover": "#ffd666",
380
- "colorWarningActive": "#d48806",
381
- "colorWarningTextHover": "#ffc53d",
382
- "colorWarningText": "#faad14",
383
- "colorWarningTextActive": "#d48806",
384
- "colorErrorOutline": "rgba(255, 38, 6, 0.06)",
385
- "colorWarningOutline": "rgba(255, 215, 5, 0.1)",
386
- "controlItemBgActive": "#f1f5fd",
387
- "controlItemBgActiveDisabled": "rgba(0, 0, 0, 0.15)",
388
- "controlItemBgActiveHover": "#e0e9f9",
389
- "controlItemBgHover": "rgba(0, 0, 0, 0.04)",
390
- "controlOutline": "rgba(5, 145, 255, 0.1)",
391
- "controlTmpOutline": "rgba(0, 0, 0, 0.02)",
392
- "borderRadius": 6,
393
- "borderRadiusLG": 8,
394
- "borderRadiusSM": 4,
395
- "borderRadiusXS": 2,
396
- "sizeStep": 4,
397
- "sizeUnit": 4,
398
- "controlInteractiveSize": 16,
399
- "size": 16,
400
- "sizeLG": 24,
401
- "sizeMD": 20,
402
- "sizeMS": 16,
403
- "sizeSM": 12,
404
- "sizeXL": 32,
405
- "sizeXS": 8,
406
- "sizeXXL": 48,
407
- "controlHeight": 32,
408
- "sizeXXS": 4,
409
- "controlHeightLG": 40,
410
- "controlHeightSM": 24,
411
- "controlHeightXS": 16,
412
- "lineWidth": 1,
413
- "lineWidthBold": 2,
414
- "lineWidthFocus": 4,
415
- "controlOutlineWidth": 2,
416
- "screenLG": 992,
417
- "screenLGMax": 1199,
418
- "screenLGMin": 992,
419
- "screenMD": 768,
420
- "screenMDMax": 991,
421
- "screenMDMin": 768,
422
- "screenSM": 576,
423
- "screenSMMax": 767,
424
- "screenSMMin": 576,
425
- "screenXL": 1200,
426
- "screenXLMax": 1599,
427
- "screenXLMin": 1200,
428
- "screenXS": 480,
429
- "screenXSMax": 575,
430
- "screenXSMin": 480,
431
- "screenXXL": 1600,
432
- "screenXXLMin": 1600,
433
- "sizePopupArrow": 16,
434
- "margin": 16,
435
- "marginLG": 24,
436
- "marginMD": 20,
437
- "marginSM": 12,
438
- "marginXL": 32,
439
- "marginXS": 8,
440
- "marginXXL": 48,
441
- "marginXXS": 4,
442
- "padding": 16,
443
- "paddingLG": 24,
444
- "paddingMD": 20,
445
- "paddingSM": 12,
446
- "paddingXL": 32,
447
- "paddingXS": 8,
448
- "paddingXXS": 4,
449
- "paddingContentHorizontal": 16,
450
- "paddingContentHorizontalLG": 24,
451
- "paddingContentHorizontalSM": 16,
452
- "paddingContentVertical": 12,
453
- "paddingContentVerticalLG": 16,
454
- "paddingContentVerticalSM": 8,
455
- "controlPaddingHorizontal": 12,
456
- "controlPaddingHorizontalSM": 8,
457
- "fontFamily": "SF Pro",
458
- "fontFamilyCode": "Courier Prime",
459
- "fontSize": 14,
460
- "fontSizeLG": 16,
461
- "fontSizeSM": 12,
462
- "fontSizeXL": 20,
463
- "fontSizeHeading1": 38,
464
- "fontSizeHeading2": 30,
465
- "fontSizeHeading3": 24,
466
- "fontSizeHeading4": 20,
467
- "fontSizeHeading5": 16,
468
- "lineHeight": 1.5714285714285714,
469
- "lineHeightHeading1": 1.2105263157894737,
470
- "lineHeightHeading2": 1.2666666666666666,
471
- "lineHeightHeading3": 1.3333333333333333,
472
- "lineHeightHeading4": 1.4,
473
- "lineHeightHeading5": 1.5,
474
- "lineHeightLG": 1.5,
475
- "lineHeightSM": 1.6666666666666667,
476
- "fontSizeIcon": 12,
477
- "fontWeightStrong": 600,
478
- "colorFillAlterSolid": "#fafafa",
479
- "fontWeightNormal": 400,
480
- "colorFilledHandleBg": "#f0f0f0",
481
- "colorBgSolid": "#000000",
482
- "colorBgSolidActive": "rgba(0, 0, 0, 0.95)",
483
- "colorBgSolidHover": "rgba(0, 0, 0, 0.75)",
484
- "solidTextColor": "#ffffff",
485
- "pink.1": "#fff0f6",
486
- "pink.2": "#ffd6e7",
487
- "pink.3": "#ffadd2",
488
- "pink.4": "#ff85c0",
489
- "pink.5": "#f759ab",
490
- "pink.6": "#eb2f96",
491
- "pink.7": "#c41d7f",
492
- "pink.8": "#9e1068",
493
- "pink.9": "#780650",
494
- "pink.10": "#520339",
495
- "sizeXXXL": 60,
496
- "sizeXXXXL": 72,
497
- "paddingXXL": 48,
498
- "paddingXXXL": 60,
499
- "paddingXXXXL": 72,
500
- "marginXXXL": 60,
501
- "marginXXXXL": 72
502
- };
503
-
504
- //#endregion
505
- //#region src/view/helper/sidebar.utils.ts
506
- const methodColors = {
507
- GET: {
508
- bg: token.colorPrimaryBgHover,
509
- color: token.colorPrimary
510
- },
511
- POST: {
512
- bg: token["green.1"],
513
- color: token.colorSuccess
514
- },
515
- DELETE: {
516
- bg: token.colorErrorBg,
517
- color: token.colorError
518
- },
519
- PUT: {
520
- bg: token.colorWarningBg,
521
- color: token.colorWarning
522
- },
523
- PATCH: {
524
- bg: token["volcano.5"],
525
- color: token.colorWhite
526
- },
527
- OPTIONS: {
528
- bg: token["geekblue.2"],
529
- color: token["geekblue.6"]
530
- },
531
- HEAD: {
532
- bg: token["purple.1"],
533
- color: token["purple.5"]
534
- },
535
- TRACE: {
536
- bg: token["cyan.1"],
537
- color: token["cyan.5"]
538
- }
539
- };
540
- const buildTreeDataStructure = (data) => {
541
- if (!data) return [];
542
- return data.map((api) => {
543
- return {
544
- title: api.title,
545
- key: api.id,
546
- selectable: true,
547
- data: api,
548
- children: Object.entries(api.tags).map(([tag, endpoints]) => {
549
- const tagId = `tag-${(0, nanoid.nanoid)(8)}`;
550
- return {
551
- title: tag,
552
- key: tagId,
553
- selectable: false,
554
- data: {
555
- tagName: tag,
556
- apiData: api
557
- },
558
- children: endpoints.map((endpoint) => {
559
- return {
560
- title: endpoint.summary,
561
- key: endpoint.id,
562
- isLeaf: true,
563
- selectable: true,
564
- method: endpoint.method,
565
- data: {
566
- endpoint,
567
- api,
568
- tagName: tag
569
- }
570
- };
571
- })
572
- };
573
- })
574
- };
575
- });
576
- };
577
- const findNodeByKey = (nodes, targetKey) => {
578
- for (const node of nodes) {
579
- if (node.key === targetKey) return node;
580
- if (node.children && node.children.length > 0) {
581
- const found = findNodeByKey(node.children, targetKey);
582
- if (found) return found;
583
- }
584
- }
585
- return null;
586
- };
587
- const isApiSectionHighlighted = (apiKey, selectedNode, treeDataStructure) => {
588
- if (!selectedNode || selectedNode.length === 0) return false;
589
- const selectedKey = selectedNode[0];
590
- if (selectedKey === apiKey) return false;
591
- const findNodeParentApi = (nodes, targetKey) => {
592
- for (const node of nodes) if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
593
- const apiId = node.key;
594
- if (node.children) for (const child of node.children) {
595
- if (child.key === targetKey) return apiId;
596
- if (child.children) {
597
- for (const grandChild of child.children) if (grandChild.key === targetKey) return apiId;
598
- }
599
- }
600
- }
601
- return null;
602
- };
603
- const parentApiKey = findNodeParentApi(treeDataStructure, selectedKey);
604
- return parentApiKey === apiKey;
605
- };
606
- const getAllTreeKeys = (data) => {
607
- const keys = [];
608
- const traverse = (nodes) => {
609
- nodes.forEach((node) => {
610
- keys.push(node.key);
611
- if (node.children && node.children.length > 0) traverse(node.children);
612
- });
613
- };
614
- traverse(data);
615
- return keys;
616
- };
617
- const filterTreeData = (data, searchText) => {
618
- if (!searchText) return data;
619
- const findOriginalNode = (nodes, key) => {
620
- for (const node of nodes) {
621
- if (node.key === key) return node;
622
- if (node.children) {
623
- const found = findOriginalNode(node.children, key);
624
- if (found) return found;
625
- }
626
- }
627
- return null;
628
- };
629
- const filterNode = (node) => {
630
- let titleText = "";
631
- const originalNode = findOriginalNode(data, node.key);
632
- if (originalNode && typeof originalNode.title === "string") titleText = originalNode.title;
633
- else if (typeof node.title === "string") titleText = node.title;
634
- let searchableText = titleText;
635
- if (node.isLeaf && node.method) searchableText = `${node.method} ${titleText}`.toLowerCase();
636
- else searchableText = titleText.toLowerCase();
637
- const searchLower = searchText.toLowerCase();
638
- const matchesSearch = searchableText.includes(searchLower);
639
- if (node.children) {
640
- const filteredChildren = node.children.map((child) => filterNode(child)).filter((child) => child !== null);
641
- if (matchesSearch || filteredChildren.length > 0) return {
642
- ...node,
643
- children: filteredChildren
644
- };
645
- } else if (matchesSearch) return node;
646
- return null;
647
- };
648
- return data.map((node) => filterNode(node)).filter((node) => node !== null);
649
- };
650
- const getSidebarStyles = (token$1, scope) => ({
651
- [scope("sider")]: {
652
- backgroundColor: token$1.colorBgContainer,
653
- maxWidth: "17.5rem",
654
- overflowY: "auto",
655
- overflowX: "clip"
656
- },
657
- [scope("content")]: { padding: token$1.padding },
658
- [scope("controls")]: {
659
- display: "flex",
660
- gap: token$1.marginXS,
661
- marginBottom: token$1.marginSM
662
- },
663
- [scope("search-input")]: { flex: 1 },
664
- [scope("tree")]: {
665
- backgroundColor: "transparent",
666
- "& .ant-tree-node-content-wrapper": {
667
- overflow: "hidden",
668
- width: "100%",
669
- display: "flex",
670
- alignItems: "center"
671
- },
672
- "& .ant-tree-title": {
673
- width: "100%",
674
- overflow: "hidden",
675
- display: "flex",
676
- alignItems: "center",
677
- marginBlock: "auto"
678
- },
679
- "& .ant-tree-treenode": {
680
- width: "100%",
681
- padding: 0
682
- },
683
- "& .ant-tree-node-content-wrapper:hover": { backgroundColor: token$1.colorFillTertiary }
684
- },
685
- [scope("endpoint-item")]: {
686
- display: "flex",
687
- alignItems: "center",
688
- gap: token$1.marginXS,
689
- width: "100%",
690
- maxWidth: "100%",
691
- minWidth: "100%"
692
- },
693
- [scope("method-tag")]: {
694
- minWidth: "3.75rem",
695
- textAlign: "center",
696
- border: "none"
697
- },
698
- [scope("endpoint-text")]: {
699
- flex: 1,
700
- maxWidth: "100%"
701
- },
702
- [scope("tag-title")]: {
703
- color: token$1.colorText,
704
- maxWidth: "100%",
705
- display: "block"
706
- },
707
- [scope("api-title")]: {
708
- color: token$1.colorText,
709
- maxWidth: "100%",
710
- display: "block",
711
- padding: 0,
712
- margin: 0,
713
- "&.highlighted": { color: token$1.colorPrimary }
714
- },
715
- [scope("create-text")]: { color: token$1.colorTextSecondary }
716
- });
717
-
718
- //#endregion
719
- //#region src/view/helper/sidebar.components.tsx
720
- const { Text } = antd.Typography;
721
- const EndpointItem = ({ method, title, cx }) => {
722
- const methodStyle = methodColors[method];
723
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
724
- className: cx("endpoint-item"),
725
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tag, {
726
- className: cx("method-tag"),
727
- style: {
728
- backgroundColor: methodStyle?.bg,
729
- color: methodStyle?.color,
730
- border: "none"
731
- },
732
- children: method
733
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
734
- className: cx("endpoint-text"),
735
- ellipsis: { tooltip: title },
736
- style: { flex: 1 },
737
- children: title
738
- })]
739
- });
740
- };
741
- const convertToRenderableTreeData = (treeDataStructure, selectedNode, cx) => {
742
- const renderNode = (node) => {
743
- let title;
744
- if (node.isLeaf && node.method) title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointItem, {
745
- method: node.method,
746
- title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
747
- cx
748
- });
749
- else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
750
- const isHighlighted = isApiSectionHighlighted(node.key, selectedNode, treeDataStructure);
751
- title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
752
- className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
753
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
754
- children: node.title
755
- });
756
- } else title = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
757
- className: cx("tag-title"),
758
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
759
- children: node.title
760
- });
761
- return {
762
- ...node,
763
- title,
764
- children: node.children ? node.children.map(renderNode) : void 0
765
- };
766
- };
767
- return treeDataStructure.map(renderNode);
768
- };
769
-
770
149
  //#endregion
771
150
  //#region src/view/components/Sidebar.tsx
772
- const { Sider } = antd.Layout;
773
- const Sidebar = () => {
774
- const expandedKeys = useStore((state) => state.view.expandedKeys);
775
- const setExpandedKeys = useStore((state) => state.view.setExpandedKeys);
776
- const setSelectedApi = useStore((state) => state.view.setSelectedApi);
777
- const setSelectedEndpoint = useStore((state) => state.view.setSelectedEndpoint);
778
- const [selectedNode, setSelectedNodeState] = (0, react.useState)();
779
- const transformedData = useStore((state) => state.view.transformedData);
780
- const builtTreeData = (0, react.useMemo)(() => buildTreeDataStructure(transformedData), [transformedData]);
781
- const [searchValue, setSearchValue] = (0, react.useState)("");
782
- const [autoExpandParent, setAutoExpandParent] = (0, react.useState)(true);
783
- const { wrapSSR, cx } = useStyle("Sidebar", getSidebarStyles);
784
- const handleSearch = (value) => {
785
- if (value) {
786
- const allKeys = getAllTreeKeys(builtTreeData);
787
- setExpandedKeys(allKeys);
788
- setSearchValue(value);
789
- setAutoExpandParent(true);
790
- } else {
791
- setSearchValue(value);
792
- setAutoExpandParent(false);
793
- }
794
- };
795
- const renderTreeData = (0, react.useMemo)(() => {
796
- return convertToRenderableTreeData(builtTreeData, selectedNode, cx);
797
- }, [
798
- builtTreeData,
799
- selectedNode,
800
- cx
801
- ]);
802
- const filteredTreeData = (0, react.useMemo)(() => {
803
- if (!searchValue) return renderTreeData;
804
- const filteredOriginal = filterTreeData(builtTreeData, searchValue);
805
- return convertToRenderableTreeData(filteredOriginal, selectedNode, cx);
806
- }, [
807
- builtTreeData,
808
- searchValue,
809
- selectedNode,
810
- cx
811
- ]);
812
- const collapseAll = () => {
813
- setExpandedKeys([]);
814
- };
815
- const handleNodeSelection = (nodeData, nodeKey) => {
816
- if (!nodeData) return null;
817
- if (nodeKey.startsWith("endpoint-")) {
818
- const endpointNodeData = nodeData;
819
- setSelectedEndpoint(endpointNodeData.endpoint);
820
- setSelectedApi(endpointNodeData.api);
821
- return {
822
- type: "endpoint",
823
- endpoint: endpointNodeData.endpoint,
824
- api: endpointNodeData.api,
825
- tag: endpointNodeData.tagName
826
- };
827
- } else if (nodeKey.startsWith("api-") || nodeKey === "custom-auth") {
828
- const apiData = nodeData;
829
- setSelectedApi(apiData);
830
- setSelectedEndpoint(null);
831
- return {
832
- type: "api",
833
- api: apiData
834
- };
835
- } else {
836
- const tagData = nodeData;
837
- return {
838
- type: "tag",
839
- tag: tagData.tagName,
840
- api: tagData.apiData
841
- };
842
- }
843
- };
844
- const onTreeNodeSelect = (selectedKeys) => {
845
- const stringKeys = selectedKeys.map((key) => String(key));
846
- if (stringKeys.length === 0) {
847
- setSelectedNodeState([]);
848
- setSelectedApi(null);
849
- setSelectedEndpoint(null);
850
- return;
851
- }
852
- const selectedKey = stringKeys[0];
853
- const selectedNode$1 = findNodeByKey(builtTreeData, selectedKey);
854
- if (selectedNode$1) handleNodeSelection(selectedNode$1.data, selectedKey);
855
- setSelectedNodeState(stringKeys);
856
- };
857
- return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sider, {
858
- width: 280,
859
- className: cx("sider"),
860
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
861
- className: cx("content"),
862
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
863
- className: cx("controls"),
864
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Input, {
865
- placeholder: "Search by APIs or Endpoints",
866
- value: searchValue,
867
- onChange: (e) => handleSearch(e.target.value),
868
- allowClear: true,
869
- className: cx("search-input")
870
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Button, {
871
- onClick: collapseAll,
872
- title: "Collapse All",
873
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Minify_default, {})
874
- })]
875
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(antd.Tree, {
876
- showLine: { showLeafIcon: false },
877
- showIcon: false,
878
- expandedKeys,
879
- autoExpandParent,
880
- selectedKeys: selectedNode,
881
- onSelect: onTreeNodeSelect,
882
- onExpand: (expandedKeysValue) => {
883
- setExpandedKeys(expandedKeysValue);
884
- setAutoExpandParent(false);
885
- },
886
- treeData: filteredTreeData,
887
- className: cx("tree")
888
- })]
889
- })
890
- }));
891
- };
151
+ function Sidebar() {
152
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "Sidebar" });
153
+ }
892
154
 
893
155
  //#endregion
894
156
  //#region src/view/components/MainContent.tsx
895
157
  const MainContent = () => {
896
- const { wrapSSR, cx } = useStyle("MainContent", (token$1, scope) => ({ [scope("container")]: {
897
- backgroundColor: token$1.colorBgContainer,
158
+ const { wrapSSR, cx } = useStyle("MainContent", (token, scope) => ({ [scope("container")]: {
159
+ backgroundColor: token.colorBgContainer,
898
160
  height: "100%",
899
161
  width: "100%",
900
162
  maxHeight: "100%",
901
163
  overflow: "auto",
902
- borderRadius: token$1.borderRadius,
903
- padding: token$1.paddingXL
164
+ borderRadius: token.borderRadius,
165
+ padding: token.paddingXL
904
166
  } }));
905
167
  return wrapSSR(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: cx("container") }));
906
168
  };
907
169
 
908
170
  //#endregion
909
- //#region src/view/layout.tsx
910
- function ErrorBoundary({ children }) {
911
- const [error, setError] = (0, react.useState)(null);
912
- if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
913
- style: {
914
- color: "red",
915
- padding: 24
916
- },
917
- children: [
918
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "Something went wrong in DocumentationLayout." }),
919
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { children: error.message }),
920
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { children: error.stack })
921
- ]
922
- });
923
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorCatcher, {
924
- onError: setError,
925
- children
926
- });
927
- }
928
- var ErrorCatcher = class extends react.default.Component {
929
- componentDidCatch(error) {
930
- this.props.onError(error);
931
- }
932
- render() {
933
- return this.props.children;
171
+ //#region src/view/helper/mutate.ts
172
+ const transformOpenApiToDocs = (api) => {
173
+ const groupedPathsByTags = { default: [] };
174
+ const validTags = new Set(api?.tags?.map(({ name }) => name) || []);
175
+ const contextPath = Object.keys(api.paths)[0];
176
+ for (const [path, methods] of Object.entries(api.paths)) for (const [method, methodData] of Object.entries(methods)) {
177
+ const entry = {
178
+ ...methodData,
179
+ method: method?.toUpperCase(),
180
+ path
181
+ };
182
+ const resourceTags = methodData.tags ?? [];
183
+ const matchedTags = resourceTags.filter((tag) => validTags.has(tag));
184
+ if (matchedTags.length > 0) matchedTags.forEach((tag) => {
185
+ if (!groupedPathsByTags[tag]) groupedPathsByTags[tag] = [];
186
+ groupedPathsByTags[tag].push({
187
+ ...entry,
188
+ id: `endpoint-${(0, nanoid.nanoid)(8)}`
189
+ });
190
+ });
191
+ else groupedPathsByTags.default.push({
192
+ ...entry,
193
+ id: `endpoint-${(0, nanoid.nanoid)(8)}`
194
+ });
934
195
  }
196
+ return {
197
+ ...api.info,
198
+ id: `api-${(0, nanoid.nanoid)(8)}`,
199
+ contextPath,
200
+ tags: groupedPathsByTags,
201
+ servers: api.servers
202
+ };
935
203
  };
936
- const DocumentationLayout = () => {
937
- const { cx } = useStyle("DocumentationLayout", (token$1, scope) => ({
204
+
205
+ //#endregion
206
+ //#region src/view/layout.tsx
207
+ const DocumentationLayout = ({ data }) => {
208
+ const { setOriginalData } = store_default(({ view }) => view);
209
+ const { setTransformedData } = store_default(({ view }) => view);
210
+ (0, react.useEffect)(() => {
211
+ setOriginalData(data);
212
+ const transformedData = data.map(transformOpenApiToDocs);
213
+ setTransformedData(transformedData);
214
+ }, [data]);
215
+ const { cx } = useStyle("DocumentationLayout", (token, scope) => ({
938
216
  [scope("container")]: {
939
217
  display: "flex",
940
218
  flexDirection: "column",
941
- gap: token$1.marginLG,
219
+ gap: token.marginLG,
942
220
  height: "100%",
943
221
  maxHeight: "100%",
944
222
  overflow: "hidden"
@@ -948,16 +226,16 @@ const DocumentationLayout = () => {
948
226
  height: "100%",
949
227
  maxHeight: "100%",
950
228
  overflow: "hidden",
951
- gap: token$1.marginLG
229
+ gap: token.marginLG
952
230
  }
953
231
  }));
954
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ant_design_nextjs_registry.AntdRegistry, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
232
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ant_design_nextjs_registry.AntdRegistry, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
955
233
  className: cx("container"),
956
234
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Header, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
957
235
  className: cx("layout"),
958
236
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sidebar, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MainContent, {})]
959
237
  })]
960
- }) }) });
238
+ }) });
961
239
  };
962
240
 
963
241
  //#endregion