# Changelog

## 3.2.3

- Moved to `@trebired/logger-adapter` 0.6.0, which depends on `@trebired/logger` 3.0.0.
- Updated the shipped `.trebired/logger/config.ts` `forVersion` to `3.0.0`. The logger checks `forVersion` by major and minor version, so under `@trebired/logger` 3.0 the old `2.7.0` value failed the check and this package's log prefix was dropped.

## 3.2.2

- Changed the verification scripts and examples to print through `@trebired/logger-adapter` instead of `console` and `process.stdout`.

## 3.2.1

- Updated the shipped `.trebired/logger/config.ts` `forVersion` to `2.7.0` and the `@trebired/code-discipline` / `@trebired/configs` ranges to `^7.2.0` / `^0.4.0`. The logger config named an older release, so under `@trebired/logger` 2.7 the version check threw and this package's log prefix was dropped.

## 3.2.0

- Updated the `@trebired/utils` dependency range to `^0.9.0`, keeping every `@trebired` package on one range so a project cannot resolve two copies.

## 3.1.2

### Changed

- Moved the `@trebired/utils` dependency range from `^0.6.0` to `^0.8.0`, matching the rest of
  the `@trebired` packages. For 0.x versions those two ranges are disjoint (`>=0.6.0 <0.7.0` vs
  `>=0.8.0 <0.9.0`), so any project combining this package with one already on `^0.8.0`
  (`@trebired/frontend`, `@trebired/uploads`, `@trebired/env`, `@trebired/security`) resolved two
  copies of `@trebired/utils` — a hoisted 0.6.x alongside a nested 0.8.x — duplicating code and
  letting app-level imports of `@trebired/utils` silently resolve to a different copy than this
  package used internally. Nothing this package uses changed across those releases; the only
  breaking change in 0.8.0 was the env module moving to `@trebired/env`, which this package does
  not import.

## 3.1.1

- Updated the logger-adapter dependency so store logging uses the current shared adapter release.

## 3.1.0

- Added request-scoped deduplication of identical storage reads. `entity.read.by`/`read.all`/`count` now issue a single underlying query per identical `(entity, operation, where, context, storage options)` within one request context, instead of one query per distinct read `mode`. Reads that differ only by `mode` (e.g. `raw` vs `view`) previously produced separate cache keys and therefore duplicate SQL for the same row; each caller still gets its own independently mapped/enriched copy because `mapRow` already clones before enriching. Deduplication reuses the existing per-request loader map, so it is invalidated by writes through `clearRequestEntityLoaders`, and is skipped entirely when `cacheBypass` is set.

## 3.0.2

- Removed dead `config.creator` from `package.json`.
- Updated shared utilities to `@trebired/utils@^0.6.0` and replaced the removed `readPackageIdentity()` with `readPackageJsonUrl()` + `readOrganizationIdentity()` + `packageSlug()`/`joinLogGroup()`. No change to exported metadata values.

## 3.0.1

- Fixed numeric environment fallback parsing so missing `DB_SLOW_MS` keeps the default slow-query threshold instead of becoming `0`.

## 3.0.0

- Removed routine write and cache invalidation success logs from normal store operation.
- Reworked Postgres and SQLite query diagnostics to use compact structured metadata without raw SQL or caller stack data on successful queries.
- Removed caller-defined boot follow-up guard log messages so store logs keep package-owned messages and app details stay in metadata.
- Avoided query caller stack capture on the successful query hot path.

## 2.2.3

- Removed routine successful read logs so cache keys and large read inputs do not clutter normal logs.
- Reduced the store creation log metadata to cache status and entity count.

## 2.2.0

- Added boot follow-up read helpers and injected record/policy readers into the follow-up API so application boot handlers only keep domain-specific decisions and actions.

## 2.1.1

- Allowed memo cache set options to carry an existing cache version hint.

## 2.1.0

- Added the application store runtime layer for package-owned boot reporting, startup timing hooks, postgres env defaults, memo cache facade, request loader invalidation, and lazy record views.
- Added generic boot helpers for default entity assignment, runtime status reset, auto-start follow-ups, follow-up result normalization, and result data unwrapping.
- Added package-owned hook read helpers, request context helpers, null redis memo adapter, postgres index-map normalization, and write limiter utilities so apps keep only domain-specific store wiring.

## 2.0.4

- Updated shared utilities to `@trebired/utils@^0.4.4`.

All notable changes to `@trebired/store` will be documented here.

This project follows semantic versioning once published.

## 2.0.3

- Updated shared utilities to `@trebired/utils@^0.4.3`.
- Replaced local validation/value helpers and package metadata parsing with shared utilities.

## 2.0.1

