@trustgraph/react-state 1.2.1 → 1.3.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/dist/index.cjs CHANGED
@@ -697,36 +697,36 @@ const createDocId = () => {
697
697
  const prepareMetadata = (doc_id, params) => {
698
698
  let doc_meta = [
699
699
  {
700
- s: { v: doc_id, e: true },
701
- p: { v: RDF_TYPE, e: true },
702
- o: { v: DIGITAL_DOCUMENT, e: true },
700
+ s: { t: "i", i: doc_id },
701
+ p: { t: "i", i: RDF_TYPE },
702
+ o: { t: "i", i: DIGITAL_DOCUMENT },
703
703
  },
704
704
  ];
705
705
  if (params.title != "")
706
706
  doc_meta = [
707
707
  ...doc_meta,
708
708
  {
709
- s: { v: doc_id, e: true },
710
- p: { v: RDFS_LABEL$1, e: true },
711
- o: { v: params.title, e: false },
709
+ s: { t: "i", i: doc_id },
710
+ p: { t: "i", i: RDFS_LABEL$1 },
711
+ o: { t: "l", v: params.title ?? "" },
712
712
  },
713
713
  ];
714
714
  if (params.url != "")
715
715
  doc_meta = [
716
716
  ...doc_meta,
717
717
  {
718
- s: { v: doc_id, e: true },
719
- p: { v: SCHEMA_URL, e: true },
720
- o: { v: params.url, e: true },
718
+ s: { t: "i", i: doc_id },
719
+ p: { t: "i", i: SCHEMA_URL },
720
+ o: { t: "i", i: params.url ?? "" },
721
721
  },
722
722
  ];
723
- for (const keyword of params.keywords)
723
+ for (const keyword of params.keywords ?? [])
724
724
  doc_meta = [
725
725
  ...doc_meta,
726
726
  {
727
- s: { v: doc_id, e: true },
728
- p: { v: SCHEMA_KEYWORDS, e: true },
729
- o: { v: keyword, e: false },
727
+ s: { t: "i", i: doc_id },
728
+ p: { t: "i", i: SCHEMA_KEYWORDS },
729
+ o: { t: "l", v: keyword },
730
730
  },
731
731
  ];
732
732
  return doc_meta;
@@ -970,6 +970,18 @@ const useTriples = ({ flow, s, p, o, limit, collection }) => {
970
970
  };
971
971
  };
972
972
 
973
+ // Helper to get the string value from a Term (IRI or Literal)
974
+ const getTermValue$2 = (term) => {
975
+ if (term.t === "i")
976
+ return term.i;
977
+ if (term.t === "l")
978
+ return term.v;
979
+ if (term.t === "b")
980
+ return term.d;
981
+ return "";
982
+ };
983
+ // Helper to check if a Term is an IRI
984
+ const isIri$2 = (term) => term.t === "i";
973
985
  const RDFS_LABEL = "http://www.w3.org/2000/01/rdf-schema#label";
974
986
  const SKOS_DEFINITION = "http://www.w3.org/2004/02/skos/core#definition";
975
987
  const SCHEMAORG_SUBJECT_OF = "https://schema.org/subjectOf";
@@ -1001,7 +1013,7 @@ const queryS = (socket, uri, add, remove, limit, collection) => {
1001
1013
  const act = "Query S: " + uri;
1002
1014
  add(act);
1003
1015
  return socket
1004
- .triplesQuery({ v: uri, e: true }, undefined, undefined, limit ? limit : LIMIT, collection)
1016
+ .triplesQuery({ t: "i", i: uri }, undefined, undefined, limit ? limit : LIMIT, collection)
1005
1017
  .then((x) => {
1006
1018
  remove(act);
1007
1019
  return x;
@@ -1016,7 +1028,7 @@ const queryP = (socket, uri, add, remove, limit, collection) => {
1016
1028
  const act = "Query P: " + uri;
1017
1029
  add(act);
1018
1030
  return socket
1019
- .triplesQuery(undefined, { v: uri, e: true }, undefined, limit ? limit : LIMIT, collection)
1031
+ .triplesQuery(undefined, { t: "i", i: uri }, undefined, limit ? limit : LIMIT, collection)
1020
1032
  .then((x) => {
1021
1033
  remove(act);
1022
1034
  return x;
@@ -1031,7 +1043,7 @@ const queryO = (socket, uri, add, remove, limit, collection) => {
1031
1043
  const act = "Query O: " + uri;
1032
1044
  add(act);
1033
1045
  return socket
1034
- .triplesQuery(undefined, undefined, { v: uri, e: true }, limit ? limit : LIMIT, collection)
1046
+ .triplesQuery(undefined, undefined, { t: "i", i: uri }, limit ? limit : LIMIT, collection)
1035
1047
  .then((x) => {
1036
1048
  remove(act);
1037
1049
  return x;
@@ -1073,12 +1085,12 @@ const queryLabel = (socket, uri, add, remove, collection) => {
1073
1085
  add(act);
1074
1086
  // Search tthe graph for the URI->label relationship
1075
1087
  return socket
1076
- .triplesQuery({ v: uri, e: true }, { v: RDFS_LABEL, e: true }, undefined, 1, collection)
1088
+ .triplesQuery({ t: "i", i: uri }, { t: "i", i: RDFS_LABEL }, undefined, 1, collection)
1077
1089
  .then((triples) => {
1078
1090
  // If got a result, return the label, otherwise the URI
1079
1091
  // can be its own label
1080
1092
  if (triples.length > 0)
1081
- return triples[0].o.v;
1093
+ return getTermValue$2(triples[0].o);
1082
1094
  else
1083
1095
  return uri;
1084
1096
  })
@@ -1095,7 +1107,7 @@ const queryLabel = (socket, uri, add, remove, collection) => {
1095
1107
  // Returns a promise
1096
1108
  const labelS = (socket, triples, add, remove, collection) => {
1097
1109
  return Promise.all(triples.map((t) => {
1098
- return queryLabel(socket, t.s.v, add, remove, collection).then((label) => {
1110
+ return queryLabel(socket, getTermValue$2(t.s), add, remove, collection).then((label) => {
1099
1111
  return {
1100
1112
  ...t,
1101
1113
  s: {
@@ -1110,7 +1122,7 @@ const labelS = (socket, triples, add, remove, collection) => {
1110
1122
  // Returns a promise
1111
1123
  const labelP = (socket, triples, add, remove, collection) => {
1112
1124
  return Promise.all(triples.map((t) => {
1113
- return queryLabel(socket, t.p.v, add, remove, collection).then((label) => {
1125
+ return queryLabel(socket, getTermValue$2(t.p), add, remove, collection).then((label) => {
1114
1126
  return {
1115
1127
  ...t,
1116
1128
  p: {
@@ -1125,10 +1137,10 @@ const labelP = (socket, triples, add, remove, collection) => {
1125
1137
  // Returns a promise
1126
1138
  const labelO = (socket, triples, add, remove, collection) => {
1127
1139
  return Promise.all(triples.map((t) => {
1128
- // If the 'o' element is a entity, do a label lookup, else
1140
+ // If the 'o' element is an IRI, do a label lookup, else
1129
1141
  // just use the literal value for its label
1130
- if (t.o.e)
1131
- return queryLabel(socket, t.o.v, add, remove, collection).then((label) => {
1142
+ if (isIri$2(t.o))
1143
+ return queryLabel(socket, t.o.i, add, remove, collection).then((label) => {
1132
1144
  return {
1133
1145
  ...t,
1134
1146
  o: {
@@ -1143,7 +1155,7 @@ const labelO = (socket, triples, add, remove, collection) => {
1143
1155
  ...t,
1144
1156
  o: {
1145
1157
  ...t.o,
1146
- label: t.o.v,
1158
+ label: getTermValue$2(t.o),
1147
1159
  },
1148
1160
  });
1149
1161
  });
@@ -1151,7 +1163,7 @@ const labelO = (socket, triples, add, remove, collection) => {
1151
1163
  };
1152
1164
  // Filter out 'structural' edges nobody needs to see
1153
1165
  const filterInternals = (triples) => triples.filter((t) => {
1154
- if (t.p.e && t.p.v == RDFS_LABEL)
1166
+ if (isIri$2(t.p) && t.p.i == RDFS_LABEL)
1155
1167
  return false;
1156
1168
  return true;
1157
1169
  });
@@ -1178,6 +1190,18 @@ const getTriples = (socket, uri, add, remove, limit, collection) => {
1178
1190
 
1179
1191
  // Functionality here helps construct subgraphs for react-force-graph
1180
1192
  // visualisation
1193
+ // Helper to get the string value from a Term (IRI or Literal)
1194
+ const getTermValue$1 = (term) => {
1195
+ if (term.t === "i")
1196
+ return term.i;
1197
+ if (term.t === "l")
1198
+ return term.v;
1199
+ if (term.t === "b")
1200
+ return term.d;
1201
+ return "";
1202
+ };
1203
+ // Helper to check if a Term is an IRI
1204
+ const isIri$1 = (term) => term.t === "i";
1181
1205
  const createSubgraph = () => {
1182
1206
  return {
1183
1207
  nodes: [],
@@ -1191,19 +1215,20 @@ const updateSubgraphTriples = (sg, triples) => {
1191
1215
  for (const t of triples) {
1192
1216
  // Skip triples where the object is a literal (property edges)
1193
1217
  // These are now shown in the node details drawer instead
1194
- if (!t.o.e) {
1218
+ if (!isIri$1(t.o)) {
1195
1219
  continue;
1196
1220
  }
1197
1221
  // Source has a URI, that can be its unique ID
1198
- const sourceId = t.s.v;
1222
+ const sourceId = getTermValue$1(t.s);
1199
1223
  // Target is always an entity now (we filtered out literals above)
1200
- const targetId = t.o.v;
1224
+ const targetId = getTermValue$1(t.o);
1201
1225
  // Links have an ID so that this edge is unique
1202
- const linkId = t.s.v + "@@" + t.p.v + "@@" + t.o.v;
1226
+ const linkId = getTermValue$1(t.s) + "@@" + getTermValue$1(t.p) + "@@" + getTermValue$1(t.o);
1203
1227
  if (!nodeIds.has(sourceId)) {
1228
+ const sLabeled = t.s;
1204
1229
  const n = {
1205
1230
  id: sourceId,
1206
- label: t.s.label ? t.s.label : "unknown",
1231
+ label: sLabeled.label ? sLabeled.label : "unknown",
1207
1232
  group: groupId,
1208
1233
  };
1209
1234
  nodeIds.add(sourceId);
@@ -1213,9 +1238,10 @@ const updateSubgraphTriples = (sg, triples) => {
1213
1238
  };
1214
1239
  }
1215
1240
  if (!nodeIds.has(targetId)) {
1241
+ const oLabeled = t.o;
1216
1242
  const n = {
1217
1243
  id: targetId,
1218
- label: t.o.label ? t.o.label : "unknown",
1244
+ label: oLabeled.label ? oLabeled.label : "unknown",
1219
1245
  group: groupId,
1220
1246
  };
1221
1247
  nodeIds.add(targetId);
@@ -1225,11 +1251,12 @@ const updateSubgraphTriples = (sg, triples) => {
1225
1251
  };
1226
1252
  }
1227
1253
  if (!linkIds.has(linkId)) {
1254
+ const pLabeled = t.p;
1228
1255
  const l = {
1229
1256
  source: sourceId,
1230
1257
  target: targetId,
1231
1258
  id: linkId,
1232
- label: t.p.label ? t.p.label : "unknown",
1259
+ label: pLabeled.label ? pLabeled.label : "unknown",
1233
1260
  value: 1,
1234
1261
  };
1235
1262
  linkIds.add(linkId);
@@ -1254,14 +1281,14 @@ const updateSubgraphByRelationship = (socket, selectedNodeId, relationshipUri, d
1254
1281
  add(activityName);
1255
1282
  // Build the query based on direction
1256
1283
  const queryPromise = direction === "outgoing"
1257
- ? socket.triplesQuery({ v: selectedNodeId, e: true }, // s = selectedNode
1258
- { v: relationshipUri, e: true }, // p = relationship
1284
+ ? socket.triplesQuery({ t: "i", i: selectedNodeId }, // s = selectedNode
1285
+ { t: "i", i: relationshipUri }, // p = relationship
1259
1286
  undefined, // o = ??? (what we want to find)
1260
1287
  20, // Limit results
1261
1288
  collection)
1262
1289
  : socket.triplesQuery(undefined, // s = ??? (what we want to find)
1263
- { v: relationshipUri, e: true }, // p = relationship
1264
- { v: selectedNodeId, e: true }, // o = selectedNode
1290
+ { t: "i", i: relationshipUri }, // p = relationship
1291
+ { t: "i", i: selectedNodeId }, // o = selectedNode
1265
1292
  20, // Limit results
1266
1293
  collection);
1267
1294
  return queryPromise
@@ -1434,8 +1461,10 @@ const getGraphEmbeddings = (socket, add, remove, limit, collection) => {
1434
1461
  .graphEmbeddingsQuery(vecs, limit , collection)
1435
1462
  .then((ents) => {
1436
1463
  remove(act);
1437
- return ents.map((ent) => {
1438
- return { uri: ent.v, target: vecs[0] };
1464
+ return ents
1465
+ .filter((ent) => ent.t === "i")
1466
+ .map((ent) => {
1467
+ return { uri: ent.i, target: vecs[0] };
1439
1468
  });
1440
1469
  })
1441
1470
  .catch((err) => {
@@ -1450,7 +1479,7 @@ const addRowLabels = (socket, add, remove, collection) => (entities) => {
1450
1479
  const act = "Label " + ent.uri;
1451
1480
  add(act);
1452
1481
  return socket
1453
- .triplesQuery({ v: ent.uri, e: true }, { v: RDFS_LABEL, e: true }, undefined, 1, collection)
1482
+ .triplesQuery({ t: "i", i: ent.uri }, { t: "i", i: RDFS_LABEL }, undefined, 1, collection)
1454
1483
  .then((t) => {
1455
1484
  if (t.length < 1) {
1456
1485
  remove(act);
@@ -1462,9 +1491,10 @@ const addRowLabels = (socket, add, remove, collection) => (entities) => {
1462
1491
  }
1463
1492
  else {
1464
1493
  remove(act);
1494
+ const obj = t[0].o;
1465
1495
  return {
1466
1496
  uri: ent.uri,
1467
- label: t[0].o.v,
1497
+ label: obj.v,
1468
1498
  target: ent.target,
1469
1499
  };
1470
1500
  }
@@ -1483,7 +1513,7 @@ const addRowDefinitions = (socket, add, remove, collection) =>
1483
1513
  const act = "Description " + ent.uri;
1484
1514
  add(act);
1485
1515
  return socket
1486
- .triplesQuery({ v: ent.uri, e: true }, { v: SKOS_DEFINITION, e: true }, undefined, 1, collection)
1516
+ .triplesQuery({ t: "i", i: ent.uri }, { t: "i", i: SKOS_DEFINITION }, undefined, 1, collection)
1487
1517
  .then((t) => {
1488
1518
  if (t.length < 1) {
1489
1519
  remove(act);
@@ -1491,9 +1521,10 @@ const addRowDefinitions = (socket, add, remove, collection) =>
1491
1521
  }
1492
1522
  else {
1493
1523
  remove(act);
1524
+ const obj = t[0].o;
1494
1525
  return {
1495
1526
  ...ent,
1496
- description: t[0].o.v,
1527
+ description: obj.v,
1497
1528
  };
1498
1529
  }
1499
1530
  })
@@ -1869,12 +1900,12 @@ const useChatSession = () => {
1869
1900
  addActivity(embActivity);
1870
1901
  // Get labels for each entity
1871
1902
  const labelPromises = result.entities.map(async (entity) => {
1872
- const labelActivity = "Label " + entity.v;
1903
+ const labelActivity = "Label " + getTermValue$2(entity);
1873
1904
  addActivity(labelActivity);
1874
1905
  try {
1875
1906
  const triples = await socket
1876
1907
  .flow(flowId)
1877
- .triplesQuery(entity, { v: RDFS_LABEL, e: true }, undefined, 1, settings.collection);
1908
+ .triplesQuery(entity, { t: "i", i: RDFS_LABEL }, undefined, 1, settings.collection);
1878
1909
  removeActivity(labelActivity);
1879
1910
  return triples;
1880
1911
  }
@@ -1888,8 +1919,8 @@ const useChatSession = () => {
1888
1919
  const entityList = labelResponses
1889
1920
  .filter((resp) => resp && resp.length > 0)
1890
1921
  .map((resp) => ({
1891
- label: resp[0].o.v,
1892
- uri: resp[0].s.v,
1922
+ label: getTermValue$2(resp[0].o),
1923
+ uri: getTermValue$2(resp[0].s),
1893
1924
  }));
1894
1925
  setEntities(entityList);
1895
1926
  removeActivity(embActivity);
@@ -3359,12 +3390,12 @@ const useKnowledgeCores = () => {
3359
3390
  });
3360
3391
  /**
3361
3392
  * Mutation for loading multiple knowledge cores
3362
- * Executes parallel load requests with specified flow
3393
+ * Executes parallel load requests with specified flow and collection
3363
3394
  */
3364
3395
  const loadKnowledgeCoresMutation = reactQuery.useMutation({
3365
- mutationFn: ({ ids, flow, onSuccess }) => {
3396
+ mutationFn: ({ ids, flow, collection, onSuccess }) => {
3366
3397
  // Execute load requests in parallel for all knowledge cores
3367
- return Promise.all(ids.map((id) => socket.knowledge().loadKgCore(id, flow))).then(() => {
3398
+ return Promise.all(ids.map((id) => socket.knowledge().loadKgCore(id, flow, collection))).then(() => {
3368
3399
  // Execute success callback if provided
3369
3400
  if (onSuccess)
3370
3401
  onSuccess();
@@ -4080,6 +4111,18 @@ const useParameterValidation = (parameterDefinitions, parameterMapping, paramete
4080
4111
  ]);
4081
4112
  };
4082
4113
 
4114
+ // Helper to get the string value from a Term (IRI or Literal)
4115
+ const getTermValue = (term) => {
4116
+ if (term.t === "i")
4117
+ return term.i;
4118
+ if (term.t === "l")
4119
+ return term.v;
4120
+ if (term.t === "b")
4121
+ return term.d;
4122
+ return "";
4123
+ };
4124
+ // Helper to check if a Term is an IRI
4125
+ const isIri = (term) => term.t === "i";
4083
4126
  /**
4084
4127
  * Standard URI to label mappings
4085
4128
  * These common URIs are mapped directly without knowledge graph queries
@@ -4130,10 +4173,10 @@ const useNodeDetails = (nodeId, flowId) => {
4130
4173
  if (!nodeId) {
4131
4174
  throw new Error("Node ID is required");
4132
4175
  }
4133
- const subjectValue = { v: nodeId, e: true };
4176
+ const subjectTerm = { t: "i", i: nodeId };
4134
4177
  return socket
4135
4178
  .flow(flowId)
4136
- .triplesQuery(subjectValue, undefined, undefined, 20, settings.collection)
4179
+ .triplesQuery(subjectTerm, undefined, undefined, 20, settings.collection)
4137
4180
  .then((triples) => {
4138
4181
  if (!Array.isArray(triples)) {
4139
4182
  console.error("Expected triples array, got:", triples);
@@ -4159,10 +4202,10 @@ const useNodeDetails = (nodeId, flowId) => {
4159
4202
  if (!nodeId) {
4160
4203
  throw new Error("Node ID is required");
4161
4204
  }
4162
- const objectValue = { v: nodeId, e: true };
4205
+ const objectTerm = { t: "i", i: nodeId };
4163
4206
  return socket
4164
4207
  .flow(flowId)
4165
- .triplesQuery(undefined, undefined, objectValue, 20, settings.collection)
4208
+ .triplesQuery(undefined, undefined, objectTerm, 20, settings.collection)
4166
4209
  .then((triples) => {
4167
4210
  if (!Array.isArray(triples)) {
4168
4211
  console.error("Expected triples array, got:", triples);
@@ -4188,17 +4231,17 @@ const useNodeDetails = (nodeId, flowId) => {
4188
4231
  if (!nodeId) {
4189
4232
  throw new Error("Node ID is required");
4190
4233
  }
4191
- const subjectValue = { v: nodeId, e: true };
4234
+ const subjectTerm = { t: "i", i: nodeId };
4192
4235
  return socket
4193
4236
  .flow(flowId)
4194
- .triplesQuery(subjectValue, undefined, undefined, 50, settings.collection) // More limit for properties
4237
+ .triplesQuery(subjectTerm, undefined, undefined, 50, settings.collection) // More limit for properties
4195
4238
  .then((triples) => {
4196
4239
  if (!Array.isArray(triples)) {
4197
4240
  console.error("Expected triples array, got:", triples);
4198
4241
  throw new Error("Invalid triples response");
4199
4242
  }
4200
- // Filter for properties (where o.e === false)
4201
- return triples.filter((triple) => triple.o && triple.o.e === false);
4243
+ // Filter for properties (where o is not an IRI, i.e., literals)
4244
+ return triples.filter((triple) => triple.o && !isIri(triple.o));
4202
4245
  })
4203
4246
  .catch((err) => {
4204
4247
  console.error("Error fetching properties:", err);
@@ -4218,9 +4261,9 @@ const useNodeDetails = (nodeId, flowId) => {
4218
4261
  // Filter for entity relationships and extract unique predicates
4219
4262
  const uniqueRelationships = new Set();
4220
4263
  outboundTriplesQuery.data.forEach((triple) => {
4221
- // Check if object is an entity (o.e === true)
4222
- if (triple.o && triple.o.e === true && triple.p && triple.p.v) {
4223
- uniqueRelationships.add(triple.p.v);
4264
+ // Check if object is an IRI (entity)
4265
+ if (triple.o && isIri(triple.o) && triple.p && isIri(triple.p)) {
4266
+ uniqueRelationships.add(triple.p.i);
4224
4267
  }
4225
4268
  });
4226
4269
  // Convert Set to array
@@ -4236,9 +4279,9 @@ const useNodeDetails = (nodeId, flowId) => {
4236
4279
  // Filter for entity relationships and extract unique predicates
4237
4280
  const uniqueRelationships = new Set();
4238
4281
  inboundTriplesQuery.data.forEach((triple) => {
4239
- // Check if subject is an entity (s.e === true)
4240
- if (triple.s && triple.s.e === true && triple.p && triple.p.v) {
4241
- uniqueRelationships.add(triple.p.v);
4282
+ // Check if subject is an IRI (entity)
4283
+ if (triple.s && isIri(triple.s) && triple.p && isIri(triple.p)) {
4284
+ uniqueRelationships.add(triple.p.i);
4242
4285
  }
4243
4286
  });
4244
4287
  // Convert Set to array
@@ -4254,8 +4297,8 @@ const useNodeDetails = (nodeId, flowId) => {
4254
4297
  // Extract unique property predicates
4255
4298
  const uniqueProperties = new Set();
4256
4299
  propertiesQuery.data.forEach((triple) => {
4257
- if (triple.p && triple.p.v) {
4258
- uniqueProperties.add(triple.p.v);
4300
+ if (triple.p && isIri(triple.p)) {
4301
+ uniqueProperties.add(triple.p.i);
4259
4302
  }
4260
4303
  });
4261
4304
  // Convert Set to array
@@ -4284,14 +4327,14 @@ const useNodeDetails = (nodeId, flowId) => {
4284
4327
  }
4285
4328
  // If not in standard mappings, query the knowledge graph
4286
4329
  try {
4287
- const subjectValue = { v: relationshipURI, e: true };
4288
- const predicateValue = { v: RDFS_LABEL, e: true };
4330
+ const subjectTerm = { t: "i", i: relationshipURI };
4331
+ const predicateTerm = { t: "i", i: RDFS_LABEL };
4289
4332
  const labelTriples = await socket
4290
4333
  .flow(flowId)
4291
- .triplesQuery(subjectValue, predicateValue, undefined, 1, settings.collection);
4334
+ .triplesQuery(subjectTerm, predicateTerm, undefined, 1, settings.collection);
4292
4335
  // Extract label from the first result, or use URI as fallback
4293
4336
  if (labelTriples && labelTriples.length > 0 && labelTriples[0].o) {
4294
- labelMap[relationshipURI] = labelTriples[0].o.v;
4337
+ labelMap[relationshipURI] = getTermValue(labelTriples[0].o);
4295
4338
  }
4296
4339
  else {
4297
4340
  labelMap[relationshipURI] = relationshipURI;
@@ -4329,14 +4372,14 @@ const useNodeDetails = (nodeId, flowId) => {
4329
4372
  }
4330
4373
  // If not in standard mappings, query the knowledge graph
4331
4374
  try {
4332
- const subjectValue = { v: relationshipURI, e: true };
4333
- const predicateValue = { v: RDFS_LABEL, e: true };
4375
+ const subjectTerm = { t: "i", i: relationshipURI };
4376
+ const predicateTerm = { t: "i", i: RDFS_LABEL };
4334
4377
  const labelTriples = await socket
4335
4378
  .flow(flowId)
4336
- .triplesQuery(subjectValue, predicateValue, undefined, 1, settings.collection);
4379
+ .triplesQuery(subjectTerm, predicateTerm, undefined, 1, settings.collection);
4337
4380
  // Extract label from the first result, or use URI as fallback
4338
4381
  if (labelTriples && labelTriples.length > 0 && labelTriples[0].o) {
4339
- labelMap[relationshipURI] = labelTriples[0].o.v;
4382
+ labelMap[relationshipURI] = getTermValue(labelTriples[0].o);
4340
4383
  }
4341
4384
  else {
4342
4385
  labelMap[relationshipURI] = relationshipURI;
@@ -4374,14 +4417,14 @@ const useNodeDetails = (nodeId, flowId) => {
4374
4417
  }
4375
4418
  // If not in standard mappings, query the knowledge graph
4376
4419
  try {
4377
- const subjectValue = { v: propertyURI, e: true };
4378
- const predicateValue = { v: RDFS_LABEL, e: true };
4420
+ const subjectTerm = { t: "i", i: propertyURI };
4421
+ const predicateTerm = { t: "i", i: RDFS_LABEL };
4379
4422
  const labelTriples = await socket
4380
4423
  .flow(flowId)
4381
- .triplesQuery(subjectValue, predicateValue, undefined, 1, settings.collection);
4424
+ .triplesQuery(subjectTerm, predicateTerm, undefined, 1, settings.collection);
4382
4425
  // Extract label from the first result, or use URI as fallback
4383
4426
  if (labelTriples && labelTriples.length > 0 && labelTriples[0].o) {
4384
- labelMap[propertyURI] = labelTriples[0].o.v;
4427
+ labelMap[propertyURI] = getTermValue(labelTriples[0].o);
4385
4428
  }
4386
4429
  else {
4387
4430
  labelMap[propertyURI] = propertyURI;
@@ -4428,15 +4471,20 @@ const useNodeDetails = (nodeId, flowId) => {
4428
4471
  return propertiesQuery.data
4429
4472
  .filter((triple) => {
4430
4473
  // Exclude label properties (RDFS_LABEL) since node label is already shown
4431
- return triple.p?.v !== RDFS_LABEL;
4474
+ const pUri = triple.p && isIri(triple.p) ? triple.p.i : "";
4475
+ return pUri !== RDFS_LABEL;
4432
4476
  })
4433
- .map((triple) => ({
4434
- predicate: {
4435
- uri: triple.p?.v || "",
4436
- label: propertyLabelsQuery.data?.[triple.p?.v || ""] || triple.p?.v || "",
4437
- },
4438
- value: triple.o?.v || "",
4439
- }));
4477
+ .map((triple) => {
4478
+ const pUri = triple.p && isIri(triple.p) ? triple.p.i : "";
4479
+ const oValue = triple.o ? getTermValue(triple.o) : "";
4480
+ return {
4481
+ predicate: {
4482
+ uri: pUri,
4483
+ label: propertyLabelsQuery.data?.[pUri] || pUri,
4484
+ },
4485
+ value: oValue,
4486
+ };
4487
+ });
4440
4488
  }, [propertiesQuery.data, propertyLabelsQuery.data]);
4441
4489
  // Show loading indicators for long-running operations
4442
4490
  useActivity(outboundTriplesQuery.isLoading ||
@@ -4543,6 +4591,7 @@ exports.SETTINGS_STORAGE_KEY = SETTINGS_STORAGE_KEY;
4543
4591
  exports.createDocId = createDocId;
4544
4592
  exports.fileToBase64 = fileToBase64;
4545
4593
  exports.generateFlowBlueprintId = generateFlowBlueprintId;
4594
+ exports.getTermValue = getTermValue$2;
4546
4595
  exports.getTriples = getTriples;
4547
4596
  exports.prepareMetadata = prepareMetadata;
4548
4597
  exports.textToBase64 = textToBase64;