UNPKG

@fabric-es/fabric-cqrs

Version:

Hyperledger Fabric middleware for event sourcing and cqrs pattern

27 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isBaseEventArray = exports.isFabricResponse = exports.isCommit = exports.isCommitRecord = void 0; const isCommitRecord = (input) => Object.entries(input) .map(([key, value]) => (value === null || value === void 0 ? void 0 : value.commitId) !== undefined && (value === null || value === void 0 ? void 0 : value.id) !== undefined && (value === null || value === void 0 ? void 0 : value.entityId) !== undefined && (value === null || value === void 0 ? void 0 : value.version) !== undefined && (value === null || value === void 0 ? void 0 : value.entityName) !== undefined && (value === null || value === void 0 ? void 0 : value.mspId) !== undefined) .reduce((acc, curr) => curr && acc, true); exports.isCommitRecord = isCommitRecord; const isCommit = (value) => (value === null || value === void 0 ? void 0 : value.commitId) !== undefined && (value === null || value === void 0 ? void 0 : value.id) !== undefined && (value === null || value === void 0 ? void 0 : value.entityId) !== undefined && (value === null || value === void 0 ? void 0 : value.version) !== undefined && (value === null || value === void 0 ? void 0 : value.entityName) !== undefined; exports.isCommit = isCommit; const isFabricResponse = (input) => (input === null || input === void 0 ? void 0 : input.status) !== undefined && (input === null || input === void 0 ? void 0 : input.message) !== undefined; exports.isFabricResponse = isFabricResponse; const isBaseEventArray = (input) => input .map((item) => { return (item === null || item === void 0 ? void 0 : item.type) !== undefined && (item === null || item === void 0 ? void 0 : item.payload) !== undefined; }) .reduce((prev, curr) => curr && prev, true); exports.isBaseEventArray = isBaseEventArray; //# sourceMappingURL=typeGuard.js.map