@reforgium/statum 3.0.0-rc.0 → 3.0.0
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 +343 -83
- package/fesm2022/reforgium-statum.mjs +423 -133
- package/package.json +3 -3
- package/types/reforgium-statum.d.ts +181 -58
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0.0
|
|
2
|
+
"version": "3.0.0",
|
|
3
3
|
"name": "@reforgium/statum",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Signals-first query and data stores for Angular",
|
|
5
5
|
"author": "rtommievich",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@angular/common": ">=18.0.0",
|
|
44
44
|
"@angular/core": ">=18.0.0",
|
|
45
|
-
"@reforgium/internal": ">=1.
|
|
45
|
+
"@reforgium/internal": ">=1.3.0",
|
|
46
46
|
"rxjs": ">=7.0.0"
|
|
47
47
|
},
|
|
48
48
|
"module": "fesm2022/reforgium-statum.mjs",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyType, AnyDict, RestMethods, PageableRequest, PageableResponse } from '@reforgium/internal';
|
|
1
|
+
import { AnyType, AnyDict, RestMethods, QueryParams, PageableRequest, PageableResponse } 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';
|
|
@@ -10,6 +10,7 @@ import * as _reforgium_statum from '@reforgium/statum';
|
|
|
10
10
|
* Used in field serialization configuration.
|
|
11
11
|
*/
|
|
12
12
|
type Types = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'period' | 'nullable';
|
|
13
|
+
type FieldConcatType = 'comma' | 'multi' | 'json';
|
|
13
14
|
/**
|
|
14
15
|
* Allowed "flat" values after serialization.
|
|
15
16
|
* Such values are safe to pass in a query string or JSON.
|
|
@@ -34,9 +35,12 @@ type ParseFormatConfig<TypeFrom, TypeTo = SerializedTypeType> = {
|
|
|
34
35
|
type FormatConfig<TypeFrom, TypeTo = SerializedTypeType> = {
|
|
35
36
|
format?: (val: TypeFrom) => TypeTo;
|
|
36
37
|
};
|
|
37
|
-
type FieldConfig = {
|
|
38
|
+
type FieldConfig = ({
|
|
38
39
|
type: Types;
|
|
39
|
-
|
|
40
|
+
concatType?: FieldConcatType;
|
|
41
|
+
} | FieldsTypeConfig<DataType, AnyType>) & {
|
|
42
|
+
concatType?: FieldConcatType;
|
|
43
|
+
};
|
|
40
44
|
type FieldsTypeConfig<EntityType extends DataType, TypeFrom, TypeTo = SerializedTypeType> = {
|
|
41
45
|
parse: (val: TypeTo, data: SerializedType) => TypeFrom;
|
|
42
46
|
format: (val: TypeFrom, data: EntityType) => TypeTo;
|
|
@@ -93,7 +97,7 @@ type SerializerConfig = {
|
|
|
93
97
|
* - format: custom array formatter.
|
|
94
98
|
*/
|
|
95
99
|
mapArray: {
|
|
96
|
-
concatType:
|
|
100
|
+
concatType: FieldConcatType;
|
|
97
101
|
removeNullable?: boolean;
|
|
98
102
|
} & FormatConfig<AnyType[]>;
|
|
99
103
|
/**
|
|
@@ -219,6 +223,7 @@ declare class Serializer<EntityType extends DataType> {
|
|
|
219
223
|
private parseJsonObject;
|
|
220
224
|
private parseInputString;
|
|
221
225
|
private mergeConfig;
|
|
226
|
+
private resolveArrayFieldModes;
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
declare const createQuerySerializer: <EntityType extends DataType = DataType>(config?: Partial<SerializerConfig>) => Serializer<EntityType>;
|
|
@@ -241,11 +246,11 @@ type StorageInterface<Key, Type> = {
|
|
|
241
246
|
|
|
242
247
|
declare class LruCache<KeyT, ValueT> implements StorageInterface<KeyT, ValueT> {
|
|
243
248
|
private map;
|
|
244
|
-
constructor(limit?: number);
|
|
245
249
|
private _limit;
|
|
250
|
+
constructor(limit?: number);
|
|
246
251
|
get limit(): number;
|
|
247
|
-
set limit(value: number);
|
|
248
252
|
get length(): number;
|
|
253
|
+
set limit(value: number);
|
|
249
254
|
get(key: KeyT): NonNullable<ValueT> | null;
|
|
250
255
|
set(key: KeyT, value: ValueT): void;
|
|
251
256
|
remove(key: KeyT): boolean;
|
|
@@ -342,6 +347,7 @@ type ResourceStoreOptions = {
|
|
|
342
347
|
retry?: RetryConfig;
|
|
343
348
|
/** Trace hook for request/cache lifecycle events. */
|
|
344
349
|
onTrace?: (event: ResourceTraceEvent) => void;
|
|
350
|
+
serializer?: Partial<SerializerConfig>;
|
|
345
351
|
};
|
|
346
352
|
/**
|
|
347
353
|
* API call arguments.
|
|
@@ -459,6 +465,7 @@ declare class ResourceStore<Data> {
|
|
|
459
465
|
private readonly maxEntries;
|
|
460
466
|
private readonly entries;
|
|
461
467
|
private readonly scheduler;
|
|
468
|
+
private readonly mutationMethods;
|
|
462
469
|
/**
|
|
463
470
|
* @param routes Map of path templates for methods (`GET/POST/...` → `/users/:id`)
|
|
464
471
|
* @param opts Global options (baseUrl, ttlMs, delay, delayMode, presetQueries/payload, etc.)
|
|
@@ -526,12 +533,14 @@ declare class ResourceStore<Data> {
|
|
|
526
533
|
private callApi;
|
|
527
534
|
private buildUrl;
|
|
528
535
|
private prepareQuery;
|
|
536
|
+
private preparePayload;
|
|
529
537
|
private trace;
|
|
530
538
|
private resolveRetryConfig;
|
|
531
539
|
private defaultShouldRetry;
|
|
532
540
|
private runWithRetry;
|
|
533
541
|
private exec$;
|
|
534
542
|
private promoteCurrent;
|
|
543
|
+
private isEmptyObject;
|
|
535
544
|
}
|
|
536
545
|
|
|
537
546
|
declare const RESOURCE_PROFILES: {
|
|
@@ -593,21 +602,70 @@ declare class AbortError extends Error {
|
|
|
593
602
|
*/
|
|
594
603
|
declare function isAbort(e: unknown): e is AbortError;
|
|
595
604
|
|
|
605
|
+
type QuerySortOrder = 'asc' | 'desc';
|
|
606
|
+
type QuerySortRule<Key extends string = string> = {
|
|
607
|
+
sort: Key;
|
|
608
|
+
order: QuerySortOrder;
|
|
609
|
+
};
|
|
610
|
+
type QuerySortInput<Key extends string = string> = QuerySortRule<Key> | ReadonlyArray<QuerySortRule<Key>> | null | undefined;
|
|
611
|
+
type PagedQueryConcurrency = 'latest-wins' | 'parallel';
|
|
612
|
+
type OffsetPaginationType = {
|
|
613
|
+
page?: number;
|
|
614
|
+
first?: number | null;
|
|
615
|
+
rows?: number | null;
|
|
616
|
+
};
|
|
617
|
+
type FetchParams<FilterType> = Omit<QueryParams<FilterType>, 'sort'> & {
|
|
618
|
+
query?: AnyDict;
|
|
619
|
+
routeParams?: AnyDict;
|
|
620
|
+
sort?: QuerySortInput;
|
|
621
|
+
};
|
|
622
|
+
type FetchInput<FilterType> = {
|
|
623
|
+
filters?: Partial<FilterType>;
|
|
624
|
+
query?: AnyDict;
|
|
625
|
+
routeParams?: AnyDict;
|
|
626
|
+
sort?: QuerySortInput;
|
|
627
|
+
};
|
|
628
|
+
type RefetchWithInput<FilterType> = {
|
|
629
|
+
filters?: Partial<FilterType>;
|
|
630
|
+
query?: AnyDict;
|
|
631
|
+
sort?: QuerySortInput;
|
|
632
|
+
};
|
|
633
|
+
type UpdatePageOptions = {
|
|
634
|
+
ignoreCache?: boolean;
|
|
635
|
+
};
|
|
636
|
+
type UpdatePageInput = UpdatePageOptions & {
|
|
637
|
+
page?: number;
|
|
638
|
+
};
|
|
639
|
+
type UpdateByOffsetOptions = {
|
|
640
|
+
query?: AnyDict;
|
|
641
|
+
sort?: QuerySortInput;
|
|
642
|
+
};
|
|
643
|
+
type SetRouteParamsOptions = {
|
|
644
|
+
reset?: boolean;
|
|
645
|
+
abort?: boolean;
|
|
646
|
+
};
|
|
647
|
+
|
|
596
648
|
/**
|
|
597
649
|
* Configuration for the paginated data store.
|
|
598
650
|
*
|
|
599
|
-
* Controls request method, page cache, debounce delay, and
|
|
651
|
+
* Controls request method, page cache, debounce delay, concurrency policy, and
|
|
600
652
|
* request/response transformations.
|
|
601
653
|
*/
|
|
602
654
|
type PagedQueryStoreConfig<ItemsType extends object, FilterType = unknown> = {
|
|
655
|
+
/** Optional base URL prepended to the route before the request is sent. */
|
|
656
|
+
baseUrl?: string;
|
|
603
657
|
/** Transport HTTP method: `GET`/`POST`/`PATCH`/`PUT`/`DELETE`. Defaults to global config or `POST`. */
|
|
604
658
|
method?: RestMethods;
|
|
605
659
|
/** Enable LRU cache for pages. */
|
|
606
660
|
hasCache?: boolean;
|
|
607
661
|
/** LRU cache size (number of pages). Defaults to global config. */
|
|
608
662
|
cacheSize?: number;
|
|
663
|
+
/** Disable LRU eviction and keep all loaded pages in memory. */
|
|
664
|
+
disableCacheLimit?: boolean;
|
|
609
665
|
/** Debounce delay before request (ms). Useful for frequent filter changes. */
|
|
610
666
|
debounceTime?: number;
|
|
667
|
+
/** Concurrency policy for overlapping requests. Defaults to `latest-wins`. */
|
|
668
|
+
concurrency?: PagedQueryConcurrency;
|
|
611
669
|
/** Initial pagination params. `page` is required. */
|
|
612
670
|
presetQuery?: {
|
|
613
671
|
page: number;
|
|
@@ -615,59 +673,50 @@ type PagedQueryStoreConfig<ItemsType extends object, FilterType = unknown> = {
|
|
|
615
673
|
};
|
|
616
674
|
/** Initial filters. Will be sent with the first request. */
|
|
617
675
|
presetFilters?: Partial<FilterType>;
|
|
676
|
+
/** Initial sort applied to requests. */
|
|
677
|
+
presetSort?: ReadonlyArray<QuerySortRule>;
|
|
618
678
|
/**
|
|
619
679
|
* Custom transformation of request data into a query object.
|
|
620
|
-
* Useful for mapping `page/pageSize` and selected filter fields
|
|
680
|
+
* Useful for mapping `page/pageSize` and selected filter fields to API-specific query keys.
|
|
621
681
|
* Returned object can contain nullable values; they are filtered before the transport call.
|
|
622
682
|
*/
|
|
623
683
|
parseRequest?: (data: PageableRequest & Partial<FilterType> & AnyDict) => AnyDict;
|
|
624
684
|
/**
|
|
625
685
|
* Custom parser of API response into unified `PageableResponse<ItemsType>`.
|
|
626
|
-
* Use if the server returns an array or a
|
|
686
|
+
* Use if the server returns an array or a non-standard structure.
|
|
627
687
|
*/
|
|
628
688
|
parseResponse?: (data: AnyType) => PageableResponse<ItemsType> | Promise<PageableResponse<ItemsType>>;
|
|
689
|
+
/** Sorting query serialization. Defaults to repeated `sort=a,asc` params. */
|
|
690
|
+
sorting?: {
|
|
691
|
+
queryKey?: string;
|
|
692
|
+
serialize?: (sort: QuerySortRule) => string;
|
|
693
|
+
};
|
|
629
694
|
};
|
|
630
695
|
/**
|
|
631
696
|
* Global defaults for `PagedQueryStore`.
|
|
632
697
|
* Can be provided via DI to avoid duplicating config in each store.
|
|
633
698
|
*/
|
|
634
699
|
type PagedQueryStoreProviderConfig = {
|
|
700
|
+
/** Default base URL for all stores (if not overridden locally). */
|
|
701
|
+
defaultBaseUrl?: string;
|
|
635
702
|
/** Default method for all stores (if not overridden locally). */
|
|
636
703
|
defaultMethod?: RestMethods;
|
|
637
704
|
/** Default base `page/pageSize`. */
|
|
638
705
|
defaultQuery?: PagedQueryStoreConfig<object>['presetQuery'];
|
|
639
|
-
/** Global `parseRequest`
|
|
706
|
+
/** Global `parseRequest` maps pagination into a query object. */
|
|
640
707
|
defaultParseRequest?: PagedQueryStoreConfig<object>['parseRequest'];
|
|
708
|
+
/** Global default sorting config. */
|
|
709
|
+
defaultSorting?: PagedQueryStoreConfig<object>['sorting'];
|
|
710
|
+
/** Global default concurrency policy. */
|
|
711
|
+
defaultConcurrency?: PagedQueryStoreConfig<object>['concurrency'];
|
|
641
712
|
/** Whether to enable page cache by default. */
|
|
642
713
|
defaultHasCache?: boolean;
|
|
643
714
|
/** Default LRU page cache size. */
|
|
644
715
|
defaultCacheSize?: number;
|
|
716
|
+
/** Disable LRU eviction globally for all stores unless overridden locally. */
|
|
717
|
+
defaultDisableCacheLimit?: boolean;
|
|
645
718
|
};
|
|
646
719
|
|
|
647
|
-
type OffsetPaginationType = {
|
|
648
|
-
page?: number;
|
|
649
|
-
first?: number | null;
|
|
650
|
-
rows?: number | null;
|
|
651
|
-
};
|
|
652
|
-
type FetchInput<FilterType> = {
|
|
653
|
-
filters?: Partial<FilterType>;
|
|
654
|
-
query?: AnyDict;
|
|
655
|
-
routeParams?: AnyDict;
|
|
656
|
-
};
|
|
657
|
-
type RefreshInput<FilterType> = {
|
|
658
|
-
filters?: Partial<FilterType>;
|
|
659
|
-
query?: AnyDict;
|
|
660
|
-
};
|
|
661
|
-
type UpdatePageOptions = {
|
|
662
|
-
ignoreCache?: boolean;
|
|
663
|
-
};
|
|
664
|
-
type UpdateByOffsetOptions = {
|
|
665
|
-
query?: AnyDict;
|
|
666
|
-
};
|
|
667
|
-
type SetRouteParamsOptions = {
|
|
668
|
-
reset?: boolean;
|
|
669
|
-
abort?: boolean;
|
|
670
|
-
};
|
|
671
720
|
/**
|
|
672
721
|
* Store for paginated data (tables/lists) with per-page cache and unified requests.
|
|
673
722
|
*
|
|
@@ -688,47 +737,88 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
688
737
|
#private;
|
|
689
738
|
private route;
|
|
690
739
|
config: PagedQueryStoreConfig<ItemsType, FilterType>;
|
|
740
|
+
private static readonly DISABLED_CACHE_LIMIT;
|
|
691
741
|
private readonly defaultConfig;
|
|
742
|
+
private readonly injector;
|
|
692
743
|
/** Current page data (reactive). */
|
|
693
744
|
items: WritableSignal<ItemsType[]>;
|
|
694
|
-
/** Merged cache of pages (flat list)
|
|
745
|
+
/** Merged cache of pages (flat list) handy for search/export. */
|
|
695
746
|
cached: WritableSignal<ItemsType[]>;
|
|
696
747
|
/** Loading flag of the current operation. */
|
|
697
748
|
loading: WritableSignal<boolean>;
|
|
749
|
+
/** Last request error (if any). */
|
|
750
|
+
error: WritableSignal<unknown>;
|
|
751
|
+
/** Increments when the current dataset is reset/replaced. Useful for external consumers with local buffers. */
|
|
752
|
+
version: WritableSignal<number>;
|
|
753
|
+
readonly pageState: _angular_core.Signal<number>;
|
|
754
|
+
readonly pageSizeState: _angular_core.Signal<number>;
|
|
755
|
+
readonly totalElementsState: _angular_core.Signal<number>;
|
|
756
|
+
readonly filtersState: _angular_core.Signal<Partial<FilterType>>;
|
|
757
|
+
readonly queryState: _angular_core.Signal<AnyDict>;
|
|
758
|
+
readonly sortState: _angular_core.Signal<QuerySortRule[]>;
|
|
759
|
+
readonly routeParamsState: _angular_core.Signal<AnyDict>;
|
|
760
|
+
/**
|
|
761
|
+
* @param route Resource URL pattern (e.g., `'/users'`)
|
|
762
|
+
* @param config Store behavior: method, cache, request/response parsers, debounce, presets, etc.
|
|
763
|
+
*/
|
|
764
|
+
constructor(route: string, config?: PagedQueryStoreConfig<ItemsType, FilterType>);
|
|
698
765
|
/** Current filters (applied to requests). */
|
|
699
|
-
filters: Partial<FilterType>;
|
|
766
|
+
get filters(): Partial<FilterType>;
|
|
700
767
|
/** Additional query params sent to transport requests. */
|
|
701
|
-
query: AnyDict;
|
|
768
|
+
get query(): AnyDict;
|
|
702
769
|
/** Current page index (0-based). */
|
|
703
|
-
page: number;
|
|
770
|
+
get page(): number;
|
|
704
771
|
/** Default page size. */
|
|
705
|
-
pageSize: number;
|
|
772
|
+
get pageSize(): number;
|
|
706
773
|
/** Total number of elements reported by the server. */
|
|
707
|
-
totalElements: number;
|
|
708
|
-
|
|
774
|
+
get totalElements(): number;
|
|
775
|
+
/** Current sort rules. */
|
|
776
|
+
get sort(): QuerySortRule[];
|
|
709
777
|
/**
|
|
710
|
-
* @
|
|
711
|
-
*
|
|
778
|
+
* @deprecated Prefer `fetch(...)`, `refetchWith(...)`, or a dedicated setter method.
|
|
779
|
+
* Direct state mutation bypasses request semantics and should be treated as legacy.
|
|
712
780
|
*/
|
|
713
|
-
|
|
781
|
+
set filters(value: Partial<FilterType>);
|
|
782
|
+
/**
|
|
783
|
+
* @deprecated Prefer `fetch(...)`, `refetchWith(...)`, or a dedicated setter method.
|
|
784
|
+
* Direct state mutation bypasses request semantics and should be treated as legacy.
|
|
785
|
+
*/
|
|
786
|
+
set query(value: AnyDict);
|
|
787
|
+
/**
|
|
788
|
+
* @deprecated Prefer `updatePage(...)`, `fetch(...)`, or `refetchWith(...)`.
|
|
789
|
+
* Direct state mutation bypasses request semantics and should be treated as legacy.
|
|
790
|
+
*/
|
|
791
|
+
set page(value: number);
|
|
792
|
+
/**
|
|
793
|
+
* @deprecated Prefer `updatePageSize(...)`.
|
|
794
|
+
* Direct state mutation bypasses request semantics and should be treated as legacy.
|
|
795
|
+
*/
|
|
796
|
+
set pageSize(value: number);
|
|
797
|
+
/**
|
|
798
|
+
* @deprecated Managed by transport responses. Direct assignment should be treated as legacy.
|
|
799
|
+
*/
|
|
800
|
+
set totalElements(value: number);
|
|
714
801
|
/**
|
|
715
802
|
* Fetch data with explicit filters and query params from the first page.
|
|
716
803
|
* Replaces legacy `setFilters`.
|
|
717
804
|
*/
|
|
718
|
-
fetch: ({ filters, query, routeParams }?: FetchInput<FilterType>) => Promise<ItemsType[] | undefined>;
|
|
805
|
+
fetch: ({ filters, query, routeParams, sort }?: FetchInput<FilterType>) => Promise<ItemsType[] | undefined>;
|
|
719
806
|
/**
|
|
720
807
|
* Force reload current data.
|
|
721
808
|
* Optional args merge into active filters/query.
|
|
722
|
-
* Route params are intentionally not changed from `
|
|
809
|
+
* Route params are intentionally not changed from `refetchWith`.
|
|
723
810
|
*/
|
|
724
|
-
|
|
811
|
+
refetchWith({ filters, query, sort }?: RefetchWithInput<FilterType>): Promise<ItemsType[] | undefined>;
|
|
725
812
|
/**
|
|
726
813
|
* Switch page with a request.
|
|
727
|
-
* If cache is enabled and the page is present in LRU
|
|
728
|
-
* @param page page index (0-based)
|
|
729
|
-
* @param
|
|
814
|
+
* If cache is enabled and the page is present in LRU returns it from cache.
|
|
815
|
+
* @param page page index (0-based) or object form: `{ page }`
|
|
816
|
+
* @param options request options
|
|
817
|
+
* @param options.ignoreCache ignore cache and fetch from network
|
|
730
818
|
*/
|
|
731
|
-
updatePage: (page?: number
|
|
819
|
+
updatePage: (page?: number | {
|
|
820
|
+
page: number;
|
|
821
|
+
}, { ignoreCache }?: UpdatePageOptions) => Promise<ItemsType[] | undefined>;
|
|
732
822
|
/**
|
|
733
823
|
* Change page size (will go to the first page) and fetch.
|
|
734
824
|
* @param size new size (rows per page)
|
|
@@ -737,25 +827,29 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
737
827
|
/**
|
|
738
828
|
* Helper for offset-based table events (PrimeNG, etc.) with `page/first/rows`.
|
|
739
829
|
*/
|
|
740
|
-
updateByOffset: ({ page: pageNum, first, rows }?: OffsetPaginationType, { query }?: UpdateByOffsetOptions) => Promise<ItemsType[] | undefined>;
|
|
830
|
+
updateByOffset: ({ page: pageNum, first, rows }?: OffsetPaginationType, { query, sort }?: UpdateByOffsetOptions) => Promise<ItemsType[] | undefined>;
|
|
831
|
+
setSort: (sort?: QuerySortInput) => void;
|
|
832
|
+
updateSort: (sort?: QuerySortRule | null) => Promise<ItemsType[] | undefined>;
|
|
833
|
+
updateSorts: (sort?: ReadonlyArray<QuerySortRule> | null) => Promise<ItemsType[] | undefined>;
|
|
741
834
|
/**
|
|
742
835
|
* Set route parameters (path variables) for the resource URL.
|
|
743
|
-
* Does not trigger loading automatically - call `
|
|
836
|
+
* Does not trigger loading automatically - call `refetchWith()` or `updatePage()` after.
|
|
744
837
|
*
|
|
745
838
|
* @param params Dictionary of route parameters (e.g., `{ id: '123' }`)
|
|
839
|
+
* @param opts
|
|
746
840
|
* @param opts.reset If `true`, resets page to 0, clears cache, total elements count, and items
|
|
747
841
|
* @param opts.abort If `true`, aborts all active transport requests and sets loading to false
|
|
748
842
|
*
|
|
749
843
|
* @example
|
|
750
844
|
* ```ts
|
|
751
845
|
* store.setRouteParams({ userId: '42' });
|
|
752
|
-
* await store.
|
|
846
|
+
* await store.refetchWith(); // fetch with new params
|
|
753
847
|
*
|
|
754
848
|
* // Or with options:
|
|
755
849
|
* store.setRouteParams({ userId: '42' }, { reset: false, abort: true });
|
|
756
850
|
* ```
|
|
757
851
|
*/
|
|
758
|
-
setRouteParams: (params?: AnyDict,
|
|
852
|
+
setRouteParams: (params?: AnyDict, opts?: SetRouteParamsOptions) => void;
|
|
759
853
|
/**
|
|
760
854
|
* Update store config on the fly (without re-creation).
|
|
761
855
|
* Does not trigger loading automatically.
|
|
@@ -773,8 +867,18 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
773
867
|
private parseResponseData;
|
|
774
868
|
private updateCache;
|
|
775
869
|
private parseFlatArray;
|
|
870
|
+
private resetDataset;
|
|
871
|
+
private bumpVersion;
|
|
872
|
+
private invalidateRequests;
|
|
873
|
+
private resolveConcurrency;
|
|
874
|
+
private shouldIgnoreRequestResult;
|
|
776
875
|
private applyConfig;
|
|
876
|
+
private resolveCacheLimit;
|
|
777
877
|
private applyPresetMeta;
|
|
878
|
+
private normalizeSort;
|
|
879
|
+
private resolveSortQueryKey;
|
|
880
|
+
private sortRulesToTokens;
|
|
881
|
+
private reinitTransport;
|
|
778
882
|
}
|
|
779
883
|
|
|
780
884
|
/**
|
|
@@ -821,6 +925,10 @@ type DictStoreConfig<ItemsType extends object> = {
|
|
|
821
925
|
method?: 'GET' | 'POST';
|
|
822
926
|
/** Debounce delay before request (ms) — for frequent input/search. */
|
|
823
927
|
debounceTime?: number;
|
|
928
|
+
/** Cache freshness window (ms). Undefined means restored cache does not expire. */
|
|
929
|
+
ttlMs?: number;
|
|
930
|
+
/** When cache is stale, keep visible items and refresh them in the background. */
|
|
931
|
+
revalidate?: boolean;
|
|
824
932
|
/** Maximum number of options exposed (truncates `options`). */
|
|
825
933
|
maxOptionsSize?: number;
|
|
826
934
|
/** Field key for label in a dictionary item. Defaults to `'name'`. */
|
|
@@ -869,6 +977,10 @@ type DictStoreProviderConfig = {
|
|
|
869
977
|
defaultRestMethod?: DictStoreConfig<AnyType>['method'];
|
|
870
978
|
/** Debounce delay before request (ms) — for frequent input/search. */
|
|
871
979
|
defaultDebounceTime?: DictStoreConfig<AnyType>['debounceTime'];
|
|
980
|
+
/** Cache freshness window (ms). Undefined means restored cache does not expire. */
|
|
981
|
+
defaultTtlMs?: DictStoreConfig<AnyType>['ttlMs'];
|
|
982
|
+
/** When cache is stale, keep visible items and refresh them in the background. */
|
|
983
|
+
defaultRevalidate?: DictStoreConfig<AnyType>['revalidate'];
|
|
872
984
|
/** Maximum number of options exposed (truncates `options`). */
|
|
873
985
|
defaultMaxOptionsSize?: DictStoreConfig<AnyType>['maxOptionsSize'];
|
|
874
986
|
/** Field key for label in a dictionary item. Defaults to `'name'`. */
|
|
@@ -899,6 +1011,7 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
899
1011
|
private apiUrl;
|
|
900
1012
|
private storageKey;
|
|
901
1013
|
static readonly MAX_CACHE_SIZE = 400;
|
|
1014
|
+
private static readonly META_SUFFIX;
|
|
902
1015
|
/**
|
|
903
1016
|
* Default dictionary configuration resolved from {@link STATUM_CONFIG}.
|
|
904
1017
|
*
|
|
@@ -910,12 +1023,16 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
910
1023
|
private readonly valueKey;
|
|
911
1024
|
private readonly maxOptionsSize?;
|
|
912
1025
|
private readonly storage?;
|
|
1026
|
+
private readonly metaStorage?;
|
|
1027
|
+
private readonly ttlMs?;
|
|
1028
|
+
private readonly revalidate;
|
|
1029
|
+
private readonly cacheUpdatedAt;
|
|
913
1030
|
/**
|
|
914
1031
|
* Search text.
|
|
915
1032
|
* With `fixed: true` filters the local cache; with `fixed: false` triggers server search.
|
|
916
1033
|
*/
|
|
917
1034
|
searchText: _angular_core.WritableSignal<string>;
|
|
918
|
-
private debouncedSearchText;
|
|
1035
|
+
private readonly debouncedSearchText;
|
|
919
1036
|
/**
|
|
920
1037
|
* Additional filters for server request (or presets).
|
|
921
1038
|
*/
|
|
@@ -941,9 +1058,10 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
941
1058
|
* @param storageKey key for saving cache in the selected strategy
|
|
942
1059
|
* @param cfg behavior (fixed/search, parsers, label/value keys, cache strategy, etc.)
|
|
943
1060
|
*/
|
|
944
|
-
constructor(apiUrl: string, storageKey: string, { autoLoad, method, presetFilters, parseResponse, parseRequest, debounceTime, fixed, maxOptionsSize, labelKey, valueKey, keyPrefix, cacheStrategy, }: DictStoreConfig<Type>);
|
|
1061
|
+
constructor(apiUrl: string, storageKey: string, { autoLoad, method, presetFilters, parseResponse, parseRequest, debounceTime, ttlMs, revalidate, fixed, maxOptionsSize, labelKey, valueKey, keyPrefix, cacheStrategy, }: DictStoreConfig<Type>);
|
|
945
1062
|
/** Restore cache from the selected storage (`persist`/`session`/`lru`/`memory`). */
|
|
946
1063
|
restoreCache(): void;
|
|
1064
|
+
clearCache(): void;
|
|
947
1065
|
/**
|
|
948
1066
|
* Set a search query and filters.
|
|
949
1067
|
* With `fixed: false` initiates server search; with `fixed: true` — local filtering.
|
|
@@ -970,9 +1088,14 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
970
1088
|
[Symbol.dispose](): void;
|
|
971
1089
|
private mergeIntoCache;
|
|
972
1090
|
private restoreFromStorage;
|
|
1091
|
+
private persistCache;
|
|
973
1092
|
private filterLocal;
|
|
974
1093
|
private keyOf;
|
|
975
1094
|
private setAutoload;
|
|
1095
|
+
private shouldFetchFixedCache;
|
|
1096
|
+
private shouldRevalidateCache;
|
|
1097
|
+
private isCacheStale;
|
|
1098
|
+
private metaKey;
|
|
976
1099
|
}
|
|
977
1100
|
|
|
978
1101
|
declare class DictLocalStore<Type extends AnyDict> {
|
|
@@ -1093,5 +1216,5 @@ declare const STATUM_CONFIG: InjectionToken<StatumConfig>;
|
|
|
1093
1216
|
declare const provideStatum: (config: StatumConfig) => EnvironmentProviders;
|
|
1094
1217
|
|
|
1095
1218
|
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 };
|
|
1219
|
+
export type { DataType, DictLocalConfig, DictStoreConfig, DictStoreProviderConfig, EntityId, EntityStoreConfig, FetchInput, FetchParams, FieldConfig, OffsetPaginationType, PagedQueryStoreConfig, PagedQueryStoreProviderConfig, QuerySortInput, QuerySortOrder, QuerySortRule, RefetchWithInput, ResourceProfileName, ResourceRoutesMap, ResourceStatus, ResourceStoreOptions, ResourceTraceEvent, RetryConfig, SerializedType, SerializerConfig, SetRouteParamsOptions, StatumConfig, StorageInterface, StorageStrategy, StorageStrategyOptions, Types, UpdateByOffsetOptions, UpdatePageInput, UpdatePageOptions };
|
|
1097
1220
|
//# sourceMappingURL=reforgium-statum.d.ts.map
|