@steerprotocol/sync-engine
v0.1.2
Published
Background sync engine for Steer Protocol vault and pool analytics.
Readme
Steer Sync Engine
This package publishes lib/sync/manager.ts and the internal modules it depends on so the background sync pipeline can be embedded in downstream services.
Contents
index.ts– barrel that re-exports the manager and helpers for conveniencelib/sync/manager.ts– background sync orchestratorlib/sync/request.tsandlib/sync/errors.ts– Effect-based helpers and error typeslib/steer/subgraph.ts– Steer subgraph queries used to hydrate vault datalib/amm/adapters.ts– AMM adapter layer for pool metadata and hour datalib/analysis/KPIs.ts– KPI recomputation logic used by the managerlib/pglite/schema.tsandlib/pglite/types.ts– lightweight PGlite schema helperstsconfig.json– preserves the@/*alias in this standalone packagepackage.json– npm metadata plus dependency list and build script
External Dependencies
effect– heavy usage across the manager and helpers@steerprotocol/sdk– protocol metadata helpers- A
fetchimplementation available in the runtime (Node 18+ provides a global one)
The database helpers assume an object that implements the PGliteDb interface (query(sql, params) returning { rows: Row[] }). If you previously relied on @electric-sql/pglite, install it where you integrate this package.
Usage
Install the package from npm and import from the re-export barrel:
import { makeBackgroundSyncService, backgroundSyncProgram } from '@steerprotocol/sync-engine'From there you can spin up the long-running loop using whatever Effect runtime your host provides. For example, in a Node process:
import { backgroundSyncProgram } from '@steerprotocol/sync-engine'
import { NodeRuntime } from '@effect/platform-node'
NodeRuntime.runMain(
backgroundSyncProgram({
logger: console,
db,
}),
)In browsers or workers you would instead supply a web-friendly runtime and logger before running the program.
Direct sub-module entry points are also declared in package.json exports should you prefer:
import { subgraphRequestEffect } from '@steerprotocol/sync-engine/request'Runtime & Observability
The sync engine does not ship with a built-in Effect runtime or telemetry stack. Supply the services that make sense for your host:
- Runtime: Use
NodeRuntime,WebRuntime, Bun, or a custom driver to runbackgroundSyncProgram. - Logging / Tracing: Pass a
loggerviaBackgroundSyncManagerOptionsand provide tracing layers (seedocs/observability/for Effect guidance) before you execute the program.
Next Steps
npm install @steerprotocol/sync-enginein the target project.- Provide concrete implementations for environment integration (logger, database, API keys).
- Supply a host-specific Effect runtime (e.g.
NodeRuntime.runMainin Node, a custom runtime in browsers or workers) and wire in your logging/tracing layers. - Wire the manager into your service lifecycle and call
triggerSync/triggerExecutionForAllas needed.
