Skip to content

Commit

Permalink
chore: fix event bugs and migration missing enum value
Browse files Browse the repository at this point in the history
  • Loading branch information
Brummos committed Oct 24, 2024
1 parent f369a16 commit 1cc5c61
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class CreateAuditEvents1701634812183 implements MigrationInterface {
await queryRunner.query(`CREATE TYPE "public"."Action_type_enum" AS ENUM('create', 'read', 'update', 'delete', 'execute')`)
await queryRunner.query(`CREATE TYPE "public"."Initiator_type_enum" AS ENUM('user', 'system', 'external')`)
await queryRunner.query(`CREATE TYPE "public"."System_correlation_id_type_enum" AS ENUM('did', 'email', 'hostname', 'phone', 'user')`)
await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'email', 'hostname', 'phone')`)
await queryRunner.query(`CREATE TYPE "public"."Party_correlation_type_enum" AS ENUM('did', 'url', 'email', 'hostname', 'phone')`)
await queryRunner.query(`CREATE TYPE "public"."Event_type_enum" AS ENUM('audit', 'activity', 'general')`)
await queryRunner.query(`CREATE TYPE "public"."Event_credential_type_enum" AS ENUM('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC')`)
await queryRunner.query(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CreateAuditEvents1701634819487 implements MigrationInterface {
"systemCorrelationIdType" varchar CHECK( "systemCorrelationIdType" IN ('did','email','hostname','phone','user') ),
"systemCorrelationId" varchar,
"systemAlias" varchar,
"partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did','email','hostname','phone') ),
"partyCorrelationType" varchar CHECK( "partyCorrelationType" IN ('did', 'url', 'email','hostname','phone') ),
"partyCorrelationId" varchar,
"partyAlias" varchar,
"credentialType" varchar CHECK( "credentialType" IN ('JSON_LD', 'JWT', 'SD_JWT', 'MSO_MDOC') ),
Expand Down
6 changes: 3 additions & 3 deletions packages/ssi-sdk-core/src/loggers/eventLogger/EventLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ class EventLogger {

public logEvent = async (event: LoggingEvent): Promise<void> => {
const eventData = await this.eventData(event)
EventLogger.LOGGERS.get(this.namespace).logl(eventData.level ?? LogLevel.INFO, JSON.stringify(eventData.data), eventData)
EventLogger.LOGGERS.get(this.namespace).logl(eventData.level ?? LogLevel.INFO, JSON.stringify(eventData), eventData)
if (this.context?.agent) {
await this.context.agent.emit(event.type, eventData)
}
}

private eventData = async (event: LoggingEvent): Promise<LogEventType> => {
if (!this.system || event.data.system) {
if (!this.system && !event.data.system) {
return Promise.reject(Error('Required system is not present'))
}

if (!this.subSystemType || event.data.subSystemType) {
if (!this.subSystemType && !event.data.subSystemType) {
return Promise.reject(Error('Required sub system type is not present'))
}

Expand Down
2 changes: 2 additions & 0 deletions packages/ssi-types/src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export enum DefaultActionSubType {
DID_SERVICE_UPDATE = 'DID service update',
VC_ISSUE = 'VC issue',
VC_VERIFY = 'VC verify',
VC_SHARE = 'VC share',
VC_DELETE = 'VC delete',
}

export type ActionSubType = DefaultActionSubType | string
Expand Down

0 comments on commit 1cc5c61

Please sign in to comment.