@reforgium/statum 3.0.0-rc.1 → 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 +342 -83
- package/fesm2022/reforgium-statum.mjs +416 -127
- package/package.json +3 -3
- package/types/reforgium-statum.d.ts +176 -59
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
|
|
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,62 +673,48 @@ 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;
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
type OffsetPaginationType = {
|
|
648
|
-
page?: number;
|
|
649
|
-
first?: number | null;
|
|
650
|
-
rows?: number | null;
|
|
651
|
-
};
|
|
652
|
-
type FetchParams<FilterType> = QueryParams<FilterType> & {
|
|
653
|
-
query?: AnyDict;
|
|
654
|
-
routeParams?: AnyDict;
|
|
655
|
-
};
|
|
656
|
-
type FetchInput<FilterType> = {
|
|
657
|
-
filters?: Partial<FilterType>;
|
|
658
|
-
query?: AnyDict;
|
|
659
|
-
routeParams?: AnyDict;
|
|
660
|
-
};
|
|
661
|
-
type RefetchWithInput<FilterType> = {
|
|
662
|
-
filters?: Partial<FilterType>;
|
|
663
|
-
query?: AnyDict;
|
|
664
|
-
};
|
|
665
|
-
type UpdatePageOptions = {
|
|
666
|
-
ignoreCache?: boolean;
|
|
667
|
-
};
|
|
668
|
-
type UpdateByOffsetOptions = {
|
|
669
|
-
query?: AnyDict;
|
|
670
|
-
};
|
|
671
|
-
type SetRouteParamsOptions = {
|
|
672
|
-
reset?: boolean;
|
|
673
|
-
abort?: boolean;
|
|
716
|
+
/** Disable LRU eviction globally for all stores unless overridden locally. */
|
|
717
|
+
defaultDisableCacheLimit?: boolean;
|
|
674
718
|
};
|
|
675
719
|
|
|
676
720
|
/**
|
|
@@ -693,47 +737,88 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
693
737
|
#private;
|
|
694
738
|
private route;
|
|
695
739
|
config: PagedQueryStoreConfig<ItemsType, FilterType>;
|
|
740
|
+
private static readonly DISABLED_CACHE_LIMIT;
|
|
696
741
|
private readonly defaultConfig;
|
|
742
|
+
private readonly injector;
|
|
697
743
|
/** Current page data (reactive). */
|
|
698
744
|
items: WritableSignal<ItemsType[]>;
|
|
699
|
-
/** Merged cache of pages (flat list)
|
|
745
|
+
/** Merged cache of pages (flat list) handy for search/export. */
|
|
700
746
|
cached: WritableSignal<ItemsType[]>;
|
|
701
747
|
/** Loading flag of the current operation. */
|
|
702
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>);
|
|
703
765
|
/** Current filters (applied to requests). */
|
|
704
|
-
filters: Partial<FilterType>;
|
|
766
|
+
get filters(): Partial<FilterType>;
|
|
705
767
|
/** Additional query params sent to transport requests. */
|
|
706
|
-
query: AnyDict;
|
|
768
|
+
get query(): AnyDict;
|
|
707
769
|
/** Current page index (0-based). */
|
|
708
|
-
page: number;
|
|
770
|
+
get page(): number;
|
|
709
771
|
/** Default page size. */
|
|
710
|
-
pageSize: number;
|
|
772
|
+
get pageSize(): number;
|
|
711
773
|
/** Total number of elements reported by the server. */
|
|
712
|
-
totalElements: number;
|
|
713
|
-
|
|
774
|
+
get totalElements(): number;
|
|
775
|
+
/** Current sort rules. */
|
|
776
|
+
get sort(): QuerySortRule[];
|
|
714
777
|
/**
|
|
715
|
-
* @
|
|
716
|
-
*
|
|
778
|
+
* @deprecated Prefer `fetch(...)`, `refetchWith(...)`, or a dedicated setter method.
|
|
779
|
+
* Direct state mutation bypasses request semantics and should be treated as legacy.
|
|
717
780
|
*/
|
|
718
|
-
|
|
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);
|
|
719
801
|
/**
|
|
720
802
|
* Fetch data with explicit filters and query params from the first page.
|
|
721
803
|
* Replaces legacy `setFilters`.
|
|
722
804
|
*/
|
|
723
|
-
fetch: ({ filters, query, routeParams }?: FetchInput<FilterType>) => Promise<ItemsType[] | undefined>;
|
|
805
|
+
fetch: ({ filters, query, routeParams, sort }?: FetchInput<FilterType>) => Promise<ItemsType[] | undefined>;
|
|
724
806
|
/**
|
|
725
807
|
* Force reload current data.
|
|
726
808
|
* Optional args merge into active filters/query.
|
|
727
809
|
* Route params are intentionally not changed from `refetchWith`.
|
|
728
810
|
*/
|
|
729
|
-
refetchWith({ filters, query }?: RefetchWithInput<FilterType>): Promise<ItemsType[] | undefined>;
|
|
811
|
+
refetchWith({ filters, query, sort }?: RefetchWithInput<FilterType>): Promise<ItemsType[] | undefined>;
|
|
730
812
|
/**
|
|
731
813
|
* Switch page with a request.
|
|
732
|
-
* If cache is enabled and the page is present in LRU
|
|
733
|
-
* @param page page index (0-based)
|
|
734
|
-
* @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
|
|
735
818
|
*/
|
|
736
|
-
updatePage: (page?: number
|
|
819
|
+
updatePage: (page?: number | {
|
|
820
|
+
page: number;
|
|
821
|
+
}, { ignoreCache }?: UpdatePageOptions) => Promise<ItemsType[] | undefined>;
|
|
737
822
|
/**
|
|
738
823
|
* Change page size (will go to the first page) and fetch.
|
|
739
824
|
* @param size new size (rows per page)
|
|
@@ -742,7 +827,10 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
742
827
|
/**
|
|
743
828
|
* Helper for offset-based table events (PrimeNG, etc.) with `page/first/rows`.
|
|
744
829
|
*/
|
|
745
|
-
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>;
|
|
746
834
|
/**
|
|
747
835
|
* Set route parameters (path variables) for the resource URL.
|
|
748
836
|
* Does not trigger loading automatically - call `refetchWith()` or `updatePage()` after.
|
|
@@ -779,8 +867,18 @@ declare class PagedQueryStore<ItemsType extends object, FilterType = unknown> {
|
|
|
779
867
|
private parseResponseData;
|
|
780
868
|
private updateCache;
|
|
781
869
|
private parseFlatArray;
|
|
870
|
+
private resetDataset;
|
|
871
|
+
private bumpVersion;
|
|
872
|
+
private invalidateRequests;
|
|
873
|
+
private resolveConcurrency;
|
|
874
|
+
private shouldIgnoreRequestResult;
|
|
782
875
|
private applyConfig;
|
|
876
|
+
private resolveCacheLimit;
|
|
783
877
|
private applyPresetMeta;
|
|
878
|
+
private normalizeSort;
|
|
879
|
+
private resolveSortQueryKey;
|
|
880
|
+
private sortRulesToTokens;
|
|
881
|
+
private reinitTransport;
|
|
784
882
|
}
|
|
785
883
|
|
|
786
884
|
/**
|
|
@@ -827,6 +925,10 @@ type DictStoreConfig<ItemsType extends object> = {
|
|
|
827
925
|
method?: 'GET' | 'POST';
|
|
828
926
|
/** Debounce delay before request (ms) — for frequent input/search. */
|
|
829
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;
|
|
830
932
|
/** Maximum number of options exposed (truncates `options`). */
|
|
831
933
|
maxOptionsSize?: number;
|
|
832
934
|
/** Field key for label in a dictionary item. Defaults to `'name'`. */
|
|
@@ -875,6 +977,10 @@ type DictStoreProviderConfig = {
|
|
|
875
977
|
defaultRestMethod?: DictStoreConfig<AnyType>['method'];
|
|
876
978
|
/** Debounce delay before request (ms) — for frequent input/search. */
|
|
877
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'];
|
|
878
984
|
/** Maximum number of options exposed (truncates `options`). */
|
|
879
985
|
defaultMaxOptionsSize?: DictStoreConfig<AnyType>['maxOptionsSize'];
|
|
880
986
|
/** Field key for label in a dictionary item. Defaults to `'name'`. */
|
|
@@ -905,6 +1011,7 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
905
1011
|
private apiUrl;
|
|
906
1012
|
private storageKey;
|
|
907
1013
|
static readonly MAX_CACHE_SIZE = 400;
|
|
1014
|
+
private static readonly META_SUFFIX;
|
|
908
1015
|
/**
|
|
909
1016
|
* Default dictionary configuration resolved from {@link STATUM_CONFIG}.
|
|
910
1017
|
*
|
|
@@ -916,12 +1023,16 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
916
1023
|
private readonly valueKey;
|
|
917
1024
|
private readonly maxOptionsSize?;
|
|
918
1025
|
private readonly storage?;
|
|
1026
|
+
private readonly metaStorage?;
|
|
1027
|
+
private readonly ttlMs?;
|
|
1028
|
+
private readonly revalidate;
|
|
1029
|
+
private readonly cacheUpdatedAt;
|
|
919
1030
|
/**
|
|
920
1031
|
* Search text.
|
|
921
1032
|
* With `fixed: true` filters the local cache; with `fixed: false` triggers server search.
|
|
922
1033
|
*/
|
|
923
1034
|
searchText: _angular_core.WritableSignal<string>;
|
|
924
|
-
private debouncedSearchText;
|
|
1035
|
+
private readonly debouncedSearchText;
|
|
925
1036
|
/**
|
|
926
1037
|
* Additional filters for server request (or presets).
|
|
927
1038
|
*/
|
|
@@ -947,9 +1058,10 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
947
1058
|
* @param storageKey key for saving cache in the selected strategy
|
|
948
1059
|
* @param cfg behavior (fixed/search, parsers, label/value keys, cache strategy, etc.)
|
|
949
1060
|
*/
|
|
950
|
-
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>);
|
|
951
1062
|
/** Restore cache from the selected storage (`persist`/`session`/`lru`/`memory`). */
|
|
952
1063
|
restoreCache(): void;
|
|
1064
|
+
clearCache(): void;
|
|
953
1065
|
/**
|
|
954
1066
|
* Set a search query and filters.
|
|
955
1067
|
* With `fixed: false` initiates server search; with `fixed: true` — local filtering.
|
|
@@ -976,9 +1088,14 @@ declare class DictStore<Type extends AnyDict> {
|
|
|
976
1088
|
[Symbol.dispose](): void;
|
|
977
1089
|
private mergeIntoCache;
|
|
978
1090
|
private restoreFromStorage;
|
|
1091
|
+
private persistCache;
|
|
979
1092
|
private filterLocal;
|
|
980
1093
|
private keyOf;
|
|
981
1094
|
private setAutoload;
|
|
1095
|
+
private shouldFetchFixedCache;
|
|
1096
|
+
private shouldRevalidateCache;
|
|
1097
|
+
private isCacheStale;
|
|
1098
|
+
private metaKey;
|
|
982
1099
|
}
|
|
983
1100
|
|
|
984
1101
|
declare class DictLocalStore<Type extends AnyDict> {
|
|
@@ -1099,5 +1216,5 @@ declare const STATUM_CONFIG: InjectionToken<StatumConfig>;
|
|
|
1099
1216
|
declare const provideStatum: (config: StatumConfig) => EnvironmentProviders;
|
|
1100
1217
|
|
|
1101
1218
|
export { AbortError, CacheMissError, DictLocalStore, DictStore, EntityStore, LruCache, PagedQueryStore, RESOURCE_PROFILES, ResourceStore, STATUM_CONFIG, Serializer, SerializerFieldError, createBodySerializer, createQuerySerializer, createResourceProfile, createStrictSerializer, isAbort, provideStatum, storageStrategy };
|
|
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 };
|
|
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 };
|
|
1103
1220
|
//# sourceMappingURL=reforgium-statum.d.ts.map
|