@ngrx/data 20.1.0 → 21.0.0-beta.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/fesm2022/ngrx-data.mjs +86 -86
- package/package.json +8 -8
- package/schematics/ng-add/index.js +39 -42
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +0 -2
- package/schematics-core/index.js +24 -75
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +28 -44
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js +8 -15
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js +4 -8
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js +17 -22
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js +19 -24
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js +1 -4
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +1 -4
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +28 -36
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js +1 -4
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/parse-name.js +5 -8
- package/schematics-core/utility/parse-name.js.map +1 -1
- package/schematics-core/utility/project.js +9 -15
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/standalone.js +13 -18
- package/schematics-core/utility/standalone.js.map +1 -1
- package/schematics-core/utility/strings.js +9 -20
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js +4 -7
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js +16 -30
- package/schematics-core/utility/visitors.js.map +1 -1
- package/types/ngrx-data.d.ts +3465 -0
- package/index.d.ts +0 -6
- package/public_api.d.ts +0 -1
- package/src/actions/entity-action-factory.d.ts +0 -38
- package/src/actions/entity-action-guard.d.ts +0 -33
- package/src/actions/entity-action-operators.d.ts +0 -30
- package/src/actions/entity-action.d.ts +0 -37
- package/src/actions/entity-cache-action.d.ts +0 -147
- package/src/actions/entity-cache-change-set.d.ts +0 -66
- package/src/actions/entity-op.d.ts +0 -70
- package/src/actions/merge-strategy.d.ts +0 -20
- package/src/actions/update-response-data.d.ts +0 -20
- package/src/dataservices/data-service-error.d.ts +0 -18
- package/src/dataservices/default-data-service-config.d.ts +0 -27
- package/src/dataservices/default-data.service.d.ts +0 -57
- package/src/dataservices/entity-cache-data.service.d.ts +0 -58
- package/src/dataservices/entity-data.service.d.ts +0 -48
- package/src/dataservices/http-url-generator.d.ts +0 -94
- package/src/dataservices/interfaces.d.ts +0 -61
- package/src/dataservices/persistence-result-handler.service.d.ts +0 -30
- package/src/dispatchers/entity-cache-dispatcher.d.ts +0 -114
- package/src/dispatchers/entity-commands.d.ts +0 -217
- package/src/dispatchers/entity-dispatcher-base.d.ts +0 -269
- package/src/dispatchers/entity-dispatcher-default-options.d.ts +0 -23
- package/src/dispatchers/entity-dispatcher-factory.d.ts +0 -46
- package/src/dispatchers/entity-dispatcher.d.ts +0 -58
- package/src/effects/entity-cache-effects.d.ts +0 -46
- package/src/effects/entity-effects-scheduler.d.ts +0 -4
- package/src/effects/entity-effects.d.ts +0 -55
- package/src/entity-data-config.d.ts +0 -15
- package/src/entity-data-without-effects.module.d.ts +0 -15
- package/src/entity-data.module.d.ts +0 -15
- package/src/entity-metadata/entity-definition.d.ts +0 -16
- package/src/entity-metadata/entity-definition.service.d.ts +0 -62
- package/src/entity-metadata/entity-filters.d.ts +0 -12
- package/src/entity-metadata/entity-metadata.d.ts +0 -19
- package/src/entity-services/entity-collection-service-base.d.ts +0 -299
- package/src/entity-services/entity-collection-service-elements-factory.d.ts +0 -28
- package/src/entity-services/entity-collection-service-factory.d.ts +0 -22
- package/src/entity-services/entity-collection-service.d.ts +0 -37
- package/src/entity-services/entity-services-base.d.ts +0 -79
- package/src/entity-services/entity-services-elements.d.ts +0 -41
- package/src/entity-services/entity-services.d.ts +0 -50
- package/src/index.d.ts +0 -65
- package/src/provide-entity-data.d.ts +0 -78
- package/src/reducers/constants.d.ts +0 -8
- package/src/reducers/entity-cache-reducer.d.ts +0 -50
- package/src/reducers/entity-cache.d.ts +0 -4
- package/src/reducers/entity-change-tracker-base.d.ts +0 -181
- package/src/reducers/entity-change-tracker.d.ts +0 -169
- package/src/reducers/entity-collection-creator.d.ts +0 -15
- package/src/reducers/entity-collection-reducer-methods.d.ts +0 -365
- package/src/reducers/entity-collection-reducer-registry.d.ts +0 -47
- package/src/reducers/entity-collection-reducer.d.ts +0 -14
- package/src/reducers/entity-collection.d.ts +0 -41
- package/src/selectors/entity-cache-selector.d.ts +0 -7
- package/src/selectors/entity-selectors$.d.ts +0 -63
- package/src/selectors/entity-selectors.d.ts +0 -117
- package/src/utils/correlation-id-generator.d.ts +0 -20
- package/src/utils/default-logger.d.ts +0 -9
- package/src/utils/default-pluralizer.d.ts +0 -18
- package/src/utils/guid-fns.d.ts +0 -24
- package/src/utils/interfaces.d.ts +0 -16
- package/src/utils/utilities.d.ts +0 -26
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { EntityCollectionDataService } from './interfaces';
|
|
2
|
-
import { DefaultDataServiceFactory } from './default-data.service';
|
|
3
|
-
import * as i0 from "@angular/core";
|
|
4
|
-
/**
|
|
5
|
-
* Registry of EntityCollection data services that make REST-like CRUD calls
|
|
6
|
-
* to entity collection endpoints.
|
|
7
|
-
*/
|
|
8
|
-
export declare class EntityDataService {
|
|
9
|
-
protected defaultDataServiceFactory: DefaultDataServiceFactory;
|
|
10
|
-
protected services: {
|
|
11
|
-
[name: string]: EntityCollectionDataService<any>;
|
|
12
|
-
};
|
|
13
|
-
constructor(defaultDataServiceFactory: DefaultDataServiceFactory);
|
|
14
|
-
/**
|
|
15
|
-
* Get (or create) a data service for entity type
|
|
16
|
-
* @param entityName - the name of the type
|
|
17
|
-
*
|
|
18
|
-
* Examples:
|
|
19
|
-
* getService('Hero'); // data service for Heroes, untyped
|
|
20
|
-
* getService<Hero>('Hero'); // data service for Heroes, typed as Hero
|
|
21
|
-
*/
|
|
22
|
-
getService<T>(entityName: string): EntityCollectionDataService<T>;
|
|
23
|
-
/**
|
|
24
|
-
* Register an EntityCollectionDataService for an entity type
|
|
25
|
-
* @param entityName - the name of the entity type
|
|
26
|
-
* @param service - data service for that entity type
|
|
27
|
-
*
|
|
28
|
-
* Examples:
|
|
29
|
-
* registerService('Hero', myHeroDataService);
|
|
30
|
-
* registerService('Villain', myVillainDataService);
|
|
31
|
-
*/
|
|
32
|
-
registerService<T>(entityName: string, service: EntityCollectionDataService<T>): void;
|
|
33
|
-
/**
|
|
34
|
-
* Register a batch of data services.
|
|
35
|
-
* @param services - data services to merge into existing services
|
|
36
|
-
*
|
|
37
|
-
* Examples:
|
|
38
|
-
* registerServices({
|
|
39
|
-
* Hero: myHeroDataService,
|
|
40
|
-
* Villain: myVillainDataService
|
|
41
|
-
* });
|
|
42
|
-
*/
|
|
43
|
-
registerServices(services: {
|
|
44
|
-
[name: string]: EntityCollectionDataService<any>;
|
|
45
|
-
}): void;
|
|
46
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<EntityDataService, never>;
|
|
47
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<EntityDataService>;
|
|
48
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Pluralizer } from '../utils/interfaces';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* Known resource URLS for specific entity types.
|
|
5
|
-
* Each entity's resource URLS are endpoints that
|
|
6
|
-
* target single entity and multi-entity HTTP operations.
|
|
7
|
-
* Used by the `DefaultHttpUrlGenerator`.
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class EntityHttpResourceUrls {
|
|
10
|
-
[entityName: string]: HttpResourceUrls;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Resource URLS for HTTP operations that target single entity
|
|
14
|
-
* and multi-entity endpoints.
|
|
15
|
-
*/
|
|
16
|
-
export interface HttpResourceUrls {
|
|
17
|
-
/**
|
|
18
|
-
* The URL path for a single entity endpoint, e.g, `some-api-root/hero/`
|
|
19
|
-
* such as you'd use to add a hero.
|
|
20
|
-
* Example: `httpClient.post<Hero>('some-api-root/hero/', addedHero)`.
|
|
21
|
-
* Note trailing slash (/).
|
|
22
|
-
*/
|
|
23
|
-
entityResourceUrl: string;
|
|
24
|
-
/**
|
|
25
|
-
* The URL path for a multiple-entity endpoint, e.g, `some-api-root/heroes/`
|
|
26
|
-
* such as you'd use when getting all heroes.
|
|
27
|
-
* Example: `httpClient.get<Hero[]>('some-api-root/heroes/')`
|
|
28
|
-
* Note trailing slash (/).
|
|
29
|
-
*/
|
|
30
|
-
collectionResourceUrl: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Generate the base part of an HTTP URL for
|
|
34
|
-
* single entity or entity collection resource
|
|
35
|
-
*/
|
|
36
|
-
export declare abstract class HttpUrlGenerator {
|
|
37
|
-
/**
|
|
38
|
-
* Return the base URL for a single entity resource,
|
|
39
|
-
* e.g., the base URL to get a single hero by its id
|
|
40
|
-
*/
|
|
41
|
-
abstract entityResource(entityName: string, root: string, trailingSlashEndpoints: boolean): string;
|
|
42
|
-
/**
|
|
43
|
-
* Return the base URL for a collection resource,
|
|
44
|
-
* e.g., the base URL to get all heroes
|
|
45
|
-
*/
|
|
46
|
-
abstract collectionResource(entityName: string, root: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* Register known single-entity and collection resource URLs for HTTP calls
|
|
49
|
-
* @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names
|
|
50
|
-
*/
|
|
51
|
-
abstract registerHttpResourceUrls(entityHttpResourceUrls?: EntityHttpResourceUrls): void;
|
|
52
|
-
}
|
|
53
|
-
export declare class DefaultHttpUrlGenerator implements HttpUrlGenerator {
|
|
54
|
-
private pluralizer;
|
|
55
|
-
/**
|
|
56
|
-
* Known single-entity and collection resource URLs for HTTP calls.
|
|
57
|
-
* Generator methods returns these resource URLs for a given entity type name.
|
|
58
|
-
* If the resources for an entity type name are not know, it generates
|
|
59
|
-
* and caches a resource name for future use
|
|
60
|
-
*/
|
|
61
|
-
protected knownHttpResourceUrls: EntityHttpResourceUrls;
|
|
62
|
-
constructor(pluralizer: Pluralizer);
|
|
63
|
-
/**
|
|
64
|
-
* Get or generate the entity and collection resource URLs for the given entity type name
|
|
65
|
-
* @param entityName {string} Name of the entity type, e.g, 'Hero'
|
|
66
|
-
* @param root {string} Root path to the resource, e.g., 'some-api`
|
|
67
|
-
*/
|
|
68
|
-
protected getResourceUrls(entityName: string, root: string, trailingSlashEndpoints?: boolean): HttpResourceUrls;
|
|
69
|
-
/**
|
|
70
|
-
* Create the path to a single entity resource
|
|
71
|
-
* @param entityName {string} Name of the entity type, e.g, 'Hero'
|
|
72
|
-
* @param root {string} Root path to the resource, e.g., 'some-api`
|
|
73
|
-
* @returns complete path to resource, e.g, 'some-api/hero'
|
|
74
|
-
*/
|
|
75
|
-
entityResource(entityName: string, root: string, trailingSlashEndpoints: boolean): string;
|
|
76
|
-
/**
|
|
77
|
-
* Create the path to a multiple entity (collection) resource
|
|
78
|
-
* @param entityName {string} Name of the entity type, e.g, 'Hero'
|
|
79
|
-
* @param root {string} Root path to the resource, e.g., 'some-api`
|
|
80
|
-
* @returns complete path to resource, e.g, 'some-api/heroes'
|
|
81
|
-
*/
|
|
82
|
-
collectionResource(entityName: string, root: string): string;
|
|
83
|
-
/**
|
|
84
|
-
* Register known single-entity and collection resource URLs for HTTP calls
|
|
85
|
-
* @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names
|
|
86
|
-
* Well-formed resource urls end in a '/';
|
|
87
|
-
* Note: this method does not ensure that resource urls are well-formed.
|
|
88
|
-
*/
|
|
89
|
-
registerHttpResourceUrls(entityHttpResourceUrls: EntityHttpResourceUrls): void;
|
|
90
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultHttpUrlGenerator, never>;
|
|
91
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DefaultHttpUrlGenerator>;
|
|
92
|
-
}
|
|
93
|
-
/** Remove leading & trailing spaces or slashes */
|
|
94
|
-
export declare function normalizeRoot(root: string): string;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { Update } from '@ngrx/entity';
|
|
3
|
-
/** A service that performs REST-like HTTP data operations for an entity collection */
|
|
4
|
-
export interface EntityCollectionDataService<T> {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
add(entity: T, httpOptions?: HttpOptions): Observable<T>;
|
|
7
|
-
delete(id: number | string, httpOptions?: HttpOptions): Observable<number | string>;
|
|
8
|
-
getAll(httpOptions?: HttpOptions): Observable<T[]>;
|
|
9
|
-
getById(id: any, httpOptions?: HttpOptions): Observable<T>;
|
|
10
|
-
getWithQuery(params: QueryParams | string, httpOptions?: HttpOptions): Observable<T[]>;
|
|
11
|
-
update(update: Update<T>, httpOptions?: HttpOptions): Observable<T>;
|
|
12
|
-
upsert(entity: T, httpOptions?: HttpOptions): Observable<T>;
|
|
13
|
-
}
|
|
14
|
-
export type HttpMethods = 'DELETE' | 'GET' | 'POST' | 'PUT';
|
|
15
|
-
export interface RequestData {
|
|
16
|
-
method: HttpMethods;
|
|
17
|
-
url: string;
|
|
18
|
-
data?: any;
|
|
19
|
-
options?: any;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* A key/value map of parameters to be turned into an HTTP query string
|
|
23
|
-
* Same as HttpClient's HttpParamsOptions which at the time of writing was
|
|
24
|
-
* NOT exported at package level
|
|
25
|
-
* https://github.com/angular/angular/issues/22013
|
|
26
|
-
*
|
|
27
|
-
* @deprecated Use HttpOptions instead. getWithQuery still accepts QueryParams as its
|
|
28
|
-
* first argument, but HttpOptions.httpParams uses Angular's own HttpParamsOptions which
|
|
29
|
-
* HttpClient accepts as an argument.
|
|
30
|
-
*/
|
|
31
|
-
export interface QueryParams {
|
|
32
|
-
[name: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Options that adhere to the constructor arguments for HttpParams and
|
|
36
|
-
* HttpHeaders.
|
|
37
|
-
*/
|
|
38
|
-
export interface HttpOptions {
|
|
39
|
-
httpParams?: HttpParams;
|
|
40
|
-
httpHeaders?: HttpHeaders;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Type that adheres to angular's Http Headers
|
|
44
|
-
*/
|
|
45
|
-
export type HttpHeaders = string | {
|
|
46
|
-
[p: string]: string | string[];
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Options that partially adheres to angular's HttpParamsOptions. The non-serializable encoder property is omitted.
|
|
50
|
-
*/
|
|
51
|
-
export declare interface HttpParams {
|
|
52
|
-
/**
|
|
53
|
-
* String representation of the HTTP parameters in URL-query-string format.
|
|
54
|
-
* Mutually exclusive with `fromObject`.
|
|
55
|
-
*/
|
|
56
|
-
fromString?: string;
|
|
57
|
-
/** Object map of the HTTP parameters. Mutually exclusive with `fromString`. */
|
|
58
|
-
fromObject?: {
|
|
59
|
-
[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { DataServiceError, EntityActionDataServiceError } from './data-service-error';
|
|
3
|
-
import { EntityAction } from '../actions/entity-action';
|
|
4
|
-
import { EntityActionFactory } from '../actions/entity-action-factory';
|
|
5
|
-
import { Logger } from '../utils/interfaces';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
/**
|
|
8
|
-
* Handling of responses from persistence operation
|
|
9
|
-
*/
|
|
10
|
-
export declare abstract class PersistenceResultHandler {
|
|
11
|
-
/** Handle successful result of persistence operation for an action */
|
|
12
|
-
abstract handleSuccess(originalAction: EntityAction): (data: any) => Action;
|
|
13
|
-
/** Handle error result of persistence operation for an action */
|
|
14
|
-
abstract handleError(originalAction: EntityAction): (error: DataServiceError | Error) => EntityAction<EntityActionDataServiceError>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Default handling of responses from persistence operation,
|
|
18
|
-
* specifically an EntityDataService
|
|
19
|
-
*/
|
|
20
|
-
export declare class DefaultPersistenceResultHandler implements PersistenceResultHandler {
|
|
21
|
-
private logger;
|
|
22
|
-
private entityActionFactory;
|
|
23
|
-
constructor(logger: Logger, entityActionFactory: EntityActionFactory);
|
|
24
|
-
/** Handle successful result of persistence operation on an EntityAction */
|
|
25
|
-
handleSuccess(originalAction: EntityAction): (data: any) => Action;
|
|
26
|
-
/** Handle error result of persistence operation on an EntityAction */
|
|
27
|
-
handleError(originalAction: EntityAction): (error: DataServiceError | Error) => EntityAction<EntityActionDataServiceError>;
|
|
28
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultPersistenceResultHandler, never>;
|
|
29
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<DefaultPersistenceResultHandler>;
|
|
30
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Action, Store } from '@ngrx/store';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { CorrelationIdGenerator } from '../utils/correlation-id-generator';
|
|
4
|
-
import { EntityActionOptions } from '../actions/entity-action';
|
|
5
|
-
import { EntityCache } from '../reducers/entity-cache';
|
|
6
|
-
import { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';
|
|
7
|
-
import { MergeStrategy } from '../actions/merge-strategy';
|
|
8
|
-
import { ChangeSet, ChangeSetItem } from '../actions/entity-cache-change-set';
|
|
9
|
-
import { EntityCacheQuerySet } from '../actions/entity-cache-action';
|
|
10
|
-
import * as i0 from "@angular/core";
|
|
11
|
-
/**
|
|
12
|
-
* Dispatches Entity Cache actions to the EntityCache reducer
|
|
13
|
-
*/
|
|
14
|
-
export declare class EntityCacheDispatcher {
|
|
15
|
-
/** Generates correlation ids for query and save methods */
|
|
16
|
-
private correlationIdGenerator;
|
|
17
|
-
/**
|
|
18
|
-
* Dispatcher options configure dispatcher behavior such as
|
|
19
|
-
* whether add is optimistic or pessimistic by default.
|
|
20
|
-
*/
|
|
21
|
-
private defaultDispatcherOptions;
|
|
22
|
-
/** The store, scoped to the EntityCache */
|
|
23
|
-
private store;
|
|
24
|
-
/**
|
|
25
|
-
* Actions scanned by the store after it processed them with reducers.
|
|
26
|
-
* A replay observable of the most recent action reduced by the store.
|
|
27
|
-
*/
|
|
28
|
-
reducedActions$: Observable<Action>;
|
|
29
|
-
private raSubscription;
|
|
30
|
-
constructor(
|
|
31
|
-
/** Generates correlation ids for query and save methods */
|
|
32
|
-
correlationIdGenerator: CorrelationIdGenerator,
|
|
33
|
-
/**
|
|
34
|
-
* Dispatcher options configure dispatcher behavior such as
|
|
35
|
-
* whether add is optimistic or pessimistic by default.
|
|
36
|
-
*/
|
|
37
|
-
defaultDispatcherOptions: EntityDispatcherDefaultOptions,
|
|
38
|
-
/** Actions scanned by the store after it processed them with reducers. */
|
|
39
|
-
scannedActions$: Observable<Action>,
|
|
40
|
-
/** The store, scoped to the EntityCache */
|
|
41
|
-
store: Store<EntityCache>);
|
|
42
|
-
/**
|
|
43
|
-
* Dispatch an Action to the store.
|
|
44
|
-
* @param action the Action
|
|
45
|
-
* @returns the dispatched Action
|
|
46
|
-
*/
|
|
47
|
-
dispatch(action: Action): Action;
|
|
48
|
-
/**
|
|
49
|
-
* Dispatch action to cancel the saveEntities request with matching correlation id.
|
|
50
|
-
* @param correlationId The correlation id for the corresponding action
|
|
51
|
-
* @param [reason] explains why canceled and by whom.
|
|
52
|
-
* @param [entityNames] array of entity names so can turn off loading flag for their collections.
|
|
53
|
-
* @param [tag] tag to identify the operation from the app perspective.
|
|
54
|
-
*/
|
|
55
|
-
cancelSaveEntities(correlationId: any, reason?: string, entityNames?: string[], tag?: string): void;
|
|
56
|
-
/** Clear the named entity collections in cache
|
|
57
|
-
* @param [collections] Array of names of the collections to clear.
|
|
58
|
-
* If empty array, does nothing. If null/undefined/no array, clear all collections.
|
|
59
|
-
* @param [tag] tag to identify the operation from the app perspective.
|
|
60
|
-
*/
|
|
61
|
-
clearCollections(collections?: string[], tag?: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* Load multiple entity collections at the same time.
|
|
64
|
-
* before any selectors$ observables emit.
|
|
65
|
-
* @param collections The collections to load, typically the result of a query.
|
|
66
|
-
* @param [tag] tag to identify the operation from the app perspective.
|
|
67
|
-
* in the form of a map of entity collections.
|
|
68
|
-
*/
|
|
69
|
-
loadCollections(collections: EntityCacheQuerySet, tag?: string): void;
|
|
70
|
-
/**
|
|
71
|
-
* Merges entities from a query result
|
|
72
|
-
* that returned entities from multiple collections.
|
|
73
|
-
* Corresponding entity cache reducer should add and update all collections
|
|
74
|
-
* at the same time, before any selectors$ observables emit.
|
|
75
|
-
* @param querySet The result of the query in the form of a map of entity collections.
|
|
76
|
-
* These are the entity data to merge into the respective collections.
|
|
77
|
-
* @param mergeStrategy How to merge a queried entity when it is already in the collection.
|
|
78
|
-
* The default is MergeStrategy.PreserveChanges
|
|
79
|
-
* @param [tag] tag to identify the operation from the app perspective.
|
|
80
|
-
*/
|
|
81
|
-
mergeQuerySet(querySet: EntityCacheQuerySet, mergeStrategy?: MergeStrategy, tag?: string): void;
|
|
82
|
-
/**
|
|
83
|
-
* Create entity cache action for replacing the entire entity cache.
|
|
84
|
-
* Dangerous because brute force but useful as when re-hydrating an EntityCache
|
|
85
|
-
* from local browser storage when the application launches.
|
|
86
|
-
* @param cache New state of the entity cache
|
|
87
|
-
* @param [tag] tag to identify the operation from the app perspective.
|
|
88
|
-
*/
|
|
89
|
-
setEntityCache(cache: EntityCache, tag?: string): void;
|
|
90
|
-
/**
|
|
91
|
-
* Dispatch action to save multiple entity changes to remote storage.
|
|
92
|
-
* Relies on an Ngrx Effect such as EntityEffects.saveEntities$.
|
|
93
|
-
* Important: only call if your server supports the SaveEntities protocol
|
|
94
|
-
* through your EntityDataService.saveEntities method.
|
|
95
|
-
* @param changes Either the entities to save, as an array of {ChangeSetItem}, or
|
|
96
|
-
* a ChangeSet that holds such changes.
|
|
97
|
-
* @param url The server url which receives the save request
|
|
98
|
-
* @param [options] options such as tag, correlationId, isOptimistic, and mergeStrategy.
|
|
99
|
-
* These values are defaulted if not supplied.
|
|
100
|
-
* @returns A terminating Observable<ChangeSet> with data returned from the server
|
|
101
|
-
* after server reports successful save OR the save error.
|
|
102
|
-
* TODO: should return the matching entities from cache rather than the raw server data.
|
|
103
|
-
*/
|
|
104
|
-
saveEntities(changes: ChangeSetItem[] | ChangeSet, url: string, options?: EntityActionOptions): Observable<ChangeSet>;
|
|
105
|
-
/**
|
|
106
|
-
* Return Observable of data from the server-success SaveEntities action with
|
|
107
|
-
* the given Correlation Id, after that action was processed by the ngrx store.
|
|
108
|
-
* or else put the server error on the Observable error channel.
|
|
109
|
-
* @param crid The correlationId for both the save and response actions.
|
|
110
|
-
*/
|
|
111
|
-
private getSaveEntitiesResponseData$;
|
|
112
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheDispatcher, never>;
|
|
113
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheDispatcher>;
|
|
114
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
import { EntityActionOptions } from '../actions/entity-action';
|
|
3
|
-
import { QueryParams } from '../dataservices/interfaces';
|
|
4
|
-
/** Commands that update the remote server. */
|
|
5
|
-
export interface EntityServerCommands<T> {
|
|
6
|
-
/**
|
|
7
|
-
* Dispatch action to save a new entity to remote storage.
|
|
8
|
-
* @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
|
|
9
|
-
* must have a key if optimistic save.
|
|
10
|
-
* @returns A terminating Observable of the entity
|
|
11
|
-
* after server reports successful save or the save error.
|
|
12
|
-
*/
|
|
13
|
-
add(entity: Partial<T>, options?: EntityActionOptions & {
|
|
14
|
-
isOptimistic?: false;
|
|
15
|
-
}): Observable<T>;
|
|
16
|
-
add(entity: T, options: EntityActionOptions & {
|
|
17
|
-
isOptimistic: true;
|
|
18
|
-
}): Observable<T>;
|
|
19
|
-
add(entity: T, options?: EntityActionOptions): Observable<T>;
|
|
20
|
-
/**
|
|
21
|
-
* Dispatch action to cancel the persistence operation (query or save) with the given correlationId.
|
|
22
|
-
* @param correlationId The correlation id for the corresponding EntityAction
|
|
23
|
-
* @param [reason] explains why canceled and by whom.
|
|
24
|
-
* @param [options] options such as the tag
|
|
25
|
-
*/
|
|
26
|
-
cancel(correlationId: any, reason?: string, options?: EntityActionOptions): void;
|
|
27
|
-
/**
|
|
28
|
-
* Dispatch action to delete entity from remote storage by key.
|
|
29
|
-
* @param key The entity to delete
|
|
30
|
-
* @param [options] options that influence save and merge behavior
|
|
31
|
-
* @returns A terminating Observable of the deleted key
|
|
32
|
-
* after server reports successful save or the save error.
|
|
33
|
-
*/
|
|
34
|
-
delete(entity: T, options?: EntityActionOptions): Observable<number | string>;
|
|
35
|
-
/**
|
|
36
|
-
* Dispatch action to delete entity from remote storage by key.
|
|
37
|
-
* @param key The primary key of the entity to remove
|
|
38
|
-
* @param [options] options that influence save and merge behavior
|
|
39
|
-
* @returns Observable of the deleted key
|
|
40
|
-
* after server reports successful save or the save error.
|
|
41
|
-
*/
|
|
42
|
-
delete(key: number | string, options?: EntityActionOptions): Observable<number | string>;
|
|
43
|
-
/**
|
|
44
|
-
* Dispatch action to query remote storage for all entities and
|
|
45
|
-
* merge the queried entities into the cached collection.
|
|
46
|
-
* @param [options] options that influence merge behavior
|
|
47
|
-
* @returns A terminating Observable of the collection
|
|
48
|
-
* after server reports successful query or the query error.
|
|
49
|
-
* @see load()
|
|
50
|
-
*/
|
|
51
|
-
getAll(options?: EntityActionOptions): Observable<T[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Dispatch action to query remote storage for the entity with this primary key.
|
|
54
|
-
* If the server returns an entity,
|
|
55
|
-
* merge it into the cached collection.
|
|
56
|
-
* @param key The primary key of the entity to get.
|
|
57
|
-
* @param [options] options that influence merge behavior
|
|
58
|
-
* @returns A terminating Observable of the queried entities that are in the collection
|
|
59
|
-
* after server reports success or the query error.
|
|
60
|
-
*/
|
|
61
|
-
getByKey(key: any, options?: EntityActionOptions): Observable<T>;
|
|
62
|
-
/**
|
|
63
|
-
* Dispatch action to query remote storage for the entities that satisfy a query expressed
|
|
64
|
-
* with either a query parameter map or an HTTP URL query string,
|
|
65
|
-
* and merge the results into the cached collection.
|
|
66
|
-
* @param queryParams the query in a form understood by the server
|
|
67
|
-
* @param [options] options that influence merge behavior
|
|
68
|
-
* @returns A terminating Observable of the queried entities
|
|
69
|
-
* after server reports successful query or the query error.
|
|
70
|
-
*/
|
|
71
|
-
getWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
|
|
72
|
-
/**
|
|
73
|
-
* Dispatch action to query remote storage for all entities and
|
|
74
|
-
* completely replace the cached collection with the queried entities.
|
|
75
|
-
* @param [options] options that influence load behavior
|
|
76
|
-
* @returns A terminating Observable of the entities in the collection
|
|
77
|
-
* after server reports successful query or the query error.
|
|
78
|
-
* @see getAll
|
|
79
|
-
*/
|
|
80
|
-
load(options?: EntityActionOptions): Observable<T[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Dispatch action to query remote storage for the entities that satisfy a query expressed
|
|
83
|
-
* with either a query parameter map or an HTTP URL query string, and
|
|
84
|
-
* completely replace the cached collection with the queried entities.
|
|
85
|
-
* @param queryParams the query in a form understood by the server
|
|
86
|
-
* @param [options] options that influence load behavior
|
|
87
|
-
* @returns A terminating Observable of the entities in the collection
|
|
88
|
-
* after server reports successful query or the query error.
|
|
89
|
-
* @see getWithQuery
|
|
90
|
-
*/
|
|
91
|
-
loadWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
|
|
92
|
-
/**
|
|
93
|
-
* Dispatch action to save the updated entity (or partial entity) in remote storage.
|
|
94
|
-
* The update entity may be partial (but must have its key)
|
|
95
|
-
* in which case it patches the existing entity.
|
|
96
|
-
* @param entity update entity, which might be a partial of T but must at least have its key.
|
|
97
|
-
* @param [options] options that influence save and merge behavior
|
|
98
|
-
* @returns A terminating Observable of the updated entity
|
|
99
|
-
* after server reports successful save or the save error.
|
|
100
|
-
*/
|
|
101
|
-
update(entity: Partial<T>, options?: EntityActionOptions): Observable<T>;
|
|
102
|
-
/**
|
|
103
|
-
* Dispatch action to save a new or update an existing entity to remote storage.
|
|
104
|
-
* Only dispatch this action if your server supports upsert.
|
|
105
|
-
* @param entity entity to upsert, which may omit its key if pessimistic and the server creates the key;
|
|
106
|
-
* must have a key if optimistic save.
|
|
107
|
-
* @returns A terminating Observable of the entity
|
|
108
|
-
* after server reports successful save or the save error.
|
|
109
|
-
*/
|
|
110
|
-
upsert(entity: T, options?: EntityActionOptions): Observable<T>;
|
|
111
|
-
}
|
|
112
|
-
/*** A collection's cache-only commands, which do not update remote storage ***/
|
|
113
|
-
export interface EntityCacheCommands<T> {
|
|
114
|
-
/**
|
|
115
|
-
* Replace all entities in the cached collection.
|
|
116
|
-
* Does not save to remote storage.
|
|
117
|
-
* @param entities to add directly to cache.
|
|
118
|
-
* @param [options] options such as mergeStrategy
|
|
119
|
-
*/
|
|
120
|
-
addAllToCache(entities: T[], options?: EntityActionOptions): void;
|
|
121
|
-
/**
|
|
122
|
-
* Add a new entity directly to the cache.
|
|
123
|
-
* Does not save to remote storage.
|
|
124
|
-
* Ignored if an entity with the same primary key is already in cache.
|
|
125
|
-
* @param entity to add directly to cache.
|
|
126
|
-
* @param [options] options such as mergeStrategy
|
|
127
|
-
*/
|
|
128
|
-
addOneToCache(entity: T, options?: EntityActionOptions): void;
|
|
129
|
-
/**
|
|
130
|
-
* Add multiple new entities directly to the cache.
|
|
131
|
-
* Does not save to remote storage.
|
|
132
|
-
* Entities with primary keys already in cache are ignored.
|
|
133
|
-
* @param entities to add directly to cache.
|
|
134
|
-
* @param [options] options such as mergeStrategy
|
|
135
|
-
*/
|
|
136
|
-
addManyToCache(entities: T[], options?: EntityActionOptions): void;
|
|
137
|
-
/** Clear the cached entity collection */
|
|
138
|
-
clearCache(options?: EntityActionOptions): void;
|
|
139
|
-
/**
|
|
140
|
-
* Remove an entity directly from the cache.
|
|
141
|
-
* Does not delete that entity from remote storage.
|
|
142
|
-
* @param entity The entity to remove
|
|
143
|
-
* @param [options] options such as mergeStrategy
|
|
144
|
-
*/
|
|
145
|
-
removeOneFromCache(entity: T, options?: EntityActionOptions): void;
|
|
146
|
-
/**
|
|
147
|
-
* Remove an entity directly from the cache.
|
|
148
|
-
* Does not delete that entity from remote storage.
|
|
149
|
-
* @param key The primary key of the entity to remove
|
|
150
|
-
* @param [options] options such as mergeStrategy
|
|
151
|
-
*/
|
|
152
|
-
removeOneFromCache(key: number | string, options?: EntityActionOptions): void;
|
|
153
|
-
/**
|
|
154
|
-
* Remove multiple entities directly from the cache.
|
|
155
|
-
* Does not delete these entities from remote storage.
|
|
156
|
-
* @param entity The entities to remove
|
|
157
|
-
* @param [options] options such as mergeStrategy
|
|
158
|
-
*/
|
|
159
|
-
removeManyFromCache(entities: T[], options?: EntityActionOptions): void;
|
|
160
|
-
/**
|
|
161
|
-
* Remove multiple entities directly from the cache.
|
|
162
|
-
* Does not delete these entities from remote storage.
|
|
163
|
-
* @param keys The primary keys of the entities to remove
|
|
164
|
-
* @param [options] options such as mergeStrategy
|
|
165
|
-
*/
|
|
166
|
-
removeManyFromCache(keys: (number | string)[], options?: EntityActionOptions): void;
|
|
167
|
-
/**
|
|
168
|
-
* Update a cached entity directly.
|
|
169
|
-
* Does not update that entity in remote storage.
|
|
170
|
-
* Ignored if an entity with matching primary key is not in cache.
|
|
171
|
-
* The update entity may be partial (but must have its key)
|
|
172
|
-
* in which case it patches the existing entity.
|
|
173
|
-
* @param entity to update directly in cache.
|
|
174
|
-
* @param [options] options such as mergeStrategy
|
|
175
|
-
*/
|
|
176
|
-
updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
|
|
177
|
-
/**
|
|
178
|
-
* Update multiple cached entities directly.
|
|
179
|
-
* Does not update these entities in remote storage.
|
|
180
|
-
* Entities whose primary keys are not in cache are ignored.
|
|
181
|
-
* Update entities may be partial but must at least have their keys.
|
|
182
|
-
* such partial entities patch their cached counterparts.
|
|
183
|
-
* @param entities to update directly in cache.
|
|
184
|
-
* @param [options] options such as mergeStrategy
|
|
185
|
-
*/
|
|
186
|
-
updateManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
|
|
187
|
-
/**
|
|
188
|
-
* Insert or update a cached entity directly.
|
|
189
|
-
* Does not save to remote storage.
|
|
190
|
-
* Upsert entity might be a partial of T but must at least have its key.
|
|
191
|
-
* Pass the Update<T> structure as the payload.
|
|
192
|
-
* @param entity to upsert directly in cache.
|
|
193
|
-
* @param [options] options such as mergeStrategy
|
|
194
|
-
*/
|
|
195
|
-
upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
|
|
196
|
-
/**
|
|
197
|
-
* Insert or update multiple cached entities directly.
|
|
198
|
-
* Does not save to remote storage.
|
|
199
|
-
* Upsert entities might be partial but must at least have their keys.
|
|
200
|
-
* Pass an array of the Update<T> structure as the payload.
|
|
201
|
-
* @param entities to upsert directly in cache.
|
|
202
|
-
* @param [options] options such as mergeStrategy
|
|
203
|
-
*/
|
|
204
|
-
upsertManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
|
|
205
|
-
/**
|
|
206
|
-
* Set the pattern that the collection's filter applies
|
|
207
|
-
* when using the `filteredEntities` selector.
|
|
208
|
-
*/
|
|
209
|
-
setFilter(pattern: any, options?: EntityActionOptions): void;
|
|
210
|
-
/** Set the loaded flag */
|
|
211
|
-
setLoaded(isLoaded: boolean, options?: EntityActionOptions): void;
|
|
212
|
-
/** Set the loading flag */
|
|
213
|
-
setLoading(isLoading: boolean, options?: EntityActionOptions): void;
|
|
214
|
-
}
|
|
215
|
-
/** Commands that dispatch entity actions for a collection */
|
|
216
|
-
export interface EntityCommands<T> extends EntityServerCommands<T>, EntityCacheCommands<T> {
|
|
217
|
-
}
|