@yuku123/z-cognition-component 1.0.1 → 1.0.3

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.
@@ -4,17 +4,17 @@ import { useNavigate as x } from "react-router-dom";
4
4
  import { Input as i, Form as a, Space as f, Button as d, Table as E, Tag as S, Modal as z, Select as O, message as m } from "antd";
5
5
  import { ReloadOutlined as P, PlusOutlined as $ } from "@ant-design/icons";
6
6
  import { cognitionApi as g } from "./api.js";
7
- import { K as q, C as F, a as N } from "./EvidenceFormList-097ICr7D.js";
8
- const { TextArea: j } = i;
7
+ import { K as k, C as q, a as F } from "./EvidenceFormList-097ICr7D.js";
8
+ const { TextArea: N } = i;
9
9
  function H() {
10
- const w = x(), [I, C] = r([]), [b, u] = r(!1), [p, h] = r(""), [K, s] = r(!1), [v, y] = r(!1), [c] = a.useForm(), l = async (t = p) => {
11
- u(!0);
10
+ const w = x(), [I, C] = r([]), [b, p] = r(!1), [u, h] = r(""), [K, s] = r(!1), [v, y] = r(!1), [c] = a.useForm(), l = async (t = u) => {
11
+ p(!0);
12
12
  try {
13
13
  C(await g.listConcepts({ domain: t }));
14
14
  } catch (n) {
15
15
  m.error(n.message);
16
16
  } finally {
17
- u(!1);
17
+ p(!1);
18
18
  }
19
19
  };
20
20
  return T(() => {
@@ -27,7 +27,7 @@ function H() {
27
27
  placeholder: "域(如 trade)",
28
28
  allowClear: !0,
29
29
  style: { width: 180 },
30
- value: p,
30
+ value: u,
31
31
  onChange: (t) => h(t.target.value),
32
32
  onPressEnter: () => l()
33
33
  }
@@ -59,6 +59,7 @@ function H() {
59
59
  render: (t, n) => /* @__PURE__ */ e(
60
60
  d,
61
61
  {
62
+ type: "link",
62
63
  size: "small",
63
64
  onClick: () => w(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(n.conceptKey)}`),
64
65
  children: "影响面"
@@ -101,18 +102,18 @@ function H() {
101
102
  label: "conceptKey",
102
103
  rules: [
103
104
  { required: !0, message: "必填" },
104
- { pattern: q, message: "^[a-z][a-z0-9_.-]{1,127}$" }
105
+ { pattern: k, message: "^[a-z][a-z0-9_.-]{1,127}$" }
105
106
  ],
106
107
  children: /* @__PURE__ */ e(i, { style: { width: 240 }, placeholder: "order" })
107
108
  }
108
109
  ),
109
110
  /* @__PURE__ */ e(a.Item, { name: "name", label: "名称", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(i, { style: { width: 200 }, placeholder: "订单" }) }),
110
- /* @__PURE__ */ e(a.Item, { name: "conceptType", label: "类型", rules: [{ required: !0, message: "必填" }], initialValue: "ENTITY", children: /* @__PURE__ */ e(O, { style: { width: 140 }, options: F.map((t) => ({ value: t, label: t })) }) }),
111
+ /* @__PURE__ */ e(a.Item, { name: "conceptType", label: "类型", rules: [{ required: !0, message: "必填" }], initialValue: "ENTITY", children: /* @__PURE__ */ e(O, { style: { width: 140 }, options: q.map((t) => ({ value: t, label: t })) }) }),
111
112
  /* @__PURE__ */ e(a.Item, { name: "domain", label: "域", children: /* @__PURE__ */ e(i, { style: { width: 140 } }) }),
112
113
  /* @__PURE__ */ e(a.Item, { name: "parentKey", label: "父概念", children: /* @__PURE__ */ e(i, { style: { width: 180 } }) })
113
114
  ] }),
114
- /* @__PURE__ */ e(a.Item, { name: "definition", label: "定义", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(j, { rows: 3 }) }),
115
- /* @__PURE__ */ e(a.Item, { label: "证据(至少一条)", required: !0, children: /* @__PURE__ */ e(N, {}) })
115
+ /* @__PURE__ */ e(a.Item, { name: "definition", label: "定义", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(N, { rows: 3 }) }),
116
+ /* @__PURE__ */ e(a.Item, { label: "证据(至少一条)", required: !0, children: /* @__PURE__ */ e(F, {}) })
116
117
  ] })
117
118
  }
118
119
  )
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),S=require("react-router-dom"),t=require("antd"),p=require("@ant-design/icons"),h=require("./api.cjs"),l=require("./EvidenceFormList-CQNgMNCG.cjs"),{TextArea:b}=t.Input;function v(){const x=S.useNavigate(),[y,g]=a.useState([]),[j,c]=a.useState(!1),[d,u]=a.useState(""),[w,r]=a.useState(!1),[I,m]=a.useState(!1),[o]=t.Form.useForm(),i=async(n=d)=>{c(!0);try{g(await h.cognitionApi.listConcepts({domain:n}))}catch(s){t.message.error(s.message)}finally{c(!1)}};a.useEffect(()=>{i()},[]);const f=async()=>{const n=await o.validateFields();m(!0);try{await h.cognitionApi.createConcept({...n,actor:n.actor||"console",note:n.note||"console create"}),t.message.success(`概念 ${n.conceptKey} 已登记`),r(!1),o.resetFields(),await i()}catch(s){t.message.error(s.field?`${s.field}: ${s.message}`:s.message)}finally{m(!1)}};return e.jsxs("div",{children:[e.jsxs(t.Space,{wrap:!0,style:{marginBottom:16},children:[e.jsx(t.Input,{placeholder:"域(如 trade)",allowClear:!0,style:{width:180},value:d,onChange:n=>u(n.target.value),onPressEnter:()=>i()}),e.jsx(t.Button,{icon:e.jsx(p.ReloadOutlined,{}),onClick:()=>{u(""),i("")},children:"重置"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(p.PlusOutlined,{}),onClick:()=>r(!0),children:"新建概念"})]}),e.jsx(t.Table,{rowKey:"conceptKey",size:"middle",loading:j,dataSource:y,pagination:{pageSize:20,showSizeChanger:!1},columns:[{title:"conceptKey",dataIndex:"conceptKey",width:200},{title:"名称",dataIndex:"name",width:180},{title:"类型",dataIndex:"conceptType",width:120,render:n=>e.jsx(t.Tag,{children:n})},{title:"域",dataIndex:"domain",width:120},{title:"父概念",dataIndex:"parentKey",width:180,render:n=>n||"—"},{title:"版本",dataIndex:"revisionNo",width:70,render:n=>`r${n}`},{title:"定义",dataIndex:"definition",ellipsis:!0},{title:"操作",width:110,render:(n,s)=>e.jsx(t.Button,{size:"small",onClick:()=>x(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(s.conceptKey)}`),children:"影响面"})}]}),e.jsx(t.Modal,{title:"新建概念(证据必填)",open:w,onCancel:()=>r(!1),onOk:f,confirmLoading:I,width:800,destroyOnHidden:!0,children:e.jsxs(t.Form,{form:o,layout:"vertical",children:[e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsx(t.Form.Item,{name:"conceptKey",label:"conceptKey",rules:[{required:!0,message:"必填"},{pattern:l.KEY_PATTERN,message:"^[a-z][a-z0-9_.-]{1,127}$"}],children:e.jsx(t.Input,{style:{width:240},placeholder:"order"})}),e.jsx(t.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:e.jsx(t.Input,{style:{width:200},placeholder:"订单"})}),e.jsx(t.Form.Item,{name:"conceptType",label:"类型",rules:[{required:!0,message:"必填"}],initialValue:"ENTITY",children:e.jsx(t.Select,{style:{width:140},options:l.CONCEPT_TYPES.map(n=>({value:n,label:n}))})}),e.jsx(t.Form.Item,{name:"domain",label:"域",children:e.jsx(t.Input,{style:{width:140}})}),e.jsx(t.Form.Item,{name:"parentKey",label:"父概念",children:e.jsx(t.Input,{style:{width:180}})})]}),e.jsx(t.Form.Item,{name:"definition",label:"定义",rules:[{required:!0,message:"必填"}],children:e.jsx(b,{rows:3})}),e.jsx(t.Form.Item,{label:"证据(至少一条)",required:!0,children:e.jsx(l.EvidenceFormList,{})})]})})]})}exports.default=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),S=require("react-router-dom"),t=require("antd"),p=require("@ant-design/icons"),h=require("./api.cjs"),l=require("./EvidenceFormList-CQNgMNCG.cjs"),{TextArea:b}=t.Input;function v(){const x=S.useNavigate(),[y,g]=a.useState([]),[j,c]=a.useState(!1),[d,u]=a.useState(""),[w,r]=a.useState(!1),[I,m]=a.useState(!1),[o]=t.Form.useForm(),i=async(n=d)=>{c(!0);try{g(await h.cognitionApi.listConcepts({domain:n}))}catch(s){t.message.error(s.message)}finally{c(!1)}};a.useEffect(()=>{i()},[]);const f=async()=>{const n=await o.validateFields();m(!0);try{await h.cognitionApi.createConcept({...n,actor:n.actor||"console",note:n.note||"console create"}),t.message.success(`概念 ${n.conceptKey} 已登记`),r(!1),o.resetFields(),await i()}catch(s){t.message.error(s.field?`${s.field}: ${s.message}`:s.message)}finally{m(!1)}};return e.jsxs("div",{children:[e.jsxs(t.Space,{wrap:!0,style:{marginBottom:16},children:[e.jsx(t.Input,{placeholder:"域(如 trade)",allowClear:!0,style:{width:180},value:d,onChange:n=>u(n.target.value),onPressEnter:()=>i()}),e.jsx(t.Button,{icon:e.jsx(p.ReloadOutlined,{}),onClick:()=>{u(""),i("")},children:"重置"}),e.jsx(t.Button,{type:"primary",icon:e.jsx(p.PlusOutlined,{}),onClick:()=>r(!0),children:"新建概念"})]}),e.jsx(t.Table,{rowKey:"conceptKey",size:"middle",loading:j,dataSource:y,pagination:{pageSize:20,showSizeChanger:!1},columns:[{title:"conceptKey",dataIndex:"conceptKey",width:200},{title:"名称",dataIndex:"name",width:180},{title:"类型",dataIndex:"conceptType",width:120,render:n=>e.jsx(t.Tag,{children:n})},{title:"域",dataIndex:"domain",width:120},{title:"父概念",dataIndex:"parentKey",width:180,render:n=>n||"—"},{title:"版本",dataIndex:"revisionNo",width:70,render:n=>`r${n}`},{title:"定义",dataIndex:"definition",ellipsis:!0},{title:"操作",width:110,render:(n,s)=>e.jsx(t.Button,{type:"link",size:"small",onClick:()=>x(`/cognition/impact?subjectType=concept&subjectKey=${encodeURIComponent(s.conceptKey)}`),children:"影响面"})}]}),e.jsx(t.Modal,{title:"新建概念(证据必填)",open:w,onCancel:()=>r(!1),onOk:f,confirmLoading:I,width:800,destroyOnHidden:!0,children:e.jsxs(t.Form,{form:o,layout:"vertical",children:[e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsx(t.Form.Item,{name:"conceptKey",label:"conceptKey",rules:[{required:!0,message:"必填"},{pattern:l.KEY_PATTERN,message:"^[a-z][a-z0-9_.-]{1,127}$"}],children:e.jsx(t.Input,{style:{width:240},placeholder:"order"})}),e.jsx(t.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:e.jsx(t.Input,{style:{width:200},placeholder:"订单"})}),e.jsx(t.Form.Item,{name:"conceptType",label:"类型",rules:[{required:!0,message:"必填"}],initialValue:"ENTITY",children:e.jsx(t.Select,{style:{width:140},options:l.CONCEPT_TYPES.map(n=>({value:n,label:n}))})}),e.jsx(t.Form.Item,{name:"domain",label:"域",children:e.jsx(t.Input,{style:{width:140}})}),e.jsx(t.Form.Item,{name:"parentKey",label:"父概念",children:e.jsx(t.Input,{style:{width:180}})})]}),e.jsx(t.Form.Item,{name:"definition",label:"定义",rules:[{required:!0,message:"必填"}],children:e.jsx(b,{rows:3})}),e.jsx(t.Form.Item,{label:"证据(至少一条)",required:!0,children:e.jsx(l.EvidenceFormList,{})})]})})]})}exports.default=v;
@@ -0,0 +1,192 @@
1
+ import { jsx as t, jsxs as r, Fragment as q } from "react/jsx-runtime";
2
+ import { useState as c, useRef as F, useEffect as U, useMemo as I } from "react";
3
+ import { useSearchParams as W, useNavigate as G } from "react-router-dom";
4
+ import { Empty as H, Tag as d, Input as N, Button as _, Spin as J, Tabs as Q, Table as k, Space as $, message as V } from "antd";
5
+ import { ApartmentOutlined as X, ReloadOutlined as Y, NodeIndexOutlined as Z } from "@ant-design/icons";
6
+ import { f as z, o as m } from "./api-BVrIcAFp.js";
7
+ import "@antv/g6";
8
+ import "d3-force";
9
+ function oe() {
10
+ const [O] = W(), n = O.get("id") || "", j = G(), [v, w] = c("default"), [l, T] = c(null), [h, L] = c([]), [y, A] = c([]), [x, K] = c([]), [R, C] = c(!1), [f, D] = c(""), o = F(0), g = async (e = v) => {
11
+ if (!n) return;
12
+ const a = ++o.current;
13
+ C(!0);
14
+ const i = (s, u) => V.error(`${s}取数失败:${u.message}`), b = [
15
+ ["统计", () => m.stats(n, e).then((s) => T(s))],
16
+ ["类列表", () => m.listClasses(n, e).then((s) => L(s || []))],
17
+ ["实例列表", () => m.listIndividuals(n, e).then((s) => A(s || []))]
18
+ ];
19
+ for (const [s, u] of b) {
20
+ if (a !== o.current) return;
21
+ try {
22
+ await u();
23
+ } catch (p) {
24
+ a === o.current && i(s, p);
25
+ }
26
+ }
27
+ try {
28
+ const u = ((h.length ? h : await m.listClasses(n, e)) || []).map((P) => P.key), p = await m.subgraph(n, u, 1, e);
29
+ a === o.current && K((p == null ? void 0 : p.edges) || []);
30
+ } catch (s) {
31
+ a === o.current && i("关系", s);
32
+ }
33
+ a === o.current && C(!1);
34
+ };
35
+ U(() => (n && (w("default"), g("default")), () => {
36
+ o.current += 1;
37
+ }), [n]);
38
+ const E = I(() => l ? [
39
+ { label: "类节点", value: l.class_nodes ?? l.classNodes ?? 0, sub: "classes" },
40
+ { label: "实例节点", value: l.individual_nodes ?? l.individualNodes ?? 0, sub: "individuals" },
41
+ { label: "总节点", value: l.node_count ?? l.nodeCount ?? 0, sub: "nodes" },
42
+ { label: "关系边", value: l.edge_count ?? l.edgeCount ?? 0, sub: "edges" },
43
+ { label: "显式陈述", value: l.explicit_statements ?? l.explicitStatements ?? 0, sub: "explicit" },
44
+ { label: "推理陈述", value: l.inferred_statements ?? l.inferredStatements ?? 0, sub: "inferred" }
45
+ ] : [], [l]), S = [
46
+ { title: "key", dataIndex: "key", key: "key", width: 240 },
47
+ {
48
+ title: "标签",
49
+ dataIndex: "labels",
50
+ key: "labels",
51
+ width: 220,
52
+ render: (e) => (e || []).map((a) => /* @__PURE__ */ t(d, { color: a === "OntologyClass" ? "purple" : a === "OntologyIndividual" ? "blue" : void 0, children: a }, a))
53
+ },
54
+ {
55
+ title: "属性",
56
+ dataIndex: "properties",
57
+ key: "properties",
58
+ render: (e) => /* @__PURE__ */ r($, { size: 4, wrap: !0, children: [
59
+ Object.entries(e || {}).slice(0, 8).map(([a, i]) => /* @__PURE__ */ r(d, { color: "default", children: [
60
+ a,
61
+ "=",
62
+ String(i)
63
+ ] }, a)),
64
+ Object.keys(e || {}).length > 8 ? /* @__PURE__ */ r(d, { children: [
65
+ "+",
66
+ Object.keys(e).length - 8
67
+ ] }) : null
68
+ ] })
69
+ }
70
+ ], M = [
71
+ { title: "from", dataIndex: "from_key", key: "from_key", width: 220 },
72
+ { title: "type", dataIndex: "type", key: "type", width: 160, render: (e) => /* @__PURE__ */ t(d, { color: "geekblue", children: e }) },
73
+ { title: "to", dataIndex: "to_key", key: "to_key", width: 220 },
74
+ {
75
+ title: "属性",
76
+ dataIndex: "properties",
77
+ key: "properties",
78
+ render: (e) => /* @__PURE__ */ t($, { size: 4, wrap: !0, children: Object.entries(e || {}).slice(0, 4).map(([a, i]) => /* @__PURE__ */ r(d, { color: "default", children: [
79
+ a,
80
+ "=",
81
+ String(i)
82
+ ] }, a)) })
83
+ }
84
+ ], B = I(() => {
85
+ const e = f.trim().toLowerCase();
86
+ return e ? (y || []).filter(
87
+ (a) => a.key.toLowerCase().includes(e) || (a.labels || []).some((i) => i.toLowerCase().includes(e)) || Object.entries(a.properties || {}).some(([i, b]) => `${i}=${b}`.toLowerCase().includes(e))
88
+ ) : y;
89
+ }, [y, f]);
90
+ return n ? /* @__PURE__ */ r("div", { className: "view", children: [
91
+ /* @__PURE__ */ r("div", { className: "view-bar", children: [
92
+ /* @__PURE__ */ r(d, { icon: /* @__PURE__ */ t(X, {}), color: "purple", children: [
93
+ "本体 ",
94
+ n
95
+ ] }),
96
+ /* @__PURE__ */ t(
97
+ N.Search,
98
+ {
99
+ style: { width: 200 },
100
+ placeholder: "工作空间(默认 default)",
101
+ value: v,
102
+ onChange: (e) => w(e.target.value),
103
+ onSearch: () => g()
104
+ }
105
+ ),
106
+ /* @__PURE__ */ t(_, { icon: /* @__PURE__ */ t(Y, {}), onClick: () => g(), children: "刷新" }),
107
+ /* @__PURE__ */ t(
108
+ _,
109
+ {
110
+ type: "primary",
111
+ icon: /* @__PURE__ */ t(Z, {}),
112
+ onClick: () => j(`/ontology/nodes?id=${encodeURIComponent(n)}`),
113
+ children: "图谱"
114
+ }
115
+ ),
116
+ /* @__PURE__ */ t("span", { className: "hint spacer" }),
117
+ /* @__PURE__ */ t("span", { className: "hint", children: z(l, "lastMaterializedAt", "last_materialized_at") ? `物化于 ${new Date(z(l, "lastMaterializedAt", "last_materialized_at")).toLocaleString()}` : "" })
118
+ ] }),
119
+ l ? /* @__PURE__ */ t("div", { className: "stat-cards", children: E.map((e) => /* @__PURE__ */ r("div", { className: "stat-card", children: [
120
+ /* @__PURE__ */ t("span", { className: "label", children: e.label }),
121
+ /* @__PURE__ */ t("span", { className: "value", children: e.value }),
122
+ /* @__PURE__ */ t("span", { className: "sub", children: e.sub })
123
+ ] }, e.label)) }) : null,
124
+ /* @__PURE__ */ t(J, { spinning: R, children: /* @__PURE__ */ t(
125
+ Q,
126
+ {
127
+ items: [
128
+ {
129
+ key: "classes",
130
+ label: `类定义(${h.length})`,
131
+ children: /* @__PURE__ */ t(
132
+ k,
133
+ {
134
+ rowKey: "key",
135
+ size: "small",
136
+ columns: S,
137
+ dataSource: h,
138
+ pagination: !1,
139
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无类定义(可先登记 schema 或物化)" }) }
140
+ }
141
+ )
142
+ },
143
+ {
144
+ key: "edges",
145
+ label: `关系(${x.length})`,
146
+ children: /* @__PURE__ */ t(
147
+ k,
148
+ {
149
+ rowKey: (e) => e.key || `${e.from_key}|${e.type}|${e.to_key}`,
150
+ size: "small",
151
+ columns: M,
152
+ dataSource: x,
153
+ pagination: !1,
154
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无关系边" }) }
155
+ }
156
+ )
157
+ },
158
+ {
159
+ key: "individuals",
160
+ label: `实例(${y.length})`,
161
+ children: /* @__PURE__ */ r(q, { children: [
162
+ /* @__PURE__ */ t("div", { style: { marginBottom: 8 }, children: /* @__PURE__ */ t(
163
+ N.Search,
164
+ {
165
+ allowClear: !0,
166
+ style: { width: 320 },
167
+ placeholder: "按 key / 标签 / 属性搜索实例",
168
+ value: f,
169
+ onChange: (e) => D(e.target.value)
170
+ }
171
+ ) }),
172
+ /* @__PURE__ */ t(
173
+ k,
174
+ {
175
+ rowKey: "key",
176
+ size: "small",
177
+ columns: S,
178
+ dataSource: B,
179
+ pagination: { pageSize: 20, showSizeChanger: !0, showTotal: (e) => `共 ${e} 条` },
180
+ locale: { emptyText: /* @__PURE__ */ t("span", { className: "empty-note", children: "暂无实例" }) }
181
+ }
182
+ )
183
+ ] })
184
+ }
185
+ ]
186
+ }
187
+ ) })
188
+ ] }) : /* @__PURE__ */ t(H, { description: "缺少本体 ID(?id=xxx)", style: { padding: 48 } });
189
+ }
190
+ export {
191
+ oe as default
192
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("react"),w=require("react-router-dom"),a=require("antd"),f=require("@ant-design/icons"),d=require("./api-D5Hgcud4.cjs");require("@antv/g6");require("d3-force");function M(){const[C]=w.useSearchParams(),i=C.get("id")||"",I=w.useNavigate(),[j,b]=r.useState("default"),[l,N]=r.useState(null),[m,_]=r.useState([]),[y,T]=r.useState([]),[k,$]=r.useState([]),[O,v]=r.useState(!1),[h,z]=r.useState(""),c=r.useRef(0),g=async(e=j)=>{if(!i)return;const s=++c.current;v(!0);const o=(n,u)=>a.message.error(`${n}取数失败:${u.message}`),x=[["统计",()=>d.ontologyApi.stats(i,e).then(n=>N(n))],["类列表",()=>d.ontologyApi.listClasses(i,e).then(n=>_(n||[]))],["实例列表",()=>d.ontologyApi.listIndividuals(i,e).then(n=>T(n||[]))]];for(const[n,u]of x){if(s!==c.current)return;try{await u()}catch(p){s===c.current&&o(n,p)}}try{const u=((m.length?m:await d.ontologyApi.listClasses(i,e))||[]).map(L=>L.key),p=await d.ontologyApi.subgraph(i,u,1,e);s===c.current&&$((p==null?void 0:p.edges)||[])}catch(n){s===c.current&&o("关系",n)}s===c.current&&v(!1)};r.useEffect(()=>(i&&(b("default"),g("default")),()=>{c.current+=1}),[i]);const q=r.useMemo(()=>l?[{label:"类节点",value:l.class_nodes??l.classNodes??0,sub:"classes"},{label:"实例节点",value:l.individual_nodes??l.individualNodes??0,sub:"individuals"},{label:"总节点",value:l.node_count??l.nodeCount??0,sub:"nodes"},{label:"关系边",value:l.edge_count??l.edgeCount??0,sub:"edges"},{label:"显式陈述",value:l.explicit_statements??l.explicitStatements??0,sub:"explicit"},{label:"推理陈述",value:l.inferred_statements??l.inferredStatements??0,sub:"inferred"}]:[],[l]),S=[{title:"key",dataIndex:"key",key:"key",width:240},{title:"标签",dataIndex:"labels",key:"labels",width:220,render:e=>(e||[]).map(s=>t.jsx(a.Tag,{color:s==="OntologyClass"?"purple":s==="OntologyIndividual"?"blue":void 0,children:s},s))},{title:"属性",dataIndex:"properties",key:"properties",render:e=>t.jsxs(a.Space,{size:4,wrap:!0,children:[Object.entries(e||{}).slice(0,8).map(([s,o])=>t.jsxs(a.Tag,{color:"default",children:[s,"=",String(o)]},s)),Object.keys(e||{}).length>8?t.jsxs(a.Tag,{children:["+",Object.keys(e).length-8]}):null]})}],A=[{title:"from",dataIndex:"from_key",key:"from_key",width:220},{title:"type",dataIndex:"type",key:"type",width:160,render:e=>t.jsx(a.Tag,{color:"geekblue",children:e})},{title:"to",dataIndex:"to_key",key:"to_key",width:220},{title:"属性",dataIndex:"properties",key:"properties",render:e=>t.jsx(a.Space,{size:4,wrap:!0,children:Object.entries(e||{}).slice(0,4).map(([s,o])=>t.jsxs(a.Tag,{color:"default",children:[s,"=",String(o)]},s))})}],R=r.useMemo(()=>{const e=h.trim().toLowerCase();return e?(y||[]).filter(s=>s.key.toLowerCase().includes(e)||(s.labels||[]).some(o=>o.toLowerCase().includes(e))||Object.entries(s.properties||{}).some(([o,x])=>`${o}=${x}`.toLowerCase().includes(e))):y},[y,h]);return i?t.jsxs("div",{className:"view",children:[t.jsxs("div",{className:"view-bar",children:[t.jsxs(a.Tag,{icon:t.jsx(f.ApartmentOutlined,{}),color:"purple",children:["本体 ",i]}),t.jsx(a.Input.Search,{style:{width:200},placeholder:"工作空间(默认 default)",value:j,onChange:e=>b(e.target.value),onSearch:()=>g()}),t.jsx(a.Button,{icon:t.jsx(f.ReloadOutlined,{}),onClick:()=>g(),children:"刷新"}),t.jsx(a.Button,{type:"primary",icon:t.jsx(f.NodeIndexOutlined,{}),onClick:()=>I(`/ontology/nodes?id=${encodeURIComponent(i)}`),children:"图谱"}),t.jsx("span",{className:"hint spacer"}),t.jsx("span",{className:"hint",children:d.field(l,"lastMaterializedAt","last_materialized_at")?`物化于 ${new Date(d.field(l,"lastMaterializedAt","last_materialized_at")).toLocaleString()}`:""})]}),l?t.jsx("div",{className:"stat-cards",children:q.map(e=>t.jsxs("div",{className:"stat-card",children:[t.jsx("span",{className:"label",children:e.label}),t.jsx("span",{className:"value",children:e.value}),t.jsx("span",{className:"sub",children:e.sub})]},e.label))}):null,t.jsx(a.Spin,{spinning:O,children:t.jsx(a.Tabs,{items:[{key:"classes",label:`类定义(${m.length})`,children:t.jsx(a.Table,{rowKey:"key",size:"small",columns:S,dataSource:m,pagination:!1,locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无类定义(可先登记 schema 或物化)"})}})},{key:"edges",label:`关系(${k.length})`,children:t.jsx(a.Table,{rowKey:e=>e.key||`${e.from_key}|${e.type}|${e.to_key}`,size:"small",columns:A,dataSource:k,pagination:!1,locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无关系边"})}})},{key:"individuals",label:`实例(${y.length})`,children:t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:8},children:t.jsx(a.Input.Search,{allowClear:!0,style:{width:320},placeholder:"按 key / 标签 / 属性搜索实例",value:h,onChange:e=>z(e.target.value)})}),t.jsx(a.Table,{rowKey:"key",size:"small",columns:S,dataSource:R,pagination:{pageSize:20,showSizeChanger:!0,showTotal:e=>`共 ${e} 条`},locale:{emptyText:t.jsx("span",{className:"empty-note",children:"暂无实例"})}})]})}]})})]}):t.jsx(a.Empty,{description:"缺少本体 ID(?id=xxx)",style:{padding:48}})}exports.default=M;
@@ -0,0 +1,114 @@
1
+ import { jsx as e, jsxs as l, Fragment as I } from "react/jsx-runtime";
2
+ import { useState as d } from "react";
3
+ import { useSearchParams as S } from "react-router-dom";
4
+ import { Alert as T, Spin as j, Card as s, Space as o, Input as v, Button as z, Table as y, message as $, Tag as a } from "antd";
5
+ import { ThunderboltOutlined as C } from "@ant-design/icons";
6
+ import { f as r, o as B } from "./api-BVrIcAFp.js";
7
+ import { parseSnapshot as A } from "./OntologyValidatePage-WX4sAfzY.js";
8
+ const { TextArea: O } = v;
9
+ function q() {
10
+ const [g] = S(), c = g.get("id") || "", [m, f] = d(
11
+ `{
12
+ "individuals": [],
13
+ "statements": []
14
+ }`
15
+ ), [n, p] = d(null), [x, h] = d(!1), b = async () => {
16
+ h(!0), p(null);
17
+ try {
18
+ p(await B.infer(c, A(m)));
19
+ } catch (t) {
20
+ $.error(t.message);
21
+ } finally {
22
+ h(!1);
23
+ }
24
+ };
25
+ if (!c)
26
+ return /* @__PURE__ */ e(T, { type: "warning", message: "缺少本体 ID(?id=xxx)" });
27
+ const w = [
28
+ { title: "主体", dataIndex: "subject", key: "subject", width: 180 },
29
+ { title: "谓词", dataIndex: "predicate", key: "predicate", width: 160 },
30
+ { title: "客体", dataIndex: "object", key: "object", width: 180 },
31
+ {
32
+ title: "性质",
33
+ key: "nature",
34
+ width: 140,
35
+ render: (t, i) => /* @__PURE__ */ l(o, { size: 4, children: [
36
+ i.inferred ? /* @__PURE__ */ e(a, { color: "blue", children: "推理" }) : /* @__PURE__ */ e(a, { children: "显式" }),
37
+ i.literal ? /* @__PURE__ */ e(a, { color: "orange", children: "字面量" }) : null
38
+ ] })
39
+ }
40
+ ], k = [
41
+ { title: "key", dataIndex: "key", key: "key", width: 200 },
42
+ { title: "名称", dataIndex: "name", key: "name", width: 160 },
43
+ {
44
+ title: "显式类型",
45
+ dataIndex: "types",
46
+ key: "types",
47
+ width: 200,
48
+ render: (t) => (t || []).map((i) => /* @__PURE__ */ e(a, { children: i }, i))
49
+ },
50
+ {
51
+ title: "推理类型",
52
+ dataIndex: "inferredTypes",
53
+ key: "inferredTypes",
54
+ render: (t, i) => (r(i, "inferredTypes") || []).map((u) => /* @__PURE__ */ e(a, { color: "blue", children: u }, u))
55
+ }
56
+ ];
57
+ return /* @__PURE__ */ l(j, { spinning: x, children: [
58
+ /* @__PURE__ */ e(s, { size: "small", title: "推理输入(OntologySnapshot)", style: { marginBottom: 16 }, children: /* @__PURE__ */ l(o, { direction: "vertical", style: { width: "100%" }, children: [
59
+ /* @__PURE__ */ e(
60
+ O,
61
+ {
62
+ rows: 10,
63
+ value: m,
64
+ onChange: (t) => f(t.target.value),
65
+ placeholder: '{"individuals": [], "statements": []}'
66
+ }
67
+ ),
68
+ /* @__PURE__ */ e(z, { type: "primary", icon: /* @__PURE__ */ e(C, {}), onClick: b, children: "开始推理" })
69
+ ] }) }),
70
+ n ? /* @__PURE__ */ l(I, { children: [
71
+ /* @__PURE__ */ e(s, { size: "small", title: "推理概览", style: { marginBottom: 16 }, children: /* @__PURE__ */ l(o, { size: "large", wrap: !0, children: [
72
+ /* @__PURE__ */ l("span", { children: [
73
+ "显式陈述 ",
74
+ /* @__PURE__ */ e("b", { children: r(n, "explicitStatements") })
75
+ ] }),
76
+ /* @__PURE__ */ l("span", { children: [
77
+ "推理陈述 ",
78
+ /* @__PURE__ */ e("b", { children: r(n, "inferredStatements") })
79
+ ] }),
80
+ /* @__PURE__ */ l("span", { children: [
81
+ "显式类型 ",
82
+ /* @__PURE__ */ e("b", { children: r(n, "explicitTypes") })
83
+ ] }),
84
+ /* @__PURE__ */ l("span", { children: [
85
+ "推理类型 ",
86
+ /* @__PURE__ */ e("b", { children: r(n, "inferredTypes") })
87
+ ] })
88
+ ] }) }),
89
+ /* @__PURE__ */ e(s, { size: "small", title: `个体(${(n.individuals || []).length})`, style: { marginBottom: 16 }, children: /* @__PURE__ */ e(
90
+ y,
91
+ {
92
+ rowKey: "key",
93
+ size: "small",
94
+ columns: k,
95
+ dataSource: n.individuals || [],
96
+ pagination: !1
97
+ }
98
+ ) }),
99
+ /* @__PURE__ */ e(s, { size: "small", title: `陈述(${(n.statements || []).length})`, children: /* @__PURE__ */ e(
100
+ y,
101
+ {
102
+ rowKey: (t, i) => `${t.subject}-${t.predicate}-${t.object}-${i}`,
103
+ size: "small",
104
+ columns: w,
105
+ dataSource: n.statements || [],
106
+ pagination: !1
107
+ }
108
+ ) })
109
+ ] }) : null
110
+ ] });
111
+ }
112
+ export {
113
+ q as default
114
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("react-router-dom"),t=require("antd"),f=require("@ant-design/icons"),a=require("./api-D5Hgcud4.cjs"),b=require("./OntologyValidatePage-Dqzp4hWg.cjs"),{TextArea:S}=t.Input;function T(){const[h]=g.useSearchParams(),r=h.get("id")||"",[d,x]=l.useState(`{
2
+ "individuals": [],
3
+ "statements": []
4
+ }`),[n,o]=l.useState(null),[p,c]=l.useState(!1),y=async()=>{c(!0),o(null);try{o(await a.ontologyApi.infer(r,b.parseSnapshot(d)))}catch(s){t.message.error(s.message)}finally{c(!1)}};if(!r)return e.jsx(t.Alert,{type:"warning",message:"缺少本体 ID(?id=xxx)"});const m=[{title:"主体",dataIndex:"subject",key:"subject",width:180},{title:"谓词",dataIndex:"predicate",key:"predicate",width:160},{title:"客体",dataIndex:"object",key:"object",width:180},{title:"性质",key:"nature",width:140,render:(s,i)=>e.jsxs(t.Space,{size:4,children:[i.inferred?e.jsx(t.Tag,{color:"blue",children:"推理"}):e.jsx(t.Tag,{children:"显式"}),i.literal?e.jsx(t.Tag,{color:"orange",children:"字面量"}):null]})}],j=[{title:"key",dataIndex:"key",key:"key",width:200},{title:"名称",dataIndex:"name",key:"name",width:160},{title:"显式类型",dataIndex:"types",key:"types",width:200,render:s=>(s||[]).map(i=>e.jsx(t.Tag,{children:i},i))},{title:"推理类型",dataIndex:"inferredTypes",key:"inferredTypes",render:(s,i)=>(a.field(i,"inferredTypes")||[]).map(u=>e.jsx(t.Tag,{color:"blue",children:u},u))}];return e.jsxs(t.Spin,{spinning:p,children:[e.jsx(t.Card,{size:"small",title:"推理输入(OntologySnapshot)",style:{marginBottom:16},children:e.jsxs(t.Space,{direction:"vertical",style:{width:"100%"},children:[e.jsx(S,{rows:10,value:d,onChange:s=>x(s.target.value),placeholder:'{"individuals": [], "statements": []}'}),e.jsx(t.Button,{type:"primary",icon:e.jsx(f.ThunderboltOutlined,{}),onClick:y,children:"开始推理"})]})}),n?e.jsxs(e.Fragment,{children:[e.jsx(t.Card,{size:"small",title:"推理概览",style:{marginBottom:16},children:e.jsxs(t.Space,{size:"large",wrap:!0,children:[e.jsxs("span",{children:["显式陈述 ",e.jsx("b",{children:a.field(n,"explicitStatements")})]}),e.jsxs("span",{children:["推理陈述 ",e.jsx("b",{children:a.field(n,"inferredStatements")})]}),e.jsxs("span",{children:["显式类型 ",e.jsx("b",{children:a.field(n,"explicitTypes")})]}),e.jsxs("span",{children:["推理类型 ",e.jsx("b",{children:a.field(n,"inferredTypes")})]})]})}),e.jsx(t.Card,{size:"small",title:`个体(${(n.individuals||[]).length})`,style:{marginBottom:16},children:e.jsx(t.Table,{rowKey:"key",size:"small",columns:j,dataSource:n.individuals||[],pagination:!1})}),e.jsx(t.Card,{size:"small",title:`陈述(${(n.statements||[]).length})`,children:e.jsx(t.Table,{rowKey:(s,i)=>`${s.subject}-${s.predicate}-${s.object}-${i}`,size:"small",columns:m,dataSource:n.statements||[],pagination:!1})})]}):null]})}exports.default=T;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),k=require("react-router-dom"),s=require("antd"),g=require("@ant-design/icons"),m=require("./api-D5Hgcud4.cjs"),{TextArea:p}=s.Input;function v(){const i=k.useNavigate(),[o,l]=r.useState([]),[y,h]=r.useState(!1),[j,c]=r.useState(!1),[f,x]=r.useState(!1),[d]=s.Form.useForm(),a=async()=>{h(!0);try{l(await m.ontologyApi.listSchemas())}catch(t){s.message.error(t.message)}finally{h(!1)}};r.useEffect(()=>{a()},[]);const w=async()=>{const t=await d.validateFields();x(!0);try{const n={id:t.id,name:t.name,version:t.version||"1.0.0",description:t.description||"",prefixes:t.prefixes?u(t.prefixes,"前缀"):{},classes:t.classes?u(t.classes,"类定义"):[],properties:t.properties?u(t.properties,"属性定义"):[]};await m.ontologyApi.registerSchema(n),s.message.success(`本体 ${n.id} 已登记`),c(!1),d.resetFields(),await a()}catch(n){s.message.error(n.message)}finally{x(!1)}},I=async t=>{try{await m.ontologyApi.deleteSchema(t),s.message.success(`本体 ${t} 已删除`),await a()}catch(n){s.message.error(n.message)}},S=[{title:"本体 ID",dataIndex:"id",key:"id",width:180},{title:"名称",dataIndex:"name",key:"name",width:160},{title:"版本",dataIndex:"version",key:"version",width:90,render:t=>e.jsx(s.Tag,{children:t})},{title:"类数",key:"classes",width:80,render:(t,n)=>(n.classes||[]).length},{title:"属性数",key:"properties",width:80,render:(t,n)=>(n.properties||[]).length},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0},{title:"操作",key:"op",width:170,render:(t,n)=>e.jsxs(s.Space,{size:"small",children:[e.jsx(s.Button,{size:"small",type:"link",onClick:()=>i(`/ontology/detail?id=${encodeURIComponent(n.id)}`),children:"详情"}),e.jsx(s.Button,{size:"small",type:"link",onClick:()=>i(`/ontology/nodes?id=${encodeURIComponent(n.id)}`),children:"图谱"}),e.jsx(s.Popconfirm,{title:`删除本体 ${n.id}?`,onConfirm:()=>I(n.id),children:e.jsx(s.Button,{size:"small",type:"link",danger:!0,children:"删除"})})]})}];return e.jsxs("div",{children:[e.jsxs(s.Space,{style:{marginBottom:12},children:[e.jsx(s.Button,{type:"primary",icon:e.jsx(g.PlusOutlined,{}),onClick:()=>c(!0),children:"登记本体"}),e.jsx(s.Button,{icon:e.jsx(g.ReloadOutlined,{}),onClick:a,children:"刷新"}),e.jsxs("span",{style:{color:"#999",fontSize:12},children:["共 ",o.length," 个本体"]})]}),e.jsx(s.Table,{rowKey:"id",size:"small",columns:S,dataSource:o,loading:y,pagination:!1}),e.jsx(s.Modal,{title:"登记本体 Schema",open:j,onCancel:()=>c(!1),onOk:w,confirmLoading:f,width:720,destroyOnClose:!0,children:e.jsxs(s.Form,{form:d,layout:"vertical",initialValues:{version:"1.0.0"},children:[e.jsx(s.Form.Item,{name:"id",label:"本体 ID",rules:[{required:!0,message:"必填"}],children:e.jsx(s.Input,{placeholder:"如 core-ontology"})}),e.jsx(s.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:e.jsx(s.Input,{placeholder:"如 核心本体"})}),e.jsx(s.Form.Item,{name:"version",label:"版本",children:e.jsx(s.Input,{placeholder:"1.0.0"})}),e.jsx(s.Form.Item,{name:"description",label:"描述",children:e.jsx(s.Input,{placeholder:"这个本体管什么"})}),e.jsx(s.Form.Item,{name:"prefixes",label:"前缀映射(JSON)",children:e.jsx(p,{rows:2,placeholder:'{"ex": "http://example.org/"}'})}),e.jsx(s.Form.Item,{name:"classes",label:"类定义(JSON 数组)",children:e.jsx(p,{rows:4,placeholder:'[{"name":"Person","label":"人"}]'})}),e.jsx(s.Form.Item,{name:"properties",label:"属性定义(JSON 数组)",children:e.jsx(p,{rows:4,placeholder:'[{"name":"knows","kind":"OBJECT"}]'})})]})})]})}function u(i,o){try{return JSON.parse(i)}catch(l){throw new Error(`${o} 不是合法 JSON:${l.message}`)}}exports.default=v;
@@ -0,0 +1,118 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as J } from "react";
3
+ import { useNavigate as $ } from "react-router-dom";
4
+ import { Form as s, Space as I, Button as l, Table as z, Modal as N, Input as a, message as n, Tag as F, Popconfirm as P } from "antd";
5
+ import { PlusOutlined as R, ReloadOutlined as T } from "@ant-design/icons";
6
+ import { o as y } from "./api-BVrIcAFp.js";
7
+ const { TextArea: f } = a;
8
+ function A() {
9
+ const o = $(), [c, p] = m([]), [v, w] = m(!1), [x, h] = m(!1), [S, k] = m(!1), [u] = s.useForm(), d = async () => {
10
+ w(!0);
11
+ try {
12
+ p(await y.listSchemas());
13
+ } catch (t) {
14
+ n.error(t.message);
15
+ } finally {
16
+ w(!1);
17
+ }
18
+ };
19
+ J(() => {
20
+ d();
21
+ }, []);
22
+ const O = async () => {
23
+ const t = await u.validateFields();
24
+ k(!0);
25
+ try {
26
+ const i = {
27
+ id: t.id,
28
+ name: t.name,
29
+ version: t.version || "1.0.0",
30
+ description: t.description || "",
31
+ prefixes: t.prefixes ? g(t.prefixes, "前缀") : {},
32
+ classes: t.classes ? g(t.classes, "类定义") : [],
33
+ properties: t.properties ? g(t.properties, "属性定义") : []
34
+ };
35
+ await y.registerSchema(i), n.success(`本体 ${i.id} 已登记`), h(!1), u.resetFields(), await d();
36
+ } catch (i) {
37
+ n.error(i.message);
38
+ } finally {
39
+ k(!1);
40
+ }
41
+ }, b = async (t) => {
42
+ try {
43
+ await y.deleteSchema(t), n.success(`本体 ${t} 已删除`), await d();
44
+ } catch (i) {
45
+ n.error(i.message);
46
+ }
47
+ }, C = [
48
+ { title: "本体 ID", dataIndex: "id", key: "id", width: 180 },
49
+ { title: "名称", dataIndex: "name", key: "name", width: 160 },
50
+ { title: "版本", dataIndex: "version", key: "version", width: 90, render: (t) => /* @__PURE__ */ e(F, { children: t }) },
51
+ { title: "类数", key: "classes", width: 80, render: (t, i) => (i.classes || []).length },
52
+ { title: "属性数", key: "properties", width: 80, render: (t, i) => (i.properties || []).length },
53
+ { title: "描述", dataIndex: "description", key: "description", ellipsis: !0 },
54
+ {
55
+ title: "操作",
56
+ key: "op",
57
+ width: 170,
58
+ render: (t, i) => /* @__PURE__ */ r(I, { size: "small", children: [
59
+ /* @__PURE__ */ e(l, { size: "small", type: "link", onClick: () => o(`/ontology/detail?id=${encodeURIComponent(i.id)}`), children: "详情" }),
60
+ /* @__PURE__ */ e(l, { size: "small", type: "link", onClick: () => o(`/ontology/nodes?id=${encodeURIComponent(i.id)}`), children: "图谱" }),
61
+ /* @__PURE__ */ e(P, { title: `删除本体 ${i.id}?`, onConfirm: () => b(i.id), children: /* @__PURE__ */ e(l, { size: "small", type: "link", danger: !0, children: "删除" }) })
62
+ ] })
63
+ }
64
+ ];
65
+ return /* @__PURE__ */ r("div", { children: [
66
+ /* @__PURE__ */ r(I, { style: { marginBottom: 12 }, children: [
67
+ /* @__PURE__ */ e(l, { type: "primary", icon: /* @__PURE__ */ e(R, {}), onClick: () => h(!0), children: "登记本体" }),
68
+ /* @__PURE__ */ e(l, { icon: /* @__PURE__ */ e(T, {}), onClick: d, children: "刷新" }),
69
+ /* @__PURE__ */ r("span", { style: { color: "#999", fontSize: 12 }, children: [
70
+ "共 ",
71
+ c.length,
72
+ " 个本体"
73
+ ] })
74
+ ] }),
75
+ /* @__PURE__ */ e(
76
+ z,
77
+ {
78
+ rowKey: "id",
79
+ size: "small",
80
+ columns: C,
81
+ dataSource: c,
82
+ loading: v,
83
+ pagination: !1
84
+ }
85
+ ),
86
+ /* @__PURE__ */ e(
87
+ N,
88
+ {
89
+ title: "登记本体 Schema",
90
+ open: x,
91
+ onCancel: () => h(!1),
92
+ onOk: O,
93
+ confirmLoading: S,
94
+ width: 720,
95
+ destroyOnClose: !0,
96
+ children: /* @__PURE__ */ r(s, { form: u, layout: "vertical", initialValues: { version: "1.0.0" }, children: [
97
+ /* @__PURE__ */ e(s.Item, { name: "id", label: "本体 ID", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(a, { placeholder: "如 core-ontology" }) }),
98
+ /* @__PURE__ */ e(s.Item, { name: "name", label: "名称", rules: [{ required: !0, message: "必填" }], children: /* @__PURE__ */ e(a, { placeholder: "如 核心本体" }) }),
99
+ /* @__PURE__ */ e(s.Item, { name: "version", label: "版本", children: /* @__PURE__ */ e(a, { placeholder: "1.0.0" }) }),
100
+ /* @__PURE__ */ e(s.Item, { name: "description", label: "描述", children: /* @__PURE__ */ e(a, { placeholder: "这个本体管什么" }) }),
101
+ /* @__PURE__ */ e(s.Item, { name: "prefixes", label: "前缀映射(JSON)", children: /* @__PURE__ */ e(f, { rows: 2, placeholder: '{"ex": "http://example.org/"}' }) }),
102
+ /* @__PURE__ */ e(s.Item, { name: "classes", label: "类定义(JSON 数组)", children: /* @__PURE__ */ e(f, { rows: 4, placeholder: '[{"name":"Person","label":"人"}]' }) }),
103
+ /* @__PURE__ */ e(s.Item, { name: "properties", label: "属性定义(JSON 数组)", children: /* @__PURE__ */ e(f, { rows: 4, placeholder: '[{"name":"knows","kind":"OBJECT"}]' }) })
104
+ ] })
105
+ }
106
+ )
107
+ ] });
108
+ }
109
+ function g(o, c) {
110
+ try {
111
+ return JSON.parse(o);
112
+ } catch (p) {
113
+ throw new Error(`${c} 不是合法 JSON:${p.message}`);
114
+ }
115
+ }
116
+ export {
117
+ A as default
118
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),D=require("react-router-dom"),s=require("antd"),z=require("@ant-design/icons"),l=require("./api-D5Hgcud4.cjs"),C=require("./OntologyValidatePage-Dqzp4hWg.cjs"),{TextArea:q}=s.Input;function R(){var x;const[j]=D.useSearchParams(),r=j.get("id")||"",[a,f]=n.useState("source"),[c,y]=n.useState("default"),[o,u]=n.useState(""),[p,S]=n.useState(`{
2
+ "individuals": [],
3
+ "statements": []
4
+ }`),[v,h]=n.useState([]),[i,d]=n.useState(null),[b,m]=n.useState(!1);n.useEffect(()=>{r&&l.ontologyApi.listSources().then(h).catch(()=>h([]))},[r]);const I=async()=>{m(!0),d(null);try{if(a==="source"){if(!o.trim()){s.message.warning("按来源物化需要指定 source");return}d(await l.ontologyApi.materialize(r,o.trim(),c))}else d(await l.ontologyApi.materializeInline(r,C.parseSnapshot(p),c))}catch(t){s.message.error(t.message)}finally{m(!1)}};if(!r)return e.jsx(s.Alert,{type:"warning",message:"缺少本体 ID(?id=xxx)"});const g=((x=i==null?void 0:i.validation)==null?void 0:x.issues)||[];return e.jsxs(s.Spin,{spinning:b,children:[e.jsx(s.Card,{size:"small",title:"物化输入",style:{marginBottom:16},children:e.jsxs(s.Space,{direction:"vertical",style:{width:"100%"},size:12,children:[e.jsxs(s.Space,{wrap:!0,children:[e.jsx(s.Select,{style:{width:200},value:a,onChange:f,options:[{value:"source",label:"按来源物化"},{value:"inline",label:"内联快照物化"}]}),e.jsx(s.Input,{style:{width:220},placeholder:"工作空间",value:c,onChange:t=>y(t.target.value)}),a==="source"?e.jsx(s.Select,{style:{width:280},placeholder:"选择数据源",value:o||void 0,onChange:u,showSearch:!0,options:v.map(t=>({value:t.id,label:t.description?`${t.id} — ${t.description}`:t.id})),notFoundContent:null}):null,e.jsx(s.Button,{type:"primary",icon:e.jsx(z.DatabaseOutlined,{}),onClick:I,children:"执行物化"})]}),a==="source"?e.jsx(s.Input,{style:{width:420},placeholder:"source ID(可直接输入)",value:o,onChange:t=>u(t.target.value)}):e.jsx(q,{rows:10,value:p,onChange:t=>S(t.target.value),placeholder:'{"individuals": [], "statements": []}'})]})}),i?e.jsxs(s.Card,{size:"small",title:"物化报告",children:[e.jsxs(s.Descriptions,{bordered:!0,size:"small",column:2,style:{marginBottom:12},children:[e.jsx(s.Descriptions.Item,{label:"本体",children:l.field(i,"ontologyId")}),e.jsx(s.Descriptions.Item,{label:"工作空间",children:l.field(i,"workspace")}),e.jsx(s.Descriptions.Item,{label:"来源",children:l.field(i,"sourceId")||"(内联)"}),e.jsxs(s.Descriptions.Item,{label:"耗时",children:[l.field(i,"durationMs")," ms"]}),e.jsx(s.Descriptions.Item,{label:"类节点",children:l.field(i,"classNodes")}),e.jsx(s.Descriptions.Item,{label:"实例节点",children:l.field(i,"individualNodes")}),e.jsx(s.Descriptions.Item,{label:"边",children:l.field(i,"edges")}),e.jsx(s.Descriptions.Item,{label:"物化时间",children:l.field(i,"materializedAt")||"—"})]}),e.jsxs(s.Space,{size:"large",wrap:!0,style:{marginBottom:8},children:[e.jsxs("span",{children:["显式陈述 ",e.jsx("b",{children:l.field(i,"explicitStatements")})]}),e.jsxs("span",{children:["推理陈述 ",e.jsx("b",{children:l.field(i,"inferredStatements")})]})]}),g.length?e.jsx("div",{children:g.map((t,w)=>e.jsxs(s.Tag,{color:t.severity==="ERROR"?"red":"orange",children:[t.code," ",t.message]},w))}):e.jsx(s.Tag,{color:"green",children:"物化通过,无校验问题"})]}):null]})}exports.default=R;