bothy-sdk
    Preparing search index...

    Interface InboxStore

    Storage of the inbox and of the jti store; every write is durable when it returns. Times are Unix milliseconds.

    interface InboxStore {
        add(entry: InboxEntry): Promise<void>;
        close(): Promise<void>;
        forRun(runId: string): Promise<InboxEntry[]>;
        get(eventId: string): Promise<InboxEntry | undefined>;
        inStates(...states: EntryState[]): Promise<InboxEntry[]>;
        jtiSeen(jti: string, nowMs: number): Promise<boolean>;
        prune(nowMs: number): Promise<void>;
        redelivered(
            eventId: string,
            token: Secret | undefined,
            iat: number | undefined,
            jti: string | undefined,
        ): Promise<InboxEntry>;
        rememberJti(jti: string, untilMs: number): Promise<void>;
        replaceToken(
            eventId: string,
            token: Secret,
            iat: number,
            jti: string,
        ): Promise<void>;
        setState(eventId: string, state: EntryState): Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Stores a new entry.

      Parameters

      • entry: InboxEntry

        The entry; its envelope must not carry invocation_token.

      Returns Promise<void>

      RangeError when the event is already stored, its ID is not a UUID or the envelope carries a token.

    • Releases the store; closing twice is harmless.

      Returns Promise<void>

    • Returns the entries of a run in seq order (ephemeral entries last, in arrival order).

      Parameters

      • runId: string

        The run.

      Returns Promise<InboxEntry[]>

    • Returns the entry of eventId.

      Parameters

      • eventId: string

        The envelope id.

      Returns Promise<InboxEntry | undefined>

      The entry, or undefined when it is not stored.

    • Returns the entries in one of states in seq order (ephemeral entries last, in arrival order).

      Parameters

      Returns Promise<InboxEntry[]>

    • Returns whether jti is remembered beyond nowMs.

      Parameters

      • jti: string

        The token ID.

      • nowMs: number

        The current wall time.

      Returns Promise<boolean>

    • Drops the jti rows that expired at nowMs; inbox entries stay.

      Parameters

      • nowMs: number

        The current wall time.

      Returns Promise<void>

    • Counts a redelivery and keeps the newer token while the entry is accepted.

      The token replaces the stored one when the entry is accepted and iat is not older than the stored iat (an equal iat takes this later arrival).

      Parameters

      • eventId: string

        The envelope id.

      • token: Secret | undefined

        The token of the redelivery, if any.

      • iat: number | undefined

        Its iat.

      • jti: string | undefined

        Its jti.

      Returns Promise<InboxEntry>

      The entry after the update.

      RangeError when the event is not stored.

    • Remembers jti until untilMs (an earlier end never shortens a later one).

      Parameters

      • jti: string

        The token ID.

      • untilMs: number

        exp plus adapter.invocation_token_leeway.

      Returns Promise<void>

    • Replaces the token unconditionally (after a renewal grant).

      Parameters

      • eventId: string

        The envelope id.

      • token: Secret

        The granted token.

      • iat: number

        Its iat.

      • jti: string

        Its jti.

      Returns Promise<void>

      RangeError when the event is not stored.

    • Sets the state of an entry.

      Parameters

      • eventId: string

        The envelope id.

      • state: EntryState

        The new state.

      Returns Promise<void>

      RangeError when the event is not stored.