Skip to main content

Interface: AmnesiaProviderOptions

Defined in: types.ts:378

Configuration for AmnesiaProvider.

Extends AmnesiaStoreOptions but exposes scopeId-aware lifecycle hooks so the same handler can serve every scope under one provider.

Extends

Properties

capacity?

optional capacity?: number

Defined in: types.ts:312

Maximum number of entries retained on the past stack. When the limit is reached, the oldest entry is dropped on every new push.

Defaults to 100. Set to Infinity to disable, but be aware closures may retain large amounts of memory.

Inherited from

AmnesiaStoreOptions.capacity


coalesceWindowMs?

optional coalesceWindowMs?: number

Defined in: types.ts:320

Maximum time (in milliseconds) between two pushes that share a non-empty coalesceKey for them to merge into a single entry.

Defaults to 400.

Inherited from

AmnesiaStoreOptions.coalesceWindowMs


metaTransform?

optional metaTransform?: (meta) => Record<string, unknown> | undefined

Defined in: types.ts:369

Sanitizer applied to meta before it is exposed in the public snapshot or passed to lifecycle hooks. Use this to redact sensitive fields without forcing every call site to remember the rule.

Only invoked when meta is defined. The return value replaces meta in the public HistoryEntry; returning undefined strips it.

The transform should be pure and stable — it runs every time the snapshot is rebuilt and every time a hook is fired.

Parameters

ParameterType
metaRecord<string, unknown>

Returns

Record<string, unknown> | undefined

Inherited from

AmnesiaStoreOptions.metaTransform


onAmend?

optional onAmend?: (entry, scopeId) => void

Defined in: types.ts:401

Lifecycle hook fired after a successful amend on scopeId. The entry is the updated top-of-past entry.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void


onClear?

optional onClear?: (scopeId) => void

Defined in: types.ts:420

Lifecycle hook fired after clear() on scopeId (and only when the call actually cleared something). When the provider's clear() clears all scopes, this fires once per cleared scope.

Parameters

ParameterType
scopeIdstring

Returns

void


onError?

optional onError?: AmnesiaErrorHandler

Defined in: types.ts:326

Custom error reporter for failures inside redo / undo. See AmnesiaErrorHandler.

Inherited from

AmnesiaStoreOptions.onError


onPush?

optional onPush?: (entry, scopeId) => void

Defined in: types.ts:395

Lifecycle hook fired after a successful push commits a new entry to the past stack of scopeId. Coalesce-merges do not fire this — only the first push of a coalesce burst counts as a logical user action.

Hook payloads are dispatched after the snapshot is updated and after subscribers have been notified, so handlers see a quiescent store. A throw inside the handler is caught and ignored.

The entry's meta (when present) has already been passed through the scope's metaTransform.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void


onRedo?

optional onRedo?: (entry, scopeId) => void

Defined in: types.ts:413

Lifecycle hook fired after a successful redo on scopeId. The entry is the one that was moved from future to past.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void


onUndo?

optional onUndo?: (entry, scopeId) => void

Defined in: types.ts:407

Lifecycle hook fired after a successful undo on scopeId. The entry is the one that was moved from past to future.

Parameters

ParameterType
entryHistoryEntry
scopeIdstring

Returns

void