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