@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.
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
@@ -0,0 +1,3465 @@
1
+ import * as _ngrx_store from '@ngrx/store';
2
+ import { Action, Store, MemoizedSelector, Selector, MetaReducer, ActionReducer } from '@ngrx/store';
3
+ import { Observable, OperatorFunction, SchedulerLike } from 'rxjs';
4
+ import { Update, IdSelector, EntityState, Dictionary, Comparer, EntityAdapter } from '@ngrx/entity';
5
+ import * as i0 from '@angular/core';
6
+ import { InjectionToken, FactoryProvider, OnDestroy, ModuleWithProviders, Provider, EnvironmentProviders } from '@angular/core';
7
+ import { HttpClient } from '@angular/common/http';
8
+ import { Actions } from '@ngrx/effects';
9
+ import * as _ngrx_data from '@ngrx/data';
10
+
11
+ /** General purpose entity action operations, good for any entity type */
12
+ declare enum EntityOp {
13
+ CANCEL_PERSIST = "@ngrx/data/cancel-persist",
14
+ CANCELED_PERSIST = "@ngrx/data/canceled-persist",
15
+ QUERY_ALL = "@ngrx/data/query-all",
16
+ QUERY_ALL_SUCCESS = "@ngrx/data/query-all/success",
17
+ QUERY_ALL_ERROR = "@ngrx/data/query-all/error",
18
+ QUERY_LOAD = "@ngrx/data/query-load",
19
+ QUERY_LOAD_SUCCESS = "@ngrx/data/query-load/success",
20
+ QUERY_LOAD_ERROR = "@ngrx/data/query-load/error",
21
+ QUERY_MANY = "@ngrx/data/query-many",
22
+ QUERY_MANY_SUCCESS = "@ngrx/data/query-many/success",
23
+ QUERY_MANY_ERROR = "@ngrx/data/query-many/error",
24
+ QUERY_BY_KEY = "@ngrx/data/query-by-key",
25
+ QUERY_BY_KEY_SUCCESS = "@ngrx/data/query-by-key/success",
26
+ QUERY_BY_KEY_ERROR = "@ngrx/data/query-by-key/error",
27
+ SAVE_ADD_MANY = "@ngrx/data/save/add-many",
28
+ SAVE_ADD_MANY_ERROR = "@ngrx/data/save/add-many/error",
29
+ SAVE_ADD_MANY_SUCCESS = "@ngrx/data/save/add-many/success",
30
+ SAVE_ADD_ONE = "@ngrx/data/save/add-one",
31
+ SAVE_ADD_ONE_ERROR = "@ngrx/data/save/add-one/error",
32
+ SAVE_ADD_ONE_SUCCESS = "@ngrx/data/save/add-one/success",
33
+ SAVE_DELETE_MANY = "@ngrx/data/save/delete-many",
34
+ SAVE_DELETE_MANY_SUCCESS = "@ngrx/data/save/delete-many/success",
35
+ SAVE_DELETE_MANY_ERROR = "@ngrx/data/save/delete-many/error",
36
+ SAVE_DELETE_ONE = "@ngrx/data/save/delete-one",
37
+ SAVE_DELETE_ONE_SUCCESS = "@ngrx/data/save/delete-one/success",
38
+ SAVE_DELETE_ONE_ERROR = "@ngrx/data/save/delete-one/error",
39
+ SAVE_UPDATE_MANY = "@ngrx/data/save/update-many",
40
+ SAVE_UPDATE_MANY_SUCCESS = "@ngrx/data/save/update-many/success",
41
+ SAVE_UPDATE_MANY_ERROR = "@ngrx/data/save/update-many/error",
42
+ SAVE_UPDATE_ONE = "@ngrx/data/save/update-one",
43
+ SAVE_UPDATE_ONE_SUCCESS = "@ngrx/data/save/update-one/success",
44
+ SAVE_UPDATE_ONE_ERROR = "@ngrx/data/save/update-one/error",
45
+ SAVE_UPSERT_MANY = "@ngrx/data/save/upsert-many",
46
+ SAVE_UPSERT_MANY_SUCCESS = "@ngrx/data/save/upsert-many/success",
47
+ SAVE_UPSERT_MANY_ERROR = "@ngrx/data/save/upsert-many/error",
48
+ SAVE_UPSERT_ONE = "@ngrx/data/save/upsert-one",
49
+ SAVE_UPSERT_ONE_SUCCESS = "@ngrx/data/save/upsert-one/success",
50
+ SAVE_UPSERT_ONE_ERROR = "@ngrx/data/save/upsert-one/error",
51
+ ADD_ALL = "@ngrx/data/add-all",
52
+ ADD_MANY = "@ngrx/data/add-many",
53
+ ADD_ONE = "@ngrx/data/add-one",
54
+ REMOVE_ALL = "@ngrx/data/remove-all",
55
+ REMOVE_MANY = "@ngrx/data/remove-many",
56
+ REMOVE_ONE = "@ngrx/data/remove-one",
57
+ UPDATE_MANY = "@ngrx/data/update-many",
58
+ UPDATE_ONE = "@ngrx/data/update-one",
59
+ UPSERT_MANY = "@ngrx/data/upsert-many",
60
+ UPSERT_ONE = "@ngrx/data/upsert-one",
61
+ COMMIT_ALL = "@ngrx/data/commit-all",
62
+ COMMIT_MANY = "@ngrx/data/commit-many",
63
+ COMMIT_ONE = "@ngrx/data/commit-one",
64
+ UNDO_ALL = "@ngrx/data/undo-all",
65
+ UNDO_MANY = "@ngrx/data/undo-many",
66
+ UNDO_ONE = "@ngrx/data/undo-one",
67
+ SET_CHANGE_STATE = "@ngrx/data/set-change-state",
68
+ SET_COLLECTION = "@ngrx/data/set-collection",
69
+ SET_FILTER = "@ngrx/data/set-filter",
70
+ SET_LOADED = "@ngrx/data/set-loaded",
71
+ SET_LOADING = "@ngrx/data/set-loading"
72
+ }
73
+ /** "Success" suffix appended to EntityOps that are successful.*/
74
+ declare const OP_SUCCESS = "/success";
75
+ /** "Error" suffix appended to EntityOps that have failed.*/
76
+ declare const OP_ERROR = "/error";
77
+ /** Make the error EntityOp corresponding to the given EntityOp */
78
+ declare function makeErrorOp(op: EntityOp): EntityOp;
79
+ /** Make the success EntityOp corresponding to the given EntityOp */
80
+ declare function makeSuccessOp(op: EntityOp): EntityOp;
81
+
82
+ /** How to merge an entity, after query or save, when the corresponding entity in the collection has unsaved changes. */
83
+ declare enum MergeStrategy {
84
+ /**
85
+ * Update the collection entities and ignore all change tracking for this operation.
86
+ * Each entity's `changeState` is untouched.
87
+ */
88
+ IgnoreChanges = 0,
89
+ /**
90
+ * Updates current values for unchanged entities.
91
+ * For each changed entity it preserves the current value and overwrites the `originalValue` with the merge entity.
92
+ * This is the query-success default.
93
+ */
94
+ PreserveChanges = 1,
95
+ /**
96
+ * Replace the current collection entities.
97
+ * For each merged entity it discards the `changeState` and sets the `changeType` to "unchanged".
98
+ * This is the save-success default.
99
+ */
100
+ OverwriteChanges = 2
101
+ }
102
+
103
+ /** A service that performs REST-like HTTP data operations for an entity collection */
104
+ interface EntityCollectionDataService<T> {
105
+ readonly name: string;
106
+ add(entity: T, httpOptions?: HttpOptions): Observable<T>;
107
+ delete(id: number | string, httpOptions?: HttpOptions): Observable<number | string>;
108
+ getAll(httpOptions?: HttpOptions): Observable<T[]>;
109
+ getById(id: any, httpOptions?: HttpOptions): Observable<T>;
110
+ getWithQuery(params: QueryParams | string, httpOptions?: HttpOptions): Observable<T[]>;
111
+ update(update: Update<T>, httpOptions?: HttpOptions): Observable<T>;
112
+ upsert(entity: T, httpOptions?: HttpOptions): Observable<T>;
113
+ }
114
+ type HttpMethods = 'DELETE' | 'GET' | 'POST' | 'PUT';
115
+ interface RequestData {
116
+ method: HttpMethods;
117
+ url: string;
118
+ data?: any;
119
+ options?: any;
120
+ }
121
+ /**
122
+ * A key/value map of parameters to be turned into an HTTP query string
123
+ * Same as HttpClient's HttpParamsOptions which at the time of writing was
124
+ * NOT exported at package level
125
+ * https://github.com/angular/angular/issues/22013
126
+ *
127
+ * @deprecated Use HttpOptions instead. getWithQuery still accepts QueryParams as its
128
+ * first argument, but HttpOptions.httpParams uses Angular's own HttpParamsOptions which
129
+ * HttpClient accepts as an argument.
130
+ */
131
+ interface QueryParams {
132
+ [name: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
133
+ }
134
+ /**
135
+ * Options that adhere to the constructor arguments for HttpParams and
136
+ * HttpHeaders.
137
+ */
138
+ interface HttpOptions {
139
+ httpParams?: HttpParams;
140
+ httpHeaders?: HttpHeaders;
141
+ }
142
+ /**
143
+ * Type that adheres to angular's Http Headers
144
+ */
145
+ type HttpHeaders = string | {
146
+ [p: string]: string | string[];
147
+ };
148
+ /**
149
+ * Options that partially adheres to angular's HttpParamsOptions. The non-serializable encoder property is omitted.
150
+ */
151
+ declare interface HttpParams {
152
+ /**
153
+ * String representation of the HTTP parameters in URL-query-string format.
154
+ * Mutually exclusive with `fromObject`.
155
+ */
156
+ fromString?: string;
157
+ /** Object map of the HTTP parameters. Mutually exclusive with `fromString`. */
158
+ fromObject?: {
159
+ [param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>;
160
+ };
161
+ }
162
+
163
+ /** Action concerning an entity collection. */
164
+ interface EntityAction<P = any> extends Action {
165
+ readonly type: string;
166
+ readonly payload: EntityActionPayload<P>;
167
+ }
168
+ /** Options of an EntityAction */
169
+ interface EntityActionOptions {
170
+ /** Correlate related EntityActions, particularly related saves. Must be serializable. */
171
+ readonly correlationId?: any;
172
+ /** True if should perform action optimistically (before server responds) */
173
+ readonly isOptimistic?: boolean;
174
+ readonly mergeStrategy?: MergeStrategy;
175
+ /** The tag to use in the action's type. The entityName if no tag specified. */
176
+ readonly tag?: string;
177
+ /** Options that will be passed to the dataService http request. Allows setting of Query Parameters and Headers */
178
+ readonly httpOptions?: HttpOptions;
179
+ /**
180
+ * The action was determined (usually by a reducer) to be in error.
181
+ * Downstream effects should not process but rather treat it as an error.
182
+ */
183
+ error?: Error;
184
+ /**
185
+ * Downstream effects should skip processing this action but should return
186
+ * an innocuous Observable<Action> of success.
187
+ */
188
+ skip?: boolean;
189
+ }
190
+ /** Payload of an EntityAction */
191
+ interface EntityActionPayload<P = any> extends EntityActionOptions {
192
+ readonly entityName: string;
193
+ readonly entityOp: EntityOp;
194
+ readonly data?: P;
195
+ }
196
+
197
+ declare class EntityActionFactory {
198
+ /**
199
+ * Create an EntityAction to perform an operation (op) for a particular entity type
200
+ * (entityName) with optional data and other optional flags
201
+ * @param entityName Name of the entity type
202
+ * @param entityOp Operation to perform (EntityOp)
203
+ * @param [data] data for the operation
204
+ * @param [options] additional options
205
+ */
206
+ create<P = any>(entityName: string, entityOp: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
207
+ /**
208
+ * Create an EntityAction to perform an operation (op) for a particular entity type
209
+ * (entityName) with optional data and other optional flags
210
+ * @param payload Defines the EntityAction and its options
211
+ */
212
+ create<P = any>(payload: EntityActionPayload<P>): EntityAction<P>;
213
+ /**
214
+ * Create an EntityAction to perform an operation (op) for a particular entity type
215
+ * (entityName) with optional data and other optional flags
216
+ * @param payload Defines the EntityAction and its options
217
+ */
218
+ protected createCore<P = any>(payload: EntityActionPayload<P>): {
219
+ type: string;
220
+ payload: EntityActionPayload<P>;
221
+ };
222
+ /**
223
+ * Create an EntityAction from another EntityAction, replacing properties with those from newPayload;
224
+ * @param from Source action that is the base for the new action
225
+ * @param newProperties New EntityAction properties that replace the source action properties
226
+ */
227
+ createFromAction<P = any>(from: EntityAction, newProperties: Partial<EntityActionPayload<P>>): EntityAction<P>;
228
+ formatActionType(op: string, tag: string): string;
229
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityActionFactory, never>;
230
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityActionFactory>;
231
+ }
232
+
233
+ /**
234
+ * Data returned in an EntityAction from the EntityEffects for SAVE_UPDATE_ONE_SUCCESS.
235
+ * Effectively extends Update<T> with a 'changed' flag.
236
+ * The is true if the server sent back changes to the entity data after update.
237
+ * Such changes must be in the entity data in changes property.
238
+ * Default is false (server did not return entity data; assume it changed nothing).
239
+ * See EntityEffects.
240
+ */
241
+ interface UpdateResponseData<T> {
242
+ /** Original key (id) of the entity */
243
+ id: number | string;
244
+ /** Entity update data. Should include the key (original or changed) */
245
+ changes: Partial<T>;
246
+ /**
247
+ * Whether the server made additional changes after processing the update.
248
+ * Such additional changes should be in the 'changes' object.
249
+ * Default is false
250
+ */
251
+ changed?: boolean;
252
+ }
253
+
254
+ /**
255
+ * Guard methods that ensure EntityAction payload is as expected.
256
+ * Each method returns that payload if it passes the guard or
257
+ * throws an error.
258
+ */
259
+ declare class EntityActionGuard<T> {
260
+ private entityName;
261
+ private selectId;
262
+ constructor(entityName: string, selectId: IdSelector<T>);
263
+ /** Throw if the action payload is not an entity with a valid key */
264
+ mustBeEntity(action: EntityAction<T>): T;
265
+ /** Throw if the action payload is not an array of entities with valid keys */
266
+ mustBeEntities(action: EntityAction<T[]>): T[];
267
+ /** Throw if the action payload is not a single, valid key */
268
+ mustBeKey(action: EntityAction<string | number>): string | number | never;
269
+ /** Throw if the action payload is not an array of valid keys */
270
+ mustBeKeys(action: EntityAction<(string | number)[]>): (string | number)[];
271
+ /** Throw if the action payload is not an update with a valid key (id) */
272
+ mustBeUpdate(action: EntityAction<Update<T>>): Update<T>;
273
+ /** Throw if the action payload is not an array of updates with valid keys (ids) */
274
+ mustBeUpdates(action: EntityAction<Update<T>[]>): Update<T>[];
275
+ /** Throw if the action payload is not an update response with a valid key (id) */
276
+ mustBeUpdateResponse(action: EntityAction<UpdateResponseData<T>>): UpdateResponseData<T>;
277
+ /** Throw if the action payload is not an array of update responses with valid keys (ids) */
278
+ mustBeUpdateResponses(action: EntityAction<UpdateResponseData<T>[]>): UpdateResponseData<T>[];
279
+ private extractData;
280
+ /** Return true if this key (id) is invalid */
281
+ private isNotKeyType;
282
+ private throwError;
283
+ }
284
+
285
+ /**
286
+ * Select actions concerning one of the allowed Entity operations
287
+ * @param allowedEntityOps Entity operations (e.g, EntityOp.QUERY_ALL) whose actions should be selected
288
+ * Example:
289
+ * ```
290
+ * this.actions.pipe(ofEntityOp(EntityOp.QUERY_ALL, EntityOp.QUERY_MANY), ...)
291
+ * this.actions.pipe(ofEntityOp(...queryOps), ...)
292
+ * this.actions.pipe(ofEntityOp(queryOps), ...)
293
+ * this.actions.pipe(ofEntityOp(), ...) // any action with a defined `entityOp` property
294
+ * ```
295
+ */
296
+ declare function ofEntityOp<T extends EntityAction>(allowedOps: string[] | EntityOp[]): OperatorFunction<EntityAction, T>;
297
+ declare function ofEntityOp<T extends EntityAction>(...allowedOps: (string | EntityOp)[]): OperatorFunction<EntityAction, T>;
298
+ /**
299
+ * Select actions concerning one of the allowed Entity types
300
+ * @param allowedEntityNames Entity-type names (e.g, 'Hero') whose actions should be selected
301
+ * Example:
302
+ * ```
303
+ * this.actions.pipe(ofEntityType(), ...) // ayn EntityAction with a defined entity type property
304
+ * this.actions.pipe(ofEntityType('Hero'), ...) // EntityActions for the Hero entity
305
+ * this.actions.pipe(ofEntityType('Hero', 'Villain', 'Sidekick'), ...)
306
+ * this.actions.pipe(ofEntityType(...theChosen), ...)
307
+ * this.actions.pipe(ofEntityType(theChosen), ...)
308
+ * ```
309
+ */
310
+ declare function ofEntityType<T extends EntityAction>(allowedEntityNames?: string[]): OperatorFunction<EntityAction, T>;
311
+ declare function ofEntityType<T extends EntityAction>(...allowedEntityNames: string[]): OperatorFunction<EntityAction, T>;
312
+
313
+ declare enum ChangeSetOperation {
314
+ Add = "Add",
315
+ Delete = "Delete",
316
+ Update = "Update",
317
+ Upsert = "Upsert"
318
+ }
319
+ interface ChangeSetAdd<T = any> {
320
+ op: ChangeSetOperation.Add;
321
+ entityName: string;
322
+ entities: T[];
323
+ }
324
+ interface ChangeSetDelete {
325
+ op: ChangeSetOperation.Delete;
326
+ entityName: string;
327
+ entities: string[] | number[];
328
+ }
329
+ interface ChangeSetUpdate<T = any> {
330
+ op: ChangeSetOperation.Update;
331
+ entityName: string;
332
+ entities: Update<T>[];
333
+ }
334
+ interface ChangeSetUpsert<T = any> {
335
+ op: ChangeSetOperation.Upsert;
336
+ entityName: string;
337
+ entities: T[];
338
+ }
339
+ /**
340
+ * A entities of a single entity type, which are changed in the same way by a ChangeSetOperation
341
+ */
342
+ type ChangeSetItem = ChangeSetAdd | ChangeSetDelete | ChangeSetUpdate | ChangeSetUpsert;
343
+ interface ChangeSet<T = any> {
344
+ /** An array of ChangeSetItems to be processed in the array order */
345
+ changes: ChangeSetItem[];
346
+ /**
347
+ * An arbitrary, serializable object that should travel with the ChangeSet.
348
+ * Meaningful to the ChangeSet producer and consumer. Ignored by @ngrx/data.
349
+ */
350
+ extras?: T;
351
+ /** An arbitrary string, identifying the ChangeSet and perhaps its purpose */
352
+ tag?: string;
353
+ }
354
+ /**
355
+ * Factory to create a ChangeSetItem for a ChangeSetOperation
356
+ */
357
+ declare class ChangeSetItemFactory {
358
+ /** Create the ChangeSetAdd for new entities of the given entity type */
359
+ add<T>(entityName: string, entities: T | T[]): ChangeSetAdd<T>;
360
+ /** Create the ChangeSetDelete for primary keys of the given entity type */
361
+ delete(entityName: string, keys: number | number[] | string | string[]): ChangeSetDelete;
362
+ /** Create the ChangeSetUpdate for Updates of entities of the given entity type */
363
+ update<T extends {
364
+ id: string | number;
365
+ }>(entityName: string, updates: Update<T> | Update<T>[]): ChangeSetUpdate<T>;
366
+ /** Create the ChangeSetUpsert for new or existing entities of the given entity type */
367
+ upsert<T>(entityName: string, entities: T | T[]): ChangeSetUpsert<T>;
368
+ }
369
+ /**
370
+ * Instance of a factory to create a ChangeSetItem for a ChangeSetOperation
371
+ */
372
+ declare const changeSetItemFactory: ChangeSetItemFactory;
373
+ /**
374
+ * Return ChangeSet after filtering out null and empty ChangeSetItems.
375
+ * @param changeSet ChangeSet with changes to filter
376
+ */
377
+ declare function excludeEmptyChangeSetItems(changeSet: ChangeSet): ChangeSet;
378
+
379
+ /**
380
+ * Error from a DataService
381
+ * The source error either comes from a failed HTTP response or was thrown within the service.
382
+ * @param error the HttpErrorResponse or the error thrown by the service
383
+ * @param requestData the HTTP request information such as the method and the url.
384
+ */
385
+ declare class DataServiceError extends Error {
386
+ error: any;
387
+ requestData: RequestData | null;
388
+ constructor(error: any, requestData: RequestData | null);
389
+ }
390
+ /** Payload for an EntityAction data service error such as QUERY_ALL_ERROR */
391
+ interface EntityActionDataServiceError {
392
+ error: DataServiceError;
393
+ originalAction: EntityAction;
394
+ }
395
+
396
+ /** Types of change in a ChangeState instance */
397
+ declare enum ChangeType {
398
+ /** The entity has not changed from its last known server state. */
399
+ Unchanged = 0,
400
+ /** The entity was added to the collection */
401
+ Added = 1,
402
+ /** The entity is scheduled for delete and was removed from the collection */
403
+ Deleted = 2,
404
+ /** The entity in the collection was updated */
405
+ Updated = 3
406
+ }
407
+ /**
408
+ * Change state for an entity with unsaved changes;
409
+ * an entry in an EntityCollection.changeState map
410
+ */
411
+ interface ChangeState<T> {
412
+ changeType: ChangeType;
413
+ originalValue?: T | undefined;
414
+ }
415
+ /**
416
+ * Map of entity primary keys to entity ChangeStates.
417
+ * Each entry represents an entity with unsaved changes.
418
+ */
419
+ type ChangeStateMap<T> = Dictionary<ChangeState<T>>;
420
+ /**
421
+ * Data and information about a collection of entities of a single type.
422
+ * EntityCollections are maintained in the EntityCache within the ngrx store.
423
+ */
424
+ interface EntityCollection<T = any> extends EntityState<T> {
425
+ /** Name of the entity type for this collection */
426
+ entityName: string;
427
+ /** A map of ChangeStates, keyed by id, for entities with unsaved changes */
428
+ changeState: ChangeStateMap<T>;
429
+ /** The user's current collection filter pattern */
430
+ filter?: string;
431
+ /** true if collection was ever filled by QueryAll; forced false if cleared */
432
+ loaded: boolean;
433
+ /** true when a query or save operation is in progress */
434
+ loading: boolean;
435
+ }
436
+
437
+ interface EntityCache {
438
+ [name: string]: EntityCollection<any>;
439
+ }
440
+
441
+ declare enum EntityCacheAction {
442
+ CLEAR_COLLECTIONS = "@ngrx/data/entity-cache/clear-collections",
443
+ LOAD_COLLECTIONS = "@ngrx/data/entity-cache/load-collections",
444
+ MERGE_QUERY_SET = "@ngrx/data/entity-cache/merge-query-set",
445
+ SET_ENTITY_CACHE = "@ngrx/data/entity-cache/set-cache",
446
+ SAVE_ENTITIES = "@ngrx/data/entity-cache/save-entities",
447
+ SAVE_ENTITIES_CANCEL = "@ngrx/data/entity-cache/save-entities-cancel",
448
+ SAVE_ENTITIES_CANCELED = "@ngrx/data/entity-cache/save-entities-canceled",
449
+ SAVE_ENTITIES_ERROR = "@ngrx/data/entity-cache/save-entities-error",
450
+ SAVE_ENTITIES_SUCCESS = "@ngrx/data/entity-cache/save-entities-success"
451
+ }
452
+ /**
453
+ * Hash of entities keyed by EntityCollection name,
454
+ * typically the result of a query that returned results from a multi-collection query
455
+ * that will be merged into an EntityCache via the `MergeQuerySet` action.
456
+ */
457
+ interface EntityCacheQuerySet {
458
+ [entityName: string]: any[];
459
+ }
460
+ /**
461
+ * Clear the collections identified in the collectionSet.
462
+ * @param [collections] Array of names of the collections to clear.
463
+ * If empty array, does nothing. If no array, clear all collections.
464
+ * @param [tag] Optional tag to identify the operation from the app perspective.
465
+ */
466
+ declare class ClearCollections implements Action {
467
+ readonly payload: {
468
+ collections?: string[];
469
+ tag?: string;
470
+ };
471
+ readonly type = EntityCacheAction.CLEAR_COLLECTIONS;
472
+ constructor(collections?: string[], tag?: string);
473
+ }
474
+ /**
475
+ * Create entity cache action that loads multiple entity collections at the same time.
476
+ * before any selectors$ observables emit.
477
+ * @param querySet The collections to load, typically the result of a query.
478
+ * @param [tag] Optional tag to identify the operation from the app perspective.
479
+ * in the form of a map of entity collections.
480
+ */
481
+ declare class LoadCollections implements Action {
482
+ readonly payload: {
483
+ collections: EntityCacheQuerySet;
484
+ tag?: string;
485
+ };
486
+ readonly type = EntityCacheAction.LOAD_COLLECTIONS;
487
+ constructor(collections: EntityCacheQuerySet, tag?: string);
488
+ }
489
+ /**
490
+ * Create entity cache action that merges entities from a query result
491
+ * that returned entities from multiple collections.
492
+ * Corresponding entity cache reducer should add and update all collections
493
+ * at the same time, before any selectors$ observables emit.
494
+ * @param querySet The result of the query in the form of a map of entity collections.
495
+ * These are the entity data to merge into the respective collections.
496
+ * @param mergeStrategy How to merge a queried entity when it is already in the collection.
497
+ * The default is MergeStrategy.PreserveChanges
498
+ * @param [tag] Optional tag to identify the operation from the app perspective.
499
+ */
500
+ declare class MergeQuerySet implements Action {
501
+ readonly payload: {
502
+ querySet: EntityCacheQuerySet;
503
+ mergeStrategy?: MergeStrategy;
504
+ tag?: string;
505
+ };
506
+ readonly type = EntityCacheAction.MERGE_QUERY_SET;
507
+ constructor(querySet: EntityCacheQuerySet, mergeStrategy?: MergeStrategy, tag?: string);
508
+ }
509
+ /**
510
+ * Create entity cache action for replacing the entire entity cache.
511
+ * Dangerous because brute force but useful as when re-hydrating an EntityCache
512
+ * from local browser storage when the application launches.
513
+ * @param cache New state of the entity cache
514
+ * @param [tag] Optional tag to identify the operation from the app perspective.
515
+ */
516
+ declare class SetEntityCache implements Action {
517
+ readonly cache: EntityCache;
518
+ readonly payload: {
519
+ cache: EntityCache;
520
+ tag?: string;
521
+ };
522
+ readonly type = EntityCacheAction.SET_ENTITY_CACHE;
523
+ constructor(cache: EntityCache, tag?: string);
524
+ }
525
+ declare class SaveEntities implements Action {
526
+ readonly payload: {
527
+ readonly changeSet: ChangeSet;
528
+ readonly url: string;
529
+ readonly correlationId?: any;
530
+ readonly isOptimistic?: boolean;
531
+ readonly mergeStrategy?: MergeStrategy;
532
+ readonly tag?: string;
533
+ error?: Error;
534
+ skip?: boolean;
535
+ };
536
+ readonly type = EntityCacheAction.SAVE_ENTITIES;
537
+ constructor(changeSet: ChangeSet, url: string, options?: EntityActionOptions);
538
+ }
539
+ declare class SaveEntitiesCancel implements Action {
540
+ readonly payload: {
541
+ readonly correlationId: any;
542
+ readonly reason?: string;
543
+ readonly entityNames?: string[];
544
+ readonly tag?: string;
545
+ };
546
+ readonly type = EntityCacheAction.SAVE_ENTITIES_CANCEL;
547
+ constructor(correlationId: any, reason?: string, entityNames?: string[], tag?: string);
548
+ }
549
+ declare class SaveEntitiesCanceled implements Action {
550
+ readonly payload: {
551
+ readonly correlationId: any;
552
+ readonly reason?: string;
553
+ readonly tag?: string;
554
+ };
555
+ readonly type = EntityCacheAction.SAVE_ENTITIES_CANCELED;
556
+ constructor(correlationId: any, reason?: string, tag?: string);
557
+ }
558
+ declare class SaveEntitiesError {
559
+ readonly payload: {
560
+ readonly error: DataServiceError;
561
+ readonly originalAction: SaveEntities;
562
+ readonly correlationId: any;
563
+ };
564
+ readonly type = EntityCacheAction.SAVE_ENTITIES_ERROR;
565
+ constructor(error: DataServiceError, originalAction: SaveEntities);
566
+ }
567
+ declare class SaveEntitiesSuccess implements Action {
568
+ readonly payload: {
569
+ readonly changeSet: ChangeSet;
570
+ readonly url: string;
571
+ readonly correlationId?: any;
572
+ readonly isOptimistic?: boolean;
573
+ readonly mergeStrategy?: MergeStrategy;
574
+ readonly tag?: string;
575
+ error?: Error;
576
+ skip?: boolean;
577
+ };
578
+ readonly type = EntityCacheAction.SAVE_ENTITIES_SUCCESS;
579
+ constructor(changeSet: ChangeSet, url: string, options?: EntityActionOptions);
580
+ }
581
+
582
+ declare abstract class Logger {
583
+ abstract error(message?: any, ...optionalParams: any[]): void;
584
+ abstract log(message?: any, ...optionalParams: any[]): void;
585
+ abstract warn(message?: any, ...optionalParams: any[]): void;
586
+ }
587
+ /**
588
+ * Mapping of entity type name to its plural
589
+ */
590
+ interface EntityPluralNames {
591
+ [entityName: string]: string;
592
+ }
593
+ declare const PLURAL_NAMES_TOKEN: InjectionToken<EntityPluralNames>;
594
+ declare abstract class Pluralizer {
595
+ abstract pluralize(name: string): string;
596
+ }
597
+
598
+ /**
599
+ * Known resource URLS for specific entity types.
600
+ * Each entity's resource URLS are endpoints that
601
+ * target single entity and multi-entity HTTP operations.
602
+ * Used by the `DefaultHttpUrlGenerator`.
603
+ */
604
+ declare abstract class EntityHttpResourceUrls {
605
+ [entityName: string]: HttpResourceUrls;
606
+ }
607
+ /**
608
+ * Resource URLS for HTTP operations that target single entity
609
+ * and multi-entity endpoints.
610
+ */
611
+ interface HttpResourceUrls {
612
+ /**
613
+ * The URL path for a single entity endpoint, e.g, `some-api-root/hero/`
614
+ * such as you'd use to add a hero.
615
+ * Example: `httpClient.post<Hero>('some-api-root/hero/', addedHero)`.
616
+ * Note trailing slash (/).
617
+ */
618
+ entityResourceUrl: string;
619
+ /**
620
+ * The URL path for a multiple-entity endpoint, e.g, `some-api-root/heroes/`
621
+ * such as you'd use when getting all heroes.
622
+ * Example: `httpClient.get<Hero[]>('some-api-root/heroes/')`
623
+ * Note trailing slash (/).
624
+ */
625
+ collectionResourceUrl: string;
626
+ }
627
+ /**
628
+ * Generate the base part of an HTTP URL for
629
+ * single entity or entity collection resource
630
+ */
631
+ declare abstract class HttpUrlGenerator {
632
+ /**
633
+ * Return the base URL for a single entity resource,
634
+ * e.g., the base URL to get a single hero by its id
635
+ */
636
+ abstract entityResource(entityName: string, root: string, trailingSlashEndpoints: boolean): string;
637
+ /**
638
+ * Return the base URL for a collection resource,
639
+ * e.g., the base URL to get all heroes
640
+ */
641
+ abstract collectionResource(entityName: string, root: string): string;
642
+ /**
643
+ * Register known single-entity and collection resource URLs for HTTP calls
644
+ * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names
645
+ */
646
+ abstract registerHttpResourceUrls(entityHttpResourceUrls?: EntityHttpResourceUrls): void;
647
+ }
648
+ declare class DefaultHttpUrlGenerator implements HttpUrlGenerator {
649
+ private pluralizer;
650
+ /**
651
+ * Known single-entity and collection resource URLs for HTTP calls.
652
+ * Generator methods returns these resource URLs for a given entity type name.
653
+ * If the resources for an entity type name are not know, it generates
654
+ * and caches a resource name for future use
655
+ */
656
+ protected knownHttpResourceUrls: EntityHttpResourceUrls;
657
+ constructor(pluralizer: Pluralizer);
658
+ /**
659
+ * Get or generate the entity and collection resource URLs for the given entity type name
660
+ * @param entityName {string} Name of the entity type, e.g, 'Hero'
661
+ * @param root {string} Root path to the resource, e.g., 'some-api`
662
+ */
663
+ protected getResourceUrls(entityName: string, root: string, trailingSlashEndpoints?: boolean): HttpResourceUrls;
664
+ /**
665
+ * Create the path to a single entity resource
666
+ * @param entityName {string} Name of the entity type, e.g, 'Hero'
667
+ * @param root {string} Root path to the resource, e.g., 'some-api`
668
+ * @returns complete path to resource, e.g, 'some-api/hero'
669
+ */
670
+ entityResource(entityName: string, root: string, trailingSlashEndpoints: boolean): string;
671
+ /**
672
+ * Create the path to a multiple entity (collection) resource
673
+ * @param entityName {string} Name of the entity type, e.g, 'Hero'
674
+ * @param root {string} Root path to the resource, e.g., 'some-api`
675
+ * @returns complete path to resource, e.g, 'some-api/heroes'
676
+ */
677
+ collectionResource(entityName: string, root: string): string;
678
+ /**
679
+ * Register known single-entity and collection resource URLs for HTTP calls
680
+ * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names
681
+ * Well-formed resource urls end in a '/';
682
+ * Note: this method does not ensure that resource urls are well-formed.
683
+ */
684
+ registerHttpResourceUrls(entityHttpResourceUrls: EntityHttpResourceUrls): void;
685
+ static ɵfac: i0.ɵɵFactoryDeclaration<DefaultHttpUrlGenerator, never>;
686
+ static ɵprov: i0.ɵɵInjectableDeclaration<DefaultHttpUrlGenerator>;
687
+ }
688
+ /** Remove leading & trailing spaces or slashes */
689
+ declare function normalizeRoot(root: string): string;
690
+
691
+ /**
692
+ * Optional configuration settings for an entity collection data service
693
+ * such as the `DefaultDataService<T>`.
694
+ */
695
+ declare abstract class DefaultDataServiceConfig {
696
+ /**
697
+ * root path of the web api. may also include protocol, domain, and port
698
+ * for remote api, e.g.: `'https://api-domain.com:8000/api/v1'` (default: 'api')
699
+ */
700
+ root?: string;
701
+ /**
702
+ * Known entity HttpResourceUrls.
703
+ * HttpUrlGenerator will create these URLs for entity types not listed here.
704
+ */
705
+ entityHttpResourceUrls?: EntityHttpResourceUrls;
706
+ /** Is a DELETE 404 really OK? (default: true) */
707
+ delete404OK?: boolean;
708
+ /** Simulate GET latency in a demo (default: 0) */
709
+ getDelay?: number;
710
+ /** Simulate save method (PUT/POST/DELETE) latency in a demo (default: 0) */
711
+ saveDelay?: number;
712
+ /** request timeout in MS (default: 0)*/
713
+ timeout?: number;
714
+ /** to keep leading & trailing slashes or not; false by default */
715
+ trailingSlashEndpoints?: boolean;
716
+ }
717
+
718
+ /**
719
+ * A basic, generic entity data service
720
+ * suitable for persistence of most entities.
721
+ * Assumes a common REST-y web API
722
+ */
723
+ declare class DefaultDataService<T> implements EntityCollectionDataService<T> {
724
+ protected http: HttpClient;
725
+ protected httpUrlGenerator: HttpUrlGenerator;
726
+ protected _name: string;
727
+ protected delete404OK: boolean;
728
+ protected entityName: string;
729
+ protected entityUrl: string;
730
+ protected entitiesUrl: string;
731
+ protected getDelay: number;
732
+ protected saveDelay: number;
733
+ protected timeout: number;
734
+ protected trailingSlashEndpoints: boolean;
735
+ get name(): string;
736
+ constructor(entityName: string, http: HttpClient, httpUrlGenerator: HttpUrlGenerator, config?: DefaultDataServiceConfig);
737
+ add(entity: T, options?: HttpOptions): Observable<T>;
738
+ delete(key: number | string, options?: HttpOptions): Observable<number | string>;
739
+ getAll(options?: HttpOptions): Observable<T[]>;
740
+ getById(key: number | string, options?: HttpOptions): Observable<T>;
741
+ getWithQuery(queryParams: QueryParams | string | undefined, options?: HttpOptions): Observable<T[]>;
742
+ update(update: Update<T>, options?: HttpOptions): Observable<T>;
743
+ upsert(entity: T, options?: HttpOptions): Observable<T>;
744
+ protected execute(method: HttpMethods, url: string, data?: any, // data, error, or undefined/null
745
+ options?: any, // options or undefined/null
746
+ httpOptions?: HttpOptions): Observable<any>;
747
+ private handleError;
748
+ private handleDelete404;
749
+ }
750
+ /**
751
+ * Create a basic, generic entity data service
752
+ * suitable for persistence of most entities.
753
+ * Assumes a common REST-y web API
754
+ */
755
+ declare class DefaultDataServiceFactory {
756
+ protected http: HttpClient;
757
+ protected httpUrlGenerator: HttpUrlGenerator;
758
+ protected config?: DefaultDataServiceConfig;
759
+ constructor(http: HttpClient, httpUrlGenerator: HttpUrlGenerator, config?: DefaultDataServiceConfig);
760
+ /**
761
+ * Create a default {EntityCollectionDataService} for the given entity type
762
+ * @param entityName {string} Name of the entity type for this data service
763
+ */
764
+ create<T>(entityName: string): EntityCollectionDataService<T>;
765
+ static ɵfac: i0.ɵɵFactoryDeclaration<DefaultDataServiceFactory, [null, null, { optional: true; }]>;
766
+ static ɵprov: i0.ɵɵInjectableDeclaration<DefaultDataServiceFactory>;
767
+ }
768
+
769
+ /**
770
+ * Default options for EntityDispatcher behavior
771
+ * such as whether `add()` is optimistic or pessimistic by default.
772
+ * An optimistic save modifies the collection immediately and before saving to the server.
773
+ * A pessimistic save modifies the collection after the server confirms the save was successful.
774
+ * This class initializes the defaults to the safest values.
775
+ * Provide an alternative to change the defaults for all entity collections.
776
+ */
777
+ declare class EntityDispatcherDefaultOptions {
778
+ /** True if added entities are saved optimistically; false if saved pessimistically. */
779
+ optimisticAdd: boolean;
780
+ /** True if deleted entities are saved optimistically; false if saved pessimistically. */
781
+ optimisticDelete: boolean;
782
+ /** True if updated entities are saved optimistically; false if saved pessimistically. */
783
+ optimisticUpdate: boolean;
784
+ /** True if upsert entities are saved optimistically; false if saved pessimistically. */
785
+ optimisticUpsert: boolean;
786
+ /** True if entities in a cache saveEntities request are saved optimistically; false if saved pessimistically. */
787
+ optimisticSaveEntities: boolean;
788
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDispatcherDefaultOptions, never>;
789
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityDispatcherDefaultOptions>;
790
+ }
791
+
792
+ /**
793
+ * Filters the `entities` array argument and returns the original `entities`,
794
+ * or a new filtered array of entities.
795
+ * NEVER mutate the original `entities` array itself.
796
+ **/
797
+ type EntityFilterFn<T> = (entities: T[], pattern?: any) => T[];
798
+ /**
799
+ * Creates an {EntityFilterFn} that matches RegExp or RegExp string pattern
800
+ * anywhere in any of the given props of an entity.
801
+ * If pattern is a string, spaces are significant and ignores case.
802
+ */
803
+ declare function PropsFilterFnFactory<T = any>(props?: (keyof T)[]): EntityFilterFn<T>;
804
+
805
+ declare const ENTITY_METADATA_TOKEN: InjectionToken<EntityMetadataMap>;
806
+ /** Metadata that describe an entity type and its collection to @ngrx/data */
807
+ interface EntityMetadata<T = any, S extends object = {}> {
808
+ entityName: string;
809
+ entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;
810
+ filterFn?: EntityFilterFn<T>;
811
+ noChangeTracking?: boolean;
812
+ selectId?: IdSelector<T>;
813
+ sortComparer?: false | Comparer<T>;
814
+ additionalCollectionState?: S;
815
+ }
816
+ /** Map entity-type name to its EntityMetadata */
817
+ interface EntityMetadataMap {
818
+ [entityName: string]: Partial<EntityMetadata<any>>;
819
+ }
820
+
821
+ interface EntityDefinition<T = any> {
822
+ entityName: string;
823
+ entityAdapter: EntityAdapter<T>;
824
+ entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;
825
+ initialState: EntityCollection<T>;
826
+ metadata: EntityMetadata<T>;
827
+ noChangeTracking: boolean;
828
+ selectId: IdSelector<T>;
829
+ sortComparer: false | Comparer<T>;
830
+ }
831
+ declare function createEntityDefinition<T, S extends object>(metadata: EntityMetadata<T, S>): EntityDefinition<T>;
832
+
833
+ interface EntityDefinitions {
834
+ [entityName: string]: EntityDefinition<any>;
835
+ }
836
+ /** Registry of EntityDefinitions for all cached entity types */
837
+ declare class EntityDefinitionService {
838
+ /** {EntityDefinition} for all cached entity types */
839
+ private readonly definitions;
840
+ constructor(entityMetadataMaps: EntityMetadataMap[]);
841
+ /**
842
+ * Get (or create) a data service for entity type
843
+ * @param entityName - the name of the type
844
+ *
845
+ * Examples:
846
+ * getDefinition('Hero'); // definition for Heroes, untyped
847
+ * getDefinition<Hero>(`Hero`); // definition for Heroes, typed with Hero interface
848
+ */
849
+ getDefinition<T>(entityName: string, shouldThrow?: boolean): EntityDefinition<T>;
850
+ /**
851
+ * Create and register the {EntityDefinition} for the {EntityMetadata} of an entity type
852
+ * @param name - the name of the entity type
853
+ * @param definition - {EntityMetadata} for a collection for that entity type
854
+ *
855
+ * Examples:
856
+ * registerMetadata(myHeroEntityDefinition);
857
+ */
858
+ registerMetadata(metadata: EntityMetadata): void;
859
+ /**
860
+ * Register an EntityMetadataMap.
861
+ * @param metadataMap - a map of entityType names to entity metadata
862
+ *
863
+ * Examples:
864
+ * registerMetadataMap({
865
+ * 'Hero': myHeroMetadata,
866
+ * Villain: myVillainMetadata
867
+ * });
868
+ */
869
+ registerMetadataMap(metadataMap?: EntityMetadataMap): void;
870
+ /**
871
+ * Register an {EntityDefinition} for an entity type
872
+ * @param definition - EntityDefinition of a collection for that entity type
873
+ *
874
+ * Examples:
875
+ * registerDefinition('Hero', myHeroEntityDefinition);
876
+ */
877
+ registerDefinition<T>(definition: EntityDefinition<T>): void;
878
+ /**
879
+ * Register a batch of EntityDefinitions.
880
+ * @param definitions - map of entityType name and associated EntityDefinitions to merge.
881
+ *
882
+ * Examples:
883
+ * registerDefinitions({
884
+ * 'Hero': myHeroEntityDefinition,
885
+ * Villain: myVillainEntityDefinition
886
+ * });
887
+ */
888
+ registerDefinitions(definitions: EntityDefinitions): void;
889
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDefinitionService, [{ optional: true; }]>;
890
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityDefinitionService>;
891
+ }
892
+
893
+ /**
894
+ * Default data service for making remote service calls targeting the entire EntityCache.
895
+ * See EntityDataService for services that target a single EntityCollection
896
+ */
897
+ declare class EntityCacheDataService {
898
+ protected entityDefinitionService: EntityDefinitionService;
899
+ protected http: HttpClient;
900
+ protected idSelectors: {
901
+ [entityName: string]: IdSelector<any>;
902
+ };
903
+ protected saveDelay: number;
904
+ protected timeout: number;
905
+ constructor(entityDefinitionService: EntityDefinitionService, http: HttpClient, config?: DefaultDataServiceConfig);
906
+ /**
907
+ * Save changes to multiple entities across one or more entity collections.
908
+ * Server endpoint must understand the essential SaveEntities protocol,
909
+ * in particular the ChangeSet interface (except for Update<T>).
910
+ * This implementation extracts the entity changes from a ChangeSet Update<T>[] and sends those.
911
+ * It then reconstructs Update<T>[] in the returned observable result.
912
+ * @param changeSet An array of SaveEntityItems.
913
+ * Each SaveEntityItem describe a change operation for one or more entities of a single collection,
914
+ * known by its 'entityName'.
915
+ * @param url The server endpoint that receives this request.
916
+ */
917
+ saveEntities(changeSet: ChangeSet, url: string): Observable<ChangeSet>;
918
+ protected handleError(reqData: RequestData): (err: any) => Observable<never>;
919
+ /**
920
+ * Filter changeSet to remove unwanted ChangeSetItems.
921
+ * This implementation excludes null and empty ChangeSetItems.
922
+ * @param changeSet ChangeSet with changes to filter
923
+ */
924
+ protected filterChangeSet(changeSet: ChangeSet): ChangeSet;
925
+ /**
926
+ * Convert the entities in update changes from @ngrx Update<T> structure to just T.
927
+ * Reverse of restoreUpdates().
928
+ */
929
+ protected flattenUpdates(changeSet: ChangeSet): ChangeSet;
930
+ /**
931
+ * Convert the flattened T entities in update changes back to @ngrx Update<T> structures.
932
+ * Reverse of flattenUpdates().
933
+ */
934
+ protected restoreUpdates(changeSet: ChangeSet): ChangeSet;
935
+ /**
936
+ * Get the id (primary key) selector function for an entity type
937
+ * @param entityName name of the entity type
938
+ */
939
+ protected getIdSelector(entityName: string): IdSelector<any>;
940
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheDataService, [null, null, { optional: true; }]>;
941
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheDataService>;
942
+ }
943
+
944
+ /**
945
+ * Registry of EntityCollection data services that make REST-like CRUD calls
946
+ * to entity collection endpoints.
947
+ */
948
+ declare class EntityDataService {
949
+ protected defaultDataServiceFactory: DefaultDataServiceFactory;
950
+ protected services: {
951
+ [name: string]: EntityCollectionDataService<any>;
952
+ };
953
+ constructor(defaultDataServiceFactory: DefaultDataServiceFactory);
954
+ /**
955
+ * Get (or create) a data service for entity type
956
+ * @param entityName - the name of the type
957
+ *
958
+ * Examples:
959
+ * getService('Hero'); // data service for Heroes, untyped
960
+ * getService<Hero>('Hero'); // data service for Heroes, typed as Hero
961
+ */
962
+ getService<T>(entityName: string): EntityCollectionDataService<T>;
963
+ /**
964
+ * Register an EntityCollectionDataService for an entity type
965
+ * @param entityName - the name of the entity type
966
+ * @param service - data service for that entity type
967
+ *
968
+ * Examples:
969
+ * registerService('Hero', myHeroDataService);
970
+ * registerService('Villain', myVillainDataService);
971
+ */
972
+ registerService<T>(entityName: string, service: EntityCollectionDataService<T>): void;
973
+ /**
974
+ * Register a batch of data services.
975
+ * @param services - data services to merge into existing services
976
+ *
977
+ * Examples:
978
+ * registerServices({
979
+ * Hero: myHeroDataService,
980
+ * Villain: myVillainDataService
981
+ * });
982
+ */
983
+ registerServices(services: {
984
+ [name: string]: EntityCollectionDataService<any>;
985
+ }): void;
986
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDataService, never>;
987
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityDataService>;
988
+ }
989
+
990
+ /**
991
+ * Handling of responses from persistence operation
992
+ */
993
+ declare abstract class PersistenceResultHandler {
994
+ /** Handle successful result of persistence operation for an action */
995
+ abstract handleSuccess(originalAction: EntityAction): (data: any) => Action;
996
+ /** Handle error result of persistence operation for an action */
997
+ abstract handleError(originalAction: EntityAction): (error: DataServiceError | Error) => EntityAction<EntityActionDataServiceError>;
998
+ }
999
+ /**
1000
+ * Default handling of responses from persistence operation,
1001
+ * specifically an EntityDataService
1002
+ */
1003
+ declare class DefaultPersistenceResultHandler implements PersistenceResultHandler {
1004
+ private logger;
1005
+ private entityActionFactory;
1006
+ constructor(logger: Logger, entityActionFactory: EntityActionFactory);
1007
+ /** Handle successful result of persistence operation on an EntityAction */
1008
+ handleSuccess(originalAction: EntityAction): (data: any) => Action;
1009
+ /** Handle error result of persistence operation on an EntityAction */
1010
+ handleError(originalAction: EntityAction): (error: DataServiceError | Error) => EntityAction<EntityActionDataServiceError>;
1011
+ static ɵfac: i0.ɵɵFactoryDeclaration<DefaultPersistenceResultHandler, never>;
1012
+ static ɵprov: i0.ɵɵInjectableDeclaration<DefaultPersistenceResultHandler>;
1013
+ }
1014
+
1015
+ /**
1016
+ * Generates a string id beginning 'CRID',
1017
+ * followed by a monotonically increasing integer for use as a correlation id.
1018
+ * As they are produced locally by a singleton service,
1019
+ * these ids are guaranteed to be unique only
1020
+ * for the duration of a single client browser instance.
1021
+ * Ngrx entity dispatcher query and save methods call this service to generate default correlation ids.
1022
+ * Do NOT use for entity keys.
1023
+ */
1024
+ declare class CorrelationIdGenerator {
1025
+ /** Seed for the ids */
1026
+ protected seed: number;
1027
+ /** Prefix of the id, 'CRID; */
1028
+ protected prefix: string;
1029
+ /** Return the next correlation id */
1030
+ next(): string;
1031
+ static ɵfac: i0.ɵɵFactoryDeclaration<CorrelationIdGenerator, never>;
1032
+ static ɵprov: i0.ɵɵInjectableDeclaration<CorrelationIdGenerator>;
1033
+ }
1034
+
1035
+ /**
1036
+ * Dispatches Entity Cache actions to the EntityCache reducer
1037
+ */
1038
+ declare class EntityCacheDispatcher {
1039
+ /** Generates correlation ids for query and save methods */
1040
+ private correlationIdGenerator;
1041
+ /**
1042
+ * Dispatcher options configure dispatcher behavior such as
1043
+ * whether add is optimistic or pessimistic by default.
1044
+ */
1045
+ private defaultDispatcherOptions;
1046
+ /** The store, scoped to the EntityCache */
1047
+ private store;
1048
+ /**
1049
+ * Actions scanned by the store after it processed them with reducers.
1050
+ * A replay observable of the most recent action reduced by the store.
1051
+ */
1052
+ reducedActions$: Observable<Action>;
1053
+ private raSubscription;
1054
+ constructor(
1055
+ /** Generates correlation ids for query and save methods */
1056
+ correlationIdGenerator: CorrelationIdGenerator,
1057
+ /**
1058
+ * Dispatcher options configure dispatcher behavior such as
1059
+ * whether add is optimistic or pessimistic by default.
1060
+ */
1061
+ defaultDispatcherOptions: EntityDispatcherDefaultOptions,
1062
+ /** Actions scanned by the store after it processed them with reducers. */
1063
+ scannedActions$: Observable<Action>,
1064
+ /** The store, scoped to the EntityCache */
1065
+ store: Store<EntityCache>);
1066
+ /**
1067
+ * Dispatch an Action to the store.
1068
+ * @param action the Action
1069
+ * @returns the dispatched Action
1070
+ */
1071
+ dispatch(action: Action): Action;
1072
+ /**
1073
+ * Dispatch action to cancel the saveEntities request with matching correlation id.
1074
+ * @param correlationId The correlation id for the corresponding action
1075
+ * @param [reason] explains why canceled and by whom.
1076
+ * @param [entityNames] array of entity names so can turn off loading flag for their collections.
1077
+ * @param [tag] tag to identify the operation from the app perspective.
1078
+ */
1079
+ cancelSaveEntities(correlationId: any, reason?: string, entityNames?: string[], tag?: string): void;
1080
+ /** Clear the named entity collections in cache
1081
+ * @param [collections] Array of names of the collections to clear.
1082
+ * If empty array, does nothing. If null/undefined/no array, clear all collections.
1083
+ * @param [tag] tag to identify the operation from the app perspective.
1084
+ */
1085
+ clearCollections(collections?: string[], tag?: string): void;
1086
+ /**
1087
+ * Load multiple entity collections at the same time.
1088
+ * before any selectors$ observables emit.
1089
+ * @param collections The collections to load, typically the result of a query.
1090
+ * @param [tag] tag to identify the operation from the app perspective.
1091
+ * in the form of a map of entity collections.
1092
+ */
1093
+ loadCollections(collections: EntityCacheQuerySet, tag?: string): void;
1094
+ /**
1095
+ * Merges entities from a query result
1096
+ * that returned entities from multiple collections.
1097
+ * Corresponding entity cache reducer should add and update all collections
1098
+ * at the same time, before any selectors$ observables emit.
1099
+ * @param querySet The result of the query in the form of a map of entity collections.
1100
+ * These are the entity data to merge into the respective collections.
1101
+ * @param mergeStrategy How to merge a queried entity when it is already in the collection.
1102
+ * The default is MergeStrategy.PreserveChanges
1103
+ * @param [tag] tag to identify the operation from the app perspective.
1104
+ */
1105
+ mergeQuerySet(querySet: EntityCacheQuerySet, mergeStrategy?: MergeStrategy, tag?: string): void;
1106
+ /**
1107
+ * Create entity cache action for replacing the entire entity cache.
1108
+ * Dangerous because brute force but useful as when re-hydrating an EntityCache
1109
+ * from local browser storage when the application launches.
1110
+ * @param cache New state of the entity cache
1111
+ * @param [tag] tag to identify the operation from the app perspective.
1112
+ */
1113
+ setEntityCache(cache: EntityCache, tag?: string): void;
1114
+ /**
1115
+ * Dispatch action to save multiple entity changes to remote storage.
1116
+ * Relies on an Ngrx Effect such as EntityEffects.saveEntities$.
1117
+ * Important: only call if your server supports the SaveEntities protocol
1118
+ * through your EntityDataService.saveEntities method.
1119
+ * @param changes Either the entities to save, as an array of {ChangeSetItem}, or
1120
+ * a ChangeSet that holds such changes.
1121
+ * @param url The server url which receives the save request
1122
+ * @param [options] options such as tag, correlationId, isOptimistic, and mergeStrategy.
1123
+ * These values are defaulted if not supplied.
1124
+ * @returns A terminating Observable<ChangeSet> with data returned from the server
1125
+ * after server reports successful save OR the save error.
1126
+ * TODO: should return the matching entities from cache rather than the raw server data.
1127
+ */
1128
+ saveEntities(changes: ChangeSetItem[] | ChangeSet, url: string, options?: EntityActionOptions): Observable<ChangeSet>;
1129
+ /**
1130
+ * Return Observable of data from the server-success SaveEntities action with
1131
+ * the given Correlation Id, after that action was processed by the ngrx store.
1132
+ * or else put the server error on the Observable error channel.
1133
+ * @param crid The correlationId for both the save and response actions.
1134
+ */
1135
+ private getSaveEntitiesResponseData$;
1136
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheDispatcher, never>;
1137
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheDispatcher>;
1138
+ }
1139
+
1140
+ /** Commands that update the remote server. */
1141
+ interface EntityServerCommands<T> {
1142
+ /**
1143
+ * Dispatch action to save a new entity to remote storage.
1144
+ * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
1145
+ * must have a key if optimistic save.
1146
+ * @returns A terminating Observable of the entity
1147
+ * after server reports successful save or the save error.
1148
+ */
1149
+ add(entity: Partial<T>, options?: EntityActionOptions & {
1150
+ isOptimistic?: false;
1151
+ }): Observable<T>;
1152
+ add(entity: T, options: EntityActionOptions & {
1153
+ isOptimistic: true;
1154
+ }): Observable<T>;
1155
+ add(entity: T, options?: EntityActionOptions): Observable<T>;
1156
+ /**
1157
+ * Dispatch action to cancel the persistence operation (query or save) with the given correlationId.
1158
+ * @param correlationId The correlation id for the corresponding EntityAction
1159
+ * @param [reason] explains why canceled and by whom.
1160
+ * @param [options] options such as the tag
1161
+ */
1162
+ cancel(correlationId: any, reason?: string, options?: EntityActionOptions): void;
1163
+ /**
1164
+ * Dispatch action to delete entity from remote storage by key.
1165
+ * @param key The entity to delete
1166
+ * @param [options] options that influence save and merge behavior
1167
+ * @returns A terminating Observable of the deleted key
1168
+ * after server reports successful save or the save error.
1169
+ */
1170
+ delete(entity: T, options?: EntityActionOptions): Observable<number | string>;
1171
+ /**
1172
+ * Dispatch action to delete entity from remote storage by key.
1173
+ * @param key The primary key of the entity to remove
1174
+ * @param [options] options that influence save and merge behavior
1175
+ * @returns Observable of the deleted key
1176
+ * after server reports successful save or the save error.
1177
+ */
1178
+ delete(key: number | string, options?: EntityActionOptions): Observable<number | string>;
1179
+ /**
1180
+ * Dispatch action to query remote storage for all entities and
1181
+ * merge the queried entities into the cached collection.
1182
+ * @param [options] options that influence merge behavior
1183
+ * @returns A terminating Observable of the collection
1184
+ * after server reports successful query or the query error.
1185
+ * @see load()
1186
+ */
1187
+ getAll(options?: EntityActionOptions): Observable<T[]>;
1188
+ /**
1189
+ * Dispatch action to query remote storage for the entity with this primary key.
1190
+ * If the server returns an entity,
1191
+ * merge it into the cached collection.
1192
+ * @param key The primary key of the entity to get.
1193
+ * @param [options] options that influence merge behavior
1194
+ * @returns A terminating Observable of the queried entities that are in the collection
1195
+ * after server reports success or the query error.
1196
+ */
1197
+ getByKey(key: any, options?: EntityActionOptions): Observable<T>;
1198
+ /**
1199
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
1200
+ * with either a query parameter map or an HTTP URL query string,
1201
+ * and merge the results into the cached collection.
1202
+ * @param queryParams the query in a form understood by the server
1203
+ * @param [options] options that influence merge behavior
1204
+ * @returns A terminating Observable of the queried entities
1205
+ * after server reports successful query or the query error.
1206
+ */
1207
+ getWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
1208
+ /**
1209
+ * Dispatch action to query remote storage for all entities and
1210
+ * completely replace the cached collection with the queried entities.
1211
+ * @param [options] options that influence load behavior
1212
+ * @returns A terminating Observable of the entities in the collection
1213
+ * after server reports successful query or the query error.
1214
+ * @see getAll
1215
+ */
1216
+ load(options?: EntityActionOptions): Observable<T[]>;
1217
+ /**
1218
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
1219
+ * with either a query parameter map or an HTTP URL query string, and
1220
+ * completely replace the cached collection with the queried entities.
1221
+ * @param queryParams the query in a form understood by the server
1222
+ * @param [options] options that influence load behavior
1223
+ * @returns A terminating Observable of the entities in the collection
1224
+ * after server reports successful query or the query error.
1225
+ * @see getWithQuery
1226
+ */
1227
+ loadWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
1228
+ /**
1229
+ * Dispatch action to save the updated entity (or partial entity) in remote storage.
1230
+ * The update entity may be partial (but must have its key)
1231
+ * in which case it patches the existing entity.
1232
+ * @param entity update entity, which might be a partial of T but must at least have its key.
1233
+ * @param [options] options that influence save and merge behavior
1234
+ * @returns A terminating Observable of the updated entity
1235
+ * after server reports successful save or the save error.
1236
+ */
1237
+ update(entity: Partial<T>, options?: EntityActionOptions): Observable<T>;
1238
+ /**
1239
+ * Dispatch action to save a new or update an existing entity to remote storage.
1240
+ * Only dispatch this action if your server supports upsert.
1241
+ * @param entity entity to upsert, which may omit its key if pessimistic and the server creates the key;
1242
+ * must have a key if optimistic save.
1243
+ * @returns A terminating Observable of the entity
1244
+ * after server reports successful save or the save error.
1245
+ */
1246
+ upsert(entity: T, options?: EntityActionOptions): Observable<T>;
1247
+ }
1248
+ /*** A collection's cache-only commands, which do not update remote storage ***/
1249
+ interface EntityCacheCommands<T> {
1250
+ /**
1251
+ * Replace all entities in the cached collection.
1252
+ * Does not save to remote storage.
1253
+ * @param entities to add directly to cache.
1254
+ * @param [options] options such as mergeStrategy
1255
+ */
1256
+ addAllToCache(entities: T[], options?: EntityActionOptions): void;
1257
+ /**
1258
+ * Add a new entity directly to the cache.
1259
+ * Does not save to remote storage.
1260
+ * Ignored if an entity with the same primary key is already in cache.
1261
+ * @param entity to add directly to cache.
1262
+ * @param [options] options such as mergeStrategy
1263
+ */
1264
+ addOneToCache(entity: T, options?: EntityActionOptions): void;
1265
+ /**
1266
+ * Add multiple new entities directly to the cache.
1267
+ * Does not save to remote storage.
1268
+ * Entities with primary keys already in cache are ignored.
1269
+ * @param entities to add directly to cache.
1270
+ * @param [options] options such as mergeStrategy
1271
+ */
1272
+ addManyToCache(entities: T[], options?: EntityActionOptions): void;
1273
+ /** Clear the cached entity collection */
1274
+ clearCache(options?: EntityActionOptions): void;
1275
+ /**
1276
+ * Remove an entity directly from the cache.
1277
+ * Does not delete that entity from remote storage.
1278
+ * @param entity The entity to remove
1279
+ * @param [options] options such as mergeStrategy
1280
+ */
1281
+ removeOneFromCache(entity: T, options?: EntityActionOptions): void;
1282
+ /**
1283
+ * Remove an entity directly from the cache.
1284
+ * Does not delete that entity from remote storage.
1285
+ * @param key The primary key of the entity to remove
1286
+ * @param [options] options such as mergeStrategy
1287
+ */
1288
+ removeOneFromCache(key: number | string, options?: EntityActionOptions): void;
1289
+ /**
1290
+ * Remove multiple entities directly from the cache.
1291
+ * Does not delete these entities from remote storage.
1292
+ * @param entity The entities to remove
1293
+ * @param [options] options such as mergeStrategy
1294
+ */
1295
+ removeManyFromCache(entities: T[], options?: EntityActionOptions): void;
1296
+ /**
1297
+ * Remove multiple entities directly from the cache.
1298
+ * Does not delete these entities from remote storage.
1299
+ * @param keys The primary keys of the entities to remove
1300
+ * @param [options] options such as mergeStrategy
1301
+ */
1302
+ removeManyFromCache(keys: (number | string)[], options?: EntityActionOptions): void;
1303
+ /**
1304
+ * Update a cached entity directly.
1305
+ * Does not update that entity in remote storage.
1306
+ * Ignored if an entity with matching primary key is not in cache.
1307
+ * The update entity may be partial (but must have its key)
1308
+ * in which case it patches the existing entity.
1309
+ * @param entity to update directly in cache.
1310
+ * @param [options] options such as mergeStrategy
1311
+ */
1312
+ updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
1313
+ /**
1314
+ * Update multiple cached entities directly.
1315
+ * Does not update these entities in remote storage.
1316
+ * Entities whose primary keys are not in cache are ignored.
1317
+ * Update entities may be partial but must at least have their keys.
1318
+ * such partial entities patch their cached counterparts.
1319
+ * @param entities to update directly in cache.
1320
+ * @param [options] options such as mergeStrategy
1321
+ */
1322
+ updateManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
1323
+ /**
1324
+ * Insert or update a cached entity directly.
1325
+ * Does not save to remote storage.
1326
+ * Upsert entity might be a partial of T but must at least have its key.
1327
+ * Pass the Update<T> structure as the payload.
1328
+ * @param entity to upsert directly in cache.
1329
+ * @param [options] options such as mergeStrategy
1330
+ */
1331
+ upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
1332
+ /**
1333
+ * Insert or update multiple cached entities directly.
1334
+ * Does not save to remote storage.
1335
+ * Upsert entities might be partial but must at least have their keys.
1336
+ * Pass an array of the Update<T> structure as the payload.
1337
+ * @param entities to upsert directly in cache.
1338
+ * @param [options] options such as mergeStrategy
1339
+ */
1340
+ upsertManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
1341
+ /**
1342
+ * Set the pattern that the collection's filter applies
1343
+ * when using the `filteredEntities` selector.
1344
+ */
1345
+ setFilter(pattern: any, options?: EntityActionOptions): void;
1346
+ /** Set the loaded flag */
1347
+ setLoaded(isLoaded: boolean, options?: EntityActionOptions): void;
1348
+ /** Set the loading flag */
1349
+ setLoading(isLoading: boolean, options?: EntityActionOptions): void;
1350
+ }
1351
+ /** Commands that dispatch entity actions for a collection */
1352
+ interface EntityCommands<T> extends EntityServerCommands<T>, EntityCacheCommands<T> {
1353
+ }
1354
+
1355
+ declare const ENTITY_CACHE_SELECTOR_TOKEN: InjectionToken<MemoizedSelector<Object, EntityCache, _ngrx_store.DefaultProjectorFn<EntityCache>>>;
1356
+ declare const entityCacheSelectorProvider: FactoryProvider;
1357
+ type EntityCacheSelector = MemoizedSelector<Object, EntityCache>;
1358
+ declare function createEntityCacheSelector(entityCacheName?: string): MemoizedSelector<Object, EntityCache>;
1359
+
1360
+ /**
1361
+ * Dispatches EntityCollection actions to their reducers and effects.
1362
+ * The substance of the interface is in EntityCommands.
1363
+ */
1364
+ interface EntityDispatcher<T> extends EntityCommands<T> {
1365
+ /** Name of the entity type */
1366
+ readonly entityName: string;
1367
+ /**
1368
+ * Utility class with methods to validate EntityAction payloads.
1369
+ */
1370
+ readonly guard: EntityActionGuard<T>;
1371
+ /** Returns the primary key (id) of this entity */
1372
+ readonly selectId: IdSelector<T>;
1373
+ /** Returns the store, scoped to the EntityCache */
1374
+ readonly store: Store<EntityCache>;
1375
+ /**
1376
+ * Create an {EntityAction} for this entity type.
1377
+ * @param op {EntityOp} the entity operation
1378
+ * @param [data] the action data
1379
+ * @param [options] additional options
1380
+ * @returns the EntityAction
1381
+ */
1382
+ createEntityAction<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
1383
+ /**
1384
+ * Create an {EntityAction} for this entity type and
1385
+ * dispatch it immediately to the store.
1386
+ * @param op {EntityOp} the entity operation
1387
+ * @param [data] the action data
1388
+ * @param [options] additional options
1389
+ * @returns the dispatched EntityAction
1390
+ */
1391
+ createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
1392
+ /**
1393
+ * Dispatch an Action to the store.
1394
+ * @param action the Action
1395
+ * @returns the dispatched Action
1396
+ */
1397
+ dispatch(action: Action): Action;
1398
+ /**
1399
+ * Convert an entity (or partial entity) into the `Update<T>` object
1400
+ * `update...` and `upsert...` methods take `Update<T>` args
1401
+ */
1402
+ toUpdate(entity: Partial<T>): Update<T>;
1403
+ }
1404
+ /**
1405
+ * Persistence operation canceled
1406
+ */
1407
+ declare class PersistanceCanceled {
1408
+ readonly message?: string;
1409
+ constructor(message?: string);
1410
+ }
1411
+
1412
+ /**
1413
+ * Dispatches EntityCollection actions to their reducers and effects (default implementation).
1414
+ * All save commands rely on an Ngrx Effect such as `EntityEffects.persist$`.
1415
+ */
1416
+ declare class EntityDispatcherBase<T> implements EntityDispatcher<T> {
1417
+ /** Name of the entity type for which entities are dispatched */
1418
+ entityName: string;
1419
+ /** Creates an {EntityAction} */
1420
+ entityActionFactory: EntityActionFactory;
1421
+ /** The store, scoped to the EntityCache */
1422
+ store: Store<EntityCache>;
1423
+ /** Returns the primary key (id) of this entity */
1424
+ selectId: IdSelector<T>;
1425
+ /**
1426
+ * Dispatcher options configure dispatcher behavior such as
1427
+ * whether add is optimistic or pessimistic by default.
1428
+ */
1429
+ private defaultDispatcherOptions;
1430
+ /** Actions scanned by the store after it processed them with reducers. */
1431
+ private reducedActions$;
1432
+ /** Generates correlation ids for query and save methods */
1433
+ private correlationIdGenerator;
1434
+ /** Utility class with methods to validate EntityAction payloads.*/
1435
+ guard: EntityActionGuard<T>;
1436
+ private entityCollection$;
1437
+ /**
1438
+ * Convert an entity (or partial entity) into the `Update<T>` object
1439
+ * `update...` and `upsert...` methods take `Update<T>` args
1440
+ */
1441
+ toUpdate: (entity: Partial<T>) => Update<T>;
1442
+ constructor(
1443
+ /** Name of the entity type for which entities are dispatched */
1444
+ entityName: string,
1445
+ /** Creates an {EntityAction} */
1446
+ entityActionFactory: EntityActionFactory,
1447
+ /** The store, scoped to the EntityCache */
1448
+ store: Store<EntityCache>,
1449
+ /** Returns the primary key (id) of this entity */
1450
+ selectId: IdSelector<T>,
1451
+ /**
1452
+ * Dispatcher options configure dispatcher behavior such as
1453
+ * whether add is optimistic or pessimistic by default.
1454
+ */
1455
+ defaultDispatcherOptions: EntityDispatcherDefaultOptions,
1456
+ /** Actions scanned by the store after it processed them with reducers. */
1457
+ reducedActions$: Observable<Action>,
1458
+ /** Store selector for the EntityCache */
1459
+ entityCacheSelector: EntityCacheSelector,
1460
+ /** Generates correlation ids for query and save methods */
1461
+ correlationIdGenerator: CorrelationIdGenerator);
1462
+ /**
1463
+ * Create an {EntityAction} for this entity type.
1464
+ * @param entityOp {EntityOp} the entity operation
1465
+ * @param [data] the action data
1466
+ * @param [options] additional options
1467
+ * @returns the EntityAction
1468
+ */
1469
+ createEntityAction<P = any>(entityOp: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
1470
+ /**
1471
+ * Create an {EntityAction} for this entity type and
1472
+ * dispatch it immediately to the store.
1473
+ * @param op {EntityOp} the entity operation
1474
+ * @param [data] the action data
1475
+ * @param [options] additional options
1476
+ * @returns the dispatched EntityAction
1477
+ */
1478
+ createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
1479
+ /**
1480
+ * Dispatch an Action to the store.
1481
+ * @param action the Action
1482
+ * @returns the dispatched Action
1483
+ */
1484
+ dispatch(action: Action): Action;
1485
+ /**
1486
+ * Dispatch action to save a new entity to remote storage.
1487
+ * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
1488
+ * must have a key if optimistic save.
1489
+ * @returns A terminating Observable of the entity
1490
+ * after server reports successful save or the save error.
1491
+ */
1492
+ add(entity: T, options?: EntityActionOptions): Observable<T>;
1493
+ /**
1494
+ * Dispatch action to cancel the persistence operation (query or save).
1495
+ * Will cause save observable to error with a PersistenceCancel error.
1496
+ * Caller is responsible for undoing changes in cache from pending optimistic save
1497
+ * @param correlationId The correlation id for the corresponding EntityAction
1498
+ * @param [reason] explains why canceled and by whom.
1499
+ */
1500
+ cancel(correlationId: any, reason?: string, options?: EntityActionOptions): void;
1501
+ /**
1502
+ * Dispatch action to delete entity from remote storage by key.
1503
+ * @param key The primary key of the entity to remove
1504
+ * @returns A terminating Observable of the deleted key
1505
+ * after server reports successful save or the save error.
1506
+ */
1507
+ delete(entity: T, options?: EntityActionOptions): Observable<number | string>;
1508
+ /**
1509
+ * Dispatch action to delete entity from remote storage by key.
1510
+ * @param key The entity to delete
1511
+ * @returns A terminating Observable of the deleted key
1512
+ * after server reports successful save or the save error.
1513
+ */
1514
+ delete(key: number | string, options?: EntityActionOptions): Observable<number | string>;
1515
+ /**
1516
+ * Dispatch action to query remote storage for all entities and
1517
+ * merge the queried entities into the cached collection.
1518
+ * @returns A terminating Observable of the queried entities that are in the collection
1519
+ * after server reports success query or the query error.
1520
+ * @see load()
1521
+ */
1522
+ getAll(options?: EntityActionOptions): Observable<T[]>;
1523
+ /**
1524
+ * Dispatch action to query remote storage for the entity with this primary key.
1525
+ * If the server returns an entity,
1526
+ * merge it into the cached collection.
1527
+ * @returns A terminating Observable of the collection
1528
+ * after server reports successful query or the query error.
1529
+ */
1530
+ getByKey(key: any, options?: EntityActionOptions): Observable<T>;
1531
+ /**
1532
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
1533
+ * with either a query parameter map or an HTTP URL query string,
1534
+ * and merge the results into the cached collection.
1535
+ * @param queryParams the query in a form understood by the server
1536
+ * @returns A terminating Observable of the queried entities
1537
+ * after server reports successful query or the query error.
1538
+ */
1539
+ getWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
1540
+ /**
1541
+ * Dispatch action to query remote storage for all entities and
1542
+ * completely replace the cached collection with the queried entities.
1543
+ * @returns A terminating Observable of the entities in the collection
1544
+ * after server reports successful query or the query error.
1545
+ * @see getAll
1546
+ */
1547
+ load(options?: EntityActionOptions): Observable<T[]>;
1548
+ /**
1549
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
1550
+ * with either a query parameter map or an HTTP URL query string,
1551
+ * and completely replace the cached collection with the queried entities.
1552
+ * @param queryParams the query in a form understood by the server
1553
+ * @param [options] options that influence load behavior
1554
+ * @returns A terminating Observable of the queried entities
1555
+ * after server reports successful query or the query error.
1556
+ */
1557
+ loadWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
1558
+ /**
1559
+ * Dispatch action to save the updated entity (or partial entity) in remote storage.
1560
+ * The update entity may be partial (but must have its key)
1561
+ * in which case it patches the existing entity.
1562
+ * @param entity update entity, which might be a partial of T but must at least have its key.
1563
+ * @returns A terminating Observable of the updated entity
1564
+ * after server reports successful save or the save error.
1565
+ */
1566
+ update(entity: Partial<T>, options?: EntityActionOptions): Observable<T>;
1567
+ /**
1568
+ * Dispatch action to save a new or existing entity to remote storage.
1569
+ * Only dispatch this action if your server supports upsert.
1570
+ * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
1571
+ * must have a key if optimistic save.
1572
+ * @returns A terminating Observable of the entity
1573
+ * after server reports successful save or the save error.
1574
+ */
1575
+ upsert(entity: T, options?: EntityActionOptions): Observable<T>;
1576
+ /**
1577
+ * Replace all entities in the cached collection.
1578
+ * Does not save to remote storage.
1579
+ */
1580
+ addAllToCache(entities: T[], options?: EntityActionOptions): void;
1581
+ /**
1582
+ * Add a new entity directly to the cache.
1583
+ * Does not save to remote storage.
1584
+ * Ignored if an entity with the same primary key is already in cache.
1585
+ */
1586
+ addOneToCache(entity: T, options?: EntityActionOptions): void;
1587
+ /**
1588
+ * Add multiple new entities directly to the cache.
1589
+ * Does not save to remote storage.
1590
+ * Entities with primary keys already in cache are ignored.
1591
+ */
1592
+ addManyToCache(entities: T[], options?: EntityActionOptions): void;
1593
+ /** Clear the cached entity collection */
1594
+ clearCache(options?: EntityActionOptions): void;
1595
+ /**
1596
+ * Remove an entity directly from the cache.
1597
+ * Does not delete that entity from remote storage.
1598
+ * @param entity The entity to remove
1599
+ */
1600
+ removeOneFromCache(entity: T, options?: EntityActionOptions): void;
1601
+ /**
1602
+ * Remove an entity directly from the cache.
1603
+ * Does not delete that entity from remote storage.
1604
+ * @param key The primary key of the entity to remove
1605
+ */
1606
+ removeOneFromCache(key: number | string, options?: EntityActionOptions): void;
1607
+ /**
1608
+ * Remove multiple entities directly from the cache.
1609
+ * Does not delete these entities from remote storage.
1610
+ * @param entity The entities to remove
1611
+ */
1612
+ removeManyFromCache(entities: T[], options?: EntityActionOptions): void;
1613
+ /**
1614
+ * Remove multiple entities directly from the cache.
1615
+ * Does not delete these entities from remote storage.
1616
+ * @param keys The primary keys of the entities to remove
1617
+ */
1618
+ removeManyFromCache(keys: (number | string)[], options?: EntityActionOptions): void;
1619
+ /**
1620
+ * Update a cached entity directly.
1621
+ * Does not update that entity in remote storage.
1622
+ * Ignored if an entity with matching primary key is not in cache.
1623
+ * The update entity may be partial (but must have its key)
1624
+ * in which case it patches the existing entity.
1625
+ */
1626
+ updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
1627
+ /**
1628
+ * Update multiple cached entities directly.
1629
+ * Does not update these entities in remote storage.
1630
+ * Entities whose primary keys are not in cache are ignored.
1631
+ * Update entities may be partial but must at least have their keys.
1632
+ * such partial entities patch their cached counterparts.
1633
+ */
1634
+ updateManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
1635
+ /**
1636
+ * Add or update a new entity directly to the cache.
1637
+ * Does not save to remote storage.
1638
+ * Upsert entity might be a partial of T but must at least have its key.
1639
+ * Pass the Update<T> structure as the payload
1640
+ */
1641
+ upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
1642
+ /**
1643
+ * Add or update multiple cached entities directly.
1644
+ * Does not save to remote storage.
1645
+ */
1646
+ upsertManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
1647
+ /**
1648
+ * Set the pattern that the collection's filter applies
1649
+ * when using the `filteredEntities` selector.
1650
+ */
1651
+ setFilter(pattern: any): void;
1652
+ /** Set the loaded flag */
1653
+ setLoaded(isLoaded: boolean): void;
1654
+ /** Set the loading flag */
1655
+ setLoading(isLoading: boolean): void;
1656
+ /** Get key from entity (unless arg is already a key) */
1657
+ private getKey;
1658
+ /**
1659
+ * Return Observable of data from the server-success EntityAction with
1660
+ * the given Correlation Id, after that action was processed by the ngrx store.
1661
+ * or else put the server error on the Observable error channel.
1662
+ * @param crid The correlationId for both the save and response actions.
1663
+ */
1664
+ private getResponseData$;
1665
+ private setQueryEntityActionOptions;
1666
+ private setSaveEntityActionOptions;
1667
+ }
1668
+
1669
+ /** Creates EntityDispatchers for entity collections */
1670
+ declare class EntityDispatcherFactory implements OnDestroy {
1671
+ private entityActionFactory;
1672
+ private store;
1673
+ private entityDispatcherDefaultOptions;
1674
+ private entityCacheSelector;
1675
+ private correlationIdGenerator;
1676
+ /**
1677
+ * Actions scanned by the store after it processed them with reducers.
1678
+ * A replay observable of the most recent action reduced by the store.
1679
+ */
1680
+ reducedActions$: Observable<Action>;
1681
+ private raSubscription;
1682
+ constructor(entityActionFactory: EntityActionFactory, store: Store<EntityCache>, entityDispatcherDefaultOptions: EntityDispatcherDefaultOptions, scannedActions$: Observable<Action>, entityCacheSelector: EntityCacheSelector, correlationIdGenerator: CorrelationIdGenerator);
1683
+ /**
1684
+ * Create an `EntityDispatcher` for an entity type `T` and store.
1685
+ */
1686
+ create<T>(
1687
+ /** Name of the entity type */
1688
+ entityName: string,
1689
+ /**
1690
+ * Function that returns the primary key for an entity `T`.
1691
+ * Usually acquired from `EntityDefinition` metadata.
1692
+ * @param {IdSelector<T>} selectId
1693
+ */
1694
+ selectId?: IdSelector<T>,
1695
+ /** Defaults for options that influence dispatcher behavior such as whether
1696
+ * `add()` is optimistic or pessimistic;
1697
+ * @param {Partial<EntityDispatcherDefaultOptions>} defaultOptions
1698
+ */
1699
+ defaultOptions?: Partial<EntityDispatcherDefaultOptions>): EntityDispatcher<T>;
1700
+ ngOnDestroy(): void;
1701
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDispatcherFactory, never>;
1702
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityDispatcherFactory>;
1703
+ }
1704
+
1705
+ declare class EntityCacheEffects {
1706
+ private actions;
1707
+ private dataService;
1708
+ private entityActionFactory;
1709
+ private logger;
1710
+ /**
1711
+ * Injecting an optional Scheduler that will be undefined
1712
+ * in normal application usage, but its injected here so that you can mock out
1713
+ * during testing using the RxJS TestScheduler for simulating passages of time.
1714
+ */
1715
+ private scheduler;
1716
+ /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */
1717
+ private responseDelay;
1718
+ constructor(actions: Actions, dataService: EntityCacheDataService, entityActionFactory: EntityActionFactory, logger: Logger,
1719
+ /**
1720
+ * Injecting an optional Scheduler that will be undefined
1721
+ * in normal application usage, but its injected here so that you can mock out
1722
+ * during testing using the RxJS TestScheduler for simulating passages of time.
1723
+ */
1724
+ scheduler: SchedulerLike);
1725
+ /**
1726
+ * Observable of SAVE_ENTITIES_CANCEL actions with non-null correlation ids
1727
+ */
1728
+ saveEntitiesCancel$: Observable<SaveEntitiesCancel>;
1729
+ saveEntities$: Observable<Action>;
1730
+ /**
1731
+ * Perform the requested SaveEntities actions and return a scalar Observable<Action>
1732
+ * that the effect should dispatch to the store after the server responds.
1733
+ * @param action The SaveEntities action
1734
+ */
1735
+ saveEntities(action: SaveEntities): Observable<Action>;
1736
+ /** return handler of error result of saveEntities, returning a scalar observable of error action */
1737
+ private handleSaveEntitiesError$;
1738
+ /** return handler of the ChangeSet result of successful saveEntities() */
1739
+ private handleSaveEntitiesSuccess$;
1740
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheEffects, [null, null, null, null, { optional: true; }]>;
1741
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheEffects>;
1742
+ }
1743
+
1744
+ declare const persistOps: EntityOp[];
1745
+ declare class EntityEffects {
1746
+ private actions;
1747
+ private dataService;
1748
+ private entityActionFactory;
1749
+ private resultHandler;
1750
+ /**
1751
+ * Injecting an optional Scheduler that will be undefined
1752
+ * in normal application usage, but its injected here so that you can mock out
1753
+ * during testing using the RxJS TestScheduler for simulating passages of time.
1754
+ */
1755
+ private scheduler;
1756
+ /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */
1757
+ private responseDelay;
1758
+ /**
1759
+ * Observable of non-null cancellation correlation ids from CANCEL_PERSIST actions
1760
+ */
1761
+ cancel$: Observable<any>;
1762
+ persist$: Observable<Action>;
1763
+ constructor(actions: Actions<EntityAction>, dataService: EntityDataService, entityActionFactory: EntityActionFactory, resultHandler: PersistenceResultHandler,
1764
+ /**
1765
+ * Injecting an optional Scheduler that will be undefined
1766
+ * in normal application usage, but its injected here so that you can mock out
1767
+ * during testing using the RxJS TestScheduler for simulating passages of time.
1768
+ */
1769
+ scheduler: SchedulerLike);
1770
+ /**
1771
+ * Perform the requested persistence operation and return a scalar Observable<Action>
1772
+ * that the effect should dispatch to the store after the server responds.
1773
+ * @param action A persistence operation EntityAction
1774
+ */
1775
+ persist(action: EntityAction): Observable<Action>;
1776
+ private callDataService;
1777
+ /**
1778
+ * Handle error result of persistence operation on an EntityAction,
1779
+ * returning a scalar observable of error action
1780
+ */
1781
+ private handleError$;
1782
+ /**
1783
+ * Because EntityAction.payload.skip is true, skip the persistence step and
1784
+ * return a scalar success action that looks like the operation succeeded.
1785
+ */
1786
+ private handleSkipSuccess$;
1787
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityEffects, [null, null, null, null, { optional: true; }]>;
1788
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityEffects>;
1789
+ }
1790
+
1791
+ declare class EntityCollectionCreator {
1792
+ private entityDefinitionService?;
1793
+ constructor(entityDefinitionService?: EntityDefinitionService);
1794
+ /**
1795
+ * Create the default collection for an entity type.
1796
+ * @param entityName {string} entity type name
1797
+ */
1798
+ create<T = any, S extends EntityCollection<T> = EntityCollection<T>>(entityName: string): S;
1799
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionCreator, [{ optional: true; }]>;
1800
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionCreator>;
1801
+ }
1802
+ declare function createEmptyEntityCollection<T>(entityName?: string): EntityCollection<T>;
1803
+
1804
+ /**
1805
+ * The selector functions for entity collection members,
1806
+ * Selects from the entity collection to the collection member
1807
+ * Contrast with {EntitySelectors}.
1808
+ */
1809
+ interface CollectionSelectors<T> {
1810
+ readonly [selector: string]: any;
1811
+ /** Count of entities in the cached collection. */
1812
+ readonly selectCount: Selector<EntityCollection<T>, number>;
1813
+ /** All entities in the cached collection. */
1814
+ readonly selectEntities: Selector<EntityCollection<T>, T[]>;
1815
+ /** Map of entity keys to entities */
1816
+ readonly selectEntityMap: Selector<EntityCollection<T>, Dictionary<T>>;
1817
+ /** Filter pattern applied by the entity collection's filter function */
1818
+ readonly selectFilter: Selector<EntityCollection<T>, string>;
1819
+ /** Entities in the cached collection that pass the filter function */
1820
+ readonly selectFilteredEntities: Selector<EntityCollection<T>, T[]>;
1821
+ /** Keys of the cached collection, in the collection's native sort order */
1822
+ readonly selectKeys: Selector<EntityCollection<T>, string[] | number[]>;
1823
+ /** True when the collection has been fully loaded. */
1824
+ readonly selectLoaded: Selector<EntityCollection<T>, boolean>;
1825
+ /** True when a multi-entity query command is in progress. */
1826
+ readonly selectLoading: Selector<EntityCollection<T>, boolean>;
1827
+ /** ChangeState (including original values) of entities with unsaved changes */
1828
+ readonly selectChangeState: Selector<EntityCollection<T>, ChangeStateMap<T>>;
1829
+ }
1830
+ /**
1831
+ * The selector functions for entity collection members,
1832
+ * Selects from store root, through EntityCache, to the entity collection member
1833
+ * Contrast with {CollectionSelectors}.
1834
+ */
1835
+ interface EntitySelectors<T> {
1836
+ /** Name of the entity collection for these selectors */
1837
+ readonly entityName: string;
1838
+ readonly [name: string]: MemoizedSelector<EntityCollection<T>, any> | string;
1839
+ /** The cached EntityCollection itself */
1840
+ readonly selectCollection: MemoizedSelector<Object, EntityCollection<T>>;
1841
+ /** Count of entities in the cached collection. */
1842
+ readonly selectCount: MemoizedSelector<Object, number>;
1843
+ /** All entities in the cached collection. */
1844
+ readonly selectEntities: MemoizedSelector<Object, T[]>;
1845
+ /** The EntityCache */
1846
+ readonly selectEntityCache: MemoizedSelector<Object, EntityCache>;
1847
+ /** Map of entity keys to entities */
1848
+ readonly selectEntityMap: MemoizedSelector<Object, Dictionary<T>>;
1849
+ /** Filter pattern applied by the entity collection's filter function */
1850
+ readonly selectFilter: MemoizedSelector<Object, string>;
1851
+ /** Entities in the cached collection that pass the filter function */
1852
+ readonly selectFilteredEntities: MemoizedSelector<Object, T[]>;
1853
+ /** Keys of the cached collection, in the collection's native sort order */
1854
+ readonly selectKeys: MemoizedSelector<Object, string[] | number[]>;
1855
+ /** True when the collection has been fully loaded. */
1856
+ readonly selectLoaded: MemoizedSelector<Object, boolean>;
1857
+ /** True when a multi-entity query command is in progress. */
1858
+ readonly selectLoading: MemoizedSelector<Object, boolean>;
1859
+ /** ChangeState (including original values) of entities with unsaved changes */
1860
+ readonly selectChangeState: MemoizedSelector<Object, ChangeStateMap<T>>;
1861
+ }
1862
+ /** Creates EntitySelector functions for entity collections. */
1863
+ declare class EntitySelectorsFactory {
1864
+ private entityCollectionCreator;
1865
+ private selectEntityCache;
1866
+ constructor(entityCollectionCreator?: EntityCollectionCreator, selectEntityCache?: EntityCacheSelector);
1867
+ /**
1868
+ * Create the NgRx selector from the store root to the named collection,
1869
+ * e.g. from Object to Heroes.
1870
+ * @param entityName the name of the collection
1871
+ */
1872
+ createCollectionSelector<T = any, C extends EntityCollection<T> = EntityCollection<T>>(entityName: string): MemoizedSelector<Object, C, (s1: EntityCache) => C>;
1873
+ /**
1874
+ * Creates entity collection selectors from metadata.
1875
+ * @param metadata - EntityMetadata for the collection.
1876
+ * May be partial but much have `entityName`.
1877
+ */
1878
+ createCollectionSelectors<T, S extends CollectionSelectors<T> = CollectionSelectors<T>>(metadata: EntityMetadata<T>): S;
1879
+ /**
1880
+ * Creates default entity collection selectors for an entity type.
1881
+ * Use the metadata overload for additional collection selectors.
1882
+ * @param entityName - name of the entity type
1883
+ */
1884
+ createCollectionSelectors<T, S extends CollectionSelectors<T> = CollectionSelectors<T>>(entityName: string): S;
1885
+ /**
1886
+ * Creates the store-rooted selectors for an entity collection.
1887
+ * {EntitySelectors$Factory} turns them into selectors$.
1888
+ *
1889
+ * @param metadata - EntityMetadata for the collection.
1890
+ * May be partial but much have `entityName`.
1891
+ *
1892
+ * Based on ngrx/entity/state_selectors.ts
1893
+ * Differs in that these selectors select from the NgRx store root,
1894
+ * through the collection, to the collection members.
1895
+ */
1896
+ create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(metadata: EntityMetadata<T>): S;
1897
+ /**
1898
+ * Creates the default store-rooted selectors for an entity collection.
1899
+ * {EntitySelectors$Factory} turns them into selectors$.
1900
+ * Use the metadata overload for additional collection selectors.
1901
+ *
1902
+ * @param entityName - name of the entity type.
1903
+ *
1904
+ * Based on ngrx/entity/state_selectors.ts
1905
+ * Differs in that these selectors select from the NgRx store root,
1906
+ * through the collection, to the collection members.
1907
+ */
1908
+ create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(entityName: string): S;
1909
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntitySelectorsFactory, [{ optional: true; }, { optional: true; }]>;
1910
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntitySelectorsFactory>;
1911
+ }
1912
+
1913
+ /**
1914
+ * The selector observable functions for entity collection members.
1915
+ */
1916
+ interface EntitySelectors$<T> {
1917
+ /** Name of the entity collection for these selectors$ */
1918
+ readonly entityName: string;
1919
+ /** Names from custom selectors from additionalCollectionState fits here, 'any' to avoid conflict with entityName */
1920
+ readonly [name: string]: Observable<any> | Store<any> | any;
1921
+ /** Observable of the collection as a whole */
1922
+ readonly collection$: Observable<EntityCollection> | Store<EntityCollection>;
1923
+ /** Observable of count of entities in the cached collection. */
1924
+ readonly count$: Observable<number> | Store<number>;
1925
+ /** Observable of all entities in the cached collection. */
1926
+ readonly entities$: Observable<T[]> | Store<T[]>;
1927
+ /** Observable of actions related to this entity type. */
1928
+ readonly entityActions$: Observable<EntityAction>;
1929
+ /** Observable of the map of entity keys to entities */
1930
+ readonly entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;
1931
+ /** Observable of error actions related to this entity type. */
1932
+ readonly errors$: Observable<EntityAction>;
1933
+ /** Observable of the filter pattern applied by the entity collection's filter function */
1934
+ readonly filter$: Observable<string> | Store<string>;
1935
+ /** Observable of entities in the cached collection that pass the filter function */
1936
+ readonly filteredEntities$: Observable<T[]> | Store<T[]>;
1937
+ /** Observable of the keys of the cached collection, in the collection's native sort order */
1938
+ readonly keys$: Observable<string[] | number[]> | Store<string[] | number[]>;
1939
+ /** Observable true when the collection has been loaded */
1940
+ readonly loaded$: Observable<boolean> | Store<boolean>;
1941
+ /** Observable true when a multi-entity query command is in progress. */
1942
+ readonly loading$: Observable<boolean> | Store<boolean>;
1943
+ /** ChangeState (including original values) of entities with unsaved changes */
1944
+ readonly changeState$: Observable<ChangeStateMap<T>> | Store<ChangeStateMap<T>>;
1945
+ }
1946
+ /** Creates observable EntitySelectors$ for entity collections. */
1947
+ declare class EntitySelectors$Factory {
1948
+ private store;
1949
+ private actions;
1950
+ private selectEntityCache;
1951
+ /** Observable of the EntityCache */
1952
+ entityCache$: Observable<EntityCache>;
1953
+ /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
1954
+ entityActionErrors$: Observable<EntityAction>;
1955
+ constructor(store: Store<any>, actions: Actions<EntityAction>, selectEntityCache: EntityCacheSelector);
1956
+ /**
1957
+ * Creates an entity collection's selectors$ observables for this factory's store.
1958
+ * `selectors$` are observable selectors of the cached entity collection.
1959
+ * @param entityName - is also the name of the collection.
1960
+ * @param selectors - selector functions for this collection.
1961
+ **/
1962
+ create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string, selectors: EntitySelectors<T>): S$;
1963
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntitySelectors$Factory, never>;
1964
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntitySelectors$Factory>;
1965
+ }
1966
+
1967
+ /**
1968
+ * A facade for managing
1969
+ * a cached collection of T entities in the ngrx store.
1970
+ */
1971
+ interface EntityCollectionService<T> extends EntityCommands<T>, EntitySelectors$<T> {
1972
+ /**
1973
+ * Create an {EntityAction} for this entity type.
1974
+ * @param op {EntityOp} the entity operation
1975
+ * @param [data] the action data
1976
+ * @param [options] additional options
1977
+ * @returns the EntityAction
1978
+ */
1979
+ createEntityAction(op: EntityOp, payload?: any, options?: EntityActionOptions): EntityAction<T>;
1980
+ /**
1981
+ * Create an {EntityAction} for this entity type and
1982
+ * dispatch it immediately to the store.
1983
+ * @param op {EntityOp} the entity operation
1984
+ * @param [data] the action data
1985
+ * @param [options] additional options
1986
+ * @returns the dispatched EntityAction
1987
+ */
1988
+ createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
1989
+ /** Dispatcher of EntityCommands (EntityActions) */
1990
+ readonly dispatcher: EntityDispatcher<T>;
1991
+ /** Name of the entity type for this collection service */
1992
+ readonly entityName: string;
1993
+ /** All selector functions of the entity collection */
1994
+ readonly selectors: EntitySelectors<T>;
1995
+ /** All selectors$ (observables of the selectors of entity collection properties) */
1996
+ readonly selectors$: EntitySelectors$<T>;
1997
+ }
1998
+
1999
+ /** Core ingredients of an EntityCollectionService */
2000
+ interface EntityCollectionServiceElements<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>> {
2001
+ readonly dispatcher: EntityDispatcher<T>;
2002
+ readonly entityName: string;
2003
+ readonly selectors: EntitySelectors<T>;
2004
+ readonly selectors$: S$;
2005
+ }
2006
+ /** Creates the core elements of the EntityCollectionService for an entity type. */
2007
+ declare class EntityCollectionServiceElementsFactory {
2008
+ private entityDispatcherFactory;
2009
+ private entityDefinitionService;
2010
+ private entitySelectorsFactory;
2011
+ private entitySelectors$Factory;
2012
+ constructor(entityDispatcherFactory: EntityDispatcherFactory, entityDefinitionService: EntityDefinitionService, entitySelectorsFactory: EntitySelectorsFactory, entitySelectors$Factory: EntitySelectors$Factory);
2013
+ /**
2014
+ * Get the ingredients for making an EntityCollectionService for this entity type
2015
+ * @param entityName - name of the entity type
2016
+ */
2017
+ create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionServiceElements<T, S$>;
2018
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionServiceElementsFactory, never>;
2019
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionServiceElementsFactory>;
2020
+ }
2021
+
2022
+ /**
2023
+ * Base class for a concrete EntityCollectionService<T>.
2024
+ * Can be instantiated. Cannot be injected. Use EntityCollectionServiceFactory to create.
2025
+ * @param EntityCollectionServiceElements The ingredients for this service
2026
+ * as a source of supporting services for creating an EntityCollectionService<T> instance.
2027
+ */
2028
+ declare class EntityCollectionServiceBase<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>> implements EntityCollectionService<T> {
2029
+ /** Name of the entity type of this collection service */
2030
+ readonly entityName: string;
2031
+ /** Dispatcher of EntityCommands (EntityActions) */
2032
+ readonly dispatcher: EntityDispatcher<T>;
2033
+ /** All selectors of entity collection properties */
2034
+ readonly selectors: EntitySelectors<T>;
2035
+ /** All selectors$ (observables of entity collection properties) */
2036
+ readonly selectors$: S$;
2037
+ constructor(
2038
+ /** Name of the entity type of this collection service */
2039
+ entityName: string,
2040
+ /** Creates the core elements of the EntityCollectionService for this entity type */
2041
+ serviceElementsFactory: EntityCollectionServiceElementsFactory);
2042
+ /**
2043
+ * Create an {EntityAction} for this entity type.
2044
+ * @param op {EntityOp} the entity operation
2045
+ * @param [data] the action data
2046
+ * @param [options] additional options
2047
+ * @returns the EntityAction
2048
+ */
2049
+ createEntityAction<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
2050
+ /**
2051
+ * Create an {EntityAction} for this entity type and
2052
+ * dispatch it immediately to the store.
2053
+ * @param op {EntityOp} the entity operation
2054
+ * @param [data] the action data
2055
+ * @param [options] additional options
2056
+ * @returns the dispatched EntityAction
2057
+ */
2058
+ createAndDispatch<P = any>(op: EntityOp, data?: P, options?: EntityActionOptions): EntityAction<P>;
2059
+ /**
2060
+ * Dispatch an action of any type to the ngrx store.
2061
+ * @param action the Action
2062
+ * @returns the dispatched Action
2063
+ */
2064
+ dispatch(action: Action): Action;
2065
+ /** The NgRx Store for the {EntityCache} */
2066
+ get store(): Store<_ngrx_data.EntityCache>;
2067
+ /**
2068
+ * Utility class with methods to validate EntityAction payloads.
2069
+ */
2070
+ guard: EntityActionGuard<T>;
2071
+ /** Returns the primary key (id) of this entity */
2072
+ selectId: IdSelector<T>;
2073
+ /**
2074
+ * Convert an entity (or partial entity) into the `Update<T>` object
2075
+ * `update...` and `upsert...` methods take `Update<T>` args
2076
+ */
2077
+ toUpdate: (entity: Partial<T>) => Update<T>;
2078
+ /**
2079
+ * Dispatch action to save a new entity to remote storage.
2080
+ * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;
2081
+ * must have a key if optimistic save.
2082
+ * @param [options] options that influence save and merge behavior
2083
+ * @returns Observable of the entity
2084
+ * after server reports successful save or the save error.
2085
+ */
2086
+ add(entity: Partial<T>, options: EntityActionOptions & {
2087
+ isOptimistic: false;
2088
+ }): Observable<T>;
2089
+ add(entity: T, options?: EntityActionOptions): Observable<T>;
2090
+ /**
2091
+ * Dispatch action to cancel the persistence operation (query or save) with the given correlationId.
2092
+ * @param correlationId The correlation id for the corresponding EntityAction
2093
+ * @param [reason] explains why canceled and by whom.
2094
+ * @param [options] options such as the tag and mergeStrategy
2095
+ */
2096
+ cancel(correlationId: any, reason?: string, options?: EntityActionOptions): void;
2097
+ /**
2098
+ * Dispatch action to delete entity from remote storage by key.
2099
+ * @param key The entity to delete
2100
+ * @param [options] options that influence save and merge behavior
2101
+ * @returns Observable of the deleted key
2102
+ * after server reports successful save or the save error.
2103
+ */
2104
+ delete(entity: T, options?: EntityActionOptions): Observable<number | string>;
2105
+ /**
2106
+ * Dispatch action to delete entity from remote storage by key.
2107
+ * @param key The primary key of the entity to remove
2108
+ * @param [options] options that influence save and merge behavior
2109
+ * @returns Observable of the deleted key
2110
+ * after server reports successful save or the save error.
2111
+ */
2112
+ delete(key: number | string, options?: EntityActionOptions): Observable<number | string>;
2113
+ /**
2114
+ * Dispatch action to query remote storage for all entities and
2115
+ * merge the queried entities into the cached collection.
2116
+ * @param [options] options that influence merge behavior
2117
+ * @returns Observable of the collection
2118
+ * after server reports successful query or the query error.
2119
+ * @see load()
2120
+ */
2121
+ getAll(options?: EntityActionOptions): Observable<T[]>;
2122
+ /**
2123
+ * Dispatch action to query remote storage for the entity with this primary key.
2124
+ * If the server returns an entity,
2125
+ * merge it into the cached collection.
2126
+ * @param key The primary key of the entity to get.
2127
+ * @param [options] options that influence merge behavior
2128
+ * @returns Observable of the queried entity that is in the collection
2129
+ * after server reports success or the query error.
2130
+ */
2131
+ getByKey(key: any, options?: EntityActionOptions): Observable<T>;
2132
+ /**
2133
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
2134
+ * with either a query parameter map or an HTTP URL query string,
2135
+ * and merge the results into the cached collection.
2136
+ * @param queryParams the query in a form understood by the server
2137
+ * @param [options] options that influence merge behavior
2138
+ * @returns Observable of the queried entities
2139
+ * after server reports successful query or the query error.
2140
+ */
2141
+ getWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
2142
+ /**
2143
+ * Dispatch action to query remote storage for all entities and
2144
+ * completely replace the cached collection with the queried entities.
2145
+ * @param [options] options that influence load behavior
2146
+ * @returns Observable of the collection
2147
+ * after server reports successful query or the query error.
2148
+ * @see getAll
2149
+ */
2150
+ load(options?: EntityActionOptions): Observable<T[]>;
2151
+ /**
2152
+ * Dispatch action to query remote storage for the entities that satisfy a query expressed
2153
+ * with either a query parameter map or an HTTP URL query string,
2154
+ * and completely replace the cached collection with the queried entities.
2155
+ * @param queryParams the query in a form understood by the server
2156
+ * @param [options] options that influence load behavior
2157
+ * @returns Observable of the queried entities
2158
+ * after server reports successful query or the query error.
2159
+ */
2160
+ loadWithQuery(queryParams: QueryParams | string, options?: EntityActionOptions): Observable<T[]>;
2161
+ /**
2162
+ * Dispatch action to save the updated entity (or partial entity) in remote storage.
2163
+ * The update entity may be partial (but must have its key)
2164
+ * in which case it patches the existing entity.
2165
+ * @param entity update entity, which might be a partial of T but must at least have its key.
2166
+ * @param [options] options that influence save and merge behavior
2167
+ * @returns Observable of the updated entity
2168
+ * after server reports successful save or the save error.
2169
+ */
2170
+ update(entity: Partial<T>, options?: EntityActionOptions): Observable<T>;
2171
+ /**
2172
+ * Dispatch action to save a new or existing entity to remote storage.
2173
+ * Call only if the server supports upsert.
2174
+ * @param entity entity to add or upsert.
2175
+ * It may omit its key if an add, and is pessimistic, and the server creates the key;
2176
+ * must have a key if optimistic save.
2177
+ * @param [options] options that influence save and merge behavior
2178
+ * @returns Observable of the entity
2179
+ * after server reports successful save or the save error.
2180
+ */
2181
+ upsert(entity: T, options?: EntityActionOptions): Observable<T>;
2182
+ /*** Cache-only operations that do not update remote storage ***/
2183
+ /**
2184
+ * Replace all entities in the cached collection.
2185
+ * Does not save to remote storage.
2186
+ * @param entities to add directly to cache.
2187
+ * @param [options] options such as mergeStrategy
2188
+ */
2189
+ addAllToCache(entities: T[], options?: EntityActionOptions): void;
2190
+ /**
2191
+ * Add a new entity directly to the cache.
2192
+ * Does not save to remote storage.
2193
+ * Ignored if an entity with the same primary key is already in cache.
2194
+ * @param entity to add directly to cache.
2195
+ * @param [options] options such as mergeStrategy
2196
+ */
2197
+ addOneToCache(entity: T, options?: EntityActionOptions): void;
2198
+ /**
2199
+ * Add multiple new entities directly to the cache.
2200
+ * Does not save to remote storage.
2201
+ * Entities with primary keys already in cache are ignored.
2202
+ * @param entities to add directly to cache.
2203
+ * @param [options] options such as mergeStrategy
2204
+ */
2205
+ addManyToCache(entities: T[], options?: EntityActionOptions): void;
2206
+ /** Clear the cached entity collection */
2207
+ clearCache(): void;
2208
+ /**
2209
+ * Remove an entity directly from the cache.
2210
+ * Does not delete that entity from remote storage.
2211
+ * @param entity The entity to remove
2212
+ * @param [options] options such as mergeStrategy
2213
+ */
2214
+ removeOneFromCache(entity: T, options?: EntityActionOptions): void;
2215
+ /**
2216
+ * Remove an entity directly from the cache.
2217
+ * Does not delete that entity from remote storage.
2218
+ * @param key The primary key of the entity to remove
2219
+ * @param [options] options such as mergeStrategy
2220
+ */
2221
+ removeOneFromCache(key: number | string, options?: EntityActionOptions): void;
2222
+ /**
2223
+ * Remove multiple entities directly from the cache.
2224
+ * Does not delete these entities from remote storage.
2225
+ * @param entity The entities to remove
2226
+ * @param [options] options such as mergeStrategy
2227
+ */
2228
+ removeManyFromCache(entities: T[], options?: EntityActionOptions): void;
2229
+ /**
2230
+ * Remove multiple entities directly from the cache.
2231
+ * Does not delete these entities from remote storage.
2232
+ * @param keys The primary keys of the entities to remove
2233
+ * @param [options] options such as mergeStrategy
2234
+ */
2235
+ removeManyFromCache(keys: (number | string)[], options?: EntityActionOptions): void;
2236
+ /**
2237
+ * Update a cached entity directly.
2238
+ * Does not update that entity in remote storage.
2239
+ * Ignored if an entity with matching primary key is not in cache.
2240
+ * The update entity may be partial (but must have its key)
2241
+ * in which case it patches the existing entity.
2242
+ * @param entity to update directly in cache.
2243
+ * @param [options] options such as mergeStrategy
2244
+ */
2245
+ updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
2246
+ /**
2247
+ * Update multiple cached entities directly.
2248
+ * Does not update these entities in remote storage.
2249
+ * Entities whose primary keys are not in cache are ignored.
2250
+ * Update entities may be partial but must at least have their keys.
2251
+ * such partial entities patch their cached counterparts.
2252
+ * @param entities to update directly in cache.
2253
+ * @param [options] options such as mergeStrategy
2254
+ */
2255
+ updateManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
2256
+ /**
2257
+ * Insert or update a cached entity directly.
2258
+ * Does not save to remote storage.
2259
+ * Upsert entity might be a partial of T but must at least have its key.
2260
+ * Pass the Update<T> structure as the payload.
2261
+ * @param entity to upsert directly in cache.
2262
+ * @param [options] options such as mergeStrategy
2263
+ */
2264
+ upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void;
2265
+ /**
2266
+ * Insert or update multiple cached entities directly.
2267
+ * Does not save to remote storage.
2268
+ * Upsert entities might be partial but must at least have their keys.
2269
+ * Pass an array of the Update<T> structure as the payload.
2270
+ * @param entities to upsert directly in cache.
2271
+ * @param [options] options such as mergeStrategy
2272
+ */
2273
+ upsertManyInCache(entities: Partial<T>[], options?: EntityActionOptions): void;
2274
+ /**
2275
+ * Set the pattern that the collection's filter applies
2276
+ * when using the `filteredEntities` selector.
2277
+ */
2278
+ setFilter(pattern: any): void;
2279
+ /** Set the loaded flag */
2280
+ setLoaded(isLoaded: boolean): void;
2281
+ /** Set the loading flag */
2282
+ setLoading(isLoading: boolean): void;
2283
+ /** Observable of the collection as a whole */
2284
+ collection$: Observable<EntityCollection<T>> | Store<EntityCollection<T>>;
2285
+ /** Observable of count of entities in the cached collection. */
2286
+ count$: Observable<number> | Store<number>;
2287
+ /** Observable of all entities in the cached collection. */
2288
+ entities$: Observable<T[]> | Store<T[]>;
2289
+ /** Observable of actions related to this entity type. */
2290
+ entityActions$: Observable<EntityAction>;
2291
+ /** Observable of the map of entity keys to entities */
2292
+ entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;
2293
+ /** Observable of error actions related to this entity type. */
2294
+ errors$: Observable<EntityAction>;
2295
+ /** Observable of the filter pattern applied by the entity collection's filter function */
2296
+ filter$: Observable<any> | Store<any>;
2297
+ /** Observable of entities in the cached collection that pass the filter function */
2298
+ filteredEntities$: Observable<T[]> | Store<T[]>;
2299
+ /** Observable of the keys of the cached collection, in the collection's native sort order */
2300
+ keys$: Observable<string[] | number[]> | Store<string[] | number[]>;
2301
+ /** Observable true when the collection has been loaded */
2302
+ loaded$: Observable<boolean> | Store<boolean>;
2303
+ /** Observable true when a multi-entity query command is in progress. */
2304
+ loading$: Observable<boolean> | Store<boolean>;
2305
+ /** Original entity values for entities with unsaved changes */
2306
+ changeState$: Observable<ChangeStateMap<T>> | Store<ChangeStateMap<T>>;
2307
+ }
2308
+
2309
+ /**
2310
+ * Creates EntityCollectionService instances for
2311
+ * a cached collection of T entities in the ngrx store.
2312
+ */
2313
+ declare class EntityCollectionServiceFactory {
2314
+ /** Creates the core elements of the EntityCollectionService for an entity type. */
2315
+ entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory;
2316
+ constructor(
2317
+ /** Creates the core elements of the EntityCollectionService for an entity type. */
2318
+ entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory);
2319
+ /**
2320
+ * Create an EntityCollectionService for an entity type
2321
+ * @param entityName - name of the entity type
2322
+ */
2323
+ create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
2324
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionServiceFactory, never>;
2325
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionServiceFactory>;
2326
+ }
2327
+
2328
+ /**
2329
+ * Class-Interface for EntityCache and EntityCollection services.
2330
+ * Serves as an Angular provider token for this service class.
2331
+ * Includes a registry of EntityCollectionServices for all entity types.
2332
+ * Creates a new default EntityCollectionService for any entity type not in the registry.
2333
+ * Optionally register specialized EntityCollectionServices for individual types
2334
+ */
2335
+ declare abstract class EntityServices {
2336
+ /** Dispatch any action to the store */
2337
+ abstract dispatch(action: Action): void;
2338
+ /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
2339
+ abstract readonly entityActionErrors$: Observable<EntityAction>;
2340
+ /** Observable of the entire entity cache */
2341
+ abstract readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;
2342
+ /** Get (or create) the singleton instance of an EntityCollectionService
2343
+ * @param entityName {string} Name of the entity type of the service
2344
+ */
2345
+ abstract getEntityCollectionService<T = any>(entityName: string): EntityCollectionService<T>;
2346
+ /**
2347
+ * Actions scanned by the store after it processed them with reducers.
2348
+ * A replay observable of the most recent Action (not just EntityAction) reduced by the store.
2349
+ */
2350
+ abstract readonly reducedActions$: Observable<Action>;
2351
+ /** Register an EntityCollectionService under its entity type name.
2352
+ * Will replace a pre-existing service for that type.
2353
+ * @param service {EntityCollectionService} The entity service
2354
+ */
2355
+ abstract registerEntityCollectionService<T>(service: EntityCollectionService<T>): void;
2356
+ /** Register entity services for several entity types at once.
2357
+ * Will replace a pre-existing service for that type.
2358
+ * @param entityCollectionServices Array of EntityCollectionServices to register
2359
+ */
2360
+ abstract registerEntityCollectionServices(entityCollectionServices: EntityCollectionService<any>[]): void;
2361
+ /** Register entity services for several entity types at once.
2362
+ * Will replace a pre-existing service for that type.
2363
+ * @param entityCollectionServiceMap Map of service-name to entity-collection-service
2364
+ */
2365
+ abstract registerEntityCollectionServices(entityCollectionServiceMap: EntityCollectionServiceMap): void;
2366
+ }
2367
+ /**
2368
+ * A map of service or entity names to their corresponding EntityCollectionServices.
2369
+ */
2370
+ interface EntityCollectionServiceMap {
2371
+ [entityName: string]: EntityCollectionService<any>;
2372
+ }
2373
+
2374
+ /** Core ingredients of an EntityServices class */
2375
+ declare class EntityServicesElements {
2376
+ /**
2377
+ * Creates EntityCollectionService instances for
2378
+ * a cached collection of T entities in the ngrx store.
2379
+ */
2380
+ readonly entityCollectionServiceFactory: EntityCollectionServiceFactory;
2381
+ /** The ngrx store, scoped to the EntityCache */
2382
+ readonly store: Store<EntityCache>;
2383
+ constructor(
2384
+ /**
2385
+ * Creates EntityCollectionService instances for
2386
+ * a cached collection of T entities in the ngrx store.
2387
+ */
2388
+ entityCollectionServiceFactory: EntityCollectionServiceFactory,
2389
+ /** Creates EntityDispatchers for entity collections */
2390
+ entityDispatcherFactory: EntityDispatcherFactory,
2391
+ /** Creates observable EntitySelectors$ for entity collections. */
2392
+ entitySelectors$Factory: EntitySelectors$Factory,
2393
+ /** The ngrx store, scoped to the EntityCache */
2394
+ store: Store<EntityCache>);
2395
+ /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
2396
+ readonly entityActionErrors$: Observable<EntityAction>;
2397
+ /** Observable of the entire entity cache */
2398
+ readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;
2399
+ /**
2400
+ * Actions scanned by the store after it processed them with reducers.
2401
+ * A replay observable of the most recent action reduced by the store.
2402
+ */
2403
+ readonly reducedActions$: Observable<Action>;
2404
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityServicesElements, never>;
2405
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityServicesElements>;
2406
+ }
2407
+
2408
+ /**
2409
+ * Base/default class of a central registry of EntityCollectionServices for all entity types.
2410
+ * Create your own subclass to add app-specific members for an improved developer experience.
2411
+ *
2412
+ * @usageNotes
2413
+ * ```ts
2414
+ * export class EntityServices extends EntityServicesBase {
2415
+ * constructor(entityServicesElements: EntityServicesElements) {
2416
+ * super(entityServicesElements);
2417
+ * }
2418
+ * // Extend with well-known, app entity collection services
2419
+ * // Convenience property to return a typed custom entity collection service
2420
+ * get companyService() {
2421
+ * return this.getEntityCollectionService<Model.Company>('Company') as CompanyService;
2422
+ * }
2423
+ * // Convenience dispatch methods
2424
+ * clearCompany(companyId: string) {
2425
+ * this.dispatch(new ClearCompanyAction(companyId));
2426
+ * }
2427
+ * }
2428
+ * ```
2429
+ */
2430
+ declare class EntityServicesBase implements EntityServices {
2431
+ private entityServicesElements;
2432
+ constructor(entityServicesElements: EntityServicesElements);
2433
+ /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */
2434
+ get entityActionErrors$(): Observable<EntityAction>;
2435
+ /** Observable of the entire entity cache */
2436
+ get entityCache$(): Observable<EntityCache> | Store<EntityCache>;
2437
+ /** Factory to create a default instance of an EntityCollectionService */
2438
+ get entityCollectionServiceFactory(): EntityCollectionServiceFactory;
2439
+ /**
2440
+ * Actions scanned by the store after it processed them with reducers.
2441
+ * A replay observable of the most recent action reduced by the store.
2442
+ */
2443
+ get reducedActions$(): Observable<Action>;
2444
+ /** The ngrx store, scoped to the EntityCache */
2445
+ protected get store(): Store<EntityCache>;
2446
+ /** Dispatch any action to the store */
2447
+ dispatch(action: Action): void;
2448
+ /** Registry of EntityCollectionService instances */
2449
+ private readonly EntityCollectionServices;
2450
+ /**
2451
+ * Create a new default instance of an EntityCollectionService.
2452
+ * Prefer getEntityCollectionService() unless you really want a new default instance.
2453
+ * This one will NOT be registered with EntityServices!
2454
+ * @param entityName {string} Name of the entity type of the service
2455
+ */
2456
+ protected createEntityCollectionService<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
2457
+ /** Get (or create) the singleton instance of an EntityCollectionService
2458
+ * @param entityName {string} Name of the entity type of the service
2459
+ */
2460
+ getEntityCollectionService<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(entityName: string): EntityCollectionService<T>;
2461
+ /** Register an EntityCollectionService under its entity type name.
2462
+ * Will replace a pre-existing service for that type.
2463
+ * @param service {EntityCollectionService} The entity service
2464
+ * @param serviceName {string} optional service name to use instead of the service's entityName
2465
+ */
2466
+ registerEntityCollectionService<T>(service: EntityCollectionService<T>, serviceName?: string): void;
2467
+ /**
2468
+ * Register entity services for several entity types at once.
2469
+ * Will replace a pre-existing service for that type.
2470
+ * @param entityCollectionServices {EntityCollectionServiceMap | EntityCollectionService<any>[]}
2471
+ * EntityCollectionServices to register, either as a map or an array
2472
+ */
2473
+ registerEntityCollectionServices(entityCollectionServices: EntityCollectionServiceMap | EntityCollectionService<any>[]): void;
2474
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityServicesBase, never>;
2475
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityServicesBase>;
2476
+ }
2477
+
2478
+ declare const ENTITY_CACHE_NAME = "entityCache";
2479
+ declare const ENTITY_CACHE_NAME_TOKEN: InjectionToken<string>;
2480
+ declare const ENTITY_CACHE_META_REDUCERS: InjectionToken<MetaReducer<any, any>[]>;
2481
+ declare const ENTITY_COLLECTION_META_REDUCERS: InjectionToken<MetaReducer<any, any>[]>;
2482
+ declare const INITIAL_ENTITY_CACHE_STATE: InjectionToken<EntityCache | (() => EntityCache)>;
2483
+
2484
+ /**
2485
+ * Methods for tracking, committing, and reverting/undoing unsaved entity changes.
2486
+ * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.
2487
+ * See EntityChangeTracker docs.
2488
+ */
2489
+ interface EntityChangeTracker<T> {
2490
+ /**
2491
+ * Commit all changes as when the collection has been completely reloaded from the server.
2492
+ * Harmless when there are no entity changes to commit.
2493
+ * @param collection The entity collection
2494
+ */
2495
+ commitAll(collection: EntityCollection<T>): EntityCollection<T>;
2496
+ /**
2497
+ * Commit changes for the given entities as when they have been refreshed from the server.
2498
+ * Harmless when there are no entity changes to commit.
2499
+ * @param entityOrIdList The entities to clear tracking or their ids.
2500
+ * @param collection The entity collection
2501
+ */
2502
+ commitMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
2503
+ /**
2504
+ * Commit changes for the given entity as when it have been refreshed from the server.
2505
+ * Harmless when no entity changes to commit.
2506
+ * @param entityOrId The entity to clear tracking or its id.
2507
+ * @param collection The entity collection
2508
+ */
2509
+ commitOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
2510
+ /**
2511
+ * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.
2512
+ * @param entities Entities returned from querying the server.
2513
+ * @param collection The entity collection
2514
+ * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.
2515
+ * If not specified, implementation supplies a default strategy.
2516
+ * @returns The merged EntityCollection.
2517
+ */
2518
+ mergeQueryResults(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2519
+ /**
2520
+ * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.
2521
+ * The default is MergeStrategy.OverwriteChanges.
2522
+ * @param entities Entities returned from saving new entities to the server.
2523
+ * @param collection The entity collection
2524
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
2525
+ * If not specified, implementation supplies a default strategy.
2526
+ * @returns The merged EntityCollection.
2527
+ */
2528
+ mergeSaveAdds(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2529
+ /**
2530
+ * Merge successful result of deleting entities on the server that have the given primary keys
2531
+ * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.
2532
+ * @param entities keys primary keys of the entities to remove/delete.
2533
+ * @param collection The entity collection
2534
+ * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.
2535
+ * If not specified, implementation supplies a default strategy.
2536
+ * @returns The merged EntityCollection.
2537
+ */
2538
+ mergeSaveDeletes(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2539
+ /**
2540
+ * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.
2541
+ * The default is MergeStrategy.OverwriteChanges.
2542
+ * @param entities Entities returned from saving upsert entities to the server.
2543
+ * @param collection The entity collection
2544
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
2545
+ * If not specified, implementation supplies a default strategy.
2546
+ * @returns The merged EntityCollection.
2547
+ */
2548
+ mergeSaveUpserts(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2549
+ /**
2550
+ * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.
2551
+ * The default is MergeStrategy.OverwriteChanges.
2552
+ * @param updates Entity response data returned from saving updated entities to the server.
2553
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
2554
+ * If not specified, implementation supplies a default strategy.
2555
+ * @param [skipUnchanged] True means skip update if server didn't change it. False by default.
2556
+ * If the update was optimistic and the server didn't make more changes of its own
2557
+ * then the updates are already in the collection and shouldn't make them again.
2558
+ * @param collection The entity collection
2559
+ * @returns The merged EntityCollection.
2560
+ */
2561
+ mergeSaveUpdates(updates: UpdateResponseData<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy, skipUnchanged?: boolean): EntityCollection<T>;
2562
+ /**
2563
+ * Track multiple entities before adding them to the collection.
2564
+ * Does NOT add to the collection (the reducer's job).
2565
+ * @param entities The entities to add. They must all have their ids.
2566
+ * @param collection The entity collection
2567
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2568
+ * If not specified, implementation supplies a default strategy.
2569
+ */
2570
+ trackAddMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2571
+ /**
2572
+ * Track an entity before adding it to the collection.
2573
+ * Does NOT add to the collection (the reducer's job).
2574
+ * @param entity The entity to add. It must have an id.
2575
+ * @param collection The entity collection
2576
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2577
+ * If not specified, implementation supplies a default strategy.
2578
+ */
2579
+ trackAddOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2580
+ /**
2581
+ * Track multiple entities before removing them with the intention of deleting them on the server.
2582
+ * Does NOT remove from the collection (the reducer's job).
2583
+ * @param keys The primary keys of the entities to delete.
2584
+ * @param collection The entity collection
2585
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2586
+ */
2587
+ trackDeleteMany(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2588
+ /**
2589
+ * Track an entity before it is removed with the intention of deleting it on the server.
2590
+ * Does NOT remove from the collection (the reducer's job).
2591
+ * @param key The primary key of the entity to delete.
2592
+ * @param collection The entity collection
2593
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2594
+ */
2595
+ trackDeleteOne(key: number | string, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2596
+ /**
2597
+ * Track multiple entities before updating them in the collection.
2598
+ * Does NOT update the collection (the reducer's job).
2599
+ * @param updates The entities to update.
2600
+ * @param collection The entity collection
2601
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2602
+ */
2603
+ trackUpdateMany(updates: Update<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2604
+ /**
2605
+ * Track an entity before updating it in the collection.
2606
+ * Does NOT update the collection (the reducer's job).
2607
+ * @param update The entity to update.
2608
+ * @param collection The entity collection
2609
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2610
+ */
2611
+ trackUpdateOne(update: Update<T>, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2612
+ /**
2613
+ * Track multiple entities before upserting (adding and updating) them to the collection.
2614
+ * Does NOT update the collection (the reducer's job).
2615
+ * @param entities The entities to add or update. They must be complete entities with ids.
2616
+ * @param collection The entity collection
2617
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2618
+ */
2619
+ trackUpsertMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2620
+ /**
2621
+ * Track an entity before upsert (adding and updating) it to the collection.
2622
+ * Does NOT update the collection (the reducer's job).
2623
+ * @param entities The entity to add or update. It must be a complete entity with its id.
2624
+ * @param collection The entity collection
2625
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
2626
+ */
2627
+ trackUpsertOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
2628
+ /**
2629
+ * Revert the unsaved changes for all collection.
2630
+ * Harmless when there are no entity changes to undo.
2631
+ * @param collection The entity collection
2632
+ */
2633
+ undoAll(collection: EntityCollection<T>): EntityCollection<T>;
2634
+ /**
2635
+ * Revert the unsaved changes for the given entities.
2636
+ * Harmless when there are no entity changes to undo.
2637
+ * @param entityOrIdList The entities to revert or their ids.
2638
+ * @param collection The entity collection
2639
+ */
2640
+ undoMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
2641
+ /**
2642
+ * Revert the unsaved changes for the given entity.
2643
+ * Harmless when there are no entity changes to undo.
2644
+ * @param entityOrId The entity to revert or its id.
2645
+ * @param collection The entity collection
2646
+ */
2647
+ undoOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
2648
+ }
2649
+
2650
+ /**
2651
+ * Map of {EntityOp} to reducer method for the operation.
2652
+ * If an operation is missing, caller should return the collection for that reducer.
2653
+ */
2654
+ interface EntityCollectionReducerMethodMap<T> {
2655
+ [method: string]: (collection: EntityCollection<T>, action: EntityAction) => EntityCollection<T>;
2656
+ }
2657
+ /**
2658
+ * Base implementation of reducer methods for an entity collection.
2659
+ */
2660
+ declare class EntityCollectionReducerMethods<T> {
2661
+ entityName: string;
2662
+ definition: EntityDefinition<T>;
2663
+ protected adapter: EntityAdapter<T>;
2664
+ protected guard: EntityActionGuard<T>;
2665
+ /** True if this collection tracks unsaved changes */
2666
+ protected isChangeTracking: boolean;
2667
+ /** Extract the primary key (id); default to `id` */
2668
+ selectId: IdSelector<T>;
2669
+ /**
2670
+ * Track changes to entities since the last query or save
2671
+ * Can revert some or all of those changes
2672
+ */
2673
+ entityChangeTracker: EntityChangeTracker<T>;
2674
+ /**
2675
+ * Convert an entity (or partial entity) into the `Update<T>` object
2676
+ * `id`: the primary key and
2677
+ * `changes`: the entity (or partial entity of changes).
2678
+ */
2679
+ protected toUpdate: (entity: Partial<T>) => Update<T>;
2680
+ /**
2681
+ * Dictionary of the {EntityCollectionReducerMethods} for this entity type,
2682
+ * keyed by the {EntityOp}
2683
+ */
2684
+ readonly methods: EntityCollectionReducerMethodMap<T>;
2685
+ constructor(entityName: string, definition: EntityDefinition<T>, entityChangeTracker?: EntityChangeTracker<T>);
2686
+ /** Cancel a persistence operation */
2687
+ protected cancelPersist(collection: EntityCollection<T>): EntityCollection<T>;
2688
+ protected queryAll(collection: EntityCollection<T>): EntityCollection<T>;
2689
+ protected queryAllError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2690
+ /**
2691
+ * Merges query results per the MergeStrategy
2692
+ * Sets loading flag to false and loaded flag to true.
2693
+ */
2694
+ protected queryAllSuccess(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2695
+ protected queryByKey(collection: EntityCollection<T>, action: EntityAction<number | string>): EntityCollection<T>;
2696
+ protected queryByKeyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2697
+ protected queryByKeySuccess(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2698
+ protected queryLoad(collection: EntityCollection<T>): EntityCollection<T>;
2699
+ protected queryLoadError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2700
+ /**
2701
+ * Replaces all entities in the collection
2702
+ * Sets loaded flag to true, loading flag to false,
2703
+ * and clears changeState for the entire collection.
2704
+ */
2705
+ protected queryLoadSuccess(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2706
+ protected queryMany(collection: EntityCollection<T>, action: EntityAction): EntityCollection<T>;
2707
+ protected queryManyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2708
+ protected queryManySuccess(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2709
+ /**
2710
+ * Save multiple new entities.
2711
+ * If saving pessimistically, delay adding to collection until server acknowledges success.
2712
+ * If saving optimistically; add immediately.
2713
+ * @param collection The collection to which the entities should be added.
2714
+ * @param action The action payload holds options, including whether the save is optimistic,
2715
+ * and the data, which must be an array of entities.
2716
+ * If saving optimistically, the entities must have their keys.
2717
+ */
2718
+ protected saveAddMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2719
+ /**
2720
+ * Attempt to save new entities failed or timed-out.
2721
+ * Action holds the error.
2722
+ * If saved pessimistically, new entities are not in the collection and
2723
+ * you may not have to compensate for the error.
2724
+ * If saved optimistically, the unsaved entities are in the collection and
2725
+ * you may need to compensate for the error.
2726
+ */
2727
+ protected saveAddManyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2728
+ /**
2729
+ * Successfully saved new entities to the server.
2730
+ * If saved pessimistically, add the entities from the server to the collection.
2731
+ * If saved optimistically, the added entities are already in the collection.
2732
+ * However, the server might have set or modified other fields (e.g, concurrency field),
2733
+ * and may even return additional new entities.
2734
+ * Therefore, upsert the entities in the collection with the returned values (if any)
2735
+ * Caution: in a race, this update could overwrite unsaved user changes.
2736
+ * Use pessimistic add to avoid this risk.
2737
+ * Note: saveAddManySuccess differs from saveAddOneSuccess when optimistic.
2738
+ * saveAddOneSuccess updates (not upserts) with the lone entity from the server.
2739
+ * There is no effect if the entity is not already in cache.
2740
+ * saveAddManySuccess will add an entity if it is not found in cache.
2741
+ */
2742
+ protected saveAddManySuccess(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2743
+ /**
2744
+ * Save a new entity.
2745
+ * If saving pessimistically, delay adding to collection until server acknowledges success.
2746
+ * If saving optimistically; add entity immediately.
2747
+ * @param collection The collection to which the entity should be added.
2748
+ * @param action The action payload holds options, including whether the save is optimistic,
2749
+ * and the data, which must be an entity.
2750
+ * If saving optimistically, the entity must have a key.
2751
+ */
2752
+ protected saveAddOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2753
+ /**
2754
+ * Attempt to save a new entity failed or timed-out.
2755
+ * Action holds the error.
2756
+ * If saved pessimistically, the entity is not in the collection and
2757
+ * you may not have to compensate for the error.
2758
+ * If saved optimistically, the unsaved entity is in the collection and
2759
+ * you may need to compensate for the error.
2760
+ */
2761
+ protected saveAddOneError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2762
+ /**
2763
+ * Successfully saved a new entity to the server.
2764
+ * If saved pessimistically, add the entity from the server to the collection.
2765
+ * If saved optimistically, the added entity is already in the collection.
2766
+ * However, the server might have set or modified other fields (e.g, concurrency field)
2767
+ * Therefore, update the entity in the collection with the returned value (if any)
2768
+ * Caution: in a race, this update could overwrite unsaved user changes.
2769
+ * Use pessimistic add to avoid this risk.
2770
+ */
2771
+ protected saveAddOneSuccess(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2772
+ /**
2773
+ * Delete an entity from the server by key and remove it from the collection (if present).
2774
+ * If the entity is an unsaved new entity, remove it from the collection immediately
2775
+ * and skip the server delete request.
2776
+ * An optimistic save removes an existing entity from the collection immediately;
2777
+ * a pessimistic save removes it after the server confirms successful delete.
2778
+ * @param collection Will remove the entity with this key from the collection.
2779
+ * @param action The action payload holds options, including whether the save is optimistic,
2780
+ * and the data, which must be a primary key or an entity with a key;
2781
+ * this reducer extracts the key from the entity.
2782
+ */
2783
+ protected saveDeleteOne(collection: EntityCollection<T>, action: EntityAction<number | string | T>): EntityCollection<T>;
2784
+ /**
2785
+ * Attempt to delete the entity on the server failed or timed-out.
2786
+ * Action holds the error.
2787
+ * If saved pessimistically, the entity could still be in the collection and
2788
+ * you may not have to compensate for the error.
2789
+ * If saved optimistically, the entity is not in the collection and
2790
+ * you may need to compensate for the error.
2791
+ */
2792
+ protected saveDeleteOneError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2793
+ /**
2794
+ * Successfully deleted entity on the server. The key of the deleted entity is in the action payload data.
2795
+ * If saved pessimistically, if the entity is still in the collection it will be removed.
2796
+ * If saved optimistically, the entity has already been removed from the collection.
2797
+ */
2798
+ protected saveDeleteOneSuccess(collection: EntityCollection<T>, action: EntityAction<number | string>): EntityCollection<T>;
2799
+ /**
2800
+ * Delete multiple entities from the server by key and remove them from the collection (if present).
2801
+ * Removes unsaved new entities from the collection immediately
2802
+ * but the id is still sent to the server for deletion even though the server will not find that entity.
2803
+ * Therefore, the server must be willing to ignore a delete request for an entity it cannot find.
2804
+ * An optimistic save removes existing entities from the collection immediately;
2805
+ * a pessimistic save removes them after the server confirms successful delete.
2806
+ * @param collection Removes entities from this collection.
2807
+ * @param action The action payload holds options, including whether the save is optimistic,
2808
+ * and the data, which must be an array of primary keys or entities with a key;
2809
+ * this reducer extracts the key from the entity.
2810
+ */
2811
+ protected saveDeleteMany(collection: EntityCollection<T>, action: EntityAction<(number | string | T)[]>): EntityCollection<T>;
2812
+ /**
2813
+ * Attempt to delete the entities on the server failed or timed-out.
2814
+ * Action holds the error.
2815
+ * If saved pessimistically, the entities could still be in the collection and
2816
+ * you may not have to compensate for the error.
2817
+ * If saved optimistically, the entities are not in the collection and
2818
+ * you may need to compensate for the error.
2819
+ */
2820
+ protected saveDeleteManyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2821
+ /**
2822
+ * Successfully deleted entities on the server. The keys of the deleted entities are in the action payload data.
2823
+ * If saved pessimistically, entities that are still in the collection will be removed.
2824
+ * If saved optimistically, the entities have already been removed from the collection.
2825
+ */
2826
+ protected saveDeleteManySuccess(collection: EntityCollection<T>, action: EntityAction<(number | string)[]>): EntityCollection<T>;
2827
+ /**
2828
+ * Save an update to an existing entity.
2829
+ * If saving pessimistically, update the entity in the collection after the server confirms success.
2830
+ * If saving optimistically, update the entity immediately, before the save request.
2831
+ * @param collection The collection to update
2832
+ * @param action The action payload holds options, including if the save is optimistic,
2833
+ * and the data which, must be an {Update<T>}
2834
+ */
2835
+ protected saveUpdateOne(collection: EntityCollection<T>, action: EntityAction<Update<T>>): EntityCollection<T>;
2836
+ /**
2837
+ * Attempt to update the entity on the server failed or timed-out.
2838
+ * Action holds the error.
2839
+ * If saved pessimistically, the entity in the collection is in the pre-save state
2840
+ * you may not have to compensate for the error.
2841
+ * If saved optimistically, the entity in the collection was updated
2842
+ * and you may need to compensate for the error.
2843
+ */
2844
+ protected saveUpdateOneError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2845
+ /**
2846
+ * Successfully saved the updated entity to the server.
2847
+ * If saved pessimistically, update the entity in the collection with data from the server.
2848
+ * If saved optimistically, the entity was already updated in the collection.
2849
+ * However, the server might have set or modified other fields (e.g, concurrency field)
2850
+ * Therefore, update the entity in the collection with the returned value (if any)
2851
+ * Caution: in a race, this update could overwrite unsaved user changes.
2852
+ * Use pessimistic update to avoid this risk.
2853
+ * @param collection The collection to update
2854
+ * @param action The action payload holds options, including if the save is optimistic, and
2855
+ * the update data which, must be an UpdateResponse<T> that corresponds to the Update sent to the server.
2856
+ * You must include an UpdateResponse even if the save was optimistic,
2857
+ * to ensure that the change tracking is properly reset.
2858
+ */
2859
+ protected saveUpdateOneSuccess(collection: EntityCollection<T>, action: EntityAction<UpdateResponseData<T>>): EntityCollection<T>;
2860
+ /**
2861
+ * Save updated entities.
2862
+ * If saving pessimistically, update the entities in the collection after the server confirms success.
2863
+ * If saving optimistically, update the entities immediately, before the save request.
2864
+ * @param collection The collection to update
2865
+ * @param action The action payload holds options, including if the save is optimistic,
2866
+ * and the data which, must be an array of {Update<T>}.
2867
+ */
2868
+ protected saveUpdateMany(collection: EntityCollection<T>, action: EntityAction<Update<T>[]>): EntityCollection<T>;
2869
+ /**
2870
+ * Attempt to update entities on the server failed or timed-out.
2871
+ * Action holds the error.
2872
+ * If saved pessimistically, the entities in the collection are in the pre-save state
2873
+ * you may not have to compensate for the error.
2874
+ * If saved optimistically, the entities in the collection were updated
2875
+ * and you may need to compensate for the error.
2876
+ */
2877
+ protected saveUpdateManyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2878
+ /**
2879
+ * Successfully saved the updated entities to the server.
2880
+ * If saved pessimistically, the entities in the collection will be updated with data from the server.
2881
+ * If saved optimistically, the entities in the collection were already updated.
2882
+ * However, the server might have set or modified other fields (e.g, concurrency field)
2883
+ * Therefore, update the entity in the collection with the returned values (if any)
2884
+ * Caution: in a race, this update could overwrite unsaved user changes.
2885
+ * Use pessimistic update to avoid this risk.
2886
+ * @param collection The collection to update
2887
+ * @param action The action payload holds options, including if the save is optimistic,
2888
+ * and the data which, must be an array of UpdateResponse<T>.
2889
+ * You must include an UpdateResponse for every Update sent to the server,
2890
+ * even if the save was optimistic, to ensure that the change tracking is properly reset.
2891
+ */
2892
+ protected saveUpdateManySuccess(collection: EntityCollection<T>, action: EntityAction<UpdateResponseData<T>[]>): EntityCollection<T>;
2893
+ /**
2894
+ * Save a new or existing entity.
2895
+ * If saving pessimistically, delay adding to collection until server acknowledges success.
2896
+ * If saving optimistically; add immediately.
2897
+ * @param collection The collection to which the entity should be upserted.
2898
+ * @param action The action payload holds options, including whether the save is optimistic,
2899
+ * and the data, which must be a whole entity.
2900
+ * If saving optimistically, the entity must have its key.
2901
+ */
2902
+ protected saveUpsertOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2903
+ /**
2904
+ * Attempt to save new or existing entity failed or timed-out.
2905
+ * Action holds the error.
2906
+ * If saved pessimistically, new or updated entity is not in the collection and
2907
+ * you may not have to compensate for the error.
2908
+ * If saved optimistically, the unsaved entities are in the collection and
2909
+ * you may need to compensate for the error.
2910
+ */
2911
+ protected saveUpsertOneError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2912
+ /**
2913
+ * Successfully saved new or existing entities to the server.
2914
+ * If saved pessimistically, add the entities from the server to the collection.
2915
+ * If saved optimistically, the added entities are already in the collection.
2916
+ * However, the server might have set or modified other fields (e.g, concurrency field)
2917
+ * Therefore, update the entities in the collection with the returned values (if any)
2918
+ * Caution: in a race, this update could overwrite unsaved user changes.
2919
+ * Use pessimistic add to avoid this risk.
2920
+ */
2921
+ protected saveUpsertOneSuccess(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2922
+ /**
2923
+ * Save multiple new or existing entities.
2924
+ * If saving pessimistically, delay adding to collection until server acknowledges success.
2925
+ * If saving optimistically; add immediately.
2926
+ * @param collection The collection to which the entities should be upserted.
2927
+ * @param action The action payload holds options, including whether the save is optimistic,
2928
+ * and the data, which must be an array of whole entities.
2929
+ * If saving optimistically, the entities must have their keys.
2930
+ */
2931
+ protected saveUpsertMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2932
+ /**
2933
+ * Attempt to save new or existing entities failed or timed-out.
2934
+ * Action holds the error.
2935
+ * If saved pessimistically, new entities are not in the collection and
2936
+ * you may not have to compensate for the error.
2937
+ * If saved optimistically, the unsaved entities are in the collection and
2938
+ * you may need to compensate for the error.
2939
+ */
2940
+ protected saveUpsertManyError(collection: EntityCollection<T>, action: EntityAction<EntityActionDataServiceError>): EntityCollection<T>;
2941
+ /**
2942
+ * Successfully saved new or existing entities to the server.
2943
+ * If saved pessimistically, add the entities from the server to the collection.
2944
+ * If saved optimistically, the added entities are already in the collection.
2945
+ * However, the server might have set or modified other fields (e.g, concurrency field)
2946
+ * Therefore, update the entities in the collection with the returned values (if any)
2947
+ * Caution: in a race, this update could overwrite unsaved user changes.
2948
+ * Use pessimistic add to avoid this risk.
2949
+ */
2950
+ protected saveUpsertManySuccess(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2951
+ /**
2952
+ * Replaces all entities in the collection
2953
+ * Sets loaded flag to true.
2954
+ * Merges query results, preserving unsaved changes
2955
+ */
2956
+ protected addAll(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2957
+ protected addMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2958
+ protected addOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2959
+ protected removeMany(collection: EntityCollection<T>, action: EntityAction<number[] | string[]>): EntityCollection<T>;
2960
+ protected removeOne(collection: EntityCollection<T>, action: EntityAction<number | string>): EntityCollection<T>;
2961
+ protected removeAll(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2962
+ protected updateMany(collection: EntityCollection<T>, action: EntityAction<Update<T>[]>): EntityCollection<T>;
2963
+ protected updateOne(collection: EntityCollection<T>, action: EntityAction<Update<T>>): EntityCollection<T>;
2964
+ protected upsertMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2965
+ protected upsertOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2966
+ protected commitAll(collection: EntityCollection<T>): EntityCollection<T>;
2967
+ protected commitMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2968
+ protected commitOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2969
+ protected undoAll(collection: EntityCollection<T>): EntityCollection<T>;
2970
+ protected undoMany(collection: EntityCollection<T>, action: EntityAction<T[]>): EntityCollection<T>;
2971
+ protected undoOne(collection: EntityCollection<T>, action: EntityAction<T>): EntityCollection<T>;
2972
+ /** Dangerous: Completely replace the collection's ChangeState. Use rarely and wisely. */
2973
+ protected setChangeState(collection: EntityCollection<T>, action: EntityAction<ChangeStateMap<T>>): EntityCollection<T>;
2974
+ /**
2975
+ * Dangerous: Completely replace the collection.
2976
+ * Primarily for testing and rehydration from local storage.
2977
+ * Use rarely and wisely.
2978
+ */
2979
+ protected setCollection(collection: EntityCollection<T>, action: EntityAction<EntityCollection<T>>): EntityCollection<T>;
2980
+ protected setFilter(collection: EntityCollection<T>, action: EntityAction<any>): EntityCollection<T>;
2981
+ protected setLoaded(collection: EntityCollection<T>, action: EntityAction<boolean>): EntityCollection<T>;
2982
+ protected setLoading(collection: EntityCollection<T>, action: EntityAction<boolean>): EntityCollection<T>;
2983
+ protected setLoadingFalse(collection: EntityCollection<T>): EntityCollection<T>;
2984
+ protected setLoadingTrue(collection: EntityCollection<T>): EntityCollection<T>;
2985
+ /** Set the collection's loading flag */
2986
+ protected setLoadingFlag(collection: EntityCollection<T>, loading: boolean): EntityCollection<T>;
2987
+ /** Safely extract data from the EntityAction payload */
2988
+ protected extractData<D = any>(action: EntityAction<D>): D;
2989
+ /** Safely extract MergeStrategy from EntityAction. Set to IgnoreChanges if collection itself is not tracked. */
2990
+ protected extractMergeStrategy(action: EntityAction): MergeStrategy;
2991
+ protected isOptimistic(action: EntityAction): boolean;
2992
+ }
2993
+ /**
2994
+ * Creates {EntityCollectionReducerMethods} for a given entity type.
2995
+ */
2996
+ declare class EntityCollectionReducerMethodsFactory {
2997
+ private entityDefinitionService;
2998
+ constructor(entityDefinitionService: EntityDefinitionService);
2999
+ /** Create the {EntityCollectionReducerMethods} for the named entity type */
3000
+ create<T>(entityName: string): EntityCollectionReducerMethodMap<T>;
3001
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionReducerMethodsFactory, never>;
3002
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionReducerMethodsFactory>;
3003
+ }
3004
+
3005
+ type EntityCollectionReducer<T = any> = (collection: EntityCollection<T>, action: EntityAction) => EntityCollection<T>;
3006
+ /** Create a default reducer for a specific entity collection */
3007
+ declare class EntityCollectionReducerFactory {
3008
+ private methodsFactory;
3009
+ constructor(methodsFactory: EntityCollectionReducerMethodsFactory);
3010
+ /** Create a default reducer for a collection of entities of T */
3011
+ create<T = any>(entityName: string): EntityCollectionReducer<T>;
3012
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionReducerFactory, never>;
3013
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionReducerFactory>;
3014
+ }
3015
+
3016
+ /** A hash of EntityCollectionReducers */
3017
+ interface EntityCollectionReducers {
3018
+ [entity: string]: EntityCollectionReducer<any>;
3019
+ }
3020
+ /**
3021
+ * Registry of entity types and their previously-constructed reducers.
3022
+ * Can create a new CollectionReducer, which it registers for subsequent use.
3023
+ */
3024
+ declare class EntityCollectionReducerRegistry {
3025
+ private entityCollectionReducerFactory;
3026
+ protected entityCollectionReducers: EntityCollectionReducers;
3027
+ private entityCollectionMetaReducer;
3028
+ constructor(entityCollectionReducerFactory: EntityCollectionReducerFactory, entityCollectionMetaReducers?: MetaReducer<EntityCollection, EntityAction>[]);
3029
+ /**
3030
+ * Get the registered EntityCollectionReducer<T> for this entity type or create one and register it.
3031
+ * @param entityName Name of the entity type for this reducer
3032
+ */
3033
+ getOrCreateReducer<T>(entityName: string): EntityCollectionReducer<T>;
3034
+ /**
3035
+ * Register an EntityCollectionReducer for an entity type
3036
+ * @param entityName - the name of the entity type
3037
+ * @param reducer - reducer for that entity type
3038
+ *
3039
+ * Examples:
3040
+ * registerReducer('Hero', myHeroReducer);
3041
+ * registerReducer('Villain', myVillainReducer);
3042
+ */
3043
+ registerReducer<T>(entityName: string, reducer: EntityCollectionReducer<T>): EntityCollectionReducer<T>;
3044
+ /**
3045
+ * Register a batch of EntityCollectionReducers.
3046
+ * @param reducers - reducers to merge into existing reducers
3047
+ *
3048
+ * Examples:
3049
+ * registerReducers({
3050
+ * Hero: myHeroReducer,
3051
+ * Villain: myVillainReducer
3052
+ * });
3053
+ */
3054
+ registerReducers(reducers: EntityCollectionReducers): void;
3055
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionReducerRegistry, [null, { optional: true; }]>;
3056
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionReducerRegistry>;
3057
+ }
3058
+
3059
+ /**
3060
+ * Creates the EntityCacheReducer via its create() method
3061
+ */
3062
+ declare class EntityCacheReducerFactory {
3063
+ private entityCollectionCreator;
3064
+ private entityCollectionReducerRegistry;
3065
+ private logger;
3066
+ constructor(entityCollectionCreator: EntityCollectionCreator, entityCollectionReducerRegistry: EntityCollectionReducerRegistry, logger: Logger);
3067
+ /**
3068
+ * Create the @ngrx/data entity cache reducer which either responds to entity cache level actions
3069
+ * or (more commonly) delegates to an EntityCollectionReducer based on the action.payload.entityName.
3070
+ */
3071
+ create(): ActionReducer<EntityCache, Action>;
3072
+ /**
3073
+ * Reducer to clear multiple collections at the same time.
3074
+ * @param entityCache the entity cache
3075
+ * @param action a ClearCollections action whose payload is an array of collection names.
3076
+ * If empty array, does nothing. If no array, clears all the collections.
3077
+ */
3078
+ protected clearCollectionsReducer(entityCache: EntityCache, action: ClearCollections): EntityCache;
3079
+ /**
3080
+ * Reducer to load collection in the form of a hash of entity data for multiple collections.
3081
+ * @param entityCache the entity cache
3082
+ * @param action a LoadCollections action whose payload is the QuerySet of entity collections to load
3083
+ */
3084
+ protected loadCollectionsReducer(entityCache: EntityCache, action: LoadCollections): EntityCache;
3085
+ /**
3086
+ * Reducer to merge query sets in the form of a hash of entity data for multiple collections.
3087
+ * @param entityCache the entity cache
3088
+ * @param action a MergeQuerySet action with the query set and a MergeStrategy
3089
+ */
3090
+ protected mergeQuerySetReducer(entityCache: EntityCache, action: MergeQuerySet): EntityCache;
3091
+ protected saveEntitiesReducer(entityCache: EntityCache, action: SaveEntities): EntityCache;
3092
+ protected saveEntitiesCancelReducer(entityCache: EntityCache, action: SaveEntitiesCancel): EntityCache;
3093
+ protected saveEntitiesErrorReducer(entityCache: EntityCache, action: SaveEntitiesError): EntityCache;
3094
+ protected saveEntitiesSuccessReducer(entityCache: EntityCache, action: SaveEntitiesSuccess): EntityCache;
3095
+ /** Apply reducer for the action's EntityCollection (if the action targets a collection) */
3096
+ private applyCollectionReducer;
3097
+ /** Ensure loading is false for every collection in entityNames */
3098
+ private clearLoadingFlags;
3099
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheReducerFactory, never>;
3100
+ static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheReducerFactory>;
3101
+ }
3102
+
3103
+ /**
3104
+ * The default implementation of EntityChangeTracker with
3105
+ * methods for tracking, committing, and reverting/undoing unsaved entity changes.
3106
+ * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.
3107
+ * See EntityChangeTracker docs.
3108
+ */
3109
+ declare class EntityChangeTrackerBase<T> implements EntityChangeTracker<T> {
3110
+ private adapter;
3111
+ private selectId;
3112
+ constructor(adapter: EntityAdapter<T>, selectId: IdSelector<T>);
3113
+ /**
3114
+ * Commit all changes as when the collection has been completely reloaded from the server.
3115
+ * Harmless when there are no entity changes to commit.
3116
+ * @param collection The entity collection
3117
+ */
3118
+ commitAll(collection: EntityCollection<T>): EntityCollection<T>;
3119
+ /**
3120
+ * Commit changes for the given entities as when they have been refreshed from the server.
3121
+ * Harmless when there are no entity changes to commit.
3122
+ * @param entityOrIdList The entities to clear tracking or their ids.
3123
+ * @param collection The entity collection
3124
+ */
3125
+ commitMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
3126
+ /**
3127
+ * Commit changes for the given entity as when it have been refreshed from the server.
3128
+ * Harmless when no entity changes to commit.
3129
+ * @param entityOrId The entity to clear tracking or its id.
3130
+ * @param collection The entity collection
3131
+ */
3132
+ commitOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
3133
+ /**
3134
+ * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.
3135
+ * @param entities Entities returned from querying the server.
3136
+ * @param collection The entity collection
3137
+ * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.
3138
+ * Defaults to MergeStrategy.PreserveChanges.
3139
+ * @returns The merged EntityCollection.
3140
+ */
3141
+ mergeQueryResults(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3142
+ /**
3143
+ * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.
3144
+ * The default is MergeStrategy.OverwriteChanges.
3145
+ * @param entities Entities returned from saving new entities to the server.
3146
+ * @param collection The entity collection
3147
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
3148
+ * Defaults to MergeStrategy.OverwriteChanges.
3149
+ * @returns The merged EntityCollection.
3150
+ */
3151
+ mergeSaveAdds(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3152
+ /**
3153
+ * Merge successful result of deleting entities on the server that have the given primary keys
3154
+ * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.
3155
+ * @param entities keys primary keys of the entities to remove/delete.
3156
+ * @param collection The entity collection
3157
+ * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.
3158
+ * Defaults to MergeStrategy.OverwriteChanges.
3159
+ * @returns The merged EntityCollection.
3160
+ */
3161
+ mergeSaveDeletes(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3162
+ /**
3163
+ * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.
3164
+ * The default is MergeStrategy.OverwriteChanges.
3165
+ * @param updateResponseData Entity response data returned from saving updated entities to the server.
3166
+ * @param collection The entity collection
3167
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
3168
+ * Defaults to MergeStrategy.OverwriteChanges.
3169
+ * @param [skipUnchanged] True means skip update if server didn't change it. False by default.
3170
+ * If the update was optimistic and the server didn't make more changes of its own
3171
+ * then the updates are already in the collection and shouldn't make them again.
3172
+ * @returns The merged EntityCollection.
3173
+ */
3174
+ mergeSaveUpdates(updateResponseData: UpdateResponseData<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy, skipUnchanged?: boolean): EntityCollection<T>;
3175
+ /**
3176
+ * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.
3177
+ * The default is MergeStrategy.OverwriteChanges.
3178
+ * @param entities Entities returned from saving upserts to the server.
3179
+ * @param collection The entity collection
3180
+ * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
3181
+ * Defaults to MergeStrategy.OverwriteChanges.
3182
+ * @returns The merged EntityCollection.
3183
+ */
3184
+ mergeSaveUpserts(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3185
+ /**
3186
+ *
3187
+ * @param entities Entities to merge
3188
+ * @param collection Collection into which entities are merged
3189
+ * @param defaultMergeStrategy How to merge when action's MergeStrategy is unspecified
3190
+ * @param [mergeStrategy] The action's MergeStrategy
3191
+ */
3192
+ private mergeServerUpserts;
3193
+ /**
3194
+ * Track multiple entities before adding them to the collection.
3195
+ * Does NOT add to the collection (the reducer's job).
3196
+ * @param entities The entities to add. They must all have their ids.
3197
+ * @param collection The entity collection
3198
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3199
+ */
3200
+ trackAddMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3201
+ /**
3202
+ * Track an entity before adding it to the collection.
3203
+ * Does NOT add to the collection (the reducer's job).
3204
+ * @param entity The entity to add. It must have an id.
3205
+ * @param collection The entity collection
3206
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3207
+ * If not specified, implementation supplies a default strategy.
3208
+ */
3209
+ trackAddOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3210
+ /**
3211
+ * Track multiple entities before removing them with the intention of deleting them on the server.
3212
+ * Does NOT remove from the collection (the reducer's job).
3213
+ * @param keys The primary keys of the entities to delete.
3214
+ * @param collection The entity collection
3215
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3216
+ */
3217
+ trackDeleteMany(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3218
+ /**
3219
+ * Track an entity before it is removed with the intention of deleting it on the server.
3220
+ * Does NOT remove from the collection (the reducer's job).
3221
+ * @param key The primary key of the entity to delete.
3222
+ * @param collection The entity collection
3223
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3224
+ */
3225
+ trackDeleteOne(key: number | string, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3226
+ /**
3227
+ * Track multiple entities before updating them in the collection.
3228
+ * Does NOT update the collection (the reducer's job).
3229
+ * @param updates The entities to update.
3230
+ * @param collection The entity collection
3231
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3232
+ */
3233
+ trackUpdateMany(updates: Update<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3234
+ /**
3235
+ * Track an entity before updating it in the collection.
3236
+ * Does NOT update the collection (the reducer's job).
3237
+ * @param update The entity to update.
3238
+ * @param collection The entity collection
3239
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3240
+ */
3241
+ trackUpdateOne(update: Update<T>, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3242
+ /**
3243
+ * Track multiple entities before upserting (adding and updating) them to the collection.
3244
+ * Does NOT update the collection (the reducer's job).
3245
+ * @param entities The entities to add or update. They must be complete entities with ids.
3246
+ * @param collection The entity collection
3247
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3248
+ */
3249
+ trackUpsertMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3250
+ /**
3251
+ * Track an entity before upsert (adding and updating) it to the collection.
3252
+ * Does NOT update the collection (the reducer's job).
3253
+ * @param entities The entity to add or update. It must be a complete entity with its id.
3254
+ * @param collection The entity collection
3255
+ * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
3256
+ */
3257
+ trackUpsertOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
3258
+ /**
3259
+ * Revert the unsaved changes for all collection.
3260
+ * Harmless when there are no entity changes to undo.
3261
+ * @param collection The entity collection
3262
+ */
3263
+ undoAll(collection: EntityCollection<T>): EntityCollection<T>;
3264
+ /**
3265
+ * Revert the unsaved changes for the given entities.
3266
+ * Harmless when there are no entity changes to undo.
3267
+ * @param entityOrIdList The entities to revert or their ids.
3268
+ * @param collection The entity collection
3269
+ */
3270
+ undoMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
3271
+ /**
3272
+ * Revert the unsaved changes for the given entity.
3273
+ * Harmless when there are no entity changes to undo.
3274
+ * @param entityOrId The entity to revert or its id.
3275
+ * @param collection The entity collection
3276
+ */
3277
+ undoOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
3278
+ }
3279
+
3280
+ declare class DefaultLogger implements Logger {
3281
+ error(message?: any, extra?: any): void;
3282
+ log(message?: any, extra?: any): void;
3283
+ warn(message?: any, extra?: any): void;
3284
+ static ɵfac: i0.ɵɵFactoryDeclaration<DefaultLogger, never>;
3285
+ static ɵprov: i0.ɵɵInjectableDeclaration<DefaultLogger>;
3286
+ }
3287
+
3288
+ declare class DefaultPluralizer {
3289
+ pluralNames: EntityPluralNames;
3290
+ constructor(pluralNames: EntityPluralNames[]);
3291
+ /**
3292
+ * Pluralize a singular name using common English language pluralization rules
3293
+ * Examples: "company" -> "companies", "employee" -> "employees", "tax" -> "taxes"
3294
+ */
3295
+ pluralize(name: string): string;
3296
+ /**
3297
+ * Register a mapping of entity type name to the entity name's plural
3298
+ * @param pluralNames {EntityPluralNames} plural names for entity types
3299
+ */
3300
+ registerPluralNames(pluralNames: EntityPluralNames): void;
3301
+ static ɵfac: i0.ɵɵFactoryDeclaration<DefaultPluralizer, [{ optional: true; }]>;
3302
+ static ɵprov: i0.ɵɵInjectableDeclaration<DefaultPluralizer>;
3303
+ }
3304
+
3305
+ /**
3306
+ Client-side id-generators
3307
+
3308
+ These GUID utility functions are not used by @ngrx/data itself at this time.
3309
+ They are included as candidates for generating persistable correlation ids if that becomes desirable.
3310
+ They are also safe for generating unique entity ids on the client.
3311
+
3312
+ Note they produce 32-character hexadecimal UUID strings,
3313
+ not the 128-bit representation found in server-side languages and databases.
3314
+
3315
+ These utilities are experimental and may be withdrawn or replaced in future.
3316
+ */
3317
+ /** Alias for getUuid(). Compare with getGuidComb(). */
3318
+ declare function getGuid(): string;
3319
+ /**
3320
+ * Creates a sortable, pseudo-GUID (globally unique identifier)
3321
+ * whose trailing 6 bytes (12 hex digits) are time-based
3322
+ * Start either with the given getTime() value, seedTime,
3323
+ * or get the current time in ms.
3324
+ *
3325
+ * @param seed {number} - optional seed for reproducible time-part
3326
+ */
3327
+ declare function getGuidComb(seed?: number): string;
3328
+ declare function guidComparer(l: string, r: string): number;
3329
+
3330
+ /**
3331
+ * Default function that returns the entity's primary key (pkey).
3332
+ * Assumes that the entity has an `id` pkey property.
3333
+ * Returns `undefined` if no entity or `id`.
3334
+ * Every selectId fn must return `undefined` when it cannot produce a full pkey.
3335
+ */
3336
+ declare function defaultSelectId(entity: any): any;
3337
+ /**
3338
+ * Flatten first arg if it is an array
3339
+ * Allows fn with ...rest signature to be called with an array instead of spread
3340
+ * Example:
3341
+ * ```
3342
+ * // See entity-action-operators.ts
3343
+ * const persistOps = [EntityOp.QUERY_ALL, EntityOp.ADD, ...];
3344
+ * actions.pipe(ofEntityOp(...persistOps)) // works
3345
+ * actions.pipe(ofEntityOp(persistOps)) // also works
3346
+ * ```
3347
+ * */
3348
+ declare function flattenArgs<T>(args?: any[]): T[];
3349
+ /**
3350
+ * Return a function that converts an entity (or partial entity) into the `Update<T>`
3351
+ * whose `id` is the primary key and
3352
+ * `changes` is the entity (or partial entity of changes).
3353
+ */
3354
+ declare function toUpdateFactory<T>(selectId?: IdSelector<T>): (entity: Partial<T>) => Update<T>;
3355
+
3356
+ interface EntityDataModuleConfig {
3357
+ entityMetadata?: EntityMetadataMap;
3358
+ entityCacheMetaReducers?: (MetaReducer<EntityCache> | InjectionToken<MetaReducer<EntityCache>>)[];
3359
+ entityCollectionMetaReducers?: MetaReducer<EntityCollection, EntityAction>[];
3360
+ initialEntityCacheState?: EntityCache | (() => EntityCache);
3361
+ pluralNames?: {
3362
+ [name: string]: string;
3363
+ };
3364
+ }
3365
+
3366
+ /**
3367
+ * Module without effects or dataservices which means no HTTP calls
3368
+ * This module helpful for internal testing.
3369
+ * Also helpful for apps that handle server access on their own and
3370
+ * therefore opt-out of @ngrx/effects for entities
3371
+ */
3372
+ declare class EntityDataModuleWithoutEffects {
3373
+ static forRoot(config: EntityDataModuleConfig): ModuleWithProviders<EntityDataModuleWithoutEffects>;
3374
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDataModuleWithoutEffects, never>;
3375
+ static ɵmod: i0.ɵɵNgModuleDeclaration<EntityDataModuleWithoutEffects, never, never, never>;
3376
+ static ɵinj: i0.ɵɵInjectorDeclaration<EntityDataModuleWithoutEffects>;
3377
+ }
3378
+
3379
+ /**
3380
+ * entity-data main module includes effects and HTTP data services
3381
+ * Configure with `forRoot`.
3382
+ * No `forFeature` yet.
3383
+ */
3384
+ declare class EntityDataModule {
3385
+ static forRoot(config: EntityDataModuleConfig): ModuleWithProviders<EntityDataModule>;
3386
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityDataModule, never>;
3387
+ static ɵmod: i0.ɵɵNgModuleDeclaration<EntityDataModule, never, [typeof EntityDataModuleWithoutEffects], never>;
3388
+ static ɵinj: i0.ɵɵInjectorDeclaration<EntityDataModule>;
3389
+ }
3390
+
3391
+ /**
3392
+ * Sets up base entity data providers with entity config.
3393
+ * This function should to be used at the root level.
3394
+ *
3395
+ * @usageNotes
3396
+ *
3397
+ * ### Providing entity data with effects
3398
+ *
3399
+ * When used with `withEffects` feature, the `provideEntityData` function is
3400
+ * an alternative to `EntityDataModule.forRoot`
3401
+ *
3402
+ * ```ts
3403
+ * import { provideStore } from '@ngrx/store';
3404
+ * import { provideEffects } from '@ngrx/effects';
3405
+ * import {
3406
+ * EntityMetadataMap,
3407
+ * provideEntityData,
3408
+ * withEffects,
3409
+ * } from '@ngrx/data';
3410
+ *
3411
+ * const entityMetadata: EntityMetadataMap = {
3412
+ * Hero: {},
3413
+ * Villain: {},
3414
+ * };
3415
+ * const pluralNames = { Hero: 'Heroes' };
3416
+ *
3417
+ * bootstrapApplication(AppComponent, {
3418
+ * providers: [
3419
+ * provideStore(),
3420
+ * provideEffects(),
3421
+ * provideEntityData({ entityMetadata, pluralNames }, withEffects()),
3422
+ * ],
3423
+ * });
3424
+ * ```
3425
+ *
3426
+ * ### Providing entity data without effects
3427
+ *
3428
+ * When used without `withEffects` feature, the `provideEntityData` function is
3429
+ * an alternative to `EntityDataModuleWithoutEffects.forRoot`.
3430
+ *
3431
+ * ```ts
3432
+ * import { provideStore } from '@ngrx/store';
3433
+ * import { EntityMetadataMap, provideEntityData } from '@ngrx/data';
3434
+ *
3435
+ * const entityMetadata: EntityMetadataMap = {
3436
+ * Musician: {},
3437
+ * Song: {},
3438
+ * };
3439
+ *
3440
+ * bootstrapApplication(AppComponent, {
3441
+ * providers: [
3442
+ * provideStore(),
3443
+ * provideEntityData({ entityMetadata }),
3444
+ * ],
3445
+ * });
3446
+ * ```
3447
+ *
3448
+ */
3449
+ declare function provideEntityData(config: EntityDataModuleConfig, ...features: EntityDataFeature[]): EnvironmentProviders;
3450
+ declare enum EntityDataFeatureKind {
3451
+ WithEffects = 0
3452
+ }
3453
+ interface EntityDataFeature {
3454
+ ɵkind: EntityDataFeatureKind;
3455
+ ɵproviders: Provider[];
3456
+ }
3457
+ /**
3458
+ * Registers entity data effects and provides HTTP data services.
3459
+ *
3460
+ * @see `provideEntityData`
3461
+ */
3462
+ declare function withEffects(): EntityDataFeature;
3463
+
3464
+ export { ChangeSetItemFactory, ChangeSetOperation, ChangeType, ClearCollections, CorrelationIdGenerator, DataServiceError, DefaultDataService, DefaultDataServiceConfig, DefaultDataServiceFactory, DefaultHttpUrlGenerator, DefaultLogger, DefaultPersistenceResultHandler, DefaultPluralizer, ENTITY_CACHE_META_REDUCERS, ENTITY_CACHE_NAME, ENTITY_CACHE_NAME_TOKEN, ENTITY_CACHE_SELECTOR_TOKEN, ENTITY_COLLECTION_META_REDUCERS, ENTITY_METADATA_TOKEN, EntityActionFactory, EntityActionGuard, EntityCacheAction, EntityCacheDataService, EntityCacheDispatcher, EntityCacheEffects, EntityCacheReducerFactory, EntityChangeTrackerBase, EntityCollectionCreator, EntityCollectionReducerFactory, EntityCollectionReducerMethods, EntityCollectionReducerMethodsFactory, EntityCollectionReducerRegistry, EntityCollectionServiceBase, EntityCollectionServiceElementsFactory, EntityCollectionServiceFactory, EntityDataModule, EntityDataModuleWithoutEffects, EntityDataService, EntityDefinitionService, EntityDispatcherBase, EntityDispatcherDefaultOptions, EntityDispatcherFactory, EntityEffects, EntityHttpResourceUrls, EntityOp, EntitySelectors$Factory, EntitySelectorsFactory, EntityServices, EntityServicesBase, EntityServicesElements, HttpUrlGenerator, INITIAL_ENTITY_CACHE_STATE, LoadCollections, Logger, MergeQuerySet, MergeStrategy, OP_ERROR, OP_SUCCESS, PLURAL_NAMES_TOKEN, PersistanceCanceled, PersistenceResultHandler, Pluralizer, PropsFilterFnFactory, SaveEntities, SaveEntitiesCancel, SaveEntitiesCanceled, SaveEntitiesError, SaveEntitiesSuccess, SetEntityCache, changeSetItemFactory, createEmptyEntityCollection, createEntityCacheSelector, createEntityDefinition, defaultSelectId, entityCacheSelectorProvider, excludeEmptyChangeSetItems, flattenArgs, getGuid, getGuidComb, guidComparer, makeErrorOp, makeSuccessOp, normalizeRoot, ofEntityOp, ofEntityType, persistOps, provideEntityData, toUpdateFactory, withEffects };
3465
+ export type { ChangeSet, ChangeSetAdd, ChangeSetDelete, ChangeSetItem, ChangeSetUpdate, ChangeSetUpsert, ChangeState, ChangeStateMap, CollectionSelectors, EntityAction, EntityActionDataServiceError, EntityActionOptions, EntityActionPayload, EntityCache, EntityCacheCommands, EntityCacheQuerySet, EntityCacheSelector, EntityChangeTracker, EntityCollection, EntityCollectionDataService, EntityCollectionReducer, EntityCollectionReducerMethodMap, EntityCollectionReducers, EntityCollectionService, EntityCollectionServiceElements, EntityCollectionServiceMap, EntityCommands, EntityDataModuleConfig, EntityDefinition, EntityDefinitions, EntityDispatcher, EntityFilterFn, EntityMetadata, EntityMetadataMap, EntityPluralNames, EntitySelectors, EntitySelectors$, EntityServerCommands, HttpMethods, HttpOptions, HttpResourceUrls, QueryParams, RequestData, UpdateResponseData };