UNPKG

@serenity-js/core

Version:

The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure

34 lines (30 loc) 1.07 kB
import type { JSONObject } from 'tiny-types'; import { ensure, isDefined } from 'tiny-types'; import type { SerialisedArtifact } from '../model'; import { Artifact, CorrelationId, Name } from '../model'; import { Timestamp } from '../screenplay'; import { DomainEvent } from './DomainEvent'; /** * @group Events */ export class ArtifactGenerated extends DomainEvent { static fromJSON(o: JSONObject): ArtifactGenerated { return new ArtifactGenerated( CorrelationId.fromJSON(o.sceneId as string), Name.fromJSON(o.name as string), Artifact.fromJSON(o.artifact as SerialisedArtifact), Timestamp.fromJSON(o.timestamp as string), ); } constructor( public readonly sceneId: CorrelationId, public readonly name: Name, public readonly artifact: Artifact, timestamp?: Timestamp, ) { super(timestamp); ensure('sceneId', sceneId, isDefined()); ensure('name', name, isDefined()); ensure('artifact', artifact, isDefined()); } }