@colabo-knalledge/i-core-services 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/cjs/index.js +443 -501
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +442 -501
- package/dist/esm/index.js.map +2 -2
- package/dist/types/lib/cf.service.isomorphic.d.ts +3 -3
- package/dist/types/lib/colabo-api-core.service.d.ts +6 -2
- package/dist/types/lib/kContainer-service.d.ts +1 -1
- 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 +1 -1
- package/dist/types/lib/kNode-service.d.ts +1 -1
- package/package.json +43 -14
package/dist/esm/index.js
CHANGED
|
@@ -8,26 +8,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
8
8
|
if (kind && result) __defProp(target, key, result);
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
|
-
var __async = (__this, __arguments, generator) => {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
var fulfilled = (value) => {
|
|
14
|
-
try {
|
|
15
|
-
step(generator.next(value));
|
|
16
|
-
} catch (e) {
|
|
17
|
-
reject(e);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var rejected = (value) => {
|
|
21
|
-
try {
|
|
22
|
-
step(generator.throw(value));
|
|
23
|
-
} catch (e) {
|
|
24
|
-
reject(e);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
28
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
11
|
|
|
32
12
|
// lib/params.ts
|
|
33
13
|
var MODULE_NAME = "@colabo-knalledge/i-core-services";
|
|
@@ -185,25 +165,43 @@ var errorInterceptor = (error) => {
|
|
|
185
165
|
return Promise.reject(error);
|
|
186
166
|
};
|
|
187
167
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService] declaring ColaboApiCoreService class");
|
|
188
|
-
var ColaboApiCoreService = class
|
|
168
|
+
var ColaboApiCoreService = class {
|
|
169
|
+
static {
|
|
170
|
+
this.interceptorsForAxios = /* @__PURE__ */ new Map();
|
|
171
|
+
}
|
|
189
172
|
// Add a response interceptor to remove JSONP prefix that Colabo.Space is sending
|
|
190
173
|
// https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
|
|
191
174
|
// https://stackoverflow.com/questions/33967189/angular-not-removing-json-prefix
|
|
192
175
|
// [Ejecting an interceptor #2615](https://github.com/axios/axios/issues/2615#issuecomment-567964331)
|
|
193
176
|
static initialize(namespace, specificAxios = axios) {
|
|
194
177
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initializing interceptor for the namespace: ", namespace);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
178
|
+
let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
|
|
179
|
+
if (!axiosImplementation || typeof axiosImplementation.colaboApiInterceptorId === "undefined") {
|
|
180
|
+
const colaboApiInterceptorId = specificAxios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
|
181
|
+
if (!axiosImplementation) {
|
|
182
|
+
axiosImplementation = {
|
|
183
|
+
colaboApiInterceptorId,
|
|
184
|
+
colaboApiInterceptorNamespace: namespace
|
|
185
|
+
};
|
|
186
|
+
this.interceptorsForAxios.set(specificAxios, axiosImplementation);
|
|
187
|
+
} else {
|
|
188
|
+
axiosImplementation.colaboApiInterceptorNamespace = namespace;
|
|
189
|
+
axiosImplementation.colaboApiInterceptorId = colaboApiInterceptorId;
|
|
190
|
+
}
|
|
198
191
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initialized interceptor for the namespace: ", namespace);
|
|
199
192
|
} else {
|
|
200
|
-
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ",
|
|
193
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ", axiosImplementation.colaboApiInterceptorNamespace);
|
|
201
194
|
}
|
|
202
|
-
return
|
|
195
|
+
return axiosImplementation.colaboApiInterceptorId;
|
|
203
196
|
}
|
|
204
197
|
static destroy(namespace, specificAxios = axios) {
|
|
205
198
|
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Destroying interceptor for the namespace: ", namespace);
|
|
206
|
-
|
|
199
|
+
let axiosImplementation = this.interceptorsForAxios.get(specificAxios);
|
|
200
|
+
if (axiosImplementation) {
|
|
201
|
+
specificAxios.interceptors.request.eject(axiosImplementation.colaboApiInterceptorId);
|
|
202
|
+
} else {
|
|
203
|
+
console.log(`[ColaboApiCoreService:initialize] no axiosImplementation found for the provided axios`);
|
|
204
|
+
}
|
|
207
205
|
}
|
|
208
206
|
};
|
|
209
207
|
injectInterceptorService(ColaboApiCoreService);
|
|
@@ -239,77 +237,71 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
239
237
|
console.log("[ColaboKnAllEdgeContainerService] created");
|
|
240
238
|
this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + KCONTAINER_API_PARAMS.API_PATH + "/";
|
|
241
239
|
}
|
|
242
|
-
getById(id) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
|
|
253
|
-
}
|
|
254
|
-
if (ColaboApiOperators.getParentEntity(result).type != KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
|
|
255
|
-
return Promise.reject(new Error("Wrong entity type, expected: " + KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
|
|
256
|
-
}
|
|
257
|
-
} catch (error) {
|
|
258
|
-
console.error(error);
|
|
259
|
-
return Promise.reject(error);
|
|
240
|
+
async getById(id) {
|
|
241
|
+
let result;
|
|
242
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id;
|
|
243
|
+
if (DEBUG) console.log("[getByIdPromise] url: ", url);
|
|
244
|
+
try {
|
|
245
|
+
const mResult = await axios2.get(url);
|
|
246
|
+
const serverData = mResult.data;
|
|
247
|
+
result = ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
|
|
248
|
+
if (!result) {
|
|
249
|
+
return Promise.reject(new Error("Problem with extracting data as an array from serverData"));
|
|
260
250
|
}
|
|
261
|
-
|
|
262
|
-
|
|
251
|
+
if (ColaboApiOperators.getParentEntity(result).type != KCONTAINER_API_PARAMS.KCONTAINER_TYPE) {
|
|
252
|
+
return Promise.reject(new Error("Wrong entity type, expected: " + KCONTAINER_API_PARAMS.KCONTAINER_TYPE));
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.error(error);
|
|
256
|
+
return Promise.reject(error);
|
|
257
|
+
}
|
|
258
|
+
return result;
|
|
263
259
|
}
|
|
264
|
-
create(kContainerWContent) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
console.warn("EMAIL_EXISTS");
|
|
285
|
-
}
|
|
286
|
-
return error.response.data;
|
|
287
|
-
} else if (error.request) {
|
|
288
|
-
console.error("No response received");
|
|
289
|
-
} else {
|
|
290
|
-
console.error("[ColaboKnAllEdgeContainerService:create] Error during request setup:", error.message);
|
|
260
|
+
async create(kContainerWContent) {
|
|
261
|
+
console.log("ColaboKnAllEdgeContainerService.create");
|
|
262
|
+
let result;
|
|
263
|
+
const url = this.apiUrl;
|
|
264
|
+
try {
|
|
265
|
+
const requestRoot = {
|
|
266
|
+
type: KCONTAINER_API_TYPE.CREATE_NEW,
|
|
267
|
+
data: kContainerWContent
|
|
268
|
+
};
|
|
269
|
+
const mResult = await axios2.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
|
|
270
|
+
const serverData = mResult.data;
|
|
271
|
+
result = ColaboApiOperators.extractVoFromServerData(serverData);
|
|
272
|
+
return result;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
if (error.response) {
|
|
275
|
+
console.log("[create]", error);
|
|
276
|
+
console.warn("Response status:", error.response.status);
|
|
277
|
+
console.warn("Response data:", error.response.data);
|
|
278
|
+
if (error.response.data.code === "EMAIL_EXISTS") {
|
|
279
|
+
console.warn("EMAIL_EXISTS");
|
|
291
280
|
}
|
|
292
|
-
|
|
293
|
-
|
|
281
|
+
return error.response.data;
|
|
282
|
+
} else if (error.request) {
|
|
283
|
+
console.error("No response received");
|
|
284
|
+
} else {
|
|
285
|
+
console.error("[ColaboKnAllEdgeContainerService:create] Error during request setup:", error.message);
|
|
294
286
|
}
|
|
295
|
-
|
|
287
|
+
rethrowColaboError(error);
|
|
288
|
+
throw new ColaboErrorUnreachable2();
|
|
289
|
+
}
|
|
296
290
|
}
|
|
297
|
-
update(kContainer) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return result;
|
|
312
|
-
});
|
|
291
|
+
async update(kContainer) {
|
|
292
|
+
console.log("ColaboKnAllEdgeContainerService.update");
|
|
293
|
+
let result;
|
|
294
|
+
const actionType = KCONTAINER_API_TYPE.UPDATE_BY_ID;
|
|
295
|
+
const url = this.apiUrl + "one/" + actionType + "/" + kContainer._id;
|
|
296
|
+
try {
|
|
297
|
+
const mResult = await axios2.put(url, kContainer, HTTP_OPTIONS_CONST_JSON);
|
|
298
|
+
const serverData = mResult.data;
|
|
299
|
+
result = ColaboApiOperators.extractVoFromServerData(serverData);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error(error);
|
|
302
|
+
return Promise.reject(error);
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
313
305
|
}
|
|
314
306
|
/**
|
|
315
307
|
/**
|
|
@@ -320,19 +312,17 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
320
312
|
* @return {*} {Promise<boolean>}
|
|
321
313
|
* @memberof ColaboKnAllEdgeContainerService
|
|
322
314
|
*/
|
|
323
|
-
destroy(id) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
});
|
|
315
|
+
async destroy(id) {
|
|
316
|
+
console.log(`[destroy] id=${id}`);
|
|
317
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.DESTROY_ONE + "/" + id;
|
|
318
|
+
try {
|
|
319
|
+
const mResult = await axios2.delete(url, HTTP_OPTIONS_CONST_JSON);
|
|
320
|
+
const serverData = mResult.data;
|
|
321
|
+
return serverData.success;
|
|
322
|
+
} catch (error) {
|
|
323
|
+
rethrowColaboError(error);
|
|
324
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
325
|
+
}
|
|
336
326
|
}
|
|
337
327
|
/**
|
|
338
328
|
* @param containerId The id of the kContainer to which we want to add kNodes
|
|
@@ -340,23 +330,21 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
340
330
|
* @description adds kNodes in a kContainer
|
|
341
331
|
* @returns edges created between the container and entities added to the container
|
|
342
332
|
*/
|
|
343
|
-
updateAddNodes(containerId, containedIds) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return result;
|
|
359
|
-
});
|
|
333
|
+
async updateAddNodes(containerId, containedIds) {
|
|
334
|
+
if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
|
|
335
|
+
let result;
|
|
336
|
+
const idsStr = containedIds.join(",");
|
|
337
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
|
|
338
|
+
console.log("updateAddNodes called", url);
|
|
339
|
+
try {
|
|
340
|
+
const mResult = await axios2.put(url, {}, HTTP_OPTIONS_CONST_JSON);
|
|
341
|
+
const serverData = mResult.data;
|
|
342
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
console.error(error);
|
|
345
|
+
return Promise.reject(error);
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
360
348
|
}
|
|
361
349
|
/**
|
|
362
350
|
* removes kNodes from a kContainer
|
|
@@ -365,67 +353,61 @@ var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
|
365
353
|
* @param ids The list of ids of the kNodes we want to remove from the container
|
|
366
354
|
* @returns edges created between the container and entities added to the container
|
|
367
355
|
*/
|
|
368
|
-
updateRemoveNodes(id, ids) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return result;
|
|
384
|
-
});
|
|
356
|
+
async updateRemoveNodes(id, ids) {
|
|
357
|
+
console.log("[ColaboKnAllEdgeContainerService::updateRemoveNodes(id, ids)", id, ids);
|
|
358
|
+
let result;
|
|
359
|
+
const idsStr = ids.join(",");
|
|
360
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_REMOVE_KNODE_BY_IDS + "/" + id + "/" + idsStr;
|
|
361
|
+
console.log("updateRemoveNodes called", url);
|
|
362
|
+
try {
|
|
363
|
+
const mResult = await axios2.put(url, {}, HTTP_OPTIONS_CONST_JSON);
|
|
364
|
+
const serverData = mResult.data;
|
|
365
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
366
|
+
} catch (error) {
|
|
367
|
+
console.error(error);
|
|
368
|
+
return Promise.reject(error);
|
|
369
|
+
}
|
|
370
|
+
return result;
|
|
385
371
|
}
|
|
386
372
|
/**
|
|
387
373
|
*
|
|
388
374
|
* @param id The id of the kContainer which knodes we want to retrieve
|
|
389
375
|
* @description retrieves kNodes in a kContainer
|
|
390
376
|
*/
|
|
391
|
-
getInContainer(id) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return [];
|
|
401
|
-
}
|
|
402
|
-
const processedResponse = CFServiceIsomorphic.processVOs(response, KNodeFrontend);
|
|
403
|
-
if (DEBUG_VERBOSE) console.log("[ColaboKnAllEdgeContainerService::getInContainer] response<KNodeFrontend>: ", JSON.stringify(processedResponse, null, 4));
|
|
404
|
-
return processedResponse;
|
|
405
|
-
} catch (error) {
|
|
406
|
-
rethrowColaboError(error);
|
|
407
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
377
|
+
async getInContainer(id) {
|
|
378
|
+
let result;
|
|
379
|
+
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
|
+
try {
|
|
382
|
+
const response = await this.http.get(url).toPromise();
|
|
383
|
+
if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
|
|
384
|
+
if (!response) {
|
|
385
|
+
return [];
|
|
408
386
|
}
|
|
409
|
-
|
|
387
|
+
const processedResponse = CFServiceIsomorphic.processVOs(response, KNodeFrontend);
|
|
388
|
+
if (DEBUG_VERBOSE) console.log("[ColaboKnAllEdgeContainerService::getInContainer] response<KNodeFrontend>: ", JSON.stringify(processedResponse, null, 4));
|
|
389
|
+
return processedResponse;
|
|
390
|
+
} catch (error) {
|
|
391
|
+
rethrowColaboError(error);
|
|
392
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
393
|
+
}
|
|
410
394
|
}
|
|
411
395
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
412
|
-
getVOs(type, upperLayerType) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return Promise.reject(new Error("Couldn't extract VOs from the serverData"));
|
|
422
|
-
}
|
|
423
|
-
} catch (error) {
|
|
424
|
-
console.error(error);
|
|
425
|
-
return Promise.reject(error);
|
|
396
|
+
async getVOs(type, upperLayerType) {
|
|
397
|
+
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);
|
|
400
|
+
try {
|
|
401
|
+
const serverData = mResult.data;
|
|
402
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
403
|
+
if (!result) {
|
|
404
|
+
return Promise.reject(new Error("Couldn't extract VOs from the serverData"));
|
|
426
405
|
}
|
|
427
|
-
|
|
428
|
-
|
|
406
|
+
} catch (error) {
|
|
407
|
+
console.error(error);
|
|
408
|
+
return Promise.reject(error);
|
|
409
|
+
}
|
|
410
|
+
return result;
|
|
429
411
|
}
|
|
430
412
|
/**
|
|
431
413
|
* Extracts upper-layer entity from kContainer and sets it up
|
|
@@ -535,188 +517,167 @@ var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
|
535
517
|
*/
|
|
536
518
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
537
519
|
// OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
|
|
538
|
-
getById(id) {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
throwColaboError2(error.message, EErrorOrigin2.SYSTEM, EColaboErrorKind2.REQUEST_BAD);
|
|
559
|
-
}
|
|
560
|
-
throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
|
|
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}`);
|
|
524
|
+
try {
|
|
525
|
+
const result = await axios3.get(url);
|
|
526
|
+
const data = result.data;
|
|
527
|
+
const kNode = this.extractVOFromDataAsArray(data, KNodeFrontend2);
|
|
528
|
+
return kNode;
|
|
529
|
+
} catch (e) {
|
|
530
|
+
if (isColaboError(e)) {
|
|
531
|
+
throw e;
|
|
532
|
+
}
|
|
533
|
+
const error = e;
|
|
534
|
+
if (error.response) {
|
|
535
|
+
} else if (error.request) {
|
|
536
|
+
throwColaboError2(error.message, EErrorOrigin2.SYSTEM, EColaboErrorKind2.REQUEST_BAD);
|
|
537
|
+
} else {
|
|
538
|
+
console.error("[ColaboKnAllEdgeNodeService:getById] Error during request setup:");
|
|
539
|
+
throwColaboError2(error.message, EErrorOrigin2.SYSTEM, EColaboErrorKind2.REQUEST_BAD);
|
|
561
540
|
}
|
|
562
|
-
|
|
541
|
+
throw new Error("This should never be reached, but throwing just because of TS error in diagnosing unreachable end");
|
|
542
|
+
}
|
|
563
543
|
}
|
|
564
|
-
getVosWithColaboApi(request) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
578
|
-
}
|
|
579
|
-
} catch (error) {
|
|
580
|
-
console.error(error);
|
|
581
|
-
return Promise.reject(error);
|
|
544
|
+
async getVosWithColaboApi(request) {
|
|
545
|
+
request.type = KNODE_API_TYPE.INDEX_COLABO_API;
|
|
546
|
+
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
547
|
+
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);
|
|
551
|
+
try {
|
|
552
|
+
const serverData = mResult.data;
|
|
553
|
+
if (!serverData) return result;
|
|
554
|
+
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
555
|
+
if (!result) {
|
|
556
|
+
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
582
557
|
}
|
|
583
|
-
|
|
584
|
-
|
|
558
|
+
} catch (error) {
|
|
559
|
+
console.error(error);
|
|
560
|
+
return Promise.reject(error);
|
|
561
|
+
}
|
|
562
|
+
return result;
|
|
585
563
|
}
|
|
586
|
-
updateSingleWithColaboApi(request) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
return kNodes[0];
|
|
592
|
-
});
|
|
564
|
+
async updateSingleWithColaboApi(request) {
|
|
565
|
+
const kNodes = await this.updateWithColaboApi(request);
|
|
566
|
+
if (!kNodes) throw new Error("kNodes is not defined");
|
|
567
|
+
if (kNodes.length <= 0) throw new Error("kNodes is empty");
|
|
568
|
+
return kNodes[0];
|
|
593
569
|
}
|
|
594
|
-
updateWithColaboApi(request) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
570
|
+
async updateWithColaboApi(request) {
|
|
571
|
+
request.type = KNODE_API_TYPE.UPDATE_COLABO_API;
|
|
572
|
+
let result;
|
|
573
|
+
const url = this.apiUrl + KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
|
|
574
|
+
console.log("[getVos] url: ", url);
|
|
575
|
+
let mResult;
|
|
576
|
+
try {
|
|
577
|
+
mResult = await axios3.put(url, request);
|
|
578
|
+
} catch (error) {
|
|
579
|
+
console.error(`${contextReportText}Error updating: ${error}`);
|
|
580
|
+
return Promise.reject(error);
|
|
581
|
+
}
|
|
582
|
+
try {
|
|
583
|
+
const serverData = mResult.data;
|
|
584
|
+
if (!serverData.success) {
|
|
585
|
+
console.error(`Error updating: [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
|
|
586
|
+
return Promise.reject(serverData);
|
|
607
587
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
console.error(`Error updating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
612
|
-
return Promise.reject(serverData);
|
|
613
|
-
}
|
|
614
|
-
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
615
|
-
if (!result) {
|
|
616
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
617
|
-
}
|
|
618
|
-
} catch (error) {
|
|
619
|
-
console.error(error);
|
|
620
|
-
return Promise.reject(error);
|
|
588
|
+
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
589
|
+
if (!result) {
|
|
590
|
+
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
621
591
|
}
|
|
622
|
-
|
|
623
|
-
|
|
592
|
+
} catch (error) {
|
|
593
|
+
console.error(error);
|
|
594
|
+
return Promise.reject(error);
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
624
597
|
}
|
|
625
598
|
// getVOs(type:string):Observable<KNodeFrontend[]> {
|
|
626
599
|
// return this.queryInMapofType(ColaboKnAllEdgeNodeService.mapId,type);
|
|
627
600
|
// }
|
|
628
|
-
createSingle(kNode) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
return kNodeCreated;
|
|
634
|
-
});
|
|
601
|
+
async createSingle(kNode) {
|
|
602
|
+
const kNodesCreated = await this.create(kNode);
|
|
603
|
+
if (!Array.isArray(kNodesCreated) || kNodesCreated.length <= 0) throw new Error(`${contextReportText()} No kNode created`);
|
|
604
|
+
const kNodeCreated = kNodesCreated[0];
|
|
605
|
+
return kNodeCreated;
|
|
635
606
|
}
|
|
636
607
|
/** creates a new Element (VO) */
|
|
637
608
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
638
|
-
create(kNode, callback) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
if (!serverData.success) {
|
|
652
|
-
throw new Error(`${contextReportText} Error creating node. [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
653
|
-
}
|
|
654
|
-
result = ColaboApiOperators2.extractVoFromServerData(serverData);
|
|
655
|
-
} catch (error) {
|
|
656
|
-
rethrowColaboError2(error);
|
|
657
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
609
|
+
async create(kNode, callback) {
|
|
610
|
+
console.log(`${contextReportText()}`);
|
|
611
|
+
let result;
|
|
612
|
+
const request = {
|
|
613
|
+
type: KNODE_API_TYPE.CREATE_COLABO_API,
|
|
614
|
+
data: kNode
|
|
615
|
+
};
|
|
616
|
+
const url = this.apiUrl;
|
|
617
|
+
try {
|
|
618
|
+
const mResult = await axios3.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
619
|
+
const serverData = mResult.data;
|
|
620
|
+
if (!serverData.success) {
|
|
621
|
+
throw new Error(`${contextReportText} Error creating node. [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
|
|
658
622
|
}
|
|
659
|
-
|
|
660
|
-
})
|
|
623
|
+
result = ColaboApiOperators2.extractVoFromServerData(serverData);
|
|
624
|
+
} catch (error) {
|
|
625
|
+
rethrowColaboError2(error);
|
|
626
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
627
|
+
}
|
|
628
|
+
return result;
|
|
661
629
|
}
|
|
662
|
-
createWithColaboApi(request) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
630
|
+
async createWithColaboApi(request) {
|
|
631
|
+
request.type = KNODE_API_TYPE.CREATE_COLABO_API;
|
|
632
|
+
let result;
|
|
633
|
+
const url = this.apiUrl + KNODE_API_TYPE.CREATE_COLABO_API + ".json";
|
|
634
|
+
console.log("[getVos] url: ", url);
|
|
635
|
+
let mResult;
|
|
636
|
+
try {
|
|
637
|
+
mResult = await axios3.post(url, request);
|
|
638
|
+
} catch (error) {
|
|
639
|
+
console.error(`${contextReportText}Error updating: ${error}`);
|
|
640
|
+
return Promise.reject(error);
|
|
641
|
+
}
|
|
642
|
+
try {
|
|
643
|
+
const serverData = mResult.data;
|
|
644
|
+
if (!serverData.success) {
|
|
645
|
+
console.error(`Error creating: [code: ${serverData.error?.kind}] ${serverData.error?.message}`);
|
|
646
|
+
return Promise.reject(serverData);
|
|
675
647
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
console.error(`Error creating: [code: ${(_a = serverData.error) == null ? void 0 : _a.kind}] ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
680
|
-
return Promise.reject(serverData);
|
|
681
|
-
}
|
|
682
|
-
result = ColaboApiOperators2.extractVoFromServerData(serverData);
|
|
683
|
-
if (!result) {
|
|
684
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
685
|
-
}
|
|
686
|
-
} catch (error) {
|
|
687
|
-
console.error(error);
|
|
688
|
-
return Promise.reject(error);
|
|
648
|
+
result = ColaboApiOperators2.extractVoFromServerData(serverData);
|
|
649
|
+
if (!result) {
|
|
650
|
+
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
689
651
|
}
|
|
690
|
-
|
|
691
|
-
|
|
652
|
+
} catch (error) {
|
|
653
|
+
console.error(error);
|
|
654
|
+
return Promise.reject(error);
|
|
655
|
+
}
|
|
656
|
+
return result;
|
|
692
657
|
}
|
|
693
658
|
/** destroys the Element (VO) with the `_id === id` */
|
|
694
659
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
695
|
-
destroy(id) {
|
|
696
|
-
return
|
|
697
|
-
return true;
|
|
698
|
-
});
|
|
660
|
+
async destroy(id) {
|
|
661
|
+
return true;
|
|
699
662
|
}
|
|
700
|
-
destroyWithColaboApi(request) {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
713
|
-
}
|
|
714
|
-
} catch (error) {
|
|
715
|
-
console.error(error);
|
|
716
|
-
return Promise.reject(error);
|
|
663
|
+
async destroyWithColaboApi(request) {
|
|
664
|
+
request.type = KNODE_API_TYPE.DESTROY_COLABO_API;
|
|
665
|
+
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
666
|
+
let result;
|
|
667
|
+
const url = this.apiUrl + KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
668
|
+
console.log("[getVos] url: ", url);
|
|
669
|
+
const mResult = await axios3.delete(url);
|
|
670
|
+
try {
|
|
671
|
+
const serverData = mResult.data;
|
|
672
|
+
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
673
|
+
if (!result) {
|
|
674
|
+
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
717
675
|
}
|
|
718
|
-
|
|
719
|
-
|
|
676
|
+
} catch (error) {
|
|
677
|
+
console.error(error);
|
|
678
|
+
return Promise.reject(error);
|
|
679
|
+
}
|
|
680
|
+
return result;
|
|
720
681
|
}
|
|
721
682
|
/** gets Elements (VOs) to populate the list */
|
|
722
683
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -749,24 +710,22 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
749
710
|
this.knAllEdgeRealTimeService = null;
|
|
750
711
|
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
751
712
|
}
|
|
752
|
-
queryByIds(ids, callback) {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
callback(result);
|
|
763
|
-
}
|
|
764
|
-
return result;
|
|
765
|
-
} catch (error) {
|
|
766
|
-
rethrowColaboError3(error);
|
|
767
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
713
|
+
async queryByIds(ids, callback) {
|
|
714
|
+
console.log("queryByIds", ids);
|
|
715
|
+
const idsStr = ids.join(",");
|
|
716
|
+
const url = this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
|
|
717
|
+
try {
|
|
718
|
+
const mResult = await axios4.get(url);
|
|
719
|
+
const serverData = mResult.data;
|
|
720
|
+
const result = CFServiceIsomorphic.processVOs(serverData, KNodeFrontend3);
|
|
721
|
+
if (callback) {
|
|
722
|
+
callback(result);
|
|
768
723
|
}
|
|
769
|
-
|
|
724
|
+
return result;
|
|
725
|
+
} catch (error) {
|
|
726
|
+
rethrowColaboError3(error);
|
|
727
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
728
|
+
}
|
|
770
729
|
}
|
|
771
730
|
/**
|
|
772
731
|
* BREAKING CHANGE: removed as the code is old, sending raw request to backend instead of `IApiRequest`. The right version is available in the `ColaboKnAllEdgeNodeService` class with the same name
|
|
@@ -827,21 +786,19 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
827
786
|
* @example URL:http://localhost:8001/knodes/one/default/5a156965d0b7970f365e1a4b.json
|
|
828
787
|
*/
|
|
829
788
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
830
|
-
destroy(id, callback) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
callback(result);
|
|
838
|
-
}
|
|
839
|
-
return result;
|
|
840
|
-
} catch (error) {
|
|
841
|
-
rethrowColaboError3(error);
|
|
842
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
789
|
+
async destroy(id, callback) {
|
|
790
|
+
try {
|
|
791
|
+
const mResult = await axios4.delete(this.apiUrl + "one/" + this.defaultAction + "/" + id, HTTP_OPTIONS_CONST_JSON);
|
|
792
|
+
const serverData = mResult.data;
|
|
793
|
+
const result = serverData.success;
|
|
794
|
+
if (callback) {
|
|
795
|
+
callback(result);
|
|
843
796
|
}
|
|
844
|
-
|
|
797
|
+
return result;
|
|
798
|
+
} catch (error) {
|
|
799
|
+
rethrowColaboError3(error);
|
|
800
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
801
|
+
}
|
|
845
802
|
}
|
|
846
803
|
/**
|
|
847
804
|
* Updates the provided node on the server and returns its server-updated appearance
|
|
@@ -854,34 +811,32 @@ var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeServic
|
|
|
854
811
|
http://localhost:8001/knodes/one/UPDATE_NODE_NAME_FINAL/5a156935d0b7970f365e1a42.json
|
|
855
812
|
*/
|
|
856
813
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
857
|
-
update(kNode, actionType, patch, callback) {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
callback(result2);
|
|
877
|
-
}
|
|
878
|
-
return result2;
|
|
879
|
-
} catch (error) {
|
|
880
|
-
rethrowColaboError3(error);
|
|
881
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
814
|
+
async update(kNode, actionType, patch, callback) {
|
|
815
|
+
function updateResponse(nodeFromServer) {
|
|
816
|
+
const responseTime = /* @__PURE__ */ new Date();
|
|
817
|
+
}
|
|
818
|
+
let result;
|
|
819
|
+
const id = kNode._id;
|
|
820
|
+
const kNodeForServer = patch ? patch : kNode.toServerCopy();
|
|
821
|
+
actionType = actionType !== null ? actionType : ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL;
|
|
822
|
+
if (kNode.state == VOFrontend.STATE_LOCAL) {
|
|
823
|
+
window.alert(`Please, wait while the entity '${kNode.name}' is being saved, before updating it`);
|
|
824
|
+
result = void 0;
|
|
825
|
+
return result;
|
|
826
|
+
} else {
|
|
827
|
+
try {
|
|
828
|
+
const mResult = await axios4.put(this.apiUrl + "one/" + actionType + "/" + id, kNodeForServer, HTTP_OPTIONS_CONST_JSON);
|
|
829
|
+
const serverData = mResult.data;
|
|
830
|
+
const result2 = this.extractVO(serverData, KNodeFrontend3);
|
|
831
|
+
if (callback) {
|
|
832
|
+
callback(result2);
|
|
882
833
|
}
|
|
834
|
+
return result2;
|
|
835
|
+
} catch (error) {
|
|
836
|
+
rethrowColaboError3(error);
|
|
837
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
883
838
|
}
|
|
884
|
-
}
|
|
839
|
+
}
|
|
885
840
|
}
|
|
886
841
|
// getVOs(type: string): Observable<KNodeFrontend[] | undefined> {
|
|
887
842
|
// return this.queryInMapofType(ColaboKnAllEdgeNodeServiceExtended.mapId, type);
|
|
@@ -1094,75 +1049,67 @@ var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
|
1094
1049
|
this.apiUrl = KnalledgeEdgeService.serverAP + "/" + KEDGE_API_PARAMS.API_PATH + "/";
|
|
1095
1050
|
console.log("[KnalledgeEdgeService] REST API URL: ", chalk2.bold.white(this.apiUrl));
|
|
1096
1051
|
}
|
|
1097
|
-
getVosWithColaboApi(request) {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
1111
|
-
}
|
|
1112
|
-
} catch (error) {
|
|
1113
|
-
console.error(error);
|
|
1114
|
-
return Promise.reject(error);
|
|
1052
|
+
async getVosWithColaboApi(request) {
|
|
1053
|
+
request.type = KEDGE_API_TYPE.INDEX_COLABO_API;
|
|
1054
|
+
console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
|
|
1055
|
+
const requestSerialized = ColaboApiOperators3.serializeApiRequest(request);
|
|
1056
|
+
let result;
|
|
1057
|
+
const url = this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized + ".json";
|
|
1058
|
+
console.log("[getVos] url: ", url);
|
|
1059
|
+
const mResult = await axios5.get(url);
|
|
1060
|
+
try {
|
|
1061
|
+
const serverData = mResult.data;
|
|
1062
|
+
result = ColaboApiOperators3.extractVosFromServerData(serverData);
|
|
1063
|
+
if (!result) {
|
|
1064
|
+
return Promise.reject(new Error("Error with extracting VOs from serverData"));
|
|
1115
1065
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1066
|
+
} catch (error) {
|
|
1067
|
+
console.error(error);
|
|
1068
|
+
return Promise.reject(error);
|
|
1069
|
+
}
|
|
1070
|
+
return result;
|
|
1118
1071
|
}
|
|
1119
1072
|
/** creates a new Element (VO) */
|
|
1120
1073
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1121
|
-
createWithPromise(kEdge, callback) {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
if (!serverData.success) {
|
|
1135
|
-
throw new Error(`${contextReportText2} Error creating edge. code: ${(_a = serverData.error) == null ? void 0 : _a.kind}, error msg: ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
1136
|
-
}
|
|
1137
|
-
result = ColaboApiOperators3.extractVoFromServerData(serverData);
|
|
1138
|
-
} catch (error) {
|
|
1139
|
-
console.error(error);
|
|
1140
|
-
return Promise.reject(error);
|
|
1074
|
+
async createWithPromise(kEdge, callback) {
|
|
1075
|
+
console.log(`${contextReportText2()}`);
|
|
1076
|
+
let result;
|
|
1077
|
+
const request = {
|
|
1078
|
+
type: KEDGE_API_TYPE.CREATE_COLABO_API,
|
|
1079
|
+
data: kEdge
|
|
1080
|
+
};
|
|
1081
|
+
const url = this.apiUrl;
|
|
1082
|
+
try {
|
|
1083
|
+
const mResult = await axios5.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
1084
|
+
const serverData = mResult.data;
|
|
1085
|
+
if (!serverData.success) {
|
|
1086
|
+
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1141
1087
|
}
|
|
1142
|
-
|
|
1143
|
-
})
|
|
1088
|
+
result = ColaboApiOperators3.extractVoFromServerData(serverData);
|
|
1089
|
+
} catch (error) {
|
|
1090
|
+
console.error(error);
|
|
1091
|
+
return Promise.reject(error);
|
|
1092
|
+
}
|
|
1093
|
+
return result;
|
|
1144
1094
|
}
|
|
1145
1095
|
/** creates a new Element (VO) */
|
|
1146
1096
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1147
|
-
createWithRequest(request) {
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
if (!serverData.success) {
|
|
1157
|
-
throw new Error(`${contextReportText2} Error creating edge. code: ${(_a = serverData.error) == null ? void 0 : _a.kind}, error msg: ${(_b = serverData.error) == null ? void 0 : _b.message}`);
|
|
1158
|
-
}
|
|
1159
|
-
result = ColaboApiOperators3.extractVoFromServerData(serverData);
|
|
1160
|
-
} catch (error) {
|
|
1161
|
-
console.error(error);
|
|
1162
|
-
return Promise.reject(error);
|
|
1097
|
+
async createWithRequest(request) {
|
|
1098
|
+
console.log(`${contextReportText2()}`);
|
|
1099
|
+
let result;
|
|
1100
|
+
const url = this.apiUrl;
|
|
1101
|
+
try {
|
|
1102
|
+
const mResult = await axios5.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
1103
|
+
const serverData = mResult.data;
|
|
1104
|
+
if (!serverData.success) {
|
|
1105
|
+
throw new Error(`${contextReportText2} Error creating edge. code: ${serverData.error?.kind}, error msg: ${serverData.error?.message}`);
|
|
1163
1106
|
}
|
|
1164
|
-
|
|
1165
|
-
})
|
|
1107
|
+
result = ColaboApiOperators3.extractVoFromServerData(serverData);
|
|
1108
|
+
} catch (error) {
|
|
1109
|
+
console.error(error);
|
|
1110
|
+
return Promise.reject(error);
|
|
1111
|
+
}
|
|
1112
|
+
return result;
|
|
1166
1113
|
}
|
|
1167
1114
|
};
|
|
1168
1115
|
KnalledgeEdgeService = __decorateClass([
|
|
@@ -1193,23 +1140,21 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1193
1140
|
* @returns {Observable<KEdge>} retrieved edge
|
|
1194
1141
|
*/
|
|
1195
1142
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1196
|
-
getById(id, callback) {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
callback(result);
|
|
1206
|
-
}
|
|
1207
|
-
return result;
|
|
1208
|
-
} catch (error) {
|
|
1209
|
-
rethrowColaboError4(error);
|
|
1210
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1143
|
+
async getById(id, callback) {
|
|
1144
|
+
console.log("getById(" + id + ")");
|
|
1145
|
+
const url = this.apiUrl + "one/" + id;
|
|
1146
|
+
try {
|
|
1147
|
+
const mResult = await axios6.get(url);
|
|
1148
|
+
const serverData = mResult.data;
|
|
1149
|
+
const result = this.extractVO(serverData, KEdge);
|
|
1150
|
+
if (callback) {
|
|
1151
|
+
callback(result);
|
|
1211
1152
|
}
|
|
1212
|
-
|
|
1153
|
+
return result;
|
|
1154
|
+
} catch (error) {
|
|
1155
|
+
rethrowColaboError4(error);
|
|
1156
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1157
|
+
}
|
|
1213
1158
|
}
|
|
1214
1159
|
/**
|
|
1215
1160
|
* Creates the provided edge on the server and returns its server-updated appearance
|
|
@@ -1218,29 +1163,27 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1218
1163
|
* @returns {Observable<KEdge>} the created edge (now with the id and other specific data allocated to it by server, so the caller should fill the original edge with it)
|
|
1219
1164
|
@example http://localhost:8001/kedges/in_map/default/579811d88e12abfa556f6b59.json
|
|
1220
1165
|
*/
|
|
1221
|
-
create(kEdge, callback) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
callback(result2);
|
|
1236
|
-
}
|
|
1237
|
-
return result2;
|
|
1238
|
-
} catch (error) {
|
|
1239
|
-
rethrowColaboError4(error);
|
|
1240
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1166
|
+
async create(kEdge, callback) {
|
|
1167
|
+
let result;
|
|
1168
|
+
if (false) {
|
|
1169
|
+
} else {
|
|
1170
|
+
if (!kEdge.toServerCopy) {
|
|
1171
|
+
throw new Error("kEdge.toServerCopy is not defined");
|
|
1172
|
+
}
|
|
1173
|
+
const kEdgeForServer = kEdge.toServerCopy();
|
|
1174
|
+
try {
|
|
1175
|
+
const mResult = await axios6.post(this.apiUrl, kEdgeForServer, HTTP_OPTIONS_CONST_JSON);
|
|
1176
|
+
const serverData = mResult.data;
|
|
1177
|
+
const result2 = this.extractVO(serverData, KEdge);
|
|
1178
|
+
if (callback) {
|
|
1179
|
+
callback(result2);
|
|
1241
1180
|
}
|
|
1181
|
+
return result2;
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
rethrowColaboError4(error);
|
|
1184
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1242
1185
|
}
|
|
1243
|
-
}
|
|
1186
|
+
}
|
|
1244
1187
|
}
|
|
1245
1188
|
/**
|
|
1246
1189
|
* Deletes the KEdge from the server
|
|
@@ -1249,21 +1192,19 @@ var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
|
1249
1192
|
* @param {function} callback Function to be called when the edge is deleted
|
|
1250
1193
|
* @example URL:http://localhost:8001/kedges/one/default/5a156965d0b7970f365e1a4b.json
|
|
1251
1194
|
*/
|
|
1252
|
-
destroy(id, callback) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
callback(result);
|
|
1260
|
-
}
|
|
1261
|
-
return result;
|
|
1262
|
-
} catch (error) {
|
|
1263
|
-
rethrowColaboError4(error);
|
|
1264
|
-
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1195
|
+
async destroy(id, callback) {
|
|
1196
|
+
try {
|
|
1197
|
+
const mResult = await axios6.delete(this.apiUrl + "one/" + id, HTTP_OPTIONS_CONST_JSON);
|
|
1198
|
+
const serverData = mResult.data;
|
|
1199
|
+
const result = serverData.success;
|
|
1200
|
+
if (callback) {
|
|
1201
|
+
callback(result);
|
|
1265
1202
|
}
|
|
1266
|
-
|
|
1203
|
+
return result;
|
|
1204
|
+
} catch (error) {
|
|
1205
|
+
rethrowColaboError4(error);
|
|
1206
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
1207
|
+
}
|
|
1267
1208
|
}
|
|
1268
1209
|
// /*
|
|
1269
1210
|
// TODO:
|