UNPKG

@fabric-es/fabric-cqrs

Version:

Hyperledger Fabric middleware for event sourcing and cqrs pattern

21 lines 1.28 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = __importDefault(require("util")); const redux_observable_1 = require("redux-observable"); const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const action_1 = require("../action"); const { CLEAR_NOTIFICATION, clearNotiSuccess, clearNotiError } = action_1.action; exports.default = (action$, _, { queryDatabase, logger }) => action$.pipe(redux_observable_1.ofType(CLEAR_NOTIFICATION), operators_1.map(({ payload }) => payload), operators_1.mergeMap(({ tx_id, args: { creator, entityName, commitId, id } }) => rxjs_1.from(queryDatabase .clearNotification({ creator, entityName, commitId, id }) .then(({ data, status, errors }) => status === 'OK' ? clearNotiSuccess({ tx_id, result: data }) : clearNotiError({ tx_id, error: errors })) .catch((error) => { logger.error(util_1.default.format('[store/query/clearNotification.js] fail to %s: tx_id:%s, %j', CLEAR_NOTIFICATION, tx_id, error)); return clearNotiError({ tx_id, error: error.message }); })))); //# sourceMappingURL=clearNotification.js.map