UNPKG

@adv-ui/boros-tcf

Version:

Adevinta GDPR - Transparency and Consent Framework - API

172 lines (140 loc) 6.13 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.BorosTcf = void 0; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator")); var _ioc = require("../core/ioc/ioc"); var _GetVendorListUseCase = require("./services/vendorlist/GetVendorListUseCase"); var _LoadUserConsentUseCase = require("./services/vendorconsent/LoadUserConsentUseCase"); var _SaveUserConsentUseCase = require("./services/vendorconsent/SaveUserConsentUseCase"); var _ChangeUiVisibleUseCase = require("./services/ui/ChangeUiVisibleUseCase"); var _GetTCDataUseCase = require("./services/tcdata/GetTCDataUseCase"); var _StatusRepository = require("../domain/status/StatusRepository"); var _Status = require("../domain/status/Status"); var _DomainEventBus = require("../domain/service/DomainEventBus"); var _constants = require("../core/constants"); var BorosTcf = /*#__PURE__*/function () { /** * @param {Object} param * @param {GetVendorListUseCase} param.getVendorListUseCase * @param {LoadUserConsentUseCase} param.loadUserConsentUseCase * @param {SaveUserConsentUseCase} param.saveUserConsentUseCase * @param {ChangeUiVisibleUseCase} param.changeUiVisibleUseCase * @param {GetTCDataUseCase} param.getTCDataUseCase */ function BorosTcf(_temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$domainEventBus = _ref.domainEventBus, domainEventBus = _ref$domainEventBus === void 0 ? (0, _ioc.inject)(_DomainEventBus.DomainEventBus) : _ref$domainEventBus, _ref$getVendorListUse = _ref.getVendorListUseCase, getVendorListUseCase = _ref$getVendorListUse === void 0 ? (0, _ioc.inject)(_GetVendorListUseCase.GetVendorListUseCase) : _ref$getVendorListUse, _ref$loadUserConsentU = _ref.loadUserConsentUseCase, loadUserConsentUseCase = _ref$loadUserConsentU === void 0 ? (0, _ioc.inject)(_LoadUserConsentUseCase.LoadUserConsentUseCase) : _ref$loadUserConsentU, _ref$saveUserConsentU = _ref.saveUserConsentUseCase, saveUserConsentUseCase = _ref$saveUserConsentU === void 0 ? (0, _ioc.inject)(_SaveUserConsentUseCase.SaveUserConsentUseCase) : _ref$saveUserConsentU, _ref$getTCDataUseCase = _ref.getTCDataUseCase, getTCDataUseCase = _ref$getTCDataUseCase === void 0 ? (0, _ioc.inject)(_GetTCDataUseCase.GetTCDataUseCase) : _ref$getTCDataUseCase, _ref$changeUiVisibleU = _ref.changeUiVisibleUseCase, changeUiVisibleUseCase = _ref$changeUiVisibleU === void 0 ? (0, _ioc.inject)(_ChangeUiVisibleUseCase.ChangeUiVisibleUseCase) : _ref$changeUiVisibleU, _ref$statusRepository = _ref.statusRepository, statusRepository = _ref$statusRepository === void 0 ? (0, _ioc.inject)(_StatusRepository.StatusRepository) : _ref$statusRepository; this._domainEventBus = domainEventBus; this._getVendorListUseCase = getVendorListUseCase; this._loadUserConsentUseCase = loadUserConsentUseCase; this._saveUserConsentUseCase = saveUserConsentUseCase; this._getTCDataUseCase = getTCDataUseCase; this._changeUiVisibleUseCase = changeUiVisibleUseCase; this._statusRepository = statusRepository; } var _proto = BorosTcf.prototype; _proto.ready = function ready() { this._statusRepository.getStatus().cmpStatus = _Status.Status.CMPSTATUS_LOADED; this._domainEventBus.raise({ eventName: _constants.EVENT_TCF_READY, payload: { version: _constants.LIB_TCF_VERSION } }); } /** * @param {Object} param * @param {Number} param.version */ ; _proto.getVendorList = function getVendorList(_temp2) { var _ref2 = _temp2 === void 0 ? {} : _temp2, version = _ref2.version; return this._getVendorListUseCase.execute({ vendorListVersion: version }); }; _proto.loadUserConsent = function loadUserConsent(_temp3) { var _ref3 = _temp3 === void 0 ? {} : _temp3, notify = _ref3.notify; return this._loadUserConsentUseCase.execute({ notify: notify }); }; _proto.uiVisible = function uiVisible(_ref4) { var visible = _ref4.visible; this._changeUiVisibleUseCase.execute({ visible: visible }); } /** * * @param {Object} param * @param {Object} param.purpose * @param {Object<Number, boolean>} param.purpose.consents * @param {Object<Number, boolean>} param.purpose.legitimateInterests * @param {Object} param.vendor * @param {Object<Number, boolean>} param.vendor.consents * @param {Object<Number, boolean>} param.vendor.legitimateInterests * @param {Object<Number, boolean>} param.specialFeatures */ ; _proto.saveUserConsent = /*#__PURE__*/ function () { var _saveUserConsent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref5) { var purpose, vendor, specialFeatures; return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: purpose = _ref5.purpose, vendor = _ref5.vendor, specialFeatures = _ref5.specialFeatures; return _context.abrupt("return", this._saveUserConsentUseCase.execute({ purpose: purpose, vendor: vendor, specialFeatures: specialFeatures })); case 2: case "end": return _context.stop(); } } }, _callee, this); })); function saveUserConsent(_x) { return _saveUserConsent.apply(this, arguments); } return saveUserConsent; }() /** * * @param {Object} param * @param {Array<Number>} param.vendorIds */ ; _proto.getTCData = function getTCData(_ref6) { var vendorIds = _ref6.vendorIds; return this._getTCDataUseCase.execute({ vendorIds: vendorIds }); }; return BorosTcf; }(); exports.BorosTcf = BorosTcf;