API reference@evolu/common › local‑first/Storage

Encrypted storage layer for local-first data.

Core

InterfaceDescription
StorageEvolu Storage.
StorageConfigConfiguration for Storage, such as quota checks.
StorageDepDependency wrapper for Storage.
StorageQuotaErrorError when storage or billing quota is exceeded.

Messages

NameDescription
CrdtMessageA CRDT message combining a unique Timestamp with a DbChange.
DbChangeA DbChange is a change to a table row. Together with a unique Timestamp, it forms a CrdtMessage.
EncryptedCrdtMessageAn encrypted CrdtMessage.
ValidDbChangeValuesErrorError produced when DbChangeValues contain reserved system columns.
DbChangeValuesColumn values of a DbChange, keyed by column name.
EncryptedDbChangeEncrypted DbChange
ValidDbChangeValuesColumn values that contain no reserved system columns.
DbChangeA DbChange is a change to a table row. Together with a unique Timestamp, it forms a CrdtMessage.
DbChangeValuesColumn values of a DbChange, keyed by column name.
ValidDbChangeValuesColumn values that contain no reserved system columns.

Ranges

NameDescription
BaseRangeCommon shape of every Range.
FingerprintRangeRange summarized by a Fingerprint for comparison.
SkipRangeRange with nothing to reconcile.
TimestampsRangeRange listing its TimestampBytes explicitly.
FingerprintA cryptographic hash used for efficiently comparing collections of TimestampByteses.
InfiniteUpperBoundType of the InfiniteUpperBound sentinel.
RangeRange exchanged during sync: SkipRange, FingerprintRange, or TimestampsRange.
RangeTypeNumeric tag of one Range variant.
RangeUpperBoundUnion type for Range's upperBound: either a TimestampBytes or InfiniteUpperBound.
fingerprintSizeNumber of leading SHA-256 bytes that form a Fingerprint.
InfiniteUpperBoundSentinel RangeUpperBound for a range without an upper limit.
RangeTypeNumeric tags discriminating Range variants.
zeroFingerprintA fingerprint of an empty range.
timestampBytesToFingerprintComputes the Fingerprint of a single timestamp.

SQLite

NameDescription
BaseSqliteStorageCommon interface for both client and relay SQLite storages.
BaseSqliteStorageDepDependency wrapper for BaseSqliteStorage.
SqliteStorageDepsDependencies required by createBaseSqliteStorage.
StorageInsertTimestampStrategyPosition at which a timestamp is inserted relative to existing timestamps.
createBaseSqliteStorageCreates a BaseSqliteStorage implementation.
createBaseSqliteStorageTablesCreates the SQLite tables used by BaseSqliteStorage.
getTimestampByIndexReads the timestamp at a position within an owner's ordered timestamps.
getTimestampInsertStrategyDetermines the insertion strategy for a timestamp based on its position relative to the current first and last timestamps.
readOwnerUsageOrDefaultReads owner usage from SQLite and returns default bounds when absent.
updateOwnerUsageUpdates timestamp bounds in evolu_usage table.

Testing

FunctionDescription
testCreateCrdtMessageTest helper for creating a simple CrdtMessage.
testFingerprintTimestampsComputes a brute-force Fingerprint from TimestampBytes values for tests and benchmarks.