@colabo-knalledge/i-core-services 1.0.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/README.md +21 -0
- package/dist/cjs/index.js +1516 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.js +1487 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/types/common.d.ts +4 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lib/cf.service.isomorphic.d.ts +50 -0
- package/dist/types/lib/colabo-api-core.service.d.ts +8 -0
- package/dist/types/lib/element.service.isomorphic.d.ts +27 -0
- package/dist/types/lib/kContainer-service.d.ts +73 -0
- package/dist/types/lib/kEdge-service-extended.d.ts +33 -0
- package/dist/types/lib/kEdge-service.d.ts +16 -0
- package/dist/types/lib/kNode-service-extended.d.ts +40 -0
- package/dist/types/lib/kNode-service.d.ts +48 -0
- package/dist/types/lib/params.d.ts +10 -0
- package/package.json +65 -0
|
@@ -0,0 +1,1487 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
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
|
+
|
|
32
|
+
// lib/params.ts
|
|
33
|
+
var MODULE_NAME = "@colabo-knalledge/i-core-services";
|
|
34
|
+
var DEBUG = false;
|
|
35
|
+
var DEBUG_VERBOSE = false;
|
|
36
|
+
|
|
37
|
+
// lib/kContainer-service.ts
|
|
38
|
+
import { GetPuzzle } from "@colabo-utils/i-config";
|
|
39
|
+
import { NotificationMsgType as NotificationMsgType2, rethrowColaboError, ColaboErrorUnreachable as ColaboErrorUnreachable2 } from "@colabo-utils/i-notifications";
|
|
40
|
+
import { KCONTAINER_API_PARAMS, KCONTAINER_API_TYPE, KNodeFrontend, ColaboApiOperators } from "@colabo-knalledge/i-core";
|
|
41
|
+
|
|
42
|
+
// lib/cf.service.isomorphic.ts
|
|
43
|
+
import { of } from "rxjs";
|
|
44
|
+
import { VOIsomorphic } from "@colabo-knalledge/i-core";
|
|
45
|
+
import { Injectable } from "@colabo-headless/i-core";
|
|
46
|
+
import { EErrorOrigin, EColaboErrorKind, throwColaboError, ColaboErrorUnreachable } from "@colabo-utils/i-notifications";
|
|
47
|
+
import { NotificationMsgType } from "@colabo-utils/i-notifications";
|
|
48
|
+
import * as config from "@colabo-utils/i-config";
|
|
49
|
+
console.log("[CFServiceIsomorphic] Injectable: ", Injectable);
|
|
50
|
+
var HIDE_ERRORS = true;
|
|
51
|
+
var HTTP_OPTIONS_CONST_JSON = {
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var CFServiceIsomorphic = class {
|
|
57
|
+
constructor(utilsNotificationService) {
|
|
58
|
+
this.utilsNotificationService = utilsNotificationService;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* processes array of VOs received from server to a local/fronted version
|
|
62
|
+
* @param vofS
|
|
63
|
+
* @param typeT
|
|
64
|
+
*/
|
|
65
|
+
static processVOs(vofS, typeT) {
|
|
66
|
+
const vos = vofS.data;
|
|
67
|
+
if (vos) {
|
|
68
|
+
for (let id = 0; id < vos.length; id++) {
|
|
69
|
+
const vo = typeT.factory(vos[id]);
|
|
70
|
+
vo.state = VOIsomorphic.STATE_SYNCED;
|
|
71
|
+
vos[id] = vo;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return vos;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* extracts VO from the server response `ServerData` and sets it up
|
|
78
|
+
* @param sd - data received from server
|
|
79
|
+
* @param typeT - type (class) of the object expected to be received
|
|
80
|
+
*/
|
|
81
|
+
extractVO(sd, typeT) {
|
|
82
|
+
if (!sd.success) {
|
|
83
|
+
console.warn("[CFServiceIsomorphic::extractVO] serverData.success = false");
|
|
84
|
+
}
|
|
85
|
+
let vo;
|
|
86
|
+
if (sd.data) {
|
|
87
|
+
vo = typeT.factory(sd.data);
|
|
88
|
+
vo.state = VOIsomorphic.STATE_SYNCED;
|
|
89
|
+
return vo;
|
|
90
|
+
} else {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* extracts VO from the server response `ServerData` and sets it up
|
|
96
|
+
* NOTE: Opposite to the `extractVO` method, this method expects the entity wrapped in an array
|
|
97
|
+
* The need and confusion is due to MongoDB difference in `find` method that returns an array,
|
|
98
|
+
* and `findById` that returns a single entity
|
|
99
|
+
* This method is here to treat uniformly both cases (for backend APIs, like `kContainer` API that wraps `findById` into an array)
|
|
100
|
+
* @param sd - data received from server
|
|
101
|
+
* @param typeT - type (class) of the object expected to be received
|
|
102
|
+
* @throws `ColaboError (DATA_MISSING | DATA_INCORRECT_FORMAT)`
|
|
103
|
+
*/
|
|
104
|
+
extractVOFromDataAsArray(sd, typeT) {
|
|
105
|
+
if (!sd.success) {
|
|
106
|
+
console.warn("[CFServiceIsomorphic::extractVO] serverData.success = false");
|
|
107
|
+
}
|
|
108
|
+
let vo;
|
|
109
|
+
if (sd.data && Array.isArray(sd.data) && sd.data.length >= 1) {
|
|
110
|
+
vo = typeT.factory(sd.data[0]);
|
|
111
|
+
vo.state = VOIsomorphic.STATE_SYNCED;
|
|
112
|
+
return vo;
|
|
113
|
+
} else {
|
|
114
|
+
console.error("OK, there is error");
|
|
115
|
+
if (!sd.data) {
|
|
116
|
+
throwColaboError("`data` property is missing in the ServerData object", EErrorOrigin.SYSTEM, EColaboErrorKind.DATA_MISSING);
|
|
117
|
+
}
|
|
118
|
+
if (!Array.isArray(sd.data)) {
|
|
119
|
+
throwColaboError("`data` property is not an array", EErrorOrigin.SYSTEM, EColaboErrorKind.DATA_INCORRECT_FORMAT);
|
|
120
|
+
}
|
|
121
|
+
throwColaboError("`data` is not in right format", EErrorOrigin.SYSTEM, EColaboErrorKind.DATA_INCORRECT_FORMAT);
|
|
122
|
+
throw new ColaboErrorUnreachable();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
errorNotification(error) {
|
|
126
|
+
if (this.utilsNotificationService && !HIDE_ERRORS) {
|
|
127
|
+
this.utilsNotificationService.addNotification({
|
|
128
|
+
type: NotificationMsgType.Error,
|
|
129
|
+
title: "CFService Error",
|
|
130
|
+
msg: JSON.stringify(error)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
handleError() {
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Handle Http operation that failed.
|
|
138
|
+
* Lets the app continue.
|
|
139
|
+
* @param operation - name of the operation that failed
|
|
140
|
+
* @param result - optional value to return as the observable result
|
|
141
|
+
*/
|
|
142
|
+
handleErrorForObservable(operation = "operation", result) {
|
|
143
|
+
return (error) => {
|
|
144
|
+
console.error("[CFServiceIsomorphic:handleError] operation: '%s'. error: ", operation, error);
|
|
145
|
+
this.errorNotification(error);
|
|
146
|
+
return of(result);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// RESTfull backend API url
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
152
|
+
CFServiceIsomorphic.serverAP = config.GetGeneral("serverUrl");
|
|
153
|
+
CFServiceIsomorphic = __decorateClass([
|
|
154
|
+
Injectable()
|
|
155
|
+
], CFServiceIsomorphic);
|
|
156
|
+
|
|
157
|
+
// lib/kContainer-service.ts
|
|
158
|
+
import axios2 from "axios";
|
|
159
|
+
import { currentContext, CONTEXTS, Injectable as Injectable2, HttpClient } from "@colabo-headless/i-core";
|
|
160
|
+
|
|
161
|
+
// lib/colabo-api-core.service.ts
|
|
162
|
+
import axios from "axios";
|
|
163
|
+
import { injectInterceptorService } from "@colabo-headless/i-core";
|
|
164
|
+
console.log("[ColaboApiCoreService] Initializing");
|
|
165
|
+
var responseInterceptor = (response) => {
|
|
166
|
+
if (DEBUG_VERBOSE) console.log("[axios::interceptor::colabo-api-core.service] response.data: ", JSON.stringify(response.data, null, 4));
|
|
167
|
+
if (typeof response.data !== "string") {
|
|
168
|
+
console.error("The data are not in expected format. This could mean, either: 1) axios is used for not only colabo api backend (we do not use it as instance, probably we should eventually), 2) colabo interceptor is installed (`ColaboApiCoreService.initialize`) twice");
|
|
169
|
+
return response;
|
|
170
|
+
}
|
|
171
|
+
let data = response.data;
|
|
172
|
+
response.data = JSON.parse(removeSecurityPrefix(data));
|
|
173
|
+
return response;
|
|
174
|
+
};
|
|
175
|
+
var removeSecurityPrefix = (data) => {
|
|
176
|
+
let index = data.indexOf("\r");
|
|
177
|
+
const indexN = data.indexOf("\n");
|
|
178
|
+
if (index < 0 || index + 1 == indexN) {
|
|
179
|
+
index = indexN;
|
|
180
|
+
}
|
|
181
|
+
data = data.substring(index + 1);
|
|
182
|
+
return data;
|
|
183
|
+
};
|
|
184
|
+
var errorInterceptor = (error) => {
|
|
185
|
+
return Promise.reject(error);
|
|
186
|
+
};
|
|
187
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService] declaring ColaboApiCoreService class");
|
|
188
|
+
var ColaboApiCoreService = class _ColaboApiCoreService {
|
|
189
|
+
// Add a response interceptor to remove JSONP prefix that Colabo.Space is sending
|
|
190
|
+
// https://docs.angularjs.org/api/ng/service/$http#json-vulnerability-protection
|
|
191
|
+
// https://stackoverflow.com/questions/33967189/angular-not-removing-json-prefix
|
|
192
|
+
// [Ejecting an interceptor #2615](https://github.com/axios/axios/issues/2615#issuecomment-567964331)
|
|
193
|
+
static initialize(namespace, specificAxios = axios) {
|
|
194
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initializing interceptor for the namespace: ", namespace);
|
|
195
|
+
if (typeof _ColaboApiCoreService.colaboApiInterceptorId === "undefined") {
|
|
196
|
+
_ColaboApiCoreService.colaboApiInterceptorNamespace = namespace;
|
|
197
|
+
_ColaboApiCoreService.colaboApiInterceptorId = specificAxios.interceptors.response.use(responseInterceptor, errorInterceptor);
|
|
198
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Initialized interceptor for the namespace: ", namespace);
|
|
199
|
+
} else {
|
|
200
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Skipping initialization. The colabo interceptor was already initialized for the namespace: ", _ColaboApiCoreService.colaboApiInterceptorNamespace);
|
|
201
|
+
}
|
|
202
|
+
return _ColaboApiCoreService.colaboApiInterceptorId;
|
|
203
|
+
}
|
|
204
|
+
static destroy(namespace, specificAxios = axios) {
|
|
205
|
+
if (DEBUG_VERBOSE) console.log("[ColaboApiCoreService:initialize] Destroying interceptor for the namespace: ", namespace);
|
|
206
|
+
specificAxios.interceptors.request.eject(_ColaboApiCoreService.colaboApiInterceptorId);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
injectInterceptorService(ColaboApiCoreService);
|
|
210
|
+
|
|
211
|
+
// lib/kContainer-service.ts
|
|
212
|
+
var puzzleConfig;
|
|
213
|
+
var ColaboKnAllEdgeContainerService = class extends CFServiceIsomorphic {
|
|
214
|
+
constructor(http, utilsNotificationService) {
|
|
215
|
+
super(utilsNotificationService);
|
|
216
|
+
this.http = http;
|
|
217
|
+
this.utilsNotificationService = utilsNotificationService;
|
|
218
|
+
this.defaultAction = "default";
|
|
219
|
+
puzzleConfig = GetPuzzle(MODULE_NAME);
|
|
220
|
+
ColaboKnAllEdgeContainerService.serverAP = puzzleConfig.serverUrl;
|
|
221
|
+
if (!this.http) {
|
|
222
|
+
if (currentContext === CONTEXTS.FRONTEND_ANGULAR) {
|
|
223
|
+
const msg = "[ColaboKnAllEdgeContainerService] DI Problem: There is no provider injected for the service `HttpClient`.";
|
|
224
|
+
console.error(msg);
|
|
225
|
+
if (this.utilsNotificationService) {
|
|
226
|
+
const nMsg = {
|
|
227
|
+
title: "DI Problem",
|
|
228
|
+
msg,
|
|
229
|
+
type: NotificationMsgType2.Error
|
|
230
|
+
};
|
|
231
|
+
this.utilsNotificationService.addNotification(nMsg);
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
console.log("[ColaboKnAllEdgeContainerService] Invited from the non-DI (non-angular) context. Initializing HttpClient ...");
|
|
235
|
+
this.http = new HttpClient(null);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
ColaboApiCoreService.initialize("ColaboKnAllEdgeContainerService", axios2);
|
|
239
|
+
console.log("[ColaboKnAllEdgeContainerService] created");
|
|
240
|
+
this.apiUrl = ColaboKnAllEdgeContainerService.serverAP + "/" + KCONTAINER_API_PARAMS.API_PATH + "/";
|
|
241
|
+
}
|
|
242
|
+
getById(id) {
|
|
243
|
+
return __async(this, null, function* () {
|
|
244
|
+
let result;
|
|
245
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_BY_ID + "/" + id;
|
|
246
|
+
if (DEBUG) console.log("[getByIdPromise] url: ", url);
|
|
247
|
+
try {
|
|
248
|
+
const mResult = yield axios2.get(url);
|
|
249
|
+
const serverData = mResult.data;
|
|
250
|
+
result = ColaboApiOperators.extractVoFromServerDataAsArray(serverData);
|
|
251
|
+
if (!result) {
|
|
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);
|
|
260
|
+
}
|
|
261
|
+
return result;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
create(kContainerWContent) {
|
|
265
|
+
return __async(this, null, function* () {
|
|
266
|
+
console.log("ColaboKnAllEdgeContainerService.create");
|
|
267
|
+
let result;
|
|
268
|
+
const url = this.apiUrl;
|
|
269
|
+
try {
|
|
270
|
+
const requestRoot = {
|
|
271
|
+
type: KCONTAINER_API_TYPE.CREATE_NEW,
|
|
272
|
+
data: kContainerWContent
|
|
273
|
+
};
|
|
274
|
+
const mResult = yield axios2.post(url, requestRoot, HTTP_OPTIONS_CONST_JSON);
|
|
275
|
+
const serverData = mResult.data;
|
|
276
|
+
result = ColaboApiOperators.extractVoFromServerData(serverData);
|
|
277
|
+
return result;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (error.response) {
|
|
280
|
+
console.log("[create]", error);
|
|
281
|
+
console.warn("Response status:", error.response.status);
|
|
282
|
+
console.warn("Response data:", error.response.data);
|
|
283
|
+
if (error.response.data.code === "EMAIL_EXISTS") {
|
|
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);
|
|
291
|
+
}
|
|
292
|
+
rethrowColaboError(error);
|
|
293
|
+
throw new ColaboErrorUnreachable2();
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
update(kContainer) {
|
|
298
|
+
return __async(this, null, function* () {
|
|
299
|
+
console.log("ColaboKnAllEdgeContainerService.update");
|
|
300
|
+
let result;
|
|
301
|
+
const actionType = KCONTAINER_API_TYPE.UPDATE_BY_ID;
|
|
302
|
+
const url = this.apiUrl + "one/" + actionType + "/" + kContainer._id;
|
|
303
|
+
try {
|
|
304
|
+
const mResult = yield axios2.put(url, kContainer, HTTP_OPTIONS_CONST_JSON);
|
|
305
|
+
const serverData = mResult.data;
|
|
306
|
+
result = ColaboApiOperators.extractVoFromServerData(serverData);
|
|
307
|
+
} catch (error) {
|
|
308
|
+
console.error(error);
|
|
309
|
+
return Promise.reject(error);
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
/**
|
|
316
|
+
* Deletes the IKContainer on server
|
|
317
|
+
* In server's response, the ServerData.data is equal to the _id of the deleted VO. ServerData.data will be equal to null, if there is no data we intended to delete. In both cases `ServerData.success` will be eq `true`
|
|
318
|
+
* @example URL:http://localhost:8001/knodes/one/default/5a156965d0b7970f365e1a4b.json
|
|
319
|
+
* @param {string} id id of the node to be deleted
|
|
320
|
+
* @return {*} {Promise<boolean>}
|
|
321
|
+
* @memberof ColaboKnAllEdgeContainerService
|
|
322
|
+
*/
|
|
323
|
+
destroy(id) {
|
|
324
|
+
return __async(this, null, function* () {
|
|
325
|
+
console.log(`[destroy] id=${id}`);
|
|
326
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.DESTROY_ONE + "/" + id;
|
|
327
|
+
try {
|
|
328
|
+
const mResult = yield axios2.delete(url, HTTP_OPTIONS_CONST_JSON);
|
|
329
|
+
const serverData = mResult.data;
|
|
330
|
+
return serverData.success;
|
|
331
|
+
} catch (error) {
|
|
332
|
+
rethrowColaboError(error);
|
|
333
|
+
throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* @param containerId The id of the kContainer to which we want to add kNodes
|
|
339
|
+
* @param containedIds The list of ids of the kNodes we want to add to the container
|
|
340
|
+
* @description adds kNodes in a kContainer
|
|
341
|
+
* @returns edges created between the container and entities added to the container
|
|
342
|
+
*/
|
|
343
|
+
updateAddNodes(containerId, containedIds) {
|
|
344
|
+
return __async(this, null, function* () {
|
|
345
|
+
if (DEBUG) console.log("[ColaboKnAllEdgeContainerService::updateAddNodes(containerId, containedIds)", containerId, containedIds);
|
|
346
|
+
let result;
|
|
347
|
+
const idsStr = containedIds.join(",");
|
|
348
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_ADD_KNODE_BY_IDS + "/" + containerId + "/" + idsStr;
|
|
349
|
+
console.log("updateAddNodes called", url);
|
|
350
|
+
try {
|
|
351
|
+
const mResult = yield axios2.put(url, {}, HTTP_OPTIONS_CONST_JSON);
|
|
352
|
+
const serverData = mResult.data;
|
|
353
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
354
|
+
} catch (error) {
|
|
355
|
+
console.error(error);
|
|
356
|
+
return Promise.reject(error);
|
|
357
|
+
}
|
|
358
|
+
return result;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* removes kNodes from a kContainer
|
|
363
|
+
*
|
|
364
|
+
* @param id The id of the kContainer from which we want to remove kNodes
|
|
365
|
+
* @param ids The list of ids of the kNodes we want to remove from the container
|
|
366
|
+
* @returns edges created between the container and entities added to the container
|
|
367
|
+
*/
|
|
368
|
+
updateRemoveNodes(id, ids) {
|
|
369
|
+
return __async(this, null, function* () {
|
|
370
|
+
console.log("[ColaboKnAllEdgeContainerService::updateRemoveNodes(id, ids)", id, ids);
|
|
371
|
+
let result;
|
|
372
|
+
const idsStr = ids.join(",");
|
|
373
|
+
const url = this.apiUrl + this.defaultAction + "/" + KCONTAINER_API_TYPE.UPDATE_REMOVE_KNODE_BY_IDS + "/" + id + "/" + idsStr;
|
|
374
|
+
console.log("updateRemoveNodes called", url);
|
|
375
|
+
try {
|
|
376
|
+
const mResult = yield axios2.put(url, {}, HTTP_OPTIONS_CONST_JSON);
|
|
377
|
+
const serverData = mResult.data;
|
|
378
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
console.error(error);
|
|
381
|
+
return Promise.reject(error);
|
|
382
|
+
}
|
|
383
|
+
return result;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
*
|
|
388
|
+
* @param id The id of the kContainer which knodes we want to retrieve
|
|
389
|
+
* @description retrieves kNodes in a kContainer
|
|
390
|
+
*/
|
|
391
|
+
getInContainer(id) {
|
|
392
|
+
return __async(this, null, function* () {
|
|
393
|
+
let result;
|
|
394
|
+
if (DEBUG) console.log(`this.apiUrl:${this.apiUrl}, this.defaultAction:${this.defaultAction}`);
|
|
395
|
+
const url = `http://127.0.0.1:8001/kcontainers/` + this.defaultAction + "/" + KCONTAINER_API_TYPE.INDEX_IN_CONTAINER + "/" + id + ".json";
|
|
396
|
+
try {
|
|
397
|
+
const response = yield this.http.get(url).toPromise();
|
|
398
|
+
if (DEBUG_VERBOSE) console.log(`[ColaboKnAllEdgeContainerService::getInContainer] response`, response);
|
|
399
|
+
if (!response) {
|
|
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`");
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
412
|
+
getVOs(type, upperLayerType) {
|
|
413
|
+
return __async(this, null, function* () {
|
|
414
|
+
let result;
|
|
415
|
+
const url = `${this.apiUrl}${this.defaultAction}/${KCONTAINER_API_TYPE.INDEX_BY_TYPE}/${type}${upperLayerType ? "/" + upperLayerType : ""}.json`;
|
|
416
|
+
const mResult = yield axios2.get(url);
|
|
417
|
+
try {
|
|
418
|
+
const serverData = mResult.data;
|
|
419
|
+
result = ColaboApiOperators.extractVosFromServerData(serverData);
|
|
420
|
+
if (!result) {
|
|
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);
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Extracts upper-layer entity from kContainer and sets it up
|
|
432
|
+
* @param kContainer - kContainer holding the upper-layer entity
|
|
433
|
+
* @param typeT - type (class) of the expected upper-layer entity
|
|
434
|
+
* @returns the extracted upper-layer entity
|
|
435
|
+
*/
|
|
436
|
+
extractEntityFromPayload(kContainer, typeT) {
|
|
437
|
+
if (!kContainer.dataContent) {
|
|
438
|
+
console.error("[ColaboKnAllEdgeContainerService::extractEntityFromPayload] container payload (kContainer.dataContent) is missing");
|
|
439
|
+
}
|
|
440
|
+
const vo = typeT.factory(kContainer.dataContent, kContainer);
|
|
441
|
+
return vo;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Extracts upper-layer entity (`<T>`) from the lower-layer entity (`IKContainer`) and sets it up into the `<T>` entity
|
|
445
|
+
* @param kContainer - kContainer containing the payload of the upper-layer entity
|
|
446
|
+
* @param factoryOperator - the operator responsible for generating and filling in the data into the upper-layer entity (`<T>`)
|
|
447
|
+
* @returns the extracted upper-layer entity
|
|
448
|
+
*/
|
|
449
|
+
extractEntityFromPayloadWithExternalOperators(kContainer, factoryOperator) {
|
|
450
|
+
if (!kContainer.dataContent) {
|
|
451
|
+
console.error("[ColaboKnAllEdgeContainerService::extractEntityFromPayload] container payload (kContainer.dataContent) is missing");
|
|
452
|
+
}
|
|
453
|
+
const vo = factoryOperator(kContainer.dataContent, kContainer);
|
|
454
|
+
return vo;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Extracts upper-layer entities from kContainers and sets them up
|
|
458
|
+
* @param kContainers - kContainer holding the upper-layer entity
|
|
459
|
+
* @param typeT - type (class) of the expected upper-layer entity
|
|
460
|
+
* @returns the extracted upper-layer entities
|
|
461
|
+
*/
|
|
462
|
+
extractEntitiesFromPayload(kContainers, typeT) {
|
|
463
|
+
const vos = [];
|
|
464
|
+
if (!Array.isArray(kContainers)) return vos;
|
|
465
|
+
for (const kContainer of kContainers) {
|
|
466
|
+
vos.push(this.extractEntityFromPayload(kContainer, typeT));
|
|
467
|
+
}
|
|
468
|
+
return vos;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
ColaboKnAllEdgeContainerService = __decorateClass([
|
|
472
|
+
Injectable2()
|
|
473
|
+
], ColaboKnAllEdgeContainerService);
|
|
474
|
+
|
|
475
|
+
// lib/kNode-service.ts
|
|
476
|
+
import { of as of2 } from "rxjs";
|
|
477
|
+
import axios3 from "axios";
|
|
478
|
+
import { EErrorOrigin as EErrorOrigin2, EColaboErrorKind as EColaboErrorKind2, rethrowColaboError as rethrowColaboError2, throwColaboError as throwColaboError2, isColaboError } from "@colabo-utils/i-notifications";
|
|
479
|
+
import { Injectable as Injectable3 } from "@colabo-headless/i-core";
|
|
480
|
+
import { HttpClient as HttpClient2 } from "@colabo-headless/i-core";
|
|
481
|
+
import { chalk } from "@colabo-headless/i-core";
|
|
482
|
+
import { currentContext as currentContext2, CONTEXTS as CONTEXTS2 } from "@colabo-headless/i-core";
|
|
483
|
+
import { GetPuzzle as GetPuzzle2 } from "@colabo-utils/i-config";
|
|
484
|
+
import { KNodeFrontend as KNodeFrontend2, KNODE_API_TYPE, ColaboApiOperators as ColaboApiOperators2, contextReportText } from "@colabo-knalledge/i-core";
|
|
485
|
+
import { NotificationMsgType as NotificationMsgType3 } from "@colabo-utils/i-notifications";
|
|
486
|
+
import { KNODE_API_PARAMS } from "@colabo-knalledge/i-core";
|
|
487
|
+
console.info(`[ColaboKnAllEdgeNodeService] Current context: ${currentContext2}`);
|
|
488
|
+
var class_id = 1;
|
|
489
|
+
var ColaboKnAllEdgeNodeService = class extends CFServiceIsomorphic {
|
|
490
|
+
/**
|
|
491
|
+
* Initializes and constructs the service
|
|
492
|
+
* In the case of the DI support, it receives http client and notification service
|
|
493
|
+
* @param http DI-ed http client (primarily in the angular environment or testing), if missing it will be created internally
|
|
494
|
+
* @param utilsNotificationService notification service for reporting errors, info and warnings to user, TODO: if missing, should we create a default `console.*` equivalent?
|
|
495
|
+
*/
|
|
496
|
+
constructor(http, utilsNotificationService) {
|
|
497
|
+
super();
|
|
498
|
+
this.http = http;
|
|
499
|
+
this.utilsNotificationService = utilsNotificationService;
|
|
500
|
+
/** the id of the current service instance */
|
|
501
|
+
this.id = class_id++;
|
|
502
|
+
/** default API action used for standard (CRUD) calls */
|
|
503
|
+
this.defaultAction = "default";
|
|
504
|
+
ColaboApiCoreService.initialize("ColaboKnAllEdgeNodeService", axios3);
|
|
505
|
+
if (!this.http) {
|
|
506
|
+
if (currentContext2 == CONTEXTS2.FRONTEND_ANGULAR) {
|
|
507
|
+
const msg = "DI Problem: There is no provider injected for the service `HttpClient`.";
|
|
508
|
+
console.error(msg);
|
|
509
|
+
if (this.utilsNotificationService) {
|
|
510
|
+
const nMsg = {
|
|
511
|
+
title: "DI Problem",
|
|
512
|
+
msg,
|
|
513
|
+
type: NotificationMsgType3.Error
|
|
514
|
+
};
|
|
515
|
+
this.utilsNotificationService.addNotification(nMsg);
|
|
516
|
+
}
|
|
517
|
+
} else {
|
|
518
|
+
this.http = new HttpClient2(null);
|
|
519
|
+
console.log(`[ColaboKnAllEdgeNodeService:${this.id}] invited from the isomorphic context. Creating and initializing vanilla HttpClient ...`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
console.log("[ColaboKnAllEdgeNodeService] created");
|
|
523
|
+
const puzzleConfig2 = GetPuzzle2(MODULE_NAME);
|
|
524
|
+
this.serverAP = puzzleConfig2.serverUrl;
|
|
525
|
+
console.log("[ColaboKnAllEdgeNodeService] connecting to backend: ", chalk.bold.white(this.serverAP));
|
|
526
|
+
this.apiUrl = this.serverAP + "/" + KNODE_API_PARAMS.API_PATH + "/";
|
|
527
|
+
console.log("[ColaboKnAllEdgeNodeService] REST API URL: ", chalk.bold.white(this.apiUrl));
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Get a KN Node from the server by its `id`
|
|
531
|
+
* @param {string} id id of the node
|
|
532
|
+
* @param {function} callback Function to be called when the node is retrieved
|
|
533
|
+
* @returns {Promise<KNodeFrontend>} the retrieved node
|
|
534
|
+
* @throws `ColaboError (REQUEST_BAD | DATA_MISSING | DATA_INCORRECT_FORMAT)`
|
|
535
|
+
*/
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
537
|
+
// OLD: getById(id: string, callback?: Function): Observable<KNodeFrontend> {
|
|
538
|
+
getById(id) {
|
|
539
|
+
return __async(this, null, function* () {
|
|
540
|
+
const url = this.apiUrl + "one/" + this.defaultAction + "/" + id;
|
|
541
|
+
console.log(`[ColaboKnAllEdgeNodeService:getById] url: ${url}`);
|
|
542
|
+
console.log(`[ColaboKnAllEdgeNodeService:getById] ${this.id}`);
|
|
543
|
+
try {
|
|
544
|
+
const result = yield axios3.get(url);
|
|
545
|
+
const data = result.data;
|
|
546
|
+
const kNode = this.extractVOFromDataAsArray(data, KNodeFrontend2);
|
|
547
|
+
return kNode;
|
|
548
|
+
} catch (e) {
|
|
549
|
+
if (isColaboError(e)) {
|
|
550
|
+
throw e;
|
|
551
|
+
}
|
|
552
|
+
const error = e;
|
|
553
|
+
if (error.response) {
|
|
554
|
+
} else if (error.request) {
|
|
555
|
+
throwColaboError2(error.message, EErrorOrigin2.SYSTEM, EColaboErrorKind2.REQUEST_BAD);
|
|
556
|
+
} else {
|
|
557
|
+
console.error("[ColaboKnAllEdgeNodeService:getById] Error during request setup:");
|
|
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");
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
getVosWithColaboApi(request) {
|
|
565
|
+
return __async(this, null, function* () {
|
|
566
|
+
request.type = KNODE_API_TYPE.INDEX_COLABO_API;
|
|
567
|
+
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
568
|
+
let result = [];
|
|
569
|
+
const url = this.apiUrl + KNODE_API_TYPE.INDEX_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
570
|
+
console.log("[getVos] url: ", url);
|
|
571
|
+
const mResult = yield axios3.get(url);
|
|
572
|
+
try {
|
|
573
|
+
const serverData = mResult.data;
|
|
574
|
+
if (!serverData) return result;
|
|
575
|
+
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
576
|
+
if (!result) {
|
|
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);
|
|
582
|
+
}
|
|
583
|
+
return result;
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
updateSingleWithColaboApi(request) {
|
|
587
|
+
return __async(this, null, function* () {
|
|
588
|
+
const kNodes = yield this.updateWithColaboApi(request);
|
|
589
|
+
if (!kNodes) throw new Error("kNodes is not defined");
|
|
590
|
+
if (kNodes.length <= 0) throw new Error("kNodes is empty");
|
|
591
|
+
return kNodes[0];
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
updateWithColaboApi(request) {
|
|
595
|
+
return __async(this, null, function* () {
|
|
596
|
+
var _a, _b;
|
|
597
|
+
request.type = KNODE_API_TYPE.UPDATE_COLABO_API;
|
|
598
|
+
let result;
|
|
599
|
+
const url = this.apiUrl + KNODE_API_TYPE.UPDATE_COLABO_API + ".json";
|
|
600
|
+
console.log("[getVos] url: ", url);
|
|
601
|
+
let mResult;
|
|
602
|
+
try {
|
|
603
|
+
mResult = yield axios3.put(url, request);
|
|
604
|
+
} catch (error) {
|
|
605
|
+
console.error(`${contextReportText}Error updating: ${error}`);
|
|
606
|
+
return Promise.reject(error);
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
const serverData = mResult.data;
|
|
610
|
+
if (!serverData.success) {
|
|
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);
|
|
621
|
+
}
|
|
622
|
+
return result;
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
// getVOs(type:string):Observable<KNodeFrontend[]> {
|
|
626
|
+
// return this.queryInMapofType(ColaboKnAllEdgeNodeService.mapId,type);
|
|
627
|
+
// }
|
|
628
|
+
createSingle(kNode) {
|
|
629
|
+
return __async(this, null, function* () {
|
|
630
|
+
const kNodesCreated = yield this.create(kNode);
|
|
631
|
+
if (!Array.isArray(kNodesCreated) || kNodesCreated.length <= 0) throw new Error(`${contextReportText()} No kNode created`);
|
|
632
|
+
const kNodeCreated = kNodesCreated[0];
|
|
633
|
+
return kNodeCreated;
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
/** creates a new Element (VO) */
|
|
637
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
638
|
+
create(kNode, callback) {
|
|
639
|
+
return __async(this, null, function* () {
|
|
640
|
+
var _a, _b;
|
|
641
|
+
console.log(`${contextReportText()}`);
|
|
642
|
+
let result;
|
|
643
|
+
const request = {
|
|
644
|
+
type: KNODE_API_TYPE.CREATE_COLABO_API,
|
|
645
|
+
data: kNode
|
|
646
|
+
};
|
|
647
|
+
const url = this.apiUrl;
|
|
648
|
+
try {
|
|
649
|
+
const mResult = yield axios3.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
650
|
+
const serverData = mResult.data;
|
|
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`");
|
|
658
|
+
}
|
|
659
|
+
return result;
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
createWithColaboApi(request) {
|
|
663
|
+
return __async(this, null, function* () {
|
|
664
|
+
var _a, _b;
|
|
665
|
+
request.type = KNODE_API_TYPE.CREATE_COLABO_API;
|
|
666
|
+
let result;
|
|
667
|
+
const url = this.apiUrl + KNODE_API_TYPE.CREATE_COLABO_API + ".json";
|
|
668
|
+
console.log("[getVos] url: ", url);
|
|
669
|
+
let mResult;
|
|
670
|
+
try {
|
|
671
|
+
mResult = yield axios3.post(url, request);
|
|
672
|
+
} catch (error) {
|
|
673
|
+
console.error(`${contextReportText}Error updating: ${error}`);
|
|
674
|
+
return Promise.reject(error);
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
const serverData = mResult.data;
|
|
678
|
+
if (!serverData.success) {
|
|
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);
|
|
689
|
+
}
|
|
690
|
+
return result;
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
/** destroys the Element (VO) with the `_id === id` */
|
|
694
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
695
|
+
destroy(id) {
|
|
696
|
+
return __async(this, null, function* () {
|
|
697
|
+
return true;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
destroyWithColaboApi(request) {
|
|
701
|
+
return __async(this, null, function* () {
|
|
702
|
+
request.type = KNODE_API_TYPE.DESTROY_COLABO_API;
|
|
703
|
+
const requestSerialized = ColaboApiOperators2.serializeApiRequest(request);
|
|
704
|
+
let result;
|
|
705
|
+
const url = this.apiUrl + KNODE_API_TYPE.DESTROY_COLABO_API + "/" + this.defaultAction + "/" + requestSerialized + ".json";
|
|
706
|
+
console.log("[getVos] url: ", url);
|
|
707
|
+
const mResult = yield axios3.delete(url);
|
|
708
|
+
try {
|
|
709
|
+
const serverData = mResult.data;
|
|
710
|
+
result = ColaboApiOperators2.extractVosFromServerData(serverData);
|
|
711
|
+
if (!result) {
|
|
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);
|
|
717
|
+
}
|
|
718
|
+
return result;
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
/** gets Elements (VOs) to populate the list */
|
|
722
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
723
|
+
getVOs(type) {
|
|
724
|
+
return of2([]);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
ColaboKnAllEdgeNodeService = __decorateClass([
|
|
728
|
+
Injectable3()
|
|
729
|
+
], ColaboKnAllEdgeNodeService);
|
|
730
|
+
|
|
731
|
+
// lib/kNode-service-extended.ts
|
|
732
|
+
import { Injectable as Injectable4 } from "@colabo-headless/i-core";
|
|
733
|
+
import { HttpClient as HttpClient3 } from "@colabo-headless/i-core";
|
|
734
|
+
import axios4 from "axios";
|
|
735
|
+
import { VOFrontend, KNodeFrontend as KNodeFrontend3 } from "@colabo-knalledge/i-core";
|
|
736
|
+
import { rethrowColaboError as rethrowColaboError3 } from "@colabo-utils/i-notifications";
|
|
737
|
+
import * as config2 from "@colabo-utils/i-config";
|
|
738
|
+
import { KNODE_API_TYPE as KNODE_API_TYPE2 } from "@colabo-knalledge/i-core";
|
|
739
|
+
console.log("[ColaboKnAllEdgeNodeServiceExtended] Injectable: ", Injectable4);
|
|
740
|
+
console.log("[ColaboKnAllEdgeNodeServiceExtended] HttpClient: ", HttpClient3);
|
|
741
|
+
var ColaboKnAllEdgeNodeServiceExtended = class extends ColaboKnAllEdgeNodeService {
|
|
742
|
+
// protected http:HttpClient = null;
|
|
743
|
+
// protected utilsNotificationService: UtilsNotificationService;
|
|
744
|
+
constructor(http, utilsNotificationService) {
|
|
745
|
+
super(http, utilsNotificationService);
|
|
746
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
747
|
+
this.knalledgeMapQueue = null;
|
|
748
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
749
|
+
this.knAllEdgeRealTimeService = null;
|
|
750
|
+
console.log("[ColaboKnAllEdgeNodeServiceExtended:constructor] constructed");
|
|
751
|
+
}
|
|
752
|
+
queryByIds(ids, callback) {
|
|
753
|
+
return __async(this, null, function* () {
|
|
754
|
+
console.log("queryByIds", ids);
|
|
755
|
+
const idsStr = ids.join(",");
|
|
756
|
+
const url = this.apiUrl + KNODE_API_TYPE2.INDEX_ID_IN + "/" + this.defaultAction + "/" + idsStr + ".json";
|
|
757
|
+
try {
|
|
758
|
+
const mResult = yield axios4.get(url);
|
|
759
|
+
const serverData = mResult.data;
|
|
760
|
+
const result = CFServiceIsomorphic.processVOs(serverData, KNodeFrontend3);
|
|
761
|
+
if (callback) {
|
|
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`");
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* 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
|
|
773
|
+
* Creates the provided node on the server and returns its server-updated appearance
|
|
774
|
+
* @param {KNodeFrontend} kNode the pre-populated node to be created on the server
|
|
775
|
+
* @param {function} callback Function to be called when the node is created
|
|
776
|
+
* @returns {Observable<KNodeFrontend>} the created node (now with the id and other specific data allocated to it by server, so the caller should fill the original node with it)
|
|
777
|
+
@example http://localhost:8001/knodes/in_map/default/579811d88e12abfa556f6b59.json
|
|
778
|
+
*/
|
|
779
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
780
|
+
// async create(kNode: KNodeFrontend, callback?: Function): Promise<KNodeFrontend> {
|
|
781
|
+
// console.log(`[ColaboKnAllEdgeNodeServiceExtended.create] kNode: ${JSON.stringify(kNode, null, 4)}`);
|
|
782
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
783
|
+
// let kNodeForServer: any;
|
|
784
|
+
// if (kNode.toServerCopy) kNodeForServer = kNode.toServerCopy();
|
|
785
|
+
// else kNodeForServer = kNode;
|
|
786
|
+
// /*
|
|
787
|
+
// TODO:NG2: in the line
|
|
788
|
+
// `result = this.http.post<KNode>(this.apiUrl, kNodeForServer, HTTP_OPTIONS_CONST_JSON)`
|
|
789
|
+
// we had to replace Generic type setting <KNode> with <ServerData> because it defines the return value
|
|
790
|
+
// (and probably the posted value), because server returns the `ServerData` object
|
|
791
|
+
// */
|
|
792
|
+
// try {
|
|
793
|
+
// const mResult: AxiosResponse<ServerData> = await axios.post<ServerData>(this.apiUrl, kNodeForServer, HTTP_OPTIONS_CONST_JSON);
|
|
794
|
+
// const serverData: ServerData = mResult.data;
|
|
795
|
+
// const result: KNodeFrontend = this.extractVO<KNodeFrontend>(serverData, KNodeFrontend);
|
|
796
|
+
// if (callback) {
|
|
797
|
+
// callback(result);
|
|
798
|
+
// }
|
|
799
|
+
// return result;
|
|
800
|
+
// } catch(error) {
|
|
801
|
+
// rethrowColaboError(error);
|
|
802
|
+
// throw new Error("This should never be reached, but throwing because TS misses seeing `rethrowColaboError` as `never`");
|
|
803
|
+
// }
|
|
804
|
+
// /* TODO:NG2 : remain of the NG1 Promise code to be integrated:
|
|
805
|
+
// let node = this.createPlain({
|
|
806
|
+
// //actionType:'default'
|
|
807
|
+
// }, kNodeForServer, function(nodeFromServer){
|
|
808
|
+
// kNode.$resolved = node.$resolved;
|
|
809
|
+
// kNode.overrideFromServer(nodeFromServer);
|
|
810
|
+
// if(callback) callback(kNode);
|
|
811
|
+
// });
|
|
812
|
+
// //createPlain manages promises for its returning value, in our case 'node', so we need to set its promise to the value we return
|
|
813
|
+
// kNode.$promise = node.$promise;
|
|
814
|
+
// kNode.$resolved = node.$resolved;
|
|
815
|
+
// if(node.$resolved){// for the case promise was resolved immediatelly (in synchonous manner) instead synchronously
|
|
816
|
+
// kNode.overrideFromServer(node);
|
|
817
|
+
// }
|
|
818
|
+
// */
|
|
819
|
+
// // }
|
|
820
|
+
// //we return this value to caller as a dirty one, and then set its value to nodeFromServer when upper callback is called
|
|
821
|
+
// }
|
|
822
|
+
/**
|
|
823
|
+
* Deletes the KNode from the server
|
|
824
|
+
* In server's response, the ServerData.data is equal to the _id of the deleted VO. ServerData.data will be equal to null, if there is no data we intended to delete. In both cases `ServerData.success` will be eq `true`
|
|
825
|
+
* @param {string} id id of the node to be deleted
|
|
826
|
+
* @param {function} callback Function to be called when the node is deleted
|
|
827
|
+
* @example URL:http://localhost:8001/knodes/one/default/5a156965d0b7970f365e1a4b.json
|
|
828
|
+
*/
|
|
829
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
830
|
+
destroy(id, callback) {
|
|
831
|
+
return __async(this, null, function* () {
|
|
832
|
+
try {
|
|
833
|
+
const mResult = yield axios4.delete(this.apiUrl + "one/" + this.defaultAction + "/" + id, HTTP_OPTIONS_CONST_JSON);
|
|
834
|
+
const serverData = mResult.data;
|
|
835
|
+
const result = serverData.success;
|
|
836
|
+
if (callback) {
|
|
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`");
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Updates the provided node on the server and returns its server-updated appearance
|
|
848
|
+
* @param {KNodeFrontend} kNode the pre-populated node to update the content of the existing node on the server
|
|
849
|
+
* @param {string} actionType type of the update action (e.g. UPDATE_NODE_NAME_FINAL, UPDATE_NODE_NAME)
|
|
850
|
+
* @param {any} patch if we provide null here, the `kNode` param is used, but if we provide here an object, it will be patched 'over' the existing node on the server
|
|
851
|
+
* @param {function} callback Function to be called when the node is updated
|
|
852
|
+
* @returns {Observable<KNodeFrontend>} the updated node (now with some specific data updated by the server, so the caller should fill the original node with it)
|
|
853
|
+
@example URLs: http://localhost:8001/knodes/one/UPDATE_NODE_NAME/5a156935d0b7970f365e1a42.json
|
|
854
|
+
http://localhost:8001/knodes/one/UPDATE_NODE_NAME_FINAL/5a156935d0b7970f365e1a42.json
|
|
855
|
+
*/
|
|
856
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
857
|
+
update(kNode, actionType, patch, callback) {
|
|
858
|
+
return __async(this, null, function* () {
|
|
859
|
+
function updateResponse(nodeFromServer) {
|
|
860
|
+
const responseTime = /* @__PURE__ */ new Date();
|
|
861
|
+
}
|
|
862
|
+
let result;
|
|
863
|
+
const id = kNode._id;
|
|
864
|
+
const kNodeForServer = patch ? patch : kNode.toServerCopy();
|
|
865
|
+
actionType = actionType !== null ? actionType : ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL;
|
|
866
|
+
if (kNode.state == VOFrontend.STATE_LOCAL) {
|
|
867
|
+
window.alert(`Please, wait while the entity '${kNode.name}' is being saved, before updating it`);
|
|
868
|
+
result = void 0;
|
|
869
|
+
return result;
|
|
870
|
+
} else {
|
|
871
|
+
try {
|
|
872
|
+
const mResult = yield axios4.put(this.apiUrl + "one/" + actionType + "/" + id, kNodeForServer, HTTP_OPTIONS_CONST_JSON);
|
|
873
|
+
const serverData = mResult.data;
|
|
874
|
+
const result2 = this.extractVO(serverData, KNodeFrontend3);
|
|
875
|
+
if (callback) {
|
|
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`");
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
// getVOs(type: string): Observable<KNodeFrontend[] | undefined> {
|
|
887
|
+
// return this.queryInMapofType(ColaboKnAllEdgeNodeServiceExtended.mapId, type);
|
|
888
|
+
// }
|
|
889
|
+
// getVOsWithPromise(type: string): Promise<IKNode[]> {
|
|
890
|
+
// return this.getVOs(type).toPromise() as Promise<IKNode[]>;
|
|
891
|
+
// }
|
|
892
|
+
// /**
|
|
893
|
+
// * Gets from the server all the KN Nodes that are contained in the map
|
|
894
|
+
// * @param {string} id id of the map
|
|
895
|
+
// * @param {function} callback Function to be called when the nodes are retrieved
|
|
896
|
+
// * @returns {Observable<KNodeFrontend[]>} array of the nodes
|
|
897
|
+
// @example http://localhost:8001/knodes/in_map/default/579811d88e12abfa556f6b59.json
|
|
898
|
+
// */
|
|
899
|
+
// queryInMap(mapId: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
900
|
+
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map/" + this.defaultAction + "/" + mapId).pipe(
|
|
901
|
+
// map((nodesFromServer: ServerData) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
902
|
+
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMap", undefined))
|
|
903
|
+
// );
|
|
904
|
+
// // I get 2 errors for the above lines:
|
|
905
|
+
// // 1st error:
|
|
906
|
+
// /*
|
|
907
|
+
// ../../../isomorphic/puzzles/knalledge/core-services/lib/kNode-service-extended.ts:89:9 - error TS2739: Type 'Observable<unknown>' is missing the following properties from type 'Observable<KNodeFrontend[]>': _isScalar, _trySubscribe, _subscribe
|
|
908
|
+
// 89 const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map/" + this.defaultAction + "/" + mapId).pipe(
|
|
909
|
+
// */
|
|
910
|
+
// //that "solve with replacing the last `);`
|
|
911
|
+
// //with `) as unknown as (Observable<KNodeFrontend[] | undefined>);` to enforce return type
|
|
912
|
+
// // ...
|
|
913
|
+
// // but I still cannot solve the 2nd error:
|
|
914
|
+
// /*
|
|
915
|
+
// ../../../isomorphic/puzzles/knalledge/core-services/lib/kNode-service-extended.ts:90:4 - error TS2345: Argument of type 'OperatorFunction<ServerData, KNodeFrontend[]>' is not assignable to parameter of type 'OperatorFunction<ServerData, unknown>'.
|
|
916
|
+
// Types of parameters 'source' and 'source' are incompatible.
|
|
917
|
+
// Type 'Observable<ServerData>' is missing the following properties from type 'Observable<ServerData>': _isScalar, _trySubscribe, _subscribe
|
|
918
|
+
// 90 map((nodesFromServer: ServerData) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
919
|
+
// */
|
|
920
|
+
// if (callback) {
|
|
921
|
+
// result.subscribe((nodes) => callback(nodes));
|
|
922
|
+
// }
|
|
923
|
+
// return result;
|
|
924
|
+
// }
|
|
925
|
+
// /**
|
|
926
|
+
// * Gets from the server all the KN Nodes that are contained in the map
|
|
927
|
+
// * @param {string} mapId id of the map
|
|
928
|
+
// * @param {function} callback Function to be called when the nodes are retrieved
|
|
929
|
+
// * @returns {Observable<KNodeFrontend[]>} array of the nodes
|
|
930
|
+
// @example http://localhost:8001/knodes/in_map/default/579811d88e12abfa556f6b59.json
|
|
931
|
+
// */
|
|
932
|
+
// // eslint-disable-next-line @typescript-eslint/ban-types
|
|
933
|
+
// queryInMapofType(mapId: string, type: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
934
|
+
// const url: string = this.apiUrl + KNODE_API_TYPE.INDEX_IN_MAP_OF_TYPE + "/" + this.defaultAction + "/" + mapId + "/" + type + ".json";
|
|
935
|
+
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(url).pipe(
|
|
936
|
+
// map((nodesFromServer: ServerData) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
937
|
+
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMapofType", undefined))
|
|
938
|
+
// );
|
|
939
|
+
// if (callback) {
|
|
940
|
+
// result.subscribe((nodes) => callback(nodes));
|
|
941
|
+
// }
|
|
942
|
+
// return result;
|
|
943
|
+
// }
|
|
944
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
|
|
945
|
+
// queryInMapofTypeAndContentData(mapId: string, type: string, contentDataPath: string, data: any, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
946
|
+
// console.log("queryInMapofTypeAndContentData", mapId, type, contentDataPath, data);
|
|
947
|
+
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(
|
|
948
|
+
// this.apiUrl + "in_map_of_type_and_content_data/" + this.defaultAction + "/" + mapId + "/" + type + "/" + contentDataPath + "/" + data + ".json"
|
|
949
|
+
// ).pipe(
|
|
950
|
+
// map((nodesFromServer: ServerData) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
951
|
+
// catchError(this.handleErrorForObservable<KNodeFrontend[] | undefined>("ColaboKnAllEdgeNodeServiceExtended::queryInMapofTypeAndContentData", undefined))
|
|
952
|
+
// );
|
|
953
|
+
// if (callback) {
|
|
954
|
+
// result.subscribe((nodes) => callback(nodes));
|
|
955
|
+
// }
|
|
956
|
+
// return result;
|
|
957
|
+
// }
|
|
958
|
+
// queryInMapofTypeForUser(mapId: string, type: string, iAmid: string, callback?: Function): Observable<KNodeFrontend[] | undefined> {
|
|
959
|
+
// console.log("queryInMapofTypeForUser", mapId, type, iAmid);
|
|
960
|
+
// const result: Observable<KNodeFrontend[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map_of_type_for_user/" + this.defaultAction + "/" + mapId + "/" + type + "/" + iAmid + ".json").pipe(
|
|
961
|
+
// map((nodesFromServer) => CFServiceIsomorphic.processVOs(nodesFromServer, KNodeFrontend)),
|
|
962
|
+
// catchError(this.handleErrorForObservable("ColaboKnAllEdgeNodeServiceExtended::queryInMap", undefined))
|
|
963
|
+
// );
|
|
964
|
+
// if (callback) {
|
|
965
|
+
// result.subscribe((nodes) => callback(nodes));
|
|
966
|
+
// }
|
|
967
|
+
// return result;
|
|
968
|
+
// }
|
|
969
|
+
// // eslint-disable-next-line @typescript-eslint/ban-types
|
|
970
|
+
// destroyByTypeInMap(type: string, mapId: string, callback?: Function): Observable<boolean> {
|
|
971
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
972
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-in-map/" + this.defaultAction + "/" + type + "/" + mapId + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
973
|
+
// tap((_) => console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
974
|
+
// map((serverData: ServerData) => serverData.success),
|
|
975
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeInMap"))
|
|
976
|
+
// );
|
|
977
|
+
// /* TODO:NG2
|
|
978
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
979
|
+
// //
|
|
980
|
+
// // let change = new puzzles.changes.Change();
|
|
981
|
+
// // change.value = null;
|
|
982
|
+
// // change.valueBeforeChange = null; //TODO
|
|
983
|
+
// // change.reference = id;
|
|
984
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
985
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
986
|
+
// // // change.action = null;
|
|
987
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
988
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
989
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
990
|
+
// //
|
|
991
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
992
|
+
// }*/
|
|
993
|
+
// if (callback) {
|
|
994
|
+
// result.subscribe((success) => callback(success));
|
|
995
|
+
// }
|
|
996
|
+
// return result;
|
|
997
|
+
// }
|
|
998
|
+
// destroyByUser(iAmid: string): Observable<boolean> {
|
|
999
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1000
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-user/" + this.defaultAction + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1001
|
+
// tap((_: ServerData) => console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
1002
|
+
// map((serverData: ServerData) => serverData.success),
|
|
1003
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByUser"))
|
|
1004
|
+
// );
|
|
1005
|
+
// /* TODO:NG2
|
|
1006
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1007
|
+
// //
|
|
1008
|
+
// // let change = new puzzles.changes.Change();
|
|
1009
|
+
// // change.value = null;
|
|
1010
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1011
|
+
// // change.reference = id;
|
|
1012
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1013
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1014
|
+
// // // change.action = null;
|
|
1015
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1016
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1017
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1018
|
+
// //
|
|
1019
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1020
|
+
// }*/
|
|
1021
|
+
// return result;
|
|
1022
|
+
// }
|
|
1023
|
+
// // eslint-disable-next-line @typescript-eslint/ban-types
|
|
1024
|
+
// destroyByTypeByUser(type: string, iAmid: string, callback?: Function): Observable<boolean> {
|
|
1025
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1026
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-n-user/" + this.defaultAction + "/" + type + "/" + iAmid + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1027
|
+
// tap((_) => console.log(`deleted nodes type=${type} and iAmid=${iAmid}`)),
|
|
1028
|
+
// map((serverData: ServerData) => serverData.success),
|
|
1029
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeByUser"))
|
|
1030
|
+
// );
|
|
1031
|
+
// /* TODO:NG2
|
|
1032
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1033
|
+
// //
|
|
1034
|
+
// // let change = new puzzles.changes.Change();
|
|
1035
|
+
// // change.value = null;
|
|
1036
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1037
|
+
// // change.reference = id;
|
|
1038
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1039
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1040
|
+
// // // change.action = null;
|
|
1041
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1042
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1043
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1044
|
+
// //
|
|
1045
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1046
|
+
// }*/
|
|
1047
|
+
// if (callback) {
|
|
1048
|
+
// result.subscribe((success) => callback(success));
|
|
1049
|
+
// }
|
|
1050
|
+
// return result;
|
|
1051
|
+
// }
|
|
1052
|
+
};
|
|
1053
|
+
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
1054
|
+
ColaboKnAllEdgeNodeServiceExtended.mapId = config2.GetGeneral("mapId");
|
|
1055
|
+
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME_FINAL = "UPDATE_NODE_NAME_FINAL";
|
|
1056
|
+
ColaboKnAllEdgeNodeServiceExtended.UPDATE_NODE_NAME = "UPDATE_NODE_NAME";
|
|
1057
|
+
ColaboKnAllEdgeNodeServiceExtended = __decorateClass([
|
|
1058
|
+
Injectable4()
|
|
1059
|
+
], ColaboKnAllEdgeNodeServiceExtended);
|
|
1060
|
+
|
|
1061
|
+
// lib/kEdge-service.ts
|
|
1062
|
+
import { Injectable as Injectable5 } from "@colabo-headless/i-core";
|
|
1063
|
+
import { HttpClient as HttpClient4 } from "@colabo-headless/i-core";
|
|
1064
|
+
import { ColaboApiOperators as ColaboApiOperators3, KEDGE_API_TYPE, KEDGE_API_PARAMS, contextReportText as contextReportText2 } from "@colabo-knalledge/i-core";
|
|
1065
|
+
import axios5 from "axios";
|
|
1066
|
+
import { chalk as chalk2 } from "@colabo-headless/i-core";
|
|
1067
|
+
import { currentContext as currentContext3, CONTEXTS as CONTEXTS3 } from "@colabo-headless/i-core";
|
|
1068
|
+
import { NotificationMsgType as NotificationMsgType4 } from "@colabo-utils/i-notifications";
|
|
1069
|
+
var KnalledgeEdgeService = class extends CFServiceIsomorphic {
|
|
1070
|
+
constructor(http, utilsNotificationService) {
|
|
1071
|
+
super(utilsNotificationService);
|
|
1072
|
+
this.http = http;
|
|
1073
|
+
this.defaultAction = "default";
|
|
1074
|
+
ColaboApiCoreService.initialize("ColaboKnAllEdgeNodeService", axios5);
|
|
1075
|
+
if (!this.http) {
|
|
1076
|
+
if (currentContext3 == CONTEXTS3.FRONTEND_ANGULAR) {
|
|
1077
|
+
const msg = "DI Problem: There is no provider injected for the service `HttpClient`.";
|
|
1078
|
+
console.error(msg);
|
|
1079
|
+
if (this.utilsNotificationService) {
|
|
1080
|
+
const nMsg = {
|
|
1081
|
+
title: "DI Problem",
|
|
1082
|
+
msg,
|
|
1083
|
+
type: NotificationMsgType4.Error
|
|
1084
|
+
};
|
|
1085
|
+
this.utilsNotificationService.addNotification(nMsg);
|
|
1086
|
+
}
|
|
1087
|
+
} else {
|
|
1088
|
+
console.log("[KnalledgeEdgeService] invited from the isomorphic context. Initializing HttpClient ...");
|
|
1089
|
+
this.http = new HttpClient4(null);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
console.log("[KnalledgeEdgeService] created");
|
|
1093
|
+
console.log("[KnalledgeEdgeService] connecting to backend: ", chalk2.bold.white(KnalledgeEdgeService.serverAP));
|
|
1094
|
+
this.apiUrl = KnalledgeEdgeService.serverAP + "/" + KEDGE_API_PARAMS.API_PATH + "/";
|
|
1095
|
+
console.log("[KnalledgeEdgeService] REST API URL: ", chalk2.bold.white(this.apiUrl));
|
|
1096
|
+
}
|
|
1097
|
+
getVosWithColaboApi(request) {
|
|
1098
|
+
return __async(this, null, function* () {
|
|
1099
|
+
request.type = KEDGE_API_TYPE.INDEX_COLABO_API;
|
|
1100
|
+
console.log(`[KnalledgeEdgeService.getVosWithColaboApi] request: ${JSON.stringify(request, null, 4)}`);
|
|
1101
|
+
const requestSerialized = ColaboApiOperators3.serializeApiRequest(request);
|
|
1102
|
+
let result;
|
|
1103
|
+
const url = this.apiUrl + KEDGE_API_TYPE.INDEX_COLABO_API + "/" + requestSerialized + ".json";
|
|
1104
|
+
console.log("[getVos] url: ", url);
|
|
1105
|
+
const mResult = yield axios5.get(url);
|
|
1106
|
+
try {
|
|
1107
|
+
const serverData = mResult.data;
|
|
1108
|
+
result = ColaboApiOperators3.extractVosFromServerData(serverData);
|
|
1109
|
+
if (!result) {
|
|
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);
|
|
1115
|
+
}
|
|
1116
|
+
return result;
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
/** creates a new Element (VO) */
|
|
1120
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1121
|
+
createWithPromise(kEdge, callback) {
|
|
1122
|
+
return __async(this, null, function* () {
|
|
1123
|
+
var _a, _b;
|
|
1124
|
+
console.log(`${contextReportText2()}`);
|
|
1125
|
+
let result;
|
|
1126
|
+
const request = {
|
|
1127
|
+
type: KEDGE_API_TYPE.CREATE_COLABO_API,
|
|
1128
|
+
data: kEdge
|
|
1129
|
+
};
|
|
1130
|
+
const url = this.apiUrl;
|
|
1131
|
+
try {
|
|
1132
|
+
const mResult = yield axios5.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
1133
|
+
const serverData = mResult.data;
|
|
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);
|
|
1141
|
+
}
|
|
1142
|
+
return result;
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
/** creates a new Element (VO) */
|
|
1146
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types
|
|
1147
|
+
createWithRequest(request) {
|
|
1148
|
+
return __async(this, null, function* () {
|
|
1149
|
+
var _a, _b;
|
|
1150
|
+
console.log(`${contextReportText2()}`);
|
|
1151
|
+
let result;
|
|
1152
|
+
const url = this.apiUrl;
|
|
1153
|
+
try {
|
|
1154
|
+
const mResult = yield axios5.post(url, request, HTTP_OPTIONS_CONST_JSON);
|
|
1155
|
+
const serverData = mResult.data;
|
|
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);
|
|
1163
|
+
}
|
|
1164
|
+
return result;
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
KnalledgeEdgeService = __decorateClass([
|
|
1169
|
+
Injectable5()
|
|
1170
|
+
], KnalledgeEdgeService);
|
|
1171
|
+
|
|
1172
|
+
// lib/kEdge-service-extended.ts
|
|
1173
|
+
import { Injectable as Injectable6 } from "@colabo-headless/i-core";
|
|
1174
|
+
import { KEdgeFrontend as KEdge } from "@colabo-knalledge/i-core";
|
|
1175
|
+
import axios6 from "axios";
|
|
1176
|
+
import { rethrowColaboError as rethrowColaboError4 } from "@colabo-utils/i-notifications";
|
|
1177
|
+
var KnalledgeEdgeServiceExtended = class extends KnalledgeEdgeService {
|
|
1178
|
+
constructor(http, utilsNotificationService) {
|
|
1179
|
+
super(http, utilsNotificationService);
|
|
1180
|
+
//http://api.colabo.space/kedges/
|
|
1181
|
+
// "http://127.0.0.1:888/kedges/";
|
|
1182
|
+
//private defaultAction:string = 'default'; not used here - only for nodes is used
|
|
1183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1184
|
+
this.knalledgeMapQueue = null;
|
|
1185
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1186
|
+
this.knAllEdgeRealTimeService = null;
|
|
1187
|
+
console.log("KnalledgeEdgeServiceExtended:: constructor");
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Gets an KN Edge from the server by its id
|
|
1191
|
+
* @param {string} id id of the edge
|
|
1192
|
+
* @param {function} callback Function to be called when the edge is retrieved
|
|
1193
|
+
* @returns {Observable<KEdge>} retrieved edge
|
|
1194
|
+
*/
|
|
1195
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
1196
|
+
getById(id, callback) {
|
|
1197
|
+
return __async(this, null, function* () {
|
|
1198
|
+
console.log("getById(" + id + ")");
|
|
1199
|
+
const url = this.apiUrl + "one/" + id;
|
|
1200
|
+
try {
|
|
1201
|
+
const mResult = yield axios6.get(url);
|
|
1202
|
+
const serverData = mResult.data;
|
|
1203
|
+
const result = this.extractVO(serverData, KEdge);
|
|
1204
|
+
if (callback) {
|
|
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`");
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Creates the provided edge on the server and returns its server-updated appearance
|
|
1216
|
+
* @param {KEdge} kEdge the pre-populated edge to be created on the server
|
|
1217
|
+
* @param {function} callback Function to be called when the edge is created
|
|
1218
|
+
* @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
|
+
@example http://localhost:8001/kedges/in_map/default/579811d88e12abfa556f6b59.json
|
|
1220
|
+
*/
|
|
1221
|
+
create(kEdge, callback) {
|
|
1222
|
+
return __async(this, null, function* () {
|
|
1223
|
+
let result;
|
|
1224
|
+
if (false) {
|
|
1225
|
+
} else {
|
|
1226
|
+
if (!kEdge.toServerCopy) {
|
|
1227
|
+
throw new Error("kEdge.toServerCopy is not defined");
|
|
1228
|
+
}
|
|
1229
|
+
const kEdgeForServer = kEdge.toServerCopy();
|
|
1230
|
+
try {
|
|
1231
|
+
const mResult = yield axios6.post(this.apiUrl, kEdgeForServer, HTTP_OPTIONS_CONST_JSON);
|
|
1232
|
+
const serverData = mResult.data;
|
|
1233
|
+
const result2 = this.extractVO(serverData, KEdge);
|
|
1234
|
+
if (callback) {
|
|
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`");
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Deletes the KEdge from the server
|
|
1247
|
+
* In server's response, the ServerData.data is equal to the _id of the deleted VO. ServerData.data will be equal to null, if there is no data we intended to delete. In both cases `ServerData.success` will be eq `true`
|
|
1248
|
+
* @param {string} id id of the edge to be deleted
|
|
1249
|
+
* @param {function} callback Function to be called when the edge is deleted
|
|
1250
|
+
* @example URL:http://localhost:8001/kedges/one/default/5a156965d0b7970f365e1a4b.json
|
|
1251
|
+
*/
|
|
1252
|
+
destroy(id, callback) {
|
|
1253
|
+
return __async(this, null, function* () {
|
|
1254
|
+
try {
|
|
1255
|
+
const mResult = yield axios6.delete(this.apiUrl + "one/" + id, HTTP_OPTIONS_CONST_JSON);
|
|
1256
|
+
const serverData = mResult.data;
|
|
1257
|
+
const result = serverData.success;
|
|
1258
|
+
if (callback) {
|
|
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`");
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
// /*
|
|
1269
|
+
// TODO:
|
|
1270
|
+
// When needed, we could develop these functions that are already supported on backend:
|
|
1271
|
+
// //gets all edges between 2 specific nodes:
|
|
1272
|
+
// queryBetween(sourceId:string, targetId:string, callback?:Function)
|
|
1273
|
+
// {
|
|
1274
|
+
// // return this.queryPlain({ searchParam:id, type:'between' }, callback);
|
|
1275
|
+
// }
|
|
1276
|
+
// //gets all edges connected to the specific node (with the provided id) (both those edges whose it's source node and those whose this is a target node)
|
|
1277
|
+
// // @example URL: URL:http://localhost:8001/kedges/connected/5a156965d0b7970f365e1a4b.json
|
|
1278
|
+
// queryConnected(id:string, callback?:Function)
|
|
1279
|
+
// {
|
|
1280
|
+
// // return this.queryPlain({ searchParam:id, type:'connected' }, callback);
|
|
1281
|
+
// }
|
|
1282
|
+
// //destroys all the edges connected to the specific node
|
|
1283
|
+
// //destroyConnected(id:string)
|
|
1284
|
+
// {
|
|
1285
|
+
// }
|
|
1286
|
+
// */
|
|
1287
|
+
// /**
|
|
1288
|
+
// * Gets from the server all the KN Edges that are contained in the map
|
|
1289
|
+
// * @param {string} id id of the map
|
|
1290
|
+
// * @param {function} callback Function to be called when the edges are retrieved
|
|
1291
|
+
// * @returns {Observable<KEdge[]>} array of the edges
|
|
1292
|
+
// @example URL: http://localhost:8001/kedges/in_map/579811d88e12abfa556f6b59.json
|
|
1293
|
+
// */
|
|
1294
|
+
// // eslint-disable-next-line @typescript-eslint/ban-types
|
|
1295
|
+
// queryInMap(id: string, callback?: Function): Observable<KEdge[] | undefined> {
|
|
1296
|
+
// const result: Observable<KEdge[] | undefined> = this.http.get<ServerData>(this.apiUrl + "in_map/" + id).pipe(
|
|
1297
|
+
// map((edgesS: ServerData) => CFServiceIsomorphic.processVOs<KEdge>(edgesS, KEdge)),
|
|
1298
|
+
// // map(edgesFromServer => CFServiceIsomorphic.processVOs<KEdge>(edgesFromServer, KEdge)),
|
|
1299
|
+
// catchError(this.handleErrorForObservable("KnalledgeEdgeService::queryInMap", undefined))
|
|
1300
|
+
// );
|
|
1301
|
+
// if (callback) {
|
|
1302
|
+
// result.subscribe((edges) => callback(edges));
|
|
1303
|
+
// }
|
|
1304
|
+
// return result;
|
|
1305
|
+
// }
|
|
1306
|
+
// /**
|
|
1307
|
+
// * UNSUPPORTED TEMPORARILY #551 (https://github.com/Cha-OS/colabo/issues/551)
|
|
1308
|
+
// * Gets from the server all the KN Edges that are contained in the map
|
|
1309
|
+
// * @param {string} id id of the map
|
|
1310
|
+
// * @param {function} callback Function to be called when the edges are retrieved
|
|
1311
|
+
// * @returns {Observable<KEdge[]>} array of the edges
|
|
1312
|
+
// @example URL: TBD
|
|
1313
|
+
// //
|
|
1314
|
+
// queryForMapTypeUserWTargetNodes(mapId:string, type:string, iAmid:string=null): Observable<KEdge[]>
|
|
1315
|
+
// {
|
|
1316
|
+
// var result:Observable<KEdge[]> = this.http.get<ServerData>(this.apiUrl+'for_map_type_user_w_target_nodes/'+mapId+'/'+type+'/'+iAmid+'.json')
|
|
1317
|
+
// .pipe(
|
|
1318
|
+
// map(edgesFromServer => CFServiceIsomorphic.processVOs(edgesFromServer, KEdge)),
|
|
1319
|
+
// catchError(this.handleError('KnalledgeEdgeService::queryForMapTypeUserWTargetNodes', null))
|
|
1320
|
+
// );
|
|
1321
|
+
// return result;
|
|
1322
|
+
// }
|
|
1323
|
+
// */
|
|
1324
|
+
// /**
|
|
1325
|
+
// * Gets from the server all the KN Edges that are contained in the map
|
|
1326
|
+
// * @param {string} id id of the map
|
|
1327
|
+
// * @param {function} callback Function to be called when the edges are retrieved
|
|
1328
|
+
// * @returns {Observable<KEdge[]>} array of the edges
|
|
1329
|
+
// @example URL: TBD
|
|
1330
|
+
// */
|
|
1331
|
+
// queryForMapTypeUser(mapId: string, type: string, iAmid: string = ""): Observable<KEdge[] | undefined> {
|
|
1332
|
+
// const result: Observable<KEdge[] | undefined> = this.http.get<ServerData>(this.apiUrl + "for_map_type_user/" + mapId + "/" + type + "/" + iAmid + ".json").pipe(
|
|
1333
|
+
// map((edgesFromServer: ServerData) => CFServiceIsomorphic.processVOs<KEdge>(edgesFromServer, KEdge)),
|
|
1334
|
+
// catchError(this.handleErrorForObservable("KnalledgeEdgeService::queryForMapTypeUser", undefined))
|
|
1335
|
+
// );
|
|
1336
|
+
// return result;
|
|
1337
|
+
// }
|
|
1338
|
+
/**
|
|
1339
|
+
* Gets from the server all the KN Edges that are contained in the map
|
|
1340
|
+
* @param {string} id id of the map
|
|
1341
|
+
* @param {function} callback Function to be called when the edges are retrieved
|
|
1342
|
+
* @returns {Observable<KEdge[]>} array of the edges
|
|
1343
|
+
@example URL: TBD
|
|
1344
|
+
*/
|
|
1345
|
+
// queryFromToForType(from: string | null, to: string, type: string = ""): Observable<KEdge[] | undefined> {
|
|
1346
|
+
// const result: Observable<KEdge[] | undefined> = this.http.get<ServerData>(this.apiUrl + "from_to_for_type/" + from + "/" + to + "/" + type + ".json").pipe(
|
|
1347
|
+
// map((edgesFromServer: ServerData) => CFServiceIsomorphic.processVOs<KEdge>(edgesFromServer, KEdge)),
|
|
1348
|
+
// catchError(this.handleErrorForObservable("KnalledgeEdgeService::queryForMapTypeUser", undefined))
|
|
1349
|
+
// );
|
|
1350
|
+
// return result;
|
|
1351
|
+
// }
|
|
1352
|
+
// public destroyInMap(mapid: string, callback?: Function): Observable<boolean> {
|
|
1353
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1354
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "in-map/" + mapid, HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1355
|
+
// tap((_) => console.log(`deleted edges for mapid=${mapid}`)),
|
|
1356
|
+
// map((serverData) => serverData.success),
|
|
1357
|
+
// catchError(this.handleErrorForObservable<boolean>("destroy"))
|
|
1358
|
+
// );
|
|
1359
|
+
// if (callback) {
|
|
1360
|
+
// result.subscribe((success) => callback(success));
|
|
1361
|
+
// }
|
|
1362
|
+
// return result;
|
|
1363
|
+
// }
|
|
1364
|
+
// /**
|
|
1365
|
+
// * @description BACKEND NOT FINISHED!
|
|
1366
|
+
// */
|
|
1367
|
+
// private destroyByTypeInMap(type: string, mapId: string): Observable<boolean> {
|
|
1368
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1369
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-in-map/" + type + "/" + mapId + ".json", HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1370
|
+
// tap((_) => console.log(`deleted nodes type=${type} and mapId=${mapId}`)),
|
|
1371
|
+
// map((serverData) => serverData.success),
|
|
1372
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeInMap"))
|
|
1373
|
+
// );
|
|
1374
|
+
// /* TODO:NG2
|
|
1375
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1376
|
+
// //
|
|
1377
|
+
// // let change = new puzzles.changes.Change();
|
|
1378
|
+
// // change.value = null;
|
|
1379
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1380
|
+
// // change.reference = id;
|
|
1381
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1382
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1383
|
+
// // // change.action = null;
|
|
1384
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1385
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1386
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1387
|
+
// //
|
|
1388
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1389
|
+
// }*/
|
|
1390
|
+
// return result;
|
|
1391
|
+
// }
|
|
1392
|
+
// destroyByTypeByUser(type: string, iAmid: string, callback?: Function): Observable<boolean> {
|
|
1393
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1394
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-type-n-user/" + type + "/" + iAmid, HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1395
|
+
// tap((_) => console.log(`deleted edges type=${type} and iAmid=${iAmid}`)),
|
|
1396
|
+
// map((serverData) => serverData.success),
|
|
1397
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByTypeByUser"))
|
|
1398
|
+
// );
|
|
1399
|
+
// /* TODO:NG2
|
|
1400
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1401
|
+
// //
|
|
1402
|
+
// // let change = new puzzles.changes.Change();
|
|
1403
|
+
// // change.value = null;
|
|
1404
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1405
|
+
// // change.reference = id;
|
|
1406
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1407
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1408
|
+
// // // change.action = null;
|
|
1409
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1410
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1411
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1412
|
+
// //
|
|
1413
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1414
|
+
// }*/
|
|
1415
|
+
// if (callback) {
|
|
1416
|
+
// result.subscribe((success) => callback(success));
|
|
1417
|
+
// }
|
|
1418
|
+
// return result;
|
|
1419
|
+
// }
|
|
1420
|
+
// destroyByUser(iAmid: string): Observable<boolean> {
|
|
1421
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1422
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "by-user/" + iAmid, HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1423
|
+
// tap((_) => console.log(`deleted nodes: iAmid=${iAmid}`)),
|
|
1424
|
+
// map((serverData) => serverData.success),
|
|
1425
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyByUser"))
|
|
1426
|
+
// );
|
|
1427
|
+
// /* TODO:NG2
|
|
1428
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1429
|
+
// //
|
|
1430
|
+
// // let change = new puzzles.changes.Change();
|
|
1431
|
+
// // change.value = null;
|
|
1432
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1433
|
+
// // change.reference = id;
|
|
1434
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1435
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1436
|
+
// // // change.action = null;
|
|
1437
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1438
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1439
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1440
|
+
// //
|
|
1441
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1442
|
+
// }*/
|
|
1443
|
+
// return result;
|
|
1444
|
+
// }
|
|
1445
|
+
// destroyEdgesToChild(targetId: string): Observable<boolean> {
|
|
1446
|
+
// //TODO:NG2 fix usage of this function to expect boolean
|
|
1447
|
+
// const result: Observable<boolean> = this.http.delete<ServerData>(this.apiUrl + "edges-to-child/" + targetId, HTTP_OPTIONS_CONST_JSON).pipe(
|
|
1448
|
+
// // tap(_ => console.log(`deleted edges type=${type} and iAmid=${iAmid}`)),
|
|
1449
|
+
// map((serverData) => serverData.success),
|
|
1450
|
+
// catchError(this.handleErrorForObservable<boolean>("destroyEdgeToChild"))
|
|
1451
|
+
// );
|
|
1452
|
+
// /* TODO:NG2
|
|
1453
|
+
// if(this.knAllEdgeRealTimeService){ // realtime distribution
|
|
1454
|
+
// //
|
|
1455
|
+
// // let change = new puzzles.changes.Change();
|
|
1456
|
+
// // change.value = null;
|
|
1457
|
+
// // change.valueBeforeChange = null; //TODO
|
|
1458
|
+
// // change.reference = id;
|
|
1459
|
+
// // change.type = puzzles.changes.ChangeType.STRUCTURAL;
|
|
1460
|
+
// // change.event = Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName;
|
|
1461
|
+
// // // change.action = null;
|
|
1462
|
+
// // change.domain = puzzles.changes.Domain.NODE;
|
|
1463
|
+
// // change.visibility = puzzles.changes.ChangeVisibility.ALL;
|
|
1464
|
+
// // change.phase = puzzles.changes.ChangePhase.UNDISPLAYED;
|
|
1465
|
+
// //
|
|
1466
|
+
// // this.knAllEdgeRealTimeService.emit(Plugins.puzzles.knalledgeMap.config.services.KnRealTimeEdgeDeletedEventName, change);//{'_id':id});
|
|
1467
|
+
// }*/
|
|
1468
|
+
// return result;
|
|
1469
|
+
// }
|
|
1470
|
+
};
|
|
1471
|
+
KnalledgeEdgeServiceExtended = __decorateClass([
|
|
1472
|
+
Injectable6()
|
|
1473
|
+
], KnalledgeEdgeServiceExtended);
|
|
1474
|
+
export {
|
|
1475
|
+
CFServiceIsomorphic as CFServiceFrontend,
|
|
1476
|
+
CFServiceIsomorphic,
|
|
1477
|
+
ColaboApiCoreService,
|
|
1478
|
+
ColaboKnAllEdgeContainerService,
|
|
1479
|
+
ColaboKnAllEdgeNodeService,
|
|
1480
|
+
ColaboKnAllEdgeNodeServiceExtended,
|
|
1481
|
+
HTTP_OPTIONS_CONST_JSON,
|
|
1482
|
+
KnalledgeEdgeService,
|
|
1483
|
+
KnalledgeEdgeServiceExtended,
|
|
1484
|
+
MODULE_NAME,
|
|
1485
|
+
removeSecurityPrefix
|
|
1486
|
+
};
|
|
1487
|
+
//# sourceMappingURL=index.js.map
|