@ngrx/data 20.1.0 → 21.0.0-rc.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.
Files changed (101) hide show
  1. package/fesm2022/ngrx-data.mjs +86 -86
  2. package/package.json +8 -8
  3. package/schematics/ng-add/index.js +39 -42
  4. package/schematics/ng-add/index.js.map +1 -1
  5. package/schematics/ng-add/schema.js +0 -2
  6. package/schematics-core/index.js +24 -75
  7. package/schematics-core/index.js.map +1 -1
  8. package/schematics-core/utility/ast-utils.js +28 -44
  9. package/schematics-core/utility/ast-utils.js.map +1 -1
  10. package/schematics-core/utility/change.js +8 -15
  11. package/schematics-core/utility/change.js.map +1 -1
  12. package/schematics-core/utility/config.js +4 -8
  13. package/schematics-core/utility/config.js.map +1 -1
  14. package/schematics-core/utility/find-component.js +17 -22
  15. package/schematics-core/utility/find-component.js.map +1 -1
  16. package/schematics-core/utility/find-module.js +19 -24
  17. package/schematics-core/utility/find-module.js.map +1 -1
  18. package/schematics-core/utility/json-utilts.js +1 -4
  19. package/schematics-core/utility/json-utilts.js.map +1 -1
  20. package/schematics-core/utility/libs-version.js +1 -4
  21. package/schematics-core/utility/libs-version.js.map +1 -1
  22. package/schematics-core/utility/ngrx-utils.js +28 -36
  23. package/schematics-core/utility/ngrx-utils.js.map +1 -1
  24. package/schematics-core/utility/package.js +1 -4
  25. package/schematics-core/utility/package.js.map +1 -1
  26. package/schematics-core/utility/parse-name.js +5 -8
  27. package/schematics-core/utility/parse-name.js.map +1 -1
  28. package/schematics-core/utility/project.js +9 -15
  29. package/schematics-core/utility/project.js.map +1 -1
  30. package/schematics-core/utility/standalone.js +13 -18
  31. package/schematics-core/utility/standalone.js.map +1 -1
  32. package/schematics-core/utility/strings.js +9 -20
  33. package/schematics-core/utility/strings.js.map +1 -1
  34. package/schematics-core/utility/update.js +4 -7
  35. package/schematics-core/utility/update.js.map +1 -1
  36. package/schematics-core/utility/visitors.js +16 -30
  37. package/schematics-core/utility/visitors.js.map +1 -1
  38. package/types/ngrx-data.d.ts +3465 -0
  39. package/index.d.ts +0 -6
  40. package/public_api.d.ts +0 -1
  41. package/src/actions/entity-action-factory.d.ts +0 -38
  42. package/src/actions/entity-action-guard.d.ts +0 -33
  43. package/src/actions/entity-action-operators.d.ts +0 -30
  44. package/src/actions/entity-action.d.ts +0 -37
  45. package/src/actions/entity-cache-action.d.ts +0 -147
  46. package/src/actions/entity-cache-change-set.d.ts +0 -66
  47. package/src/actions/entity-op.d.ts +0 -70
  48. package/src/actions/merge-strategy.d.ts +0 -20
  49. package/src/actions/update-response-data.d.ts +0 -20
  50. package/src/dataservices/data-service-error.d.ts +0 -18
  51. package/src/dataservices/default-data-service-config.d.ts +0 -27
  52. package/src/dataservices/default-data.service.d.ts +0 -57
  53. package/src/dataservices/entity-cache-data.service.d.ts +0 -58
  54. package/src/dataservices/entity-data.service.d.ts +0 -48
  55. package/src/dataservices/http-url-generator.d.ts +0 -94
  56. package/src/dataservices/interfaces.d.ts +0 -61
  57. package/src/dataservices/persistence-result-handler.service.d.ts +0 -30
  58. package/src/dispatchers/entity-cache-dispatcher.d.ts +0 -114
  59. package/src/dispatchers/entity-commands.d.ts +0 -217
  60. package/src/dispatchers/entity-dispatcher-base.d.ts +0 -269
  61. package/src/dispatchers/entity-dispatcher-default-options.d.ts +0 -23
  62. package/src/dispatchers/entity-dispatcher-factory.d.ts +0 -46
  63. package/src/dispatchers/entity-dispatcher.d.ts +0 -58
  64. package/src/effects/entity-cache-effects.d.ts +0 -46
  65. package/src/effects/entity-effects-scheduler.d.ts +0 -4
  66. package/src/effects/entity-effects.d.ts +0 -55
  67. package/src/entity-data-config.d.ts +0 -15
  68. package/src/entity-data-without-effects.module.d.ts +0 -15
  69. package/src/entity-data.module.d.ts +0 -15
  70. package/src/entity-metadata/entity-definition.d.ts +0 -16
  71. package/src/entity-metadata/entity-definition.service.d.ts +0 -62
  72. package/src/entity-metadata/entity-filters.d.ts +0 -12
  73. package/src/entity-metadata/entity-metadata.d.ts +0 -19
  74. package/src/entity-services/entity-collection-service-base.d.ts +0 -299
  75. package/src/entity-services/entity-collection-service-elements-factory.d.ts +0 -28
  76. package/src/entity-services/entity-collection-service-factory.d.ts +0 -22
  77. package/src/entity-services/entity-collection-service.d.ts +0 -37
  78. package/src/entity-services/entity-services-base.d.ts +0 -79
  79. package/src/entity-services/entity-services-elements.d.ts +0 -41
  80. package/src/entity-services/entity-services.d.ts +0 -50
  81. package/src/index.d.ts +0 -65
  82. package/src/provide-entity-data.d.ts +0 -78
  83. package/src/reducers/constants.d.ts +0 -8
  84. package/src/reducers/entity-cache-reducer.d.ts +0 -50
  85. package/src/reducers/entity-cache.d.ts +0 -4
  86. package/src/reducers/entity-change-tracker-base.d.ts +0 -181
  87. package/src/reducers/entity-change-tracker.d.ts +0 -169
  88. package/src/reducers/entity-collection-creator.d.ts +0 -15
  89. package/src/reducers/entity-collection-reducer-methods.d.ts +0 -365
  90. package/src/reducers/entity-collection-reducer-registry.d.ts +0 -47
  91. package/src/reducers/entity-collection-reducer.d.ts +0 -14
  92. package/src/reducers/entity-collection.d.ts +0 -41
  93. package/src/selectors/entity-cache-selector.d.ts +0 -7
  94. package/src/selectors/entity-selectors$.d.ts +0 -63
  95. package/src/selectors/entity-selectors.d.ts +0 -117
  96. package/src/utils/correlation-id-generator.d.ts +0 -20
  97. package/src/utils/default-logger.d.ts +0 -9
  98. package/src/utils/default-pluralizer.d.ts +0 -18
  99. package/src/utils/guid-fns.d.ts +0 -24
  100. package/src/utils/interfaces.d.ts +0 -16
  101. package/src/utils/utilities.d.ts +0 -26
