@oneuptime/common 8.0.5151 → 8.0.5159
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/Server/Utils/Telemetry/CaptureSpan.ts +0 -4
- package/UI/Components/JSONTable/JSONTable.tsx +179 -0
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +93 -18
- package/build/dist/Server/Utils/Telemetry/CaptureSpan.js +1 -1
- package/build/dist/Server/Utils/Telemetry/CaptureSpan.js.map +1 -1
- package/build/dist/UI/Components/JSONTable/JSONTable.js +110 -0
- package/build/dist/UI/Components/JSONTable/JSONTable.js.map +1 -0
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +64 -16
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React, { FunctionComponent, ReactElement, useMemo } from "react";
|
|
2
|
+
import CopyableButton from "../CopyableButton/CopyableButton";
|
|
3
|
+
import JSONFunctions from "../../../Types/JSONFunctions";
|
|
4
|
+
|
|
5
|
+
export interface JSONTableProps {
|
|
6
|
+
json: { [key: string]: any } | null | undefined;
|
|
7
|
+
title?: string | undefined;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
// Always flattened (dot notation) for consistency.
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface FlatItem {
|
|
13
|
+
key: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizeValue(value: unknown): string {
|
|
18
|
+
if (value === null || value === undefined) {
|
|
19
|
+
return "-";
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
try {
|
|
23
|
+
return JSON.stringify(value);
|
|
24
|
+
} catch {
|
|
25
|
+
return "[Object]";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === "boolean") {
|
|
29
|
+
return value ? "true" : "false";
|
|
30
|
+
}
|
|
31
|
+
// Fallback for numbers / strings / bigint / symbol etc.
|
|
32
|
+
return String(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const JSONTable: FunctionComponent<JSONTableProps> = (
|
|
36
|
+
props: JSONTableProps,
|
|
37
|
+
): ReactElement => {
|
|
38
|
+
const { json } = props;
|
|
39
|
+
|
|
40
|
+
const flatItems: Array<FlatItem> = useMemo(() => {
|
|
41
|
+
if (!json) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const working: { [key: string]: any } = JSONFunctions.flattenObject(
|
|
46
|
+
JSONFunctions.nestJson(json),
|
|
47
|
+
) as { [key: string]: any };
|
|
48
|
+
|
|
49
|
+
// Post-process flattened keys to group primitive arrays: prefix.0, prefix.1 => prefix: [v0, v1]
|
|
50
|
+
// We ONLY group if all matching keys are simple (no deeper nesting like prefix.0.field)
|
|
51
|
+
type GroupEntry = { index: number; value: unknown };
|
|
52
|
+
type GroupMap = { [prefix: string]: Array<GroupEntry> };
|
|
53
|
+
const groupMap: GroupMap = {};
|
|
54
|
+
const keys: Array<string> = Object.keys(working);
|
|
55
|
+
|
|
56
|
+
// Track keys that should be removed after grouping
|
|
57
|
+
const keysToRemove: Set<string> = new Set();
|
|
58
|
+
|
|
59
|
+
// Helper to detect if a key has nested descendants
|
|
60
|
+
const hasNestedDescendant: (k: string) => boolean = (
|
|
61
|
+
k: string,
|
|
62
|
+
): boolean => {
|
|
63
|
+
const descendantPrefix: string = k + "."; // e.g. arr.0.
|
|
64
|
+
return keys.some((other: string) => {
|
|
65
|
+
return other.startsWith(descendantPrefix);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
for (const key of keys) {
|
|
70
|
+
const match: RegExpMatchArray | null = key.match(/^(.*)\.(\d+)$/);
|
|
71
|
+
if (!match || match.length < 3) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const prefix: string = match[1] as string;
|
|
75
|
+
const indexStr: string = match[2] as string;
|
|
76
|
+
const index: number = parseInt(indexStr, 10);
|
|
77
|
+
|
|
78
|
+
// Skip if this index key has further nesting (e.g., arr.0.field)
|
|
79
|
+
if (hasNestedDescendant(key)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!groupMap[prefix]) {
|
|
84
|
+
groupMap[prefix] = [];
|
|
85
|
+
}
|
|
86
|
+
groupMap[prefix].push({ index, value: working[key] });
|
|
87
|
+
keysToRemove.add(key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Apply grouping where it makes sense (only if at least 2 items or at least 1 and prefix not already defined)
|
|
91
|
+
for (const prefix in groupMap) {
|
|
92
|
+
const arr: Array<GroupEntry> = groupMap[prefix] || [];
|
|
93
|
+
if (arr.length === 0) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Sort by numeric index
|
|
97
|
+
arr.sort((a: GroupEntry, b: GroupEntry): number => {
|
|
98
|
+
return a.index - b.index;
|
|
99
|
+
});
|
|
100
|
+
// Always override / set grouped array representation.
|
|
101
|
+
working[prefix] = arr.map((i: GroupEntry) => {
|
|
102
|
+
return i.value;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Remove grouped index keys
|
|
107
|
+
for (const k of keysToRemove) {
|
|
108
|
+
delete working[k];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return Object.keys(working)
|
|
112
|
+
.sort()
|
|
113
|
+
.map((key: string) => {
|
|
114
|
+
return { key, value: normalizeValue(working[key]) };
|
|
115
|
+
});
|
|
116
|
+
}, [json]);
|
|
117
|
+
|
|
118
|
+
if (!flatItems.length) {
|
|
119
|
+
return (
|
|
120
|
+
<div className="border border-dashed border-gray-300 rounded-md p-4 text-sm text-gray-500 bg-gray-50">
|
|
121
|
+
No attributes.
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className={props.className}>
|
|
128
|
+
{props.title && (
|
|
129
|
+
<div className="text-sm font-semibold text-gray-700 mb-2">
|
|
130
|
+
{props.title}
|
|
131
|
+
</div>
|
|
132
|
+
)}
|
|
133
|
+
<div className="overflow-hidden border border-gray-200 rounded-md">
|
|
134
|
+
<table className="min-w-full table-fixed">
|
|
135
|
+
<thead>
|
|
136
|
+
<tr className="bg-gray-50 text-xs uppercase tracking-wider text-left text-gray-500">
|
|
137
|
+
<th className="px-3 py-2 w-1/3">Key</th>
|
|
138
|
+
<th className="px-3 py-2">Value</th>
|
|
139
|
+
</tr>
|
|
140
|
+
</thead>
|
|
141
|
+
<tbody className="divide-y divide-gray-100">
|
|
142
|
+
{flatItems.map((item: FlatItem) => {
|
|
143
|
+
return (
|
|
144
|
+
<tr key={item.key} className="group hover:bg-gray-50 text-sm">
|
|
145
|
+
<td className="font-mono px-3 py-2 align-top text-gray-700 break-all whitespace-pre-wrap">
|
|
146
|
+
{item.key}
|
|
147
|
+
</td>
|
|
148
|
+
<td className="px-3 py-2 align-top break-all whitespace-pre-wrap font-mono text-gray-800">
|
|
149
|
+
<div className="flex items-start">
|
|
150
|
+
<div className="flex-1 pr-2">
|
|
151
|
+
{item.value.length > 500 ? (
|
|
152
|
+
<details>
|
|
153
|
+
<summary className="cursor-pointer select-none text-gray-600">
|
|
154
|
+
Show value ({item.value.length} chars)
|
|
155
|
+
</summary>
|
|
156
|
+
<pre className="mt-1 text-xs overflow-auto max-h-64">
|
|
157
|
+
{item.value}
|
|
158
|
+
</pre>
|
|
159
|
+
</details>
|
|
160
|
+
) : (
|
|
161
|
+
<span>{item.value}</span>
|
|
162
|
+
)}
|
|
163
|
+
</div>
|
|
164
|
+
<div className="opacity-0 group-hover:opacity-100 transition-opacity duration-150">
|
|
165
|
+
<CopyableButton textToBeCopied={item.value} />
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</td>
|
|
169
|
+
</tr>
|
|
170
|
+
);
|
|
171
|
+
})}
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default JSONTable;
|
|
@@ -14,14 +14,14 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
14
14
|
props: ComponentProps,
|
|
15
15
|
): ReactElement => {
|
|
16
16
|
return (
|
|
17
|
-
<div>
|
|
17
|
+
<div className="max-w-none p-3">
|
|
18
18
|
<ReactMarkdown
|
|
19
19
|
components={{
|
|
20
20
|
// because tailwind does not supply <h1 ... /> styles https://tailwindcss.com/docs/preflight#headings-are-unstyled
|
|
21
21
|
h1: ({ ...props }: any) => {
|
|
22
22
|
return (
|
|
23
23
|
<h1
|
|
24
|
-
className="text-
|
|
24
|
+
className="text-4xl mt-8 mb-6 border-b-2 border-blue-500 pb-2 text-gray-900 font-bold"
|
|
25
25
|
{...props}
|
|
26
26
|
/>
|
|
27
27
|
);
|
|
@@ -29,7 +29,7 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
29
29
|
h2: ({ ...props }: any) => {
|
|
30
30
|
return (
|
|
31
31
|
<h2
|
|
32
|
-
className="text-
|
|
32
|
+
className="text-3xl mt-6 mb-4 border-b border-gray-300 pb-1 text-gray-900 font-semibold"
|
|
33
33
|
{...props}
|
|
34
34
|
/>
|
|
35
35
|
);
|
|
@@ -37,7 +37,7 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
37
37
|
h3: ({ ...props }: any) => {
|
|
38
38
|
return (
|
|
39
39
|
<h3
|
|
40
|
-
className="text-
|
|
40
|
+
className="text-2xl mt-6 mb-3 text-gray-900 font-semibold"
|
|
41
41
|
{...props}
|
|
42
42
|
/>
|
|
43
43
|
);
|
|
@@ -45,7 +45,7 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
45
45
|
h4: ({ ...props }: any) => {
|
|
46
46
|
return (
|
|
47
47
|
<h4
|
|
48
|
-
className="text-
|
|
48
|
+
className="text-xl mt-5 mb-3 text-gray-900 font-medium"
|
|
49
49
|
{...props}
|
|
50
50
|
/>
|
|
51
51
|
);
|
|
@@ -53,7 +53,7 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
53
53
|
h5: ({ ...props }: any) => {
|
|
54
54
|
return (
|
|
55
55
|
<h5
|
|
56
|
-
className="text-lg mt-
|
|
56
|
+
className="text-lg mt-4 mb-2 text-gray-900 font-medium"
|
|
57
57
|
{...props}
|
|
58
58
|
/>
|
|
59
59
|
);
|
|
@@ -61,43 +61,116 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
61
61
|
h6: ({ ...props }: any) => {
|
|
62
62
|
return (
|
|
63
63
|
<h6
|
|
64
|
-
className="text-base mt-3 text-gray-
|
|
64
|
+
className="text-base mt-3 mb-2 text-gray-900 font-medium"
|
|
65
65
|
{...props}
|
|
66
66
|
/>
|
|
67
67
|
);
|
|
68
68
|
},
|
|
69
69
|
p: ({ ...props }: any) => {
|
|
70
|
-
return
|
|
70
|
+
return (
|
|
71
|
+
<p
|
|
72
|
+
className="text-base mt-3 mb-4 text-gray-700 leading-relaxed"
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
71
76
|
},
|
|
72
77
|
a: ({ ...props }: any) => {
|
|
73
78
|
return (
|
|
74
|
-
<a
|
|
79
|
+
<a
|
|
80
|
+
className="underline text-blue-600 hover:text-blue-800 font-medium transition-colors"
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
75
83
|
);
|
|
76
84
|
},
|
|
77
85
|
|
|
78
|
-
pre: ({ ...
|
|
86
|
+
pre: ({ children, ...rest }: any) => {
|
|
87
|
+
// Avoid double borders when SyntaxHighlighter is already styling the block.
|
|
88
|
+
const isSyntaxHighlighter: boolean =
|
|
89
|
+
React.isValidElement(children) &&
|
|
90
|
+
// name can be 'SyntaxHighlighter' or wrapped/minified; fall back to presence of 'children' prop with 'react-syntax-highlighter' data attribute.
|
|
91
|
+
(((children as any).type &&
|
|
92
|
+
((children as any).type.name === "SyntaxHighlighter" ||
|
|
93
|
+
(children as any).type.displayName ===
|
|
94
|
+
"SyntaxHighlighter")) ||
|
|
95
|
+
(children as any).props?.className?.includes(
|
|
96
|
+
"syntax-highlighter",
|
|
97
|
+
));
|
|
98
|
+
|
|
99
|
+
const baseClass: string = isSyntaxHighlighter
|
|
100
|
+
? "mt-4 mb-4 rounded-lg overflow-hidden"
|
|
101
|
+
: "bg-gray-900 text-gray-100 mt-4 mb-4 p-4 rounded-lg text-sm overflow-x-auto border border-gray-700";
|
|
102
|
+
|
|
79
103
|
return (
|
|
80
|
-
<pre
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/>
|
|
104
|
+
<pre className={baseClass} {...rest}>
|
|
105
|
+
{children}
|
|
106
|
+
</pre>
|
|
84
107
|
);
|
|
85
108
|
},
|
|
86
109
|
strong: ({ ...props }: any) => {
|
|
87
110
|
return (
|
|
88
111
|
<strong
|
|
89
|
-
className="text-
|
|
112
|
+
className="text-base font-semibold text-gray-900"
|
|
90
113
|
{...props}
|
|
91
114
|
/>
|
|
92
115
|
);
|
|
93
116
|
},
|
|
94
117
|
li: ({ ...props }: any) => {
|
|
95
118
|
return (
|
|
96
|
-
<li
|
|
119
|
+
<li
|
|
120
|
+
className="text-base mt-2 mb-1 text-gray-700 leading-relaxed"
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
97
123
|
);
|
|
98
124
|
},
|
|
99
125
|
ul: ({ ...props }: any) => {
|
|
100
|
-
return <ul className="list-disc
|
|
126
|
+
return <ul className="list-disc pl-8 mt-2 mb-4" {...props} />;
|
|
127
|
+
},
|
|
128
|
+
ol: ({ ...props }: any) => {
|
|
129
|
+
return <ol className="list-decimal pl-8 mt-2 mb-4" {...props} />;
|
|
130
|
+
},
|
|
131
|
+
blockquote: ({ ...props }: any) => {
|
|
132
|
+
return (
|
|
133
|
+
<blockquote
|
|
134
|
+
className="border-l-4 border-blue-500 pl-4 italic text-gray-600 bg-gray-50 py-2 my-4"
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
table: ({ ...props }: any) => {
|
|
140
|
+
return (
|
|
141
|
+
<table
|
|
142
|
+
className="min-w-full table-auto border-collapse border border-gray-300 mt-4 mb-4"
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
thead: ({ ...props }: any) => {
|
|
148
|
+
return <thead className="bg-gray-100" {...props} />;
|
|
149
|
+
},
|
|
150
|
+
tbody: ({ ...props }: any) => {
|
|
151
|
+
return <tbody {...props} />;
|
|
152
|
+
},
|
|
153
|
+
tr: ({ ...props }: any) => {
|
|
154
|
+
return <tr className="border-b border-gray-200" {...props} />;
|
|
155
|
+
},
|
|
156
|
+
th: ({ ...props }: any) => {
|
|
157
|
+
return (
|
|
158
|
+
<th
|
|
159
|
+
className="px-4 py-2 text-left text-sm font-semibold text-gray-900 border border-gray-300"
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
td: ({ ...props }: any) => {
|
|
165
|
+
return (
|
|
166
|
+
<td
|
|
167
|
+
className="px-4 py-2 text-sm text-gray-700 border border-gray-300"
|
|
168
|
+
{...props}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
hr: ({ ...props }: any) => {
|
|
173
|
+
return <hr className="border-gray-300 my-6" {...props} />;
|
|
101
174
|
},
|
|
102
175
|
code: (props: any) => {
|
|
103
176
|
const { children, className, ...rest } = props;
|
|
@@ -118,7 +191,7 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
118
191
|
return item.includes("language-");
|
|
119
192
|
}).length > 0)
|
|
120
193
|
? ""
|
|
121
|
-
: "text-sm
|
|
194
|
+
: "text-sm px-2 py-1 bg-gray-200 rounded text-gray-900 font-mono";
|
|
122
195
|
|
|
123
196
|
return match ? (
|
|
124
197
|
<SyntaxHighlighter
|
|
@@ -128,6 +201,8 @@ const MarkdownViewer: FunctionComponent<ComponentProps> = (
|
|
|
128
201
|
children={content}
|
|
129
202
|
language={match[1]}
|
|
130
203
|
style={a11yDark}
|
|
204
|
+
className="rounded-lg mt-4 mb-4 !bg-gray-900 !p-4 text-sm"
|
|
205
|
+
codeTagProps={{ className: "font-mono" }}
|
|
131
206
|
/>
|
|
132
207
|
) : (
|
|
133
208
|
<code className={codeClassName} {...rest}>
|
|
@@ -32,7 +32,7 @@ function CaptureSpan(data) {
|
|
|
32
32
|
return Telemetry.startActiveSpan({
|
|
33
33
|
name: name,
|
|
34
34
|
options: {
|
|
35
|
-
attributes: Object.assign(
|
|
35
|
+
attributes: Object.assign({}, spanAttributes),
|
|
36
36
|
},
|
|
37
37
|
fn: (span) => {
|
|
38
38
|
let result = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptureSpan.js","sourceRoot":"","sources":["../../../../../Server/Utils/Telemetry/CaptureSpan.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAQ,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,aAAa,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,SAAS,WAAW,CAAC,IAIpB;IAKC,OAAO,UACL,MAAW,EACX,WAAmB,EACnB,UAAwC;;QAExC,MAAM,cAAc,GAAQ,UAAU,CAAC,KAAK,CAAC;QAE7C,IAAI,SAAS,GAAuB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,0CAAE,IAAI,CAAC;QAE9D,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;YACjD,MAAM,eAAe,GAAuB,MAAM,aAAN,MAAM,uBAAN,MAAM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AAM,YAAY,OAAO,CAAC,EAAE,CAAC;4BACjC,IAAI,CAAC,GAAG,EAAE,CAAC;wBACb,CAAC;oBACH,CAAC;gBACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import CopyableButton from "../CopyableButton/CopyableButton";
|
|
3
|
+
import JSONFunctions from "../../../Types/JSONFunctions";
|
|
4
|
+
function normalizeValue(value) {
|
|
5
|
+
if (value === null || value === undefined) {
|
|
6
|
+
return "-";
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === "object") {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.stringify(value);
|
|
11
|
+
}
|
|
12
|
+
catch (_a) {
|
|
13
|
+
return "[Object]";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === "boolean") {
|
|
17
|
+
return value ? "true" : "false";
|
|
18
|
+
}
|
|
19
|
+
// Fallback for numbers / strings / bigint / symbol etc.
|
|
20
|
+
return String(value);
|
|
21
|
+
}
|
|
22
|
+
const JSONTable = (props) => {
|
|
23
|
+
const { json } = props;
|
|
24
|
+
const flatItems = useMemo(() => {
|
|
25
|
+
if (!json) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const working = JSONFunctions.flattenObject(JSONFunctions.nestJson(json));
|
|
29
|
+
const groupMap = {};
|
|
30
|
+
const keys = Object.keys(working);
|
|
31
|
+
// Track keys that should be removed after grouping
|
|
32
|
+
const keysToRemove = new Set();
|
|
33
|
+
// Helper to detect if a key has nested descendants
|
|
34
|
+
const hasNestedDescendant = (k) => {
|
|
35
|
+
const descendantPrefix = k + "."; // e.g. arr.0.
|
|
36
|
+
return keys.some((other) => {
|
|
37
|
+
return other.startsWith(descendantPrefix);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
const match = key.match(/^(.*)\.(\d+)$/);
|
|
42
|
+
if (!match || match.length < 3) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const prefix = match[1];
|
|
46
|
+
const indexStr = match[2];
|
|
47
|
+
const index = parseInt(indexStr, 10);
|
|
48
|
+
// Skip if this index key has further nesting (e.g., arr.0.field)
|
|
49
|
+
if (hasNestedDescendant(key)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (!groupMap[prefix]) {
|
|
53
|
+
groupMap[prefix] = [];
|
|
54
|
+
}
|
|
55
|
+
groupMap[prefix].push({ index, value: working[key] });
|
|
56
|
+
keysToRemove.add(key);
|
|
57
|
+
}
|
|
58
|
+
// Apply grouping where it makes sense (only if at least 2 items or at least 1 and prefix not already defined)
|
|
59
|
+
for (const prefix in groupMap) {
|
|
60
|
+
const arr = groupMap[prefix] || [];
|
|
61
|
+
if (arr.length === 0) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Sort by numeric index
|
|
65
|
+
arr.sort((a, b) => {
|
|
66
|
+
return a.index - b.index;
|
|
67
|
+
});
|
|
68
|
+
// Always override / set grouped array representation.
|
|
69
|
+
working[prefix] = arr.map((i) => {
|
|
70
|
+
return i.value;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// Remove grouped index keys
|
|
74
|
+
for (const k of keysToRemove) {
|
|
75
|
+
delete working[k];
|
|
76
|
+
}
|
|
77
|
+
return Object.keys(working)
|
|
78
|
+
.sort()
|
|
79
|
+
.map((key) => {
|
|
80
|
+
return { key, value: normalizeValue(working[key]) };
|
|
81
|
+
});
|
|
82
|
+
}, [json]);
|
|
83
|
+
if (!flatItems.length) {
|
|
84
|
+
return (React.createElement("div", { className: "border border-dashed border-gray-300 rounded-md p-4 text-sm text-gray-500 bg-gray-50" }, "No attributes."));
|
|
85
|
+
}
|
|
86
|
+
return (React.createElement("div", { className: props.className },
|
|
87
|
+
props.title && (React.createElement("div", { className: "text-sm font-semibold text-gray-700 mb-2" }, props.title)),
|
|
88
|
+
React.createElement("div", { className: "overflow-hidden border border-gray-200 rounded-md" },
|
|
89
|
+
React.createElement("table", { className: "min-w-full table-fixed" },
|
|
90
|
+
React.createElement("thead", null,
|
|
91
|
+
React.createElement("tr", { className: "bg-gray-50 text-xs uppercase tracking-wider text-left text-gray-500" },
|
|
92
|
+
React.createElement("th", { className: "px-3 py-2 w-1/3" }, "Key"),
|
|
93
|
+
React.createElement("th", { className: "px-3 py-2" }, "Value"))),
|
|
94
|
+
React.createElement("tbody", { className: "divide-y divide-gray-100" }, flatItems.map((item) => {
|
|
95
|
+
return (React.createElement("tr", { key: item.key, className: "group hover:bg-gray-50 text-sm" },
|
|
96
|
+
React.createElement("td", { className: "font-mono px-3 py-2 align-top text-gray-700 break-all whitespace-pre-wrap" }, item.key),
|
|
97
|
+
React.createElement("td", { className: "px-3 py-2 align-top break-all whitespace-pre-wrap font-mono text-gray-800" },
|
|
98
|
+
React.createElement("div", { className: "flex items-start" },
|
|
99
|
+
React.createElement("div", { className: "flex-1 pr-2" }, item.value.length > 500 ? (React.createElement("details", null,
|
|
100
|
+
React.createElement("summary", { className: "cursor-pointer select-none text-gray-600" },
|
|
101
|
+
"Show value (",
|
|
102
|
+
item.value.length,
|
|
103
|
+
" chars)"),
|
|
104
|
+
React.createElement("pre", { className: "mt-1 text-xs overflow-auto max-h-64" }, item.value))) : (React.createElement("span", null, item.value))),
|
|
105
|
+
React.createElement("div", { className: "opacity-0 group-hover:opacity-100 transition-opacity duration-150" },
|
|
106
|
+
React.createElement(CopyableButton, { textToBeCopied: item.value }))))));
|
|
107
|
+
}))))));
|
|
108
|
+
};
|
|
109
|
+
export default JSONTable;
|
|
110
|
+
//# sourceMappingURL=JSONTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONTable.js","sourceRoot":"","sources":["../../../../../UI/Components/JSONTable/JSONT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,SAAS,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,EAAE;oBAChC,OAAO,CACL,4BAAI,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAC,gCAAgC;wBAC3D,4BAAI,SAAS,EAAC,2EAA2E,IACtF,IAAI,CAAC,GAAG,CACN;wBACL,4BAAI,SAAS,EAAC,2EAA2E;4BACvF,6BAAK,SAAS,EAAC,kBAAkB;gCAC/B,6BAAK,SAAS,EAAC,aAAa,IACzB,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CACzB;oCACE,iCAAS,SAAS,EAAC,0CAA0C;;wCAC9C,IAAI,CAAC,KAAK,CAAC,MAAM;kDACtB;oCACV,6BAAK,SAAS,EAAC,qCAAqC,IACjD,IAAI,CAAC,KAAK,CACP,CACE,CACX,CAAC,CAAC,CAAC,CACF,kCAAO,IAAI,CAAC,KAAK,CAAQ,CAC1B,CACG;gCACN,6BAAK,SAAS,EAAC,mEAAmE;oCAChF,oBAAC,cAAc,IAAC,cAAc,EAAE,IAAI,CAAC,KAAK,GAAI,CAC1C,CACF,CACH,CACF,CACN,CAAC;gBACJ,CAAC,CAAC,CACI,CACF,CACJ,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -17,56 +17,104 @@ import remarkGfm from "remark-gfm";
|
|
|
17
17
|
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
18
18
|
import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism";
|
|
19
19
|
const MarkdownViewer = (props) => {
|
|
20
|
-
return (React.createElement("div",
|
|
20
|
+
return (React.createElement("div", { className: "max-w-none p-3" },
|
|
21
21
|
React.createElement(ReactMarkdown, { components: {
|
|
22
22
|
// because tailwind does not supply <h1 ... /> styles https://tailwindcss.com/docs/preflight#headings-are-unstyled
|
|
23
23
|
h1: (_a) => {
|
|
24
24
|
var props = __rest(_a, []);
|
|
25
|
-
return (React.createElement("h1", Object.assign({ className: "text-
|
|
25
|
+
return (React.createElement("h1", Object.assign({ className: "text-4xl mt-8 mb-6 border-b-2 border-blue-500 pb-2 text-gray-900 font-bold" }, props)));
|
|
26
26
|
},
|
|
27
27
|
h2: (_a) => {
|
|
28
28
|
var props = __rest(_a, []);
|
|
29
|
-
return (React.createElement("h2", Object.assign({ className: "text-
|
|
29
|
+
return (React.createElement("h2", Object.assign({ className: "text-3xl mt-6 mb-4 border-b border-gray-300 pb-1 text-gray-900 font-semibold" }, props)));
|
|
30
30
|
},
|
|
31
31
|
h3: (_a) => {
|
|
32
32
|
var props = __rest(_a, []);
|
|
33
|
-
return (React.createElement("h3", Object.assign({ className: "text-
|
|
33
|
+
return (React.createElement("h3", Object.assign({ className: "text-2xl mt-6 mb-3 text-gray-900 font-semibold" }, props)));
|
|
34
34
|
},
|
|
35
35
|
h4: (_a) => {
|
|
36
36
|
var props = __rest(_a, []);
|
|
37
|
-
return (React.createElement("h4", Object.assign({ className: "text-
|
|
37
|
+
return (React.createElement("h4", Object.assign({ className: "text-xl mt-5 mb-3 text-gray-900 font-medium" }, props)));
|
|
38
38
|
},
|
|
39
39
|
h5: (_a) => {
|
|
40
40
|
var props = __rest(_a, []);
|
|
41
|
-
return (React.createElement("h5", Object.assign({ className: "text-lg mt-
|
|
41
|
+
return (React.createElement("h5", Object.assign({ className: "text-lg mt-4 mb-2 text-gray-900 font-medium" }, props)));
|
|
42
42
|
},
|
|
43
43
|
h6: (_a) => {
|
|
44
44
|
var props = __rest(_a, []);
|
|
45
|
-
return (React.createElement("h6", Object.assign({ className: "text-base mt-3 text-gray-
|
|
45
|
+
return (React.createElement("h6", Object.assign({ className: "text-base mt-3 mb-2 text-gray-900 font-medium" }, props)));
|
|
46
46
|
},
|
|
47
47
|
p: (_a) => {
|
|
48
48
|
var props = __rest(_a, []);
|
|
49
|
-
return React.createElement("p", Object.assign({ className: "text-
|
|
49
|
+
return (React.createElement("p", Object.assign({ className: "text-base mt-3 mb-4 text-gray-700 leading-relaxed" }, props)));
|
|
50
50
|
},
|
|
51
51
|
a: (_a) => {
|
|
52
52
|
var props = __rest(_a, []);
|
|
53
|
-
return (React.createElement("a", Object.assign({ className: "underline text-blue-
|
|
53
|
+
return (React.createElement("a", Object.assign({ className: "underline text-blue-600 hover:text-blue-800 font-medium transition-colors" }, props)));
|
|
54
54
|
},
|
|
55
55
|
pre: (_a) => {
|
|
56
|
-
var
|
|
57
|
-
|
|
56
|
+
var _b, _c;
|
|
57
|
+
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
58
|
+
// Avoid double borders when SyntaxHighlighter is already styling the block.
|
|
59
|
+
const isSyntaxHighlighter = React.isValidElement(children) &&
|
|
60
|
+
// name can be 'SyntaxHighlighter' or wrapped/minified; fall back to presence of 'children' prop with 'react-syntax-highlighter' data attribute.
|
|
61
|
+
((children.type &&
|
|
62
|
+
(children.type.name === "SyntaxHighlighter" ||
|
|
63
|
+
children.type.displayName ===
|
|
64
|
+
"SyntaxHighlighter")) ||
|
|
65
|
+
((_c = (_b = children.props) === null || _b === void 0 ? void 0 : _b.className) === null || _c === void 0 ? void 0 : _c.includes("syntax-highlighter")));
|
|
66
|
+
const baseClass = isSyntaxHighlighter
|
|
67
|
+
? "mt-4 mb-4 rounded-lg overflow-hidden"
|
|
68
|
+
: "bg-gray-900 text-gray-100 mt-4 mb-4 p-4 rounded-lg text-sm overflow-x-auto border border-gray-700";
|
|
69
|
+
return (React.createElement("pre", Object.assign({ className: baseClass }, rest), children));
|
|
58
70
|
},
|
|
59
71
|
strong: (_a) => {
|
|
60
72
|
var props = __rest(_a, []);
|
|
61
|
-
return (React.createElement("strong", Object.assign({ className: "text-
|
|
73
|
+
return (React.createElement("strong", Object.assign({ className: "text-base font-semibold text-gray-900" }, props)));
|
|
62
74
|
},
|
|
63
75
|
li: (_a) => {
|
|
64
76
|
var props = __rest(_a, []);
|
|
65
|
-
return (React.createElement("li", Object.assign({ className: "text-
|
|
77
|
+
return (React.createElement("li", Object.assign({ className: "text-base mt-2 mb-1 text-gray-700 leading-relaxed" }, props)));
|
|
66
78
|
},
|
|
67
79
|
ul: (_a) => {
|
|
68
80
|
var props = __rest(_a, []);
|
|
69
|
-
return React.createElement("ul", Object.assign({ className: "list-disc
|
|
81
|
+
return React.createElement("ul", Object.assign({ className: "list-disc pl-8 mt-2 mb-4" }, props));
|
|
82
|
+
},
|
|
83
|
+
ol: (_a) => {
|
|
84
|
+
var props = __rest(_a, []);
|
|
85
|
+
return React.createElement("ol", Object.assign({ className: "list-decimal pl-8 mt-2 mb-4" }, props));
|
|
86
|
+
},
|
|
87
|
+
blockquote: (_a) => {
|
|
88
|
+
var props = __rest(_a, []);
|
|
89
|
+
return (React.createElement("blockquote", Object.assign({ className: "border-l-4 border-blue-500 pl-4 italic text-gray-600 bg-gray-50 py-2 my-4" }, props)));
|
|
90
|
+
},
|
|
91
|
+
table: (_a) => {
|
|
92
|
+
var props = __rest(_a, []);
|
|
93
|
+
return (React.createElement("table", Object.assign({ className: "min-w-full table-auto border-collapse border border-gray-300 mt-4 mb-4" }, props)));
|
|
94
|
+
},
|
|
95
|
+
thead: (_a) => {
|
|
96
|
+
var props = __rest(_a, []);
|
|
97
|
+
return React.createElement("thead", Object.assign({ className: "bg-gray-100" }, props));
|
|
98
|
+
},
|
|
99
|
+
tbody: (_a) => {
|
|
100
|
+
var props = __rest(_a, []);
|
|
101
|
+
return React.createElement("tbody", Object.assign({}, props));
|
|
102
|
+
},
|
|
103
|
+
tr: (_a) => {
|
|
104
|
+
var props = __rest(_a, []);
|
|
105
|
+
return React.createElement("tr", Object.assign({ className: "border-b border-gray-200" }, props));
|
|
106
|
+
},
|
|
107
|
+
th: (_a) => {
|
|
108
|
+
var props = __rest(_a, []);
|
|
109
|
+
return (React.createElement("th", Object.assign({ className: "px-4 py-2 text-left text-sm font-semibold text-gray-900 border border-gray-300" }, props)));
|
|
110
|
+
},
|
|
111
|
+
td: (_a) => {
|
|
112
|
+
var props = __rest(_a, []);
|
|
113
|
+
return (React.createElement("td", Object.assign({ className: "px-4 py-2 text-sm text-gray-700 border border-gray-300" }, props)));
|
|
114
|
+
},
|
|
115
|
+
hr: (_a) => {
|
|
116
|
+
var props = __rest(_a, []);
|
|
117
|
+
return React.createElement("hr", Object.assign({ className: "border-gray-300 my-6" }, props));
|
|
70
118
|
},
|
|
71
119
|
code: (props) => {
|
|
72
120
|
const { children, className } = props, rest = __rest(props, ["children", "className"]);
|
|
@@ -78,10 +126,10 @@ const MarkdownViewer = (props) => {
|
|
|
78
126
|
return item.includes("language-");
|
|
79
127
|
}).length) > 0)
|
|
80
128
|
? ""
|
|
81
|
-
: "text-sm
|
|
129
|
+
: "text-sm px-2 py-1 bg-gray-200 rounded text-gray-900 font-mono";
|
|
82
130
|
return match ? (React.createElement(SyntaxHighlighter, Object.assign({}, rest, { PreTag: "div",
|
|
83
131
|
// eslint-disable-next-line react/no-children-prop
|
|
84
|
-
children: content, language: match[1], style: a11yDark }))) : (React.createElement("code", Object.assign({ className: codeClassName }, rest), children));
|
|
132
|
+
children: content, language: match[1], style: a11yDark, className: "rounded-lg mt-4 mb-4 !bg-gray-900 !p-4 text-sm", codeTagProps: { className: "font-mono" } }))) : (React.createElement("code", Object.assign({ className: codeClassName }, rest), children));
|
|
85
133
|
},
|
|
86
134
|
}, remarkPlugins: [remarkGfm] }, props.text)));
|
|
87
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownViewer.js","sourceRoot":"","sources":["../../../../../UI/Components/Markdown.tsx/MarkdownViewer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAC/D,6CAA6C;AAC7C,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,yCAAyC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAM1E,MAAM,cAAc,GAAsC,CACxD,KAAqB,EACP,EAAE;IAChB,OAAO,CACL;
|
|
1
|
+
{"version":3,"file":"MarkdownViewer.js","sourceRoot":"","sources":["../../../../../UI/Components/Markdown.tsx/MarkdownViewer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAC/D,6CAA6C;AAC7C,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,yCAAyC;AACzC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAM1E,MAAM,cAAc,GAAsC,CACxD,KAAqB,EACP,EAAE;IAChB,OAAO,CACL,6BAAK,SAAS,EAAC,gBAAgB;QAC7B,oBAAC,aAAa,IACZ,UAAU,EAAE;gBACV,kHAAkH;gBAClH,EAAE,EAAE,CAAC,EAAiB,EAAE,EAAE;wBAAhB,KAAK,cAAV,EAAY,CAAF;oBACb,OAAO,CACL,0CACE,SAAS,EAAC,4EAA4E,IAClF,KAAK,EACT,CACH,CAAC;gBACJ,CAAC;gBACD,EAAE,EAAE,CAAC,EAAiB,EAAE,EAAE;wBAAhB,KAAK,cAAV,EAAY,CAAF;oBACb,OAAO,CACL,0CACE,SAAS,EAAC,8EAA8E,IACpF,KAAK,EACT,CACH,CAAC;gBACJ,CAAC;gBACD,EAAE,EAAE,CAAC,EAAiB,EAAE,EAAE;wBAAhB,KAAK,cAAV,EAAY,CAAF;oBACb,OAAO,CACL,0CACE,SAAS,EAAC,gDAAgD,IACtD,KAAK,EACT,CACH,CAAC;gBACJ,CAAC;gBACD,EAAE,EAAE,CAAC,EAAiB,EAAE,EAAE;wBAAhB,KAAK,cAAV,EAAY,CAAF;oBACb,OAAO,CACL,0CACE,SAAS,EAAC,6CAA6C,IACnD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