Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 5x 5x 5x 5x 5x 5x 23x 46x 24x 29x 9x 20x 24x 24x 4x 4x 1x 73x 46x 46x 46x 46x 46x 5x | "use strict";
/*! Copyright (c) 2023 Siemens AG. Licensed under the MIT License. */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TnLifecycleController = void 0;
const operators_1 = require("rxjs/operators");
const tn_connector_1 = require("../common/tn-connector");
const tn_lifecycle_service_1 = require("../service/tn-lifecycle-service");
const tn_base_controller_1 = require("./tn-base-controller");
class TnLifecycleController extends tn_base_controller_1.TnBaseController {
get lifecycleController() {
return this.container.getController("ObjectLifecycleController");
}
trackAgents(selector, onCancelled$) {
const obj2Event = (obj, state) => ({
identity: { name: obj.name, id: obj.objectId, local: this.container.identity.objectId === obj.objectId },
state,
});
const checkName = (objName, selName) => {
if (selName instanceof RegExp) {
return selName.test(objName);
}
else {
return objName === selName;
}
};
const selectorName = selector.identityName;
if ((selectorName === null || selectorName === void 0 ? void 0 : selectorName.startsWith("/")) && selectorName.endsWith("/")) {
try {
selector.identityName = new RegExp(selectorName.substring(1, selectorName.length - 1));
}
catch (error) {
throw new Error(`'${selectorName}' is not a valid JavaScript regular expression: ${error.message}`);
}
}
return this.lifecycleController.observeObjectLifecycleInfoByCoreType("Identity", obj => obj["role"] === tn_connector_1.TnConnector.IDENTITY_ROLE &&
(selector.identityId ?
obj.objectId === selector.identityId :
(selector.identityName ?
checkName(obj.name, selector.identityName) :
true)))
.pipe((0, operators_1.takeUntil)(onCancelled$), (0, operators_1.mergeMap)(info => {
var _a, _b, _c;
const events = [];
((_a = info.added) !== null && _a !== void 0 ? _a : []).forEach(obj => events.push(obj2Event(obj, tn_lifecycle_service_1.AgentLifecycleState.Join)));
((_b = info.removed) !== null && _b !== void 0 ? _b : []).forEach(obj => events.push(obj2Event(obj, tn_lifecycle_service_1.AgentLifecycleState.Leave)));
((_c = info.changed) !== null && _c !== void 0 ? _c : []).forEach(obj => events.push(obj2Event(obj, tn_lifecycle_service_1.AgentLifecycleState.Join)));
return events;
}));
}
}
exports.TnLifecycleController = TnLifecycleController;
|