@@ -1,19 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { IdSelector, Comparer } from '@ngrx/entity';
3
- import { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher-default-options';
4
- import { EntityFilterFn } from './entity-filters';
5
- export declare const ENTITY_METADATA_TOKEN: InjectionToken<EntityMetadataMap>;
6
- /** Metadata that describe an entity type and its collection to @ngrx/data */
7
- export interface EntityMetadata<T = any, S extends object = {}> {
8
- entityName: string;
9
- entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;
10
- filterFn?: EntityFilterFn<T>;
11
- noChangeTracking?: boolean;
12
- selectId?: IdSelector<T>;
13
- sortComparer?: false | Comparer<T>;
14
- additionalCollectionState?: S;
15
- }
16
- /** Map entity-type name to its EntityMetadata */
17
- export interface EntityMetadataMap {
18
- [entityName: string]: Partial<EntityMetadata<any>>;
19
- }
@@ -1,299 +0,0 @@
1
- import { Action, Store } from '@ngrx/store';
2
- import { Dictionary, IdSelector, Update } from '@ngrx/entity';
3
- import { Observable } from 'rxjs';
4
- import { EntityAction, EntityActionOptions } from '../actions/entity-action';
5
- import { EntityActionGuard } from '../actions/entity-action-guard';
6
- import { EntityCollection, ChangeStateMap } from '../reducers/entity-collection';
7
- import { EntityDispatcher } from '../dispatchers/entity-dispatcher';
8
- import { EntityCollectionService } from './entity-collection-service';
9
- import { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';
10
- import { EntityOp } from '../actions/entity-op';
11
- import { EntitySelectors } from '../selectors/entity-selectors';
12
- import { EntitySelectors$ } from '../selectors/entity-selectors$';
13
- import { QueryParams } from '../dataservices/interfaces';
14
- /**
15
- * Base class for a concrete EntityCollectionService<T>.
16
- * Can be instantiated. Cannot be injected. Use EntityCollectionServiceFactory to create.
17
- * @param EntityCollectionServiceElements The ingredients for this service
18
- * as a source of supporting services for creating an EntityCollectionService<T> instance.
19
- */
20
- export declare class EntityCollectionServiceBase<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>> implements EntityCollectionService<T> {
21
- /** Name of the entity type of this collection service */
22
- readonly entityName: string;
23
- /** Dispatcher of EntityCommands (EntityActions) */
24
- readonly dispatcher: EntityDispatcher<T>;
25
- /** All selectors of entity collection properties */
26
- readonly selectors: EntitySelectors<T>;
27
- /** All selectors$ (observables of entity collection properties) */
28
- readonly selectors$: S$;
29
- constructor(
30
- /** Name of the entity type of this collection service */
31
- entityName: string,
32
- /** Creates the core elements of the EntityCollectionService for this entity type */
33
- serviceElementsFactory: EntityCollectionServiceElementsFactory);
34
- /**
35
- * Create an {EntityAction} for this entity type.
36
- * @param op {EntityOp} the entity operation
37
- * @param [data] the action data
38
- * @param [options] additional options
39
- * @returns the EntityAction
40
- */
41
- createEntityAction<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
42
- /**
43
- * Create an {EntityAction} for this entity type and
44
- * dispatch it immediately to the store.
45
- * @param op {EntityOp} the entity operation
46
- * @param [data] the action data
47
- * @param [options] additional options
48
- * @returns the dispatched EntityAction
49
- */
50
- createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
51
- /**
52
- * Dispatch an action of any type to the ngrx store.
53
- * @param action the Action
54
- * @returns the dispatched Action
55
- */
56
- dispatch(action: Action): Action;
57
- /** The NgRx Store for the {EntityCache} */
58
- get store(): Store<import("@ngrx/data").EntityCache>;
59
- /**
60
- * Utility class with methods to validate EntityAction payloads.
61
- */
62
- guard: EntityActionGuard<T>;
63
- /** Returns the primary key (id) of this entity */
64
- selectId: IdSelector<T>;
65
- /**
66
- * Convert an entity (or partial entity) into the `Update<T>` object
67
- * `update...` and `upsert...` methods take `Update<T>` args
68
- */
69
- toUpdate: (entity: Partial<T>) => Update<T>;
70
- /**
71
- * Dispatch action to save a new entity to remote storage.
72
- * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
73
- * must have a key if optimistic save.
74
- * @param [options] options that influence save and merge behavior
75
- * @returns Observable of the entity
76
- * after server reports successful save or the save error.
77
- */
78
- add(entity: Partial<T>, options: EntityActionOptions & {
79
- isOptimistic: false;
80
- }): Observable<T>;
81
- add(entity: T, options?: EntityActionOptions): Observable<T>;
82
- /**
83
- * Dispatch action to cancel the persistence operation (query or save) with the given correlationId.
84
- * @param correlationId The correlation id for the corresponding EntityAction
85
- * @param [reason] explains why canceled and by whom.
86
- * @param [options] options such as the tag and mergeStrategy
87
- */
88
- cancel(correlationId: any, reason?: string, options?: EntityActionOptions): void;
89
- /**
90
- * Dispatch action to delete entity from remote storage by key.
91
- * @param key The entity to delete
92
- * @param [options] options that influence save and merge behavior
93
- * @returns Observable of the deleted key
94
- * after server reports successful save or the save error.
95
- */
96
- delete(entity: T, options?: EntityActionOptions): Observable<number | string>;
97
- /**
98
- * Dispatch action to delete entity from remote storage by key.
99
- * @param key The primary key of the entity to remove
100
- * @param [options] options that influence save and merge behavior
101
- * @returns Observable of the deleted key
102
- * after server reports successful save or the save error.
103
- */
104
- delete(key: number | string, options?: EntityActionOptions): Observable<number | string>;
105
- /**
106
- * Dispatch action to query remote storage for all entities and
107
- * merge the queried entities into the cached collection.
108
- * @param [options] options that influence merge behavior
109
- * @returns Observable of the collection
110
- * after server reports successful query or the query error.
111
- * @see load()
112
- */
113
- getAll(options?: EntityActionOptions): Observable<T[]>;
114
- /**
115
- * Dispatch action to query remote storage for the entity with this primary key.
116
- * If the server returns an entity,
117
- * merge it into the cached collection.
118
- * @param key The primary key of the entity to get.
119
- * @param [options] options that influence merge behavior
120
- * @returns Observable of the queried entity that is in the collection
121
- * after server reports success or the query error.
122
- */
123
- getByKey(key: any, options?: EntityActionOptions): Observable<T>;
124
- /**
125
- * Dispatch action to query remote storage for the entities that satisfy a query expressed
126
- * with either a query parameter map or an HTTP URL query string,
127
- * and merge the results into the cached collection.
128
- * @param queryParams the query in a form understood by the server
129
- * @param [options] options that influence merge behavior
130
- * @returns Observable of the queried entities
131
- * after server reports successful query or the query error.
132
- */
133
- getWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
134
- /**
135
- * Dispatch action to query remote storage for all entities and
136
- * completely replace the cached collection with the queried entities.
137
- * @param [options] options that influence load behavior
138
- * @returns Observable of the collection
139
- * after server reports successful query or the query error.
140
- * @see getAll
141
- */
142
- load(options?: EntityActionOptions): Observable<T[]>;
143
- /**
144
- * Dispatch action to query remote storage for the entities that satisfy a query expressed
145
- * with either a query parameter map or an HTTP URL query string,
146
- * and completely replace the cached collection with the queried entities.
147
- * @param queryParams the query in a form understood by the server
148
- * @param [options] options that influence load behavior
149
- * @returns Observable of the queried entities
150
- * after server reports successful query or the query error.
151
- */
152
- loadWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
153
- /**
154
- * Dispatch action to save the updated entity (or partial entity) in remote storage.
155
- * The update entity may be partial (but must have its key)
156
- * in which case it patches the existing entity.
157
- * @param entity update entity, which might be a partial of T but must at least have its key.
158
- * @param [options] options that influence save and merge behavior
159
- * @returns Observable of the updated entity
160
- * after server reports successful save or the save error.
161
- */
162
- update(entity: Partial<T>, options?: EntityActionOptions): Observable<T>;
163
- /**
164
- * Dispatch action to save a new or existing entity to remote storage.
165
- * Call only if the server supports upsert.
166
- * @param entity entity to add or upsert.
167
- * It may omit its key if an add, and is pessimistic, and the server creates the key;
168
- * must have a key if optimistic save.
169
- * @param [options] options that influence save and merge behavior
170
- * @returns Observable of the entity
171
- * after server reports successful save or the save error.
172
- */
173
- upsert(entity: T, options?: EntityActionOptions): Observable<T>;
174
- /*** Cache-only operations that do not update remote storage ***/
175
- /**
176
- * Replace all entities in the cached collection.
177
- * Does not save to remote storage.
178
- * @param entities to add directly to cache.
179
- * @param [options] options such as mergeStrategy
180
- */
181
- addAllToCache(entities: T[], options?: EntityActionOptions): void;
182
- /**
183
- * Add a new entity directly to the cache.
184
- * Does not save to remote storage.
185
- * Ignored if an entity with the same primary key is already in cache.
186
- * @param entity to add directly to cache.
187
- * @param [options] options such as mergeStrategy
188
- */
189
- addOneToCache(entity: T, options?: EntityActionOptions): void;
190
- /**
191
- * Add multiple new entities directly to the cache.
192
- * Does not save to remote storage.
193
- * Entities with primary keys already in cache are ignored.
194
- * @param entities to add directly to cache.
195
- * @param [options] options such as mergeStrategy
196
- */
197
- addManyToCache(entities: T[], options?: EntityActionOptions): void;
198
- /** Clear the cached entity collection */
199
- clearCache(): void;
200
- /**
201
- * Remove an entity directly from the cache.
202
- * Does not delete that entity from remote storage.
203
- * @param entity The entity to remove
204
- * @param [options] options such as mergeStrategy
205
- */
206
- removeOneFromCache(entity: T, options?: EntityActionOptions): void;
207
- /**
208
- * Remove an entity directly from the cache.
209
- * Does not delete that entity from remote storage.
210
- * @param key The primary key of the entity to remove
211
- * @param [options] options such as mergeStrategy
212
- */
213
- removeOneFromCache(key: number | string, options?: EntityActionOptions): void;
214
- /**
215
- * Remove multiple entities directly from the cache.
216
- * Does not delete these entities from remote storage.
217
- * @param entity The entities to remove
218
- * @param [options] options such as mergeStrategy
219
- */
220
- removeManyFromCache(entities: T[], options?: EntityActionOptions): void;
221
- /**
222
- * Remove multiple entities directly from the cache.
223
- * Does not delete these entities from remote storage.
224
- * @param keys The primary keys of the entities to remove
225
- * @param [options] options such as mergeStrategy
226
- */
227
- removeManyFromCache(keys: (number | string)[], options?: EntityActionOptions): void;
228
- /**
229
- * Update a cached entity directly.
230
- * Does not update that entity in remote storage.
231
- * Ignored if an entity with matching primary key is not in cache.
232
- * The update entity may be partial (but must have its key)
233
- * in which case it patches the existing entity.
234
- * @param entity to update directly in cache.
235
- * @param [options] options such as mergeStrategy
236
- */
237
- updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
238
- /**
239
- * Update multiple cached entities directly.
240
- * Does not update these entities in remote storage.
241
- * Entities whose primary keys are not in cache are ignored.
242
- * Update entities may be partial but must at least have their keys.
243
- * such partial entities patch their cached counterparts.
244
- * @param entities to update directly in cache.
245
- * @param [options] options such as mergeStrategy
246
- */
247
- updateManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
248
- /**
249
- * Insert or update a cached entity directly.
250
- * Does not save to remote storage.
251
- * Upsert entity might be a partial of T but must at least have its key.
252
- * Pass the Update<T> structure as the payload.
253
- * @param entity to upsert directly in cache.
254
- * @param [options] options such as mergeStrategy
255
- */
256
- upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
257
- /**
258
- * Insert or update multiple cached entities directly.
259
- * Does not save to remote storage.
260
- * Upsert entities might be partial but must at least have their keys.
261
- * Pass an array of the Update<T> structure as the payload.
262
- * @param entities to upsert directly in cache.
263
- * @param [options] options such as mergeStrategy
264
- */
265
- upsertManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
266
- /**
267
- * Set the pattern that the collection's filter applies
268
- * when using the `filteredEntities` selector.
269
- */
270
- setFilter(pattern: any): void;
271
- /** Set the loaded flag */
272
- setLoaded(isLoaded: boolean): void;
273
- /** Set the loading flag */
274
- setLoading(isLoading: boolean): void;
275
- /** Observable of the collection as a whole */
276
- collection$: Observable<EntityCollection<T>> | Store<EntityCollection<T>>;
277
- /** Observable of count of entities in the cached collection. */
278
- count$: Observable<number> | Store<number>;
279
- /** Observable of all entities in the cached collection. */
280
- entities$: Observable<T[]> | Store<T[]>;
281
- /** Observable of actions related to this entity type. */
282
- entityActions$: Observable<EntityAction>;
283
- /** Observable of the map of entity keys to entities */
284
- entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;
285
- /** Observable of error actions related to this entity type. */
286
- errors$: Observable<EntityAction>;
287
- /** Observable of the filter pattern applied by the entity collection's filter function */
288
- filter$: Observable<any> | Store<any>;
289
- /** Observable of entities in the cached collection that pass the filter function */
290
- filteredEntities$: Observable<T[]> | Store<T[]>;
291
- /** Observable of the keys of the cached collection, in the collection's native sort order */
292
- keys$: Observable<string[] | number[]> | Store<string[] | number[]>;
293
- /** Observable true when the collection has been loaded */
294
- loaded$: Observable<boolean> | Store<boolean>;
295
- /** Observable true when a multi-entity query command is in progress. */
296
- loading$: Observable<boolean> | Store<boolean>;
297
- /** Original entity values for entities with unsaved changes */
298
- changeState$: Observable<ChangeStateMap<T>> | Store<ChangeStateMap<T>>;
299
- }
@@ -1,28 +0,0 @@
1
- import { EntityDispatcher } from '../dispatchers/entity-dispatcher';
2
- import { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';
3
- import { EntityDefinitionService } from '../entity-metadata/entity-definition.service';
4
- import { EntitySelectors, EntitySelectorsFactory } from '../selectors/entity-selectors';
5
- import { EntitySelectors$, EntitySelectors$Factory } from '../selectors/entity-selectors$';
6
- import * as i0 from "@angular/core";
7
- /** Core ingredients of an EntityCollectionService */
8
- export interface EntityCollectionServiceElements<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>> {
9
- readonly dispatcher: EntityDispatcher<T>;
10
- readonly entityName: string;
11
- readonly selectors: EntitySelectors<T>;
12
- readonly selectors$: S$;
13
- }
14
- /** Creates the core elements of the EntityCollectionService for an entity type. */
15
- export declare class EntityCollectionServiceElementsFactory {
16
- private entityDispatcherFactory;
17
- private entityDefinitionService;
18
- private entitySelectorsFactory;
19
- private entitySelectors$Factory;
20
- constructor(entityDispatcherFactory: EntityDispatcherFactory, entityDefinitionService: EntityDefinitionService, entitySelectorsFactory: EntitySelectorsFactory, entitySelectors$Factory: EntitySelectors$Factory);
21
- /**
22
- * Get the ingredients for making an EntityCollectionService for this entity type
23
- * @param entityName - name of the entity type
24
- */
25
- create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionServiceElements<T, S$>;
26
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionServiceElementsFactory, never>;
27
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionServiceElementsFactory>;
28
- }
@@ -1,22 +0,0 @@
1
- import { EntityCollectionService } from './entity-collection-service';
2
- import { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';
3
- import { EntitySelectors$ } from '../selectors/entity-selectors$';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * Creates EntityCollectionService instances for
7
- * a cached collection of T entities in the ngrx store.
8
- */
9
- export declare class EntityCollectionServiceFactory {
10
- /** Creates the core elements of the EntityCollectionService for an entity type. */
11
- entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory;
12
- constructor(
13
- /** Creates the core elements of the EntityCollectionService for an entity type. */
14
- entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory);
15
- /**
16
- * Create an EntityCollectionService for an entity type
17
- * @param entityName - name of the entity type
18
- */
19
- create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
20
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionServiceFactory, never>;
21
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionServiceFactory>;
22
- }
@@ -1,37 +0,0 @@
1
- import { EntityAction, EntityActionOptions } from '../actions/entity-action';
2
- import { EntityCommands } from '../dispatchers/entity-commands';
3
- import { EntityDispatcher } from '../dispatchers/entity-dispatcher';
4
- import { EntityOp } from '../actions/entity-op';
5
- import { EntitySelectors$ } from '../selectors/entity-selectors$';
6
- import { EntitySelectors } from '../selectors/entity-selectors';
7
- /**
8
- * A facade for managing
9
- * a cached collection of T entities in the ngrx store.
10
- */
11
- export interface EntityCollectionService<T> extends EntityCommands<T>, EntitySelectors$<T> {
12
- /**
13
- * Create an {EntityAction} for this entity type.
14
- * @param op {EntityOp} the entity operation
15
- * @param [data] the action data
16
- * @param [options] additional options
17
- * @returns the EntityAction
18
- */
19
- createEntityAction(op: EntityOp, payload?: any, options?: EntityActionOptions): EntityAction<T>;
20
- /**
21
- * Create an {EntityAction} for this entity type and
22
- * dispatch it immediately to the store.
23
- * @param op {EntityOp} the entity operation
24
- * @param [data] the action data
25
- * @param [options] additional options
26
- * @returns the dispatched EntityAction
27
- */
28
- createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
29
- /** Dispatcher of EntityCommands (EntityActions) */
30
- readonly dispatcher: EntityDispatcher<T>;
31
- /** Name of the entity type for this collection service */
32
- readonly entityName: string;
33
- /** All selector functions of the entity collection */
34
- readonly selectors: EntitySelectors<T>;
35
- /** All selectors$ (observables of the selectors of entity collection properties) */
36
- readonly selectors$: EntitySelectors$<T>;
37
- }
@@ -1,79 +0,0 @@
1
- import { Action, Store } from '@ngrx/store';
2
- import { Observable } from 'rxjs';
3
- import { EntityAction } from '../actions/entity-action';
4
- import { EntityCache } from '../reducers/entity-cache';
5
- import { EntityCollectionService } from './entity-collection-service';
6
- import { EntityCollectionServiceFactory } from './entity-collection-service-factory';
7
- import { EntityCollectionServiceMap, EntityServices } from './entity-services';
8
- import { EntitySelectors$ } from '../selectors/entity-selectors$';
9
- import { EntityServicesElements } from './entity-services-elements';
10
- import * as i0 from "@angular/core";
11
- /**
12
- * Base/default class of a central registry of EntityCollectionServices for all entity types.
13
- * Create your own subclass to add app-specific members for an improved developer experience.
14
- *
15
- * @usageNotes
16
- * ```ts
17
- * export class EntityServices extends EntityServicesBase {
18
- * constructor(entityServicesElements: EntityServicesElements) {
19
- * super(entityServicesElements);
20
- * }
21
- * // Extend with well-known, app entity collection services
22
- * // Convenience property to return a typed custom entity collection service
23
- * get companyService() {
24
- * return this.getEntityCollectionService<Model.Company>('Company') as CompanyService;
25
- * }
26
- * // Convenience dispatch methods
27
- * clearCompany(companyId: string) {
28
- * this.dispatch(new ClearCompanyAction(companyId));
29
- * }
30
- * }
31
- * ```
32
- */
33
- export declare class EntityServicesBase implements EntityServices {
34
- private entityServicesElements;
35
- constructor(entityServicesElements: EntityServicesElements);
36
- /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
37
- get entityActionErrors$(): Observable<EntityAction>;
38
- /** Observable of the entire entity cache */
39
- get entityCache$(): Observable<EntityCache> | Store<EntityCache>;
40
- /** Factory to create a default instance of an EntityCollectionService */
41
- get entityCollectionServiceFactory(): EntityCollectionServiceFactory;
42
- /**
43
- * Actions scanned by the store after it processed them with reducers.
44
- * A replay observable of the most recent action reduced by the store.
45
- */
46
- get reducedActions$(): Observable<Action>;
47
- /** The ngrx store, scoped to the EntityCache */
48
- protected get store(): Store<EntityCache>;
49
- /** Dispatch any action to the store */
50
- dispatch(action: Action): void;
51
- /** Registry of EntityCollectionService instances */
52
- private readonly EntityCollectionServices;
53
- /**
54
- * Create a new default instance of an EntityCollectionService.
55
- * Prefer getEntityCollectionService() unless you really want a new default instance.
56
- * This one will NOT be registered with EntityServices!
57
- * @param entityName {string} Name of the entity type of the service
58
- */
59
- protected createEntityCollectionService<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
60
- /** Get (or create) the singleton instance of an EntityCollectionService
61
- * @param entityName {string} Name of the entity type of the service
62
- */
63
- getEntityCollectionService<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
64
- /** Register an EntityCollectionService under its entity type name.
65
- * Will replace a pre-existing service for that type.
66
- * @param service {EntityCollectionService} The entity service
67
- * @param serviceName {string} optional service name to use instead of the service's entityName
68
- */
69
- registerEntityCollectionService<T>(service: EntityCollectionService<T>, serviceName?: string): void;
70
- /**
71
- * Register entity services for several entity types at once.
72
- * Will replace a pre-existing service for that type.
73
- * @param entityCollectionServices {EntityCollectionServiceMap | EntityCollectionService<any>[]}
74
- * EntityCollectionServices to register, either as a map or an array
75
- */
76
- registerEntityCollectionServices(entityCollectionServices: EntityCollectionServiceMap | EntityCollectionService<any>[]): void;
77
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityServicesBase, never>;
78
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityServicesBase>;
79
- }
@@ -1,41 +0,0 @@
1
- import { Action, Store } from '@ngrx/store';
2
- import { Observable } from 'rxjs';
3
- import { EntityAction } from '../actions/entity-action';
4
- import { EntityCache } from '../reducers/entity-cache';
5
- import { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';
6
- import { EntitySelectors$Factory } from '../selectors/entity-selectors$';
7
- import { EntityCollectionServiceFactory } from './entity-collection-service-factory';
8
- import * as i0 from "@angular/core";
9
- /** Core ingredients of an EntityServices class */
10
- export declare class EntityServicesElements {
11
- /**
12
- * Creates EntityCollectionService instances for
13
- * a cached collection of T entities in the ngrx store.
14
- */
15
- readonly entityCollectionServiceFactory: EntityCollectionServiceFactory;
16
- /** The ngrx store, scoped to the EntityCache */
17
- readonly store: Store<EntityCache>;
18
- constructor(
19
- /**
20
- * Creates EntityCollectionService instances for
21
- * a cached collection of T entities in the ngrx store.
22
- */
23
- entityCollectionServiceFactory: EntityCollectionServiceFactory,
24
- /** Creates EntityDispatchers for entity collections */
25
- entityDispatcherFactory: EntityDispatcherFactory,
26
- /** Creates observable EntitySelectors$ for entity collections. */
27
- entitySelectors$Factory: EntitySelectors$Factory,
28
- /** The ngrx store, scoped to the EntityCache */
29
- store: Store<EntityCache>);
30
- /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
31
- readonly entityActionErrors$: Observable<EntityAction>;
32
- /** Observable of the entire entity cache */
33
- readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;
34
- /**
35
- * Actions scanned by the store after it processed them with reducers.
36
- * A replay observable of the most recent action reduced by the store.
37
- */
38
- readonly reducedActions$: Observable<Action>;
39
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityServicesElements, never>;
40
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityServicesElements>;
41
- }
@@ -1,50 +0,0 @@
1
- import { Action, Store } from '@ngrx/store';
2
- import { Observable } from 'rxjs';
3
- import { EntityAction } from '../actions/entity-action';
4
- import { EntityCache } from '../reducers/entity-cache';
5
- import { EntityCollectionService } from './entity-collection-service';
6
- /**
7
- * Class-Interface for EntityCache and EntityCollection services.
8
- * Serves as an Angular provider token for this service class.
9
- * Includes a registry of EntityCollectionServices for all entity types.
10
- * Creates a new default EntityCollectionService for any entity type not in the registry.
11
- * Optionally register specialized EntityCollectionServices for individual types
12
- */
13
- export declare abstract class EntityServices {
14
- /** Dispatch any action to the store */
15
- abstract dispatch(action: Action): void;
16
- /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
17
- abstract readonly entityActionErrors$: Observable<EntityAction>;
18
- /** Observable of the entire entity cache */
19
- abstract readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;
20
- /** Get (or create) the singleton instance of an EntityCollectionService
21
- * @param entityName {string} Name of the entity type of the service
22
- */
23
- abstract getEntityCollectionService<T = any>(entityName: string): EntityCollectionService<T>;
24
- /**
25
- * Actions scanned by the store after it processed them with reducers.
26
- * A replay observable of the most recent Action (not just EntityAction) reduced by the store.
27
- */
28
- abstract readonly reducedActions$: Observable<Action>;
29
- /** Register an EntityCollectionService under its entity type name.
30
- * Will replace a pre-existing service for that type.
31
- * @param service {EntityCollectionService} The entity service
32
- */
33
- abstract registerEntityCollectionService<T>(service: EntityCollectionService<T>): void;
34
- /** Register entity services for several entity types at once.
35
- * Will replace a pre-existing service for that type.
36
- * @param entityCollectionServices Array of EntityCollectionServices to register
37
- */
38
- abstract registerEntityCollectionServices(entityCollectionServices: EntityCollectionService<any>[]): void;
39
- /** Register entity services for several entity types at once.
40
- * Will replace a pre-existing service for that type.
41
- * @param entityCollectionServiceMap Map of service-name to entity-collection-service
42
- */
43
- abstract registerEntityCollectionServices(entityCollectionServiceMap: EntityCollectionServiceMap): void;
44
- }
45
- /**
46
- * A map of service or entity names to their corresponding EntityCollectionServices.
47
- */
48
- export interface EntityCollectionServiceMap {
49
- [entityName: string]: EntityCollectionService<any>;
50
- }
package/src/index.d.ts DELETED
@@ -1,65 +0,0 @@
1
- export { EntityActionFactory } from './actions/entity-action-factory';
2
- export { EntityActionGuard } from './actions/entity-action-guard';
3
- export { ofEntityOp, ofEntityType } from './actions/entity-action-operators';
4
- export { EntityAction, EntityActionOptions, EntityActionPayload, } from './actions/entity-action';
5
- export { EntityCacheAction, EntityCacheQuerySet, ClearCollections, LoadCollections, MergeQuerySet, SetEntityCache, SaveEntities, SaveEntitiesCancel, SaveEntitiesCanceled, SaveEntitiesError, SaveEntitiesSuccess, } from './actions/entity-cache-action';
6
- export { ChangeSetOperation, ChangeSetAdd, ChangeSetDelete, ChangeSetUpdate, ChangeSetUpsert, ChangeSetItem, ChangeSet, ChangeSetItemFactory, changeSetItemFactory, excludeEmptyChangeSetItems, } from './actions/entity-cache-change-set';
7
- export { EntityOp, OP_SUCCESS, OP_ERROR, makeErrorOp, makeSuccessOp, } from './actions/entity-op';
8
- export { MergeStrategy } from './actions/merge-strategy';
9
- export { UpdateResponseData } from './actions/update-response-data';
10
- export { DataServiceError } from './dataservices/data-service-error';
11
- export { EntityActionDataServiceError } from './dataservices/data-service-error';
12
- export { DefaultDataServiceConfig } from './dataservices/default-data-service-config';
13
- export { DefaultDataService } from './dataservices/default-data.service';
14
- export { DefaultDataServiceFactory } from './dataservices/default-data.service';
15
- export { EntityCacheDataService } from './dataservices/entity-cache-data.service';
16
- export { EntityDataService } from './dataservices/entity-data.service';
17
- export { EntityHttpResourceUrls } from './dataservices/http-url-generator';
18
- export { HttpResourceUrls } from './dataservices/http-url-generator';
19
- export { HttpUrlGenerator } from './dataservices/http-url-generator';
20
- export { DefaultHttpUrlGenerator } from './dataservices/http-url-generator';
21
- export { normalizeRoot } from './dataservices/http-url-generator';
22
- export { EntityCollectionDataService, HttpMethods, HttpOptions, RequestData, QueryParams, } from './dataservices/interfaces';
23
- export { PersistenceResultHandler, DefaultPersistenceResultHandler, } from './dataservices/persistence-result-handler.service';
24
- export { EntityCacheDispatcher } from './dispatchers/entity-cache-dispatcher';
25
- export { EntityServerCommands, EntityCacheCommands, EntityCommands, } from './dispatchers/entity-commands';
26
- export { EntityDispatcherBase } from './dispatchers/entity-dispatcher-base';
27
- export { EntityDispatcherDefaultOptions } from './dispatchers/entity-dispatcher-default-options';
28
- export { EntityDispatcherFactory } from './dispatchers/entity-dispatcher-factory';
29
- export { EntityDispatcher, PersistanceCanceled, } from './dispatchers/entity-dispatcher';
30
- export { EntityCacheEffects } from './effects/entity-cache-effects';
31
- export { persistOps, EntityEffects } from './effects/entity-effects';
32
- export { EntityDefinitions, EntityDefinitionService, } from './entity-metadata/entity-definition.service';
33
- export { EntityDefinition, createEntityDefinition, } from './entity-metadata/entity-definition';
34
- export { EntityFilterFn, PropsFilterFnFactory, } from './entity-metadata/entity-filters';
35
- export { ENTITY_METADATA_TOKEN, EntityMetadata, EntityMetadataMap, } from './entity-metadata/entity-metadata';
36
- export { EntityCollectionServiceBase } from './entity-services/entity-collection-service-base';
37
- export { EntityCollectionServiceElements, EntityCollectionServiceElementsFactory, } from './entity-services/entity-collection-service-elements-factory';
38
- export { EntityCollectionServiceFactory } from './entity-services/entity-collection-service-factory';
39
- export { EntityCollectionService } from './entity-services/entity-collection-service';
40
- export { EntityServicesBase } from './entity-services/entity-services-base';
41
- export { EntityServicesElements } from './entity-services/entity-services-elements';
42
- export { EntityServices, EntityCollectionServiceMap, } from './entity-services/entity-services';
43
- export { ENTITY_CACHE_NAME, ENTITY_CACHE_NAME_TOKEN, ENTITY_CACHE_META_REDUCERS, ENTITY_COLLECTION_META_REDUCERS, INITIAL_ENTITY_CACHE_STATE, } from './reducers/constants';
44
- export { EntityCacheReducerFactory } from './reducers/entity-cache-reducer';
45
- export { EntityCache } from './reducers/entity-cache';
46
- export { EntityChangeTrackerBase } from './reducers/entity-change-tracker-base';
47
- export { EntityChangeTracker } from './reducers/entity-change-tracker';
48
- export { EntityCollectionCreator, createEmptyEntityCollection, } from './reducers/entity-collection-creator';
49
- export { EntityCollectionReducerMethodMap, EntityCollectionReducerMethods, EntityCollectionReducerMethodsFactory, } from './reducers/entity-collection-reducer-methods';
50
- export { EntityCollectionReducers, EntityCollectionReducerRegistry, } from './reducers/entity-collection-reducer-registry';
51
- export { EntityCollectionReducer, EntityCollectionReducerFactory, } from './reducers/entity-collection-reducer';
52
- export { ChangeType, ChangeState, ChangeStateMap, EntityCollection, } from './reducers/entity-collection';
53
- export { ENTITY_CACHE_SELECTOR_TOKEN, entityCacheSelectorProvider, EntityCacheSelector, createEntityCacheSelector, } from './selectors/entity-cache-selector';
54
- export { CollectionSelectors, EntitySelectors, EntitySelectorsFactory, } from './selectors/entity-selectors';
55
- export { EntitySelectors$, EntitySelectors$Factory, } from './selectors/entity-selectors$';
56
- export { CorrelationIdGenerator } from './utils/correlation-id-generator';
57
- export { DefaultLogger } from './utils/default-logger';
58
- export { DefaultPluralizer } from './utils/default-pluralizer';
59
- export { getGuid, getGuidComb, guidComparer } from './utils/guid-fns';
60
- export { Logger, EntityPluralNames, PLURAL_NAMES_TOKEN, Pluralizer, } from './utils/interfaces';
61
- export { defaultSelectId, flattenArgs, toUpdateFactory, } from './utils/utilities';
62
- export { EntityDataModuleConfig } from './entity-data-config';
63
- export { EntityDataModuleWithoutEffects } from './entity-data-without-effects.module';
64
- export { EntityDataModule } from './entity-data.module';
65
- export { provideEntityData, withEffects } from './provide-entity-data';