@reforgium/statum 3.0.0-rc.0 → 3.0.0-rc.1

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/README.md CHANGED
@@ -235,7 +235,7 @@ Lightweight store for server-side pagination with filtering, dynamic query param
235
235
  | Method | Description |
236
236
  |----------------|---------------------------------------------------------------------------|
237
237
  | fetch | Clean first-page request: `fetch({ filters, query, routeParams })` |
238
- | refresh | Repeat request, optional merge overrides: `refresh({ filters, query })` |
238
+ | refetchWith | Repeat request, optional merge overrides: `refetchWith({ filters, query })` |
239
239
  | updatePage | Change page: `updatePage(page, { ignoreCache })` |
240
240
  | updatePageSize | Change page size and reset cache: `updatePageSize(size)` |
241
241
  | updateByOffset | Table-event mapper: `updateByOffset({ page/first/rows }, { query })` |
@@ -249,7 +249,7 @@ Lightweight store for server-side pagination with filtering, dynamic query param
249
249
  | Method | Cache read | Cache reset | Notes |
250
250
  |----------------|------------|-------------|-------|
251
251
  | fetch | no | yes | Always starts clean from page `0` |
252
- | refresh | no | no | Uses active page/filters/query, merges overrides |
252
+ | refetchWith | no | no | Uses active page/filters/query, merges overrides |
253
253
  | updatePage | yes | no | Can bypass with `ignoreCache: true` |
254
254
  | updatePageSize | no | yes | Prevents mixed caches for different page sizes |
255
255
  | updateByOffset | yes | no | Internally maps to `page + size` |
@@ -431,3 +431,4 @@ const body = serializer.serialize({ name: ' Vasya ', active: null });
431
431
  MIT
432
432
 
433
433
 