- Updated the shared Trebired config dependency to `@trebired/configs@^0.1.2`.

## 2.0.0

- Removed the boot follow-up dispatcher `group` override so store boot follow-up diagnostics stay package-owned.

## 1.0.14

- Adopted the external `@trebired/configs` preset and updated Code Discipline tooling to `@trebired/code-discipline@^6.0.9`.

## 1.0.13

- Updated the Code Discipline devDependency and lockfile to public `@trebired/code-discipline@^5.5.2`.
## 1.0.12

- Adopted the shared Trebired Code Discipline preset so package configs only keep repo-specific policy.
- Updated the Code Discipline devDependency and lockfile to public `@trebired/code-discipline@^5.5.1`.

## 1.0.11

- Updated the package Code Discipline config to the platform-aligned rule set, including formatting, redundant path segment cleanup, removable comment checks, structural blank lines, and dry checks.
- Updated the Code Discipline devDependency and lockfile to the current public `@trebired/code-discipline@^5.3.0`.

## 1.0.10

- Refreshed package dependency ranges and lockfile state with `bun update` after adopting the `.trebired/code-discipline` structure.

## 1.0.9

- Moved Code Discipline config, alias-map state, generated tsconfig paths, and reports to `.trebired/code-discipline/`.
- Updated the `@trebired/code-discipline` devDependency to `^4.10.0`.

## 1.0.8

- Updated Code Discipline configuration to the `imports` rule with dead import removal enabled.
- Updated store log group metadata fallback so package-owned logs stay under the organization root when package metadata is unavailable.
- Updated internal package dependency ranges to the current published sibling releases.

## 1.0.7

- Aligned two internal Symbol keys (`enrichedBrand`, `BOOT_FOLLOW_UP_DISPATCH`) with the `@package/store/...` naming convention used by every other package's internal Symbols; they previously used an inconsistent dot-separated form.
- Fixed a broken published-package build: a fresh checkout has no committed `.code-discipline/generated/` output, and nothing regenerated it before `typecheck`/`build`, so every internal `#hash` import failed to resolve. `typecheck` and `build` now run `prepare:generated` first.
- Standardized package metadata (author field, config-driven organization name, dropped the Node engine constraint) and migrated `.code-discipline/config.ts` to `defineCodeDisciplineConfig`.
- Normalized README structure and removed the license footer.
- Updated the `@trebired/code-discipline` devDependency to 4.8.0.

## 1.0.5

- Standardized package metadata ordering and contributing guidance around the Trebired writing style.
- Added package-owned organization metadata and derived store runtime log groups from `package.json`.
- Updated internal package dependency ranges to the current sibling package releases.

## 1.0.4

- Removed dead test scripts and stale test commands from publish workflows and maintainer docs.

## 1.0.3

- Removed package test suites and banned committed `*.spec.ts`/`*.spec.tsx` files through Code Discipline.
- Added Code Discipline enforcement for hardcoded `trebired` strings outside package metadata.
- Migrated Code Discipline to `.code-discipline/config.ts` with alias-map sync output.
- Updated package-generated artifact ignores and internal package dependency ranges.

## 1.0.2

- Moved package-owned store logging under the `trebired.store` group root across runtime creation, reads, writes, cache invalidation, boot follow-ups, SQLite, and Postgres diagnostics.

## 1.0.1

- Normalized `null` and `undefined` store contexts to `{}` across entity reads, writes, record views, provider-backed virtual sub-entities, and cache key creation.
- Added clean `store-invalid-context` result failures for non-object contexts instead of leaking runtime `TypeError`s or misclassifying them as storage errors.
- Kept required context validation and enriched-record safeguards unchanged, with regression coverage for both paths.

## 1.0.0

- Added first-class SQLite support through `createSqliteJsonStorageAdapter(...)`, with JSON string records, scoped context filtering, `where` and `options.where`, `byIds`, `limit`, `sort`, `count`, `hasAny`, native `removeMany`, and strict identifier/path validation.
- Added `createStoreRuntime({ sqlite, entities, ... })` with runtime-owned SQLite query/init support, table creation, expression indexes, migrations, optional metrics/logging, and structured envelope query failures.
- Updated runtime entity storage defaults so explicit storage always wins, SQLite-only runtimes default to `sqlite`, and mixed Postgres/SQLite runtimes remain deterministic with explicit per-entity storage available.
- Exported SQLite adapter, database/client, runtime facade, query, migration, index, and metrics types from the package root.
- Added SQLite examples, README coverage, and tests for direct adapter usage, runtime initialization, migrations, mixed storage, query validation, malformed JSON reads, and bulk operations.

## 0.7.0

