@ngrx/entity 11.0.0-rc.0 → 11.1.1

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 (44) hide show
  1. package/bundles/ngrx-entity.umd.js +39 -637
  2. package/bundles/ngrx-entity.umd.js.map +1 -1
  3. package/bundles/ngrx-entity.umd.min.js +1 -1
  4. package/bundles/ngrx-entity.umd.min.js.map +1 -1
  5. package/esm2015/index.js +2 -7
  6. package/esm2015/ngrx-entity.js +2 -7
  7. package/esm2015/public_api.js +2 -7
  8. package/esm2015/src/create_adapter.js +2 -19
  9. package/esm2015/src/entity_state.js +1 -18
  10. package/esm2015/src/index.js +1 -6
  11. package/esm2015/src/models.js +1 -245
  12. package/esm2015/src/sorted_state_adapter.js +11 -139
  13. package/esm2015/src/state_adapter.js +9 -31
  14. package/esm2015/src/state_selectors.js +5 -43
  15. package/esm2015/src/unsorted_state_adapter.js +11 -151
  16. package/esm2015/src/utils.js +1 -13
  17. package/fesm2015/ngrx-entity.js +37 -668
  18. package/fesm2015/ngrx-entity.js.map +1 -1
  19. package/package.json +3 -3
  20. package/schematics-core/index.js +4 -1
  21. package/schematics-core/index.js.map +1 -1
  22. package/schematics-core/utility/ast-utils.js +127 -1
  23. package/schematics-core/utility/ast-utils.js.map +1 -1
  24. package/schematics-core/utility/config.js +1 -1
  25. package/schematics-core/utility/config.js.map +1 -1
  26. package/schematics-core/utility/find-component.js +101 -0
  27. package/schematics-core/utility/find-component.js.map +1 -0
  28. package/schematics-core/utility/libs-version.js +1 -1
  29. package/schematics-core/utility/libs-version.js.map +1 -1
  30. package/schematics-core/utility/project.js +4 -2
  31. package/schematics-core/utility/project.js.map +1 -1
  32. package/CHANGELOG.md +0 -3
  33. package/esm2015/index.ngsummary.json +0 -1
  34. package/esm2015/ngrx-entity.ngsummary.json +0 -1
  35. package/esm2015/public_api.ngsummary.json +0 -1
  36. package/esm2015/src/create_adapter.ngsummary.json +0 -1
  37. package/esm2015/src/entity_state.ngsummary.json +0 -1
  38. package/esm2015/src/index.ngsummary.json +0 -1
  39. package/esm2015/src/models.ngsummary.json +0 -1
  40. package/esm2015/src/sorted_state_adapter.ngsummary.json +0 -1
  41. package/esm2015/src/state_adapter.ngsummary.json +0 -1
  42. package/esm2015/src/state_selectors.ngsummary.json +0 -1
  43. package/esm2015/src/unsorted_state_adapter.ngsummary.json +0 -1
  44. package/esm2015/src/utils.ngsummary.json +0 -1
@@ -1,80 +1,25 @@
1
1
  import { createSelector } from '@ngrx/store';
2
2
  import { isDevMode } from '@angular/core';
3
3
 
4
- /**
5
- * @fileoverview added by tsickle
6
- * Generated from: src/entity_state.ts
7
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
8
- */
9
- /**
10
- * @template V
11
- * @return {?}
12
- */
13
4
  function getInitialEntityState() {
14
5
  return {
15
6
  ids: [],
16
7
  entities: {},
17
8
  };
18
9
  }
19
- /**
20
- * @template V
21
- * @return {?}
22
- */
23
10
  function createInitialStateFactory() {
24
- /**
25
- * @param {?=} additionalState
26
- * @return {?}
27
- */
28
11
  function getInitialState(additionalState = {}) {
29
12
  return Object.assign(getInitialEntityState(), additionalState);
30
13
  }
31
14
  return { getInitialState };
32
15
  }
33
16
 
