@colabo-knalledge/i-core-services 1.1.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/CHANGELOG.md +15 -0
- package/dist/cjs/index.js +420 -495
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +420 -495
- package/dist/esm/index.js.map +1 -1
- package/package.json +16 -9
package/dist/cjs/index.js
CHANGED
|
@@ -34,26 +34,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
34
34
|
if (kind && result) __defProp(target, key, result);
|
|
35
35
|
return result;
|
|
36
36
|
};
|
|
37
|
-
var __async = (__this, __arguments, generator) => {
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
var fulfilled = (value) => {
|
|
40
|
-
try {
|
|
41
|
-
step(generator.next(value));
|
|
42
|
-
} catch (e) {
|
|
43
|
-
reject(e);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var rejected = (value) => {
|
|
47
|
-
try {
|
|
48
|
-
step(generator.throw(value));
|
|
49
|
-
} catch (e) {
|
|
50
|
-
reject(e);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
54
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
37
|
|
|
58
38
|
// index.ts
|
|
59
39
|
var index_exports = {};
|
|
@@ -229,6 +209,9 @@ var errorInterceptor = (error) => {
|
|
|
229
209
|
};
|
|
230
210
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService] declaring ColaboApiCoreService class");
|
|
231
211
|
var ColaboApiCoreService = class {
|
|
212
|
+
static {
|
|
213
|
+
this.interceptorsForAxios = /* @__PURE__ */ new Map();
|
|
214
|
+
}
|
|
232
215
|
// Add a response interceptor to remove JSONP prefix that Colabo.Space is sending
|
|
233
216
|
// https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
|
|
234
217
|
// https://stackoverflow.com/questions/33967189/angular-not-removing-json-prefix
|
|
@@ -264,7 +247,6 @@ var ColaboApiCoreService = class {
|
|
|
264
247
|
}
|
|
265
248
|
}
|
|
266
249
|
};
|
|
267
|
-
ColaboApiCoreService.interceptorsForAxios = /* @__PURE__ */ new Map();
|
|
268
250
|
(0, import_i_core3.injectInterceptorService)(ColaboApiCoreService);
|
|
269
251
|
|
|
270
252
|
// lib/kContainer-service.ts
|
|
@@ -298,77 +280,71 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
298
280
|
console.log("[ColaboKnAllEdgeContainerService] created");
|
|
299
281
|
this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + import_i_core4.KCONTAINER_API_PARAMS.API_PATH + "/";
|
|
300
282
|
}
|
|
301
|
-
getById(id) {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
|
|
312
|
-
}
|
|
313
|
-
if (import_i_core4.ColaboApiOperators.getParentEntity(result).type != import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
|
|
314
|
-
return Promise.reject(new Error("Wrong entity type, expected: " + import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
|
|
315
|
-
}
|
|
316
|
-
} catch (error) {
|
|
317
|
-
console.error(error);
|
|
318
|
-
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"));
|
|
319
293
|
}
|
|
320
|
-
|
|
321
|
-
|
|
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;
|
|
322
302
|
}
|
|
323
|
-
create(kContainerWContent) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
console.warn("EMAIL_EXISTS");
|
|
344
|
-
}
|
|
345
|
-
return error.response.data;
|
|
346
|
-
} else if (error.request) {
|
|
347
|
-
console.error("No response received");
|
|
348
|
-
} else {
|
|
349
|
-
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");
|
|
350
323
|
}
|
|
351
|
-
|
|
352
|
-
|
|
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);
|
|
353
329
|
}
|
|
354
|
-
|
|
330
|
+
(0, import_i_notifications3.rethrowColaboError)(error);
|
|
331
|
+
throw new import_i_notifications3.ColaboErrorUnreachable();
|
|
332
|
+
}
|
|
355
333
|
}
|
|
356
|
-
update(kContainer) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return result;
|
|
371
|
-
});
|
|
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;
|
|
372
348
|
}
|
|
373
349
|
/**
|
|
374
350
|
/**
|
|
@@ -379,19 +355,17 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
379
355
|
* @return {*} {Promise<boolean>}
|
|
380
356
|
* @memberof ColaboKnAllEdgeContainerService
|
|
381
357
|
*/
|
|
382
|
-
destroy(id) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
});
|
|
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
|
+
}
|
|
395
369
|
}
|
|
396
370
|
/**
|
|
397
371
|
* @param containerId The id of the kContainer to which we want to add kNodes
|
|
@@ -399,23 +373,21 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
399
373
|
* @description adds kNodes in a kContainer
|
|
400
374
|
* @returns edges created between the container and entities added to the container
|
|
401
375
|
*/
|
|
402
|
-
updateAddNodes(containerId, containedIds) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return result;
|
|
418
|
-
});
|
|
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;
|
|
419
391
|
}
|
|
420
392
|
/**
|
|
421
393
|
* removes kNodes from a kContainer
|
|
@@ -424,67 +396,61 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
424
396
|
* @param ids The list of ids of the kNodes we want to remove from the container
|
|
425
397
|
* @returns edges created between the container and entities added to the container
|
|
426
398
|
*/
|
|
427
|
-
updateRemoveNodes(id, ids) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
return result;
|
|
443
|
-
});
|
|
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;
|
|
444
414
|
}
|
|
445
415
|
/**
|
|
446
416
|
*
|
|
447
417
|
* @param id The id of the kContainer which knodes we want to retrieve
|
|
448
418
|
* @description retrieves kNodes in a kContainer
|
|
449
419
|
*/
|
|
450
|
-
getInContainer(id) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return [];
|
|
460
|
-
}
|
|
461
|
-
const processedResponse = CFServiceIsomorphic.processVOs(response, import_i_core4.KNodeFrontend);
|
|
462
|
-
if (DEBUG_VERBOSE) console.log("[ColaboKnAllEdgeContainerService::getInContainer] response<KNodeFrontend>: ", JSON.stringify(processedResponse, null, 4));
|
|
463
|
-
return processedResponse;
|
|
464
|
-
} catch (error) {
|
|
465
|
-
(0, import_i_notifications3.rethrowColaboError)(error);
|
|
466
|
-
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 [];
|
|
467
429
|
}
|
|
468
|
-
|
|
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
|
+
}
|
|
469
437
|
}
|
|
470
438
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
471
|
-
getVOs(type, upperLayerType) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return Promise.reject(new Error("Couldn't extract VOs from the serverData"));
|
|
481
|
-
}
|
|
482
|
-
} catch (error) {
|
|
483
|
-
console.error(error);
|
|
484
|
-
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"));
|
|
485
448
|
}
|
|
486
|
-
|
|
487
|
-
|
|
449
|
+
} catch (error) {
|
|
450
|
+
console.error(error);
|
|
451
|
+
return Promise.reject(error);
|
|
452
|
+
}
|
|
453
|
+
return result;
|
|
488
454
|
}
|
|
489
455
|
/**
|
|
490
456
|
* Extracts upper-layer entity from kContainer and sets it up
|
|
@@ -594,188 +560,167 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
594
560
|
*/
|
|
595
561
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
596
562
|
// OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
|
|
597
|
-
getById(id) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
throw e;
|
|
610
|
-
}
|
|
611
|
-
const error = e;
|
|
612
|
-
if (error.response) {
|
|
613
|
-
} else if (error.request) {
|
|
614
|
-
(0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
|
|
615
|
-
} else {
|
|
616
|
-
console.error("[ColaboKnAllEdgeNodeService:getById] Error during request setup:");
|
|
617
|
-
(0, import_i_notifications4.throwColaboError)(error.message, import_i_notifications4.EErrorOrigin.SYSTEM, import_i_notifications4.EColaboErrorKind.REQUEST_BAD);
|
|
618
|
-
}
|
|
619
|
-
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;
|
|
620
575
|
}
|
|
621
|
-
|
|
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);
|
|
583
|
+
}
|
|
584
|
+
throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
|
|
585
|
+
}
|
|
622
586
|
}
|
|
623
|
-
getVosWithColaboApi(request) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
637
|
-
}
|
|
638
|
-
} catch (error) {
|
|
639
|
-
console.error(error);
|
|
640
|
-
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"));
|
|
641
600
|
}
|
|
642
|
-
|
|
643
|
-
|
|
601
|
+
} catch (error) {
|
|
602
|
+
console.error(error);
|
|
603
|
+
return Promise.reject(error);
|
|
604
|
+
}
|
|
605
|
+
return result;
|
|
644
606
|
}
|
|
645
|
-
updateSingleWithColaboApi(request) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
return kNodes[0];
|
|
651
|
-
});
|
|
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];
|
|
652
612
|
}
|
|
653
|
-
updateWithColaboApi(request) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
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);
|
|
666
630
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
console.error(`Error updating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
671
|
-
return Promise.reject(serverData);
|
|
672
|
-
}
|
|
673
|
-
result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
|
|
674
|
-
if (!result) {
|
|
675
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
676
|
-
}
|
|
677
|
-
} catch (error) {
|
|
678
|
-
console.error(error);
|
|
679
|
-
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"));
|
|
680
634
|
}
|
|
681
|
-
|
|
682
|
-
|
|
635
|
+
} catch (error) {
|
|
636
|
+
console.error(error);
|
|
637
|
+
return Promise.reject(error);
|
|
638
|
+
}
|
|
639
|
+
return result;
|
|
683
640
|
}
|
|
684
641
|
// getVOs(type:string):Observable<KNodeFrontend[]> {
|
|
685
642
|
// return this.queryInMapofType(ColaboKnAllEdgeNodeService.mapId,type);
|
|
686
643
|
// }
|
|
687
|
-
createSingle(kNode) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
return kNodeCreated;
|
|
693
|
-
});
|
|
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;
|
|
694
649
|
}
|
|
695
650
|
/** creates a new Element (VO) */
|
|
696
651
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
697
|
-
create(kNode, callback) {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
if (!serverData.success) {
|
|
711
|
-
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}`);
|
|
712
|
-
}
|
|
713
|
-
result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
714
|
-
} catch (error) {
|
|
715
|
-
(0, import_i_notifications4.rethrowColaboError)(error);
|
|
716
|
-
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}`);
|
|
717
665
|
}
|
|
718
|
-
|
|
719
|
-
})
|
|
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;
|
|
720
672
|
}
|
|
721
|
-
createWithColaboApi(request) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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);
|
|
734
690
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
console.error(`Error creating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
739
|
-
return Promise.reject(serverData);
|
|
740
|
-
}
|
|
741
|
-
result = import_i_core10.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
742
|
-
if (!result) {
|
|
743
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
744
|
-
}
|
|
745
|
-
} catch (error) {
|
|
746
|
-
console.error(error);
|
|
747
|
-
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"));
|
|
748
694
|
}
|
|
749
|
-
|
|
750
|
-
|
|
695
|
+
} catch (error) {
|
|
696
|
+
console.error(error);
|
|
697
|
+
return Promise.reject(error);
|
|
698
|
+
}
|
|
699
|
+
return result;
|
|
751
700
|
}
|
|
752
701
|
/** destroys the Element (VO) with the `_id === id` */
|
|
753
702
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
754
|
-
destroy(id) {
|
|
755
|
-
return
|
|
756
|
-
return true;
|
|
757
|
-
});
|
|
703
|
+
async destroy(id) {
|
|
704
|
+
return true;
|
|
758
705
|
}
|
|
759
|
-
destroyWithColaboApi(request) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
772
|
-
}
|
|
773
|
-
} catch (error) {
|
|
774
|
-
console.error(error);
|
|
775
|
-
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"));
|
|
776
718
|
}
|
|
777
|
-
|
|
778
|
-
|
|
719
|
+
} catch (error) {
|
|
720
|
+
console.error(error);
|
|
721
|
+
return Promise.reject(error);
|
|
722
|
+
}
|
|
723
|
+
return result;
|
|
779
724
|
}
|
|
780
725
|
/** gets Elements (VOs) to populate the list */
|
|
781
726
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -808,24 +753,22 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
808
753
|
this.knAllEdgeRealTimeService = null;
|
|
809
754
|
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
810
755
|
}
|
|
811
|
-
queryByIds(ids, callback) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
callback(result);
|
|
822
|
-
}
|
|
823
|
-
return result;
|
|
824
|
-
} catch (error) {
|
|
825
|
-
(0, import_i_notifications6.rethrowColaboError)(error);
|
|
826
|
-
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);
|
|
827
766
|
}
|
|
828
|
-
|
|
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
|
+
}
|
|
829
772
|
}
|
|
830
773
|
/**
|
|
831
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
|
|
@@ -886,21 +829,19 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
886
829
|
* @example URL:http://localhost:8001/knodes/one/default/5a156965d0b7970f365e1a4b.json
|
|
887
830
|
*/
|
|
888
831
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
889
|
-
destroy(id, callback) {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
callback(result);
|
|
897
|
-
}
|
|
898
|
-
return result;
|
|
899
|
-
} catch (error) {
|
|
900
|
-
(0, import_i_notifications6.rethrowColaboError)(error);
|
|
901
|
-
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);
|
|
902
839
|
}
|
|
903
|
-
|
|
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
|
+
}
|
|
904
845
|
}
|
|
905
846
|
/**
|
|
906
847
|
* Updates the provided node on the server and returns its server-updated appearance
|
|
@@ -913,34 +854,32 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
913
854
|
http://localhost:8001/knodes/one/UPDATE_NODE_NAME_FINAL/5a156935d0b7970f365e1a42.json
|
|
914
855
|
*/
|
|
915
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
|
|
916
|
-
update(kNode, actionType, patch, callback) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
callback(result2);
|
|
936
|
-
}
|
|
937
|
-
return result2;
|
|
938
|
-
} catch (error) {
|
|
939
|
-
(0, import_i_notifications6.rethrowColaboError)(error);
|
|
940
|
-
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);
|
|
941
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`");
|
|
942
881
|
}
|
|
943
|
-
}
|
|
882
|
+
}
|
|
944
883
|
}
|
|
945
884
|
// getVOs(type: string): Observable<KNodeFrontend[] | undefined> {
|
|
946
885
|
// return this.queryInMapofType(ColaboKnAllEdgeNodeServiceExtended.mapId, type);
|
|
@@ -1153,75 +1092,67 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1153
1092
|
this.apiUrl = KnalledgeEdgeService.serverAP + "/" + import_i_core18.KEDGE_API_PARAMS.API_PATH + "/";
|
|
1154
1093
|
console.log("[KnalledgeEdgeService] REST API URL: ", import_i_core19.chalk.bold.white(this.apiUrl));
|
|
1155
1094
|
}
|
|
1156
|
-
getVosWithColaboApi(request) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
1170
|
-
}
|
|
1171
|
-
} catch (error) {
|
|
1172
|
-
console.error(error);
|
|
1173
|
-
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"));
|
|
1174
1108
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1109
|
+
} catch (error) {
|
|
1110
|
+
console.error(error);
|
|
1111
|
+
return Promise.reject(error);
|
|
1112
|
+
}
|
|
1113
|
+
return result;
|
|
1177
1114
|
}
|
|
1178
1115
|
/** creates a new Element (VO) */
|
|
1179
1116
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1180
|
-
createWithPromise(kEdge, callback) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
if (!serverData.success) {
|
|
1194
|
-
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}`);
|
|
1195
|
-
}
|
|
1196
|
-
result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
1197
|
-
} catch (error) {
|
|
1198
|
-
console.error(error);
|
|
1199
|
-
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}`);
|
|
1200
1130
|
}
|
|
1201
|
-
|
|
1202
|
-
})
|
|
1131
|
+
result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
console.error(error);
|
|
1134
|
+
return Promise.reject(error);
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1203
1137
|
}
|
|
1204
1138
|
/** creates a new Element (VO) */
|
|
1205
1139
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1206
|
-
createWithRequest(request) {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
if (!serverData.success) {
|
|
1216
|
-
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}`);
|
|
1217
|
-
}
|
|
1218
|
-
result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
1219
|
-
} catch (error) {
|
|
1220
|
-
console.error(error);
|
|
1221
|
-
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}`);
|
|
1222
1149
|
}
|
|
1223
|
-
|
|
1224
|
-
})
|
|
1150
|
+
result = import_i_core18.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
1151
|
+
} catch (error) {
|
|
1152
|
+
console.error(error);
|
|
1153
|
+
return Promise.reject(error);
|
|
1154
|
+
}
|
|
1155
|
+
return result;
|
|
1225
1156
|
}
|
|
1226
1157
|
};
|
|
1227
1158
|
KnalledgeEdgeService = __decorateClass([
|
|
@@ -1252,23 +1183,21 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1252
1183
|
* @returns {Observable<KEdge>} retrieved edge
|
|
1253
1184
|
*/
|
|
1254
1185
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1255
|
-
getById(id, callback) {
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
callback(result);
|
|
1265
|
-
}
|
|
1266
|
-
return result;
|
|
1267
|
-
} catch (error) {
|
|
1268
|
-
(0, import_i_notifications8.rethrowColaboError)(error);
|
|
1269
|
-
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);
|
|
1270
1195
|
}
|
|
1271
|
-
|
|
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
|
+
}
|
|
1272
1201
|
}
|
|
1273
1202
|
/**
|
|
1274
1203
|
* Creates the provided edge on the server and returns its server-updated appearance
|
|
@@ -1277,29 +1206,27 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1277
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)
|
|
1278
1207
|
@example http://localhost:8001/kedges/in_map/default/579811d88e12abfa556f6b59.json
|
|
1279
1208
|
*/
|
|
1280
|
-
create(kEdge, callback) {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
callback(result2);
|
|
1295
|
-
}
|
|
1296
|
-
return result2;
|
|
1297
|
-
} catch (error) {
|
|
1298
|
-
(0, import_i_notifications8.rethrowColaboError)(error);
|
|
1299
|
-
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);
|
|
1300
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`");
|
|
1301
1228
|
}
|
|
1302
|
-
}
|
|
1229
|
+
}
|
|
1303
1230
|
}
|
|
1304
1231
|
/**
|
|
1305
1232
|
* Deletes the KEdge from the server
|
|
@@ -1308,21 +1235,19 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1308
1235
|
* @param {function} callback Function to be called when the edge is deleted
|
|
1309
1236
|
* @example URL:http://localhost:8001/kedges/one/default/5a156965d0b7970f365e1a4b.json
|
|
1310
1237
|
*/
|
|
1311
|
-
destroy(id, callback) {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
callback(result);
|
|
1319
|
-
}
|
|
1320
|
-
return result;
|
|
1321
|
-
} catch (error) {
|
|
1322
|
-
(0, import_i_notifications8.rethrowColaboError)(error);
|
|
1323
|
-
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);
|
|
1324
1245
|
}
|
|
1325
|
-
|
|
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
|
+
}
|
|
1326
1251
|
}
|
|
1327
1252
|
// /*
|
|
1328
1253
|
// TODO:
|