Magek Framework
    Preparing search index...

    Interface EventStoreAdapter

    interface EventStoreAdapter {
        rawToEnvelopes(rawEvents: unknown): EventEnvelope[];
        rawStreamToEnvelopes(
            config: MagekConfig,
            context: unknown,
            dedupEventStream: EventStream,
        ): EventEnvelope[];
        dedupEventStream(
            config: MagekConfig,
            rawEvents: unknown,
        ): Promise<EventStream>;
        produce(
            entityName: string,
            entityID: UUID,
            eventEnvelopes: EventEnvelope[],
            config: MagekConfig,
        ): Promise<void>;
        forEntitySince(
            config: MagekConfig,
            entityTypeName: string,
            entityID: UUID,
            since?: string,
        ): Promise<EventEnvelope[]>;
        latestEntitySnapshot(
            config: MagekConfig,
            entityTypeName: string,
            entityID: UUID,
        ): Promise<EntitySnapshotEnvelope | undefined>;
        search(
            config: MagekConfig,
            parameters: EventSearchParameters,
        ): Promise<EventSearchResponse[]>;
        searchEntitiesIDs(
            config: MagekConfig,
            limit: number,
            afterCursor: Record<string, string> | undefined,
            entityTypeName: string,
        ): Promise<PaginatedEntitiesIdsResult>;
        store(
            eventEnvelopes: NonPersistedEventEnvelope[],
            config: MagekConfig,
        ): Promise<EventEnvelope[]>;
        storeSnapshot(
            snapshotEnvelope: NonPersistedEntitySnapshotEnvelope,
            config: MagekConfig,
        ): Promise<EntitySnapshotEnvelope>;
        storeDispatched(
            eventEnvelope: EventEnvelope,
            config: MagekConfig,
        ): Promise<boolean>;
        findDeletableEvent(
            config: MagekConfig,
            parameters: EventDeleteParameters,
        ): Promise<EventEnvelopeFromDatabase[]>;
        findDeletableSnapshot(
            config: MagekConfig,
            parameters: SnapshotDeleteParameters,
        ): Promise<EntitySnapshotEnvelopeFromDatabase[]>;
        deleteEvent(
            config: MagekConfig,
            events: EventEnvelopeFromDatabase[],
        ): Promise<void>;
        deleteSnapshot(
            config: MagekConfig,
            snapshots: EntitySnapshotEnvelopeFromDatabase[],
        ): Promise<void>;
        healthCheck?: {
            isUp(config: MagekConfig): Promise<boolean>;
            details(config: MagekConfig): Promise<unknown>;
            urls(config: MagekConfig): Promise<string[]>;
        };
    }
    Index

    Methods

    • Retrieves events for a specific entity since a given time

      Parameters

      • config: MagekConfig

        The Magek configuration object

      • entityTypeName: string

        The type name of the entity

      • entityID: UUID

        The ID of the entity

      • Optionalsince: string

        The time to retrieve events since (optional)

      Returns Promise<EventEnvelope[]>

      A promise that resolves to an array of EventEnvelope objects

    • Searches for entities IDs based on a specific entity type and pagination parameters

      Parameters

      • config: MagekConfig

        The Magek configuration object

      • limit: number

        The maximum number of entities IDs to retrieve

      • afterCursor: Record<string, string> | undefined

        The cursor to retrieve entities IDs after (optional)

      • entityTypeName: string

        The type name of the entities to search for

      Returns Promise<PaginatedEntitiesIdsResult>

      A promise that resolves to a PaginatedEntitiesIdsResult object

    • Stores an event envelope that has been dispatched in the dispatched events table.

      Parameters

      Returns Promise<boolean>

      true if the dispatched event was stored, false if the event already exists in the dispatched events table, throws an error on any other type of error.

    Properties

    healthCheck?: {
        isUp(config: MagekConfig): Promise<boolean>;
        details(config: MagekConfig): Promise<unknown>;
        urls(config: MagekConfig): Promise<string[]>;
    }

    Health check methods for the event store

    Type Declaration