@colabo-knalledge/i-core-services 1.6.0 → 1.8.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/esm/index.js CHANGED
@@ -342,14 +342,16 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
342
342
  * @description adds kNodes in a kContainer
343
343
  * @returns edges created between the container and entities added to the container
344
344
  */
345
- async updateAddNodes(containerId, containedIds, edgeDataContent) {
345
+ async updateAddNodes(containerId, containedIds, edgeDataContent, mapId) {
346
346
  if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
347
347
  let result;
348
348
  const idsStr = containedIds.join(",");
349
349
  const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
350
350
  if (DEBUG) console.log("updateAddNodes called", url);
351
351
  try {
352
- const body = edgeDataContent ? { edgeDataContent } : {};
352
+ const body = {};
353
+ if (edgeDataContent) body.edgeDataContent = edgeDataContent;
354
+ if (mapId) body.mapId = mapId;
353
355
  const mResult = await axios2.put(url, body, HTTP_OPTIONS_CONST_JSON);
354
356
  const serverData = mResult.data;
355
357
  result = ColaboApiOperators.extractVosFromServerData(serverData);
@@ -387,11 +389,13 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
387
389
  * @param id The id of the kContainer which kNodes we want to retrieve
388
390
  * @description retrieves kNodes in a kContainer
389
391
  */
390
- async getInContainer(id, fields) {
391
- let result;
392
+ async getInContainer(id, fields, fetchFn) {
392
393
  const url = ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json", fields);
393
394
  if (DEBUG) console.log(`this.apiUrl:${this.apiUrl}, this.defaultAction:${this.defaultAction}`);
394
395
  try {
396
+ if (fetchFn) {
397
+ return await fetchFn(url);
398
+ }
395
399
  const response = await this.http.get(url).toPromise();
396
400
  if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
397
401
  if (!response) {
@@ -406,11 +410,14 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
406
410
  }
407
411
  }
408
412
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
409
- async getVOs(type, upperLayerType, fields) {
413
+ async getVOs(type, upperLayerType, fields, fetchFn) {
410
414
  let result;
411
415
  const url = ColaboApiOperators.appendFieldsParam(`${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`, fields);
412
- const mResult = await axios2.get(url);
413
416
  try {
417
+ if (fetchFn) {
418
+ return await fetchFn(url);
419
+ }
420
+ const mResult = await axios2.get(url);
414
421
  const serverData = mResult.data;
415
422
  result = ColaboApiOperators.extractVosFromServerData(serverData);
416
423
  if (!result) {
@@ -556,14 +563,17 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
556
563
  throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
557
564
  }
558
565
  }
559
- async getVosWithColaboApi(request) {
566
+ async getVosWithColaboApi(request, fetchFn) {
560
567
  request.type = KNODE_API_TYPE.INDEX_COLABO_API;
561
568
  const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
562
569
  let result = [];
563
570
  const url = ColaboApiOperators2.appendFieldsParam(this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json", request.fields);
564
571
  if (DEBUG3) console.log("[getVos] url: ", url);
565
- const mResult = await axios3.get(url);
566
572
  try {
573
+ if (fetchFn) {
574
+ return await fetchFn(url);
575
+ }
576
+ const mResult = await axios3.get(url);
567
577
  const serverData = mResult.data;
568
578
  if (!serverData) return result;
569
579
  result = ColaboApiOperators2.extractVosFromServerData(serverData);
@@ -745,11 +755,16 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
745
755
  static get mapId() {
746
756
  return config2.GetString("mapId");
747
757
  }
748
- async queryByIds(ids, fields, callback) {
758
+ async queryByIds(ids, fields, callback, fetchFn) {
749
759
  if (DEBUG4) console.log("queryByIds", ids);
750
760
  const idsStr = ids.join(",");
751
761
  const url = ColaboApiOperators3.appendFieldsParam(this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json", fields);
752
762
  try {
763
+ if (fetchFn) {
764
+ const rawNodes = await fetchFn(url);
765
+ if (callback) callback(rawNodes);
766
+ return rawNodes;
767
+ }
753
768
  const mResult = await axios4.get(url);
754
769
  const serverData = mResult.data;
755
770
  const result = CFServiceIsomorphic.processVOs(serverData, KNodeFrontend3);
@@ -1084,15 +1099,18 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
1084
1099
  this.apiUrl = KnalledgeEdgeService.serverAP + "/" + KEDGE_API_PARAMS.API_PATH + "/";
1085
1100
  console.log("[KnalledgeEdgeService] REST API URL: ", chalk2.bold.white(this.apiUrl));
1086
1101
  }
1087
- async getVosWithColaboApi(request) {
1102
+ async getVosWithColaboApi(request, fetchFn) {
1088
1103
  request.type = KEDGE_API_TYPE.INDEX_COLABO_API;
1089
1104
  console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
1090
1105
  const requestSerialized = ColaboApiOperators4.serializeApiRequest(request);
1091
1106
  let result;
1092
1107
  const url = ColaboApiOperators4.appendFieldsParam(this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized, request.fields);
1093
1108
  console.log("[getVos] url: ", url);
1094
- const mResult = await axios5.get(url);
1095
1109
  try {
1110
+ if (fetchFn) {
1111
+ return await fetchFn(url);
1112
+ }
1113
+ const mResult = await axios5.get(url);
1096
1114
  const serverData = mResult.data;
1097
1115
  result = ColaboApiOperators4.extractVosFromServerData(serverData);
1098
1116
  if (!result) {