/*!
 * @hyext-mock/mock-sdk 
 * (c) 2020-2021 Alex
 * Released under the MIT License.
 */
import MockExcutor from '@hyext-mock/event-mock-excutor';

var Mocker = /** @class */ (function () {
    function Mocker(implement) {
        this.mockImplement = implement;
    }
    Mocker.prototype.getMockImplement = function () {
        return this.mockImplement;
    };
    Mocker.prototype.hack = function (cb) {
        return cb && cb(this.mockImplement);
    };
    return Mocker;
}());

function createSendWupMocker(dataSource) {
    var implement = function (opts) {
        var funcName = opts.funcName, req = opts.req;
        var getDataFn = dataSource[funcName];
        if (typeof getDataFn === 'function') {
            return getDataFn(req);
        }
        else {
            console.warn("you not yet has " + funcName + " mock implementation");
        }
    };
    return new Mocker(implement);
}

function createOnWupMessagesMocker(mockEventConfigQueue) {
    var implement = function (queue) {
        var mockExcutor = new MockExcutor(mockEventConfigQueue);
        queue.forEach(function (config) {
            var uri = config.uri, handler = config.handler;
            mockExcutor.registry(uri, handler);
        });
        mockExcutor.start();
    };
    return new Mocker(implement);
}
function createOnWupMessageMocker(mockEventConfigQueue) {
    var implement = function (eventConfig) {
        var mockExcutor = new MockExcutor(mockEventConfigQueue);
        var uri = eventConfig.uri, handler = eventConfig.handler;
        mockExcutor.registry(uri, handler);
        mockExcutor.start();
    };
    return new Mocker(implement);
}

export { createOnWupMessageMocker, createOnWupMessagesMocker, createSendWupMocker };