434
+
@@ -1310,9 +1310,9 @@ class PagedQueryStore {
1310
1310
  /**
1311
1311
  * Force reload current data.
1312
1312
  * Optional args merge into active filters/query.
1313
- * Route params are intentionally not changed from `refresh`.
1313
+ * Route params are intentionally not changed from `refetchWith`.
1314
1314
  */
1315
- refresh({ filters, query } = {}) {
1315
+ refetchWith({ filters, query } = {}) {
1316
1316
  const nextFilters = filters == null ? this.filters : { ...this.filters, ...filters };
1317
1317
  const nextQuery = query == null ? this.query : { ...this.query, ...query };
1318
1318
  return this.#fetchItems({ filters: nextFilters, query: nextQuery });
@@ -1353,35 +1353,36 @@ class PagedQueryStore {
1353
1353
  };
1354
1354
  /**
1355
1355
  * Set route parameters (path variables) for the resource URL.
1356
- * Does not trigger loading automatically - call `refresh()` or `updatePage()` after.
1356
+ * Does not trigger loading automatically - call `refetchWith()` or `updatePage()` after.
1357
1357
  *
1358
1358
  * @param params Dictionary of route parameters (e.g., `{ id: '123' }`)
1359
+ * @param opts
1359
1360
  * @param opts.reset If `true`, resets page to 0, clears cache, total elements count, and items
1360
1361
  * @param opts.abort If `true`, aborts all active transport requests and sets loading to false
1361
1362
  *
1362
1363
  * @example
1363
1364
  * ```ts
1364
1365
  * store.setRouteParams({ userId: '42' });
1365
- * await store.refresh(); // fetch with new params
1366
+ * await store.refetchWith(); // fetch with new params
1366
1367
  *
1367
1368
  * // Or with options:
1368
1369
  * store.setRouteParams({ userId: '42' }, { reset: false, abort: true });
1369
1370
  * ```
1370
1371
  */
1371
- setRouteParams = (params = {}, { reset = false, abort = false } = {}) => {
1372
+ setRouteParams = (params = {}, opts = {}) => {
1372
1373
  const isChanged = !deepEqual(this.routeParams, params);
1373
1374
  if (!isChanged) {
1374
1375
  return;
1375
1376
  }
1376
1377
  this.routeParams = params;
1377
- if (reset) {
1378
+ if (opts.reset) {
1378
1379
  this.page = 0;
1379
1380
  this.totalElements = 0;
1380
1381
  this.#cache.clear();
1381
1382
  this.cached.set([]);
1382
1383
  this.items.set([]);
1383
1384
  }
1384
- if (abort) {
1385
+ if (opts.abort) {
1385
1386
  try {
1386
1387
  this.#transport?.abortAll?.('Route params changed');
1387
1388
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.0-rc.0",
2
+ "version": "3.0.0-rc.1",
3
3
  "name": "@reforgium/statum",
4
4
  "description": "reforgium State modules",
5
5
  "author": "rtommievich",
@@ -1,4 +1,4 @@
1
- import { AnyType, AnyDict, RestMethods, PageableRequest, PageableResponse } from '@reforgium/internal';
1
+ import { AnyType, AnyDict, RestMethods, PageableRequest, PageableResponse, QueryParams } from '@reforgium/internal';
2
2
  import * as _angular_core from '@angular/core';
3
3
  import { Signal, WritableSignal, EnvironmentProviders, InjectionToken } from '@angular/core';
4
4
  import * as _reforgium_statum from '@reforgium/statum';
@@ -649,12 +649,16 @@ type OffsetPaginationType = {
649
649
  first?: number | null;
650
650
  rows?: number | null;
651
651
  };
652
+ type FetchParams<FilterType> = QueryParams<FilterType> & {
653
+ query?: AnyDict;
654
+ routeParams?: AnyDict;
655
+ };
652
656
  type FetchInput<FilterType> = {
653
657
  filters?: Partial<FilterType>;
654
658
  query?: AnyDict;
655
659
  routeParams?: AnyDict;
656
660
  };
657
- type RefreshInput<FilterType> = {
661
+ type RefetchWithInput<FilterType> = {
658
662
  filters?: Partial<FilterType>;
659
663
  query?: AnyDict;
660
664
  };
@@ -668,6 +672,7 @@ type SetRouteParamsOptions = {
668
672
  reset?: boolean;
669
673
  abort?: boolean;
670
674
  };
675
+
671
676
  /**
672
677
  * Store for paginated data (tables/lists) with per-page cache and unified requests.
673
678
  *
@@ -719,9 +724,9 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
719
724
  /**
720
725
  * Force reload current data.
721
726
  * Optional args merge into active filters/query.
722
- * Route params are intentionally not changed from `refresh`.
727
+ * Route params are intentionally not changed from `refetchWith`.
723
728
  */
724
- refresh({ filters, query }?: RefreshInput<FilterType>): Promise<ItemsType[] | undefined>;
729
+ refetchWith({ filters, query }?: RefetchWithInput<FilterType>): Promise<ItemsType[] | undefined>;
725
730
  /**
726
731
  * Switch page with a request.
727
732
  * If cache is enabled and the page is present in LRU — returns it from cache.
@@ -740,22 +745,23 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
740
745
  updateByOffset: ({ page: pageNum, first, rows }?: OffsetPaginationType, { query }?: UpdateByOffsetOptions) => Promise<ItemsType[] | undefined>;
741
746
  /**
742
747
  * Set route parameters (path variables) for the resource URL.
743
- * Does not trigger loading automatically - call `refresh()` or `updatePage()` after.
748
+ * Does not trigger loading automatically - call `refetchWith()` or `updatePage()` after.
744
749
  *
745
750
  * @param params Dictionary of route parameters (e.g., `{ id: '123' }`)
751
+ * @param opts
746
752
  * @param opts.reset If `true`, resets page to 0, clears cache, total elements count, and items
747
753
  * @param opts.abort If `true`, aborts all active transport requests and sets loading to false
748
754
  *
749
755
  * @example
750
756
  * ```ts
751
757
  * store.setRouteParams({ userId: '42' });
752
- * await store.refresh(); // fetch with new params
758
+ * await store.refetchWith(); // fetch with new params
753
759
  *
754
760
  * // Or with options:
755
761
  * store.setRouteParams({ userId: '42' }, { reset: false, abort: true });
756
762
  * ```
757
763
  */
758
- setRouteParams: (params?: AnyDict, { reset, abort }?: SetRouteParamsOptions) => void;
764
+ setRouteParams: (params?: AnyDict, opts?: SetRouteParamsOptions) => void;
759
765
  /**
760
766
  * Update store config on the fly (without re-creation).
761
767
  * Does not trigger loading automatically.
@@ -1093,5 +1099,5 @@ declare const STATUM_CONFIG: InjectionToken<StatumConfig>;
1093
1099
  declare const provideStatum: (config: StatumConfig) => EnvironmentProviders;
1094
1100
 
1095
1101
  export { AbortError, CacheMissError, DictLocalStore, DictStore, EntityStore, LruCache, PagedQueryStore, RESOURCE_PROFILES, ResourceStore, STATUM_CONFIG, Serializer, SerializerFieldError, createBodySerializer, createQuerySerializer, createResourceProfile, createStrictSerializer, isAbort, provideStatum, storageStrategy };
1096
- export type { DataType, DictLocalConfig, DictStoreConfig, DictStoreProviderConfig, EntityId, EntityStoreConfig, FieldConfig, PagedQueryStoreConfig, PagedQueryStoreProviderConfig, ResourceProfileName, ResourceRoutesMap, ResourceStatus, ResourceStoreOptions, ResourceTraceEvent, RetryConfig, SerializedType, SerializerConfig, StatumConfig, StorageInterface, StorageStrategy, StorageStrategyOptions, Types };
1102
+ export type { DataType, DictLocalConfig, DictStoreConfig, DictStoreProviderConfig, EntityId, EntityStoreConfig, FetchInput, FetchParams, FieldConfig, OffsetPaginationType, PagedQueryStoreConfig, PagedQueryStoreProviderConfig, RefetchWithInput, ResourceProfileName, ResourceRoutesMap, ResourceStatus, ResourceStoreOptions, ResourceTraceEvent, RetryConfig, SerializedType, SerializerConfig, SetRouteParamsOptions, StatumConfig, StorageInterface, StorageStrategy, StorageStrategyOptions, Types, UpdateByOffsetOptions, UpdatePageOptions };
1097
1103
  //# sourceMappingURL=reforgium-statum.d.ts.map