@adventurelabs/scout-core
v2.2.1
Published
Core utilities and helpers for Adventure Labs Scout applications
Maintainers
Readme
Scout Core
Core utilities and helpers for Adventure Labs Scout applications.
Imports
Scout Core has separate browser and server entrypoints:
import { get_devices_by_herd } from "@adventurelabs/scout-core/client";
const response = await get_devices_by_herd(supabase, herdId);import { get_devices_by_herd } from "@adventurelabs/scout-core/server";
const response = await get_devices_by_herd(herdId);Client data helpers accept a Supabase client as their first argument. Matching server helpers create a cookie-backed Supabase client and use the same remaining arguments. Both paths therefore apply the current user's row-level security policies.
Use @adventurelabs/scout-core/types for type-only imports. Hooks, providers,
Redux, IndexedDB cache helpers, and browser client factories are available only
from /client. Middleware, cookie handling, API-key actions, and privileged key
operations are available only from /server.
Use /server/middleware for updateSession and /server/supabase for
newServerClient so middleware and RSC bundles do not load the full helper
barrel.
ScoutRefreshProvider accepts an existing browser Supabase client and otherwise
creates one stable client. Its automatic refresh uses a fresh IndexedDB cache
without another request; manual and reconnect refreshes still query the API.
Returning to a visible tab revalidates herd data and refreshes JWT mints that
are near expiry, covering browsers that suspend background timers.
Offline PWAs can pass a persisted offlineUserId to restore that user's herd
modules and JWT mints before online authentication is revalidated. Cached mints
remain available when expired; pass false as the fourth argument to
can_herd_ability only for offline UI gates. The ID scopes cached data; it does
not synthesize a Supabase User when no validated user is available.
Use createScoutBrowserClient() when the application needs the same configured
client outside the provider.
Provider descendants should call useScoutRefreshActions() for
handleRefresh and clearCache instead of creating another
useScoutRefresh() instance.
Create Redux state explicitly with configureScoutStore() and keep that
instance stable in the application provider.
The package root is not an entrypoint. Replace imports from
@adventurelabs/scout-core with /client, /server, or /types.
Server helper names no longer include the server_ prefix. Existing
client-injected helper names are unchanged. Software-version reads expose
get_versions_software_with_build_urls when signed build artifact URLs are
needed. The diagnostic-only test_event_loading and test_api_key_loading
exports were removed.