- Added `createBootFollowUpDispatcher(...)` with generic call lookup, structured skipped/success/failure outcomes, exception handling, optional boolean policy checks, readiness guard polling, timeout skips, and package-owned follow-up log metadata.
- Added boot follow-up result helpers and `readBootBoolean(...)` for hosts that need direct control while keeping result envelopes consistent.
- Expanded `RuntimeBootResult` with `followUps` and `followUpsRunCount` so queued follow-up outcomes are visible alongside boot changes and failures.
- Added boot rewrite builders including `createBootRewriter(...)`, `bootRecord(...)`, alias/default/nested/object/array/string/number/boolean transforms, slug generation, boolean policy defaults, and `customTransform(...)`.
- Documented the generic boot dispatcher and rewrite-builder patterns so hosts can keep only handler implementations, target readiness checks, and host-specific transforms.

## 0.6.0

- Added package-owned runtime boot helper builders for reusable boot fix declarations, status reset actions, default field actions, truthy policy conditions, follow-up queues, and boot option merging.
- Kept host-owned follow-up execution and record normalization outside the package while reducing the repetitive boot configuration code hosts need to keep.

## 0.5.0

- Added package-owned normalization for concise runtime entity registries, including `required`, `private`, concise mode hook maps, and automatic `"with-"` hook-name stripping.
- Added strict runtime registry validation so invalid definitions fail during runtime creation.
- Expanded runtime PostgreSQL support with envelope result mode, query metrics callbacks, one-time init guarding, pool wait logging, and structured query validation errors.
- Added `createRedisMemoAdapter(...)` plus richer runtime memo inspection, stale L2 entry rejection, entity invalidation metadata, and cross-process invalidation wiring.
- Extended boot reconciliation with runtime context/environment config, `{ ctx: "..." }` value resolvers, stable change detection, strict record id failure reporting, and result callbacks.
- Added first-class provider-backed virtual sub-entities routed through `runtime.entity.read.*`.

## 0.4.0

- Added `createStoreRuntime(...)`, a high-level runtime facade that exposes entity, cache, records, repair, sub-entity, Postgres, memo, and boot APIs from one package-owned bootstrap.
- Added runtime-owned PostgreSQL pool/query/init support with query safety validation, redacted URL logging, caller metadata, schema/table creation, default JSONB GIN indexes, expression indexes, and migration hooks.
- Added a generic boot reconciliation runner with matching conditions, nested field reads, set/set-if-missing/unset, rewrites, follow-up queues, skip rules, and structured boot summaries.
- Added runtime memo caching with stable read keys, ignored request/runtime keys, L1 TTL/max-entry support, optional L2, in-flight de-duplication, entity versioning, invalidation, and optional remote invalidation.
- Added declarative hydration builders for relation, count, and computed mode enrichment, while preserving hook loading and legacy hook adapters for complex host-owned behavior.
- Moved `pg` to runtime dependencies because the runtime now owns explicit PostgreSQL pool creation.

## 0.3.0

- Added generic record views with discriminator-scoped reads, normalized writes, default values, sort/limit read options, unique upsert, and enforced enriched-record safeguards.
- Added `store.entity.write.removeMany(...)` with storage-native bulk delete support and safe per-id fallback behavior.
- Added generic orphan and duplicate repair helpers for parent/child record views, including freshest duplicate selection and bulk deletion summaries.
- Expanded memory and PostgreSQL JSONB adapters to support sorted and limited reads, plus native PostgreSQL bulk removal.
- Updated documentation and examples for record views, raw versus enriched reads, unique upsert, bulk removal, and generic repair flows.

## 0.2.0

- Added first-class `where` support for `read.all`, `read.count`, and `read.hasAny`, with cache keys, validation, memory storage, and PostgreSQL JSONB storage all using the same criteria semantics.
- Expanded request-scoped context helpers with metadata access through `getStoreRequestContext()` and metadata-aware `runWithStoreRequestContext(...)`.
- Added generic mode-enricher registry construction from entity mode hook maps, with sequential hook execution and read-only hook APIs.
- Added package-owned cache invalidation through `store.cache.invalidateEntity(...)` and kept enriched-record protections mandatory for marked, branded, frozen, or persisted enriched records.

## 0.1.1

- Added `@trebired/logger-adapter` support with package-owned `logger` and `loggerAdapter` options, public store logger types, and generic store lifecycle/read/write/cache events.

## 0.1.0

- Initial public release of `@trebired/store`.
- Added the generic entity registry, store read/write API, request-scoped loader helpers, mode enrichment, private field redaction, enriched-record safety guards, cache invalidation, sub-entity execution, and the PostgreSQL JSONB storage adapter.
