@sphereon/ssi-sdk.data-store
Version:
70 lines • 5.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.activityEventEntityFrom = exports.activityEventFrom = exports.auditEventEntityFrom = exports.auditEventFrom = void 0;
const ssi_types_1 = require("@sphereon/ssi-types");
const FormattingUtils_1 = require("../FormattingUtils");
const AuditEventEntity_1 = require("../../entities/eventLogger/AuditEventEntity");
const auditEventFrom = (event) => {
const result = Object.assign(Object.assign({ id: event.id, type: ssi_types_1.LoggingEventType.AUDIT, description: event.description, timestamp: event.timestamp, level: event.level, correlationId: event.correlationId, actionType: event.actionType, actionSubType: event.actionSubType, initiatorType: event.initiatorType, partyAlias: event.partyAlias, partyCorrelationId: event.partyCorrelationId, partyCorrelationType: event.partyCorrelationType, subSystemType: event.subSystemType, system: event.system, systemAlias: event.systemAlias, systemCorrelationId: event.systemCorrelationId, systemCorrelationIdType: event.systemCorrelationIdType }, (event.data && { data: JSON.parse(event.data) })), (event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }));
return (0, FormattingUtils_1.replaceNullWithUndefined)(result);
};
exports.auditEventFrom = auditEventFrom;
const auditEventEntityFrom = (args) => {
const auditEventEntity = new AuditEventEntity_1.AuditEventEntity();
auditEventEntity.type = ssi_types_1.LoggingEventType.AUDIT;
auditEventEntity.timestamp = args.timestamp;
auditEventEntity.level = args.level;
auditEventEntity.correlationId = args.correlationId;
auditEventEntity.system = args.system;
auditEventEntity.subSystemType = args.subSystemType;
auditEventEntity.actionType = args.actionType;
auditEventEntity.actionSubType = args.actionSubType;
auditEventEntity.initiatorType = args.initiatorType;
auditEventEntity.systemCorrelationIdType = args.systemCorrelationIdType;
auditEventEntity.systemCorrelationId = args.systemCorrelationId;
auditEventEntity.systemAlias = args.systemAlias;
auditEventEntity.partyCorrelationType = args.partyCorrelationType;
auditEventEntity.partyCorrelationId = args.partyCorrelationId;
auditEventEntity.partyAlias = args.partyAlias;
auditEventEntity.description = args.description;
auditEventEntity.partyCorrelationType = args.partyCorrelationType;
auditEventEntity.data = JSON.stringify(args.data);
auditEventEntity.diagnosticData = JSON.stringify(args.diagnosticData);
return auditEventEntity;
};
exports.auditEventEntityFrom = auditEventEntityFrom;
const activityEventFrom = (event) => {
const result = Object.assign(Object.assign({ id: event.id, type: ssi_types_1.LoggingEventType.ACTIVITY, credentialType: event.credentialType, originalCredential: event.originalCredential, credentialHash: event.credentialHash, parentCredentialHash: event.parentCredentialHash, sharePurpose: event.sharePurpose, description: event.description, timestamp: event.timestamp, level: event.level, correlationId: event.correlationId, actionType: event.actionType, actionSubType: event.actionSubType, initiatorType: event.initiatorType, partyAlias: event.partyAlias, partyCorrelationId: event.partyCorrelationId, partyCorrelationType: event.partyCorrelationType, subSystemType: event.subSystemType, system: event.system, systemAlias: event.systemAlias, systemCorrelationId: event.systemCorrelationId, systemCorrelationIdType: event.systemCorrelationIdType }, (event.data && { data: JSON.parse(event.data) })), (event.diagnosticData && { diagnosticData: JSON.parse(event.diagnosticData) }));
return (0, FormattingUtils_1.replaceNullWithUndefined)(result);
};
exports.activityEventFrom = activityEventFrom;
const activityEventEntityFrom = (args) => {
const activityEventEntity = new AuditEventEntity_1.AuditEventEntity();
activityEventEntity.type = ssi_types_1.LoggingEventType.ACTIVITY;
activityEventEntity.timestamp = args.timestamp;
activityEventEntity.level = args.level;
activityEventEntity.correlationId = args.correlationId;
activityEventEntity.system = args.system;
activityEventEntity.subSystemType = args.subSystemType;
activityEventEntity.actionType = args.actionType;
activityEventEntity.actionSubType = args.actionSubType;
activityEventEntity.initiatorType = args.initiatorType;
activityEventEntity.systemCorrelationIdType = args.systemCorrelationIdType;
activityEventEntity.systemCorrelationId = args.systemCorrelationId;
activityEventEntity.systemAlias = args.systemAlias;
activityEventEntity.partyCorrelationType = args.partyCorrelationType;
activityEventEntity.partyCorrelationId = args.partyCorrelationId;
activityEventEntity.partyAlias = args.partyAlias;
activityEventEntity.description = args.description;
activityEventEntity.partyCorrelationType = args.partyCorrelationType;
activityEventEntity.data = JSON.stringify(args.data);
activityEventEntity.sharePurpose = args.sharePurpose;
activityEventEntity.credentialType = args.credentialType;
activityEventEntity.originalCredential = args.originalCredential;
activityEventEntity.credentialHash = args.credentialHash;
activityEventEntity.parentCredentialHash = args.parentCredentialHash;
activityEventEntity.diagnosticData = JSON.stringify(args.diagnosticData);
return activityEventEntity;
};
exports.activityEventEntityFrom = activityEventEntityFrom;
//# sourceMappingURL=MappingUtils.js.map