@reforgium/statum 3.1.5 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +28 -24
- package/fesm2022/reforgium-statum.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [3.1.6]: 2026-04-17
|
|
2
|
+
|
|
3
|
+
### Fix:
|
|
4
|
+
- `PagedQueryStore`: plain array responses (`T[]`) no longer synthesize `totalElements = data.length`; `parseFlatArray()` now keeps `totalElements` as `undefined` unless the backend or a custom `parseResponse(...)` provides an exact total explicitly
|
|
5
|
+
|
|
6
|
+
### Test:
|
|
7
|
+
- updated flat-array regression coverage to assert unknown-total semantics instead of the old inferred-length behavior
|
|
8
|
+
|
|
9
|
+
### Docs:
|
|
10
|
+
- `README`: clarified that bare array responses are treated as unknown-total datasets and that exact totals must come from the backend or a custom `parseResponse(...)`
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
1
14
|
## [3.1.5]: 2026-04-14
|
|
2
15
|
|
|
3
16
|
### Fix:
|
package/README.md
CHANGED
|
@@ -336,19 +336,19 @@ Lightweight store for server-side pagination with filtering, dynamic query param
|
|
|
336
336
|
|
|
337
337
|
### State
|
|
338
338
|
|
|
339
|
-
| Field / Signal | Type
|
|
340
|
-
|
|
341
|
-
| items | `WritableSignal<T[]>`
|
|
342
|
-
| cached | `WritableSignal<T[]>`
|
|
343
|
-
| loading | `WritableSignal<boolean>`
|
|
344
|
-
| error | `WritableSignal<unknown \| null>`
|
|
345
|
-
| version | `WritableSignal<number>`
|
|
346
|
-
| page | `number`
|
|
347
|
-
| pageSize | `number`
|
|
348
|
-
| totalElements | `number \| undefined`
|
|
349
|
-
| filters | `Partial<F>`
|
|
350
|
-
| query | `Record<string, unknown>`
|
|
351
|
-
| sort | `ReadonlyArray<{ sort: string; order: 'asc' \| 'desc' }>` | Active sort state
|
|
339
|
+
| Field / Signal | Type | Description |
|
|
340
|
+
|----------------|-----------------------------------------------------------|---------------------------------------|
|
|
341
|
+
| items | `WritableSignal<T[]>` | Current page items |
|
|
342
|
+
| cached | `WritableSignal<T[]>` | Flattened cache of cached pages |
|
|
343
|
+
| loading | `WritableSignal<boolean>` | Loading indicator |
|
|
344
|
+
| error | `WritableSignal<unknown \| null>` | Last request error |
|
|
345
|
+
| version | `WritableSignal<number>` | Increments when the dataset is reset |
|
|
346
|
+
| page | `number` | Current page (0-based) |
|
|
347
|
+
| pageSize | `number` | Page size |
|
|
348
|
+
| totalElements | `number \| undefined` | Exact total items on server, if known |
|
|
349
|
+
| filters | `Partial<F>` | Active filters |
|
|
350
|
+
| query | `Record<string, unknown>` | Active query params |
|
|
351
|
+
| sort | `ReadonlyArray<{ sort: string; order: 'asc' \| 'desc' }>` | Active sort state |
|
|
352
352
|
|
|
353
353
|
Reactive metadata signals are also available:
|
|
354
354
|
|
|
@@ -368,9 +368,9 @@ Reactive metadata signals are also available:
|
|
|
368
368
|
| refetchWith | Repeat request, optional merge overrides: `refetchWith({ filters, query })` |
|
|
369
369
|
| updatePage | Change page: `updatePage(page, { ignoreCache })` or `updatePage({ page, ignoreCache })` |
|
|
370
370
|
| updatePageSize | Change page size and reset cache: `updatePageSize(size)` |
|
|
371
|
-
| setSort | Update sort state without triggering a request
|
|
372
|
-
| updateSort | Apply single-sort state and load from the first page
|
|
373
|
-
| updateSorts | Apply multi-sort state and load from the first page
|
|
371
|
+
| setSort | Update sort state without triggering a request |
|
|
372
|
+
| updateSort | Apply single-sort state and load from the first page |
|
|
373
|
+
| updateSorts | Apply multi-sort state and load from the first page |
|
|
374
374
|
| updateByOffset | Table-event mapper: `updateByOffset({ page/first/rows }, { query })` |
|
|
375
375
|
| setRouteParams | Update route params: `setRouteParams(params, { reset, abort })` |
|
|
376
376
|
| updateConfig | Patch config: `updateConfig(config)` |
|
|
@@ -393,13 +393,13 @@ Concurrency can be configured per store:
|
|
|
393
393
|
|
|
394
394
|
### Cache behavior
|
|
395
395
|
|
|
396
|
-
| Method | Cache read | Cache reset | Notes
|
|
397
|
-
|
|
398
|
-
| fetch | no | yes | Always starts clean from page `0`
|
|
399
|
-
| refetchWith | no | conditional | Reloads current state; when filters/query/sort actually change, resets to page `0` and replaces the dataset |
|
|
400
|
-
| updatePage | yes | no | Can bypass with `ignoreCache: true`
|
|
401
|
-
| updatePageSize | no | yes | Prevents mixed caches for different page sizes
|
|
402
|
-
| updateByOffset | yes | no | Internally maps to `page + size`
|
|
396
|
+
| Method | Cache read | Cache reset | Notes |
|
|
397
|
+
|----------------|------------|-------------|-------------------------------------------------------------------------------------------------------------|
|
|
398
|
+
| fetch | no | yes | Always starts clean from page `0` |
|
|
399
|
+
| refetchWith | no | conditional | Reloads current state; when filters/query/sort actually change, resets to page `0` and replaces the dataset |
|
|
400
|
+
| updatePage | yes | no | Can bypass with `ignoreCache: true` |
|
|
401
|
+
| updatePageSize | no | yes | Prevents mixed caches for different page sizes |
|
|
402
|
+
| updateByOffset | yes | no | Internally maps to `page + size` |
|
|
403
403
|
|
|
404
404
|
Example:
|
|
405
405
|
|
|
@@ -422,7 +422,9 @@ store.updateSort({ sort: 'name', order: 'asc' });
|
|
|
422
422
|
|
|
423
423
|
`cached()` remains a bounded hot-cache view. It is useful for cache-aware revisit/export/search helpers, but it is not the right datasource for infinity scrolling once cache eviction matters. For `data-grid` infinity mode, prefer passing the whole store as a `GridPagedDataSource` (`[source]="store"`) and let the grid keep its own page buffer.
|
|
424
424
|
|
|
425
|
-
`sort` and `routeParams` should be changed only through `setSort(...)` and `setRouteParams(...)`. Direct state mutation setters for `page`, `pageSize`, `filters`, `query`, and `totalElements` are available for low-level integration scenarios (such as external data-grid source contracts) but prefer the explicit store methods for typical use. `totalElements` may be `undefined` when the backend does not report a total.
|
|
425
|
+
`sort` and `routeParams` should be changed only through `setSort(...)` and `setRouteParams(...)`. Direct state mutation setters for `page`, `pageSize`, `filters`, `query`, and `totalElements` are available for low-level integration scenarios (such as external data-grid source contracts) but prefer the explicit store methods for typical use. `totalElements` may be `undefined` when the backend does not report a total.
|
|
426
|
+
|
|
427
|
+
If the transport returns a bare array (`T[]`) instead of a pageable object, `PagedQueryStore` treats it as an unknown-total dataset and keeps `totalElements === undefined`. A plain array does not prove the final dataset size. If your backend knows the exact total, return it explicitly or map the response with `parseResponse(...)`.
|
|
426
428
|
|
|
427
429
|
### PagedQueryStore + DataGrid source mode
|
|
428
430
|
|
|
@@ -449,6 +451,8 @@ This works because the store already exposes the expected source contract:
|
|
|
449
451
|
- `updatePage(...)`
|
|
450
452
|
- `updatePageSize(...)`
|
|
451
453
|
- `updateSort(...)`
|
|
454
|
+
|
|
455
|
+
When `PagedQueryStore` is fed by a flat-array response without an exact backend total, `totalElements` stays `undefined`. This is intentional: consumers such as `@reforgium/data-grid` can then stay in open-ended paging mode instead of trusting a fake total derived from `data.length`.
|
|
452
456
|
- `updateSorts(...)`
|
|
453
457
|
|
|
454
458
|
Keep `data-grid` source prefetch in `sequential` mode when the store uses `latest-wins`. Switch to `parallel` only if the store is configured with `concurrency: 'parallel'` and the backend flow supports overlapping page requests.
|
package/package.json
CHANGED