@fabric-es/fabric-cqrs
Version:
Hyperledger Fabric middleware for event sourcing and cqrs pattern
34 lines • 1.71 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPrivateRepository = void 0;
const store_1 = require("../store");
const types_1 = require("../types");
const utils_1 = require("../utils");
const createPrivateRepository = (entity, callback, option) => {
const entityName = entity.entityName;
const parentName = entity.parentName || '';
const reducer = types_1.getReducer(callback);
const logger = (option === null || option === void 0 ? void 0 : option.logger) || utils_1.getLogger({ name: '[fabric-cqrs] createPrivateRepository.js' });
const { gateway, network, channelName, connectionProfile, wallet } = option;
const store = store_1.getCommandStore({ network, gateway, logger });
const commandOption = {
logger,
wallet,
store,
connectionProfile,
channelName,
};
return {
create: utils_1.commandCreate(entityName, true, commandOption, parentName),
getCommitByEntityName: utils_1.commandGetByEntityName(entityName, true, commandOption),
getCommitByEntityIdCommitId: utils_1.commandGetByEntityIdCommitId(entityName, true, commandOption),
getCommitById: utils_1.commandGetByEntityId(entityName, true, commandOption),
deleteByEntityIdCommitId: utils_1.commandDeleteByEntityIdCommitId(entityName, true, commandOption),
getById: utils_1.commandGetById(entityName, reducer, true, commandOption),
getEntityName: () => entityName,
getParentName: () => parentName,
disconnect: () => gateway.disconnect(),
};
};
exports.createPrivateRepository = createPrivateRepository;
//# sourceMappingURL=createPrivateRepository.js.map