@colabo-knalledge/i-core-services 1.0.0 → 1.2.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/cjs/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -33,26 +34,6 @@ var __decorateClass = (decorators, target, key, kind) => {
33
34
  if (kind && result) __defProp(target, key, result);
34
35
  return result;
35
36
  };
36
- var __async = (__this, __arguments, generator) => {
37
- return new Promise((resolve, reject) => {
38
- var fulfilled = (value) => {
39
- try {
40
- step(generator.next(value));
41
- } catch (e) {
42
- reject(e);
43
- }
44
- };
45
- var rejected = (value) => {
46
- try {
47
- step(generator.throw(value));
48
- } catch (e) {
49
- reject(e);
50
- }
51
- };
52
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
53
- step((generator = generator.apply(__this, __arguments)).next());
54
- });
55
- };
56
37
 
57
38
  // index.ts
58
39
  var index_exports = {};
@@ -227,25 +208,43 @@ var errorInterceptor = (error) => {
227
208
  return Promise.reject(error);
228
209
  };
229
210
  if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService] declaring ColaboApiCoreService class");
230
- var ColaboApiCoreService = class _ColaboApiCoreService {
211
+ var ColaboApiCoreService = class {
212
+ static {
213
+ this.interceptorsForAxios = /* @__PURE__ */ new Map();
214
+ }
231
215
  // Add a response interceptor to remove JSONP prefix that Colabo.Space is sending
232
216
  // https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
233
217
  // https://stackoverflow.com/questions/33967189/angular-not-removing-json-prefix
234
218
  // [Ejecting an interceptor #2615](https://github.com/axios/axios/issues/2615#issuecomment-567964331)
235
219
  static initialize(namespace, specificAxios = import_axios.default) {
236
220
  if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initializing interceptor for the namespace: ", namespace);
237
- if (typeof _ColaboApiCoreService.colaboApiInterceptorId === "undefined") {
238
- _ColaboApiCoreService.colaboApiInterceptorNamespace = namespace;
239
- _ColaboApiCoreService.colaboApiInterceptorId = specificAxios.interceptors.response.use(responseInterceptor, errorInterceptor);
221
+ let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
222
+ if (!axiosImplementation || typeof axiosImplementation.colaboApiInterceptorId === "undefined") {
223
+ const colaboApiInterceptorId = specificAxios.interceptors.response.use(responseInterceptor, errorInterceptor);
224
+ if (!axiosImplementation) {
225
+ axiosImplementation = {
226
+ colaboApiInterceptorId,
227
+ colaboApiInterceptorNamespace: namespace
228
+ };
229
+ this.interceptorsForAxios.set(specificAxios, axiosImplementation);
230
+ } else {
231
+ axiosImplementation.colaboApiInterceptorNamespace = namespace;
232
+ axiosImplementation.colaboApiInterceptorId = colaboApiInterceptorId;
233
+ }
240
234
  if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initialized interceptor for the namespace: ", namespace);
241
235
  } else {
242
- if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ", _ColaboApiCoreService.colaboApiInterceptorNamespace);
236
+ if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ", axiosImplementation.colaboApiInterceptorNamespace);
243
237
  }
244
- return _ColaboApiCoreService.colaboApiInterceptorId;
238
+ return axiosImplementation.colaboApiInterceptorId;
245
239
  }
246
240
  static destroy(namespace, specificAxios = import_axios.default) {
247
241
  if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Destroying interceptor for the namespace: ", namespace);
248
- specificAxios.interceptors.request.eject(_ColaboApiCoreService.colaboApiInterceptorId);
242
+ let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
243
+ if (axiosImplementation) {
244
+ specificAxios.interceptors.request.eject(axiosImplementation.colaboApiInterceptorId);
245
+ } else {
246
+ console.log(`[ColaboApiCoreService:initialize] no axiosImplementation found for the provided axios`);
247
+ }
249
248
  }
250
249
  };
251
250
  (0, import_i_core3.injectInterceptorService)(ColaboApiCoreService);
@@ -281,77 +280,71 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
281
280
  console.log("[ColaboKnAllEdgeContainerService] created");
282
281
  this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + import_i_core4.KCONTAINER_API_PARAMS.API_PATH + "/";
283
282
  }
284
- getById(id) {
285
- return __async(this, null, function* () {
286
- let result;
287
- const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id;
288
- if (DEBUG) console.log("[getByIdPromise] url: ", url);
289
- try {
290
- const mResult = yield import_axios2.default.get(url);
291
- const serverData = mResult.data;
292
- result = import_i_core4.ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
293
- if (!result) {
294
- return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
295
- }
296
- if (import_i_core4.ColaboApiOperators.getParentEntity(result).type != import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
297
- return Promise.reject(new Error("Wrong entity type, expected: " + import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
298
- }
299
- } catch (error) {
300
- console.error(error);
301
- return Promise.reject(error);
283
+ async getById(id) {
284
+ let result;
285
+ const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id;
286
+ if (DEBUG) console.log("[getByIdPromise] url: ", url);
287
+ try {
288
+ const mResult = await import_axios2.default.get(url);
289
+ const serverData = mResult.data;
290
+ result = import_i_core4.ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
291
+ if (!result) {
292
+ return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
302
293
  }
303
- return result;
304
- });
294
+ if (import_i_core4.ColaboApiOperators.getParentEntity(result).type != import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
295
+ return Promise.reject(new Error("Wrong entity type, expected: " + import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
296
+ }
297
+ } catch (error) {
298
+ console.error(error);
299
+ return Promise.reject(error);
300
+ }
301
+ return result;
305
302
  }
306
- create(kContainerWContent) {
307
- return __async(this, null, function* () {
308
- console.log("ColaboKnAllEdgeContainerService.create");
309
- let result;
310
- const url = this.apiUrl;
311
- try {
312
- const requestRoot = {
313
- type: import_i_core4.KCONTAINER_API_TYPE.CREATE_NEW,
314
- data: kContainerWContent
315
- };
316
- const mResult = yield import_axios2.default.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
317
- const serverData = mResult.data;
318
- result = import_i_core4.ColaboApiOperators.extractVoFromServerData(serverData);
319
- return result;
320
- } catch (error) {
321
- if (error.response) {
322
- console.log("[create]", error);
323
- console.warn("Response status:", error.response.status);
324
- console.warn("Response data:", error.response.data);
325
- if (error.response.data.code === "EMAIL_EXISTS") {
326
- console.warn("EMAIL_EXISTS");
327
- }
328
- return error.response.data;
329
- } else if (error.request) {
330
- console.error("No response received");
331
- } else {
332
- console.error("[ColaboKnAllEdgeContainerService:create] Error during request setup:", error.message);
303
+ async create(kContainerWContent) {
304
+ console.log("ColaboKnAllEdgeContainerService.create");
305
+ let result;
306
+ const url = this.apiUrl;
307
+ try {
308
+ const requestRoot = {
309
+ type: import_i_core4.KCONTAINER_API_TYPE.CREATE_NEW,
310
+ data: kContainerWContent
311
+ };
312
+ const mResult = await import_axios2.default.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
313
+ const serverData = mResult.data;
314
+ result = import_i_core4.ColaboApiOperators.extractVoFromServerData(serverData);
315
+ return result;
316
+ } catch (error) {
317
+ if (error.response) {
318
+ console.log("[create]", error);
319
+ console.warn("Response status:", error.response.status);
320
+ console.warn("Response data:", error.response.data);
321
+ if (error.response.data.code === "EMAIL_EXISTS") {
322
+ console.warn("EMAIL_EXISTS");
333
323
  }
334
- (0, import_i_notifications3.rethrowColaboError)(error);
335
- throw new import_i_notifications3.ColaboErrorUnreachable();
324
+ return error.response.data;
325
+ } else if (error.request) {
326
+ console.error("No response received");
327
+ } else {
328
+ console.error("[ColaboKnAllEdgeContainerService:create] Error during request setup:", error.message);
336
329
  }
337
- });
330
+ (0, import_i_notifications3.rethrowColaboError)(error);
331
+ throw new import_i_notifications3.ColaboErrorUnreachable();
332
+ }
338
333
  }
339
- update(kContainer) {
340
- return __async(this, null, function* () {
341
- console.log("ColaboKnAllEdgeContainerService.update");
342
- let result;
343
- const actionType = import_i_core4.KCONTAINER_API_TYPE.UPDATE_BY_ID;
344
- const url = this.apiUrl + "one/" + actionType + "/" + kContainer._id;
345
- try {
346
- const mResult = yield import_axios2.default.put(url, kContainer, HTTP_OPTIONS_CONST_JSON);
347
- const serverData = mResult.data;
348
- result = import_i_core4.ColaboApiOperators.extractVoFromServerData(serverData);
349
- } catch (error) {
350
- console.error(error);
351
- return Promise.reject(error);
352
- }
353
- return result;
354
- });
334
+ async update(kContainer) {
335
+ console.log("ColaboKnAllEdgeContainerService.update");
336
+ let result;
337
+ const actionType = import_i_core4.KCONTAINER_API_TYPE.UPDATE_BY_ID;
338
+ const url = this.apiUrl + "one/" + actionType + "/" + kContainer._id;
339
+ try {
340
+ const mResult = await import_axios2.default.put(url, kContainer, HTTP_OPTIONS_CONST_JSON);
341
+ const serverData = mResult.data;
342
+ result = import_i_core4.ColaboApiOperators.extractVoFromServerData(serverData);
343
+ } catch (error) {
344
+ console.error(error);
345
+ return Promise.reject(error);
346
+ }
347
+ return result;
355
348
  }
356
349
  /**
357
350
  /**
@@ -362,19 +355,17 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
362
355
  * @return {*} {Promise<boolean>}
363
356
  * @memberof ColaboKnAllEdgeContainerService
364
357
  */
365
- destroy(id) {
366
- return __async(this, null, function* () {
367
- console.log(`[destroy] id=${id}`);
368
- const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.DESTROY_ONE + "/" + id;
369
- try {
370
- const mResult = yield import_axios2.default.delete(url, HTTP_OPTIONS_CONST_JSON);
371
- const serverData = mResult.data;
372
- return serverData.success;
373
- } catch (error) {
374
- (0, import_i_notifications3.rethrowColaboError)(error);
375
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
376
- }
377
- });
358
+ async destroy(id) {
359
+ console.log(`[destroy] id=${id}`);
360
+ const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.DESTROY_ONE + "/" + id;
361
+ try {
362
+ const mResult = await import_axios2.default.delete(url, HTTP_OPTIONS_CONST_JSON);
363
+ const serverData = mResult.data;
364
+ return serverData.success;
365
+ } catch (error) {
366
+ (0, import_i_notifications3.rethrowColaboError)(error);
367
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
368
+ }
378
369
  }
379
370
  /**
380
371
  * @param containerId The id of the kContainer to which we want to add kNodes
@@ -382,23 +373,21 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
382
373
  * @description adds kNodes in a kContainer
383
374
  * @returns edges created between the container and entities added to the container
384
375
  */
385
- updateAddNodes(containerId, containedIds) {
386
- return __async(this, null, function* () {
387
- if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
388
- let result;
389
- const idsStr = containedIds.join(",");
390
- const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
391
- console.log("updateAddNodes called", url);
392
- try {
393
- const mResult = yield import_axios2.default.put(url, {}, HTTP_OPTIONS_CONST_JSON);
394
- const serverData = mResult.data;
395
- result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
396
- } catch (error) {
397
- console.error(error);
398
- return Promise.reject(error);
399
- }
400
- return result;
401
- });
376
+ async updateAddNodes(containerId, containedIds) {
377
+ if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
378
+ let result;
379
+ const idsStr = containedIds.join(",");
380
+ const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
381
+ console.log("updateAddNodes called", url);
382
+ try {
383
+ const mResult = await import_axios2.default.put(url, {}, HTTP_OPTIONS_CONST_JSON);
384
+ const serverData = mResult.data;
385
+ result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
386
+ } catch (error) {
387
+ console.error(error);
388
+ return Promise.reject(error);
389
+ }
390
+ return result;
402
391
  }
403
392
  /**
404
393
  * removes kNodes from a kContainer
@@ -407,67 +396,61 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
407
396
  * @param ids The list of ids of the kNodes we want to remove from the container
408
397
  * @returns edges created between the container and entities added to the container
409
398
  */
410
- updateRemoveNodes(id, ids) {
411
- return __async(this, null, function* () {
412
- console.log("[ColaboKnAllEdgeContainerService::updateRemoveNodes(id, ids)", id, ids);
413
- let result;
414
- const idsStr = ids.join(",");
415
- const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.UPDATE_REMOVE_KNODE_BY_IDS + "/" + id + "/" + idsStr;
416
- console.log("updateRemoveNodes called", url);
417
- try {
418
- const mResult = yield import_axios2.default.put(url, {}, HTTP_OPTIONS_CONST_JSON);
419
- const serverData = mResult.data;
420
- result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
421
- } catch (error) {
422
- console.error(error);
423
- return Promise.reject(error);
424
- }
425
- return result;
426
- });
399
+ async updateRemoveNodes(id, ids) {
400
+ console.log("[ColaboKnAllEdgeContainerService::updateRemoveNodes(id, ids)", id, ids);
401
+ let result;
402
+ const idsStr = ids.join(",");
403
+ const url = this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.UPDATE_REMOVE_KNODE_BY_IDS + "/" + id + "/" + idsStr;
404
+ console.log("updateRemoveNodes called", url);
405
+ try {
406
+ const mResult = await import_axios2.default.put(url, {}, HTTP_OPTIONS_CONST_JSON);
407
+ const serverData = mResult.data;
408
+ result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
409
+ } catch (error) {
410
+ console.error(error);
411
+ return Promise.reject(error);
412
+ }
413
+ return result;
427
414
  }
428
415
  /**
429
416
  *
430
417
  * @param id The id of the kContainer which knodes we want to retrieve
431
418
  * @description retrieves kNodes in a kContainer
432
419
  */
433
- getInContainer(id) {
434
- return __async(this, null, function* () {
435
- let result;
436
- if (DEBUG) console.log(`this.apiUrl:${this.apiUrl}, this.defaultAction:${this.defaultAction}`);
437
- const url = `http://127.0.0.1:8001/kcontainers/` + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json";
438
- try {
439
- const response = yield this.http.get(url).toPromise();
440
- if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
441
- if (!response) {
442
- return [];
443
- }
444
- const processedResponse = CFServiceIsomorphic.processVOs(response, import_i_core4.KNodeFrontend);
445
- if (DEBUG_VERBOSE) console.log("[ColaboKnAllEdgeContainerService::getInContainer] response<KNodeFrontend>: ", JSON.stringify(processedResponse, null, 4));
446
- return processedResponse;
447
- } catch (error) {
448
- (0, import_i_notifications3.rethrowColaboError)(error);
449
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
420
+ async getInContainer(id) {
421
+ let result;
422
+ if (DEBUG) console.log(`this.apiUrl:${this.apiUrl}, this.defaultAction:${this.defaultAction}`);
423
+ const url = `http://127.0.0.1:8001/kcontainers/` + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json";
424
+ try {
425
+ const response = await this.http.get(url).toPromise();
426
+ if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
427
+ if (!response) {
428
+ return [];
450
429
  }
451
- });
430
+ const processedResponse = CFServiceIsomorphic.processVOs(response, import_i_core4.KNodeFrontend);
431
+ if (DEBUG_VERBOSE) console.log("[ColaboKnAllEdgeContainerService::getInContainer] response<KNodeFrontend>: ", JSON.stringify(processedResponse, null, 4));
432
+ return processedResponse;
433
+ } catch (error) {
434
+ (0, import_i_notifications3.rethrowColaboError)(error);
435
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
436
+ }
452
437
  }
453
438
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
454
- getVOs(type, upperLayerType) {
455
- return __async(this, null, function* () {
456
- let result;
457
- const url = `${this.apiUrl}${this.defaultAction}/${import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`;
458
- const mResult = yield import_axios2.default.get(url);
459
- try {
460
- const serverData = mResult.data;
461
- result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
462
- if (!result) {
463
- return Promise.reject(new Error("Couldn't extract VOs from the serverData"));
464
- }
465
- } catch (error) {
466
- console.error(error);
467
- return Promise.reject(error);
439
+ async getVOs(type, upperLayerType) {
440
+ let result;
441
+ const url = `${this.apiUrl}${this.defaultAction}/${import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`;
442
+ const mResult = await import_axios2.default.get(url);
443
+ try {
444
+ const serverData = mResult.data;
445
+ result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
446
+ if (!result) {
447
+ return Promise.reject(new Error("Couldn't extract VOs from the serverData"));
468
448
  }
469
- return result;
470
- });
449
+ } catch (error) {
450
+ console.error(error);
451
+ return Promise.reject(error);
452
+ }
453
+ return result;
471
454
  }
472
455
  /**
473
456
  * Extracts upper-layer entity from kContainer and sets it up
@@ -577,188 +560,167 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
577
560
  */
578
561
  // eslint-disable-next-line @typescript-eslint/ban-types
579
562
  // OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
580
- getById(id) {
581
- return __async(this, null, function* () {
582
- const url = this.apiUrl + "one/" + this.defaultAction + "/" + id;
583
- console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
584
- console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
585
- try {
586
- const result = yield import_axios3.default.get(url);
587
- const data = result.data;
588
- const kNode = this.extractVOFromDataAsArray(data, import_i_core10.KNodeFrontend);
589
- return kNode;
590
- } catch (e) {
591
- if ((0, import_i_notifications4.isColaboError)(e)) {
592
- throw e;
593
- }
594
- const error = e;
595
- if (error.response) {
596
- } else if (error.request) {
597
- (0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
598
- } else {
599
- console.error("[ColaboKnAllEdgeNodeService:getById] Error during request setup:");
600
- (0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
601
- }
602
- throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
563
+ async getById(id) {
564
+ const url = this.apiUrl + "one/" + this.defaultAction + "/" + id;
565
+ console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
566
+ console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
567
+ try {
568
+ const result = await import_axios3.default.get(url);
569
+ const data = result.data;
570
+ const kNode = this.extractVOFromDataAsArray(data, import_i_core10.KNodeFrontend);
571
+ return kNode;
572
+ } catch (e) {
573
+ if ((0, import_i_notifications4.isColaboError)(e)) {
574
+ throw e;
575
+ }
576
+ const error = e;
577
+ if (error.response) {
578
+ } else if (error.request) {
579
+ (0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
580
+ } else {
581
+ console.error("[ColaboKnAllEdgeNodeService:getById] Error during request setup:");
582
+ (0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
603
583
  }
604
- });
584
+ throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
585
+ }
605
586
  }
606
- getVosWithColaboApi(request) {
607
- return __async(this, null, function* () {
608
- request.type = import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API;
609
- const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
610
- let result = [];
611
- const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
612
- console.log("[getVos] url: ", url);
613
- const mResult = yield import_axios3.default.get(url);
614
- try {
615
- const serverData = mResult.data;
616
- if (!serverData) return result;
617
- result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
618
- if (!result) {
619
- return Promise.reject(new Error("Error with extracting VOs from serverData"));
620
- }
621
- } catch (error) {
622
- console.error(error);
623
- return Promise.reject(error);
587
+ async getVosWithColaboApi(request) {
588
+ request.type = import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API;
589
+ const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
590
+ let result = [];
591
+ const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
592
+ console.log("[getVos] url: ", url);
593
+ const mResult = await import_axios3.default.get(url);
594
+ try {
595
+ const serverData = mResult.data;
596
+ if (!serverData) return result;
597
+ result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
598
+ if (!result) {
599
+ return Promise.reject(new Error("Error with extracting VOs from serverData"));
624
600
  }
625
- return result;
626
- });
601
+ } catch (error) {
602
+ console.error(error);
603
+ return Promise.reject(error);
604
+ }
605
+ return result;
627
606
  }
628
- updateSingleWithColaboApi(request) {
629
- return __async(this, null, function* () {
630
- const kNodes = yield this.updateWithColaboApi(request);
631
- if (!kNodes) throw new Error("kNodes is not defined");
632
- if (kNodes.length <= 0) throw new Error("kNodes is empty");
633
- return kNodes[0];
634
- });
607
+ async updateSingleWithColaboApi(request) {
608
+ const kNodes = await this.updateWithColaboApi(request);
609
+ if (!kNodes) throw new Error("kNodes is not defined");
610
+ if (kNodes.length <= 0) throw new Error("kNodes is empty");
611
+ return kNodes[0];
635
612
  }
636
- updateWithColaboApi(request) {
637
- return __async(this, null, function* () {
638
- var _a, _b;
639
- request.type = import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API;
640
- let result;
641
- const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
642
- console.log("[getVos] url: ", url);
643
- let mResult;
644
- try {
645
- mResult = yield import_axios3.default.put(url, request);
646
- } catch (error) {
647
- console.error(`${import_i_core10.contextReportText}Error updating: ${error}`);
648
- return Promise.reject(error);
613
+ async updateWithColaboApi(request) {
614
+ request.type = import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API;
615
+ let result;
616
+ const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
617
+ console.log("[getVos] url: ", url);
618
+ let mResult;
619
+ try {
620
+ mResult = await import_axios3.default.put(url, request);
621
+ } catch (error) {
622
+ console.error(`${import_i_core10.contextReportText}Error updating: ${error}`);
623
+ return Promise.reject(error);
624
+ }
625
+ try {
626
+ const serverData = mResult.data;
627
+ if (!serverData.success) {
628
+ console.error(`Error updating: [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
629
+ return Promise.reject(serverData);
649
630
  }
650
- try {
651
- const serverData = mResult.data;
652
- if (!serverData.success) {
653
- console.error(`Error updating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
654
- return Promise.reject(serverData);
655
- }
656
- result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
657
- if (!result) {
658
- return Promise.reject(new Error("Error with extracting VOs from serverData"));
659
- }
660
- } catch (error) {
661
- console.error(error);
662
- return Promise.reject(error);
631
+ result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
632
+ if (!result) {
633
+ return Promise.reject(new Error("Error with extracting VOs from serverData"));
663
634
  }
664
- return result;
665
- });
635
+ } catch (error) {
636
+ console.error(error);
637
+ return Promise.reject(error);
638
+ }
639
+ return result;
666
640
  }
667
641
  // getVOs(type:string):Observable<KNodeFrontend[]> {
668
642
  // return this.queryInMapofType(ColaboKnAllEdgeNodeService.mapId,type);
669
643
  // }
670
- createSingle(kNode) {
671
- return __async(this, null, function* () {
672
- const kNodesCreated = yield this.create(kNode);
673
- if (!Array.isArray(kNodesCreated) || kNodesCreated.length <= 0) throw new Error(`${(0, import_i_core10.contextReportText)()} No kNode created`);
674
- const kNodeCreated = kNodesCreated[0];
675
- return kNodeCreated;
676
- });
644
+ async createSingle(kNode) {
645
+ const kNodesCreated = await this.create(kNode);
646
+ if (!Array.isArray(kNodesCreated) || kNodesCreated.length <= 0) throw new Error(`${(0, import_i_core10.contextReportText)()} No kNode created`);
647
+ const kNodeCreated = kNodesCreated[0];
648
+ return kNodeCreated;
677
649
  }
678
650
  /** creates a new Element (VO) */
679
651
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
680
- create(kNode, callback) {
681
- return __async(this, null, function* () {
682
- var _a, _b;
683
- console.log(`${(0, import_i_core10.contextReportText)()}`);
684
- let result;
685
- const request = {
686
- type: import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API,
687
- data: kNode
688
- };
689
- const url = this.apiUrl;
690
- try {
691
- const mResult = yield import_axios3.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
692
- const serverData = mResult.data;
693
- if (!serverData.success) {
694
- throw new Error(`${import_i_core10.contextReportText} Error creating node. [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
695
- }
696
- result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
697
- } catch (error) {
698
- (0, import_i_notifications4.rethrowColaboError)(error);
699
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
652
+ async create(kNode, callback) {
653
+ console.log(`${(0, import_i_core10.contextReportText)()}`);
654
+ let result;
655
+ const request = {
656
+ type: import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API,
657
+ data: kNode
658
+ };
659
+ const url = this.apiUrl;
660
+ try {
661
+ const mResult = await import_axios3.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
662
+ const serverData = mResult.data;
663
+ if (!serverData.success) {
664
+ throw new Error(`${import_i_core10.contextReportText} Error creating node. [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
700
665
  }
701
- return result;
702
- });
666
+ result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
667
+ } catch (error) {
668
+ (0, import_i_notifications4.rethrowColaboError)(error);
669
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
670
+ }
671
+ return result;
703
672
  }
704
- createWithColaboApi(request) {
705
- return __async(this, null, function* () {
706
- var _a, _b;
707
- request.type = import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API;
708
- let result;
709
- const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API + ".json";
710
- console.log("[getVos] url: ", url);
711
- let mResult;
712
- try {
713
- mResult = yield import_axios3.default.post(url, request);
714
- } catch (error) {
715
- console.error(`${import_i_core10.contextReportText}Error updating: ${error}`);
716
- return Promise.reject(error);
673
+ async createWithColaboApi(request) {
674
+ request.type = import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API;
675
+ let result;
676
+ const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API + ".json";
677
+ console.log("[getVos] url: ", url);
678
+ let mResult;
679
+ try {
680
+ mResult = await import_axios3.default.post(url, request);
681
+ } catch (error) {
682
+ console.error(`${import_i_core10.contextReportText}Error updating: ${error}`);
683
+ return Promise.reject(error);
684
+ }
685
+ try {
686
+ const serverData = mResult.data;
687
+ if (!serverData.success) {
688
+ console.error(`Error creating: [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
689
+ return Promise.reject(serverData);
717
690
  }
718
- try {
719
- const serverData = mResult.data;
720
- if (!serverData.success) {
721
- console.error(`Error creating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
722
- return Promise.reject(serverData);
723
- }
724
- result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
725
- if (!result) {
726
- return Promise.reject(new Error("Error with extracting VOs from serverData"));
727
- }
728
- } catch (error) {
729
- console.error(error);
730
- return Promise.reject(error);
691
+ result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
692
+ if (!result) {
693
+ return Promise.reject(new Error("Error with extracting VOs from serverData"));
731
694
  }
732
- return result;
733
- });
695
+ } catch (error) {
696
+ console.error(error);
697
+ return Promise.reject(error);
698
+ }
699
+ return result;
734
700
  }
735
701
  /** destroys the Element (VO) with the `_id === id` */
736
702
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
737
- destroy(id) {
738
- return __async(this, null, function* () {
739
- return true;
740
- });
703
+ async destroy(id) {
704
+ return true;
741
705
  }
742
- destroyWithColaboApi(request) {
743
- return __async(this, null, function* () {
744
- request.type = import_i_core10.KNODE_API_TYPE.DESTROY_COLABO_API;
745
- const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
746
- let result;
747
- const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
748
- console.log("[getVos] url: ", url);
749
- const mResult = yield import_axios3.default.delete(url);
750
- try {
751
- const serverData = mResult.data;
752
- result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
753
- if (!result) {
754
- return Promise.reject(new Error("Error with extracting VOs from serverData"));
755
- }
756
- } catch (error) {
757
- console.error(error);
758
- return Promise.reject(error);
706
+ async destroyWithColaboApi(request) {
707
+ request.type = import_i_core10.KNODE_API_TYPE.DESTROY_COLABO_API;
708
+ const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
709
+ let result;
710
+ const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
711
+ console.log("[getVos] url: ", url);
712
+ const mResult = await import_axios3.default.delete(url);
713
+ try {
714
+ const serverData = mResult.data;
715
+ result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
716
+ if (!result) {
717
+ return Promise.reject(new Error("Error with extracting VOs from serverData"));
759
718
  }
760
- return result;
761
- });
719
+ } catch (error) {
720
+ console.error(error);
721
+ return Promise.reject(error);
722
+ }
723
+ return result;
762
724
  }
763
725
  /** gets Elements (VOs) to populate the list */
764
726
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -791,24 +753,22 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
791
753
  this.knAllEdgeRealTimeService = null;
792
754
  console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
793
755
  }
794
- queryByIds(ids, callback) {
795
- return __async(this, null, function* () {
796
- console.log("queryByIds", ids);
797
- const idsStr = ids.join(",");
798
- const url = this.apiUrl + import_i_core15.KNODE_API_TYPE.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
799
- try {
800
- const mResult = yield import_axios4.default.get(url);
801
- const serverData = mResult.data;
802
- const result = CFServiceIsomorphic.processVOs(serverData, import_i_core14.KNodeFrontend);
803
- if (callback) {
804
- callback(result);
805
- }
806
- return result;
807
- } catch (error) {
808
- (0, import_i_notifications6.rethrowColaboError)(error);
809
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
756
+ async queryByIds(ids, callback) {
757
+ console.log("queryByIds", ids);
758
+ const idsStr = ids.join(",");
759
+ const url = this.apiUrl + import_i_core15.KNODE_API_TYPE.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
760
+ try {
761
+ const mResult = await import_axios4.default.get(url);
762
+ const serverData = mResult.data;
763
+ const result = CFServiceIsomorphic.processVOs(serverData, import_i_core14.KNodeFrontend);
764
+ if (callback) {
765
+ callback(result);
810
766
  }
811
- });
767
+ return result;
768
+ } catch (error) {
769
+ (0, import_i_notifications6.rethrowColaboError)(error);
770
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
771
+ }
812
772
  }
813
773
  /**
814
774
  * BREAKING CHANGE: removed as the code is old, sending raw request to backend instead of `IApiRequest`. The right version is available in the `ColaboKnAllEdgeNodeService` class with the same name
@@ -869,21 +829,19 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
869
829
  * @example URL:http://localhost:8001/knodes/one/default/5a156965d0b7970f365e1a4b.json
870
830
  */
871
831
  // eslint-disable-next-line @typescript-eslint/ban-types
872
- destroy(id, callback) {
873
- return __async(this, null, function* () {
874
- try {
875
- const mResult = yield import_axios4.default.delete(this.apiUrl + "one/" + this.defaultAction + "/" + id, HTTP_OPTIONS_CONST_JSON);
876
- const serverData = mResult.data;
877
- const result = serverData.success;
878
- if (callback) {
879
- callback(result);
880
- }
881
- return result;
882
- } catch (error) {
883
- (0, import_i_notifications6.rethrowColaboError)(error);
884
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
832
+ async destroy(id, callback) {
833
+ try {
834
+ const mResult = await import_axios4.default.delete(this.apiUrl + "one/" + this.defaultAction + "/" + id, HTTP_OPTIONS_CONST_JSON);
835
+ const serverData = mResult.data;
836
+ const result = serverData.success;
837
+ if (callback) {
838
+ callback(result);
885
839
  }
886
- });
840
+ return result;
841
+ } catch (error) {
842
+ (0, import_i_notifications6.rethrowColaboError)(error);
843
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
844
+ }
887
845
  }
888
846
  /**
889
847
  * Updates the provided node on the server and returns its server-updated appearance
@@ -896,34 +854,32 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
896
854
  http://localhost:8001/knodes/one/UPDATE_NODE_NAME_FINAL/5a156935d0b7970f365e1a42.json
897
855
  */
898
856
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
899
- update(kNode, actionType, patch, callback) {
900
- return __async(this, null, function* () {
901
- function updateResponse(nodeFromServer) {
902
- const responseTime = /* @__PURE__ */ new Date();
903
- }
904
- let result;
905
- const id = kNode._id;
906
- const kNodeForServer = patch ? patch : kNode.toServerCopy();
907
- actionType = actionType !== null ? actionType : ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL;
908
- if (kNode.state == import_i_core14.VOFrontend.STATE_LOCAL) {
909
- window.alert(`Please, wait while the entity '${kNode.name}' is being saved, before updating it`);
910
- result = void 0;
911
- return result;
912
- } else {
913
- try {
914
- const mResult = yield import_axios4.default.put(this.apiUrl + "one/" + actionType + "/" + id, kNodeForServer, HTTP_OPTIONS_CONST_JSON);
915
- const serverData = mResult.data;
916
- const result2 = this.extractVO(serverData, import_i_core14.KNodeFrontend);
917
- if (callback) {
918
- callback(result2);
919
- }
920
- return result2;
921
- } catch (error) {
922
- (0, import_i_notifications6.rethrowColaboError)(error);
923
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
857
+ async update(kNode, actionType, patch, callback) {
858
+ function updateResponse(nodeFromServer) {
859
+ const responseTime = /* @__PURE__ */ new Date();
860
+ }
861
+ let result;
862
+ const id = kNode._id;
863
+ const kNodeForServer = patch ? patch : kNode.toServerCopy();
864
+ actionType = actionType !== null ? actionType : ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL;
865
+ if (kNode.state == import_i_core14.VOFrontend.STATE_LOCAL) {
866
+ window.alert(`Please, wait while the entity '${kNode.name}' is being saved, before updating it`);
867
+ result = void 0;
868
+ return result;
869
+ } else {
870
+ try {
871
+ const mResult = await import_axios4.default.put(this.apiUrl + "one/" + actionType + "/" + id, kNodeForServer, HTTP_OPTIONS_CONST_JSON);
872
+ const serverData = mResult.data;
873
+ const result2 = this.extractVO(serverData, import_i_core14.KNodeFrontend);
874
+ if (callback) {
875
+ callback(result2);
924
876
  }
877
+ return result2;
878
+ } catch (error) {
879
+ (0, import_i_notifications6.rethrowColaboError)(error);
880
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
925
881
  }
926
- });
882
+ }
927
883
  }
928
884
  // getVOs(type: string): Observable<KNodeFrontend[] | undefined> {
929
885
  // return this.queryInMapofType(ColaboKnAllEdgeNodeServiceExtended.mapId, type);
@@ -1136,75 +1092,67 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
1136
1092
  this.apiUrl = KnalledgeEdgeService.serverAP + "/" + import_i_core18.KEDGE_API_PARAMS.API_PATH + "/";
1137
1093
  console.log("[KnalledgeEdgeService] REST API URL: ", import_i_core19.chalk.bold.white(this.apiUrl));
1138
1094
  }
1139
- getVosWithColaboApi(request) {
1140
- return __async(this, null, function* () {
1141
- request.type = import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API;
1142
- console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
1143
- const requestSerialized = import_i_core18.ColaboApiOperators.serializeApiRequest(request);
1144
- let result;
1145
- const url = this.apiUrl + import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized + ".json";
1146
- console.log("[getVos] url: ", url);
1147
- const mResult = yield import_axios5.default.get(url);
1148
- try {
1149
- const serverData = mResult.data;
1150
- result = import_i_core18.ColaboApiOperators.extractVosFromServerData(serverData);
1151
- if (!result) {
1152
- return Promise.reject(new Error("Error with extracting VOs from serverData"));
1153
- }
1154
- } catch (error) {
1155
- console.error(error);
1156
- return Promise.reject(error);
1095
+ async getVosWithColaboApi(request) {
1096
+ request.type = import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API;
1097
+ console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
1098
+ const requestSerialized = import_i_core18.ColaboApiOperators.serializeApiRequest(request);
1099
+ let result;
1100
+ const url = this.apiUrl + import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized + ".json";
1101
+ console.log("[getVos] url: ", url);
1102
+ const mResult = await import_axios5.default.get(url);
1103
+ try {
1104
+ const serverData = mResult.data;
1105
+ result = import_i_core18.ColaboApiOperators.extractVosFromServerData(serverData);
1106
+ if (!result) {
1107
+ return Promise.reject(new Error("Error with extracting VOs from serverData"));
1157
1108
  }
1158
- return result;
1159
- });
1109
+ } catch (error) {
1110
+ console.error(error);
1111
+ return Promise.reject(error);
1112
+ }
1113
+ return result;
1160
1114
  }
1161
1115
  /** creates a new Element (VO) */
1162
1116
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
1163
- createWithPromise(kEdge, callback) {
1164
- return __async(this, null, function* () {
1165
- var _a, _b;
1166
- console.log(`${(0, import_i_core18.contextReportText)()}`);
1167
- let result;
1168
- const request = {
1169
- type: import_i_core18.KEDGE_API_TYPE.CREATE_COLABO_API,
1170
- data: kEdge
1171
- };
1172
- const url = this.apiUrl;
1173
- try {
1174
- const mResult = yield import_axios5.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
1175
- const serverData = mResult.data;
1176
- if (!serverData.success) {
1177
- throw new Error(`${import_i_core18.contextReportText} Error creating edge. code: ${(_a = serverData.error) == null ? void 0 : _a.kind}, error msg: ${(_b = serverData.error) == null ? void 0 : _b.message}`);
1178
- }
1179
- result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
1180
- } catch (error) {
1181
- console.error(error);
1182
- return Promise.reject(error);
1117
+ async createWithPromise(kEdge, callback) {
1118
+ console.log(`${(0, import_i_core18.contextReportText)()}`);
1119
+ let result;
1120
+ const request = {
1121
+ type: import_i_core18.KEDGE_API_TYPE.CREATE_COLABO_API,
1122
+ data: kEdge
1123
+ };
1124
+ const url = this.apiUrl;
1125
+ try {
1126
+ const mResult = await import_axios5.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
1127
+ const serverData = mResult.data;
1128
+ if (!serverData.success) {
1129
+ throw new Error(`${import_i_core18.contextReportText} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
1183
1130
  }
1184
- return result;
1185
- });
1131
+ result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
1132
+ } catch (error) {
1133
+ console.error(error);
1134
+ return Promise.reject(error);
1135
+ }
1136
+ return result;
1186
1137
  }
1187
1138
  /** creates a new Element (VO) */
1188
1139
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
1189
- createWithRequest(request) {
1190
- return __async(this, null, function* () {
1191
- var _a, _b;
1192
- console.log(`${(0, import_i_core18.contextReportText)()}`);
1193
- let result;
1194
- const url = this.apiUrl;
1195
- try {
1196
- const mResult = yield import_axios5.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
1197
- const serverData = mResult.data;
1198
- if (!serverData.success) {
1199
- throw new Error(`${import_i_core18.contextReportText} Error creating edge. code: ${(_a = serverData.error) == null ? void 0 : _a.kind}, error msg: ${(_b = serverData.error) == null ? void 0 : _b.message}`);
1200
- }
1201
- result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
1202
- } catch (error) {
1203
- console.error(error);
1204
- return Promise.reject(error);
1140
+ async createWithRequest(request) {
1141
+ console.log(`${(0, import_i_core18.contextReportText)()}`);
1142
+ let result;
1143
+ const url = this.apiUrl;
1144
+ try {
1145
+ const mResult = await import_axios5.default.post(url, request, HTTP_OPTIONS_CONST_JSON);
1146
+ const serverData = mResult.data;
1147
+ if (!serverData.success) {
1148
+ throw new Error(`${import_i_core18.contextReportText} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
1205
1149
  }
1206
- return result;
1207
- });
1150
+ result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
1151
+ } catch (error) {
1152
+ console.error(error);
1153
+ return Promise.reject(error);
1154
+ }
1155
+ return result;
1208
1156
  }
1209
1157
  };
1210
1158
  KnalledgeEdgeService = __decorateClass([
@@ -1235,23 +1183,21 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
1235
1183
  * @returns {Observable<KEdge>} retrieved edge
1236
1184
  */
1237
1185
  // eslint-disable-next-line @typescript-eslint/ban-types
1238
- getById(id, callback) {
1239
- return __async(this, null, function* () {
1240
- console.log("getById(" + id + ")");
1241
- const url = this.apiUrl + "one/" + id;
1242
- try {
1243
- const mResult = yield import_axios6.default.get(url);
1244
- const serverData = mResult.data;
1245
- const result = this.extractVO(serverData, import_i_core22.KEdgeFrontend);
1246
- if (callback) {
1247
- callback(result);
1248
- }
1249
- return result;
1250
- } catch (error) {
1251
- (0, import_i_notifications8.rethrowColaboError)(error);
1252
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1186
+ async getById(id, callback) {
1187
+ console.log("getById(" + id + ")");
1188
+ const url = this.apiUrl + "one/" + id;
1189
+ try {
1190
+ const mResult = await import_axios6.default.get(url);
1191
+ const serverData = mResult.data;
1192
+ const result = this.extractVO(serverData, import_i_core22.KEdgeFrontend);
1193
+ if (callback) {
1194
+ callback(result);
1253
1195
  }
1254
- });
1196
+ return result;
1197
+ } catch (error) {
1198
+ (0, import_i_notifications8.rethrowColaboError)(error);
1199
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1200
+ }
1255
1201
  }
1256
1202
  /**
1257
1203
  * Creates the provided edge on the server and returns its server-updated appearance
@@ -1260,29 +1206,27 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
1260
1206
  * @returns {Observable<KEdge>} the created edge (now with the id and other specific data allocated to it by server, so the caller should fill the original edge with it)
1261
1207
  @example http://localhost:8001/kedges/in_map/default/579811d88e12abfa556f6b59.json
1262
1208
  */
1263
- create(kEdge, callback) {
1264
- return __async(this, null, function* () {
1265
- let result;
1266
- if (false) {
1267
- } else {
1268
- if (!kEdge.toServerCopy) {
1269
- throw new Error("kEdge.toServerCopy is not defined");
1270
- }
1271
- const kEdgeForServer = kEdge.toServerCopy();
1272
- try {
1273
- const mResult = yield import_axios6.default.post(this.apiUrl, kEdgeForServer, HTTP_OPTIONS_CONST_JSON);
1274
- const serverData = mResult.data;
1275
- const result2 = this.extractVO(serverData, import_i_core22.KEdgeFrontend);
1276
- if (callback) {
1277
- callback(result2);
1278
- }
1279
- return result2;
1280
- } catch (error) {
1281
- (0, import_i_notifications8.rethrowColaboError)(error);
1282
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1209
+ async create(kEdge, callback) {
1210
+ let result;
1211
+ if (false) {
1212
+ } else {
1213
+ if (!kEdge.toServerCopy) {
1214
+ throw new Error("kEdge.toServerCopy is not defined");
1215
+ }
1216
+ const kEdgeForServer = kEdge.toServerCopy();
1217
+ try {
1218
+ const mResult = await import_axios6.default.post(this.apiUrl, kEdgeForServer, HTTP_OPTIONS_CONST_JSON);
1219
+ const serverData = mResult.data;
1220
+ const result2 = this.extractVO(serverData, import_i_core22.KEdgeFrontend);
1221
+ if (callback) {
1222
+ callback(result2);
1283
1223
  }
1224
+ return result2;
1225
+ } catch (error) {
1226
+ (0, import_i_notifications8.rethrowColaboError)(error);
1227
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1284
1228
  }
1285
- });
1229
+ }
1286
1230
  }
1287
1231
  /**
1288
1232
  * Deletes the KEdge from the server
@@ -1291,21 +1235,19 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
1291
1235
  * @param {function} callback Function to be called when the edge is deleted
1292
1236
  * @example URL:http://localhost:8001/kedges/one/default/5a156965d0b7970f365e1a4b.json
1293
1237
  */
1294
- destroy(id, callback) {
1295
- return __async(this, null, function* () {
1296
- try {
1297
- const mResult = yield import_axios6.default.delete(this.apiUrl + "one/" + id, HTTP_OPTIONS_CONST_JSON);
1298
- const serverData = mResult.data;
1299
- const result = serverData.success;
1300
- if (callback) {
1301
- callback(result);
1302
- }
1303
- return result;
1304
- } catch (error) {
1305
- (0, import_i_notifications8.rethrowColaboError)(error);
1306
- throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1238
+ async destroy(id, callback) {
1239
+ try {
1240
+ const mResult = await import_axios6.default.delete(this.apiUrl + "one/" + id, HTTP_OPTIONS_CONST_JSON);
1241
+ const serverData = mResult.data;
1242
+ const result = serverData.success;
1243
+ if (callback) {
1244
+ callback(result);
1307
1245
  }
1308
- });
1246
+ return result;
1247
+ } catch (error) {
1248
+ (0, import_i_notifications8.rethrowColaboError)(error);
1249
+ throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
1250
+ }
1309
1251
  }
1310
1252
  // /*
1311
1253
  // TODO: