@ngrx/data 20.0.1 → 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 (102) hide show
  1. package/fesm2022/ngrx-data.mjs +87 -87
  2. package/fesm2022/ngrx-data.mjs.map +1 -1
  3. package/package.json +8 -8
  4. package/schematics/ng-add/index.js +39 -42
  5. package/schematics/ng-add/index.js.map +1 -1
  6. package/schematics/ng-add/schema.js +0 -2
  7. package/schematics-core/index.js +24 -75
  8. package/schematics-core/index.js.map +1 -1
  9. package/schematics-core/utility/ast-utils.js +28 -44
  10. package/schematics-core/utility/ast-utils.js.map +1 -1
  11. package/schematics-core/utility/change.js +8 -15
  12. package/schematics-core/utility/change.js.map +1 -1
  13. package/schematics-core/utility/config.js +4 -8
  14. package/schematics-core/utility/config.js.map +1 -1
  15. package/schematics-core/utility/find-component.js +17 -22
  16. package/schematics-core/utility/find-component.js.map +1 -1
  17. package/schematics-core/utility/find-module.js +19 -24
  18. package/schematics-core/utility/find-module.js.map +1 -1
  19. package/schematics-core/utility/json-utilts.js +1 -4
  20. package/schematics-core/utility/json-utilts.js.map +1 -1
  21. package/schematics-core/utility/libs-version.js +1 -4
  22. package/schematics-core/utility/libs-version.js.map +1 -1
  23. package/schematics-core/utility/ngrx-utils.js +28 -36
  24. package/schematics-core/utility/ngrx-utils.js.map +1 -1
  25. package/schematics-core/utility/package.js +1 -4
  26. package/schematics-core/utility/package.js.map +1 -1
  27. package/schematics-core/utility/parse-name.js +5 -8
  28. package/schematics-core/utility/parse-name.js.map +1 -1
  29. package/schematics-core/utility/project.js +9 -15
  30. package/schematics-core/utility/project.js.map +1 -1
  31. package/schematics-core/utility/standalone.js +13 -18
  32. package/schematics-core/utility/standalone.js.map +1 -1
  33. package/schematics-core/utility/strings.js +9 -20
  34. package/schematics-core/utility/strings.js.map +1 -1
  35. package/schematics-core/utility/update.js +4 -7
  36. package/schematics-core/utility/update.js.map +1 -1
  37. package/schematics-core/utility/visitors.js +16 -30
  38. package/schematics-core/utility/visitors.js.map +1 -1
  39. package/types/ngrx-data.d.ts +3465 -0
  40. package/index.d.ts +0 -6
  41. package/public_api.d.ts +0 -1
  42. package/src/actions/entity-action-factory.d.ts +0 -38
  43. package/src/actions/entity-action-guard.d.ts +0 -33
  44. package/src/actions/entity-action-operators.d.ts +0 -30
  45. package/src/actions/entity-action.d.ts +0 -37
  46. package/src/actions/entity-cache-action.d.ts +0 -147
  47. package/src/actions/entity-cache-change-set.d.ts +0 -66
  48. package/src/actions/entity-op.d.ts +0 -70
  49. package/src/actions/merge-strategy.d.ts +0 -20
  50. package/src/actions/update-response-data.d.ts +0 -20
  51. package/src/dataservices/data-service-error.d.ts +0 -18
  52. package/src/dataservices/default-data-service-config.d.ts +0 -27
  53. package/src/dataservices/default-data.service.d.ts +0 -57
  54. package/src/dataservices/entity-cache-data.service.d.ts +0 -58
  55. package/src/dataservices/entity-data.service.d.ts +0 -48
  56. package/src/dataservices/http-url-generator.d.ts +0 -94
  57. package/src/dataservices/interfaces.d.ts +0 -61
  58. package/src/dataservices/persistence-result-handler.service.d.ts +0 -30
  59. package/src/dispatchers/entity-cache-dispatcher.d.ts +0 -114
  60. package/src/dispatchers/entity-commands.d.ts +0 -217
  61. package/src/dispatchers/entity-dispatcher-base.d.ts +0 -269
  62. package/src/dispatchers/entity-dispatcher-default-options.d.ts +0 -23
  63. package/src/dispatchers/entity-dispatcher-factory.d.ts +0 -46
  64. package/src/dispatchers/entity-dispatcher.d.ts +0 -58
  65. package/src/effects/entity-cache-effects.d.ts +0 -46
  66. package/src/effects/entity-effects-scheduler.d.ts +0 -4
  67. package/src/effects/entity-effects.d.ts +0 -55
  68. package/src/entity-data-config.d.ts +0 -15
  69. package/src/entity-data-without-effects.module.d.ts +0 -15
  70. package/src/entity-data.module.d.ts +0 -15
  71. package/src/entity-metadata/entity-definition.d.ts +0 -16
  72. package/src/entity-metadata/entity-definition.service.d.ts +0 -62
  73. package/src/entity-metadata/entity-filters.d.ts +0 -12
  74. package/src/entity-metadata/entity-metadata.d.ts +0 -19
  75. package/src/entity-services/entity-collection-service-base.d.ts +0 -299
  76. package/src/entity-services/entity-collection-service-elements-factory.d.ts +0 -28
  77. package/src/entity-services/entity-collection-service-factory.d.ts +0 -22
  78. package/src/entity-services/entity-collection-service.d.ts +0 -37
  79. package/src/entity-services/entity-services-base.d.ts +0 -79
  80. package/src/entity-services/entity-services-elements.d.ts +0 -41
  81. package/src/entity-services/entity-services.d.ts +0 -50
  82. package/src/index.d.ts +0 -65
  83. package/src/provide-entity-data.d.ts +0 -78
  84. package/src/reducers/constants.d.ts +0 -8
  85. package/src/reducers/entity-cache-reducer.d.ts +0 -50
  86. package/src/reducers/entity-cache.d.ts +0 -4
  87. package/src/reducers/entity-change-tracker-base.d.ts +0 -181
  88. package/src/reducers/entity-change-tracker.d.ts +0 -169
  89. package/src/reducers/entity-collection-creator.d.ts +0 -15
  90. package/src/reducers/entity-collection-reducer-methods.d.ts +0 -365
  91. package/src/reducers/entity-collection-reducer-registry.d.ts +0 -47
  92. package/src/reducers/entity-collection-reducer.d.ts +0 -14
  93. package/src/reducers/entity-collection.d.ts +0 -41
  94. package/src/selectors/entity-cache-selector.d.ts +0 -7
  95. package/src/selectors/entity-selectors$.d.ts +0 -63
  96. package/src/selectors/entity-selectors.d.ts +0 -117
  97. package/src/utils/correlation-id-generator.d.ts +0 -20
  98. package/src/utils/default-logger.d.ts +0 -9
  99. package/src/utils/default-pluralizer.d.ts +0 -18
  100. package/src/utils/guid-fns.d.ts +0 -24
  101. package/src/utils/interfaces.d.ts +0 -16
  102. package/src/utils/utilities.d.ts +0 -26
