@colabo-knalledge/i-core-services 1.5.3 → 1.6.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 +28 -0
- package/dist/cjs/index.js +94 -58
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/index.js +101 -65
- 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/kNode-service-extended.d.ts +2 -2
- package/dist/types/lib/kNode-service.d.ts +3 -1
- package/package.json +9 -9
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,13 +384,13 @@ 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) {
|
|
390
|
+
async getInContainer(id, fields) {
|
|
378
391
|
let result;
|
|
392
|
+
const url = ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json", fields);
|
|
379
393
|
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
394
|
try {
|
|
382
395
|
const response = await this.http.get(url).toPromise();
|
|
383
396
|
if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
|
|
@@ -393,9 +406,9 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
393
406
|
}
|
|
394
407
|
}
|
|
395
408
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
396
|
-
async getVOs(type, upperLayerType) {
|
|
409
|
+
async getVOs(type, upperLayerType, fields) {
|
|
397
410
|
let result;
|
|
398
|
-
const url = `${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json
|
|
411
|
+
const url = ColaboApiOperators.appendFieldsParam(`${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`, fields);
|
|
399
412
|
const mResult = await axios2.get(url);
|
|
400
413
|
try {
|
|
401
414
|
const serverData = mResult.data;
|
|
@@ -466,7 +479,9 @@ import { GetPuzzle as GetPuzzle2 } from "@colabo-utils/i-config";
|
|
|
466
479
|
import { KNodeFrontend as KNodeFrontend2, KNODE_API_TYPE, ColaboApiOperators as ColaboApiOperators2, contextReportText } from "@colabo-knalledge/i-core";
|
|
467
480
|
import { NotificationMsgType as NotificationMsgType3 } from "@colabo-utils/i-notifications";
|
|
468
481
|
import { KNODE_API_PARAMS } from "@colabo-knalledge/i-core";
|
|
469
|
-
|
|
482
|
+
var DEBUG3 = false;
|
|
483
|
+
var DEBUG_VERBOSE2 = false;
|
|
484
|
+
if (DEBUG3) console.info(`[ColaboKnAllEdgeNodeService] Current context: ${currentContext2}`);
|
|
470
485
|
var class_id = 1;
|
|
471
486
|
var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
472
487
|
/**
|
|
@@ -498,15 +513,15 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
498
513
|
}
|
|
499
514
|
} else {
|
|
500
515
|
this.http = new HttpClient2(null);
|
|
501
|
-
console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
516
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
502
517
|
}
|
|
503
518
|
}
|
|
504
|
-
console.log("[ColaboKnAllEdgeNodeService] created");
|
|
519
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] created");
|
|
505
520
|
const puzzleConfig2 = GetPuzzle2(MODULE_NAME);
|
|
506
521
|
this.serverAP = puzzleConfig2.serverUrl;
|
|
507
|
-
console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", chalk.bold.white(this.serverAP));
|
|
522
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", chalk.bold.white(this.serverAP));
|
|
508
523
|
this.apiUrl = this.serverAP + "/" + KNODE_API_PARAMS.API_PATH + "/";
|
|
509
|
-
console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", chalk.bold.white(this.apiUrl));
|
|
524
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", chalk.bold.white(this.apiUrl));
|
|
510
525
|
}
|
|
511
526
|
/**
|
|
512
527
|
* Get a KN Node from the server by its `id`
|
|
@@ -517,10 +532,10 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
517
532
|
*/
|
|
518
533
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
519
534
|
// 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}`);
|
|
535
|
+
async getById(id, fields) {
|
|
536
|
+
const url = ColaboApiOperators2.appendFieldsParam(this.apiUrl + "one/" + this.defaultAction + "/" + id, fields);
|
|
537
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
|
|
538
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
|
|
524
539
|
try {
|
|
525
540
|
const result = await axios3.get(url);
|
|
526
541
|
const data = result.data;
|
|
@@ -545,8 +560,8 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
545
560
|
request.type = KNODE_API_TYPE.INDEX_COLABO_API;
|
|
546
561
|
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
547
562
|
let result = [];
|
|
548
|
-
const url = this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
549
|
-
console.log("[getVos] url: ", url);
|
|
563
|
+
const url = ColaboApiOperators2.appendFieldsParam(this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json", request.fields);
|
|
564
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
550
565
|
const mResult = await axios3.get(url);
|
|
551
566
|
try {
|
|
552
567
|
const serverData = mResult.data;
|
|
@@ -571,7 +586,8 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
571
586
|
request.type = KNODE_API_TYPE.UPDATE_COLABO_API;
|
|
572
587
|
let result;
|
|
573
588
|
const url = this.apiUrl + KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
|
|
574
|
-
console.log("[
|
|
589
|
+
if (DEBUG3) console.log("[updateWithColaboApi] url: ", url);
|
|
590
|
+
if (DEBUG_VERBOSE2) console.log("[updateWithColaboApi] request: ", JSON.stringify(request, null, 4));
|
|
575
591
|
let mResult;
|
|
576
592
|
try {
|
|
577
593
|
mResult = await axios3.put(url, request);
|
|
@@ -604,10 +620,24 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
604
620
|
const kNodeCreated = kNodesCreated[0];
|
|
605
621
|
return kNodeCreated;
|
|
606
622
|
}
|
|
623
|
+
/** creates multiple KNodes in a single bulk request */
|
|
624
|
+
async createBulk(kNodes) {
|
|
625
|
+
if (DEBUG_VERBOSE2) console.log(`${contextReportText(this)} bulk creating ${kNodes.length} nodes`);
|
|
626
|
+
const url = this.apiUrl + "bulk";
|
|
627
|
+
try {
|
|
628
|
+
const mResult = await axios3.post(url, kNodes, HTTP_OPTIONS_CONST_JSON);
|
|
629
|
+
const created = mResult.data;
|
|
630
|
+
if (DEBUG3) console.log(`${contextReportText(this)} bulk created ${created.length} nodes`);
|
|
631
|
+
return created;
|
|
632
|
+
} catch (error) {
|
|
633
|
+
rethrowColaboError2(error);
|
|
634
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
635
|
+
}
|
|
636
|
+
}
|
|
607
637
|
/** creates a new Element (VO) */
|
|
608
638
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
609
639
|
async create(kNode, callback) {
|
|
610
|
-
console.log(`${contextReportText()}`);
|
|
640
|
+
if (DEBUG_VERBOSE2) console.log(`${contextReportText(this)} creating node: name=${kNode.name}, type=${kNode.type}`);
|
|
611
641
|
let result;
|
|
612
642
|
const request = {
|
|
613
643
|
type: KNODE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -631,7 +661,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
631
661
|
request.type = KNODE_API_TYPE.CREATE_COLABO_API;
|
|
632
662
|
let result;
|
|
633
663
|
const url = this.apiUrl + KNODE_API_TYPE.CREATE_COLABO_API + ".json";
|
|
634
|
-
console.log("[getVos] url: ", url);
|
|
664
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
635
665
|
let mResult;
|
|
636
666
|
try {
|
|
637
667
|
mResult = await axios3.post(url, request);
|
|
@@ -665,7 +695,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
665
695
|
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
666
696
|
let result;
|
|
667
697
|
const url = this.apiUrl + KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
668
|
-
console.log("[getVos] url: ", url);
|
|
698
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
669
699
|
const mResult = await axios3.delete(url);
|
|
670
700
|
try {
|
|
671
701
|
const serverData = mResult.data;
|
|
@@ -696,9 +726,10 @@ import axios4 from "axios";
|
|
|
696
726
|
import { VOFrontend, KNodeFrontend as KNodeFrontend3 } from "@colabo-knalledge/i-core";
|
|
697
727
|
import { rethrowColaboError as rethrowColaboError3 } from "@colabo-utils/i-notifications";
|
|
698
728
|
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]
|
|
729
|
+
import { KNODE_API_TYPE as KNODE_API_TYPE2, ColaboApiOperators as ColaboApiOperators3 } from "@colabo-knalledge/i-core";
|
|
730
|
+
var DEBUG4 = false;
|
|
731
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] Injectable: ", Injectable4);
|
|
732
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] HttpClient: ", HttpClient3);
|
|
702
733
|
var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeService {
|
|
703
734
|
// protected http:HttpClient = null;
|
|
704
735
|
// protected utilsNotificationService: UtilsNotificationService;
|
|
@@ -708,12 +739,16 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
708
739
|
this.knalledgeMapQueue = null;
|
|
709
740
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
710
741
|
this.knAllEdgeRealTimeService = null;
|
|
711
|
-
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
742
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
743
|
+
}
|
|
744
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
745
|
+
static get mapId() {
|
|
746
|
+
return config2.GetString("mapId");
|
|
712
747
|
}
|
|
713
|
-
async queryByIds(ids, callback) {
|
|
714
|
-
console.log("queryByIds", ids);
|
|
748
|
+
async queryByIds(ids, fields, callback) {
|
|
749
|
+
if (DEBUG4) console.log("queryByIds", ids);
|
|
715
750
|
const idsStr = ids.join(",");
|
|
716
|
-
const url = this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
|
|
751
|
+
const url = ColaboApiOperators3.appendFieldsParam(this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json", fields);
|
|
717
752
|
try {
|
|
718
753
|
const mResult = await axios4.get(url);
|
|
719
754
|
const serverData = mResult.data;
|
|
@@ -737,7 +772,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
737
772
|
*/
|
|
738
773
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
739
774
|
// async create(kNode: KNodeFrontend, callback?: Function): Promise<KNodeFrontend> {
|
|
740
|
-
// console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
775
|
+
// if(DEBUG) console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
741
776
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
742
777
|
// let kNodeForServer: any;
|
|
743
778
|
// if (kNode.toServerCopy) kNodeForServer = kNode.toServerCopy();
|
|
@@ -898,7 +933,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
898
933
|
// }
|
|
899
934
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
|
|
900
935
|
// queryInMapofTypeAndContentData(mapId: string, type: string, contentDataPath: string, data: any, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
901
|
-
// console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
936
|
+
// if(DEBUG) console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
902
937
|
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(
|
|
903
938
|
// this.apiUrl + "in_map_of_type_and_content_data/" + this.defaultAction + "/" + mapId + "/" + type + "/" + contentDataPath + "/" + data + ".json"
|
|
904
939
|
// ).pipe(
|
|
@@ -911,7 +946,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
911
946
|
// return result;
|
|
912
947
|
// }
|
|
913
948
|
// queryInMapofTypeForUser(mapId: string, type: string, iAmid: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
914
|
-
// console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
949
|
+
// if(DEBUG) console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
915
950
|
// 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
951
|
// map((nodesFromServer) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
917
952
|
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMap", undefined))
|
|
@@ -925,7 +960,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
925
960
|
// destroyByTypeInMap(type: string, mapId: string, callback?: Function): Observable<boolean> {
|
|
926
961
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
927
962
|
// 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}`)),
|
|
963
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
929
964
|
// map((serverData: ServerData) => serverData.success),
|
|
930
965
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeInMap"))
|
|
931
966
|
// );
|
|
@@ -953,7 +988,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
953
988
|
// destroyByUser(iAmid: string): Observable<boolean> {
|
|
954
989
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
955
990
|
// 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}`)),
|
|
991
|
+
// tap((_: ServerData) => if(DEBUG) console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
957
992
|
// map((serverData: ServerData) => serverData.success),
|
|
958
993
|
// catchError(this.handleErrorForObservable<boolean>("destroyByUser"))
|
|
959
994
|
// );
|
|
@@ -979,7 +1014,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
979
1014
|
// destroyByTypeByUser(type: string, iAmid: string, callback?: Function): Observable<boolean> {
|
|
980
1015
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
981
1016
|
// 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}`)),
|
|
1017
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
983
1018
|
// map((serverData: ServerData) => serverData.success),
|
|
984
1019
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeByUser"))
|
|
985
1020
|
// );
|
|
@@ -1005,8 +1040,6 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
1005
1040
|
// return result;
|
|
1006
1041
|
// }
|
|
1007
1042
|
};
|
|
1008
|
-
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
1009
|
-
ColaboKnAllEdgeNodeServiceExtended.mapId = config2.GetGeneral("mapId");
|
|
1010
1043
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL = "UPDATE_NODE_NAME_FINAL";
|
|
1011
1044
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME = "UPDATE_NODE_NAME";
|
|
1012
1045
|
ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
@@ -1016,11 +1049,13 @@ ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
|
1016
1049
|
// lib/kEdge-service.ts
|
|
1017
1050
|
import { Injectable as Injectable5 } from "@colabo-headless/i-core";
|
|
1018
1051
|
import { HttpClient as HttpClient4 } from "@colabo-headless/i-core";
|
|
1019
|
-
import { ColaboApiOperators as
|
|
1052
|
+
import { ColaboApiOperators as ColaboApiOperators4, KEDGE_API_TYPE, KEDGE_API_PARAMS, contextReportText as contextReportText2 } from "@colabo-knalledge/i-core";
|
|
1020
1053
|
import axios5 from "axios";
|
|
1021
1054
|
import { chalk as chalk2 } from "@colabo-headless/i-core";
|
|
1022
1055
|
import { currentContext as currentContext3, CONTEXTS as CONTEXTS3 } from "@colabo-headless/i-core";
|
|
1023
1056
|
import { NotificationMsgType as NotificationMsgType4 } from "@colabo-utils/i-notifications";
|
|
1057
|
+
var DEBUG5 = false;
|
|
1058
|
+
var DEBUG_VERBOSE3 = false;
|
|
1024
1059
|
var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
1025
1060
|
constructor(http, utilsNotificationService) {
|
|
1026
1061
|
super(utilsNotificationService);
|
|
@@ -1052,14 +1087,14 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1052
1087
|
async getVosWithColaboApi(request) {
|
|
1053
1088
|
request.type = KEDGE_API_TYPE.INDEX_COLABO_API;
|
|
1054
1089
|
console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
|
|
1055
|
-
const requestSerialized =
|
|
1090
|
+
const requestSerialized = ColaboApiOperators4.serializeApiRequest(request);
|
|
1056
1091
|
let result;
|
|
1057
|
-
const url = this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized
|
|
1092
|
+
const url = ColaboApiOperators4.appendFieldsParam(this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized, request.fields);
|
|
1058
1093
|
console.log("[getVos] url: ", url);
|
|
1059
1094
|
const mResult = await axios5.get(url);
|
|
1060
1095
|
try {
|
|
1061
1096
|
const serverData = mResult.data;
|
|
1062
|
-
result =
|
|
1097
|
+
result = ColaboApiOperators4.extractVosFromServerData(serverData);
|
|
1063
1098
|
if (!result) {
|
|
1064
1099
|
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
1065
1100
|
}
|
|
@@ -1072,7 +1107,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1072
1107
|
/** creates a new Element (VO) */
|
|
1073
1108
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1074
1109
|
async createWithPromise(kEdge, callback) {
|
|
1075
|
-
console.log(`${contextReportText2()}`);
|
|
1110
|
+
if (DEBUG_VERBOSE3) console.log(`${contextReportText2(this)} creating edge: sourceId=${kEdge.sourceId}, targetId=${kEdge.targetId}, type=${kEdge.type}`);
|
|
1076
1111
|
let result;
|
|
1077
1112
|
const request = {
|
|
1078
1113
|
type: KEDGE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -1085,7 +1120,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1085
1120
|
if (!serverData.success) {
|
|
1086
1121
|
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1087
1122
|
}
|
|
1088
|
-
result =
|
|
1123
|
+
result = ColaboApiOperators4.extractVoFromServerData(serverData);
|
|
1089
1124
|
} catch (error) {
|
|
1090
1125
|
console.error(error);
|
|
1091
1126
|
return Promise.reject(error);
|
|
@@ -1095,7 +1130,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1095
1130
|
/** creates a new Element (VO) */
|
|
1096
1131
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1097
1132
|
async createWithRequest(request) {
|
|
1098
|
-
console.log(`${contextReportText2()}`);
|
|
1133
|
+
if (DEBUG5) console.log(`${contextReportText2(this)} request type=${request.type}, activity=${request.activity ?? "default"}`);
|
|
1099
1134
|
let result;
|
|
1100
1135
|
const url = this.apiUrl;
|
|
1101
1136
|
try {
|
|
@@ -1104,7 +1139,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1104
1139
|
if (!serverData.success) {
|
|
1105
1140
|
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1106
1141
|
}
|
|
1107
|
-
result =
|
|
1142
|
+
result = ColaboApiOperators4.extractVoFromServerData(serverData);
|
|
1108
1143
|
} catch (error) {
|
|
1109
1144
|
console.error(error);
|
|
1110
1145
|
return Promise.reject(error);
|
|
@@ -1118,7 +1153,7 @@ KnalledgeEdgeService = __decorateClass([
|
|
|
1118
1153
|
|
|
1119
1154
|
// lib/kEdge-service-extended.ts
|
|
1120
1155
|
import { Injectable as Injectable6 } from "@colabo-headless/i-core";
|
|
1121
|
-
import { KEdgeFrontend as KEdge } from "@colabo-knalledge/i-core";
|
|
1156
|
+
import { KEdgeFrontend as KEdge, ColaboApiOperators as ColaboApiOperators5 } from "@colabo-knalledge/i-core";
|
|
1122
1157
|
import axios6 from "axios";
|
|
1123
1158
|
import { rethrowColaboError as rethrowColaboError4 } from "@colabo-utils/i-notifications";
|
|
1124
1159
|
var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
@@ -1140,9 +1175,9 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1140
1175
|
* @returns {Observable<KEdge>} retrieved edge
|
|
1141
1176
|
*/
|
|
1142
1177
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1143
|
-
async getById(id, callback) {
|
|
1178
|
+
async getById(id, fields, callback) {
|
|
1144
1179
|
console.log("getById(" + id + ")");
|
|
1145
|
-
const url = this.apiUrl + "one/" + id;
|
|
1180
|
+
const url = ColaboApiOperators5.appendFieldsParam(this.apiUrl + "one/" + id, fields);
|
|
1146
1181
|
try {
|
|
1147
1182
|
const mResult = await axios6.get(url);
|
|
1148
1183
|
const serverData = mResult.data;
|
|
@@ -1423,6 +1458,7 @@ export {
|
|
|
1423
1458
|
KnalledgeEdgeService,
|
|
1424
1459
|
KnalledgeEdgeServiceExtended,
|
|
1425
1460
|
MODULE_NAME,
|
|
1461
|
+
addSecurityPrefix,
|
|
1426
1462
|
removeSecurityPrefix
|
|
1427
1463
|
};
|
|
1428
1464
|
//# sourceMappingURL=index.js.map
|