@colabo-knalledge/i-core-services 1.5.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/index.js +116 -64
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +123 -71
- package/dist/esm/index.js.map +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/cf.service.isomorphic.d.ts +1 -1
- package/dist/types/lib/colabo-api-core.service.d.ts +1 -0
- package/dist/types/lib/kContainer-service.d.ts +11 -5
- package/dist/types/lib/kEdge-service-extended.d.ts +1 -1
- package/dist/types/lib/kEdge-service.d.ts +1 -1
- package/dist/types/lib/kNode-service-extended.d.ts +2 -2
- package/dist/types/lib/kNode-service.d.ts +4 -2
- package/package.json +10 -10
package/dist/esm/index.js
CHANGED
|
@@ -26,7 +26,8 @@ import { Injectable } from "@colabo-headless/i-core";
|
|
|
26
26
|
import { EErrorOrigin, EColaboErrorKind, throwColaboError, ColaboErrorUnreachable } from "@colabo-utils/i-notifications";
|
|
27
27
|
import { NotificationMsgType } from "@colabo-utils/i-notifications";
|
|
28
28
|
import * as config from "@colabo-utils/i-config";
|
|
29
|
-
|
|
29
|
+
var DEBUG2 = false;
|
|
30
|
+
if (DEBUG2) console.log("[CFServiceIsomorphic] Injectable: ", Injectable);
|
|
30
31
|
var HIDE_ERRORS = true;
|
|
31
32
|
var HTTP_OPTIONS_CONST_JSON = {
|
|
32
33
|
headers: {
|
|
@@ -37,6 +38,11 @@ var CFServiceIsomorphic = class {
|
|
|
37
38
|
constructor(utilsNotificationService) {
|
|
38
39
|
this.utilsNotificationService = utilsNotificationService;
|
|
39
40
|
}
|
|
41
|
+
// RESTfull backend API url
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
43
|
+
static get serverAP() {
|
|
44
|
+
return config.GetString("serverUrl");
|
|
45
|
+
}
|
|
40
46
|
/**
|
|
41
47
|
* processes array of VOs received from server to a local/fronted version
|
|
42
48
|
* @param vofS
|
|
@@ -127,9 +133,6 @@ var CFServiceIsomorphic = class {
|
|
|
127
133
|
};
|
|
128
134
|
}
|
|
129
135
|
};
|
|
130
|
-
// RESTfull backend API url
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
132
|
-
CFServiceIsomorphic.serverAP = config.GetGeneral("serverUrl");
|
|
133
136
|
CFServiceIsomorphic = __decorateClass([
|
|
134
137
|
Injectable()
|
|
135
138
|
], CFServiceIsomorphic);
|
|
@@ -141,7 +144,7 @@ import { currentContext, CONTEXTS, Injectable as Injectable2, HttpClient } from
|
|
|
141
144
|
// lib/colabo-api-core.service.ts
|
|
142
145
|
import axios from "axios";
|
|
143
146
|
import { injectInterceptorService } from "@colabo-headless/i-core";
|
|
144
|
-
console.log("[ColaboApiCoreService] Initializing");
|
|
147
|
+
if (DEBUG) console.log("[ColaboApiCoreService] Initializing");
|
|
145
148
|
var responseInterceptor = (response) => {
|
|
146
149
|
if (DEBUG_VERBOSE) console.log("[axios::interceptor::colabo-api-core.service] response.data: ", JSON.stringify(response.data, null, 4));
|
|
147
150
|
if (typeof response.data !== "string") {
|
|
@@ -152,6 +155,10 @@ var responseInterceptor = (response) => {
|
|
|
152
155
|
response.data = JSON.parse(removeSecurityPrefix(data));
|
|
153
156
|
return response;
|
|
154
157
|
};
|
|
158
|
+
var addSecurityPrefix = (data) => {
|
|
159
|
+
const dataSecured = ")]}',\n" + JSON.stringify(data);
|
|
160
|
+
return dataSecured;
|
|
161
|
+
};
|
|
155
162
|
var removeSecurityPrefix = (data) => {
|
|
156
163
|
let index = data.indexOf("\r");
|
|
157
164
|
const indexN = data.indexOf("\n");
|
|
@@ -215,7 +222,6 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
215
222
|
this.utilsNotificationService = utilsNotificationService;
|
|
216
223
|
this.defaultAction = "default";
|
|
217
224
|
puzzleConfig = GetPuzzle(MODULE_NAME);
|
|
218
|
-
ColaboKnAllEdgeContainerService.serverAP = puzzleConfig.serverUrl;
|
|
219
225
|
if (!this.http) {
|
|
220
226
|
if (currentContext === CONTEXTS.FRONTEND_ANGULAR) {
|
|
221
227
|
const msg = "[ColaboKnAllEdgeContainerService] DI Problem: There is no provider injected for the service `HttpClient`.";
|
|
@@ -237,29 +243,34 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
237
243
|
console.log("[ColaboKnAllEdgeContainerService] created");
|
|
238
244
|
this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + KCONTAINER_API_PARAMS.API_PATH + "/";
|
|
239
245
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Retrieves the kContainer with a given ID. It retrieves only the kContainer kNode, not all the kNodes that are in the kContainer.
|
|
248
|
+
* @param id the id of the kContainer to be retrieved
|
|
249
|
+
* @returns
|
|
250
|
+
*/
|
|
251
|
+
async getById(id, fields) {
|
|
252
|
+
let retrievedKContainer;
|
|
253
|
+
const url = ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id, fields);
|
|
243
254
|
if (DEBUG) console.log("[getByIdPromise] url: ", url);
|
|
244
255
|
try {
|
|
245
256
|
const mResult = await axios2.get(url);
|
|
246
257
|
const serverData = mResult.data;
|
|
247
|
-
|
|
248
|
-
if (!
|
|
258
|
+
retrievedKContainer = ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
|
|
259
|
+
if (!retrievedKContainer) {
|
|
249
260
|
return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
|
|
250
261
|
}
|
|
251
|
-
if (ColaboApiOperators.getParentEntity(
|
|
262
|
+
if (ColaboApiOperators.getParentEntity(retrievedKContainer).type != KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
|
|
252
263
|
return Promise.reject(new Error("Wrong entity type, expected: " + KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
|
|
253
264
|
}
|
|
254
265
|
} catch (error) {
|
|
255
266
|
console.error(error);
|
|
256
267
|
return Promise.reject(error);
|
|
257
268
|
}
|
|
258
|
-
return
|
|
269
|
+
return retrievedKContainer;
|
|
259
270
|
}
|
|
260
271
|
async create(kContainerWContent) {
|
|
261
272
|
console.log("ColaboKnAllEdgeContainerService.create");
|
|
262
|
-
let
|
|
273
|
+
let createdKContainer;
|
|
263
274
|
const url = this.apiUrl;
|
|
264
275
|
try {
|
|
265
276
|
const requestRoot = {
|
|
@@ -268,8 +279,8 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
268
279
|
};
|
|
269
280
|
const mResult = await axios2.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
|
|
270
281
|
const serverData = mResult.data;
|
|
271
|
-
|
|
272
|
-
return
|
|
282
|
+
createdKContainer = ColaboApiOperators.extractVoFromServerData(serverData);
|
|
283
|
+
return createdKContainer;
|
|
273
284
|
} catch (error) {
|
|
274
285
|
if (error.response) {
|
|
275
286
|
console.log("[create]", error);
|
|
@@ -327,17 +338,19 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
327
338
|
/**
|
|
328
339
|
* @param containerId The id of the kContainer to which we want to add kNodes
|
|
329
340
|
* @param containedIds The list of ids of the kNodes we want to add to the container
|
|
341
|
+
* @param edgeDataContent Optional dataContent to set on the created edges (e.g. `{ type: "litterra.corpus.document" }`)
|
|
330
342
|
* @description adds kNodes in a kContainer
|
|
331
343
|
* @returns edges created between the container and entities added to the container
|
|
332
344
|
*/
|
|
333
|
-
async updateAddNodes(containerId, containedIds) {
|
|
345
|
+
async updateAddNodes(containerId, containedIds, edgeDataContent) {
|
|
334
346
|
if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
|
|
335
347
|
let result;
|
|
336
348
|
const idsStr = containedIds.join(",");
|
|
337
349
|
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
|
|
338
|
-
console.log("updateAddNodes called", url);
|
|
350
|
+
if (DEBUG) console.log("updateAddNodes called", url);
|
|
339
351
|
try {
|
|
340
|
-
const
|
|
352
|
+
const body = edgeDataContent ? { edgeDataContent } : {};
|
|
353
|
+
const mResult = await axios2.put(url, body, HTTP_OPTIONS_CONST_JSON);
|
|
341
354
|
const serverData = mResult.data;
|
|
342
355
|
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
343
356
|
} catch (error) {
|
|
@@ -371,14 +384,16 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
371
384
|
}
|
|
372
385
|
/**
|
|
373
386
|
*
|
|
374
|
-
* @param id The id of the kContainer which
|
|
387
|
+
* @param id The id of the kContainer which kNodes we want to retrieve
|
|
375
388
|
* @description retrieves kNodes in a kContainer
|
|
376
389
|
*/
|
|
377
|
-
async getInContainer(id) {
|
|
378
|
-
|
|
390
|
+
async getInContainer(id, fields, fetchFn) {
|
|
391
|
+
const url = ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json", fields);
|
|
379
392
|
if (DEBUG) console.log(`this.apiUrl:${this.apiUrl}, this.defaultAction:${this.defaultAction}`);
|
|
380
|
-
const url = `http://127.0.0.1:8001/kcontainers/` + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json";
|
|
381
393
|
try {
|
|
394
|
+
if (fetchFn) {
|
|
395
|
+
return await fetchFn(url);
|
|
396
|
+
}
|
|
382
397
|
const response = await this.http.get(url).toPromise();
|
|
383
398
|
if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
|
|
384
399
|
if (!response) {
|
|
@@ -393,11 +408,14 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
393
408
|
}
|
|
394
409
|
}
|
|
395
410
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
396
|
-
async getVOs(type, upperLayerType) {
|
|
411
|
+
async getVOs(type, upperLayerType, fields, fetchFn) {
|
|
397
412
|
let result;
|
|
398
|
-
const url = `${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json
|
|
399
|
-
const mResult = await axios2.get(url);
|
|
413
|
+
const url = ColaboApiOperators.appendFieldsParam(`${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`, fields);
|
|
400
414
|
try {
|
|
415
|
+
if (fetchFn) {
|
|
416
|
+
return await fetchFn(url);
|
|
417
|
+
}
|
|
418
|
+
const mResult = await axios2.get(url);
|
|
401
419
|
const serverData = mResult.data;
|
|
402
420
|
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
403
421
|
if (!result) {
|
|
@@ -466,7 +484,9 @@ import { GetPuzzle as GetPuzzle2 } from "@colabo-utils/i-config";
|
|
|
466
484
|
import { KNodeFrontend as KNodeFrontend2, KNODE_API_TYPE, ColaboApiOperators as ColaboApiOperators2, contextReportText } from "@colabo-knalledge/i-core";
|
|
467
485
|
import { NotificationMsgType as NotificationMsgType3 } from "@colabo-utils/i-notifications";
|
|
468
486
|
import { KNODE_API_PARAMS } from "@colabo-knalledge/i-core";
|
|
469
|
-
|
|
487
|
+
var DEBUG3 = false;
|
|
488
|
+
var DEBUG_VERBOSE2 = false;
|
|
489
|
+
if (DEBUG3) console.info(`[ColaboKnAllEdgeNodeService] Current context: ${currentContext2}`);
|
|
470
490
|
var class_id = 1;
|
|
471
491
|
var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
472
492
|
/**
|
|
@@ -498,15 +518,15 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
498
518
|
}
|
|
499
519
|
} else {
|
|
500
520
|
this.http = new HttpClient2(null);
|
|
501
|
-
console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
521
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
502
522
|
}
|
|
503
523
|
}
|
|
504
|
-
console.log("[ColaboKnAllEdgeNodeService] created");
|
|
524
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] created");
|
|
505
525
|
const puzzleConfig2 = GetPuzzle2(MODULE_NAME);
|
|
506
526
|
this.serverAP = puzzleConfig2.serverUrl;
|
|
507
|
-
console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", chalk.bold.white(this.serverAP));
|
|
527
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", chalk.bold.white(this.serverAP));
|
|
508
528
|
this.apiUrl = this.serverAP + "/" + KNODE_API_PARAMS.API_PATH + "/";
|
|
509
|
-
console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", chalk.bold.white(this.apiUrl));
|
|
529
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", chalk.bold.white(this.apiUrl));
|
|
510
530
|
}
|
|
511
531
|
/**
|
|
512
532
|
* Get a KN Node from the server by its `id`
|
|
@@ -517,10 +537,10 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
517
537
|
*/
|
|
518
538
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
519
539
|
// OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
|
|
520
|
-
async getById(id) {
|
|
521
|
-
const url = this.apiUrl + "one/" + this.defaultAction + "/" + id;
|
|
522
|
-
console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
|
|
523
|
-
console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
|
|
540
|
+
async getById(id, fields) {
|
|
541
|
+
const url = ColaboApiOperators2.appendFieldsParam(this.apiUrl + "one/" + this.defaultAction + "/" + id, fields);
|
|
542
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
|
|
543
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
|
|
524
544
|
try {
|
|
525
545
|
const result = await axios3.get(url);
|
|
526
546
|
const data = result.data;
|
|
@@ -541,14 +561,17 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
541
561
|
throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
|
|
542
562
|
}
|
|
543
563
|
}
|
|
544
|
-
async getVosWithColaboApi(request) {
|
|
564
|
+
async getVosWithColaboApi(request, fetchFn) {
|
|
545
565
|
request.type = KNODE_API_TYPE.INDEX_COLABO_API;
|
|
546
566
|
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
547
567
|
let result = [];
|
|
548
|
-
const url = this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
549
|
-
console.log("[getVos] url: ", url);
|
|
550
|
-
const mResult = await axios3.get(url);
|
|
568
|
+
const url = ColaboApiOperators2.appendFieldsParam(this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json", request.fields);
|
|
569
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
551
570
|
try {
|
|
571
|
+
if (fetchFn) {
|
|
572
|
+
return await fetchFn(url);
|
|
573
|
+
}
|
|
574
|
+
const mResult = await axios3.get(url);
|
|
552
575
|
const serverData = mResult.data;
|
|
553
576
|
if (!serverData) return result;
|
|
554
577
|
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
@@ -571,7 +594,8 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
571
594
|
request.type = KNODE_API_TYPE.UPDATE_COLABO_API;
|
|
572
595
|
let result;
|
|
573
596
|
const url = this.apiUrl + KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
|
|
574
|
-
console.log("[
|
|
597
|
+
if (DEBUG3) console.log("[updateWithColaboApi] url: ", url);
|
|
598
|
+
if (DEBUG_VERBOSE2) console.log("[updateWithColaboApi] request: ", JSON.stringify(request, null, 4));
|
|
575
599
|
let mResult;
|
|
576
600
|
try {
|
|
577
601
|
mResult = await axios3.put(url, request);
|
|
@@ -604,10 +628,24 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
604
628
|
const kNodeCreated = kNodesCreated[0];
|
|
605
629
|
return kNodeCreated;
|
|
606
630
|
}
|
|
631
|
+
/** creates multiple KNodes in a single bulk request */
|
|
632
|
+
async createBulk(kNodes) {
|
|
633
|
+
if (DEBUG_VERBOSE2) console.log(`${contextReportText(this)} bulk creating ${kNodes.length} nodes`);
|
|
634
|
+
const url = this.apiUrl + "bulk";
|
|
635
|
+
try {
|
|
636
|
+
const mResult = await axios3.post(url, kNodes, HTTP_OPTIONS_CONST_JSON);
|
|
637
|
+
const created = mResult.data;
|
|
638
|
+
if (DEBUG3) console.log(`${contextReportText(this)} bulk created ${created.length} nodes`);
|
|
639
|
+
return created;
|
|
640
|
+
} catch (error) {
|
|
641
|
+
rethrowColaboError2(error);
|
|
642
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
643
|
+
}
|
|
644
|
+
}
|
|
607
645
|
/** creates a new Element (VO) */
|
|
608
646
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
609
647
|
async create(kNode, callback) {
|
|
610
|
-
console.log(`${contextReportText()}`);
|
|
648
|
+
if (DEBUG_VERBOSE2) console.log(`${contextReportText(this)} creating node: name=${kNode.name}, type=${kNode.type}`);
|
|
611
649
|
let result;
|
|
612
650
|
const request = {
|
|
613
651
|
type: KNODE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -631,7 +669,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
631
669
|
request.type = KNODE_API_TYPE.CREATE_COLABO_API;
|
|
632
670
|
let result;
|
|
633
671
|
const url = this.apiUrl + KNODE_API_TYPE.CREATE_COLABO_API + ".json";
|
|
634
|
-
console.log("[getVos] url: ", url);
|
|
672
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
635
673
|
let mResult;
|
|
636
674
|
try {
|
|
637
675
|
mResult = await axios3.post(url, request);
|
|
@@ -665,7 +703,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
665
703
|
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
666
704
|
let result;
|
|
667
705
|
const url = this.apiUrl + KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
668
|
-
console.log("[getVos] url: ", url);
|
|
706
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
669
707
|
const mResult = await axios3.delete(url);
|
|
670
708
|
try {
|
|
671
709
|
const serverData = mResult.data;
|
|
@@ -696,9 +734,10 @@ import axios4 from "axios";
|
|
|
696
734
|
import { VOFrontend, KNodeFrontend as KNodeFrontend3 } from "@colabo-knalledge/i-core";
|
|
697
735
|
import { rethrowColaboError as rethrowColaboError3 } from "@colabo-utils/i-notifications";
|
|
698
736
|
import * as config2 from "@colabo-utils/i-config";
|
|
699
|
-
import { KNODE_API_TYPE as KNODE_API_TYPE2 } from "@colabo-knalledge/i-core";
|
|
700
|
-
|
|
701
|
-
console.log("[ColaboKnAllEdgeNodeServiceExtended]
|
|
737
|
+
import { KNODE_API_TYPE as KNODE_API_TYPE2, ColaboApiOperators as ColaboApiOperators3 } from "@colabo-knalledge/i-core";
|
|
738
|
+
var DEBUG4 = false;
|
|
739
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] Injectable: ", Injectable4);
|
|
740
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] HttpClient: ", HttpClient3);
|
|
702
741
|
var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeService {
|
|
703
742
|
// protected http:HttpClient = null;
|
|
704
743
|
// protected utilsNotificationService: UtilsNotificationService;
|
|
@@ -708,13 +747,22 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
708
747
|
this.knalledgeMapQueue = null;
|
|
709
748
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
710
749
|
this.knAllEdgeRealTimeService = null;
|
|
711
|
-
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
750
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
712
751
|
}
|
|
713
|
-
|
|
714
|
-
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
753
|
+
static get mapId() {
|
|
754
|
+
return config2.GetString("mapId");
|
|
755
|
+
}
|
|
756
|
+
async queryByIds(ids, fields, callback, fetchFn) {
|
|
757
|
+
if (DEBUG4) console.log("queryByIds", ids);
|
|
715
758
|
const idsStr = ids.join(",");
|
|
716
|
-
const url = this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
|
|
759
|
+
const url = ColaboApiOperators3.appendFieldsParam(this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json", fields);
|
|
717
760
|
try {
|
|
761
|
+
if (fetchFn) {
|
|
762
|
+
const rawNodes = await fetchFn(url);
|
|
763
|
+
if (callback) callback(rawNodes);
|
|
764
|
+
return rawNodes;
|
|
765
|
+
}
|
|
718
766
|
const mResult = await axios4.get(url);
|
|
719
767
|
const serverData = mResult.data;
|
|
720
768
|
const result = CFServiceIsomorphic.processVOs(serverData, KNodeFrontend3);
|
|
@@ -737,7 +785,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
737
785
|
*/
|
|
738
786
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
739
787
|
// async create(kNode: KNodeFrontend, callback?: Function): Promise<KNodeFrontend> {
|
|
740
|
-
// console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
788
|
+
// if(DEBUG) console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
741
789
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
742
790
|
// let kNodeForServer: any;
|
|
743
791
|
// if (kNode.toServerCopy) kNodeForServer = kNode.toServerCopy();
|
|
@@ -898,7 +946,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
898
946
|
// }
|
|
899
947
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
|
|
900
948
|
// queryInMapofTypeAndContentData(mapId: string, type: string, contentDataPath: string, data: any, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
901
|
-
// console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
949
|
+
// if(DEBUG) console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
902
950
|
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(
|
|
903
951
|
// this.apiUrl + "in_map_of_type_and_content_data/" + this.defaultAction + "/" + mapId + "/" + type + "/" + contentDataPath + "/" + data + ".json"
|
|
904
952
|
// ).pipe(
|
|
@@ -911,7 +959,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
911
959
|
// return result;
|
|
912
960
|
// }
|
|
913
961
|
// queryInMapofTypeForUser(mapId: string, type: string, iAmid: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
914
|
-
// console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
962
|
+
// if(DEBUG) console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
915
963
|
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map_of_type_for_user/" + this.defaultAction + "/" + mapId + "/" + type + "/" + iAmid + ".json").pipe(
|
|
916
964
|
// map((nodesFromServer) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
917
965
|
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMap", undefined))
|
|
@@ -925,7 +973,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
925
973
|
// destroyByTypeInMap(type: string, mapId: string, callback?: Function): Observable<boolean> {
|
|
926
974
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
927
975
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-in-map/" + this.defaultAction + "/" + type + "/" + mapId + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
928
|
-
// tap((_) => console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
976
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
929
977
|
// map((serverData: ServerData) => serverData.success),
|
|
930
978
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeInMap"))
|
|
931
979
|
// );
|
|
@@ -953,7 +1001,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
953
1001
|
// destroyByUser(iAmid: string): Observable<boolean> {
|
|
954
1002
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
955
1003
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-user/" + this.defaultAction + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
956
|
-
// tap((_: ServerData) => console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
1004
|
+
// tap((_: ServerData) => if(DEBUG) console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
957
1005
|
// map((serverData: ServerData) => serverData.success),
|
|
958
1006
|
// catchError(this.handleErrorForObservable<boolean>("destroyByUser"))
|
|
959
1007
|
// );
|
|
@@ -979,7 +1027,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
979
1027
|
// destroyByTypeByUser(type: string, iAmid: string, callback?: Function): Observable<boolean> {
|
|
980
1028
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
981
1029
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-n-user/" + this.defaultAction + "/" + type + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
982
|
-
// tap((_) => console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
1030
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
983
1031
|
// map((serverData: ServerData) => serverData.success),
|
|
984
1032
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeByUser"))
|
|
985
1033
|
// );
|
|
@@ -1005,8 +1053,6 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
1005
1053
|
// return result;
|
|
1006
1054
|
// }
|
|
1007
1055
|
};
|
|
1008
|
-
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
1009
|
-
ColaboKnAllEdgeNodeServiceExtended.mapId = config2.GetGeneral("mapId");
|
|
1010
1056
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL = "UPDATE_NODE_NAME_FINAL";
|
|
1011
1057
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME = "UPDATE_NODE_NAME";
|
|
1012
1058
|
ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
@@ -1016,11 +1062,13 @@ ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
|
1016
1062
|
// lib/kEdge-service.ts
|
|
1017
1063
|
import { Injectable as Injectable5 } from "@colabo-headless/i-core";
|
|
1018
1064
|
import { HttpClient as HttpClient4 } from "@colabo-headless/i-core";
|
|
1019
|
-
import { ColaboApiOperators as
|
|
1065
|
+
import { ColaboApiOperators as ColaboApiOperators4, KEDGE_API_TYPE, KEDGE_API_PARAMS, contextReportText as contextReportText2 } from "@colabo-knalledge/i-core";
|
|
1020
1066
|
import axios5 from "axios";
|
|
1021
1067
|
import { chalk as chalk2 } from "@colabo-headless/i-core";
|
|
1022
1068
|
import { currentContext as currentContext3, CONTEXTS as CONTEXTS3 } from "@colabo-headless/i-core";
|
|
1023
1069
|
import { NotificationMsgType as NotificationMsgType4 } from "@colabo-utils/i-notifications";
|
|
1070
|
+
var DEBUG5 = false;
|
|
1071
|
+
var DEBUG_VERBOSE3 = false;
|
|
1024
1072
|
var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
1025
1073
|
constructor(http, utilsNotificationService) {
|
|
1026
1074
|
super(utilsNotificationService);
|
|
@@ -1049,17 +1097,20 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1049
1097
|
this.apiUrl = KnalledgeEdgeService.serverAP + "/" + KEDGE_API_PARAMS.API_PATH + "/";
|
|
1050
1098
|
console.log("[KnalledgeEdgeService] REST API URL: ", chalk2.bold.white(this.apiUrl));
|
|
1051
1099
|
}
|
|
1052
|
-
async getVosWithColaboApi(request) {
|
|
1100
|
+
async getVosWithColaboApi(request, fetchFn) {
|
|
1053
1101
|
request.type = KEDGE_API_TYPE.INDEX_COLABO_API;
|
|
1054
1102
|
console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
|
|
1055
|
-
const requestSerialized =
|
|
1103
|
+
const requestSerialized = ColaboApiOperators4.serializeApiRequest(request);
|
|
1056
1104
|
let result;
|
|
1057
|
-
const url = this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized
|
|
1105
|
+
const url = ColaboApiOperators4.appendFieldsParam(this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized, request.fields);
|
|
1058
1106
|
console.log("[getVos] url: ", url);
|
|
1059
|
-
const mResult = await axios5.get(url);
|
|
1060
1107
|
try {
|
|
1108
|
+
if (fetchFn) {
|
|
1109
|
+
return await fetchFn(url);
|
|
1110
|
+
}
|
|
1111
|
+
const mResult = await axios5.get(url);
|
|
1061
1112
|
const serverData = mResult.data;
|
|
1062
|
-
result =
|
|
1113
|
+
result = ColaboApiOperators4.extractVosFromServerData(serverData);
|
|
1063
1114
|
if (!result) {
|
|
1064
1115
|
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
1065
1116
|
}
|
|
@@ -1072,7 +1123,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1072
1123
|
/** creates a new Element (VO) */
|
|
1073
1124
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1074
1125
|
async createWithPromise(kEdge, callback) {
|
|
1075
|
-
console.log(`${contextReportText2()}`);
|
|
1126
|
+
if (DEBUG_VERBOSE3) console.log(`${contextReportText2(this)} creating edge: sourceId=${kEdge.sourceId}, targetId=${kEdge.targetId}, type=${kEdge.type}`);
|
|
1076
1127
|
let result;
|
|
1077
1128
|
const request = {
|
|
1078
1129
|
type: KEDGE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -1085,7 +1136,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1085
1136
|
if (!serverData.success) {
|
|
1086
1137
|
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1087
1138
|
}
|
|
1088
|
-
result =
|
|
1139
|
+
result = ColaboApiOperators4.extractVoFromServerData(serverData);
|
|
1089
1140
|
} catch (error) {
|
|
1090
1141
|
console.error(error);
|
|
1091
1142
|
return Promise.reject(error);
|
|
@@ -1095,7 +1146,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1095
1146
|
/** creates a new Element (VO) */
|
|
1096
1147
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1097
1148
|
async createWithRequest(request) {
|
|
1098
|
-
console.log(`${contextReportText2()}`);
|
|
1149
|
+
if (DEBUG5) console.log(`${contextReportText2(this)} request type=${request.type}, activity=${request.activity ?? "default"}`);
|
|
1099
1150
|
let result;
|
|
1100
1151
|
const url = this.apiUrl;
|
|
1101
1152
|
try {
|
|
@@ -1104,7 +1155,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1104
1155
|
if (!serverData.success) {
|
|
1105
1156
|
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1106
1157
|
}
|
|
1107
|
-
result =
|
|
1158
|
+
result = ColaboApiOperators4.extractVoFromServerData(serverData);
|
|
1108
1159
|
} catch (error) {
|
|
1109
1160
|
console.error(error);
|
|
1110
1161
|
return Promise.reject(error);
|
|
@@ -1118,7 +1169,7 @@ KnalledgeEdgeService = __decorateClass([
|
|
|
1118
1169
|
|
|
1119
1170
|
// lib/kEdge-service-extended.ts
|
|
1120
1171
|
import { Injectable as Injectable6 } from "@colabo-headless/i-core";
|
|
1121
|
-
import { KEdgeFrontend as KEdge } from "@colabo-knalledge/i-core";
|
|
1172
|
+
import { KEdgeFrontend as KEdge, ColaboApiOperators as ColaboApiOperators5 } from "@colabo-knalledge/i-core";
|
|
1122
1173
|
import axios6 from "axios";
|
|
1123
1174
|
import { rethrowColaboError as rethrowColaboError4 } from "@colabo-utils/i-notifications";
|
|
1124
1175
|
var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
@@ -1140,9 +1191,9 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1140
1191
|
* @returns {Observable<KEdge>} retrieved edge
|
|
1141
1192
|
*/
|
|
1142
1193
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1143
|
-
async getById(id, callback) {
|
|
1194
|
+
async getById(id, fields, callback) {
|
|
1144
1195
|
console.log("getById(" + id + ")");
|
|
1145
|
-
const url = this.apiUrl + "one/" + id;
|
|
1196
|
+
const url = ColaboApiOperators5.appendFieldsParam(this.apiUrl + "one/" + id, fields);
|
|
1146
1197
|
try {
|
|
1147
1198
|
const mResult = await axios6.get(url);
|
|
1148
1199
|
const serverData = mResult.data;
|
|
@@ -1423,6 +1474,7 @@ export {
|
|
|
1423
1474
|
KnalledgeEdgeService,
|
|
1424
1475
|
KnalledgeEdgeServiceExtended,
|
|
1425
1476
|
MODULE_NAME,
|
|
1477
|
+
addSecurityPrefix,
|
|
1426
1478
|
removeSecurityPrefix
|
|
1427
1479
|
};
|
|
1428
1480
|
//# sourceMappingURL=index.js.map
|