@niuhuoshan/dsh-connect 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +380 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +1489 -0
- package/lib/index.js +2303 -0
- package/lib/index.js.map +7 -0
- package/lib/types/client/ConnectSettings.d.ts +9 -0
- package/lib/types/client/ConnectSettings.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +5 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/rpc.d.ts +7 -0
- package/lib/types/client/rpc.d.ts.map +1 -0
- package/lib/types/client/styles.d.ts +3 -0
- package/lib/types/client/styles.d.ts.map +1 -0
- package/lib/types/domain.d.ts +156 -0
- package/lib/types/domain.d.ts.map +1 -0
- package/lib/types/host/datasource/clickhouse.d.ts +8 -0
- package/lib/types/host/datasource/clickhouse.d.ts.map +1 -0
- package/lib/types/host/datasource/index.d.ts +4 -0
- package/lib/types/host/datasource/index.d.ts.map +1 -0
- package/lib/types/host/datasource/mysql.d.ts +8 -0
- package/lib/types/host/datasource/mysql.d.ts.map +1 -0
- package/lib/types/host/datasource/postgresql.d.ts +8 -0
- package/lib/types/host/datasource/postgresql.d.ts.map +1 -0
- package/lib/types/host/datasource/provider.d.ts +24 -0
- package/lib/types/host/datasource/provider.d.ts.map +1 -0
- package/lib/types/host/http/conversation-api.d.ts +57 -0
- package/lib/types/host/http/conversation-api.d.ts.map +1 -0
- package/lib/types/host/http/executor.d.ts +10 -0
- package/lib/types/host/http/executor.d.ts.map +1 -0
- package/lib/types/host/http/security.d.ts +5 -0
- package/lib/types/host/http/security.d.ts.map +1 -0
- package/lib/types/host/http/tools.d.ts +13 -0
- package/lib/types/host/http/tools.d.ts.map +1 -0
- package/lib/types/host/metadata/enricher.d.ts +35 -0
- package/lib/types/host/metadata/enricher.d.ts.map +1 -0
- package/lib/types/host/metadata/governance.d.ts +4 -0
- package/lib/types/host/metadata/governance.d.ts.map +1 -0
- package/lib/types/host/metadata/profiler.d.ts +22 -0
- package/lib/types/host/metadata/profiler.d.ts.map +1 -0
- package/lib/types/host/metadata/tools.d.ts +4 -0
- package/lib/types/host/metadata/tools.d.ts.map +1 -0
- package/lib/types/host/rpc.d.ts +29 -0
- package/lib/types/host/rpc.d.ts.map +1 -0
- package/lib/types/host/store.d.ts +47 -0
- package/lib/types/host/store.d.ts.map +1 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/types.d.ts +395 -0
- package/lib/types/types.d.ts.map +1 -0
- package/package.json +121 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1489 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-connect",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name2 in all)
|
|
13
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/client/index.tsx
|
|
26
|
+
var index_exports = {};
|
|
27
|
+
__export(index_exports, {
|
|
28
|
+
apply: () => apply,
|
|
29
|
+
inject: () => inject,
|
|
30
|
+
name: () => name
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/client/ConnectSettings.tsx
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
37
|
+
|
|
38
|
+
// src/client/assets/clickhouse.svg
|
|
39
|
+
var clickhouse_default = 'data:image/svg+xml,<svg fill="%23FFCC01" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>ClickHouse</title><path d="M21.333 10H24v4h-2.667ZM16 1.335h2.667v21.33H16Zm-5.333 0h2.666v21.33h-2.666ZM0 22.665V1.335h2.667v21.33zm5.333-21.33H8v21.33H5.333Z"/></svg>';
|
|
40
|
+
|
|
41
|
+
// src/client/assets/mysql.svg
|
|
42
|
+
var mysql_default = 'data:image/svg+xml,<svg fill="%234479A1" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>MySQL</title><path d="M16.405 5.501c-.115 0-.193.014-.274.033v.013h.014c.054.104.146.18.214.273.054.107.1.214.154.32l.014-.015c.094-.066.14-.172.14-.333-.04-.047-.046-.094-.08-.14-.04-.067-.126-.1-.18-.153zM5.77 18.695h-.927a50.854 50.854 0 00-.27-4.41h-.008l-1.41 4.41H2.45l-1.4-4.41h-.01a72.892 72.892 0 00-.195 4.41H0c.055-1.966.192-3.81.41-5.53h1.15l1.335 4.064h.008l1.347-4.064h1.095c.242 2.015.384 3.86.428 5.53zm4.017-4.08c-.378 2.045-.876 3.533-1.492 4.46-.482.716-1.01 1.073-1.583 1.073-.153 0-.34-.046-.566-.138v-.494c.11.017.24.026.386.026.268 0 .483-.075.647-.222.197-.18.295-.382.295-.605 0-.155-.077-.47-.23-.944L6.23 14.615h.91l.727 2.36c.164.536.233.91.205 1.123.4-1.064.678-2.227.835-3.483zm12.325 4.08h-2.63v-5.53h.885v4.85h1.745zm-3.32.135l-1.016-.5c.09-.076.177-.158.255-.25.433-.506.648-1.258.648-2.253 0-1.83-.718-2.746-2.155-2.746-.704 0-1.254.232-1.65.697-.43.508-.646 1.256-.646 2.245 0 .972.19 1.686.574 2.14.35.41.877.615 1.583.615.264 0 .506-.033.725-.098l1.325.772.36-.622zM15.5 17.588c-.225-.36-.337-.94-.337-1.736 0-1.393.424-2.09 1.27-2.09.443 0 .77.167.977.5.224.362.336.936.336 1.723 0 1.404-.424 2.108-1.27 2.108-.445 0-.77-.167-.978-.5zm-1.658-.425c0 .47-.172.856-.516 1.156-.344.3-.803.45-1.384.45-.543 0-1.064-.172-1.573-.515l.237-.476c.438.22.833.328 1.19.328.332 0 .593-.073.783-.22a.754.754 0 00.3-.615c0-.33-.23-.61-.648-.845-.388-.213-1.163-.657-1.163-.657-.422-.307-.632-.636-.632-1.177 0-.45.157-.81.47-1.085.315-.278.72-.415 1.22-.415.512 0 .98.136 1.4.41l-.213.476a2.726 2.726 0 00-1.064-.23c-.283 0-.502.068-.654.206a.685.685 0 00-.248.524c0 .328.234.61.666.85.393.215 1.187.67 1.187.67.433.305.648.63.648 1.168zm9.382-5.852c-.535-.014-.95.04-1.297.188-.1.04-.26.04-.274.167.055.053.063.14.11.214.08.134.218.313.346.407.14.11.28.216.427.31.26.16.555.255.81.416.145.094.293.213.44.313.073.05.12.14.214.172v-.02c-.046-.06-.06-.147-.105-.214-.067-.067-.134-.127-.2-.193a3.223 3.223 0 00-.695-.675c-.214-.146-.682-.35-.77-.595l-.013-.014c.146-.013.32-.066.46-.106.227-.06.435-.047.67-.106.106-.027.213-.06.32-.094v-.06c-.12-.12-.21-.283-.334-.395a8.867 8.867 0 00-1.104-.823c-.21-.134-.476-.22-.697-.334-.08-.04-.214-.06-.26-.127-.12-.146-.19-.34-.275-.514a17.69 17.69 0 01-.547-1.163c-.12-.262-.193-.523-.34-.763-.69-1.137-1.437-1.826-2.586-2.5-.247-.14-.543-.2-.856-.274-.167-.008-.334-.02-.5-.027-.11-.047-.216-.174-.31-.235-.38-.24-1.364-.76-1.644-.072-.18.434.267.862.422 1.082.115.153.26.328.34.5.047.116.06.235.107.356.106.294.207.622.347.897.073.14.153.287.247.413.054.073.146.107.167.227-.094.136-.1.334-.154.5-.24.757-.146 1.693.194 2.25.107.166.362.534.703.393.3-.12.234-.5.32-.835.02-.08.007-.133.048-.187v.015c.094.188.188.367.274.555.206.328.566.668.867.895.16.12.287.328.487.402v-.02h-.015c-.043-.058-.1-.086-.154-.133a3.445 3.445 0 01-.35-.4 8.76 8.76 0 01-.747-1.218c-.11-.21-.202-.436-.29-.643-.04-.08-.04-.2-.107-.24-.1.146-.247.273-.32.453-.127.288-.14.642-.188 1.01-.027.007-.014 0-.027.014-.214-.052-.287-.274-.367-.46-.2-.475-.233-1.238-.06-1.785.047-.14.247-.582.167-.716-.042-.127-.174-.2-.247-.303a2.478 2.478 0 01-.24-.427c-.16-.374-.24-.788-.414-1.162-.08-.173-.22-.354-.334-.513-.127-.18-.267-.307-.368-.52-.033-.073-.08-.194-.027-.274.014-.054.042-.075.094-.09.088-.072.335.022.422.062.247.1.455.194.662.334.094.066.195.193.315.226h.14c.214.047.455.014.655.073.355.114.675.28.962.46a5.953 5.953 0 012.085 2.286c.08.154.115.295.188.455.14.33.313.663.455.982.14.315.275.636.476.897.1.14.502.213.682.286.133.06.34.115.46.188.23.14.454.3.67.454.11.076.443.243.463.378z"/></svg>';
|
|
43
|
+
|
|
44
|
+
// src/client/assets/postgresql.svg
|
|
45
|
+
var postgresql_default = 'data:image/svg+xml,<svg fill="%234169E1" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>PostgreSQL</title><path d="M23.5594 14.7228a.5269.5269 0 0 0-.0563-.1191c-.139-.2632-.4768-.3418-1.0074-.2321-1.6533.3411-2.2935.1312-2.5256-.0191 1.342-2.0482 2.445-4.522 3.0411-6.8297.2714-1.0507.7982-3.5237.1222-4.7316a1.5641 1.5641 0 0 0-.1509-.235C21.6931.9086 19.8007.0248 17.5099.0005c-1.4947-.0158-2.7705.3461-3.1161.4794a9.449 9.449 0 0 0-.5159-.0816 8.044 8.044 0 0 0-1.3114-.1278c-1.1822-.0184-2.2038.2642-3.0498.8406-.8573-.3211-4.7888-1.645-7.2219.0788C.9359 2.1526.3086 3.8733.4302 6.3043c.0409.818.5069 3.334 1.2423 5.7436.4598 1.5065.9387 2.7019 1.4334 3.582.553.9942 1.1259 1.5933 1.7143 1.7895.4474.1491 1.1327.1441 1.8581-.7279.8012-.9635 1.5903-1.8258 1.9446-2.2069.4351.2355.9064.3625 1.39.3772a.0569.0569 0 0 0 .0004.0041 11.0312 11.0312 0 0 0-.2472.3054c-.3389.4302-.4094.5197-1.5002.7443-.3102.064-1.1344.2339-1.1464.8115-.0025.1224.0329.2309.0919.3268.2269.4231.9216.6097 1.015.6331 1.3345.3335 2.5044.092 3.3714-.6787-.017 2.231.0775 4.4174.3454 5.0874.2212.5529.7618 1.9045 2.4692 1.9043.2505 0 .5263-.0291.8296-.0941 1.7819-.3821 2.5557-1.1696 2.855-2.9059.1503-.8707.4016-2.8753.5388-4.1012.0169-.0703.0357-.1207.057-.1362.0007-.0005.0697-.0471.4272.0307a.3673.3673 0 0 0 .0443.0068l.2539.0223.0149.001c.8468.0384 1.9114-.1426 2.5312-.4308.6438-.2988 1.8057-1.0323 1.5951-1.6698zM2.371 11.8765c-.7435-2.4358-1.1779-4.8851-1.2123-5.5719-.1086-2.1714.4171-3.6829 1.5623-4.4927 1.8367-1.2986 4.8398-.5408 6.108-.13-.0032.0032-.0066.0061-.0098.0094-2.0238 2.044-1.9758 5.536-1.9708 5.7495-.0002.0823.0066.1989.0162.3593.0348.5873.0996 1.6804-.0735 2.9184-.1609 1.1504.1937 2.2764.9728 3.0892.0806.0841.1648.1631.2518.2374-.3468.3714-1.1004 1.1926-1.9025 2.1576-.5677.6825-.9597.5517-1.0886.5087-.3919-.1307-.813-.5871-1.2381-1.3223-.4796-.839-.9635-2.0317-1.4155-3.5126zm6.0072 5.0871c-.1711-.0428-.3271-.1132-.4322-.1772.0889-.0394.2374-.0902.4833-.1409 1.2833-.2641 1.4815-.4506 1.9143-1.0002.0992-.126.2116-.2687.3673-.4426a.3549.3549 0 0 0 .0737-.1298c.1708-.1513.2724-.1099.4369-.0417.156.0646.3078.26.3695.4752.0291.1016.0619.2945-.0452.4444-.9043 1.2658-2.2216 1.2494-3.1676 1.0128zm2.094-3.988-.0525.141c-.133.3566-.2567.6881-.3334 1.003-.6674-.0021-1.3168-.2872-1.8105-.8024-.6279-.6551-.9131-1.5664-.7825-2.5004.1828-1.3079.1153-2.4468.079-3.0586-.005-.0857-.0095-.1607-.0122-.2199.2957-.2621 1.6659-.9962 2.6429-.7724.4459.1022.7176.4057.8305.928.5846 2.7038.0774 3.8307-.3302 4.7363-.084.1866-.1633.3629-.2311.5454zm7.3637 4.5725c-.0169.1768-.0358.376-.0618.5959l-.146.4383a.3547.3547 0 0 0-.0182.1077c-.0059.4747-.054.6489-.115.8693-.0634.2292-.1353.4891-.1794 1.0575-.11 1.4143-.8782 2.2267-2.4172 2.5565-1.5155.3251-1.7843-.4968-2.0212-1.2217a6.5824 6.5824 0 0 0-.0769-.2266c-.2154-.5858-.1911-1.4119-.1574-2.5551.0165-.5612-.0249-1.9013-.3302-2.6462.0044-.2932.0106-.5909.019-.8918a.3529.3529 0 0 0-.0153-.1126 1.4927 1.4927 0 0 0-.0439-.208c-.1226-.4283-.4213-.7866-.7797-.9351-.1424-.059-.4038-.1672-.7178-.0869.067-.276.1831-.5875.309-.9249l.0529-.142c.0595-.16.134-.3257.213-.5012.4265-.9476 1.0106-2.2453.3766-5.1772-.2374-1.0981-1.0304-1.6343-2.2324-1.5098-.7207.0746-1.3799.3654-1.7088.5321a5.6716 5.6716 0 0 0-.1958.1041c.0918-1.1064.4386-3.1741 1.7357-4.4823a4.0306 4.0306 0 0 1 .3033-.276.3532.3532 0 0 0 .1447-.0644c.7524-.5706 1.6945-.8506 2.802-.8325.4091.0067.8017.0339 1.1742.081 1.939.3544 3.2439 1.4468 4.0359 2.3827.8143.9623 1.2552 1.9315 1.4312 2.4543-1.3232-.1346-2.2234.1268-2.6797.779-.9926 1.4189.543 4.1729 1.2811 5.4964.1353.2426.2522.4522.2889.5413.2403.5825.5515.9713.7787 1.2552.0696.087.1372.1714.1885.245-.4008.1155-1.1208.3825-1.0552 1.717-.0123.1563-.0423.4469-.0834.8148-.0461.2077-.0702.4603-.0994.7662zm.8905-1.6211c-.0405-.8316.2691-.9185.5967-1.0105a2.8566 2.8566 0 0 0 .135-.0406 1.202 1.202 0 0 0 .1342.103c.5703.3765 1.5823.4213 3.0068.1344-.2016.1769-.5189.3994-.9533.6011-.4098.1903-1.0957.333-1.7473.3636-.7197.0336-1.0859-.0807-1.1721-.151zm.5695-9.2712c-.0059.3508-.0542.6692-.1054 1.0017-.055.3576-.112.7274-.1264 1.1762-.0142.4368.0404.8909.0932 1.3301.1066.887.216 1.8003-.2075 2.7014a3.5272 3.5272 0 0 1-.1876-.3856c-.0527-.1276-.1669-.3326-.3251-.6162-.6156-1.1041-2.0574-3.6896-1.3193-4.7446.3795-.5427 1.3408-.5661 2.1781-.463zm.2284 7.0137a12.3762 12.3762 0 0 0-.0853-.1074l-.0355-.0444c.7262-1.1995.5842-2.3862.4578-3.4385-.0519-.4318-.1009-.8396-.0885-1.2226.0129-.4061.0666-.7543.1185-1.0911.0639-.415.1288-.8443.1109-1.3505.0134-.0531.0188-.1158.0118-.1902-.0457-.4855-.5999-1.938-1.7294-3.253-.6076-.7073-1.4896-1.4972-2.6889-2.0395.5251-.1066 1.2328-.2035 2.0244-.1859 2.0515.0456 3.6746.8135 4.8242 2.2824a.908.908 0 0 1 .0667.1002c.7231 1.3556-.2762 6.2751-2.9867 10.5405zm-8.8166-6.1162c-.025.1794-.3089.4225-.6211.4225a.5821.5821 0 0 1-.0809-.0056c-.1873-.026-.3765-.144-.5059-.3156-.0458-.0605-.1203-.178-.1055-.2844.0055-.0401.0261-.0985.0925-.1488.1182-.0894.3518-.1226.6096-.0867.3163.0441.6426.1938.6113.4186zm7.9305-.4114c.0111.0792-.049.201-.1531.3102-.0683.0717-.212.1961-.4079.2232a.5456.5456 0 0 1-.075.0052c-.2935 0-.5414-.2344-.5607-.3717-.024-.1765.2641-.3106.5611-.352.297-.0414.6111.0088.6356.1851z"/></svg>';
|
|
46
|
+
|
|
47
|
+
// src/client/ConnectSettings.tsx
|
|
48
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
|
+
function ConnectSettings(props) {
|
|
50
|
+
const [tab, setTab] = (0, import_react.useState)("sources");
|
|
51
|
+
const [sources, setSources] = (0, import_react.useState)([]);
|
|
52
|
+
const [apis, setApis] = (0, import_react.useState)([]);
|
|
53
|
+
const [loaded, setLoaded] = (0, import_react.useState)(false);
|
|
54
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
55
|
+
const [busy, setBusy] = (0, import_react.useState)("");
|
|
56
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
57
|
+
const [notice, setNotice] = (0, import_react.useState)("");
|
|
58
|
+
const [sourceEditor, setSourceEditor] = (0, import_react.useState)(null);
|
|
59
|
+
const [apiEditor, setApiEditor] = (0, import_react.useState)(null);
|
|
60
|
+
const [metadataSource, setMetadataSource] = (0, import_react.useState)(null);
|
|
61
|
+
const [governanceSource, setGovernanceSource] = (0, import_react.useState)(null);
|
|
62
|
+
const [testApi, setTestApi] = (0, import_react.useState)(null);
|
|
63
|
+
const loadSources = (0, import_react.useCallback)(async (showLoading = true) => {
|
|
64
|
+
if (showLoading) setLoading(true);
|
|
65
|
+
try {
|
|
66
|
+
setSources(await props.connectClient.call("sources/list"));
|
|
67
|
+
setError("");
|
|
68
|
+
} catch (nextError) {
|
|
69
|
+
setError(errorText(nextError));
|
|
70
|
+
} finally {
|
|
71
|
+
if (showLoading) setLoading(false);
|
|
72
|
+
}
|
|
73
|
+
}, [props.connectClient]);
|
|
74
|
+
const loadAll = (0, import_react.useCallback)(async () => {
|
|
75
|
+
setLoading(true);
|
|
76
|
+
try {
|
|
77
|
+
const [nextSources, nextApis] = await Promise.all([
|
|
78
|
+
props.connectClient.call("sources/list"),
|
|
79
|
+
props.connectClient.call("apis/list")
|
|
80
|
+
]);
|
|
81
|
+
setSources(nextSources);
|
|
82
|
+
setApis(nextApis);
|
|
83
|
+
setLoaded(true);
|
|
84
|
+
setError("");
|
|
85
|
+
} catch (nextError) {
|
|
86
|
+
setError(errorText(nextError));
|
|
87
|
+
} finally {
|
|
88
|
+
setLoading(false);
|
|
89
|
+
}
|
|
90
|
+
}, [props.connectClient]);
|
|
91
|
+
(0, import_react.useEffect)(() => {
|
|
92
|
+
if (!loaded) void loadAll();
|
|
93
|
+
}, [loadAll, loaded]);
|
|
94
|
+
const scanning = sources.some((source) => isActiveJob(source.latestJob));
|
|
95
|
+
(0, import_react.useEffect)(() => {
|
|
96
|
+
if (!scanning) return;
|
|
97
|
+
const timer = window.setInterval(() => {
|
|
98
|
+
void loadSources(false);
|
|
99
|
+
}, 1200);
|
|
100
|
+
return () => {
|
|
101
|
+
window.clearInterval(timer);
|
|
102
|
+
};
|
|
103
|
+
}, [loadSources, scanning]);
|
|
104
|
+
async function sourceAction(source, action) {
|
|
105
|
+
const key = `${source.id}:${action}`;
|
|
106
|
+
setBusy(key);
|
|
107
|
+
setError("");
|
|
108
|
+
setNotice("");
|
|
109
|
+
try {
|
|
110
|
+
if (action === "test") {
|
|
111
|
+
await props.connectClient.call("sources/test", { id: source.id });
|
|
112
|
+
setNotice(`${source.name} \u8FDE\u63A5\u6210\u529F`);
|
|
113
|
+
} else if (action === "scan" || action === "model" || action === "full") {
|
|
114
|
+
const mode = action === "model" ? "rebuild-ai" : action === "full" ? "full" : "incremental";
|
|
115
|
+
await props.connectClient.call("sources/scan", { sourceId: source.id, mode });
|
|
116
|
+
setNotice(action === "model" ? `${source.name} AI \u5EFA\u6A21\u5DF2\u542F\u52A8` : action === "full" ? `${source.name} \u5168\u91CF\u91CD\u5EFA\u5DF2\u542F\u52A8` : `${source.name} \u5143\u6570\u636E\u626B\u63CF\u5DF2\u542F\u52A8`);
|
|
117
|
+
} else {
|
|
118
|
+
await props.connectClient.call("sources/cancel", { sourceId: source.id });
|
|
119
|
+
setNotice(`${source.name} \u626B\u63CF\u5DF2\u505C\u6B62\uFF0C\u5DF2\u5B8C\u6210\u90E8\u5206\u5DF2\u4FDD\u7559`);
|
|
120
|
+
}
|
|
121
|
+
await loadSources(false);
|
|
122
|
+
} catch (nextError) {
|
|
123
|
+
setError(errorText(nextError));
|
|
124
|
+
} finally {
|
|
125
|
+
setBusy("");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function deleteSource(source) {
|
|
129
|
+
if (!window.confirm(`\u5220\u9664\u6570\u636E\u5E93\u201C${source.name}\u201D\u53CA\u5176\u5143\u6570\u636E\uFF1F`)) return;
|
|
130
|
+
setBusy(`${source.id}:delete`);
|
|
131
|
+
try {
|
|
132
|
+
await props.connectClient.call("sources/delete", { id: source.id });
|
|
133
|
+
await loadSources(false);
|
|
134
|
+
setNotice(`${source.name} \u5DF2\u5220\u9664`);
|
|
135
|
+
} catch (nextError) {
|
|
136
|
+
setError(errorText(nextError));
|
|
137
|
+
} finally {
|
|
138
|
+
setBusy("");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function deleteApi(definition) {
|
|
142
|
+
if (!window.confirm(`\u5220\u9664 HTTP API\u201C${definition.name}\u201D\uFF1F`)) return;
|
|
143
|
+
setBusy(`${definition.id}:delete`);
|
|
144
|
+
try {
|
|
145
|
+
await props.connectClient.call("apis/delete", { id: definition.id });
|
|
146
|
+
setApis(await props.connectClient.call("apis/list"));
|
|
147
|
+
setNotice(`${definition.name} \u5DF2\u5220\u9664`);
|
|
148
|
+
} catch (nextError) {
|
|
149
|
+
setError(errorText(nextError));
|
|
150
|
+
} finally {
|
|
151
|
+
setBusy("");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const sourceCount = sources.length;
|
|
155
|
+
const apiCount = apis.length;
|
|
156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshc-workbench", children: [
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "dshc-page-head", children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-page-title", children: [
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "DSH\u8FDE\u63A5\u5668" }),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u8FDE\u63A5\u6570\u636E\u5E93\uFF0CHTTP API \u4EA4\u7ED9 Agent \u81EA\u52A8\u8C03\u7528\u3002" })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-page-summary", children: [
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-summary-item", children: [
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: sourceCount }),
|
|
165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u6570\u636E\u5E93" })
|
|
166
|
+
] }),
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-summary-item", children: [
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: apiCount }),
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "HTTP API" })
|
|
170
|
+
] })
|
|
171
|
+
] })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-body", children: [
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-toolbar", children: [
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-tabs", role: "tablist", "aria-label": "DSH\u8FDE\u63A5\u5668\u8BBE\u7F6E", children: [
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", role: "tab", className: "dshc-tab", "data-active": tab === "sources", "aria-selected": tab === "sources", onClick: () => {
|
|
177
|
+
setTab("sources");
|
|
178
|
+
}, children: [
|
|
179
|
+
"\u6570\u636E\u5E93 ",
|
|
180
|
+
sourceCount > 0 ? `(${sourceCount})` : ""
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", role: "tab", className: "dshc-tab", "data-active": tab === "apis", "aria-selected": tab === "apis", onClick: () => {
|
|
183
|
+
setTab("apis");
|
|
184
|
+
}, children: [
|
|
185
|
+
"HTTP API ",
|
|
186
|
+
apiCount > 0 ? `(${apiCount})` : ""
|
|
187
|
+
] })
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u5237\u65B0", "aria-label": "\u5237\u65B0", disabled: loading, onClick: () => {
|
|
190
|
+
void loadAll();
|
|
191
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconRefreshOutline16, {}) }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-primary", onClick: () => {
|
|
193
|
+
tab === "sources" ? setSourceEditor("new") : setApiEditor("new");
|
|
194
|
+
}, children: [
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPlusOutline16, { size: 14 }),
|
|
196
|
+
tab === "sources" ? "\u6DFB\u52A0\u6570\u636E\u5E93" : "\u6DFB\u52A0 API"
|
|
197
|
+
] })
|
|
198
|
+
] }),
|
|
199
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error", role: "alert", children: error }) : null,
|
|
200
|
+
notice !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-notice", role: "status", children: notice }) : null,
|
|
201
|
+
loading && !loaded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, { label: "\u6B63\u5728\u52A0\u8F7D\u6570\u636E\u5E93\u548C HTTP API" }) : null,
|
|
202
|
+
loaded && tab === "sources" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
203
|
+
DataSourceList,
|
|
204
|
+
{
|
|
205
|
+
sources,
|
|
206
|
+
busy,
|
|
207
|
+
onEdit: setSourceEditor,
|
|
208
|
+
onMetadata: setMetadataSource,
|
|
209
|
+
onGovernance: setGovernanceSource,
|
|
210
|
+
onAction: (source, action) => {
|
|
211
|
+
void sourceAction(source, action);
|
|
212
|
+
},
|
|
213
|
+
onDelete: (source) => {
|
|
214
|
+
void deleteSource(source);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
) : null,
|
|
218
|
+
loaded && tab === "apis" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
219
|
+
ApiList,
|
|
220
|
+
{
|
|
221
|
+
apis,
|
|
222
|
+
busy,
|
|
223
|
+
onEdit: setApiEditor,
|
|
224
|
+
onTest: setTestApi,
|
|
225
|
+
onDelete: (definition) => {
|
|
226
|
+
void deleteApi(definition);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
) : null
|
|
230
|
+
] }),
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
|
+
DataSourceEditor,
|
|
233
|
+
{
|
|
234
|
+
value: sourceEditor,
|
|
235
|
+
onClose: () => {
|
|
236
|
+
setSourceEditor(null);
|
|
237
|
+
},
|
|
238
|
+
onSave: async (payload) => {
|
|
239
|
+
await props.connectClient.call("sources/save", payload);
|
|
240
|
+
await loadSources(false);
|
|
241
|
+
setSourceEditor(null);
|
|
242
|
+
setNotice(payload.id === void 0 ? "\u6570\u636E\u5E93\u5DF2\u6DFB\u52A0" : "\u6570\u636E\u5E93\u5DF2\u66F4\u65B0");
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
|
+
ApiEditor,
|
|
248
|
+
{
|
|
249
|
+
value: apiEditor,
|
|
250
|
+
onClose: () => {
|
|
251
|
+
setApiEditor(null);
|
|
252
|
+
},
|
|
253
|
+
onSave: async (payload) => {
|
|
254
|
+
await props.connectClient.call("apis/save", payload);
|
|
255
|
+
setApis(await props.connectClient.call("apis/list"));
|
|
256
|
+
setApiEditor(null);
|
|
257
|
+
setNotice(payload.id === void 0 ? "HTTP API \u5DF2\u6DFB\u52A0\uFF0C\u53EF\u5728\u5BF9\u8BDD\u4E2D\u8C03\u7528" : "HTTP API \u5DF2\u66F4\u65B0");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MetadataBrowser, { client: props.connectClient, source: metadataSource, onClose: () => {
|
|
262
|
+
setMetadataSource(null);
|
|
263
|
+
} }),
|
|
264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GovernancePanel, { client: props.connectClient, source: governanceSource, onClose: () => {
|
|
265
|
+
setGovernanceSource(null);
|
|
266
|
+
} }),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ApiTester, { client: props.connectClient, definition: testApi, onClose: () => {
|
|
268
|
+
setTestApi(null);
|
|
269
|
+
} })
|
|
270
|
+
] });
|
|
271
|
+
}
|
|
272
|
+
function DataSourceList(props) {
|
|
273
|
+
if (props.sources.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u6682\u65E0\u6570\u636E\u5E93" });
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-card-grid", children: props.sources.map((source) => {
|
|
275
|
+
const active = isActiveJob(source.latestJob);
|
|
276
|
+
const progress = jobProgress(source.latestJob);
|
|
277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "dshc-source-card", children: [
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-card-head", children: [
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DatabaseLogo, { type: source.type }),
|
|
280
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-card-title", children: [
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: source.name }),
|
|
282
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: databaseLabel(source.type) })
|
|
283
|
+
] }),
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusBadge, { source })
|
|
285
|
+
] }),
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshc-source-address", children: [
|
|
287
|
+
source.host,
|
|
288
|
+
":",
|
|
289
|
+
source.port,
|
|
290
|
+
" / ",
|
|
291
|
+
source.database
|
|
292
|
+
] }),
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-stats", children: [
|
|
294
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
295
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: source.profileCount }),
|
|
296
|
+
" \u5BF9\u8C61"
|
|
297
|
+
] }),
|
|
298
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
299
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: source.aiProfileCount }),
|
|
300
|
+
" AI \u5143\u6570\u636E"
|
|
301
|
+
] }),
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: source.credentialConfigured ? "\u51ED\u636E\u5DF2\u914D\u7F6E" : "\u5F85\u914D\u7F6E\u51ED\u636E" })
|
|
303
|
+
] }),
|
|
304
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-progress", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { width: `${progress}%` } }) }) : null,
|
|
305
|
+
active && source.latestJob?.currentObject !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dshc-current-object", children: [
|
|
306
|
+
"\u6B63\u5728\u5904\u7406 ",
|
|
307
|
+
source.latestJob.currentObject
|
|
308
|
+
] }) : null,
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-card-actions", children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary", disabled: props.busy !== "", onClick: () => {
|
|
311
|
+
props.onAction(source, "test");
|
|
312
|
+
}, children: "\u6D4B\u8BD5\u8FDE\u63A5" }),
|
|
313
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", disabled: props.busy !== "", onClick: () => {
|
|
314
|
+
props.onAction(source, "cancel");
|
|
315
|
+
}, children: [
|
|
316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCloseOutline16, { size: 13 }),
|
|
317
|
+
"\u505C\u6B62"
|
|
318
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", disabled: !source.enabled || props.busy !== "", onClick: () => {
|
|
319
|
+
props.onAction(source, "scan");
|
|
320
|
+
}, children: [
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconRefreshOutline16, { size: 13 }),
|
|
322
|
+
"\u626B\u63CF"
|
|
323
|
+
] }),
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-primary", disabled: !source.enabled || !source.aiEnrichment || active || props.busy !== "", onClick: () => {
|
|
325
|
+
props.onAction(source, "model");
|
|
326
|
+
}, children: "AI \u5EFA\u6A21" })
|
|
327
|
+
] }),
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-card-actions dshc-card-actions-muted", children: [
|
|
329
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u6D4F\u89C8\u5143\u6570\u636E", "aria-label": `\u6D4F\u89C8 ${source.name} \u5143\u6570\u636E`, disabled: source.profileCount === 0, onClick: () => {
|
|
330
|
+
props.onMetadata(source);
|
|
331
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, {}) }),
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary", disabled: source.profileCount === 0, onClick: () => {
|
|
333
|
+
props.onGovernance(source);
|
|
334
|
+
}, children: "\u5143\u6570\u636E" }),
|
|
335
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u7F16\u8F91", "aria-label": `\u7F16\u8F91 ${source.name}`, onClick: () => {
|
|
336
|
+
props.onEdit(source);
|
|
337
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEditOutline16, {}) }),
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u5220\u9664", "aria-label": `\u5220\u9664 ${source.name}`, disabled: props.busy !== "", onClick: () => {
|
|
339
|
+
props.onDelete(source);
|
|
340
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTrashOutline16, {}) }),
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-row-meta", children: source.aiEnrichment ? "AI \u5DF2\u5F00\u542F" : "\u4EC5\u7269\u7406\u8BC6\u522B" })
|
|
342
|
+
] })
|
|
343
|
+
] }, source.id);
|
|
344
|
+
}) });
|
|
345
|
+
}
|
|
346
|
+
function ApiList(props) {
|
|
347
|
+
if (props.apis.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u6682\u65E0 HTTP API" });
|
|
348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-card-grid", children: props.apis.map((definition) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", { className: "dshc-api-card", children: [
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-card-head", children: [
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-api-method", "data-method": definition.method, children: definition.method }),
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-card-title", children: [
|
|
352
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: definition.name }),
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
354
|
+
definition.baseUrl,
|
|
355
|
+
definition.pathTemplate
|
|
356
|
+
] })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", "data-tone": definition.enabled ? "success" : void 0, children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
360
|
+
definition.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528"
|
|
361
|
+
] })
|
|
362
|
+
] }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-api-description", children: definition.description }),
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-source-stats", children: [
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: definition.parameters.length }),
|
|
367
|
+
" \u4E2A\u53C2\u6570"
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: authLabel(definition.auth) })
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: "dshc-tool-name", children: definition.toolName }),
|
|
372
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-card-actions", children: [
|
|
373
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", disabled: props.busy !== "", onClick: () => {
|
|
374
|
+
props.onTest(definition);
|
|
375
|
+
}, children: [
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconApiOutline14, {}),
|
|
377
|
+
"\u6D4B\u8BD5\u8BF7\u6C42"
|
|
378
|
+
] }),
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", onClick: () => {
|
|
380
|
+
props.onEdit(definition);
|
|
381
|
+
}, children: [
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconEditOutline16, {}),
|
|
383
|
+
"\u7F16\u8F91"
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u5220\u9664", "aria-label": `\u5220\u9664 ${definition.name}`, disabled: props.busy !== "", onClick: () => {
|
|
386
|
+
props.onDelete(definition);
|
|
387
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTrashOutline16, {}) })
|
|
388
|
+
] })
|
|
389
|
+
] }, definition.id)) });
|
|
390
|
+
}
|
|
391
|
+
function DataSourceEditor(props) {
|
|
392
|
+
const [draft, setDraft] = (0, import_react.useState)(() => emptyDataSource());
|
|
393
|
+
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
394
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
395
|
+
(0, import_react.useEffect)(() => {
|
|
396
|
+
if (props.value === null) return;
|
|
397
|
+
setDraft(props.value === "new" ? emptyDataSource() : dataSourceDraft(props.value));
|
|
398
|
+
setError("");
|
|
399
|
+
}, [props.value]);
|
|
400
|
+
async function submit(event) {
|
|
401
|
+
event.preventDefault();
|
|
402
|
+
setSaving(true);
|
|
403
|
+
setError("");
|
|
404
|
+
try {
|
|
405
|
+
await props.onSave({
|
|
406
|
+
...draft.id === void 0 ? {} : { id: draft.id },
|
|
407
|
+
name: draft.name,
|
|
408
|
+
type: draft.type,
|
|
409
|
+
host: draft.host,
|
|
410
|
+
port: draft.port,
|
|
411
|
+
database: draft.database,
|
|
412
|
+
username: draft.username,
|
|
413
|
+
...draft.secret.trim() === "" ? {} : { secret: draft.secret },
|
|
414
|
+
schemaInclude: draft.schemaInclude.split(",").map((value) => value.trim()).filter(Boolean),
|
|
415
|
+
tls: draft.tls,
|
|
416
|
+
sampleRows: draft.sampleRows,
|
|
417
|
+
aiEnrichment: draft.aiEnrichment,
|
|
418
|
+
enabled: draft.enabled
|
|
419
|
+
});
|
|
420
|
+
} catch (nextError) {
|
|
421
|
+
setError(errorText(nextError));
|
|
422
|
+
} finally {
|
|
423
|
+
setSaving(false);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
const isNew = props.value === "new";
|
|
427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
428
|
+
import_dsh_client_ui_primitives.Modal,
|
|
429
|
+
{
|
|
430
|
+
open: props.value !== null,
|
|
431
|
+
onClose: saving ? () => {
|
|
432
|
+
} : props.onClose,
|
|
433
|
+
title: isNew ? "\u6DFB\u52A0\u6570\u636E\u5E93" : "\u7F16\u8F91\u6570\u636E\u5E93",
|
|
434
|
+
...isNew ? {} : { description: "\u7559\u7A7A\u5BC6\u7801\u5C06\u4FDD\u7559\u73B0\u6709\u51ED\u636E\u3002" },
|
|
435
|
+
className: "dshc-modal",
|
|
436
|
+
contentClassName: "dshc-modal-content",
|
|
437
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-form-footer", children: [
|
|
438
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-form-error", children: error }) : null,
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary", disabled: saving, onClick: props.onClose, children: "\u53D6\u6D88" }),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", form: "dshc-source-form", className: "dshc-primary", disabled: saving, children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58" })
|
|
441
|
+
] }),
|
|
442
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { id: "dshc-source-form", className: "dshc-form", onSubmit: (event) => {
|
|
443
|
+
void submit(event);
|
|
444
|
+
}, children: [
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-grid", children: [
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u540D\u79F0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, maxLength: 100, value: draft.name, onChange: (event) => {
|
|
447
|
+
setDraft({ ...draft, name: event.target.value });
|
|
448
|
+
} }) }),
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-field dshc-field-wide", children: [
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-field-label", children: "\u6570\u636E\u5E93\u7C7B\u578B" }),
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-db-picker", role: "radiogroup", "aria-label": "\u6570\u636E\u5E93\u7C7B\u578B", children: ["mysql", "postgresql", "clickhouse"].map((type) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", role: "radio", "aria-checked": draft.type === type, className: "dshc-db-option", "data-active": draft.type === type, onClick: () => {
|
|
452
|
+
setDraft({ ...draft, type, port: defaultPort(type) });
|
|
453
|
+
}, children: [
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DatabaseLogo, { type }),
|
|
455
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: databaseLabel(type) }),
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: defaultPort(type) })
|
|
457
|
+
] }, type)) })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u4E3B\u673A", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.host, onChange: (event) => {
|
|
460
|
+
setDraft({ ...draft, host: event.target.value });
|
|
461
|
+
} }) }),
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u7AEF\u53E3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "number", min: 1, max: 65535, required: true, value: draft.port, onChange: (event) => {
|
|
463
|
+
setDraft({ ...draft, port: Number(event.target.value) });
|
|
464
|
+
} }) }),
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u6570\u636E\u5E93", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.database, onChange: (event) => {
|
|
466
|
+
setDraft({ ...draft, database: event.target.value });
|
|
467
|
+
} }) }),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u7528\u6237\u540D", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.username, onChange: (event) => {
|
|
469
|
+
setDraft({ ...draft, username: event.target.value });
|
|
470
|
+
} }) }),
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: isNew ? "\u5BC6\u7801" : "\u65B0\u5BC6\u7801", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "password", required: isNew, autoComplete: "new-password", value: draft.secret, onChange: (event) => {
|
|
472
|
+
setDraft({ ...draft, secret: event.target.value });
|
|
473
|
+
} }) }),
|
|
474
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "Schema \u767D\u540D\u5355", hint: "\u9017\u53F7\u5206\u9694\uFF1B\u7559\u7A7A\u626B\u63CF\u5168\u90E8\u53EF\u89C1 Schema", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: draft.schemaInclude, onChange: (event) => {
|
|
475
|
+
setDraft({ ...draft, schemaInclude: event.target.value });
|
|
476
|
+
} }) }),
|
|
477
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u91C7\u6837\u884C\u6570", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: draft.sampleRows, onChange: (event) => {
|
|
478
|
+
setDraft({ ...draft, sampleRows: Number(event.target.value) });
|
|
479
|
+
}, children: [
|
|
480
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: 0, children: "\u4E0D\u91C7\u6837" }),
|
|
481
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: 1, children: "1 \u884C" }),
|
|
482
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: 2, children: "2 \u884C" }),
|
|
483
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: 3, children: "3 \u884C" })
|
|
484
|
+
] }) })
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-checks", children: [
|
|
487
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { label: "TLS", checked: draft.tls, onChange: (value) => {
|
|
488
|
+
setDraft({ ...draft, tls: value });
|
|
489
|
+
} }),
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { label: "AI \u8BED\u4E49\u589E\u5F3A\uFF08DSH \u9ED8\u8BA4\u6A21\u578B\uFF09", checked: draft.aiEnrichment, onChange: (value) => {
|
|
491
|
+
setDraft({ ...draft, aiEnrichment: value });
|
|
492
|
+
} }),
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { label: "\u542F\u7528", checked: draft.enabled, onChange: (value) => {
|
|
494
|
+
setDraft({ ...draft, enabled: value });
|
|
495
|
+
} })
|
|
496
|
+
] })
|
|
497
|
+
] })
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
function ApiEditor(props) {
|
|
502
|
+
const [draft, setDraft] = (0, import_react.useState)(() => emptyApi());
|
|
503
|
+
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
504
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
505
|
+
(0, import_react.useEffect)(() => {
|
|
506
|
+
if (props.value === null) return;
|
|
507
|
+
setDraft(props.value === "new" ? emptyApi() : apiDraft(props.value));
|
|
508
|
+
setError("");
|
|
509
|
+
}, [props.value]);
|
|
510
|
+
async function submit(event) {
|
|
511
|
+
event.preventDefault();
|
|
512
|
+
setSaving(true);
|
|
513
|
+
setError("");
|
|
514
|
+
try {
|
|
515
|
+
await props.onSave({
|
|
516
|
+
...draft.id === void 0 ? {} : { id: draft.id },
|
|
517
|
+
name: draft.name,
|
|
518
|
+
slug: draft.slug,
|
|
519
|
+
description: draft.description,
|
|
520
|
+
method: draft.method,
|
|
521
|
+
baseUrl: draft.baseUrl,
|
|
522
|
+
pathTemplate: draft.pathTemplate,
|
|
523
|
+
parameters: draft.parameters,
|
|
524
|
+
auth: authPayload(draft),
|
|
525
|
+
...draft.secret.trim() === "" ? {} : { secret: draft.secret },
|
|
526
|
+
timeoutMs: draft.timeoutMs,
|
|
527
|
+
maxResponseBytes: draft.maxResponseBytes,
|
|
528
|
+
responsePointer: draft.responsePointer,
|
|
529
|
+
allowPrivateNetwork: draft.allowPrivateNetwork,
|
|
530
|
+
enabled: draft.enabled
|
|
531
|
+
});
|
|
532
|
+
} catch (nextError) {
|
|
533
|
+
setError(errorText(nextError));
|
|
534
|
+
} finally {
|
|
535
|
+
setSaving(false);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const isNew = props.value === "new";
|
|
539
|
+
const authNeedsSecret = draft.authType !== "none";
|
|
540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
541
|
+
import_dsh_client_ui_primitives.Modal,
|
|
542
|
+
{
|
|
543
|
+
open: props.value !== null,
|
|
544
|
+
onClose: saving ? () => {
|
|
545
|
+
} : props.onClose,
|
|
546
|
+
title: isNew ? "\u6DFB\u52A0 HTTP API" : "\u7F16\u8F91 HTTP API",
|
|
547
|
+
...isNew ? {} : { description: "\u7559\u7A7A\u5BC6\u94A5\u5C06\u4FDD\u7559\u73B0\u6709\u51ED\u636E\u3002" },
|
|
548
|
+
className: "dshc-modal",
|
|
549
|
+
contentClassName: "dshc-modal-content",
|
|
550
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-form-footer", children: [
|
|
551
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-form-error", children: error }) : null,
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary", disabled: saving, onClick: props.onClose, children: "\u53D6\u6D88" }),
|
|
553
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", form: "dshc-api-form", className: "dshc-primary", disabled: saving, children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58" })
|
|
554
|
+
] }),
|
|
555
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { id: "dshc-api-form", className: "dshc-form", onSubmit: (event) => {
|
|
556
|
+
void submit(event);
|
|
557
|
+
}, children: [
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-grid", children: [
|
|
559
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u540D\u79F0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, maxLength: 100, value: draft.name, onChange: (event) => {
|
|
560
|
+
setDraft({ ...draft, name: event.target.value });
|
|
561
|
+
} }) }),
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u5DE5\u5177\u6807\u8BC6", hint: "\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u4EC5\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, pattern: "[a-z][a-z0-9_]+", maxLength: 48, value: draft.slug, onChange: (event) => {
|
|
563
|
+
setDraft({ ...draft, slug: event.target.value.toLowerCase().replaceAll(/[^a-z0-9_]/g, "_") });
|
|
564
|
+
} }) }),
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u65B9\u6CD5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "dshc-select", value: draft.method, onChange: (event) => {
|
|
566
|
+
setDraft({ ...draft, method: event.target.value });
|
|
567
|
+
}, children: ["GET", "POST", "PUT", "PATCH", "DELETE"].map((method) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { children: method }, method)) }) }),
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u57FA\u7840 URL", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "url", required: true, placeholder: "https://api.example.com", value: draft.baseUrl, onChange: (event) => {
|
|
569
|
+
setDraft({ ...draft, baseUrl: event.target.value });
|
|
570
|
+
} }) }),
|
|
571
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u8DEF\u5F84\u6A21\u677F", hint: "\u8DEF\u5F84\u53C2\u6570\u4F7F\u7528 {name}", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.pathTemplate, onChange: (event) => {
|
|
572
|
+
setDraft({ ...draft, pathTemplate: event.target.value });
|
|
573
|
+
} }) }),
|
|
574
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "JSON Pointer", hint: "\u7559\u7A7A\u8FD4\u56DE\u5B8C\u6574\u54CD\u5E94", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", placeholder: "/data/items", value: draft.responsePointer, onChange: (event) => {
|
|
575
|
+
setDraft({ ...draft, responsePointer: event.target.value });
|
|
576
|
+
} }) }),
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "number", min: 1e3, max: 12e4, value: draft.timeoutMs, onChange: (event) => {
|
|
578
|
+
setDraft({ ...draft, timeoutMs: Number(event.target.value) });
|
|
579
|
+
} }) }),
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u6700\u5927\u54CD\u5E94\uFF08\u5B57\u8282\uFF09", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "number", min: 1024, max: 2097152, value: draft.maxResponseBytes, onChange: (event) => {
|
|
581
|
+
setDraft({ ...draft, maxResponseBytes: Number(event.target.value) });
|
|
582
|
+
} }) }),
|
|
583
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u63CF\u8FF0", wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshc-textarea", required: true, maxLength: 1e3, value: draft.description, onChange: (event) => {
|
|
584
|
+
setDraft({ ...draft, description: event.target.value });
|
|
585
|
+
} }) })
|
|
586
|
+
] }),
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-section-title", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u8BA4\u8BC1" }) }),
|
|
588
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-grid", children: [
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u8BA4\u8BC1\u65B9\u5F0F", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: draft.authType, onChange: (event) => {
|
|
590
|
+
setDraft({ ...draft, authType: event.target.value });
|
|
591
|
+
}, children: [
|
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "none", children: "\u65E0" }),
|
|
593
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "bearer", children: "Bearer Token" }),
|
|
594
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "api-key", children: "API Key" }),
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "basic", children: "Basic Auth" })
|
|
596
|
+
] }) }),
|
|
597
|
+
draft.authType === "api-key" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u653E\u7F6E\u4F4D\u7F6E", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: draft.authLocation, onChange: (event) => {
|
|
598
|
+
setDraft({ ...draft, authLocation: event.target.value });
|
|
599
|
+
}, children: [
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "header", children: "Header" }),
|
|
601
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "query", children: "Query" })
|
|
602
|
+
] }) }) : null,
|
|
603
|
+
draft.authType === "api-key" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u53C2\u6570\u540D\u79F0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.authName, onChange: (event) => {
|
|
604
|
+
setDraft({ ...draft, authName: event.target.value });
|
|
605
|
+
} }) }) : null,
|
|
606
|
+
draft.authType === "basic" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u7528\u6237\u540D", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, value: draft.authUsername, onChange: (event) => {
|
|
607
|
+
setDraft({ ...draft, authUsername: event.target.value });
|
|
608
|
+
} }) }) : null,
|
|
609
|
+
authNeedsSecret ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: isNew ? "\u5BC6\u94A5" : "\u65B0\u5BC6\u94A5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", type: "password", required: isNew, autoComplete: "new-password", value: draft.secret, onChange: (event) => {
|
|
610
|
+
setDraft({ ...draft, secret: event.target.value });
|
|
611
|
+
} }) }) : null
|
|
612
|
+
] }),
|
|
613
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-section-title", children: [
|
|
614
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u5DE5\u5177\u53C2\u6570" }),
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", onClick: () => {
|
|
616
|
+
setDraft({ ...draft, parameters: [...draft.parameters, emptyParameter()] });
|
|
617
|
+
}, children: [
|
|
618
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconPlusOutline16, { size: 13 }),
|
|
619
|
+
"\u6DFB\u52A0\u53C2\u6570"
|
|
620
|
+
] })
|
|
621
|
+
] }),
|
|
622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-param-list", children: [
|
|
623
|
+
draft.parameters.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-row-meta", children: "\u65E0\u53C2\u6570" }) : null,
|
|
624
|
+
draft.parameters.map((parameter, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
625
|
+
ParameterEditor,
|
|
626
|
+
{
|
|
627
|
+
parameter,
|
|
628
|
+
onChange: (next) => {
|
|
629
|
+
setDraft({ ...draft, parameters: replaceAt(draft.parameters, index, next) });
|
|
630
|
+
},
|
|
631
|
+
onDelete: () => {
|
|
632
|
+
setDraft({ ...draft, parameters: draft.parameters.filter((_, itemIndex) => itemIndex !== index) });
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
index
|
|
636
|
+
))
|
|
637
|
+
] }),
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-checks", children: [
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { label: "\u5141\u8BB8\u8BBF\u95EE\u79C1\u6709\u7F51\u7EDC", checked: draft.allowPrivateNetwork, onChange: (value) => {
|
|
640
|
+
setDraft({ ...draft, allowPrivateNetwork: value });
|
|
641
|
+
} }),
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { label: "\u542F\u7528\u4E3A Agent \u5DE5\u5177", checked: draft.enabled, onChange: (value) => {
|
|
643
|
+
setDraft({ ...draft, enabled: value });
|
|
644
|
+
} })
|
|
645
|
+
] })
|
|
646
|
+
] })
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
function ParameterEditor(props) {
|
|
651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-param", children: [
|
|
652
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: true, placeholder: "\u53C2\u6570\u540D", value: props.parameter.name, onChange: (event) => {
|
|
653
|
+
props.onChange({ ...props.parameter, name: event.target.value });
|
|
654
|
+
} }),
|
|
655
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: props.parameter.location, onChange: (event) => {
|
|
656
|
+
props.onChange({ ...props.parameter, location: event.target.value });
|
|
657
|
+
}, children: [
|
|
658
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "path", children: "Path" }),
|
|
659
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "query", children: "Query" }),
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "header", children: "Header" }),
|
|
661
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "body", children: "Body" })
|
|
662
|
+
] }),
|
|
663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: props.parameter.type, onChange: (event) => {
|
|
664
|
+
props.onChange({ ...props.parameter, type: event.target.value });
|
|
665
|
+
}, children: [
|
|
666
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "string", children: "String" }),
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "number", children: "Number" }),
|
|
668
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "integer", children: "Integer" }),
|
|
669
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "boolean", children: "Boolean" }),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "json", children: "JSON" })
|
|
671
|
+
] }),
|
|
672
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshc-check", children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: props.parameter.required, onChange: (event) => {
|
|
674
|
+
props.onChange({ ...props.parameter, required: event.target.checked });
|
|
675
|
+
} }),
|
|
676
|
+
"\u5FC5\u586B"
|
|
677
|
+
] }),
|
|
678
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-icon", title: "\u5220\u9664\u53C2\u6570", "aria-label": "\u5220\u9664\u53C2\u6570", onClick: props.onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconTrashOutline16, {}) }),
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input dshc-param-desc", placeholder: "\u53C2\u6570\u63CF\u8FF0", maxLength: 500, value: props.parameter.description, onChange: (event) => {
|
|
680
|
+
props.onChange({ ...props.parameter, description: event.target.value });
|
|
681
|
+
} })
|
|
682
|
+
] });
|
|
683
|
+
}
|
|
684
|
+
function MetadataBrowser(props) {
|
|
685
|
+
const [profiles, setProfiles] = (0, import_react.useState)([]);
|
|
686
|
+
const [selectedId, setSelectedId] = (0, import_react.useState)("");
|
|
687
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
688
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
689
|
+
const [loadedSourceId, setLoadedSourceId] = (0, import_react.useState)("");
|
|
690
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
691
|
+
(0, import_react.useEffect)(() => {
|
|
692
|
+
if (props.source === null) return;
|
|
693
|
+
let live = true;
|
|
694
|
+
setLoading(true);
|
|
695
|
+
setError("");
|
|
696
|
+
void props.client.call("metadata/list", { sourceId: props.source.id }).then((result) => {
|
|
697
|
+
if (!live) return;
|
|
698
|
+
setProfiles(result);
|
|
699
|
+
setSelectedId(result[0]?.id ?? "");
|
|
700
|
+
setLoadedSourceId(props.source?.id ?? "");
|
|
701
|
+
}).catch((nextError) => {
|
|
702
|
+
if (live) setError(errorText(nextError));
|
|
703
|
+
}).finally(() => {
|
|
704
|
+
if (live) setLoading(false);
|
|
705
|
+
});
|
|
706
|
+
return () => {
|
|
707
|
+
live = false;
|
|
708
|
+
};
|
|
709
|
+
}, [props.client, props.source]);
|
|
710
|
+
const filtered = (0, import_react.useMemo)(() => {
|
|
711
|
+
const needle = query.trim().toLowerCase();
|
|
712
|
+
if (needle === "") return profiles;
|
|
713
|
+
return profiles.filter((profile) => `${profile.schemaName}.${profile.objectName} ${profile.term} ${profile.description} ${profile.tags.join(" ")}`.toLowerCase().includes(needle));
|
|
714
|
+
}, [profiles, query]);
|
|
715
|
+
const selected = profiles.find((profile) => profile.id === selectedId) ?? filtered[0];
|
|
716
|
+
const pending = props.source !== null && (loading || error === "" && loadedSourceId !== props.source.id);
|
|
717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Modal, { open: props.source !== null, onClose: props.onClose, title: props.source === null ? "\u5143\u6570\u636E" : `${props.source.name} \u5143\u6570\u636E`, className: "dshc-meta-modal", contentClassName: "dshc-modal-content", children: [
|
|
718
|
+
pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, { label: "\u6B63\u5728\u52A0\u8F7D\u6570\u636E\u5E93\u5143\u6570\u636E" }) : null,
|
|
719
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error", children: error }) : null,
|
|
720
|
+
!pending && error === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-meta-layout", children: [
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "dshc-meta-side", children: [
|
|
722
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-meta-search", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshc-field", children: [
|
|
723
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-field-label", children: "\u641C\u7D22" }),
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-search-wrap", children: [
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconSearchOutline16, {}),
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: query, onChange: (event) => {
|
|
727
|
+
setQuery(event.target.value);
|
|
728
|
+
} })
|
|
729
|
+
] })
|
|
730
|
+
] }) }),
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-meta-list", children: [
|
|
732
|
+
filtered.map((profile) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-meta-item", "data-active": profile.id === selected?.id, onClick: () => {
|
|
733
|
+
setSelectedId(profile.id);
|
|
734
|
+
}, children: [
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
736
|
+
profile.schemaName,
|
|
737
|
+
".",
|
|
738
|
+
profile.objectName
|
|
739
|
+
] }),
|
|
740
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
741
|
+
profile.objectType,
|
|
742
|
+
" / ",
|
|
743
|
+
profile.columns.length,
|
|
744
|
+
" \u5217 / \u7F6E\u4FE1\u5EA6 ",
|
|
745
|
+
profile.confidence
|
|
746
|
+
] })
|
|
747
|
+
] }, profile.id)),
|
|
748
|
+
filtered.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u65E0\u5339\u914D\u7ED3\u679C" }) : null
|
|
749
|
+
] })
|
|
750
|
+
] }),
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MetadataDetail, { profile: selected })
|
|
752
|
+
] }) : null
|
|
753
|
+
] });
|
|
754
|
+
}
|
|
755
|
+
function MetadataDetail({ profile }) {
|
|
756
|
+
if (profile === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u6682\u65E0\u5143\u6570\u636E" });
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshc-meta-detail", children: [
|
|
758
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: [
|
|
759
|
+
profile.schemaName,
|
|
760
|
+
".",
|
|
761
|
+
profile.objectName
|
|
762
|
+
] }),
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", "data-tone": profile.ignored ? "warn" : "success", children: [
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
765
|
+
profile.ignored ? "\u9ED8\u8BA4\u5FFD\u7565" : "\u53EF\u68C0\u7D22",
|
|
766
|
+
" / ",
|
|
767
|
+
profile.confidence
|
|
768
|
+
] }),
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: profile.description || profile.comment || "\u6682\u65E0\u63CF\u8FF0" }),
|
|
770
|
+
profile.tags.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: profile.tags.map((tag) => `#${tag}`).join(" ") }) : null,
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-detail-title", children: "\u5B57\u6BB5" }),
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "dshc-table", children: [
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
774
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u540D\u79F0" }),
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u7C7B\u578B" }),
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u8BED\u4E49" }),
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u7EA6\u675F" })
|
|
778
|
+
] }) }),
|
|
779
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: profile.columns.map((column) => {
|
|
780
|
+
const semantic = profile.semanticColumns.find((item) => item.name === column.name);
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
782
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: column.name }),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: column.type }),
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
|
|
785
|
+
semantic?.term ?? "",
|
|
786
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
787
|
+
semantic?.description ?? ""
|
|
788
|
+
] }),
|
|
789
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
|
|
790
|
+
column.primaryKey ? "PK " : "",
|
|
791
|
+
column.nullable ? "NULL" : "NOT NULL",
|
|
792
|
+
column.references === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
793
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
794
|
+
"FK \u2192 ",
|
|
795
|
+
column.references.schemaName,
|
|
796
|
+
".",
|
|
797
|
+
column.references.objectName,
|
|
798
|
+
".",
|
|
799
|
+
column.references.columnName
|
|
800
|
+
] })
|
|
801
|
+
] })
|
|
802
|
+
] }, column.name);
|
|
803
|
+
}) })
|
|
804
|
+
] }),
|
|
805
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-detail-title", children: "DDL" }),
|
|
806
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshc-code", children: profile.ddl }),
|
|
807
|
+
profile.sample.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-detail-title", children: "\u8131\u654F\u91C7\u6837" }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshc-code", children: JSON.stringify(profile.sample, null, 2) })
|
|
810
|
+
] }) : null,
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
812
|
+
"\u8BC6\u522B\u4F9D\u636E\uFF1A",
|
|
813
|
+
profile.confidenceReason || "\u89C4\u5219\u8BC6\u522B"
|
|
814
|
+
] })
|
|
815
|
+
] });
|
|
816
|
+
}
|
|
817
|
+
function GovernancePanel(props) {
|
|
818
|
+
const [section, setSection] = (0, import_react.useState)("metadata");
|
|
819
|
+
const [profiles, setProfiles] = (0, import_react.useState)([]);
|
|
820
|
+
const [changes, setChanges] = (0, import_react.useState)([]);
|
|
821
|
+
const [changeTotal, setChangeTotal] = (0, import_react.useState)(0);
|
|
822
|
+
const [changesHaveMore, setChangesHaveMore] = (0, import_react.useState)(false);
|
|
823
|
+
const [historyLoaded, setHistoryLoaded] = (0, import_react.useState)(false);
|
|
824
|
+
const [historyLoading, setHistoryLoading] = (0, import_react.useState)(false);
|
|
825
|
+
const [sql, setSql] = (0, import_react.useState)("");
|
|
826
|
+
const [queryResult, setQueryResult] = (0, import_react.useState)(null);
|
|
827
|
+
const [queryError, setQueryError] = (0, import_react.useState)("");
|
|
828
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
829
|
+
const [loadedSourceId, setLoadedSourceId] = (0, import_react.useState)("");
|
|
830
|
+
const [working, setWorking] = (0, import_react.useState)(false);
|
|
831
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
832
|
+
const load = async () => {
|
|
833
|
+
if (props.source === null) return;
|
|
834
|
+
setLoading(true);
|
|
835
|
+
setError("");
|
|
836
|
+
try {
|
|
837
|
+
const sourceId = props.source.id;
|
|
838
|
+
const nextProfiles = await props.client.call("metadata/list", { sourceId });
|
|
839
|
+
setProfiles(nextProfiles);
|
|
840
|
+
setLoadedSourceId(sourceId);
|
|
841
|
+
setChanges([]);
|
|
842
|
+
setChangeTotal(0);
|
|
843
|
+
setChangesHaveMore(false);
|
|
844
|
+
setHistoryLoaded(false);
|
|
845
|
+
} catch (nextError) {
|
|
846
|
+
setError(errorText(nextError));
|
|
847
|
+
} finally {
|
|
848
|
+
setLoading(false);
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
(0, import_react.useEffect)(() => {
|
|
852
|
+
if (props.source !== null) {
|
|
853
|
+
setSection("metadata");
|
|
854
|
+
setQueryResult(null);
|
|
855
|
+
setQueryError("");
|
|
856
|
+
void load();
|
|
857
|
+
}
|
|
858
|
+
}, [props.source]);
|
|
859
|
+
async function loadChanges(reset) {
|
|
860
|
+
if (props.source === null || historyLoading) return;
|
|
861
|
+
setHistoryLoading(true);
|
|
862
|
+
setError("");
|
|
863
|
+
try {
|
|
864
|
+
const offset = reset ? 0 : changes.length;
|
|
865
|
+
const response = await props.client.call("metadata/changes", { sourceId: props.source.id, offset, limit: 20 });
|
|
866
|
+
const page = normalizeChangePage(response, offset, 20);
|
|
867
|
+
setChanges((current) => reset ? page.items : [...current, ...page.items]);
|
|
868
|
+
setChangeTotal(page.total);
|
|
869
|
+
setChangesHaveMore(page.hasMore);
|
|
870
|
+
setHistoryLoaded(true);
|
|
871
|
+
} catch (nextError) {
|
|
872
|
+
setError(errorText(nextError));
|
|
873
|
+
} finally {
|
|
874
|
+
setHistoryLoading(false);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
async function downloadYaml() {
|
|
878
|
+
if (props.source === null) return;
|
|
879
|
+
setWorking(true);
|
|
880
|
+
setError("");
|
|
881
|
+
try {
|
|
882
|
+
const yaml = await props.client.call("metadata/yaml", { sourceId: props.source.id });
|
|
883
|
+
const url = URL.createObjectURL(new Blob([yaml], { type: "application/yaml;charset=utf-8" }));
|
|
884
|
+
const anchor = document.createElement("a");
|
|
885
|
+
anchor.href = url;
|
|
886
|
+
anchor.download = `${safeFilename(props.source.name)}-metadata.yaml`;
|
|
887
|
+
anchor.click();
|
|
888
|
+
window.setTimeout(() => {
|
|
889
|
+
URL.revokeObjectURL(url);
|
|
890
|
+
}, 0);
|
|
891
|
+
} catch (nextError) {
|
|
892
|
+
setError(errorText(nextError));
|
|
893
|
+
} finally {
|
|
894
|
+
setWorking(false);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
async function runQuery(event) {
|
|
898
|
+
event.preventDefault();
|
|
899
|
+
if (props.source === null || sql.trim() === "") return;
|
|
900
|
+
setWorking(true);
|
|
901
|
+
setQueryError("");
|
|
902
|
+
setQueryResult(null);
|
|
903
|
+
try {
|
|
904
|
+
setQueryResult(await props.client.call("sources/query", { sourceId: props.source.id, sql, limit: 100 }));
|
|
905
|
+
} catch (nextError) {
|
|
906
|
+
setQueryError(errorText(nextError));
|
|
907
|
+
} finally {
|
|
908
|
+
setWorking(false);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
const governancePending = props.source !== null && (loading || error === "" && loadedSourceId !== props.source.id);
|
|
912
|
+
const sourceLoaded = props.source !== null && loadedSourceId === props.source.id;
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dsh_client_ui_primitives.Modal, { open: props.source !== null, onClose: props.onClose, title: props.source === null ? "\u5143\u6570\u636E" : `${props.source.name} \u5143\u6570\u636E`, className: "dshc-meta-modal", contentClassName: "dshc-modal-content", children: [
|
|
914
|
+
governancePending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, { label: "\u6B63\u5728\u52A0\u8F7D\u5143\u6570\u636E" }) : null,
|
|
915
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error", role: "alert", children: error }) : null,
|
|
916
|
+
!governancePending && sourceLoaded ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-tabs", role: "tablist", children: [["metadata", "\u5143\u6570\u636E"], ["query", "\u53EA\u8BFB SQL"], ["history", "\u53D8\u66F4\u8BB0\u5F55"]].map(([key, label]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", role: "tab", className: "dshc-tab", "data-active": section === key, "aria-selected": section === key, onClick: () => {
|
|
918
|
+
setSection(key);
|
|
919
|
+
if (key === "history" && !historyLoaded) void loadChanges(true);
|
|
920
|
+
}, children: label }, key)) }),
|
|
921
|
+
section === "metadata" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GovernanceMetadataEditor, { client: props.client, profiles, onSaved: load }) : null,
|
|
922
|
+
section === "query" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshc-governance-section", children: [
|
|
923
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "dshc-form", onSubmit: (event) => {
|
|
924
|
+
void runQuery(event);
|
|
925
|
+
}, children: [
|
|
926
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u53EA\u8BFB SQL", wide: true, hint: "\u53EA\u5141\u8BB8 SELECT / WITH\uFF0C\u6700\u591A\u8FD4\u56DE 100 \u884C", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshc-textarea dshc-sql-editor", value: sql, onChange: (event) => {
|
|
927
|
+
setSql(event.target.value);
|
|
928
|
+
setQueryError("");
|
|
929
|
+
}, placeholder: "SELECT ..." }) }),
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: "dshc-primary", disabled: working || sql.trim() === "", children: "\u6267\u884C\u67E5\u8BE2" })
|
|
931
|
+
] }),
|
|
932
|
+
queryResult !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", "data-tone": "success", children: [
|
|
934
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
935
|
+
queryResult.rowCount,
|
|
936
|
+
" \u884C \xB7 ",
|
|
937
|
+
queryResult.durationMs,
|
|
938
|
+
" ms",
|
|
939
|
+
queryResult.truncated ? " \xB7 \u5DF2\u622A\u65AD" : ""
|
|
940
|
+
] }),
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshc-test-result", children: formatValue(queryResult.rows) })
|
|
942
|
+
] }) : null,
|
|
943
|
+
queryError !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error dshc-query-error", role: "alert", children: queryError }) : null
|
|
944
|
+
] }) : null,
|
|
945
|
+
section === "history" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshc-governance-section", children: [
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-section-title", children: [
|
|
947
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
948
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u53D8\u66F4\u8BB0\u5F55" }),
|
|
949
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-row-meta", children: [
|
|
950
|
+
"\u5DF2\u52A0\u8F7D ",
|
|
951
|
+
changes.length,
|
|
952
|
+
" / ",
|
|
953
|
+
changeTotal
|
|
954
|
+
] })
|
|
955
|
+
] }),
|
|
956
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-secondary", disabled: working, onClick: () => {
|
|
957
|
+
void downloadYaml();
|
|
958
|
+
}, children: [
|
|
959
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDownloadOutline16, { size: 14 }),
|
|
960
|
+
"\u5BFC\u51FA YAML"
|
|
961
|
+
] })
|
|
962
|
+
] }),
|
|
963
|
+
changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-governance-row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
964
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: change.summary }),
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("small", { children: [
|
|
966
|
+
new Date(change.changedAt).toLocaleString("zh-CN"),
|
|
967
|
+
" \xB7 ",
|
|
968
|
+
change.action
|
|
969
|
+
] })
|
|
970
|
+
] }) }, change.id)),
|
|
971
|
+
historyLoading && changes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, { label: "\u6B63\u5728\u52A0\u8F7D\u53D8\u66F4\u8BB0\u5F55", compact: true }) : null,
|
|
972
|
+
!historyLoading && historyLoaded && changes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u6682\u65E0\u53D8\u66F4\u8BB0\u5F55" }) : null,
|
|
973
|
+
changesHaveMore ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary dshc-load-more", disabled: historyLoading, onClick: () => {
|
|
974
|
+
void loadChanges(false);
|
|
975
|
+
}, children: historyLoading ? "\u52A0\u8F7D\u4E2D\u2026" : "\u52A0\u8F7D\u66F4\u591A" }) : null
|
|
976
|
+
] }) : null
|
|
977
|
+
] }) : null
|
|
978
|
+
] });
|
|
979
|
+
}
|
|
980
|
+
function GovernanceMetadataEditor(props) {
|
|
981
|
+
const [selected, setSelected] = (0, import_react.useState)("");
|
|
982
|
+
const [search, setSearch] = (0, import_react.useState)("");
|
|
983
|
+
const [tab, setTab] = (0, import_react.useState)("table");
|
|
984
|
+
const profile = props.profiles.find((item) => item.id === selected) ?? props.profiles[0];
|
|
985
|
+
const [term, setTerm] = (0, import_react.useState)("");
|
|
986
|
+
const [description, setDescription] = (0, import_react.useState)("");
|
|
987
|
+
const [tags, setTags] = (0, import_react.useState)("");
|
|
988
|
+
const [synonyms, setSynonyms] = (0, import_react.useState)("");
|
|
989
|
+
const [ignored, setIgnored] = (0, import_react.useState)(false);
|
|
990
|
+
const [columnName, setColumnName] = (0, import_react.useState)("");
|
|
991
|
+
const [columnTerm, setColumnTerm] = (0, import_react.useState)("");
|
|
992
|
+
const [columnDescription, setColumnDescription] = (0, import_react.useState)("");
|
|
993
|
+
const [columnSynonyms, setColumnSynonyms] = (0, import_react.useState)("");
|
|
994
|
+
const [columnEnums, setColumnEnums] = (0, import_react.useState)("");
|
|
995
|
+
const [columnRole, setColumnRole] = (0, import_react.useState)("unknown");
|
|
996
|
+
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
997
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
998
|
+
const selectedColumn = profile?.columns.find((column) => column.name === columnName) ?? profile?.columns[0];
|
|
999
|
+
const visibleProfiles = (0, import_react.useMemo)(() => {
|
|
1000
|
+
const query = search.trim().toLocaleLowerCase();
|
|
1001
|
+
if (query === "") return props.profiles;
|
|
1002
|
+
return props.profiles.filter((item) => `${item.schemaName}.${item.objectName} ${item.term} ${item.description} ${item.comment ?? ""}`.toLocaleLowerCase().includes(query));
|
|
1003
|
+
}, [props.profiles, search]);
|
|
1004
|
+
(0, import_react.useEffect)(() => {
|
|
1005
|
+
if (profile !== void 0) {
|
|
1006
|
+
setSelected(profile.id);
|
|
1007
|
+
setTerm(profile.term);
|
|
1008
|
+
setDescription(profile.description);
|
|
1009
|
+
setTags(profile.tags.join(", "));
|
|
1010
|
+
setSynonyms(profile.synonyms.join(", "));
|
|
1011
|
+
setIgnored(profile.ignored);
|
|
1012
|
+
const first = profile.columns[0];
|
|
1013
|
+
setColumnName(first?.name ?? "");
|
|
1014
|
+
setError("");
|
|
1015
|
+
}
|
|
1016
|
+
}, [profile?.id, profile?.editedAt]);
|
|
1017
|
+
(0, import_react.useEffect)(() => {
|
|
1018
|
+
const semantic = profile?.semanticColumns.find((item) => item.name === selectedColumn?.name);
|
|
1019
|
+
setColumnTerm(semantic?.term ?? selectedColumn?.comment ?? "");
|
|
1020
|
+
setColumnDescription(semantic?.description ?? "");
|
|
1021
|
+
setColumnSynonyms(semantic?.synonyms.join(", ") ?? "");
|
|
1022
|
+
setColumnEnums(semantic?.enums.join(", ") ?? "");
|
|
1023
|
+
setColumnRole(semantic?.role ?? (selectedColumn?.primaryKey || selectedColumn?.references !== void 0 ? "identifier" : "unknown"));
|
|
1024
|
+
}, [profile?.id, selectedColumn?.name]);
|
|
1025
|
+
if (profile === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u6682\u65E0\u5143\u6570\u636E" });
|
|
1026
|
+
const currentProfile = profile;
|
|
1027
|
+
async function saveTable(event) {
|
|
1028
|
+
event.preventDefault();
|
|
1029
|
+
setSaving(true);
|
|
1030
|
+
setError("");
|
|
1031
|
+
try {
|
|
1032
|
+
await props.client.call("metadata/update", { id: currentProfile.id, term, description, tags: csv(tags), synonyms: csv(synonyms), ignored });
|
|
1033
|
+
await props.onSaved();
|
|
1034
|
+
} catch (nextError) {
|
|
1035
|
+
setError(errorText(nextError));
|
|
1036
|
+
} finally {
|
|
1037
|
+
setSaving(false);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
async function saveColumn(event) {
|
|
1041
|
+
event.preventDefault();
|
|
1042
|
+
if (columnName === "") return;
|
|
1043
|
+
setSaving(true);
|
|
1044
|
+
setError("");
|
|
1045
|
+
try {
|
|
1046
|
+
const semanticColumns = currentProfile.semanticColumns.filter((item) => item.name !== columnName);
|
|
1047
|
+
semanticColumns.push({ name: columnName, term: columnTerm, description: columnDescription, synonyms: csv(columnSynonyms), enums: csv(columnEnums), role: columnRole });
|
|
1048
|
+
await props.client.call("metadata/update", { id: currentProfile.id, semanticColumns });
|
|
1049
|
+
await props.onSaved();
|
|
1050
|
+
} catch (nextError) {
|
|
1051
|
+
setError(errorText(nextError));
|
|
1052
|
+
} finally {
|
|
1053
|
+
setSaving(false);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dshc-governance-layout", children: [
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "dshc-governance-sidebar", children: [
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-table-search", children: [
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconSearchOutline16, { size: 14 }),
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { value: search, onChange: (event) => {
|
|
1061
|
+
setSearch(event.target.value);
|
|
1062
|
+
}, placeholder: "\u641C\u7D22\u8868\u540D\u6216\u63CF\u8FF0", "aria-label": "\u641C\u7D22\u8868\u540D\u6216\u63CF\u8FF0" })
|
|
1063
|
+
] }),
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-governance-table-list", children: [
|
|
1065
|
+
visibleProfiles.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dshc-governance-table", "data-active": item.id === currentProfile.id, "aria-current": item.id === currentProfile.id ? "true" : void 0, onClick: () => {
|
|
1066
|
+
setSelected(item.id);
|
|
1067
|
+
}, children: [
|
|
1068
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
1069
|
+
item.schemaName,
|
|
1070
|
+
".",
|
|
1071
|
+
item.objectName
|
|
1072
|
+
] }),
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.description || item.term || item.comment || "\u6682\u65E0\u8868\u63CF\u8FF0" })
|
|
1074
|
+
] }, item.id)),
|
|
1075
|
+
visibleProfiles.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-empty", children: "\u672A\u627E\u5230\u5339\u914D\u7684\u8868" }) : null
|
|
1076
|
+
] })
|
|
1077
|
+
] }),
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-governance-content", children: [
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-governance-heading", children: [
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1081
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
1082
|
+
currentProfile.schemaName,
|
|
1083
|
+
".",
|
|
1084
|
+
currentProfile.objectName
|
|
1085
|
+
] }),
|
|
1086
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: currentProfile.description || currentProfile.comment || "\u6682\u65E0\u8868\u63CF\u8FF0" })
|
|
1087
|
+
] }),
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", children: [
|
|
1089
|
+
currentProfile.columns.length,
|
|
1090
|
+
" \u4E2A\u5B57\u6BB5"
|
|
1091
|
+
] })
|
|
1092
|
+
] }),
|
|
1093
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-tabs dshc-governance-tabs", role: "tablist", children: [
|
|
1094
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", role: "tab", className: "dshc-tab", "data-active": tab === "table", "aria-selected": tab === "table", onClick: () => {
|
|
1095
|
+
setTab("table");
|
|
1096
|
+
}, children: "\u8868\u5143\u6570\u636E" }),
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", role: "tab", className: "dshc-tab", "data-active": tab === "fields", "aria-selected": tab === "fields", onClick: () => {
|
|
1098
|
+
setTab("fields");
|
|
1099
|
+
}, children: "\u5B57\u6BB5\u5143\u6570\u636E" })
|
|
1100
|
+
] }),
|
|
1101
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error", role: "alert", children: error }) : null,
|
|
1102
|
+
tab === "table" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "dshc-form dshc-governance-form", onSubmit: (event) => {
|
|
1103
|
+
void saveTable(event);
|
|
1104
|
+
}, children: [
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-grid", children: [
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u4E1A\u52A1\u540D\u79F0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: term, onChange: (event) => {
|
|
1107
|
+
setTerm(event.target.value);
|
|
1108
|
+
} }) }),
|
|
1109
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u540C\u4E49\u8BCD", hint: "\u9017\u53F7\u5206\u9694", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: synonyms, onChange: (event) => {
|
|
1110
|
+
setSynonyms(event.target.value);
|
|
1111
|
+
} }) }),
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u8868\u63CF\u8FF0", wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshc-textarea", value: description, onChange: (event) => {
|
|
1113
|
+
setDescription(event.target.value);
|
|
1114
|
+
} }) }),
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u6807\u7B7E", hint: "\u9017\u53F7\u5206\u9694", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: tags, onChange: (event) => {
|
|
1116
|
+
setTags(event.target.value);
|
|
1117
|
+
} }) })
|
|
1118
|
+
] }),
|
|
1119
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshc-check", children: [
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: ignored, onChange: (event) => {
|
|
1121
|
+
setIgnored(event.target.checked);
|
|
1122
|
+
} }),
|
|
1123
|
+
"\u4ECE Agent \u68C0\u7D22\u4E2D\u5FFD\u7565"
|
|
1124
|
+
] }),
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: "dshc-primary dshc-form-action", disabled: saving, children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\u8868\u5143\u6570\u636E" })
|
|
1126
|
+
] }) : null,
|
|
1127
|
+
tab === "fields" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "dshc-form dshc-governance-form", onSubmit: (event) => {
|
|
1128
|
+
void saveColumn(event);
|
|
1129
|
+
}, children: [
|
|
1130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u9009\u62E9\u5B57\u6BB5", wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "dshc-select", value: columnName, onChange: (event) => {
|
|
1131
|
+
setColumnName(event.target.value);
|
|
1132
|
+
}, children: currentProfile.columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: column.name, children: [
|
|
1133
|
+
column.name,
|
|
1134
|
+
" \xB7 ",
|
|
1135
|
+
column.type,
|
|
1136
|
+
column.primaryKey ? " \xB7 \u4E3B\u952E" : "",
|
|
1137
|
+
column.references === void 0 ? "" : ` \xB7 \u5916\u952E \u2192 ${column.references.schemaName}.${column.references.objectName}.${column.references.columnName}`
|
|
1138
|
+
] }, column.name)) }) }),
|
|
1139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-grid", children: [
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u5B57\u6BB5\u4E1A\u52A1\u540D\u79F0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: columnTerm, onChange: (event) => {
|
|
1141
|
+
setColumnTerm(event.target.value);
|
|
1142
|
+
} }) }),
|
|
1143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u5B57\u6BB5\u7528\u9014", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", value: columnRole, onChange: (event) => {
|
|
1144
|
+
setColumnRole(event.target.value);
|
|
1145
|
+
}, children: [
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "identifier", children: "\u6807\u8BC6/\u5173\u8054\u5B57\u6BB5" }),
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "dimension", children: "\u63CF\u8FF0/\u5206\u7C7B\u5B57\u6BB5" }),
|
|
1148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "measure", children: "\u6570\u503C\u5B57\u6BB5" }),
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "time", children: "\u65F6\u95F4\u5B57\u6BB5" }),
|
|
1150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "unknown", children: "\u6682\u4E0D\u786E\u5B9A" })
|
|
1151
|
+
] }) }),
|
|
1152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u5B57\u6BB5\u540C\u4E49\u8BCD", hint: "\u9017\u53F7\u5206\u9694", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: columnSynonyms, onChange: (event) => {
|
|
1153
|
+
setColumnSynonyms(event.target.value);
|
|
1154
|
+
} }) }),
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u679A\u4E3E\u503C", hint: "\u9017\u53F7\u5206\u9694", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", value: columnEnums, onChange: (event) => {
|
|
1156
|
+
setColumnEnums(event.target.value);
|
|
1157
|
+
} }) }),
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: "\u5B57\u6BB5\u63CF\u8FF0", wide: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshc-textarea", value: columnDescription, onChange: (event) => {
|
|
1159
|
+
setColumnDescription(event.target.value);
|
|
1160
|
+
} }) })
|
|
1161
|
+
] }),
|
|
1162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: "dshc-primary dshc-form-action", disabled: saving || columnName === "", children: saving ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\u5B57\u6BB5\u5143\u6570\u636E" })
|
|
1163
|
+
] }) : null
|
|
1164
|
+
] })
|
|
1165
|
+
] });
|
|
1166
|
+
}
|
|
1167
|
+
function csv(value) {
|
|
1168
|
+
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
1169
|
+
}
|
|
1170
|
+
function safeFilename(value) {
|
|
1171
|
+
return value.replace(/[\\/:*?"<>|]+/g, "-").trim() || "metadata";
|
|
1172
|
+
}
|
|
1173
|
+
function normalizeChangePage(response, offset, limit) {
|
|
1174
|
+
if (!Array.isArray(response)) {
|
|
1175
|
+
if (typeof response !== "object" || response === null || !Array.isArray(response.items)) throw new Error("\u53D8\u66F4\u8BB0\u5F55\u54CD\u5E94\u683C\u5F0F\u65E0\u6548");
|
|
1176
|
+
return response;
|
|
1177
|
+
}
|
|
1178
|
+
const items = response.slice(offset, offset + limit);
|
|
1179
|
+
return { items, offset, limit, total: response.length, hasMore: offset + limit < response.length };
|
|
1180
|
+
}
|
|
1181
|
+
function ApiTester(props) {
|
|
1182
|
+
const [values, setValues] = (0, import_react.useState)({});
|
|
1183
|
+
const [result, setResult] = (0, import_react.useState)(null);
|
|
1184
|
+
const [testing, setTesting] = (0, import_react.useState)(false);
|
|
1185
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
1186
|
+
(0, import_react.useEffect)(() => {
|
|
1187
|
+
setValues({});
|
|
1188
|
+
setResult(null);
|
|
1189
|
+
setError("");
|
|
1190
|
+
}, [props.definition]);
|
|
1191
|
+
async function test(event) {
|
|
1192
|
+
event.preventDefault();
|
|
1193
|
+
if (props.definition === null) return;
|
|
1194
|
+
setTesting(true);
|
|
1195
|
+
setError("");
|
|
1196
|
+
setResult(null);
|
|
1197
|
+
try {
|
|
1198
|
+
const args = {};
|
|
1199
|
+
for (const parameter of props.definition.parameters) {
|
|
1200
|
+
const raw = values[parameter.name] ?? "";
|
|
1201
|
+
if (raw === "" && !parameter.required) continue;
|
|
1202
|
+
args[parameter.name] = parseParameterValue(parameter, raw);
|
|
1203
|
+
}
|
|
1204
|
+
setResult(await props.client.call("apis/test", { id: props.definition.id, args }));
|
|
1205
|
+
} catch (nextError) {
|
|
1206
|
+
setError(errorText(nextError));
|
|
1207
|
+
} finally {
|
|
1208
|
+
setTesting(false);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1212
|
+
import_dsh_client_ui_primitives.Modal,
|
|
1213
|
+
{
|
|
1214
|
+
open: props.definition !== null,
|
|
1215
|
+
onClose: testing ? () => {
|
|
1216
|
+
} : props.onClose,
|
|
1217
|
+
title: props.definition === null ? "\u6D4B\u8BD5 HTTP API" : `\u6D4B\u8BD5 ${props.definition.name}`,
|
|
1218
|
+
className: "dshc-modal",
|
|
1219
|
+
contentClassName: "dshc-modal-content",
|
|
1220
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dshc-form-footer", children: [
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dshc-secondary", disabled: testing, onClick: props.onClose, children: "\u5173\u95ED" }),
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", form: "dshc-api-test", className: "dshc-primary", disabled: testing, children: testing ? "\u8BF7\u6C42\u4E2D\u2026" : "\u53D1\u9001\u8BF7\u6C42" })
|
|
1223
|
+
] }),
|
|
1224
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { id: "dshc-api-test", className: "dshc-form", onSubmit: (event) => {
|
|
1225
|
+
void test(event);
|
|
1226
|
+
}, children: [
|
|
1227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dshc-grid", children: props.definition?.parameters.map((parameter) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { label: `${parameter.name}${parameter.required ? " *" : ""}`, hint: `${parameter.location} / ${parameter.type}`, wide: parameter.type === "json", children: parameter.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dshc-select", required: parameter.required, value: values[parameter.name] ?? "", onChange: (event) => {
|
|
1228
|
+
setValues({ ...values, [parameter.name]: event.target.value });
|
|
1229
|
+
}, children: [
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\u672A\u8BBE\u7F6E" }),
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "true", children: "true" }),
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "false", children: "false" })
|
|
1233
|
+
] }) : parameter.type === "json" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { className: "dshc-textarea", required: parameter.required, value: values[parameter.name] ?? "", onChange: (event) => {
|
|
1234
|
+
setValues({ ...values, [parameter.name]: event.target.value });
|
|
1235
|
+
} }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dshc-input", required: parameter.required, type: parameter.type === "number" || parameter.type === "integer" ? "number" : "text", step: parameter.type === "integer" ? 1 : "any", value: values[parameter.name] ?? "", onChange: (event) => {
|
|
1236
|
+
setValues({ ...values, [parameter.name]: event.target.value });
|
|
1237
|
+
} }) }, parameter.name)) }),
|
|
1238
|
+
props.definition?.parameters.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-row-meta", children: "\u6B64 API \u65E0\u52A8\u6001\u53C2\u6570" }) : null,
|
|
1239
|
+
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dshc-error", children: error }) : null,
|
|
1240
|
+
result !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1241
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", "data-tone": "success", children: [
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
1243
|
+
"HTTP ",
|
|
1244
|
+
result.status,
|
|
1245
|
+
" / ",
|
|
1246
|
+
result.durationMs,
|
|
1247
|
+
" ms",
|
|
1248
|
+
result.truncated ? " / \u5DF2\u622A\u65AD" : ""
|
|
1249
|
+
] }),
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dshc-test-result", children: formatValue(result.body) })
|
|
1251
|
+
] }) : null
|
|
1252
|
+
] })
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
function Field(props) {
|
|
1257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: `dshc-field${props.wide === true ? " dshc-field-wide" : ""}`, children: [
|
|
1258
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: props.label }),
|
|
1259
|
+
props.children,
|
|
1260
|
+
props.hint !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: props.hint }) : null
|
|
1261
|
+
] });
|
|
1262
|
+
}
|
|
1263
|
+
function Check(props) {
|
|
1264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dshc-check", children: [
|
|
1265
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: props.checked, onChange: (event) => {
|
|
1266
|
+
props.onChange(event.target.checked);
|
|
1267
|
+
} }),
|
|
1268
|
+
props.label
|
|
1269
|
+
] });
|
|
1270
|
+
}
|
|
1271
|
+
function LoadingState({ label, compact = false }) {
|
|
1272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `dshc-loading${compact ? " dshc-loading-compact" : ""}`, role: "status", children: [
|
|
1273
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-spinner", "aria-hidden": "true" }),
|
|
1274
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1275
|
+
label,
|
|
1276
|
+
"\u2026"
|
|
1277
|
+
] })
|
|
1278
|
+
] });
|
|
1279
|
+
}
|
|
1280
|
+
function StatusBadge({ source }) {
|
|
1281
|
+
const job = source.latestJob;
|
|
1282
|
+
if (!source.enabled) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", children: [
|
|
1283
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
1284
|
+
"\u5DF2\u505C\u7528"
|
|
1285
|
+
] });
|
|
1286
|
+
if (job === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", children: [
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
1288
|
+
source.profileCount > 0 ? `\u5DF2\u6709 ${source.profileCount} \u4E2A\u5143\u6570\u636E` : "\u672A\u626B\u63CF"
|
|
1289
|
+
] });
|
|
1290
|
+
const tone = job.status === "completed" ? "success" : job.status === "failed" ? "error" : void 0;
|
|
1291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dshc-badge", "data-tone": tone, children: [
|
|
1292
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dshc-dot" }),
|
|
1293
|
+
jobStatus(job)
|
|
1294
|
+
] });
|
|
1295
|
+
}
|
|
1296
|
+
function DatabaseLogo({ type }) {
|
|
1297
|
+
const logos = { mysql: mysql_default, postgresql: postgresql_default, clickhouse: clickhouse_default };
|
|
1298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `dshc-db-logo dshc-db-logo-${type}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: logos[type], alt: "" }) });
|
|
1299
|
+
}
|
|
1300
|
+
function databaseLabel(type) {
|
|
1301
|
+
return type === "postgresql" ? "PostgreSQL" : type === "clickhouse" ? "ClickHouse" : "MySQL";
|
|
1302
|
+
}
|
|
1303
|
+
function emptyDataSource() {
|
|
1304
|
+
return { name: "", type: "mysql", host: "127.0.0.1", port: 3306, database: "", username: "", secret: "", schemaInclude: "", tls: false, sampleRows: 0, aiEnrichment: false, enabled: true };
|
|
1305
|
+
}
|
|
1306
|
+
function dataSourceDraft(source) {
|
|
1307
|
+
return { id: source.id, name: source.name, type: source.type, host: source.host, port: source.port, database: source.database, username: source.username, secret: "", schemaInclude: source.schemaInclude.join(", "), tls: source.tls, sampleRows: source.sampleRows, aiEnrichment: source.aiEnrichment, enabled: source.enabled };
|
|
1308
|
+
}
|
|
1309
|
+
function emptyApi() {
|
|
1310
|
+
return { name: "", slug: "", description: "", method: "GET", baseUrl: "", pathTemplate: "/", parameters: [], authType: "none", authLocation: "header", authName: "X-API-Key", authUsername: "", secret: "", timeoutMs: 3e4, maxResponseBytes: 131072, responsePointer: "", allowPrivateNetwork: false, enabled: true };
|
|
1311
|
+
}
|
|
1312
|
+
function apiDraft(definition) {
|
|
1313
|
+
const auth = definition.auth;
|
|
1314
|
+
return {
|
|
1315
|
+
id: definition.id,
|
|
1316
|
+
name: definition.name,
|
|
1317
|
+
slug: definition.slug,
|
|
1318
|
+
description: definition.description,
|
|
1319
|
+
method: definition.method,
|
|
1320
|
+
baseUrl: definition.baseUrl,
|
|
1321
|
+
pathTemplate: definition.pathTemplate,
|
|
1322
|
+
parameters: definition.parameters.map((parameter) => ({ ...parameter })),
|
|
1323
|
+
authType: auth.type,
|
|
1324
|
+
authLocation: auth.type === "api-key" ? auth.location : "header",
|
|
1325
|
+
authName: auth.type === "api-key" ? auth.name : "X-API-Key",
|
|
1326
|
+
authUsername: auth.type === "basic" ? auth.username : "",
|
|
1327
|
+
secret: "",
|
|
1328
|
+
timeoutMs: definition.timeoutMs,
|
|
1329
|
+
maxResponseBytes: definition.maxResponseBytes,
|
|
1330
|
+
responsePointer: definition.responsePointer,
|
|
1331
|
+
allowPrivateNetwork: definition.allowPrivateNetwork,
|
|
1332
|
+
enabled: definition.enabled
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
function emptyParameter() {
|
|
1336
|
+
return { name: "", location: "query", type: "string", description: "", required: false };
|
|
1337
|
+
}
|
|
1338
|
+
function authPayload(draft) {
|
|
1339
|
+
if (draft.authType === "none" || draft.authType === "bearer") return { type: draft.authType };
|
|
1340
|
+
if (draft.authType === "basic") return { type: "basic", username: draft.authUsername };
|
|
1341
|
+
return { type: "api-key", location: draft.authLocation, name: draft.authName };
|
|
1342
|
+
}
|
|
1343
|
+
function authLabel(auth) {
|
|
1344
|
+
if (auth.type === "none") return "\u65E0\u9700\u8BA4\u8BC1";
|
|
1345
|
+
return `${auth.type} / ${auth.credentialConfigured ? "\u51ED\u636E\u5DF2\u914D\u7F6E" : "\u51ED\u636E\u672A\u914D\u7F6E"}`;
|
|
1346
|
+
}
|
|
1347
|
+
function replaceAt(values, index, value) {
|
|
1348
|
+
return values.map((item, itemIndex) => itemIndex === index ? value : item);
|
|
1349
|
+
}
|
|
1350
|
+
function defaultPort(type) {
|
|
1351
|
+
if (type === "postgresql") return 5432;
|
|
1352
|
+
if (type === "clickhouse") return 8123;
|
|
1353
|
+
return 3306;
|
|
1354
|
+
}
|
|
1355
|
+
function isActiveJob(job) {
|
|
1356
|
+
return job?.status === "queued" || job?.status === "running";
|
|
1357
|
+
}
|
|
1358
|
+
function jobProgress(job) {
|
|
1359
|
+
if (job === void 0 || job.total === 0) return 4;
|
|
1360
|
+
return Math.max(4, Math.min(100, Math.round(job.processed / job.total * 100)));
|
|
1361
|
+
}
|
|
1362
|
+
function jobStatus(job) {
|
|
1363
|
+
if (job.status === "queued") return "\u7B49\u5F85\u626B\u63CF";
|
|
1364
|
+
if (job.status === "running") return `\u626B\u63CF\u4E2D ${job.processed}/${job.total || "?"}`;
|
|
1365
|
+
if (job.status === "completed") return "\u626B\u63CF\u5B8C\u6210";
|
|
1366
|
+
if (job.status === "failed") return "\u626B\u63CF\u5931\u8D25";
|
|
1367
|
+
return "\u626B\u63CF\u672A\u5B8C\u6210";
|
|
1368
|
+
}
|
|
1369
|
+
function parseParameterValue(parameter, raw) {
|
|
1370
|
+
if (parameter.type === "string") return raw;
|
|
1371
|
+
if (parameter.type === "boolean") return raw === "true";
|
|
1372
|
+
if (parameter.type === "number" || parameter.type === "integer") {
|
|
1373
|
+
const value = Number(raw);
|
|
1374
|
+
if (!Number.isFinite(value) || parameter.type === "integer" && !Number.isSafeInteger(value)) throw new Error(`${parameter.name} \u4E0D\u662F\u6709\u6548\u7684${parameter.type === "integer" ? "\u6574\u6570" : "\u6570\u5B57"}`);
|
|
1375
|
+
return value;
|
|
1376
|
+
}
|
|
1377
|
+
try {
|
|
1378
|
+
return JSON.parse(raw);
|
|
1379
|
+
} catch {
|
|
1380
|
+
throw new Error(`${parameter.name} \u4E0D\u662F\u6709\u6548\u7684 JSON`);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
function formatValue(value) {
|
|
1384
|
+
if (typeof value === "string") return value;
|
|
1385
|
+
try {
|
|
1386
|
+
return JSON.stringify(value, null, 2);
|
|
1387
|
+
} catch {
|
|
1388
|
+
return String(value);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
function errorText(error) {
|
|
1392
|
+
return error instanceof Error ? error.message : String(error);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// src/client/rpc.ts
|
|
1396
|
+
var ConnectClient = class {
|
|
1397
|
+
constructor(rpc) {
|
|
1398
|
+
this.rpc = rpc;
|
|
1399
|
+
}
|
|
1400
|
+
async call(endpoint, payload = {}) {
|
|
1401
|
+
const result = await this.rpc.call("/dsh-connect", endpoint, payload);
|
|
1402
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
1403
|
+
return result.value;
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
// src/client/styles.ts
|
|
1408
|
+
var STYLE_ID = "dsh-connect-styles";
|
|
1409
|
+
var CSS = `
|
|
1410
|
+
.dshc-workbench{width:100%;min-height:100%;box-sizing:border-box;color:var(--dsw-alias-label-primary,#17191c);background:var(--dsw-alias-bg-base,#f6f7f8);padding:28px 32px 40px}
|
|
1411
|
+
.dshc-page-head{display:flex;align-items:center;justify-content:space-between;gap:24px;max-width:1180px;margin:0 auto 22px}.dshc-page-title{min-width:0}.dshc-page-title h1{margin:0;font-size:22px;line-height:1.3;font-weight:650}.dshc-page-title p{margin:5px 0 0;color:var(--dsw-alias-label-tertiary,#70757d);font-size:13px}.dshc-page-summary{display:flex;align-items:center;gap:16px;flex:0 0 auto;color:var(--dsw-alias-label-tertiary,#70757d);font-size:12px;white-space:nowrap}.dshc-summary-item{display:inline-flex;align-items:baseline;gap:5px;white-space:nowrap}.dshc-summary-item strong{color:var(--dsw-alias-label-primary,#17191c);font-size:20px;font-weight:650}
|
|
1412
|
+
.dshc-workbench>.dshc-body{max-width:1180px;margin:0 auto;padding:0}
|
|
1413
|
+
.dshc-card-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:14px}.dshc-source-card,.dshc-api-card{min-width:0;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:8px;padding:16px;background:var(--dsw-alias-bg-layer-3,#fff);transition:border-color .16s,box-shadow .16s}.dshc-source-card:hover,.dshc-api-card:hover{border-color:var(--dsw-alias-label-dimmed,#aeb3ba);box-shadow:0 5px 16px rgb(23 25 28 / 6%)}
|
|
1414
|
+
.dshc-source-card-head{display:flex;align-items:center;gap:10px;min-width:0}.dshc-source-card-title{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}.dshc-source-card-title strong{font-size:14px;font-weight:650;overflow-wrap:anywhere}.dshc-source-card-title span{font-size:11px;color:var(--dsw-alias-label-tertiary,#70757d)}.dshc-db-logo{width:34px;height:34px;border-radius:8px;display:grid;place-items:center;flex:none;background:var(--dsw-alias-bg-layer-1,#f2f3f5)}.dshc-db-logo img{width:22px;height:22px}.dshc-db-logo-mysql{background:#e7f0f7}.dshc-db-logo-postgresql{background:#e9f0f6}.dshc-db-logo-clickhouse{background:#fff1e8}
|
|
1415
|
+
.dshc-source-address{margin:15px 0 11px;font:11px/1.4 ui-monospace,SFMono-Regular,Consolas,monospace;color:var(--dsw-alias-label-secondary,#4f555d);overflow-wrap:anywhere}.dshc-source-stats{display:flex;align-items:center;flex-wrap:wrap;gap:12px;color:var(--dsw-alias-label-tertiary,#70757d);font-size:11px}.dshc-source-stats strong{color:var(--dsw-alias-label-primary,#17191c);font-size:14px;font-weight:650;margin-right:3px}.dshc-current-object,.dshc-api-description{margin:8px 0 0;color:var(--dsw-alias-label-tertiary,#70757d);font-size:11px;line-height:1.45;overflow-wrap:anywhere}.dshc-card-actions{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin-top:15px}.dshc-card-actions-muted{margin-top:9px}.dshc-card-actions-muted .dshc-row-meta{margin-left:auto}.dshc-tool-name{display:block;margin-top:11px;padding:6px 8px;border-radius:5px;background:var(--dsw-alias-bg-base,#f4f5f6);font:10px/1.4 ui-monospace,SFMono-Regular,Consolas,monospace;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,#4f555d)}.dshc-api-method{display:inline-grid;place-items:center;width:43px;height:28px;border-radius:6px;background:var(--dsw-alias-bg-layer-1,#f2f3f5);font:650 10px ui-monospace,SFMono-Regular,Consolas,monospace;color:var(--dsw-alias-label-secondary,#4f555d)}.dshc-api-method[data-method=GET]{color:#147a55;background:#eaf7f0}.dshc-api-method[data-method=POST]{color:#2568a5;background:#eaf2fb}.dshc-api-method[data-method=DELETE]{color:#b23b43;background:#fcedee}
|
|
1416
|
+
.dshc-card{list-style:none;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:8px;background:var(--dsw-alias-bg-layer-3,#fff);color:var(--dsw-alias-label-primary,#17191c);overflow:hidden}
|
|
1417
|
+
.dshc-card[data-open=true]{border-color:var(--dsw-alias-label-dimmed,#aeb3ba);background:var(--dsw-alias-bg-layer-2,#fafafa)}
|
|
1418
|
+
.dshc-card-head{width:100%;border:0;background:none;color:inherit;display:flex;align-items:center;gap:12px;padding:14px 16px;text-align:left;cursor:pointer;font:inherit}
|
|
1419
|
+
.dshc-card-head:focus-visible,.dshc-icon:focus-visible,.dshc-tab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2d6ae3);outline-offset:-2px}
|
|
1420
|
+
.dshc-card-title{display:flex;flex:1;min-width:0;flex-direction:column;gap:3px}
|
|
1421
|
+
.dshc-card-title strong{font-size:15px;line-height:1.4;font-weight:600}
|
|
1422
|
+
.dshc-card-title span{font-size:13px;line-height:1.45;color:var(--dsw-alias-label-tertiary,#70757d)}
|
|
1423
|
+
.dshc-summary{flex:none;font-size:11px;line-height:18px;color:var(--dsw-alias-label-secondary,#4f555d)}
|
|
1424
|
+
.dshc-chevron{flex:none;color:var(--dsw-alias-label-tertiary,#70757d);transition:transform .16s}.dshc-chevron-open{transform:rotate(180deg)}
|
|
1425
|
+
.dshc-body{border-top:1px solid var(--dsw-alias-border-l2,#dfe2e6);padding:0 16px 16px}
|
|
1426
|
+
.dshc-toolbar{display:flex;align-items:center;gap:8px;padding:12px 0 8px;min-height:44px}
|
|
1427
|
+
.dshc-tabs{display:flex;align-items:flex-end;gap:20px;align-self:stretch;border-bottom:1px solid var(--dsw-alias-border-l2,#dfe2e6);margin-right:auto}
|
|
1428
|
+
.dshc-tab{position:relative;border:0;background:none;color:var(--dsw-alias-label-tertiary,#70757d);font:inherit;font-size:13px;line-height:20px;padding:6px 1px 9px;cursor:pointer;white-space:nowrap}
|
|
1429
|
+
.dshc-tab[data-active=true]{color:var(--dsw-alias-label-primary,#17191c);font-weight:600}.dshc-tab[data-active=true]:after{position:absolute;right:0;bottom:-1px;left:0;height:2px;background:var(--dsw-alias-label-primary,#17191c);content:''}
|
|
1430
|
+
.dshc-spacer{flex:1}.dshc-icon{width:30px;height:30px;display:inline-grid;place-items:center;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#4f555d);cursor:pointer}.dshc-icon:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,#aeb3ba);color:var(--dsw-alias-label-primary,#17191c)}.dshc-icon:disabled{opacity:.42;cursor:default}
|
|
1431
|
+
.dshc-primary,.dshc-secondary,.dshc-danger{min-height:30px;border-radius:6px;padding:5px 11px;font:inherit;font-size:12px;line-height:18px;display:inline-flex;align-items:center;justify-content:center;gap:6px;cursor:pointer;white-space:nowrap}
|
|
1432
|
+
.dshc-primary{border:1px solid var(--dsw-alias-label-primary,#17191c);background:var(--dsw-alias-label-primary,#17191c);color:var(--dsw-alias-bg-layer-3,#fff)}
|
|
1433
|
+
.dshc-secondary{border:1px solid var(--dsw-alias-border-l2,#dfe2e6);background:transparent;color:var(--dsw-alias-label-secondary,#4f555d)}
|
|
1434
|
+
.dshc-danger{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary,#c7353d) 35%,transparent);background:transparent;color:var(--dsw-alias-state-error-primary,#c7353d)}
|
|
1435
|
+
.dshc-primary:disabled,.dshc-secondary:disabled,.dshc-danger:disabled{opacity:.42;cursor:default}
|
|
1436
|
+
.dshc-list{border-top:1px solid var(--dsw-alias-border-l2,#dfe2e6)}
|
|
1437
|
+
.dshc-row{display:grid;grid-template-columns:minmax(150px,1fr) minmax(110px,.7fr) minmax(110px,.7fr) auto;align-items:center;gap:12px;padding:12px 2px;border-bottom:1px solid var(--dsw-alias-border-l1,#eceef0)}.dshc-row:last-child{border-bottom:0}
|
|
1438
|
+
.dshc-row-main{min-width:0}.dshc-row-main strong{display:block;overflow-wrap:anywhere;font-size:13px;font-weight:600}.dshc-row-main span,.dshc-row-meta{display:block;margin-top:2px;overflow-wrap:anywhere;font-size:11px;color:var(--dsw-alias-label-tertiary,#70757d)}
|
|
1439
|
+
.dshc-row-actions{display:flex;align-items:center;justify-content:flex-end;gap:5px}
|
|
1440
|
+
.dshc-badge{display:inline-flex;align-items:center;gap:5px;width:max-content;max-width:100%;border-radius:999px;padding:2px 8px;background:var(--dsw-alias-bg-layer-1,#f2f3f5);color:var(--dsw-alias-label-secondary,#4f555d);font-size:11px;line-height:18px}.dshc-dot{width:6px;height:6px;border-radius:50%;background:currentColor}.dshc-badge[data-tone=success]{color:var(--dsw-alias-state-success-primary,#16835b)}.dshc-badge[data-tone=error]{color:var(--dsw-alias-state-error-primary,#c7353d)}.dshc-badge[data-tone=warn]{color:var(--dsw-alias-state-warn-primary,#a86700)}
|
|
1441
|
+
.dshc-progress{height:3px;margin-top:7px;border-radius:2px;background:var(--dsw-alias-bg-layer-1,#e9ebee);overflow:hidden}.dshc-progress span{display:block;height:100%;background:var(--dsw-alias-brand-primary,#2d6ae3);transition:width .2s}
|
|
1442
|
+
.dshc-empty{padding:36px 12px;text-align:center;color:var(--dsw-alias-label-tertiary,#70757d);font-size:13px}.dshc-error,.dshc-notice{margin:10px 0 0;padding:8px 10px;border-radius:6px;font-size:12px;line-height:1.5}.dshc-error{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#c7353d) 10%,transparent);color:var(--dsw-alias-state-error-primary,#c7353d)}.dshc-notice{background:var(--dsw-alias-bg-layer-1,#f2f3f5);color:var(--dsw-alias-label-secondary,#4f555d)}
|
|
1443
|
+
.dshc-loading{display:flex;min-height:220px;align-items:center;justify-content:center;gap:9px;color:var(--dsw-alias-label-tertiary,#70757d);font-size:13px}.dshc-loading-compact{min-height:72px}.dshc-spinner{width:16px;height:16px;box-sizing:border-box;border:2px solid var(--dsw-alias-border-l2,#dfe2e6);border-top-color:var(--dsw-alias-label-primary,#17191c);border-radius:50%;animation:dshc-spin .75s linear infinite}@keyframes dshc-spin{to{transform:rotate(360deg)}}
|
|
1444
|
+
.dshc-modal{width:min(760px,calc(100vw - 32px));max-height:min(820px,calc(100vh - 32px))}.dshc-meta-modal{width:min(1040px,calc(100vw - 32px));max-height:min(820px,calc(100vh - 32px))}.dshc-modal-content{overflow:auto}
|
|
1445
|
+
.dshc-form{display:flex;flex-direction:column;gap:16px}.dshc-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px 16px}.dshc-field{display:flex;min-width:0;flex-direction:column;gap:6px}.dshc-field-wide{grid-column:1/-1}.dshc-field label,.dshc-field-label{font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,#4f555d)}.dshc-field small{font-size:11px;color:var(--dsw-alias-label-tertiary,#70757d)}
|
|
1446
|
+
.dshc-input,.dshc-select,.dshc-textarea{width:100%;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:6px;background:var(--dsw-alias-bg-layer-3,#fff);color:var(--dsw-alias-label-primary,#17191c);font:inherit;font-size:13px}.dshc-input,.dshc-select{height:34px;padding:0 9px}.dshc-textarea{min-height:76px;resize:vertical;padding:8px 9px;line-height:1.5}.dshc-input:focus,.dshc-select:focus,.dshc-textarea:focus{outline:2px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#2d6ae3) 35%,transparent);border-color:var(--dsw-alias-brand-primary,#2d6ae3)}
|
|
1447
|
+
.dshc-db-picker{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.dshc-db-option{min-width:0;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:8px;background:var(--dsw-alias-bg-layer-3,#fff);color:var(--dsw-alias-label-primary,#17191c);padding:10px 8px;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:2px 8px;text-align:left;cursor:pointer}.dshc-db-option:hover{border-color:var(--dsw-alias-label-dimmed,#aeb3ba)}.dshc-db-option[data-active=true]{border-color:var(--dsw-alias-brand-primary,#2d6ae3);box-shadow:inset 0 0 0 1px var(--dsw-alias-brand-primary,#2d6ae3)}.dshc-db-option .dshc-db-logo{grid-row:1/3}.dshc-db-option>span{font-size:12px;font-weight:650;overflow-wrap:anywhere}.dshc-db-option>small{font-size:10px;color:var(--dsw-alias-label-tertiary,#70757d)}
|
|
1448
|
+
.dshc-checks{display:flex;align-items:center;flex-wrap:wrap;gap:14px}.dshc-check{display:inline-flex;align-items:center;gap:7px;font-size:12px;color:var(--dsw-alias-label-secondary,#4f555d)}.dshc-check input{width:15px;height:15px;accent-color:var(--dsw-alias-brand-primary,#2d6ae3)}
|
|
1449
|
+
.dshc-form-footer{display:flex;align-items:center;justify-content:flex-end;gap:8px}.dshc-form-error{margin-right:auto;font-size:12px;color:var(--dsw-alias-state-error-primary,#c7353d)}
|
|
1450
|
+
.dshc-section-title{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:4px;border-top:1px solid var(--dsw-alias-border-l1,#eceef0)}.dshc-section-title strong{font-size:12px}.dshc-param-list{display:flex;flex-direction:column;gap:8px}.dshc-param{display:grid;grid-template-columns:minmax(110px,1.1fr) minmax(90px,.8fr) minmax(90px,.8fr) auto auto;align-items:center;gap:7px}.dshc-param .dshc-input,.dshc-param .dshc-select{height:32px;font-size:12px}.dshc-param-desc{grid-column:1/5}
|
|
1451
|
+
.dshc-test-result{max-height:240px;overflow:auto;margin:0;padding:10px;border-radius:6px;background:var(--dsw-alias-bg-base,#f4f5f6);font:12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
1452
|
+
.dshc-meta-layout{display:grid;grid-template-columns:minmax(210px,.7fr) minmax(0,1.6fr);gap:16px;min-height:420px}.dshc-meta-side{border-right:1px solid var(--dsw-alias-border-l2,#dfe2e6);padding-right:14px}.dshc-meta-search{margin-bottom:8px}.dshc-search-wrap{position:relative;display:block}.dshc-search-wrap svg{position:absolute;left:8px;top:9px}.dshc-search-wrap .dshc-input{padding-left:30px}.dshc-meta-list{max-height:540px;overflow:auto}.dshc-meta-item{width:100%;border:0;border-bottom:1px solid var(--dsw-alias-border-l1,#eceef0);background:transparent;color:inherit;text-align:left;padding:9px 4px;cursor:pointer}.dshc-meta-item[data-active=true]{background:var(--dsw-alias-bg-layer-1,#f2f3f5)}.dshc-meta-item strong{display:block;font-size:12px;overflow-wrap:anywhere}.dshc-meta-item span{font-size:11px;color:var(--dsw-alias-label-tertiary,#70757d)}.dshc-meta-detail{min-width:0;overflow:auto}.dshc-meta-detail h3{margin:0 0 4px;font-size:15px}.dshc-meta-detail p{margin:4px 0 12px;font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary,#4f555d)}
|
|
1453
|
+
.dshc-table{width:100%;border-collapse:collapse;font-size:11px}.dshc-table th,.dshc-table td{padding:7px 8px;border-bottom:1px solid var(--dsw-alias-border-l1,#eceef0);text-align:left;vertical-align:top;overflow-wrap:anywhere}.dshc-table th{color:var(--dsw-alias-label-tertiary,#70757d);font-weight:600}.dshc-code{max-height:220px;overflow:auto;padding:10px;border-radius:6px;background:var(--dsw-alias-bg-base,#f4f5f6);font:11px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.dshc-detail-title{margin:16px 0 7px;font-size:12px;font-weight:600}
|
|
1454
|
+
.dshc-governance-section{display:flex;flex-direction:column;gap:10px;padding-top:16px}.dshc-governance-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;padding:10px 2px;border-bottom:1px solid var(--dsw-alias-border-l1,#eceef0)}.dshc-governance-row>div{min-width:0}.dshc-governance-row strong{display:block;font-size:12px;overflow-wrap:anywhere}.dshc-governance-row small{display:block;margin-top:3px;color:var(--dsw-alias-label-tertiary,#70757d);font-size:11px;line-height:1.45;overflow-wrap:anywhere}.dshc-sql-editor{min-height:150px;font:12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace}.dshc-query-error{margin-top:auto}
|
|
1455
|
+
.dshc-load-more{align-self:center;margin-top:4px}.dshc-governance-layout{display:grid;grid-template-columns:250px minmax(0,1fr);min-height:540px;border-top:1px solid var(--dsw-alias-border-l2,#dfe2e6);margin-top:12px}.dshc-governance-sidebar{min-width:0;padding:14px 12px 0 0;border-right:1px solid var(--dsw-alias-border-l2,#dfe2e6)}.dshc-table-search{display:flex;align-items:center;gap:6px;height:32px;padding:0 9px;border:1px solid var(--dsw-alias-border-l2,#dfe2e6);border-radius:6px;color:var(--dsw-alias-label-tertiary,#70757d)}.dshc-table-search input{width:100%;min-width:0;border:0;outline:0;background:transparent;color:inherit;font:inherit;font-size:12px}.dshc-governance-table-list{display:flex;flex-direction:column;gap:3px;margin-top:10px;max-height:470px;overflow:auto}.dshc-governance-table{display:flex;flex-direction:column;gap:3px;width:100%;padding:9px 10px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#4f555d);text-align:left;cursor:pointer}.dshc-governance-table:hover{background:var(--dsw-alias-bg-layer-1,#f2f3f5)}.dshc-governance-table[data-active=true]{border-color:var(--dsw-alias-border-l2,#dfe2e6);background:var(--dsw-alias-bg-layer-1,#f2f3f5);color:var(--dsw-alias-label-primary,#17191c)}.dshc-governance-table strong{font-size:12px;overflow-wrap:anywhere}.dshc-governance-table span{font-size:11px;line-height:1.4;color:var(--dsw-alias-label-tertiary,#70757d);overflow-wrap:anywhere}.dshc-governance-content{min-width:0;padding:14px 0 0 20px}.dshc-governance-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.dshc-governance-heading>div{min-width:0}.dshc-governance-heading strong,.dshc-governance-heading span{display:block;overflow-wrap:anywhere}.dshc-governance-heading strong{font-size:15px}.dshc-governance-heading>div span{margin-top:3px;color:var(--dsw-alias-label-tertiary,#70757d);font-size:11px}.dshc-governance-tabs{margin-top:15px;margin-right:0;gap:18px}.dshc-governance-form{padding-top:18px}.dshc-form-action{align-self:flex-start}
|
|
1456
|
+
@media(max-width:720px){.dshc-workbench{position:fixed;inset:78px 24px 24px;z-index:1;min-height:0;overflow:auto;padding:16px 12px 28px;background:var(--dsw-alias-bg-layer-3,#fff)}.dshc-page-head{align-items:flex-start;flex-direction:column;gap:14px}.dshc-page-title{align-items:flex-start}.dshc-page-title p{font-size:12px}.dshc-page-summary{padding-left:0}.dshc-body{padding:0}.dshc-toolbar{flex-wrap:wrap}.dshc-tabs{width:100%;order:2;gap:14px;overflow-x:auto}.dshc-card-grid{grid-template-columns:1fr}.dshc-row{grid-template-columns:minmax(0,1fr) auto}.dshc-row-meta{display:none}.dshc-meta-layout{grid-template-columns:1fr}.dshc-meta-side{border-right:0;border-bottom:1px solid var(--dsw-alias-border-l2,#dfe2e6);padding:0 0 12px}.dshc-meta-list{max-height:180px}.dshc-grid{grid-template-columns:1fr}.dshc-field-wide{grid-column:auto}.dshc-db-picker{grid-template-columns:1fr}.dshc-param{grid-template-columns:1fr 1fr}.dshc-param-desc{grid-column:1/3}.dshc-param .dshc-icon{justify-self:end}.dshc-summary{display:none}.dshc-governance-row{align-items:flex-start}.dshc-governance-row .dshc-badge{flex:none}.dshc-governance-layout{grid-template-columns:1fr}.dshc-governance-sidebar{padding:12px 0;border-right:0;border-bottom:1px solid var(--dsw-alias-border-l2,#dfe2e6)}.dshc-governance-table-list{max-height:180px}.dshc-governance-content{padding:14px 0 0}}
|
|
1457
|
+
@media(max-width:720px){.dshc-workbench{width:auto}}
|
|
1458
|
+
`;
|
|
1459
|
+
function installConnectStyles(ctx) {
|
|
1460
|
+
if (typeof document === "undefined" || document.getElementById(STYLE_ID) !== null) return;
|
|
1461
|
+
const style = document.createElement("style");
|
|
1462
|
+
style.id = STYLE_ID;
|
|
1463
|
+
style.textContent = CSS;
|
|
1464
|
+
document.head.append(style);
|
|
1465
|
+
ctx.effect(() => () => {
|
|
1466
|
+
style.remove();
|
|
1467
|
+
}, "dsh-connect styles");
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
// src/client/index.tsx
|
|
1471
|
+
var name = "dsh-connect-client";
|
|
1472
|
+
var inject = ["slots", "connection"];
|
|
1473
|
+
function apply(ctx) {
|
|
1474
|
+
installConnectStyles(ctx);
|
|
1475
|
+
const client = new ConnectClient(ctx.connection.rpc);
|
|
1476
|
+
const section = {
|
|
1477
|
+
name: "settings.section",
|
|
1478
|
+
id: "dsh-connect",
|
|
1479
|
+
order: 35,
|
|
1480
|
+
label: "DSH\u8FDE\u63A5\u5668",
|
|
1481
|
+
icon: "connection",
|
|
1482
|
+
inject: () => ({ connectClient: client })
|
|
1483
|
+
};
|
|
1484
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register(section, ConnectSettings));
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
return module.exports;
|
|
1488
|
+
}
|
|
1489
|
+
});
|