UNPKG

@fabric-es/fabric-cqrs

Version:

Hyperledger Fabric middleware for event sourcing and cqrs pattern

34 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.commandCreate = void 0; const command_1 = require("../store/command"); const _1 = require("."); const commandCreate = (entityName, isPrivateData, { channelName, logger, connectionProfile, wallet, store }, parentName) => ({ enrollmentId, id }) => ({ save: _1.dispatcher(({ tx_id, args: { events, signedRequest } }) => command_1.action.create({ channelName, connectionProfile, wallet, tx_id, enrollmentId, store, args: { entityName, parentName, id, version: 0, isPrivateData, events: _1.replaceTag(_1.addCreator(_1.addCreatedAt(events), enrollmentId)), signedRequest, }, }), { name: 'command_create', store, slice: 'write', SuccessAction: command_1.action.CREATE_SUCCESS, ErrorAction: command_1.action.CREATE_ERROR, logger, typeGuard: _1.isCommitRecord, }, (result) => Object.values(result)[0]), }); exports.commandCreate = commandCreate; //# sourceMappingURL=commandCreate.js.map