Refactor event bus and queue system; detect cycles in DI realization and make
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-01-26 19:37:54 -06:00
parent 506fb55c74
commit 6d1cf18680
69 changed files with 1673 additions and 720 deletions

View File

@@ -1,27 +1,12 @@
import {Event} from '../../event/Event'
import {SecurityContext} from '../context/SecurityContext'
import {Awaitable, JSONState} from '../../util'
import {Authenticatable} from '../types'
import {BaseEvent} from '../../support/bus'
/**
* Event fired when a user is authenticated.
*/
export class AuthenticationEvent extends Event {
export abstract class AuthenticationEvent extends BaseEvent {
constructor(
public readonly user: Authenticatable,
public readonly context: SecurityContext,
) {
super()
}
async dehydrate(): Promise<JSONState> {
return {
user: await this.user.dehydrate(),
contextName: this.context.name,
}
}
rehydrate(state: JSONState): Awaitable<void> { // eslint-disable-line @typescript-eslint/no-unused-vars
// TODO fill this in
}
}

View File

@@ -3,4 +3,6 @@ import {AuthenticationEvent} from './AuthenticationEvent'
/**
* Event fired when a user is authenticated.
*/
export class UserAuthenticatedEvent extends AuthenticationEvent {}
export class UserAuthenticatedEvent extends AuthenticationEvent {
public readonly eventName = '@extollo/lib:UserAuthenticatedEvent'
}

View File

@@ -3,4 +3,6 @@ import {AuthenticationEvent} from './AuthenticationEvent'
/**
* Event raised when a user is re-authenticated to a security context
*/
export class UserAuthenticationResumedEvent extends AuthenticationEvent {}
export class UserAuthenticationResumedEvent extends AuthenticationEvent {
public readonly eventName = '@extollo/lib:UserAuthenticationResumedEvent'
}

View File

@@ -3,4 +3,6 @@ import {AuthenticationEvent} from './AuthenticationEvent'
/**
* Event fired when a user is unauthenticated.
*/
export class UserFlushedEvent extends AuthenticationEvent {}
export class UserFlushedEvent extends AuthenticationEvent {
public readonly eventName = '@extollo/lib:UserFlushedEvent'
}