# Changelog

## [8.1.1] - 2026-06-05

### 👷 CI

- Raised the minimum supported Node.js to `>=24.0.0` (Node 24 LTS) in `engines`, dropping Node 22.

### ⬆️ Dependencies

- Bumped dev `vitest` to `^4.1.8`. No source changes — dev-tooling bump only.

## [8.1.0] - 2026-05-21

### ✨ Features

### New `onLoadError` event

`FileSystemStore` now exposes an `onLoadError` event on its `EventHub`. The constructor schedules the initial reload in the background, and the FS watcher triggers a reload on every external change — failures from either path used to surface only as unhandled promise rejections. They are now emitted via `onLoadError` so consumers can log, retry, or fall back without monkey-patching.

```ts
const store = new FileSystemStore({ model: Item, fileName: '/srv/data.json', primaryKey: 'id' })
store.addListener('onLoadError', ({ error }) => log.error('store reload failed', { error }))
```

### ♻️ Refactoring

### `hasChanges` is now read-only; `tick` is private

`FileSystemStore.hasChanges` is now a getter backed by the private `_hasChanges` field — external mutation was always a footgun (the dirty flag is owned by `add` / `update` / `remove` / `saveChanges`) and is now a type error. The internal `tick` interval handle was demoted from `public` to `private` for the same reason. No supported call site mutated either, so this is a safety tightening rather than a behavior change.

### ⬆️ Dependencies

- Bump dev `vitest` to `^4.1.5`.
- Bumped `@types/node` to `^25.9.1` and `vitest` to `^4.1.7`. No source changes — dev-tooling bump only.

### 📚 Documentation

- Rewrote JSDoc on `FileSystemStore` and `defineFileSystemStore` to follow the new value-test guidance: dropped restate-the-type narration, called out the init-race contract (calls before the background reload resolves see an empty cache), the `ENOENT` swallow on first run, and the requirement to `await` the async dispose to avoid lost writes.

## [8.0.0] - 2026-04-25

### 💥 Breaking Changes

Stores are now first-class DI tokens. See the [v7 migration guide](../../docs/migrations/v7-functional-di.md) for rationale, recipes, and pitfalls.

- Removed `useFileSystemStore(...)`. Declare the store at module scope with `defineFileSystemStore<T, PK>({ name, model, primaryKey, fileName, tickMs? })` — the returned `StoreToken<T, PK>` is self-disposing.
- Disposal (tick interval, file-system watcher, final flush) now runs through the token's `onDispose` hook on injector teardown.

## [7.1.7] - 2026-04-17

### ⬆️ Dependencies

- Raised `@types/node` to ^25.6.0, `typescript` to ^6.0.3, and `vitest` to ^4.1.4 so package development matches the workspace toolchain.

## [7.1.6] - 2026-03-27

### ⬆️ Dependencies

- Updated `vitest` to ^4.1.2

## [7.1.5] - 2026-03-25

### 📦 Build

- Removed deprecated `baseUrl` from tsconfig.json for TypeScript 6 compatibility

### ⬆️ Dependencies

- Upgraded `typescript` from ^5.9.3 to ^6.0.2
- Upgraded `vitest` from ^4.1.0 to ^4.1.1

## [7.1.4] - 2026-03-19

### ✨ Features

- Updated `@furystack/core` dependency to the latest major version.
- Added `onWatcherError` event for file system watcher failures.

### ⬆️ Dependencies

- Upgraded `vite` from ^7.3.1 to ^8.0.0 for improved build performance and new features
- Upgraded `vitest` from ^4.0.18 to ^4.1.0
- Upgraded `@vitest/coverage-istanbul` from ^4.0.18 to ^4.1.0

## [7.1.3] - 2026-03-10

### ⬆️ Dependencies

- Updated `@furystack/core` dependency to the new major version

## [7.1.2] - 2026-03-07

### ⬆️ Dependencies

- Updated `@types/node` from `^25.3.1` to `^25.3.5`

## [7.1.1] - 2026-03-06

### 🧪 Tests

- Refactored `FileSystemStore` watcher error test to use `using()` wrapper for proper disposal, ensuring cleanup even if assertions fail

## [7.1.0] - 2026-03-03

### ✨ Features

### `onWatcherError` event for file system watcher failures

`FileSystemStore` now emits an `onWatcherError` event when registering the file system watcher fails, replacing silent error swallowing.

```typescript
const store = new FileSystemStore({
  fileName: '/data/entities.json',
  primaryKey: 'id',
  model: MyEntity,
})

store.addListener('onWatcherError', ({ error }) => {
  console.error('File watcher registration failed:', error)
})
```

- Added `onListenerError` to the event map for consistent EventHub error handling

## [7.0.40] - 2026-02-26

### ⬆️ Dependencies

- Updated internal `@furystack/*` dependencies
- Bumped `@types/node` from ^25.3.0 to ^25.3.1

## [7.0.39] - 2026-02-26

### 📝 Documentation

- Added tip about wrapping the physical store with a Repository DataSet for application-level data access

## [7.0.38] - 2026-02-22

### ⬆️ Dependencies

- Updated `@furystack/core` dependency

## [7.0.37] - 2026-02-19

### ⬆️ Dependencies

- Updated `@furystack/core`

## [7.0.36] - 2026-02-11

### ♻️ Refactoring

- Removed semaphore-based file locking from all store operations (`get`, `add`, `find`, `count`, `remove`, `update`, `saveChanges`, `reloadData`). Operations now delegate directly to the in-memory store without lock wrapping.

### 🧪 Tests

- Wrapped `FileSystemStore` instances in `usingAsync()` to ensure cleanup runs even when assertions fail

### ⬆️ Dependencies

- Bump `vitest` from `^4.0.17` to `^4.0.18`
- Bump `@types/node` from `^25.0.10` to `^25.2.3`
- Removed `semaphore-async-await` dependency

## [7.0.35] - 2026-02-09

### ⬆️ Dependencies

- Updated `@furystack/core` dependency
- Updated `@furystack/*` dependencies

## [7.0.34] - 2026-01-26

### 🔧 Chores

- Standardized author format, improved keywords, removed obsolete `gitHead`, added `engines` (Node 22+) and `sideEffects: false`

## [7.0.33] - 2026-01-26

### ⬆️ Dependencies

- Updated `@furystack/inject` with fix for singleton injector reference being overwritten by child injectors

## [7.0.32] - 2026-01-22

### ⬆️ Dependencies

- Dependency updates

### 🔧 Chores

- Migrated to centralized changelog management system
