@archastro/sdk
    Preparing search index...
    Index

    Constructors

    Methods

    • Claim events from a subscription Atomically leases the oldest unacknowledged delivery. Returns an empty data array when the queue is empty or its head already has an active lease. Passing max_events opts into batch mode, where leased entries are skipped instead of blocking; wait_seconds bounds a long poll on an empty queue.

      Parameters

      • subscription: string

        Subscription ID (esub_...).

      • input: {
            consumer_id?: string;
            max_events?: number;
            request_id?: string;
            visibility_timeout_seconds?: number;
            wait_seconds?: number;
        }

        Request body.

        • Optionalconsumer_id?: string

          Consumer identity between 1 and 128 bytes, recorded on the lease for attribution.

        • Optionalmax_events?: number

          Opts into batch mode: leases up to this many lease-available deliveries (between 1 and 20) in sequence order, skipping leased entries instead of blocking on the head. Omit to keep strict head-of-line semantics.

        • Optionalrequest_id?: string

          Idempotency key between 1 and 128 bytes. Use a value unique per claim attempt (e.g. a UUID) — the key is scoped to the subscription, so a reused value takes over whatever leases it last stamped. Retrying a claim with the same request_id while its leases are unexpired returns the same deliveries (regardless of max_events) with fresh receipt handles and refreshed leases.

        • Optionalvisibility_timeout_seconds?: number

          Lease duration override between 15 and 3600 seconds.

        • Optionalwait_seconds?: number

          Long-poll bound between 0 and 20 seconds. When the queue is empty, the request waits up to this long for a delivery before returning an empty data array. 0 (or omitting) returns immediately.

      Returns Promise<EventSubscriptionClaim>

      Successful response

    • Create a domain-event subscription Creates a durable subscription that receives exportable domain events matching its exact event names. Matching events fan out into a per-subscription queue bounded by max_pending_events and retention_seconds; consume with claim and acknowledge.

      Parameters

      • input: {
            event_names: string[];
            filter?: Record<string, unknown>;
            max_pending_events?: number;
            name: string;
            previous_filter?: Record<string, unknown>;
            previous_filters?: Record<string, unknown>[];
            previous_watch_key?: string;
            retention_seconds?: number;
            status?: "active" | "paused";
            ttl_seconds?: number;
            visibility_timeout_seconds?: number;
            watch_key?: string;
        }

        Request body.

        • event_names: string[]

          Exact event names to receive.

        • Optionalfilter?: Record<string, unknown>

          Optional match over subject_key, actor_key, and allowlisted dims. Only valid when every event name is a custom (script-emitted) event type. Missing filter matches all events.

        • Optionalmax_pending_events?: number

          Queue cap. Defaults to 100; maximum 1000.

        • name: string

          Customer-defined subscription name.

        • Optionalprevious_filter?: Record<string, unknown>

          Expected legacy filter for atomic watch-key adoption.

        • Optionalprevious_filters?: Record<string, unknown>[]

          Additional exact historical filters accepted for atomic watch-key adoption.

        • Optionalprevious_watch_key?: string

          Optionally adopt an existing key in the exact same owner and residence when the destination is absent and its filter exactly matches previous_filter, one of previous_filters, or filter. Preserves queue identity and deliveries; mismatches reject the request without changing either queue.

        • Optionalretention_seconds?: number

          Delivery retention in seconds. Defaults to 86400 (24 hours); between 7200 and 2592000. Applies to future deliveries only.

        • Optionalstatus?: "active" | "paused"

          Initial status. Defaults to active.

        • Optionalttl_seconds?: number

          Optional subscription lifetime in seconds, between 1 and 604800. Recreating a watch key resets its expiry; omission makes it permanent.

        • Optionalvisibility_timeout_seconds?: number

          Default claim lease in seconds. Defaults to 300.

        • Optionalwatch_key?: string

          Optional durable identity within the caller owner and residence. Repeated creates replace routes and filter on that queue; omission creates a new queue regardless of name.

      Returns Promise<EventSubscription>

      The new volatile subscription.

    • Delete a domain-event subscription Deletes the subscription and every delivery still in its queue.

      Parameters

      • subscription: string

        Subscription ID (esub_...).

      Returns Promise<void>

      No content

    • Discard pending subscription deliveries Removes lease-available pending deliveries, preserves active leases, and records the gap.

      Parameters

      • subscription: string

        Subscription ID (esub_...).

      Returns Promise<Record<string, unknown>>

      An object containing discarded, the number of removed deliveries.

    • List domain-event subscriptions Lists the subscriptions visible to the caller, with current queue counters.

      Parameters

      • Optionalparams: { page?: number; perPage?: number }

        Query parameters.

        • Optionalpage?: number

          Page number, starting at 1.

        • OptionalperPage?: number

          Subscriptions per page, from 1 through 100.

      Returns Promise<EventSubscriptionPage>

      Subscriptions visible to this caller.

    • Read a subscription queue Returns a non-reserving, oldest-first view of unacknowledged deliveries, including the queue's loss indicators (queue_epoch, dropped_events_total, dropped_through_position). Committed deliveries are visible immediately. Exclusive sequence cursors navigate the currently visible queue; they are not durable consumption checkpoints. A lower-sequence delivery that commits after a cursor advances can be omitted from subsequent pages while remaining visible in a fresh listing. Use claim and acknowledge for reliable consumption.

      Parameters

      • subscription: string

        Subscription ID (esub_...).

      • Optionalparams: { afterCursor?: string; beforeCursor?: string; limit?: number }

        Query parameters.

        • OptionalafterCursor?: string

          Opaque exclusive sequence cursor for the following page; mutually exclusive with before_cursor. Navigation only: late commits below this position can be missed. Use claim and acknowledge for reliable consumption.

        • OptionalbeforeCursor?: string

          Opaque exclusive sequence cursor for the preceding page; mutually exclusive with after_cursor.

        • Optionallimit?: number

          Maximum entries to return, from 1 through 100.

      Returns Promise<EventSubscriptionQueue>

      Successful response

    • Update a domain-event subscription Updates matching, status, or queue limits for future fanout. Already queued deliveries remain unless a lower cap trims the oldest entries; retention changes apply to future deliveries only.

      Parameters

      • subscription: string

        Subscription ID (esub_...).

      • input: {
            event_names?: string[];
            filter?: Record<string, unknown>;
            max_pending_events?: number;
            name?: string;
            retention_seconds?: number;
            status?: "active" | "paused";
            visibility_timeout_seconds?: number;
        }

        Request body.

        • Optionalevent_names?: string[]
        • Optionalfilter?: Record<string, unknown>

          Optional match over subject_key, actor_key, and allowlisted dims. Only valid when every event name is a custom (script-emitted) event type. Missing filter matches all events.

        • Optionalmax_pending_events?: number
        • Optionalname?: string
        • Optionalretention_seconds?: number

          Delivery retention in seconds. Defaults to 86400 (24 hours); between 7200 and 2592000. Applies to future deliveries only.

        • Optionalstatus?: "active" | "paused"
        • Optionalvisibility_timeout_seconds?: number

      Returns Promise<EventSubscription>

      Successful response