34
- /**
35
- * @fileoverview added by tsickle
36
- * Generated from: src/state_selectors.ts
37
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
38
- */
39
- /**
40
- * @template T
41
- * @return {?}
42
- */
43
17
  function createSelectorsFactory() {
44
- /**
45
- * @param {?=} selectState
46
- * @return {?}
47
- */
48
18
  function getSelectors(selectState) {
49
- /** @type {?} */
50
- const selectIds = (/**
51
- * @param {?} state
52
- * @return {?}
53
- */
54
- (state) => state.ids);
55
- /** @type {?} */
56
- const selectEntities = (/**
57
- * @param {?} state
58
- * @return {?}
59
- */
60
- (state) => state.entities);
61
- /** @type {?} */
62
- const selectAll = createSelector(selectIds, selectEntities, (/**
63
- * @param {?} ids
64
- * @param {?} entities
65
- * @return {?}
66
- */
67
- (ids, entities) => ids.map((/**
68
- * @param {?} id
69
- * @return {?}
70
- */
71
- (id) => ((/** @type {?} */ (entities)))[id]))));
72
- /** @type {?} */
73
- const selectTotal = createSelector(selectIds, (/**
74
- * @param {?} ids
75
- * @return {?}
76
- */
77
- (ids) => ids.length));
19
+ const selectIds = (state) => state.ids;
20
+ const selectEntities = (state) => state.entities;
21
+ const selectAll = createSelector(selectIds, selectEntities, (ids, entities) => ids.map((id) => entities[id]));
22
+ const selectTotal = createSelector(selectIds, (ids) => ids.length);
78
23
  if (!selectState) {
79
24
  return {
80
25
  selectIds,
@@ -93,39 +38,18 @@ function createSelectorsFactory() {
93
38
  return { getSelectors };
94
39
  }
95
40
 
96
- /**
97
- * @fileoverview added by tsickle
98
- * Generated from: src/state_adapter.ts
99
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
100
- */
101
- /** @enum {number} */
102
- const DidMutate = {
103
- EntitiesOnly: 0,
104
- Both: 1,
105
- None: 2,
106
- };
107
- DidMutate[DidMutate.EntitiesOnly] = 'EntitiesOnly';
108
- DidMutate[DidMutate.Both] = 'Both';
109
- DidMutate[DidMutate.None] = 'None';
110
- /**
111
- * @template V, R
112
- * @param {?} mutator
113
- * @return {?}
114
- */
41
+ var DidMutate;
42
+ (function (DidMutate) {
43
+ DidMutate[DidMutate["EntitiesOnly"] = 0] = "EntitiesOnly";
44
+ DidMutate[DidMutate["Both"] = 1] = "Both";
45
+ DidMutate[DidMutate["None"] = 2] = "None";
46
+ })(DidMutate || (DidMutate = {}));
115
47
  function createStateOperator(mutator) {
116
- return (/**
117
- * @template S
118
- * @param {?} arg
119
- * @param {?} state
120
- * @return {?}
121
- */
122
- function operation(arg, state) {
123
- /** @type {?} */
48
+ return function operation(arg, state) {
124
49
  const clonedEntityState = {
125
50
  ids: [...state.ids],
126
51
  entities: Object.assign({}, state.entities),
127
52
  };
128
- /** @type {?} */
129
53
  const didMutate = mutator(arg, clonedEntityState);
130
54
  if (didMutate === DidMutate.Both) {
131
55
  return Object.assign({}, state, clonedEntityState);
@@ -134,22 +58,10 @@ function createStateOperator(mutator) {
134
58
  return Object.assign(Object.assign({}, state), { entities: clonedEntityState.entities });
135
59
  }
136
60
  return state;
137
- });
61
+ };
138
62
  }
139
63
 
140
- /**
141
- * @fileoverview added by tsickle
142
- * Generated from: src/utils.ts
143
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
144
- */
145
- /**
146
- * @template T
147
- * @param {?} entity
148
- * @param {?} selectId
149
- * @return {?}
150
- */
151
64
  function selectIdValue(entity, selectId) {
152
- /** @type {?} */
153
65
  const key = selectId(entity);
154
66
  if (isDevMode() && key === undefined) {
155
67
  console.warn('@ngrx/entity: The entity passed to the `selectId` implementation returned undefined.', 'You should probably provide your own `selectId` implementation.', 'The entity that was passed:', entity, 'The `selectId` implementation:', selectId.toString());
@@ -157,24 +69,8 @@ function selectIdValue(entity, selectId) {
157
69
  return key;
158
70
  }
159
71
 
160
- /**
161
- * @fileoverview added by tsickle
162
- * Generated from: src/unsorted_state_adapter.ts
163
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
164
- */
165
- /**
166
- * @template T
167
- * @param {?} selectId
168
- * @return {?}
169
- */
170
72
  function createUnsortedStateAdapter(selectId) {
171
- /**
172
- * @param {?} entity
173
- * @param {?} state
174
- * @return {?}
175
- */
176
73
  function addOneMutably(entity, state) {
177
- /** @type {?} */
178
74
  const key = selectIdValue(entity, selectId);
179
75
  if (key in state.entities) {
180
76
  return DidMutate.None;
@@ -183,37 +79,20 @@ function createUnsortedStateAdapter(selectId) {
183
79
  state.entities[key] = entity;
184
80
  return DidMutate.Both;
185
81
  }
186
- /**
187
- * @param {?} entities
188
- * @param {?} state
189
- * @return {?}
190
- */
191
82
  function addManyMutably(entities, state) {
192
- /** @type {?} */
193
83
  let didMutate = false;
194
84
  for (const entity of entities) {
195
85
  didMutate = addOneMutably(entity, state) !== DidMutate.None || didMutate;
196
86
  }
197
87
  return didMutate ? DidMutate.Both : DidMutate.None;
198
88
  }
199
- /**
200
- * @param {?} entities
201
- * @param {?} state
202
- * @return {?}
203
- */
204
89
  function setAllMutably(entities, state) {
205
90
  state.ids = [];
206
91
  state.entities = {};
207
92
  addManyMutably(entities, state);
208
93
  return DidMutate.Both;
209
94
  }
210
- /**
211
- * @param {?} entity
212
- * @param {?} state
213
- * @return {?}
214
- */
215
95
  function setOneMutably(entity, state) {
216
- /** @type {?} */
217
96
  const key = selectIdValue(entity, selectId);
218
97
  if (key in state.entities) {
219
98
  state.entities[key] = entity;
@@ -223,74 +102,31 @@ function createUnsortedStateAdapter(selectId) {
223
102
  state.entities[key] = entity;
224
103
  return DidMutate.Both;
225
104
  }
226
- /**
227
- * @param {?} key
228
- * @param {?} state
229
- * @return {?}
230
- */
231
105
  function removeOneMutably(key, state) {
232
106
  return removeManyMutably([key], state);
233
107
  }
234
- /**
235
- * @param {?} keysOrPredicate
236
- * @param {?} state
237
- * @return {?}
238
- */
239
108
  function removeManyMutably(keysOrPredicate, state) {
240
- /** @type {?} */
241
109
  const keys = keysOrPredicate instanceof Array
242
110
  ? keysOrPredicate
243
- : state.ids.filter((/**
244
- * @param {?} key
245
- * @return {?}
246
- */
247
- (key) => keysOrPredicate(state.entities[key])));
248
- /** @type {?} */
111
+ : state.ids.filter((key) => keysOrPredicate(state.entities[key]));
249
112
  const didMutate = keys
250
- .filter((/**
251
- * @param {?} key
252
- * @return {?}
253
- */
254
- (key) => key in state.entities))
255
- .map((/**
256
- * @param {?} key
257
- * @return {?}
258
- */
259
- (key) => delete state.entities[key])).length > 0;
113
+ .filter((key) => key in state.entities)
114
+ .map((key) => delete state.entities[key]).length > 0;
260
115
  if (didMutate) {
261
- state.ids = state.ids.filter((/**
262
- * @param {?} id
263
- * @return {?}
264
- */
265
- (id) => id in state.entities));
116
+ state.ids = state.ids.filter((id) => id in state.entities);
266
117
  }
267
118
  return didMutate ? DidMutate.Both : DidMutate.None;
268
119
  }
269
- /**
270
- * @template S
271
- * @param {?} state
272
- * @return {?}
273
- */
274
120
  function removeAll(state) {
275
121
  return Object.assign({}, state, {
276
122
  ids: [],
277
123
  entities: {},
278
124
  });
279
125
  }
280
- /**
281
- * @param {?} keys
282
- * @param {?} update
283
- * @param {?} state
284
- * @return {?}
285
- */
286
126
  function takeNewKey(keys, update, state) {
287
- /** @type {?} */
288
127
  const original = state.entities[update.id];
289
- /** @type {?} */
290
128
  const updated = Object.assign({}, original, update.changes);
291
- /** @type {?} */
292
129
  const newKey = selectIdValue(updated, selectId);
293
- /** @type {?} */
294
130
  const hasNewKey = newKey !== update.id;
295
131
  if (hasNewKey) {
296
132
  keys[update.id] = newKey;
@@ -299,43 +135,18 @@ function createUnsortedStateAdapter(selectId) {
299
135
  state.entities[newKey] = updated;
300
136
  return hasNewKey;
301
137
  }
302
- /**
303
- * @param {?} update
304
- * @param {?} state
305
- * @return {?}
306
- */
307
138
  function updateOneMutably(update, state) {
308
139
  return updateManyMutably([update], state);
309
140
  }
310
- /**
311
- * @param {?} updates
312
- * @param {?} state
313
- * @return {?}
314
- */
315
141
  function updateManyMutably(updates, state) {
316
- /** @type {?} */
317
142
  const newKeys = {};
318
- updates = updates.filter((/**
319
- * @param {?} update
320
- * @return {?}
321
- */
322
- (update) => update.id in state.entities));
323
- /** @type {?} */
143
+ updates = updates.filter((update) => update.id in state.entities);
324
144
  const didMutateEntities = updates.length > 0;
325
145
  if (didMutateEntities) {
326
- /** @type {?} */
327
- const didMutateIds = updates.filter((/**
328
- * @param {?} update
329
- * @return {?}
330
- */
331
- (update) => takeNewKey(newKeys, update, state))).length >
146
+ const didMutateIds = updates.filter((update) => takeNewKey(newKeys, update, state)).length >
332
147
  0;
333
148
  if (didMutateIds) {
334
- state.ids = state.ids.map((/**
335
- * @param {?} id
336
- * @return {?}
337
- */
338
- (id) => newKeys[id] || id));
149
+ state.ids = state.ids.map((id) => newKeys[id] || id);
339
150
  return DidMutate.Both;
340
151
  }
341
152
  else {
@@ -344,72 +155,35 @@ function createUnsortedStateAdapter(selectId) {
344
155
  }
345
156
  return DidMutate.None;
346
157
  }
347
- /**
348
- * @param {?} map
349
- * @param {?} state
350
- * @return {?}
351
- */
352
158
  function mapMutably(map, state) {
353
- /** @type {?} */
354
- const changes = state.ids.reduce((/**
355
- * @param {?} changes
356
- * @param {?} id
357
- * @return {?}
358
- */
359
- (changes, id) => {
360
- /** @type {?} */
159
+ const changes = state.ids.reduce((changes, id) => {
361
160
  const change = map(state.entities[id]);
362
161
  if (change !== state.entities[id]) {
363
162
  changes.push({ id, changes: change });
364
163
  }
365
164
  return changes;
366
- }), []);
367
- /** @type {?} */
368
- const updates = changes.filter((/**
369
- * @param {?} __0
370
- * @return {?}
371
- */
372
- ({ id }) => id in state.entities));
165
+ }, []);
166
+ const updates = changes.filter(({ id }) => id in state.entities);
373
167
  return updateManyMutably(updates, state);
374
168
  }
375
- /**
376
- * @param {?} __0
377
- * @param {?} state
378
- * @return {?}
379
- */
380
169
  function mapOneMutably({ map, id }, state) {
381
- /** @type {?} */
382
170
  const entity = state.entities[id];
383
171
  if (!entity) {
384
172
  return DidMutate.None;
385
173
  }
386
- /** @type {?} */
387
174
  const updatedEntity = map(entity);
388
175
  return updateOneMutably({
389
176
  id: id,
390
177
  changes: updatedEntity,
391
178
  }, state);
392
179
  }
393
- /**
394
- * @param {?} entity
395
- * @param {?} state
396
- * @return {?}
397
- */
398
180
  function upsertOneMutably(entity, state) {
399
181
  return upsertManyMutably([entity], state);
400
182
  }
401
- /**
402
- * @param {?} entities
403
- * @param {?} state
404
- * @return {?}
405
- */
406
183
  function upsertManyMutably(entities, state) {
407
- /** @type {?} */
408
184
  const added = [];
409
- /** @type {?} */
410
185
  const updated = [];
411
186
  for (const entity of entities) {
412
- /** @type {?} */
413
187
  const id = selectIdValue(entity, selectId);
414
188
  if (id in state.entities) {
415
189
  updated.push({ id, changes: entity });
@@ -418,9 +192,7 @@ function createUnsortedStateAdapter(selectId) {
418
192
  added.push(entity);
419
193
  }
420
194
  }
421
- /** @type {?} */
422
195
  const didMutateByUpdated = updateManyMutably(updated, state);
423
- /** @type {?} */
424
196
  const didMutateByAdded = addManyMutably(added, state);
425
197
  switch (true) {
426
198
  case didMutateByAdded === DidMutate.None &&
@@ -450,39 +222,13 @@ function createUnsortedStateAdapter(selectId) {
450
222
  };
451
223
  }
452
224
 
453
- /**
454
- * @fileoverview added by tsickle
455
- * Generated from: src/sorted_state_adapter.ts
456
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
457
- */
458
- /**
459
- * @template T
460
- * @param {?} selectId
461
- * @param {?} sort
462
- * @return {?}
463
- */
464
225
  function createSortedStateAdapter(selectId, sort) {
465
226
  const { removeOne, removeMany, removeAll } = createUnsortedStateAdapter(selectId);
466
- /**
467
- * @param {?} entity
468
- * @param {?} state
469
- * @return {?}
470
- */
471
227
  function addOneMutably(entity, state) {
472
228
  return addManyMutably([entity], state);
473
229
  }
474
- /**
475
- * @param {?} newModels
476
- * @param {?} state
477
- * @return {?}
478
- */
479
230
  function addManyMutably(newModels, state) {
480
- /** @type {?} */
481
- const models = newModels.filter((/**
482
- * @param {?} model
483
- * @return {?}
484
- */
485
- (model) => !(selectIdValue(model, selectId) in state.entities)));
231
+ const models = newModels.filter((model) => !(selectIdValue(model, selectId) in state.entities));
486
232
  if (models.length === 0) {
487
233
  return DidMutate.None;
488
234
  }
@@ -491,31 +237,16 @@ function createSortedStateAdapter(selectId, sort) {
491
237
  return DidMutate.Both;
492
238
  }
493
239
  }
494
- /**
495
- * @param {?} models
496
- * @param {?} state
497
- * @return {?}
498
- */
499
240
  function setAllMutably(models, state) {
500
241
  state.entities = {};
501
242
  state.ids = [];
502
243
  addManyMutably(models, state);
503
244
  return DidMutate.Both;
504
245
  }
505
- /**
506
- * @param {?} entity
507
- * @param {?} state
508
- * @return {?}
509
- */
510
246
  function setOneMutably(entity, state) {
511
- /** @type {?} */
512
247
  const id = selectIdValue(entity, selectId);
513
248
  if (id in state.entities) {
514
- state.ids = state.ids.filter((/**
515
- * @param {?} val
516
- * @return {?}
517
- */
518
- (val) => val !== id));
249
+ state.ids = state.ids.filter((val) => val !== id);
519
250
  merge([entity], state);
520
251
  return DidMutate.Both;
521
252
  }
@@ -523,63 +254,31 @@ function createSortedStateAdapter(selectId, sort) {
523
254
  return addOneMutably(entity, state);
524
255
  }
525
256
  }
526
- /**
527
- * @param {?} update
528
- * @param {?} state
529
- * @return {?}
530
- */
531
257
  function updateOneMutably(update, state) {
532
258
  return updateManyMutably([update], state);
533
259
  }
534
- /**
535
- * @param {?} models
536
- * @param {?} update
537
- * @param {?} state
538
- * @return {?}
539
- */
540
260
  function takeUpdatedModel(models, update, state) {
541
261
  if (!(update.id in state.entities)) {
542
262
  return false;
543
263
  }
544
- /** @type {?} */
545
264
  const original = state.entities[update.id];
546
- /** @type {?} */
547
265
  const updated = Object.assign({}, original, update.changes);
548
- /** @type {?} */
549
266
  const newKey = selectIdValue(updated, selectId);
550
267
  delete state.entities[update.id];
551
268
  models.push(updated);
552
269
  return newKey !== update.id;
553
270
  }
554
- /**
555
- * @param {?} updates
556
- * @param {?} state
557
- * @return {?}
558
- */
559
271
  function updateManyMutably(updates, state) {
560
- /** @type {?} */
561
272
  const models = [];
562
- /** @type {?} */
563
- const didMutateIds = updates.filter((/**
564
- * @param {?} update
565
- * @return {?}
566
- */
567
- (update) => takeUpdatedModel(models, update, state)))
273
+ const didMutateIds = updates.filter((update) => takeUpdatedModel(models, update, state))
568
274
  .length > 0;
569
275
  if (models.length === 0) {
570
276
  return DidMutate.None;
571
277
  }
572
278
  else {
573
- /** @type {?} */
574
279
  const originalIds = state.ids;
575
- /** @type {?} */
576
280
  const updatedIndexes = [];
577
- state.ids = state.ids.filter((/**
578
- * @param {?} id
579
- * @param {?} index
580
- * @return {?}
581
- */
582
- (id, index) => {
281
+ state.ids = state.ids.filter((id, index) => {
583
282
  if (id in state.entities) {
584
283
  return true;
585
284
  }
@@ -587,14 +286,10 @@ function createSortedStateAdapter(selectId, sort) {
587
286
  updatedIndexes.push(index);
588
287
  return false;
589
288
  }
590
- }));
289
+ });
591
290
  merge(models, state);
592
291
  if (!didMutateIds &&
593
- updatedIndexes.every((/**
594
- * @param {?} i
595
- * @return {?}
596
- */
597
- (i) => state.ids[i] === originalIds[i]))) {
292
+ updatedIndexes.every((i) => state.ids[i] === originalIds[i])) {
598
293
  return DidMutate.EntitiesOnly;
599
294
  }
600
295
  else {
@@ -602,66 +297,34 @@ function createSortedStateAdapter(selectId, sort) {
602
297
  }
603
298
  }
604
299
  }
605
- /**
606
- * @param {?} updatesOrMap
607
- * @param {?} state
608
- * @return {?}
609
- */
610
300
  function mapMutably(updatesOrMap, state) {
611
- /** @type {?} */
612
- const updates = state.ids.reduce((/**
613
- * @param {?} changes
614
- * @param {?} id
615
- * @return {?}
616
- */
617
- (changes, id) => {
618
- /** @type {?} */
301
+ const updates = state.ids.reduce((changes, id) => {
619
302
  const change = updatesOrMap(state.entities[id]);
620
303
  if (change !== state.entities[id]) {
621
304
  changes.push({ id, changes: change });
622
305
  }
623
306
  return changes;
624
- }), []);
307
+ }, []);
625
308
  return updateManyMutably(updates, state);
626
309
  }
627
- /**
628
- * @param {?} __0
629
- * @param {?} state
630
- * @return {?}
631
- */
632
310
  function mapOneMutably({ map, id }, state) {
633
- /** @type {?} */
634
311
  const entity = state.entities[id];
635
312
  if (!entity) {
636
313
  return DidMutate.None;
637
314
  }
638
- /** @type {?} */
639
315
  const updatedEntity = map(entity);
640
316
  return updateOneMutably({
641
317
  id: id,
642
318
  changes: updatedEntity,
643
319
  }, state);
644
320
  }
645
- /**
646
- * @param {?} entity
647
- * @param {?} state
648
- * @return {?}
649
- */
650
321
  function upsertOneMutably(entity, state) {
651
322
  return upsertManyMutably([entity], state);
652
323
  }
653
- /**
654
- * @param {?} entities
655
- * @param {?} state
656
- * @return {?}
657
- */
658
324
  function upsertManyMutably(entities, state) {
659
- /** @type {?} */
660
325
  const added = [];
661
- /** @type {?} */
662
326
  const updated = [];
663
327
  for (const entity of entities) {
664
- /** @type {?} */
665
328
  const id = selectIdValue(entity, selectId);
666
329
  if (id in state.entities) {
667
330
  updated.push({ id, changes: entity });
@@ -670,9 +333,7 @@ function createSortedStateAdapter(selectId, sort) {
670
333
  added.push(entity);
671
334
  }
672
335
  }
673
- /** @type {?} */
674
336
  const didMutateByUpdated = updateManyMutably(updated, state);
675
- /** @type {?} */
676
337
  const didMutateByAdded = addManyMutably(added, state);
677
338
  switch (true) {
678
339
  case didMutateByAdded === DidMutate.None &&
@@ -685,27 +346,15 @@ function createSortedStateAdapter(selectId, sort) {
685
346
  return DidMutate.EntitiesOnly;
686
347
  }
687
348
  }
688
- /**
689
- * @param {?} models
690
- * @param {?} state
691
- * @return {?}
692
- */
693
349
  function merge(models, state) {
694
350
  models.sort(sort);
695
- /** @type {?} */
696
351
  const ids = [];
697
- /** @type {?} */
698
352
  let i = 0;
699
- /** @type {?} */
700
353
  let j = 0;
701
354
  while (i < models.length && j < state.ids.length) {
702
- /** @type {?} */
703
355
  const model = models[i];
704
- /** @type {?} */
705
356
  const modelId = selectIdValue(model, selectId);
706
- /** @type {?} */
707
357
  const entityId = state.ids[j];
708
- /** @type {?} */
709
358
  const entity = state.entities[entityId];
710
359
  if (sort(model, entity) <= 0) {
711
360
  ids.push(modelId);
@@ -722,14 +371,9 @@ function createSortedStateAdapter(selectId, sort) {
722
371
  else {
723
372
  state.ids = ids.concat(state.ids.slice(j));
724
373
  }
725
- models.forEach((/**
726
- * @param {?} model
727
- * @param {?} i
728
- * @return {?}
729
- */
730
- (model, i) => {
374
+ models.forEach((model, i) => {
731
375
  state.entities[selectId(model)] = model;
732
- }));
376
+ });
733
377
  }
734
378
  return {
735
379
  removeOne,
@@ -748,27 +392,10 @@ function createSortedStateAdapter(selectId, sort) {
748
392
  };
749
393
  }
750
394
 
751
- /**
752
- * @fileoverview added by tsickle
753
- * Generated from: src/create_adapter.ts
754
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
755
- */
756
- /**
757
- * @template T
758
- * @param {?=} options
759
- * @return {?}
760
- */
761
395
  function createEntityAdapter(options = {}) {
762
- const { selectId, sortComparer } = Object.assign({ sortComparer: false, selectId: (/**
763
- * @param {?} instance
764
- * @return {?}
765
- */
766
- (instance) => instance.id) }, options);
767
- /** @type {?} */
396
+ const { selectId, sortComparer } = Object.assign({ sortComparer: false, selectId: (instance) => instance.id }, options);
768
397
  const stateFactory = createInitialStateFactory();
769
- /** @type {?} */
770
398
  const selectorsFactory = createSelectorsFactory();
771
- /** @type {?} */
772
399
  const stateAdapter = sortComparer
773
400
  ? createSortedStateAdapter(selectId, sortComparer)
774
401
  : createUnsortedStateAdapter(selectId);
@@ -776,275 +403,17 @@ function createEntityAdapter(options = {}) {
776
403
  sortComparer }, stateFactory), selectorsFactory), stateAdapter);
777
404
  }
778
405
 
779
- /**
780
- * @fileoverview added by tsickle
781
- * Generated from: src/models.ts
782
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
783
- */
784
- /**
785
- * @record
786
- * @template T
787
- */
788
- function DictionaryNum() { }
789
- /**
790
- * @abstract
791
- * @template T
792
- */
793
406
  class Dictionary {
794
407
  }
795
- /**
796
- * @record
797
- * @template T
798
- */
799
- function UpdateStr() { }
800
- if (false) {
801
- /** @type {?} */
802
- UpdateStr.prototype.id;
803
- /** @type {?} */
804
- UpdateStr.prototype.changes;
805
- }
806
- /**
807
- * @record
808
- * @template T
809
- */
810
- function UpdateNum() { }
811
- if (false) {
812
- /** @type {?} */
813
- UpdateNum.prototype.id;
814
- /** @type {?} */
815
- UpdateNum.prototype.changes;
816
- }
817
- /**
818
- * @record
819
- * @template T
820
- */
821
- function EntityMapOneNum() { }
822
- if (false) {
823
- /** @type {?} */
824
- EntityMapOneNum.prototype.id;
825
- /** @type {?} */
826
- EntityMapOneNum.prototype.map;
827
- }
828
- /**
829
- * @record
830
- * @template T
831
- */
832
- function EntityMapOneStr() { }
833
- if (false) {
834
- /** @type {?} */
835
- EntityMapOneStr.prototype.id;
836
- /** @type {?} */
837
- EntityMapOneStr.prototype.map;
838
- }
839
- /**
840
- * @record
841
- * @template T
842
- */
843
- function EntityState() { }
844
- if (false) {
845
- /** @type {?} */
846
- EntityState.prototype.ids;
847
- /** @type {?} */
848
- EntityState.prototype.entities;
849
- }
850
- /**
851
- * @record
852
- * @template T
853
- */
854
- function EntityDefinition() { }
855
- if (false) {
856
- /** @type {?} */
857
- EntityDefinition.prototype.selectId;
858
- /** @type {?} */
859
- EntityDefinition.prototype.sortComparer;
860
- }
861
- /**
862
- * @record
863
- * @template T
864
- */
865
- function EntityStateAdapter() { }
866
- if (false) {
867
- /**
868
- * @template S
869
- * @param {?} entity
870
- * @param {?} state
871
- * @return {?}
872
- */
873
- EntityStateAdapter.prototype.addOne = function (entity, state) { };
874
- /**
875
- * @template S
876
- * @param {?} entities
877
- * @param {?} state
878
- * @return {?}
879
- */
880
- EntityStateAdapter.prototype.addMany = function (entities, state) { };
881
- /**
882
- * @template S
883
- * @param {?} entities
884
- * @param {?} state
885
- * @return {?}
886
- */
887
- EntityStateAdapter.prototype.setAll = function (entities, state) { };
888
- /**
889
- * @template S
890
- * @param {?} entity
891
- * @param {?} state
892
- * @return {?}
893
- */
894
- EntityStateAdapter.prototype.setOne = function (entity, state) { };
895
- /**
896
- * @template S
897
- * @param {?} key
898
- * @param {?} state
899
- * @return {?}
900
- */
901
- EntityStateAdapter.prototype.removeOne = function (key, state) { };
902
- /**
903
- * @template S
904
- * @param {?} key
905
- * @param {?} state
906
- * @return {?}
907
- */
908
- EntityStateAdapter.prototype.removeOne = function (key, state) { };
909
- /**
910
- * @template S
911
- * @param {?} keys
912
- * @param {?} state
913
- * @return {?}
914
- */
915
- EntityStateAdapter.prototype.removeMany = function (keys, state) { };
916
- /**
917
- * @template S
918
- * @param {?} keys
919
- * @param {?} state
920
- * @return {?}
921
- */
922
- EntityStateAdapter.prototype.removeMany = function (keys, state) { };
923
- /**
924
- * @template S
925
- * @param {?} predicate
926
- * @param {?} state
927
- * @return {?}
928
- */
929
- EntityStateAdapter.prototype.removeMany = function (predicate, state) { };
930
- /**
931
- * @template S
932
- * @param {?} state
933
- * @return {?}
934
- */
935
- EntityStateAdapter.prototype.removeAll = function (state) { };
936
- /**
937
- * @template S
938
- * @param {?} update
939
- * @param {?} state
940
- * @return {?}
941
- */
942
- EntityStateAdapter.prototype.updateOne = function (update, state) { };
943
- /**
944
- * @template S
945
- * @param {?} updates
946
- * @param {?} state
947
- * @return {?}
948
- */
949
- EntityStateAdapter.prototype.updateMany = function (updates, state) { };
950
- /**
951
- * @template S
952
- * @param {?} entity
953
- * @param {?} state
954
- * @return {?}
955
- */
956
- EntityStateAdapter.prototype.upsertOne = function (entity, state) { };
957
- /**
958
- * @template S
959
- * @param {?} entities
960
- * @param {?} state
961
- * @return {?}
962
- */
963
- EntityStateAdapter.prototype.upsertMany = function (entities, state) { };
964
- /**
965
- * @template S
966
- * @param {?} map
967
- * @param {?} state
968
- * @return {?}
969
- */
970
- EntityStateAdapter.prototype.mapOne = function (map, state) { };
971
- /**
972
- * @template S
973
- * @param {?} map
974
- * @param {?} state
975
- * @return {?}
976
- */
977
- EntityStateAdapter.prototype.map = function (map, state) { };
978
- }
979
- /**
980
- * @record
981
- * @template T, V
982
- */
983
- function EntitySelectors() { }
984
- if (false) {
985
- /** @type {?} */
986
- EntitySelectors.prototype.selectIds;
987
- /** @type {?} */
988
- EntitySelectors.prototype.selectEntities;
989
- /** @type {?} */
990
- EntitySelectors.prototype.selectAll;
991
- /** @type {?} */
992
- EntitySelectors.prototype.selectTotal;
993
- }
994
- /**
995
- * @record
996
- * @template T
997
- */
998
- function EntityAdapter() { }
999
- if (false) {
1000
- /** @type {?} */
1001
- EntityAdapter.prototype.selectId;
1002
- /** @type {?} */
1003
- EntityAdapter.prototype.sortComparer;
1004
- /**
1005
- * @return {?}
1006
- */
1007
- EntityAdapter.prototype.getInitialState = function () { };
1008
- /**
1009
- * @template S
1010
- * @param {?} state
1011
- * @return {?}
1012
- */
1013
- EntityAdapter.prototype.getInitialState = function (state) { };
1014
- /**
1015
- * @return {?}
1016
- */
1017
- EntityAdapter.prototype.getSelectors = function () { };
1018
- /**
1019
- * @template V
1020
- * @param {?} selectState
1021
- * @return {?}
1022
- */
1023
- EntityAdapter.prototype.getSelectors = function (selectState) { };
1024
- }
1025
-
1026
- /**
1027
- * @fileoverview added by tsickle
1028
- * Generated from: src/index.ts
1029
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1030
- */
1031
-
1032
- /**
1033
- * @fileoverview added by tsickle
1034
- * Generated from: public_api.ts
1035
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1036
- */
1037
408
 
1038
409
  /**
1039
- * @fileoverview added by tsickle
1040
- * Generated from: index.ts
1041
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
410
+ * DO NOT EDIT
411
+ *
412
+ * This file is automatically generated at build
1042
413
  */
1043
414
 
1044
415
  /**
1045
- * @fileoverview added by tsickle
1046
- * Generated from: ngrx-entity.ts
1047
- * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
416
+ * Generated bundle index. Do not edit.
1048
417
  */
1049
418
 
1050
419
  export { Dictionary, createEntityAdapter };