@@ -1,78 +0,0 @@
1
- import { EnvironmentProviders, Provider } from '@angular/core';
2
- import { EntityDataModuleConfig } from './entity-data-config';
3
- export declare const BASE_ENTITY_DATA_PROVIDERS: Array<Provider | EnvironmentProviders>;
4
- export declare const ENTITY_DATA_EFFECTS_PROVIDERS: Array<Provider | EnvironmentProviders>;
5
- export declare function provideEntityDataConfig(config: EntityDataModuleConfig): Provider[];
6
- /**
7
- * Sets up base entity data providers with entity config.
8
- * This function should to be used at the root level.
9
- *
10
- * @usageNotes
11
- *
12
- * ### Providing entity data with effects
13
- *
14
- * When used with `withEffects` feature, the `provideEntityData` function is
15
- * an alternative to `EntityDataModule.forRoot`
16
- *
17
- * ```ts
18
- * import { provideStore } from '@ngrx/store';
19
- * import { provideEffects } from '@ngrx/effects';
20
- * import {
21
- * EntityMetadataMap,
22
- * provideEntityData,
23
- * withEffects,
24
- * } from '@ngrx/data';
25
- *
26
- * const entityMetadata: EntityMetadataMap = {
27
- * Hero: {},
28
- * Villain: {},
29
- * };
30
- * const pluralNames = { Hero: 'Heroes' };
31
- *
32
- * bootstrapApplication(AppComponent, {
33
- * providers: [
34
- * provideStore(),
35
- * provideEffects(),
36
- * provideEntityData({ entityMetadata, pluralNames }, withEffects()),
37
- * ],
38
- * });
39
- * ```
40
- *
41
- * ### Providing entity data without effects
42
- *
43
- * When used without `withEffects` feature, the `provideEntityData` function is
44
- * an alternative to `EntityDataModuleWithoutEffects.forRoot`.
45
- *
46
- * ```ts
47
- * import { provideStore } from '@ngrx/store';
48
- * import { EntityMetadataMap, provideEntityData } from '@ngrx/data';
49
- *
50
- * const entityMetadata: EntityMetadataMap = {
51
- * Musician: {},
52
- * Song: {},
53
- * };
54
- *
55
- * bootstrapApplication(AppComponent, {
56
- * providers: [
57
- * provideStore(),
58
- * provideEntityData({ entityMetadata }),
59
- * ],
60
- * });
61
- * ```
62
- *
63
- */
64
- export declare function provideEntityData(config: EntityDataModuleConfig, ...features: EntityDataFeature[]): EnvironmentProviders;
65
- declare enum EntityDataFeatureKind {
66
- WithEffects = 0
67
- }
68
- interface EntityDataFeature {
69
- ɵkind: EntityDataFeatureKind;
70
- ɵproviders: Provider[];
71
- }
72
- /**
73
- * Registers entity data effects and provides HTTP data services.
74
- *
75
- * @see `provideEntityData`
76
- */
77
- export declare function withEffects(): EntityDataFeature;
78
- export {};
@@ -1,8 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { MetaReducer } from '@ngrx/store';
3
- import { EntityCache } from './entity-cache';
4
- export declare const ENTITY_CACHE_NAME = "entityCache";
5
- export declare const ENTITY_CACHE_NAME_TOKEN: InjectionToken<string>;
6
- export declare const ENTITY_CACHE_META_REDUCERS: InjectionToken<MetaReducer<any, any>[]>;
7
- export declare const ENTITY_COLLECTION_META_REDUCERS: InjectionToken<MetaReducer<any, any>[]>;
8
- export declare const INITIAL_ENTITY_CACHE_STATE: InjectionToken<EntityCache | (() => EntityCache)>;
@@ -1,50 +0,0 @@
1
- import { Action, ActionReducer } from '@ngrx/store';
2
- import { EntityCache } from './entity-cache';
3
- import { ClearCollections, LoadCollections, MergeQuerySet, SaveEntities, SaveEntitiesCancel, SaveEntitiesError, SaveEntitiesSuccess } from '../actions/entity-cache-action';
4
- import { EntityCollectionCreator } from './entity-collection-creator';
5
- import { EntityCollectionReducerRegistry } from './entity-collection-reducer-registry';
6
- import { Logger } from '../utils/interfaces';
7
- import * as i0 from "@angular/core";
8
- /**
9
- * Creates the EntityCacheReducer via its create() method
10
- */
11
- export declare class EntityCacheReducerFactory {
12
- private entityCollectionCreator;
13
- private entityCollectionReducerRegistry;
14
- private logger;
15
- constructor(entityCollectionCreator: EntityCollectionCreator, entityCollectionReducerRegistry: EntityCollectionReducerRegistry, logger: Logger);
16
- /**
17
- * Create the @ngrx/data entity cache reducer which either responds to entity cache level actions
18
- * or (more commonly) delegates to an EntityCollectionReducer based on the action.payload.entityName.
19
- */
20
- create(): ActionReducer<EntityCache, Action>;
21
- /**
22
- * Reducer to clear multiple collections at the same time.
23
- * @param entityCache the entity cache
24
- * @param action a ClearCollections action whose payload is an array of collection names.
25
- * If empty array, does nothing. If no array, clears all the collections.
26
- */
27
- protected clearCollectionsReducer(entityCache: EntityCache, action: ClearCollections): EntityCache;
28
- /**
29
- * Reducer to load collection in the form of a hash of entity data for multiple collections.
30
- * @param entityCache the entity cache
31
- * @param action a LoadCollections action whose payload is the QuerySet of entity collections to load
32
- */
33
- protected loadCollectionsReducer(entityCache: EntityCache, action: LoadCollections): EntityCache;
34
- /**
35
- * Reducer to merge query sets in the form of a hash of entity data for multiple collections.
36
- * @param entityCache the entity cache
37
- * @param action a MergeQuerySet action with the query set and a MergeStrategy
38
- */
39
- protected mergeQuerySetReducer(entityCache: EntityCache, action: MergeQuerySet): EntityCache;
40
- protected saveEntitiesReducer(entityCache: EntityCache, action: SaveEntities): EntityCache;
41
- protected saveEntitiesCancelReducer(entityCache: EntityCache, action: SaveEntitiesCancel): EntityCache;
42
- protected saveEntitiesErrorReducer(entityCache: EntityCache, action: SaveEntitiesError): EntityCache;
43
- protected saveEntitiesSuccessReducer(entityCache: EntityCache, action: SaveEntitiesSuccess): EntityCache;
44
- /** Apply reducer for the action's EntityCollection (if the action targets a collection) */
45
- private applyCollectionReducer;
46
- /** Ensure loading is false for every collection in entityNames */
47
- private clearLoadingFlags;
48
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityCacheReducerFactory, never>;
49
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityCacheReducerFactory>;
50
- }
@@ -1,4 +0,0 @@
1
- import { EntityCollection } from './entity-collection';
2
- export interface EntityCache {
3
- [name: string]: EntityCollection<any>;
4
- }
@@ -1,181 +0,0 @@
1
- import { EntityAdapter, IdSelector, Update } from '@ngrx/entity';
2
- import { EntityCollection } from './entity-collection';
3
- import { EntityChangeTracker } from './entity-change-tracker';
4
- import { MergeStrategy } from '../actions/merge-strategy';
5
- import { UpdateResponseData } from '../actions/update-response-data';
6
- /**
7
- * The default implementation of EntityChangeTracker with
8
- * methods for tracking, committing, and reverting/undoing unsaved entity changes.
9
- * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.
10
- * See EntityChangeTracker docs.
11
- */
12
- export declare class EntityChangeTrackerBase<T> implements EntityChangeTracker<T> {
13
- private adapter;
14
- private selectId;
15
- constructor(adapter: EntityAdapter<T>, selectId: IdSelector<T>);
16
- /**
17
- * Commit all changes as when the collection has been completely reloaded from the server.
18
- * Harmless when there are no entity changes to commit.
19
- * @param collection The entity collection
20
- */
21
- commitAll(collection: EntityCollection<T>): EntityCollection<T>;
22
- /**
23
- * Commit changes for the given entities as when they have been refreshed from the server.
24
- * Harmless when there are no entity changes to commit.
25
- * @param entityOrIdList The entities to clear tracking or their ids.
26
- * @param collection The entity collection
27
- */
28
- commitMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
29
- /**
30
- * Commit changes for the given entity as when it have been refreshed from the server.
31
- * Harmless when no entity changes to commit.
32
- * @param entityOrId The entity to clear tracking or its id.
33
- * @param collection The entity collection
34
- */
35
- commitOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
36
- /**
37
- * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.
38
- * @param entities Entities returned from querying the server.
39
- * @param collection The entity collection
40
- * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.
41
- * Defaults to MergeStrategy.PreserveChanges.
42
- * @returns The merged EntityCollection.
43
- */
44
- mergeQueryResults(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
45
- /**
46
- * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.
47
- * The default is MergeStrategy.OverwriteChanges.
48
- * @param entities Entities returned from saving new entities to the server.
49
- * @param collection The entity collection
50
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
51
- * Defaults to MergeStrategy.OverwriteChanges.
52
- * @returns The merged EntityCollection.
53
- */
54
- mergeSaveAdds(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
55
- /**
56
- * Merge successful result of deleting entities on the server that have the given primary keys
57
- * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.
58
- * @param entities keys primary keys of the entities to remove/delete.
59
- * @param collection The entity collection
60
- * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.
61
- * Defaults to MergeStrategy.OverwriteChanges.
62
- * @returns The merged EntityCollection.
63
- */
64
- mergeSaveDeletes(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
65
- /**
66
- * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.
67
- * The default is MergeStrategy.OverwriteChanges.
68
- * @param updateResponseData Entity response data returned from saving updated entities to the server.
69
- * @param collection The entity collection
70
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
71
- * Defaults to MergeStrategy.OverwriteChanges.
72
- * @param [skipUnchanged] True means skip update if server didn't change it. False by default.
73
- * If the update was optimistic and the server didn't make more changes of its own
74
- * then the updates are already in the collection and shouldn't make them again.
75
- * @returns The merged EntityCollection.
76
- */
77
- mergeSaveUpdates(updateResponseData: UpdateResponseData<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy, skipUnchanged?: boolean): EntityCollection<T>;
78
- /**
79
- * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.
80
- * The default is MergeStrategy.OverwriteChanges.
81
- * @param entities Entities returned from saving upserts to the server.
82
- * @param collection The entity collection
83
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
84
- * Defaults to MergeStrategy.OverwriteChanges.
85
- * @returns The merged EntityCollection.
86
- */
87
- mergeSaveUpserts(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
88
- /**
89
- *
90
- * @param entities Entities to merge
91
- * @param collection Collection into which entities are merged
92
- * @param defaultMergeStrategy How to merge when action's MergeStrategy is unspecified
93
- * @param [mergeStrategy] The action's MergeStrategy
94
- */
95
- private mergeServerUpserts;
96
- /**
97
- * Track multiple entities before adding them to the collection.
98
- * Does NOT add to the collection (the reducer's job).
99
- * @param entities The entities to add. They must all have their ids.
100
- * @param collection The entity collection
101
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
102
- */
103
- trackAddMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
104
- /**
105
- * Track an entity before adding it to the collection.
106
- * Does NOT add to the collection (the reducer's job).
107
- * @param entity The entity to add. It must have an id.
108
- * @param collection The entity collection
109
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
110
- * If not specified, implementation supplies a default strategy.
111
- */
112
- trackAddOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
113
- /**
114
- * Track multiple entities before removing them with the intention of deleting them on the server.
115
- * Does NOT remove from the collection (the reducer's job).
116
- * @param keys The primary keys of the entities to delete.
117
- * @param collection The entity collection
118
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
119
- */
120
- trackDeleteMany(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
121
- /**
122
- * Track an entity before it is removed with the intention of deleting it on the server.
123
- * Does NOT remove from the collection (the reducer's job).
124
- * @param key The primary key of the entity to delete.
125
- * @param collection The entity collection
126
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
127
- */
128
- trackDeleteOne(key: number | string, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
129
- /**
130
- * Track multiple entities before updating them in the collection.
131
- * Does NOT update the collection (the reducer's job).
132
- * @param updates The entities to update.
133
- * @param collection The entity collection
134
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
135
- */
136
- trackUpdateMany(updates: Update<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
137
- /**
138
- * Track an entity before updating it in the collection.
139
- * Does NOT update the collection (the reducer's job).
140
- * @param update The entity to update.
141
- * @param collection The entity collection
142
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
143
- */
144
- trackUpdateOne(update: Update<T>, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
145
- /**
146
- * Track multiple entities before upserting (adding and updating) them to the collection.
147
- * Does NOT update the collection (the reducer's job).
148
- * @param entities The entities to add or update. They must be complete entities with ids.
149
- * @param collection The entity collection
150
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
151
- */
152
- trackUpsertMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
153
- /**
154
- * Track an entity before upsert (adding and updating) it to the collection.
155
- * Does NOT update the collection (the reducer's job).
156
- * @param entities The entity to add or update. It must be a complete entity with its id.
157
- * @param collection The entity collection
158
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
159
- */
160
- trackUpsertOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
161
- /**
162
- * Revert the unsaved changes for all collection.
163
- * Harmless when there are no entity changes to undo.
164
- * @param collection The entity collection
165
- */
166
- undoAll(collection: EntityCollection<T>): EntityCollection<T>;
167
- /**
168
- * Revert the unsaved changes for the given entities.
169
- * Harmless when there are no entity changes to undo.
170
- * @param entityOrIdList The entities to revert or their ids.
171
- * @param collection The entity collection
172
- */
173
- undoMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
174
- /**
175
- * Revert the unsaved changes for the given entity.
176
- * Harmless when there are no entity changes to undo.
177
- * @param entityOrId The entity to revert or its id.
178
- * @param collection The entity collection
179
- */
180
- undoOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
181
- }
@@ -1,169 +0,0 @@
1
- import { Update } from '@ngrx/entity';
2
- import { EntityCollection } from './entity-collection';
3
- import { MergeStrategy } from '../actions/merge-strategy';
4
- import { UpdateResponseData } from '../actions/update-response-data';
5
- /**
6
- * Methods for tracking, committing, and reverting/undoing unsaved entity changes.
7
- * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.
8
- * See EntityChangeTracker docs.
9
- */
10
- export interface EntityChangeTracker<T> {
11
- /**
12
- * Commit all changes as when the collection has been completely reloaded from the server.
13
- * Harmless when there are no entity changes to commit.
14
- * @param collection The entity collection
15
- */
16
- commitAll(collection: EntityCollection<T>): EntityCollection<T>;
17
- /**
18
- * Commit changes for the given entities as when they have been refreshed from the server.
19
- * Harmless when there are no entity changes to commit.
20
- * @param entityOrIdList The entities to clear tracking or their ids.
21
- * @param collection The entity collection
22
- */
23
- commitMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
24
- /**
25
- * Commit changes for the given entity as when it have been refreshed from the server.
26
- * Harmless when no entity changes to commit.
27
- * @param entityOrId The entity to clear tracking or its id.
28
- * @param collection The entity collection
29
- */
30
- commitOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
31
- /**
32
- * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.
33
- * @param entities Entities returned from querying the server.
34
- * @param collection The entity collection
35
- * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.
36
- * If not specified, implementation supplies a default strategy.
37
- * @returns The merged EntityCollection.
38
- */
39
- mergeQueryResults(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
40
- /**
41
- * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.
42
- * The default is MergeStrategy.OverwriteChanges.
43
- * @param entities Entities returned from saving new entities to the server.
44
- * @param collection The entity collection
45
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
46
- * If not specified, implementation supplies a default strategy.
47
- * @returns The merged EntityCollection.
48
- */
49
- mergeSaveAdds(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
50
- /**
51
- * Merge successful result of deleting entities on the server that have the given primary keys
52
- * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.
53
- * @param entities keys primary keys of the entities to remove/delete.
54
- * @param collection The entity collection
55
- * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.
56
- * If not specified, implementation supplies a default strategy.
57
- * @returns The merged EntityCollection.
58
- */
59
- mergeSaveDeletes(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
60
- /**
61
- * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.
62
- * The default is MergeStrategy.OverwriteChanges.
63
- * @param entities Entities returned from saving upsert entities to the server.
64
- * @param collection The entity collection
65
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
66
- * If not specified, implementation supplies a default strategy.
67
- * @returns The merged EntityCollection.
68
- */
69
- mergeSaveUpserts(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
70
- /**
71
- * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.
72
- * The default is MergeStrategy.OverwriteChanges.
73
- * @param updates Entity response data returned from saving updated entities to the server.
74
- * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.
75
- * If not specified, implementation supplies a default strategy.
76
- * @param [skipUnchanged] True means skip update if server didn't change it. False by default.
77
- * If the update was optimistic and the server didn't make more changes of its own
78
- * then the updates are already in the collection and shouldn't make them again.
79
- * @param collection The entity collection
80
- * @returns The merged EntityCollection.
81
- */
82
- mergeSaveUpdates(updates: UpdateResponseData<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy, skipUnchanged?: boolean): EntityCollection<T>;
83
- /**
84
- * Track multiple entities before adding them to the collection.
85
- * Does NOT add to the collection (the reducer's job).
86
- * @param entities The entities to add. They must all have their ids.
87
- * @param collection The entity collection
88
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
89
- * If not specified, implementation supplies a default strategy.
90
- */
91
- trackAddMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
92
- /**
93
- * Track an entity before adding it to the collection.
94
- * Does NOT add to the collection (the reducer's job).
95
- * @param entity The entity to add. It must have an id.
96
- * @param collection The entity collection
97
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
98
- * If not specified, implementation supplies a default strategy.
99
- */
100
- trackAddOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
101
- /**
102
- * Track multiple entities before removing them with the intention of deleting them on the server.
103
- * Does NOT remove from the collection (the reducer's job).
104
- * @param keys The primary keys of the entities to delete.
105
- * @param collection The entity collection
106
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
107
- */
108
- trackDeleteMany(keys: (number | string)[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
109
- /**
110
- * Track an entity before it is removed with the intention of deleting it on the server.
111
- * Does NOT remove from the collection (the reducer's job).
112
- * @param key The primary key of the entity to delete.
113
- * @param collection The entity collection
114
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
115
- */
116
- trackDeleteOne(key: number | string, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
117
- /**
118
- * Track multiple entities before updating them in the collection.
119
- * Does NOT update the collection (the reducer's job).
120
- * @param updates The entities to update.
121
- * @param collection The entity collection
122
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
123
- */
124
- trackUpdateMany(updates: Update<T>[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
125
- /**
126
- * Track an entity before updating it in the collection.
127
- * Does NOT update the collection (the reducer's job).
128
- * @param update The entity to update.
129
- * @param collection The entity collection
130
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
131
- */
132
- trackUpdateOne(update: Update<T>, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
133
- /**
134
- * Track multiple entities before upserting (adding and updating) them to the collection.
135
- * Does NOT update the collection (the reducer's job).
136
- * @param entities The entities to add or update. They must be complete entities with ids.
137
- * @param collection The entity collection
138
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
139
- */
140
- trackUpsertMany(entities: T[], collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
141
- /**
142
- * Track an entity before upsert (adding and updating) it to the collection.
143
- * Does NOT update the collection (the reducer's job).
144
- * @param entities The entity to add or update. It must be a complete entity with its id.
145
- * @param collection The entity collection
146
- * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.
147
- */
148
- trackUpsertOne(entity: T, collection: EntityCollection<T>, mergeStrategy?: MergeStrategy): EntityCollection<T>;
149
- /**
150
- * Revert the unsaved changes for all collection.
151
- * Harmless when there are no entity changes to undo.
152
- * @param collection The entity collection
153
- */
154
- undoAll(collection: EntityCollection<T>): EntityCollection<T>;
155
- /**
156
- * Revert the unsaved changes for the given entities.
157
- * Harmless when there are no entity changes to undo.
158
- * @param entityOrIdList The entities to revert or their ids.
159
- * @param collection The entity collection
160
- */
161
- undoMany(entityOrIdList: (number | string | T)[], collection: EntityCollection<T>): EntityCollection<T>;
162
- /**
163
- * Revert the unsaved changes for the given entity.
164
- * Harmless when there are no entity changes to undo.
165
- * @param entityOrId The entity to revert or its id.
166
- * @param collection The entity collection
167
- */
168
- undoOne(entityOrId: number | string | T, collection: EntityCollection<T>): EntityCollection<T>;
169
- }
@@ -1,15 +0,0 @@
1
- import { EntityCollection } from './entity-collection';
2
- import { EntityDefinitionService } from '../entity-metadata/entity-definition.service';
3
- import * as i0 from "@angular/core";
4
- export declare class EntityCollectionCreator {
5
- private entityDefinitionService?;
6
- constructor(entityDefinitionService?: EntityDefinitionService);
7
- /**
8
- * Create the default collection for an entity type.
9
- * @param entityName {string} entity type name
10
- */
11
- create<T = any, S extends EntityCollection<T> = EntityCollection<T>>(entityName: string): S;
12
- static ɵfac: i0.ɵɵFactoryDeclaration<EntityCollectionCreator, [{ optional: true; }]>;
13
- static ɵprov: i0.ɵɵInjectableDeclaration<EntityCollectionCreator>;
14
- }
15
- export declare function createEmptyEntityCollection<T>(entityName?: string): EntityCollection<T>;