@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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
# [@colabo-knalledge/i-core-services-v1.7.0](https://github.com/Cha-OS/colabo/compare/@colabo-knalledge/i-core-services-v1.6.0...@colabo-knalledge/i-core-services-v1.7.0) (2026-06-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **knalledge:** add fetchFn injection to all GET service methods for worker-based fetch ([275eb46](https://github.com/Cha-OS/colabo/commit/275eb462595cd57b5bc4ad28bdb7bc8bff4ebe34))
|
|
7
|
+
|
|
8
|
+
# [@colabo-knalledge/i-core-services-v1.6.0](https://github.com/Cha-OS/colabo/compare/@colabo-knalledge/i-core-services-v1.5.3...@colabo-knalledge/i-core-services-v1.6.0) (2026-06-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **@colabo-knalledge/i-core-services:** :bug: Fixed bug with hardcoded 127.0.0.1 ([dcb6a5f](https://github.com/Cha-OS/colabo/commit/dcb6a5fc84c96e1a605368f9e693275655230a28))
|
|
14
|
+
* **@colabo-knalledge/i-core-services:** :bug: Fixed bug with hardcoded 127.0.0.1 ([13302f5](https://github.com/Cha-OS/colabo/commit/13302f53fb01a1a836a52062ac3c4428ebfdd471))
|
|
15
|
+
* **@colabo-knalledge/i-core-services:** :bug: remove `.json` suffix from kEdge ColaboAPI URL ([1927d88](https://github.com/Cha-OS/colabo/commit/1927d8815be39eb7eb19aab4d1fa99f90a733930))
|
|
16
|
+
* **@colabo-knalledge:** improve diagnostic logging with context and DEBUG guards ([4890981](https://github.com/Cha-OS/colabo/commit/48909811ff1f55ae324d9b0504206d0d57efc187))
|
|
17
|
+
* **@colabo:** :arrow_up: Bumped up versions ([4e7bdd1](https://github.com/Cha-OS/colabo/commit/4e7bdd133e80f09b25ff974f35ee1a8448308333))
|
|
18
|
+
* **@colabo:** :arrow_up: Bumped up versions ([71ea2c4](https://github.com/Cha-OS/colabo/commit/71ea2c49754d2e16c37a0ee0582e9addfa457028))
|
|
19
|
+
* **@colabo:** :arrow_up: Bumped versions ([058d9f1](https://github.com/Cha-OS/colabo/commit/058d9f19ed9e7cb4f5e57489463c61b0bf650a81))
|
|
20
|
+
* **@colabo:** :bug: Fixed support for releasing the current branch ([b672e34](https://github.com/Cha-OS/colabo/commit/b672e340bb959475be6228f69fab19592ce2d893))
|
|
21
|
+
* **@colabo:** :bug: Fixes running backend code in ESM env ([206280d](https://github.com/Cha-OS/colabo/commit/206280d510e7b5b5d619d992667d67a4a432c47c))
|
|
22
|
+
* **@colabo:** :bug: Fixes running backend code in ESM env ([de71e80](https://github.com/Cha-OS/colabo/commit/de71e806e7af084ff60204612324273a73586562))
|
|
23
|
+
* **@colabo:** :bug: Instatiates store on demand instead on "imports" ([b872a8b](https://github.com/Cha-OS/colabo/commit/b872a8b69ff24bcc0c715ef74635ec33fbdcabe7))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **@colabo-flow/f-core:** :sparkles: Initial work toward zustand store and separating store into a service code ([0292bcc](https://github.com/Cha-OS/colabo/commit/0292bcc460d9cd0215f5dc074d8fe2c06f34cde0))
|
|
29
|
+
* **@colabo-flow/i-core:** :sparkles: Adds flow and flowchestrator store, FlowChestrator API (Nest.js => Bun -> Jarn), Extends token with RIMA ([ac50af6](https://github.com/Cha-OS/colabo/commit/ac50af6ecf3dcbfc812204dd647d44461c0fbfdd))
|
|
30
|
+
* **@colabo-flow/sa-flowchestrator:** :sparkles: Adds flow instance features, fixes COARS, returns ServerData results and protects JSONP ([6eb45e8](https://github.com/Cha-OS/colabo/commit/6eb45e8e94cb5d8a6865887efe0065f3da4b5a83))
|
|
31
|
+
* **@colabo-knalledge/i-core-services:** :sparkles: add fields projection to isomorphic kEdge services ([aa2b587](https://github.com/Cha-OS/colabo/commit/aa2b5871208b64c2fd6eb2fbc78f6e0bf41a0d90))
|
|
32
|
+
* **@colabo-knalledge/i-core-services:** :sparkles: add fields projection to isomorphic kNode and kContainer services ([7286a34](https://github.com/Cha-OS/colabo/commit/7286a34a9b2998db1a869f939b8bf02f64405b47))
|
|
33
|
+
* **@colabo-knalledge:** add bulk client methods for batch annotation insertion ([6daf47a](https://github.com/Cha-OS/colabo/commit/6daf47a43b96f9dcee867030ed2ce9ed07d75d84))
|
|
34
|
+
* **KnAllEdge:** ✨ add edgeDataContent support when adding nodes to container ([1bd3b74](https://github.com/Cha-OS/colabo/commit/1bd3b74cfb2d882f4fcdfe0f7471ad058a2dbc72))
|
|
35
|
+
|
|
1
36
|
# [@colabo-knalledge/i-core-services-v1.5.3](https://github.com/Cha-OS/colabo/compare/@colabo-knalledge/i-core-services-v1.5.2...@colabo-knalledge/i-core-services-v1.5.3) (2025-02-28)
|
|
2
37
|
|
|
3
38
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
KnalledgeEdgeService: () => KnalledgeEdgeService,
|
|
49
49
|
KnalledgeEdgeServiceExtended: () => KnalledgeEdgeServiceExtended,
|
|
50
50
|
MODULE_NAME: () => MODULE_NAME,
|
|
51
|
+
addSecurityPrefix: () => addSecurityPrefix,
|
|
51
52
|
removeSecurityPrefix: () => removeSecurityPrefix
|
|
52
53
|
});
|
|
53
54
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -69,7 +70,8 @@ var import_i_core2 = require("@colabo-headless/i-core");
|
|
|
69
70
|
var import_i_notifications = require("@colabo-utils/i-notifications");
|
|
70
71
|
var import_i_notifications2 = require("@colabo-utils/i-notifications");
|
|
71
72
|
var config = __toESM(require("@colabo-utils/i-config"), 1);
|
|
72
|
-
|
|
73
|
+
var DEBUG2 = false;
|
|
74
|
+
if (DEBUG2) console.log("[CFServiceIsomorphic] Injectable: ", import_i_core2.Injectable);
|
|
73
75
|
var HIDE_ERRORS = true;
|
|
74
76
|
var HTTP_OPTIONS_CONST_JSON = {
|
|
75
77
|
headers: {
|
|
@@ -80,6 +82,11 @@ var CFServiceIsomorphic = class {
|
|
|
80
82
|
constructor(utilsNotificationService) {
|
|
81
83
|
this.utilsNotificationService = utilsNotificationService;
|
|
82
84
|
}
|
|
85
|
+
// RESTfull backend API url
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
87
|
+
static get serverAP() {
|
|
88
|
+
return config.GetString("serverUrl");
|
|
89
|
+
}
|
|
83
90
|
/**
|
|
84
91
|
* processes array of VOs received from server to a local/fronted version
|
|
85
92
|
* @param vofS
|
|
@@ -170,9 +177,6 @@ var CFServiceIsomorphic = class {
|
|
|
170
177
|
};
|
|
171
178
|
}
|
|
172
179
|
};
|
|
173
|
-
// RESTfull backend API url
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
175
|
-
CFServiceIsomorphic.serverAP = config.GetGeneral("serverUrl");
|
|
176
180
|
CFServiceIsomorphic = __decorateClass([
|
|
177
181
|
(0, import_i_core2.Injectable)()
|
|
178
182
|
], CFServiceIsomorphic);
|
|
@@ -184,7 +188,7 @@ var import_i_core5 = require("@colabo-headless/i-core");
|
|
|
184
188
|
// lib/colabo-api-core.service.ts
|
|
185
189
|
var import_axios = __toESM(require("axios"), 1);
|
|
186
190
|
var import_i_core3 = require("@colabo-headless/i-core");
|
|
187
|
-
console.log("[ColaboApiCoreService] Initializing");
|
|
191
|
+
if (DEBUG) console.log("[ColaboApiCoreService] Initializing");
|
|
188
192
|
var responseInterceptor = (response) => {
|
|
189
193
|
if (DEBUG_VERBOSE) console.log("[axios::interceptor::colabo-api-core.service] response.data: ", JSON.stringify(response.data, null, 4));
|
|
190
194
|
if (typeof response.data !== "string") {
|
|
@@ -195,6 +199,10 @@ var responseInterceptor = (response) => {
|
|
|
195
199
|
response.data = JSON.parse(removeSecurityPrefix(data));
|
|
196
200
|
return response;
|
|
197
201
|
};
|
|
202
|
+
var addSecurityPrefix = (data) => {
|
|
203
|
+
const dataSecured = ")]}',\n" + JSON.stringify(data);
|
|
204
|
+
return dataSecured;
|
|
205
|
+
};
|
|
198
206
|
var removeSecurityPrefix = (data) => {
|
|
199
207
|
let index = data.indexOf("\r");
|
|
200
208
|
const indexN = data.indexOf("\n");
|
|
@@ -258,7 +266,6 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
258
266
|
this.utilsNotificationService = utilsNotificationService;
|
|
259
267
|
this.defaultAction = "default";
|
|
260
268
|
puzzleConfig = (0, import_i_config.GetPuzzle)(MODULE_NAME);
|
|
261
|
-
ColaboKnAllEdgeContainerService.serverAP = puzzleConfig.serverUrl;
|
|
262
269
|
if (!this.http) {
|
|
263
270
|
if (import_i_core5.currentContext === import_i_core5.CONTEXTS.FRONTEND_ANGULAR) {
|
|
264
271
|
const msg = "[ColaboKnAllEdgeContainerService] DI Problem: There is no provider injected for the service `HttpClient`.";
|
|
@@ -280,29 +287,34 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
280
287
|
console.log("[ColaboKnAllEdgeContainerService] created");
|
|
281
288
|
this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + import_i_core4.KCONTAINER_API_PARAMS.API_PATH + "/";
|
|
282
289
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Retrieves the kContainer with a given ID. It retrieves only the kContainer kNode, not all the kNodes that are in the kContainer.
|
|
292
|
+
* @param id the id of the kContainer to be retrieved
|
|
293
|
+
* @returns
|
|
294
|
+
*/
|
|
295
|
+
async getById(id, fields) {
|
|
296
|
+
let retrievedKContainer;
|
|
297
|
+
const url = import_i_core4.ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id, fields);
|
|
286
298
|
if (DEBUG) console.log("[getByIdPromise] url: ", url);
|
|
287
299
|
try {
|
|
288
300
|
const mResult = await import_axios2.default.get(url);
|
|
289
301
|
const serverData = mResult.data;
|
|
290
|
-
|
|
291
|
-
if (!
|
|
302
|
+
retrievedKContainer = import_i_core4.ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
|
|
303
|
+
if (!retrievedKContainer) {
|
|
292
304
|
return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
|
|
293
305
|
}
|
|
294
|
-
if (import_i_core4.ColaboApiOperators.getParentEntity(
|
|
306
|
+
if (import_i_core4.ColaboApiOperators.getParentEntity(retrievedKContainer).type != import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
|
|
295
307
|
return Promise.reject(new Error("Wrong entity type, expected: " + import_i_core4.KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
|
|
296
308
|
}
|
|
297
309
|
} catch (error) {
|
|
298
310
|
console.error(error);
|
|
299
311
|
return Promise.reject(error);
|
|
300
312
|
}
|
|
301
|
-
return
|
|
313
|
+
return retrievedKContainer;
|
|
302
314
|
}
|
|
303
315
|
async create(kContainerWContent) {
|
|
304
316
|
console.log("ColaboKnAllEdgeContainerService.create");
|
|
305
|
-
let
|
|
317
|
+
let createdKContainer;
|
|
306
318
|
const url = this.apiUrl;
|
|
307
319
|
try {
|
|
308
320
|
const requestRoot = {
|
|
@@ -311,8 +323,8 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
311
323
|
};
|
|
312
324
|
const mResult = await import_axios2.default.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
|
|
313
325
|
const serverData = mResult.data;
|
|
314
|
-
|
|
315
|
-
return
|
|
326
|
+
createdKContainer = import_i_core4.ColaboApiOperators.extractVoFromServerData(serverData);
|
|
327
|
+
return createdKContainer;
|
|
316
328
|
} catch (error) {
|
|
317
329
|
if (error.response) {
|
|
318
330
|
console.log("[create]", error);
|
|
@@ -370,17 +382,19 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
370
382
|
/**
|
|
371
383
|
* @param containerId The id of the kContainer to which we want to add kNodes
|
|
372
384
|
* @param containedIds The list of ids of the kNodes we want to add to the container
|
|
385
|
+
* @param edgeDataContent Optional dataContent to set on the created edges (e.g. `{ type: "litterra.corpus.document" }`)
|
|
373
386
|
* @description adds kNodes in a kContainer
|
|
374
387
|
* @returns edges created between the container and entities added to the container
|
|
375
388
|
*/
|
|
376
|
-
async updateAddNodes(containerId, containedIds) {
|
|
389
|
+
async updateAddNodes(containerId, containedIds, edgeDataContent) {
|
|
377
390
|
if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
|
|
378
391
|
let result;
|
|
379
392
|
const idsStr = containedIds.join(",");
|
|
380
393
|
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);
|
|
394
|
+
if (DEBUG) console.log("updateAddNodes called", url);
|
|
382
395
|
try {
|
|
383
|
-
const
|
|
396
|
+
const body = edgeDataContent ? { edgeDataContent } : {};
|
|
397
|
+
const mResult = await import_axios2.default.put(url, body, HTTP_OPTIONS_CONST_JSON);
|
|
384
398
|
const serverData = mResult.data;
|
|
385
399
|
result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
|
|
386
400
|
} catch (error) {
|
|
@@ -414,14 +428,16 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
414
428
|
}
|
|
415
429
|
/**
|
|
416
430
|
*
|
|
417
|
-
* @param id The id of the kContainer which
|
|
431
|
+
* @param id The id of the kContainer which kNodes we want to retrieve
|
|
418
432
|
* @description retrieves kNodes in a kContainer
|
|
419
433
|
*/
|
|
420
|
-
async getInContainer(id) {
|
|
421
|
-
|
|
434
|
+
async getInContainer(id, fields, fetchFn) {
|
|
435
|
+
const url = import_i_core4.ColaboApiOperators.appendFieldsParam(this.apiUrl + this.defaultAction + "/" + import_i_core4.KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json", fields);
|
|
422
436
|
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
437
|
try {
|
|
438
|
+
if (fetchFn) {
|
|
439
|
+
return await fetchFn(url);
|
|
440
|
+
}
|
|
425
441
|
const response = await this.http.get(url).toPromise();
|
|
426
442
|
if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
|
|
427
443
|
if (!response) {
|
|
@@ -436,11 +452,14 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
436
452
|
}
|
|
437
453
|
}
|
|
438
454
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
439
|
-
async getVOs(type, upperLayerType) {
|
|
455
|
+
async getVOs(type, upperLayerType, fields, fetchFn) {
|
|
440
456
|
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);
|
|
457
|
+
const url = import_i_core4.ColaboApiOperators.appendFieldsParam(`${this.apiUrl}${this.defaultAction}/${import_i_core4.KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`, fields);
|
|
443
458
|
try {
|
|
459
|
+
if (fetchFn) {
|
|
460
|
+
return await fetchFn(url);
|
|
461
|
+
}
|
|
462
|
+
const mResult = await import_axios2.default.get(url);
|
|
444
463
|
const serverData = mResult.data;
|
|
445
464
|
result = import_i_core4.ColaboApiOperators.extractVosFromServerData(serverData);
|
|
446
465
|
if (!result) {
|
|
@@ -509,7 +528,9 @@ var import_i_config2 = require("@colabo-utils/i-config");
|
|
|
509
528
|
var import_i_core10 = require("@colabo-knalledge/i-core");
|
|
510
529
|
var import_i_notifications5 = require("@colabo-utils/i-notifications");
|
|
511
530
|
var import_i_core11 = require("@colabo-knalledge/i-core");
|
|
512
|
-
|
|
531
|
+
var DEBUG3 = false;
|
|
532
|
+
var DEBUG_VERBOSE2 = false;
|
|
533
|
+
if (DEBUG3) console.info(`[ColaboKnAllEdgeNodeService] Current context: ${import_i_core9.currentContext}`);
|
|
513
534
|
var class_id = 1;
|
|
514
535
|
var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
515
536
|
/**
|
|
@@ -541,15 +562,15 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
541
562
|
}
|
|
542
563
|
} else {
|
|
543
564
|
this.http = new import_i_core7.HttpClient(null);
|
|
544
|
-
console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
565
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
545
566
|
}
|
|
546
567
|
}
|
|
547
|
-
console.log("[ColaboKnAllEdgeNodeService] created");
|
|
568
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] created");
|
|
548
569
|
const puzzleConfig2 = (0, import_i_config2.GetPuzzle)(MODULE_NAME);
|
|
549
570
|
this.serverAP = puzzleConfig2.serverUrl;
|
|
550
|
-
console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", import_i_core8.chalk.bold.white(this.serverAP));
|
|
571
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", import_i_core8.chalk.bold.white(this.serverAP));
|
|
551
572
|
this.apiUrl = this.serverAP + "/" + import_i_core11.KNODE_API_PARAMS.API_PATH + "/";
|
|
552
|
-
console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", import_i_core8.chalk.bold.white(this.apiUrl));
|
|
573
|
+
if (DEBUG3) console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", import_i_core8.chalk.bold.white(this.apiUrl));
|
|
553
574
|
}
|
|
554
575
|
/**
|
|
555
576
|
* Get a KN Node from the server by its `id`
|
|
@@ -560,10 +581,10 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
560
581
|
*/
|
|
561
582
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
562
583
|
// OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
|
|
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}`);
|
|
584
|
+
async getById(id, fields) {
|
|
585
|
+
const url = import_i_core10.ColaboApiOperators.appendFieldsParam(this.apiUrl + "one/" + this.defaultAction + "/" + id, fields);
|
|
586
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
|
|
587
|
+
if (DEBUG3) console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
|
|
567
588
|
try {
|
|
568
589
|
const result = await import_axios3.default.get(url);
|
|
569
590
|
const data = result.data;
|
|
@@ -584,14 +605,17 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
584
605
|
throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
|
|
585
606
|
}
|
|
586
607
|
}
|
|
587
|
-
async getVosWithColaboApi(request) {
|
|
608
|
+
async getVosWithColaboApi(request, fetchFn) {
|
|
588
609
|
request.type = import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API;
|
|
589
610
|
const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
|
|
590
611
|
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);
|
|
612
|
+
const url = import_i_core10.ColaboApiOperators.appendFieldsParam(this.apiUrl + import_i_core10.KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json", request.fields);
|
|
613
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
594
614
|
try {
|
|
615
|
+
if (fetchFn) {
|
|
616
|
+
return await fetchFn(url);
|
|
617
|
+
}
|
|
618
|
+
const mResult = await import_axios3.default.get(url);
|
|
595
619
|
const serverData = mResult.data;
|
|
596
620
|
if (!serverData) return result;
|
|
597
621
|
result = import_i_core10.ColaboApiOperators.extractVosFromServerData(serverData);
|
|
@@ -614,7 +638,8 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
614
638
|
request.type = import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API;
|
|
615
639
|
let result;
|
|
616
640
|
const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
|
|
617
|
-
console.log("[
|
|
641
|
+
if (DEBUG3) console.log("[updateWithColaboApi] url: ", url);
|
|
642
|
+
if (DEBUG_VERBOSE2) console.log("[updateWithColaboApi] request: ", JSON.stringify(request, null, 4));
|
|
618
643
|
let mResult;
|
|
619
644
|
try {
|
|
620
645
|
mResult = await import_axios3.default.put(url, request);
|
|
@@ -647,10 +672,24 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
647
672
|
const kNodeCreated = kNodesCreated[0];
|
|
648
673
|
return kNodeCreated;
|
|
649
674
|
}
|
|
675
|
+
/** creates multiple KNodes in a single bulk request */
|
|
676
|
+
async createBulk(kNodes) {
|
|
677
|
+
if (DEBUG_VERBOSE2) console.log(`${(0, import_i_core10.contextReportText)(this)} bulk creating ${kNodes.length} nodes`);
|
|
678
|
+
const url = this.apiUrl + "bulk";
|
|
679
|
+
try {
|
|
680
|
+
const mResult = await import_axios3.default.post(url, kNodes, HTTP_OPTIONS_CONST_JSON);
|
|
681
|
+
const created = mResult.data;
|
|
682
|
+
if (DEBUG3) console.log(`${(0, import_i_core10.contextReportText)(this)} bulk created ${created.length} nodes`);
|
|
683
|
+
return created;
|
|
684
|
+
} catch (error) {
|
|
685
|
+
(0, import_i_notifications4.rethrowColaboError)(error);
|
|
686
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
687
|
+
}
|
|
688
|
+
}
|
|
650
689
|
/** creates a new Element (VO) */
|
|
651
690
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
652
691
|
async create(kNode, callback) {
|
|
653
|
-
console.log(`${(0, import_i_core10.contextReportText)()}`);
|
|
692
|
+
if (DEBUG_VERBOSE2) console.log(`${(0, import_i_core10.contextReportText)(this)} creating node: name=${kNode.name}, type=${kNode.type}`);
|
|
654
693
|
let result;
|
|
655
694
|
const request = {
|
|
656
695
|
type: import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -674,7 +713,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
674
713
|
request.type = import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API;
|
|
675
714
|
let result;
|
|
676
715
|
const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.CREATE_COLABO_API + ".json";
|
|
677
|
-
console.log("[getVos] url: ", url);
|
|
716
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
678
717
|
let mResult;
|
|
679
718
|
try {
|
|
680
719
|
mResult = await import_axios3.default.post(url, request);
|
|
@@ -708,7 +747,7 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
708
747
|
const requestSerialized = import_i_core10.ColaboApiOperators.serializeApiRequest(request);
|
|
709
748
|
let result;
|
|
710
749
|
const url = this.apiUrl + import_i_core10.KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
711
|
-
console.log("[getVos] url: ", url);
|
|
750
|
+
if (DEBUG3) console.log("[getVos] url: ", url);
|
|
712
751
|
const mResult = await import_axios3.default.delete(url);
|
|
713
752
|
try {
|
|
714
753
|
const serverData = mResult.data;
|
|
@@ -740,8 +779,9 @@ var import_i_core14 = require("@colabo-knalledge/i-core");
|
|
|
740
779
|
var import_i_notifications6 = require("@colabo-utils/i-notifications");
|
|
741
780
|
var config2 = __toESM(require("@colabo-utils/i-config"), 1);
|
|
742
781
|
var import_i_core15 = require("@colabo-knalledge/i-core");
|
|
743
|
-
|
|
744
|
-
console.log("[ColaboKnAllEdgeNodeServiceExtended]
|
|
782
|
+
var DEBUG4 = false;
|
|
783
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] Injectable: ", import_i_core12.Injectable);
|
|
784
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended] HttpClient: ", import_i_core13.HttpClient);
|
|
745
785
|
var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeService {
|
|
746
786
|
// protected http:HttpClient = null;
|
|
747
787
|
// protected utilsNotificationService: UtilsNotificationService;
|
|
@@ -751,13 +791,22 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
751
791
|
this.knalledgeMapQueue = null;
|
|
752
792
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
753
793
|
this.knAllEdgeRealTimeService = null;
|
|
754
|
-
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
794
|
+
if (DEBUG4) console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
755
795
|
}
|
|
756
|
-
|
|
757
|
-
|
|
796
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
797
|
+
static get mapId() {
|
|
798
|
+
return config2.GetString("mapId");
|
|
799
|
+
}
|
|
800
|
+
async queryByIds(ids, fields, callback, fetchFn) {
|
|
801
|
+
if (DEBUG4) console.log("queryByIds", ids);
|
|
758
802
|
const idsStr = ids.join(",");
|
|
759
|
-
const url = this.apiUrl + import_i_core15.KNODE_API_TYPE.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
|
|
803
|
+
const url = import_i_core15.ColaboApiOperators.appendFieldsParam(this.apiUrl + import_i_core15.KNODE_API_TYPE.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json", fields);
|
|
760
804
|
try {
|
|
805
|
+
if (fetchFn) {
|
|
806
|
+
const rawNodes = await fetchFn(url);
|
|
807
|
+
if (callback) callback(rawNodes);
|
|
808
|
+
return rawNodes;
|
|
809
|
+
}
|
|
761
810
|
const mResult = await import_axios4.default.get(url);
|
|
762
811
|
const serverData = mResult.data;
|
|
763
812
|
const result = CFServiceIsomorphic.processVOs(serverData, import_i_core14.KNodeFrontend);
|
|
@@ -780,7 +829,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
780
829
|
*/
|
|
781
830
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
782
831
|
// async create(kNode: KNodeFrontend, callback?: Function): Promise<KNodeFrontend> {
|
|
783
|
-
// console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
832
|
+
// if(DEBUG) console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
784
833
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
785
834
|
// let kNodeForServer: any;
|
|
786
835
|
// if (kNode.toServerCopy) kNodeForServer = kNode.toServerCopy();
|
|
@@ -941,7 +990,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
941
990
|
// }
|
|
942
991
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
|
|
943
992
|
// queryInMapofTypeAndContentData(mapId: string, type: string, contentDataPath: string, data: any, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
944
|
-
// console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
993
|
+
// if(DEBUG) console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
945
994
|
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(
|
|
946
995
|
// this.apiUrl + "in_map_of_type_and_content_data/" + this.defaultAction + "/" + mapId + "/" + type + "/" + contentDataPath + "/" + data + ".json"
|
|
947
996
|
// ).pipe(
|
|
@@ -954,7 +1003,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
954
1003
|
// return result;
|
|
955
1004
|
// }
|
|
956
1005
|
// queryInMapofTypeForUser(mapId: string, type: string, iAmid: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
957
|
-
// console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
1006
|
+
// if(DEBUG) console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
958
1007
|
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map_of_type_for_user/" + this.defaultAction + "/" + mapId + "/" + type + "/" + iAmid + ".json").pipe(
|
|
959
1008
|
// map((nodesFromServer) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
960
1009
|
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMap", undefined))
|
|
@@ -968,7 +1017,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
968
1017
|
// destroyByTypeInMap(type: string, mapId: string, callback?: Function): Observable<boolean> {
|
|
969
1018
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
970
1019
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-in-map/" + this.defaultAction + "/" + type + "/" + mapId + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
971
|
-
// tap((_) => console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
1020
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
972
1021
|
// map((serverData: ServerData) => serverData.success),
|
|
973
1022
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeInMap"))
|
|
974
1023
|
// );
|
|
@@ -996,7 +1045,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
996
1045
|
// destroyByUser(iAmid: string): Observable<boolean> {
|
|
997
1046
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
998
1047
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-user/" + this.defaultAction + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
999
|
-
// tap((_: ServerData) => console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
1048
|
+
// tap((_: ServerData) => if(DEBUG) console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
1000
1049
|
// map((serverData: ServerData) => serverData.success),
|
|
1001
1050
|
// catchError(this.handleErrorForObservable<boolean>("destroyByUser"))
|
|
1002
1051
|
// );
|
|
@@ -1022,7 +1071,7 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
1022
1071
|
// destroyByTypeByUser(type: string, iAmid: string, callback?: Function): Observable<boolean> {
|
|
1023
1072
|
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1024
1073
|
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-n-user/" + this.defaultAction + "/" + type + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1025
|
-
// tap((_) => console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
1074
|
+
// tap((_) => if(DEBUG) console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
1026
1075
|
// map((serverData: ServerData) => serverData.success),
|
|
1027
1076
|
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeByUser"))
|
|
1028
1077
|
// );
|
|
@@ -1048,8 +1097,6 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
1048
1097
|
// return result;
|
|
1049
1098
|
// }
|
|
1050
1099
|
};
|
|
1051
|
-
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
1052
|
-
ColaboKnAllEdgeNodeServiceExtended.mapId = config2.GetGeneral("mapId");
|
|
1053
1100
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL = "UPDATE_NODE_NAME_FINAL";
|
|
1054
1101
|
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME = "UPDATE_NODE_NAME";
|
|
1055
1102
|
ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
@@ -1064,6 +1111,8 @@ var import_axios5 = __toESM(require("axios"), 1);
|
|
|
1064
1111
|
var import_i_core19 = require("@colabo-headless/i-core");
|
|
1065
1112
|
var import_i_core20 = require("@colabo-headless/i-core");
|
|
1066
1113
|
var import_i_notifications7 = require("@colabo-utils/i-notifications");
|
|
1114
|
+
var DEBUG5 = false;
|
|
1115
|
+
var DEBUG_VERBOSE3 = false;
|
|
1067
1116
|
var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
1068
1117
|
constructor(http, utilsNotificationService) {
|
|
1069
1118
|
super(utilsNotificationService);
|
|
@@ -1092,15 +1141,18 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1092
1141
|
this.apiUrl = KnalledgeEdgeService.serverAP + "/" + import_i_core18.KEDGE_API_PARAMS.API_PATH + "/";
|
|
1093
1142
|
console.log("[KnalledgeEdgeService] REST API URL: ", import_i_core19.chalk.bold.white(this.apiUrl));
|
|
1094
1143
|
}
|
|
1095
|
-
async getVosWithColaboApi(request) {
|
|
1144
|
+
async getVosWithColaboApi(request, fetchFn) {
|
|
1096
1145
|
request.type = import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API;
|
|
1097
1146
|
console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
|
|
1098
1147
|
const requestSerialized = import_i_core18.ColaboApiOperators.serializeApiRequest(request);
|
|
1099
1148
|
let result;
|
|
1100
|
-
const url = this.apiUrl + import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized
|
|
1149
|
+
const url = import_i_core18.ColaboApiOperators.appendFieldsParam(this.apiUrl + import_i_core18.KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized, request.fields);
|
|
1101
1150
|
console.log("[getVos] url: ", url);
|
|
1102
|
-
const mResult = await import_axios5.default.get(url);
|
|
1103
1151
|
try {
|
|
1152
|
+
if (fetchFn) {
|
|
1153
|
+
return await fetchFn(url);
|
|
1154
|
+
}
|
|
1155
|
+
const mResult = await import_axios5.default.get(url);
|
|
1104
1156
|
const serverData = mResult.data;
|
|
1105
1157
|
result = import_i_core18.ColaboApiOperators.extractVosFromServerData(serverData);
|
|
1106
1158
|
if (!result) {
|
|
@@ -1115,7 +1167,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1115
1167
|
/** creates a new Element (VO) */
|
|
1116
1168
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1117
1169
|
async createWithPromise(kEdge, callback) {
|
|
1118
|
-
console.log(`${(0, import_i_core18.contextReportText)()}`);
|
|
1170
|
+
if (DEBUG_VERBOSE3) console.log(`${(0, import_i_core18.contextReportText)(this)} creating edge: sourceId=${kEdge.sourceId}, targetId=${kEdge.targetId}, type=${kEdge.type}`);
|
|
1119
1171
|
let result;
|
|
1120
1172
|
const request = {
|
|
1121
1173
|
type: import_i_core18.KEDGE_API_TYPE.CREATE_COLABO_API,
|
|
@@ -1138,7 +1190,7 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1138
1190
|
/** creates a new Element (VO) */
|
|
1139
1191
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1140
1192
|
async createWithRequest(request) {
|
|
1141
|
-
console.log(`${(0, import_i_core18.contextReportText)()}`);
|
|
1193
|
+
if (DEBUG5) console.log(`${(0, import_i_core18.contextReportText)(this)} request type=${request.type}, activity=${request.activity ?? "default"}`);
|
|
1142
1194
|
let result;
|
|
1143
1195
|
const url = this.apiUrl;
|
|
1144
1196
|
try {
|
|
@@ -1183,9 +1235,9 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1183
1235
|
* @returns {Observable<KEdge>} retrieved edge
|
|
1184
1236
|
*/
|
|
1185
1237
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1186
|
-
async getById(id, callback) {
|
|
1238
|
+
async getById(id, fields, callback) {
|
|
1187
1239
|
console.log("getById(" + id + ")");
|
|
1188
|
-
const url = this.apiUrl + "one/" + id;
|
|
1240
|
+
const url = import_i_core22.ColaboApiOperators.appendFieldsParam(this.apiUrl + "one/" + id, fields);
|
|
1189
1241
|
try {
|
|
1190
1242
|
const mResult = await import_axios6.default.get(url);
|
|
1191
1243
|
const serverData = mResult.data;
|