diffusion
Version:
Diffusion JavaScript client
91 lines (90 loc) • 3.53 kB
JavaScript
;
/**
* @module SessionTrees
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionTreesImpl = void 0;
var Services = require("./../services/session-trees-services");
var logger = require("./../util/logger");
var require_non_null_1 = require("./../util/require-non-null");
var response_success_1 = require("./../util/response-success");
var log = logger.create('SessionTrees');
/**
* Implementation of the {@link SessionTrees} feature
*/
var SessionTreesImpl = /** @class */ (function () {
/**
* Create a new instance of the SessionTrees feature
*
* @param internal the internal session
*/
function SessionTreesImpl(internal) {
this.internal = internal;
var serviceLocator = internal.getServiceLocator();
this.PUT_BRANCH_MAPPING_TABLE = serviceLocator.obtain(Services.PUT_BRANCH_MAPPING_TABLE);
this.GET_SESSION_TREE_BRANCHES_WITH_MAPPINGS
= serviceLocator.obtain(Services.GET_SESSION_TREE_BRANCHES_WITH_MAPPINGS);
this.GET_BRANCH_MAPPING_TABLE = serviceLocator.obtain(Services.GET_BRANCH_MAPPING_TABLE);
}
/**
* @inheritdoc
*/
SessionTreesImpl.prototype.putBranchMappingTable = function (branchMappingTable) {
var _this = this;
return new Promise(function (resolve, reject) {
require_non_null_1.requireNonNull(branchMappingTable, 'branchMappingTable');
if (_this.internal.checkConnected(reject)) {
_this.PUT_BRANCH_MAPPING_TABLE.send(branchMappingTable, function (err, response) {
if (!response_success_1.responseSuccess(err, response)) {
reject(err);
log.debug('Put branch mapping table failed');
}
else {
resolve();
}
});
}
});
};
/**
* @inheritdoc
*/
SessionTreesImpl.prototype.getSessionTreeBranchesWithMappings = function () {
var _this = this;
return new Promise(function (resolve, reject) {
if (_this.internal.checkConnected(reject)) {
_this.GET_SESSION_TREE_BRANCHES_WITH_MAPPINGS.send(null, function (err, response) {
if (!response_success_1.responseSuccess(err, response)) {
reject(err);
log.debug('Get session tree branches with mappings failed');
}
else {
resolve(response.paths);
}
});
}
});
};
/**
* @inheritdoc
*/
SessionTreesImpl.prototype.getBranchMappingTable = function (sessionTreeBranch) {
var _this = this;
return new Promise(function (resolve, reject) {
require_non_null_1.requireNonNull(sessionTreeBranch, 'sessionTreeBranch');
if (_this.internal.checkConnected(reject)) {
_this.GET_BRANCH_MAPPING_TABLE.send(sessionTreeBranch, function (err, response) {
if (!response_success_1.responseSuccess(err, response)) {
reject(err);
log.debug('Get branch mapping table failed');
}
else {
resolve(response);
}
});
}
});
};
return SessionTreesImpl;
}());
exports.SessionTreesImpl = SessionTreesImpl;