@ngrx/signals 19.0.1 → 19.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/entities/src/helpers.d.ts +4 -4
- package/entities/src/index.d.ts +4 -0
- package/entities/src/updaters/prepend-entities.d.ts +17 -0
- package/entities/src/updaters/prepend-entity.d.ts +17 -0
- package/entities/src/updaters/upsert-entities.d.ts +17 -0
- package/entities/src/updaters/upsert-entity.d.ts +17 -0
- package/fesm2022/ngrx-signals-entities.mjs +68 -10
- package/fesm2022/ngrx-signals-entities.mjs.map +1 -1
- package/fesm2022/ngrx-signals-rxjs-interop.mjs +9 -2
- package/fesm2022/ngrx-signals-rxjs-interop.mjs.map +1 -1
- package/fesm2022/ngrx-signals-testing.mjs +15 -0
- package/fesm2022/ngrx-signals-testing.mjs.map +1 -0
- package/fesm2022/ngrx-signals.mjs +53 -7
- package/fesm2022/ngrx-signals.mjs.map +1 -1
- package/package.json +5 -1
- package/rxjs-interop/src/index.d.ts +1 -1
- package/rxjs-interop/src/rx-method.d.ts +1 -1
- package/schematics-core/utility/libs-version.js +1 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/src/index.d.ts +3 -2
- package/src/signal-method.d.ts +1 -2
- package/src/state-source.d.ts +1 -0
- package/src/with-feature.d.ts +25 -0
- package/testing/index.d.ts +1 -0
- package/testing/src/index.d.ts +1 -0
- package/testing/src/unprotected.d.ts +4 -0
|
@@ -17,9 +17,9 @@ export declare function getEntityUpdaterResult(state: EntityState<any>, stateKey
|
|
|
17
17
|
entityMapKey: string;
|
|
18
18
|
idsKey: string;
|
|
19
19
|
}, didMutate: DidMutate): Record<string, any>;
|
|
20
|
-
export declare function addEntityMutably(state: EntityState<any>, entity: any, selectId: SelectEntityId<any
|
|
21
|
-
export declare function addEntitiesMutably(state: EntityState<any>, entities: any[], selectId: SelectEntityId<any
|
|
22
|
-
export declare function setEntityMutably(state: EntityState<any>, entity: any, selectId: SelectEntityId<any
|
|
23
|
-
export declare function setEntitiesMutably(state: EntityState<any>, entities: any[], selectId: SelectEntityId<any
|
|
20
|
+
export declare function addEntityMutably(state: EntityState<any>, entity: any, selectId: SelectEntityId<any>, prepend?: boolean): DidMutate;
|
|
21
|
+
export declare function addEntitiesMutably(state: EntityState<any>, entities: any[], selectId: SelectEntityId<any>, prepend?: boolean): DidMutate;
|
|
22
|
+
export declare function setEntityMutably(state: EntityState<any>, entity: any, selectId: SelectEntityId<any>, replace?: boolean): DidMutate;
|
|
23
|
+
export declare function setEntitiesMutably(state: EntityState<any>, entities: any[], selectId: SelectEntityId<any>, replace?: boolean): DidMutate;
|
|
24
24
|
export declare function removeEntitiesMutably(state: EntityState<any>, idsOrPredicate: EntityId[] | EntityPredicate<any>): DidMutate;
|
|
25
25
|
export declare function updateEntitiesMutably(state: EntityState<any>, idsOrPredicate: EntityId[] | EntityPredicate<any>, changes: EntityChanges<any>, selectId: SelectEntityId<any>): DidMutate;
|
package/entities/src/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { addEntity } from './updaters/add-entity';
|
|
2
2
|
export { addEntities } from './updaters/add-entities';
|
|
3
|
+
export { prependEntity } from './updaters/prepend-entity';
|
|
4
|
+
export { prependEntities } from './updaters/prepend-entities';
|
|
3
5
|
export { removeEntity } from './updaters/remove-entity';
|
|
4
6
|
export { removeEntities } from './updaters/remove-entities';
|
|
5
7
|
export { removeAllEntities } from './updaters/remove-all-entities';
|
|
@@ -9,6 +11,8 @@ export { setAllEntities } from './updaters/set-all-entities';
|
|
|
9
11
|
export { updateEntity } from './updaters/update-entity';
|
|
10
12
|
export { updateEntities } from './updaters/update-entities';
|
|
11
13
|
export { updateAllEntities } from './updaters/update-all-entities';
|
|
14
|
+
export { upsertEntity } from './updaters/upsert-entity';
|
|
15
|
+
export { upsertEntities } from './updaters/upsert-entities';
|
|
12
16
|
export { entityConfig } from './entity-config';
|
|
13
17
|
export { EntityId, EntityMap, EntityProps, EntityState, NamedEntityProps, NamedEntityState, SelectEntityId, } from './models';
|
|
14
18
|
export { withEntities } from './with-entities';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartialStateUpdater } from '@ngrx/signals';
|
|
2
|
+
import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
|
|
3
|
+
export declare function prependEntities<Entity extends {
|
|
4
|
+
id: EntityId;
|
|
5
|
+
}>(entities: Entity[]): PartialStateUpdater<EntityState<Entity>>;
|
|
6
|
+
export declare function prependEntities<Entity, Collection extends string>(entities: Entity[], config: {
|
|
7
|
+
collection: Collection;
|
|
8
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
9
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
10
|
+
export declare function prependEntities<Entity extends {
|
|
11
|
+
id: EntityId;
|
|
12
|
+
}, Collection extends string>(entities: Entity[], config: {
|
|
13
|
+
collection: Collection;
|
|
14
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
15
|
+
export declare function prependEntities<Entity>(entities: Entity[], config: {
|
|
16
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
17
|
+
}): PartialStateUpdater<EntityState<Entity>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartialStateUpdater } from '@ngrx/signals';
|
|
2
|
+
import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
|
|
3
|
+
export declare function prependEntity<Entity extends {
|
|
4
|
+
id: EntityId;
|
|
5
|
+
}>(entity: Entity): PartialStateUpdater<EntityState<Entity>>;
|
|
6
|
+
export declare function prependEntity<Entity, Collection extends string>(entity: Entity, config: {
|
|
7
|
+
collection: Collection;
|
|
8
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
9
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
10
|
+
export declare function prependEntity<Entity extends {
|
|
11
|
+
id: EntityId;
|
|
12
|
+
}, Collection extends string>(entity: Entity, config: {
|
|
13
|
+
collection: Collection;
|
|
14
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
15
|
+
export declare function prependEntity<Entity>(entity: Entity, config: {
|
|
16
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
17
|
+
}): PartialStateUpdater<EntityState<Entity>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartialStateUpdater } from '@ngrx/signals';
|
|
2
|
+
import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
|
|
3
|
+
export declare function upsertEntities<Entity extends {
|
|
4
|
+
id: EntityId;
|
|
5
|
+
}>(entities: Entity[]): PartialStateUpdater<EntityState<Entity>>;
|
|
6
|
+
export declare function upsertEntities<Entity, Collection extends string>(entities: Entity[], config: {
|
|
7
|
+
collection: Collection;
|
|
8
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
9
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
10
|
+
export declare function upsertEntities<Entity extends {
|
|
11
|
+
id: EntityId;
|
|
12
|
+
}, Collection extends string>(entities: Entity[], config: {
|
|
13
|
+
collection: Collection;
|
|
14
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
15
|
+
export declare function upsertEntities<Entity>(entities: Entity[], config: {
|
|
16
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
17
|
+
}): PartialStateUpdater<EntityState<Entity>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PartialStateUpdater } from '@ngrx/signals';
|
|
2
|
+
import { EntityId, EntityState, NamedEntityState, SelectEntityId } from '../models';
|
|
3
|
+
export declare function upsertEntity<Entity extends {
|
|
4
|
+
id: EntityId;
|
|
5
|
+
}>(entity: Entity): PartialStateUpdater<EntityState<Entity>>;
|
|
6
|
+
export declare function upsertEntity<Entity, Collection extends string>(entity: Entity, config: {
|
|
7
|
+
collection: Collection;
|
|
8
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
9
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
10
|
+
export declare function upsertEntity<Entity extends {
|
|
11
|
+
id: EntityId;
|
|
12
|
+
}, Collection extends string>(entity: Entity, config: {
|
|
13
|
+
collection: Collection;
|
|
14
|
+
}): PartialStateUpdater<NamedEntityState<Entity, Collection>>;
|
|
15
|
+
export declare function upsertEntity<Entity>(entity: Entity, config: {
|
|
16
|
+
selectId: SelectEntityId<NoInfer<Entity>>;
|
|
17
|
+
}): PartialStateUpdater<EntityState<Entity>>;
|
|
@@ -41,39 +41,46 @@ function getEntityUpdaterResult(state, stateKeys, didMutate) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function addEntityMutably(state, entity, selectId) {
|
|
44
|
+
function addEntityMutably(state, entity, selectId, prepend = false) {
|
|
45
45
|
const id = selectId(entity);
|
|
46
46
|
if (state.entityMap[id]) {
|
|
47
47
|
return DidMutate.None;
|
|
48
48
|
}
|
|
49
49
|
state.entityMap[id] = entity;
|
|
50
|
-
|
|
50
|
+
if (prepend) {
|
|
51
|
+
state.ids.unshift(id);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
state.ids.push(id);
|
|
55
|
+
}
|
|
51
56
|
return DidMutate.Both;
|
|
52
57
|
}
|
|
53
|
-
function addEntitiesMutably(state, entities, selectId) {
|
|
58
|
+
function addEntitiesMutably(state, entities, selectId, prepend = false) {
|
|
54
59
|
let didMutate = DidMutate.None;
|
|
55
60
|
for (const entity of entities) {
|
|
56
|
-
const result = addEntityMutably(state, entity, selectId);
|
|
61
|
+
const result = addEntityMutably(state, entity, selectId, prepend);
|
|
57
62
|
if (result === DidMutate.Both) {
|
|
58
63
|
didMutate = result;
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
return didMutate;
|
|
62
67
|
}
|
|
63
|
-
function setEntityMutably(state, entity, selectId) {
|
|
68
|
+
function setEntityMutably(state, entity, selectId, replace = true) {
|
|
64
69
|
const id = selectId(entity);
|
|
65
70
|
if (state.entityMap[id]) {
|
|
66
|
-
state.entityMap[id] =
|
|
71
|
+
state.entityMap[id] = replace
|
|
72
|
+
? entity
|
|
73
|
+
: { ...state.entityMap[id], ...entity };
|
|
67
74
|
return DidMutate.Entities;
|
|
68
75
|
}
|
|
69
76
|
state.entityMap[id] = entity;
|
|
70
77
|
state.ids.push(id);
|
|
71
78
|
return DidMutate.Both;
|
|
72
79
|
}
|
|
73
|
-
function setEntitiesMutably(state, entities, selectId) {
|
|
80
|
+
function setEntitiesMutably(state, entities, selectId, replace = true) {
|
|
74
81
|
let didMutate = DidMutate.None;
|
|
75
82
|
for (const entity of entities) {
|
|
76
|
-
const result = setEntityMutably(state, entity, selectId);
|
|
83
|
+
const result = setEntityMutably(state, entity, selectId, replace);
|
|
77
84
|
if (didMutate === DidMutate.Both) {
|
|
78
85
|
continue;
|
|
79
86
|
}
|
|
@@ -122,7 +129,9 @@ function updateEntitiesMutably(state, idsOrPredicate, changes, selectId) {
|
|
|
122
129
|
state.ids = state.ids.map((id) => newIds[id] ?? id);
|
|
123
130
|
didMutate = DidMutate.Both;
|
|
124
131
|
}
|
|
125
|
-
if (ngDevMode
|
|
132
|
+
if (typeof ngDevMode !== 'undefined' &&
|
|
133
|
+
ngDevMode &&
|
|
134
|
+
state.ids.length !== Object.keys(state.entityMap).length) {
|
|
126
135
|
console.warn('@ngrx/signals/entities: Entities with IDs:', ids, 'are not updated correctly.', 'Make sure to apply valid changes when using `updateEntity`,', '`updateEntities`, and `updateAllEntities` updaters.');
|
|
127
136
|
}
|
|
128
137
|
return didMutate;
|
|
@@ -148,6 +157,35 @@ function addEntities(entities, config) {
|
|
|
148
157
|
};
|
|
149
158
|
}
|
|
150
159
|
|
|
160
|
+
function prependEntity(entity, config) {
|
|
161
|
+
const selectId = getEntityIdSelector(config);
|
|
162
|
+
const stateKeys = getEntityStateKeys(config);
|
|
163
|
+
return (state) => {
|
|
164
|
+
const clonedState = cloneEntityState(state, stateKeys);
|
|
165
|
+
const didMutate = addEntityMutably(clonedState, entity, selectId, true);
|
|
166
|
+
return getEntityUpdaterResult(clonedState, stateKeys, didMutate);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function prependEntities(entities, config) {
|
|
171
|
+
const selectId = getEntityIdSelector(config);
|
|
172
|
+
const stateKeys = getEntityStateKeys(config);
|
|
173
|
+
return (state) => {
|
|
174
|
+
const clonedState = cloneEntityState(state, stateKeys);
|
|
175
|
+
const uniqueEntities = [];
|
|
176
|
+
const seenIds = new Set();
|
|
177
|
+
for (const entity of entities) {
|
|
178
|
+
const id = selectId(entity);
|
|
179
|
+
if (!seenIds.has(id)) {
|
|
180
|
+
uniqueEntities.unshift(entity);
|
|
181
|
+
seenIds.add(id);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const didMutate = addEntitiesMutably(clonedState, uniqueEntities, selectId, true);
|
|
185
|
+
return getEntityUpdaterResult(clonedState, stateKeys, didMutate);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
151
189
|
function removeEntity(id, config) {
|
|
152
190
|
const stateKeys = getEntityStateKeys(config);
|
|
153
191
|
return (state) => {
|
|
@@ -238,6 +276,26 @@ function updateAllEntities(changes, config) {
|
|
|
238
276
|
};
|
|
239
277
|
}
|
|
240
278
|
|
|
279
|
+
function upsertEntity(entity, config) {
|
|
280
|
+
const selectId = getEntityIdSelector(config);
|
|
281
|
+
const stateKeys = getEntityStateKeys(config);
|
|
282
|
+
return (state) => {
|
|
283
|
+
const clonedState = cloneEntityState(state, stateKeys);
|
|
284
|
+
const didMutate = setEntityMutably(clonedState, entity, selectId, false);
|
|
285
|
+
return getEntityUpdaterResult(clonedState, stateKeys, didMutate);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function upsertEntities(entities, config) {
|
|
290
|
+
const selectId = getEntityIdSelector(config);
|
|
291
|
+
const stateKeys = getEntityStateKeys(config);
|
|
292
|
+
return (state) => {
|
|
293
|
+
const clonedState = cloneEntityState(state, stateKeys);
|
|
294
|
+
const didMutate = setEntitiesMutably(clonedState, entities, selectId, false);
|
|
295
|
+
return getEntityUpdaterResult(clonedState, stateKeys, didMutate);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
241
299
|
function entityConfig(config) {
|
|
242
300
|
return config;
|
|
243
301
|
}
|
|
@@ -260,5 +318,5 @@ function withEntities(config) {
|
|
|
260
318
|
* Generated bundle index. Do not edit.
|
|
261
319
|
*/
|
|
262
320
|
|
|
263
|
-
export { addEntities, addEntity, entityConfig, removeAllEntities, removeEntities, removeEntity, setAllEntities, setEntities, setEntity, updateAllEntities, updateEntities, updateEntity, withEntities };
|
|
321
|
+
export { addEntities, addEntity, entityConfig, prependEntities, prependEntity, removeAllEntities, removeEntities, removeEntity, setAllEntities, setEntities, setEntity, updateAllEntities, updateEntities, updateEntity, upsertEntities, upsertEntity, withEntities };
|
|
264
322
|
//# sourceMappingURL=ngrx-signals-entities.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngrx-signals-entities.mjs","sources":["../../../../modules/signals/entities/src/models.ts","../../../../modules/signals/entities/src/helpers.ts","../../../../modules/signals/entities/src/updaters/add-entity.ts","../../../../modules/signals/entities/src/updaters/add-entities.ts","../../../../modules/signals/entities/src/updaters/remove-entity.ts","../../../../modules/signals/entities/src/updaters/remove-entities.ts","../../../../modules/signals/entities/src/updaters/remove-all-entities.ts","../../../../modules/signals/entities/src/updaters/set-entity.ts","../../../../modules/signals/entities/src/updaters/set-entities.ts","../../../../modules/signals/entities/src/updaters/set-all-entities.ts","../../../../modules/signals/entities/src/updaters/update-entity.ts","../../../../modules/signals/entities/src/updaters/update-entities.ts","../../../../modules/signals/entities/src/updaters/update-all-entities.ts","../../../../modules/signals/entities/src/entity-config.ts","../../../../modules/signals/entities/src/with-entities.ts","../../../../modules/signals/entities/ngrx-signals-entities.ts"],"sourcesContent":["import { Signal } from '@angular/core';\n\nexport type EntityId = string | number;\n\nexport type EntityMap<Entity> = Record<EntityId, Entity>;\n\nexport type EntityState<Entity> = {\n entityMap: EntityMap<Entity>;\n ids: EntityId[];\n};\n\nexport type NamedEntityState<Entity, Collection extends string> = {\n [K in keyof EntityState<Entity> as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];\n};\n\nexport type EntityProps<Entity> = {\n entities: Signal<Entity[]>;\n};\n\nexport type NamedEntityProps<Entity, Collection extends string> = {\n [K in keyof EntityProps<Entity> as `${Collection}${Capitalize<K>}`]: EntityProps<Entity>[K];\n};\n\nexport type SelectEntityId<Entity> = (entity: Entity) => EntityId;\n\nexport type EntityPredicate<Entity> = (entity: Entity) => boolean;\n\nexport type EntityChanges<Entity> =\n | Partial<Entity>\n | ((entity: Entity) => Partial<Entity>);\n\nexport enum DidMutate {\n None,\n Entities,\n Both,\n}\n","import {\n DidMutate,\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n SelectEntityId,\n} from './models';\n\ndeclare const ngDevMode: unknown;\nconst defaultSelectId: SelectEntityId<{ id: EntityId }> = (entity) => entity.id;\n\nexport function getEntityIdSelector(config?: {\n selectId?: SelectEntityId<any>;\n}): SelectEntityId<any> {\n return config?.selectId ?? defaultSelectId;\n}\n\nexport function getEntityStateKeys(config?: { collection?: string }): {\n entityMapKey: string;\n idsKey: string;\n entitiesKey: string;\n} {\n const collection = config?.collection;\n const entityMapKey =\n collection === undefined ? 'entityMap' : `${collection}EntityMap`;\n const idsKey = collection === undefined ? 'ids' : `${collection}Ids`;\n const entitiesKey =\n collection === undefined ? 'entities' : `${collection}Entities`;\n\n return { entityMapKey, idsKey, entitiesKey };\n}\n\nexport function cloneEntityState(\n state: Record<string, any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n }\n): EntityState<any> {\n return {\n entityMap: { ...state[stateKeys.entityMapKey] },\n ids: [...state[stateKeys.idsKey]],\n };\n}\n\nexport function getEntityUpdaterResult(\n state: EntityState<any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n },\n didMutate: DidMutate\n): Record<string, any> {\n switch (didMutate) {\n case DidMutate.Both: {\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n }\n case DidMutate.Entities: {\n return { [stateKeys.entityMapKey]: state.entityMap };\n }\n default: {\n return {};\n }\n }\n}\n\nexport function addEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n return DidMutate.None;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function addEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = addEntityMutably(state, entity, selectId);\n\n if (result === DidMutate.Both) {\n didMutate = result;\n }\n }\n\n return didMutate;\n}\n\nexport function setEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n state.entityMap[id] = entity;\n return DidMutate.Entities;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function setEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = setEntityMutably(state, entity, selectId);\n\n if (didMutate === DidMutate.Both) {\n continue;\n }\n\n didMutate = result;\n }\n\n return didMutate;\n}\n\nexport function removeEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n if (state.entityMap[id]) {\n delete state.entityMap[id];\n didMutate = DidMutate.Both;\n }\n }\n\n if (didMutate === DidMutate.Both) {\n state.ids = state.ids.filter((id) => id in state.entityMap);\n }\n\n return didMutate;\n}\n\nexport function updateEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n changes: EntityChanges<any>,\n selectId: SelectEntityId<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let newIds: Record<EntityId, EntityId> | undefined = undefined;\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n const entity = state.entityMap[id];\n\n if (entity) {\n const changesRecord =\n typeof changes === 'function' ? changes(entity) : changes;\n state.entityMap[id] = { ...entity, ...changesRecord };\n didMutate = DidMutate.Entities;\n\n const newId = selectId(state.entityMap[id]);\n if (newId !== id) {\n state.entityMap[newId] = state.entityMap[id];\n delete state.entityMap[id];\n\n newIds = newIds || {};\n newIds[id] = newId;\n }\n }\n }\n\n if (newIds) {\n state.ids = state.ids.map((id) => newIds[id] ?? id);\n didMutate = DidMutate.Both;\n }\n\n if (ngDevMode && state.ids.length !== Object.keys(state.entityMap).length) {\n console.warn(\n '@ngrx/signals/entities: Entities with IDs:',\n ids,\n 'are not updated correctly.',\n 'Make sure to apply valid changes when using `updateEntity`,',\n '`updateEntities`, and `updateAllEntities` updaters.'\n );\n }\n\n return didMutate;\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntityMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntitiesMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityId, EntityState, NamedEntityState } from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntity(\n id: EntityId\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntity<Collection extends string>(\n id: EntityId,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntity(\n id: EntityId,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, [id]);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntities(\n ids: EntityId[]\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntities<Entity>(\n predicate: EntityPredicate<Entity>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function removeEntities<Collection extends string>(\n ids: EntityId[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n predicate: EntityPredicate<Entity>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function removeEntities(\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, idsOrPredicate);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityState, NamedEntityState } from '../models';\nimport { getEntityStateKeys } from '../helpers';\n\nexport function removeAllEntities(): PartialStateUpdater<EntityState<any>>;\nexport function removeAllEntities<Collection extends string>(config: {\n collection: Collection;\n}): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeAllEntities(config?: {\n collection?: string;\n}): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return () => ({\n [stateKeys.entityMapKey]: {},\n [stateKeys.idsKey]: [],\n });\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntityMutably,\n} from '../helpers';\n\nexport function setEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n getEntityIdSelector,\n getEntityStateKeys,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setAllEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return () => {\n const state: EntityState<any> = { entityMap: {}, ids: [] };\n setEntitiesMutably(state, entities, selectId);\n\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntity<Entity>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity<Entity extends { id: EntityId }>(update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity(\n update: {\n id: EntityId;\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n [update.id],\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<Entity>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities(\n update: ({ ids: EntityId[] } | { predicate: EntityPredicate<any> }) & {\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n const idsOrPredicate = 'ids' in update ? update.ids : update.predicate;\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n idsOrPredicate,\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<Entity>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities<Entity extends { id: EntityId }>(\n changes: EntityChanges<NoInfer<Entity>>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities(\n changes: EntityChanges<any>,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n (state as Record<string, any>)[stateKeys.idsKey],\n changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { SelectEntityId } from './models';\n\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): typeof config;\nexport function entityConfig<Entity>(config: { entity: Entity }): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n collection?: string;\n selectId?: SelectEntityId<Entity>;\n}): typeof config {\n return config;\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n EmptyFeatureResult,\n SignalStoreFeature,\n signalStoreFeature,\n withComputed,\n withState,\n} from '@ngrx/signals';\nimport {\n EntityProps,\n EntityId,\n EntityMap,\n EntityState,\n NamedEntityProps,\n NamedEntityState,\n} from './models';\nimport { getEntityStateKeys } from './helpers';\n\nexport function withEntities<Entity>(): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: NamedEntityState<Entity, Collection>;\n props: NamedEntityProps<Entity, Collection>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config: {\n entity: Entity;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config?: {\n entity: Entity;\n collection?: string;\n}): SignalStoreFeature {\n const { entityMapKey, idsKey, entitiesKey } = getEntityStateKeys(config);\n\n return signalStoreFeature(\n withState({\n [entityMapKey]: {},\n [idsKey]: [],\n }),\n withComputed((store: Record<string, Signal<unknown>>) => ({\n [entitiesKey]: computed(() => {\n const entityMap = store[entityMapKey]() as EntityMap<Entity>;\n const ids = store[idsKey]() as EntityId[];\n\n return ids.map((id) => entityMap[id]);\n }),\n }))\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA+BA,IAAY,SAIX;AAJD,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SA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AACH;;ACjDM,SAAU,YAAY,CAAS,MAIpC,EAAA;AACC,IAAA,OAAO,MAAM;AACf;;ACyBM,SAAU,YAAY,CAAS,MAGpC,EAAA;AACC,IAAA,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAExE,OAAO,kBAAkB,CACvB,SAAS,CAAC;QACR,CAAC,YAAY,GAAG,EAAE;QAClB,CAAC,MAAM,GAAG,EAAE;KACb,CAAC,EACF,YAAY,CAAC,CAAC,KAAsC,MAAM;AACxD,QAAA,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAK;AAC3B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,EAAuB;AAC5D,YAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAgB;AAEzC,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CAAC;AACvC,SAAC,CAAC;KACH,CAAC,CAAC,CACJ;AACH;;ACnEA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngrx-signals-entities.mjs","sources":["../../../../modules/signals/entities/src/models.ts","../../../../modules/signals/entities/src/helpers.ts","../../../../modules/signals/entities/src/updaters/add-entity.ts","../../../../modules/signals/entities/src/updaters/add-entities.ts","../../../../modules/signals/entities/src/updaters/prepend-entity.ts","../../../../modules/signals/entities/src/updaters/prepend-entities.ts","../../../../modules/signals/entities/src/updaters/remove-entity.ts","../../../../modules/signals/entities/src/updaters/remove-entities.ts","../../../../modules/signals/entities/src/updaters/remove-all-entities.ts","../../../../modules/signals/entities/src/updaters/set-entity.ts","../../../../modules/signals/entities/src/updaters/set-entities.ts","../../../../modules/signals/entities/src/updaters/set-all-entities.ts","../../../../modules/signals/entities/src/updaters/update-entity.ts","../../../../modules/signals/entities/src/updaters/update-entities.ts","../../../../modules/signals/entities/src/updaters/update-all-entities.ts","../../../../modules/signals/entities/src/updaters/upsert-entity.ts","../../../../modules/signals/entities/src/updaters/upsert-entities.ts","../../../../modules/signals/entities/src/entity-config.ts","../../../../modules/signals/entities/src/with-entities.ts","../../../../modules/signals/entities/ngrx-signals-entities.ts"],"sourcesContent":["import { Signal } from '@angular/core';\n\nexport type EntityId = string | number;\n\nexport type EntityMap<Entity> = Record<EntityId, Entity>;\n\nexport type EntityState<Entity> = {\n entityMap: EntityMap<Entity>;\n ids: EntityId[];\n};\n\nexport type NamedEntityState<Entity, Collection extends string> = {\n [K in keyof EntityState<Entity> as `${Collection}${Capitalize<K>}`]: EntityState<Entity>[K];\n};\n\nexport type EntityProps<Entity> = {\n entities: Signal<Entity[]>;\n};\n\nexport type NamedEntityProps<Entity, Collection extends string> = {\n [K in keyof EntityProps<Entity> as `${Collection}${Capitalize<K>}`]: EntityProps<Entity>[K];\n};\n\nexport type SelectEntityId<Entity> = (entity: Entity) => EntityId;\n\nexport type EntityPredicate<Entity> = (entity: Entity) => boolean;\n\nexport type EntityChanges<Entity> =\n | Partial<Entity>\n | ((entity: Entity) => Partial<Entity>);\n\nexport enum DidMutate {\n None,\n Entities,\n Both,\n}\n","import {\n DidMutate,\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n SelectEntityId,\n} from './models';\n\ndeclare const ngDevMode: unknown;\nconst defaultSelectId: SelectEntityId<{ id: EntityId }> = (entity) => entity.id;\n\nexport function getEntityIdSelector(config?: {\n selectId?: SelectEntityId<any>;\n}): SelectEntityId<any> {\n return config?.selectId ?? defaultSelectId;\n}\n\nexport function getEntityStateKeys(config?: { collection?: string }): {\n entityMapKey: string;\n idsKey: string;\n entitiesKey: string;\n} {\n const collection = config?.collection;\n const entityMapKey =\n collection === undefined ? 'entityMap' : `${collection}EntityMap`;\n const idsKey = collection === undefined ? 'ids' : `${collection}Ids`;\n const entitiesKey =\n collection === undefined ? 'entities' : `${collection}Entities`;\n\n return { entityMapKey, idsKey, entitiesKey };\n}\n\nexport function cloneEntityState(\n state: Record<string, any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n }\n): EntityState<any> {\n return {\n entityMap: { ...state[stateKeys.entityMapKey] },\n ids: [...state[stateKeys.idsKey]],\n };\n}\n\nexport function getEntityUpdaterResult(\n state: EntityState<any>,\n stateKeys: {\n entityMapKey: string;\n idsKey: string;\n },\n didMutate: DidMutate\n): Record<string, any> {\n switch (didMutate) {\n case DidMutate.Both: {\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n }\n case DidMutate.Entities: {\n return { [stateKeys.entityMapKey]: state.entityMap };\n }\n default: {\n return {};\n }\n }\n}\n\nexport function addEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>,\n prepend = false\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n return DidMutate.None;\n }\n\n state.entityMap[id] = entity;\n\n if (prepend) {\n state.ids.unshift(id);\n } else {\n state.ids.push(id);\n }\n\n return DidMutate.Both;\n}\n\nexport function addEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>,\n prepend = false\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = addEntityMutably(state, entity, selectId, prepend);\n\n if (result === DidMutate.Both) {\n didMutate = result;\n }\n }\n\n return didMutate;\n}\n\nexport function setEntityMutably(\n state: EntityState<any>,\n entity: any,\n selectId: SelectEntityId<any>,\n replace = true\n): DidMutate {\n const id = selectId(entity);\n\n if (state.entityMap[id]) {\n state.entityMap[id] = replace\n ? entity\n : { ...state.entityMap[id], ...entity };\n\n return DidMutate.Entities;\n }\n\n state.entityMap[id] = entity;\n state.ids.push(id);\n\n return DidMutate.Both;\n}\n\nexport function setEntitiesMutably(\n state: EntityState<any>,\n entities: any[],\n selectId: SelectEntityId<any>,\n replace = true\n): DidMutate {\n let didMutate = DidMutate.None;\n\n for (const entity of entities) {\n const result = setEntityMutably(state, entity, selectId, replace);\n\n if (didMutate === DidMutate.Both) {\n continue;\n }\n\n didMutate = result;\n }\n\n return didMutate;\n}\n\nexport function removeEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n if (state.entityMap[id]) {\n delete state.entityMap[id];\n didMutate = DidMutate.Both;\n }\n }\n\n if (didMutate === DidMutate.Both) {\n state.ids = state.ids.filter((id) => id in state.entityMap);\n }\n\n return didMutate;\n}\n\nexport function updateEntitiesMutably(\n state: EntityState<any>,\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n changes: EntityChanges<any>,\n selectId: SelectEntityId<any>\n): DidMutate {\n const ids = Array.isArray(idsOrPredicate)\n ? idsOrPredicate\n : state.ids.filter((id) => idsOrPredicate(state.entityMap[id]));\n let newIds: Record<EntityId, EntityId> | undefined = undefined;\n let didMutate = DidMutate.None;\n\n for (const id of ids) {\n const entity = state.entityMap[id];\n\n if (entity) {\n const changesRecord =\n typeof changes === 'function' ? changes(entity) : changes;\n state.entityMap[id] = { ...entity, ...changesRecord };\n didMutate = DidMutate.Entities;\n\n const newId = selectId(state.entityMap[id]);\n if (newId !== id) {\n state.entityMap[newId] = state.entityMap[id];\n delete state.entityMap[id];\n\n newIds = newIds || {};\n newIds[id] = newId;\n }\n }\n }\n\n if (newIds) {\n state.ids = state.ids.map((id) => newIds[id] ?? id);\n didMutate = DidMutate.Both;\n }\n\n if (\n typeof ngDevMode !== 'undefined' &&\n ngDevMode &&\n state.ids.length !== Object.keys(state.entityMap).length\n ) {\n console.warn(\n '@ngrx/signals/entities: Entities with IDs:',\n ids,\n 'are not updated correctly.',\n 'Make sure to apply valid changes when using `updateEntity`,',\n '`updateEntities`, and `updateAllEntities` updaters.'\n );\n }\n\n return didMutate;\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntityMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntitiesMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function addEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function addEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function addEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntityMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function prependEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function prependEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function prependEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function prependEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function prependEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = addEntityMutably(clonedState, entity, selectId, true);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n addEntitiesMutably,\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n} from '../helpers';\n\nexport function prependEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function prependEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function prependEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function prependEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function prependEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n\n const uniqueEntities: any[] = [];\n const seenIds = new Set<EntityId>();\n\n for (const entity of entities) {\n const id = selectId(entity);\n\n if (!seenIds.has(id)) {\n uniqueEntities.unshift(entity);\n seenIds.add(id);\n }\n }\n\n const didMutate = addEntitiesMutably(\n clonedState,\n uniqueEntities,\n selectId,\n true\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityId, EntityState, NamedEntityState } from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntity(\n id: EntityId\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntity<Collection extends string>(\n id: EntityId,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntity(\n id: EntityId,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, [id]);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityStateKeys,\n getEntityUpdaterResult,\n removeEntitiesMutably,\n} from '../helpers';\n\nexport function removeEntities(\n ids: EntityId[]\n): PartialStateUpdater<EntityState<any>>;\nexport function removeEntities<Entity>(\n predicate: EntityPredicate<Entity>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function removeEntities<Collection extends string>(\n ids: EntityId[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n predicate: EntityPredicate<Entity>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function removeEntities(\n idsOrPredicate: EntityId[] | EntityPredicate<any>,\n config?: { collection?: string }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = removeEntitiesMutably(clonedState, idsOrPredicate);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport { EntityState, NamedEntityState } from '../models';\nimport { getEntityStateKeys } from '../helpers';\n\nexport function removeAllEntities(): PartialStateUpdater<EntityState<any>>;\nexport function removeAllEntities<Collection extends string>(config: {\n collection: Collection;\n}): PartialStateUpdater<NamedEntityState<any, Collection>>;\nexport function removeAllEntities(config?: {\n collection?: string;\n}): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const stateKeys = getEntityStateKeys(config);\n\n return () => ({\n [stateKeys.entityMapKey]: {},\n [stateKeys.idsKey]: [],\n });\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntityMutably,\n} from '../helpers';\n\nexport function setEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntityMutably(clonedState, entity, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntitiesMutably(clonedState, entities, selectId);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n getEntityIdSelector,\n getEntityStateKeys,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function setAllEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function setAllEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function setAllEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return () => {\n const state: EntityState<any> = { entityMap: {}, ids: [] };\n setEntitiesMutably(state, entities, selectId);\n\n return {\n [stateKeys.entityMapKey]: state.entityMap,\n [stateKeys.idsKey]: state.ids,\n };\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntity<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntity<Entity>(\n update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity<Entity extends { id: EntityId }>(update: {\n id: EntityId;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntity(\n update: {\n id: EntityId;\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n [update.id],\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityPredicate,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateEntities<Entity>(\n update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity>(\n update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n },\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n ids: EntityId[];\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities<Entity extends { id: EntityId }>(update: {\n predicate: EntityPredicate<Entity>;\n changes: EntityChanges<NoInfer<Entity>>;\n}): PartialStateUpdater<EntityState<Entity>>;\nexport function updateEntities(\n update: ({ ids: EntityId[] } | { predicate: EntityPredicate<any> }) & {\n changes: EntityChanges<any>;\n },\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n const idsOrPredicate = 'ids' in update ? update.ids : update.predicate;\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n idsOrPredicate,\n update.changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityChanges,\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n updateEntitiesMutably,\n} from '../helpers';\n\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<infer E, Collection> ? E : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: {\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<\n Collection extends string,\n State extends NamedEntityState<any, Collection>,\n Entity = State extends NamedEntityState<\n infer E extends { id: EntityId },\n Collection\n >\n ? E\n : never\n>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { collection: Collection }\n): PartialStateUpdater<State>;\nexport function updateAllEntities<Entity>(\n changes: EntityChanges<NoInfer<Entity>>,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities<Entity extends { id: EntityId }>(\n changes: EntityChanges<NoInfer<Entity>>\n): PartialStateUpdater<EntityState<Entity>>;\nexport function updateAllEntities(\n changes: EntityChanges<any>,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = updateEntitiesMutably(\n clonedState,\n (state as Record<string, any>)[stateKeys.idsKey],\n changes,\n selectId\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntityMutably,\n} from '../helpers';\n\nexport function upsertEntity<Entity extends { id: EntityId }>(\n entity: Entity\n): PartialStateUpdater<EntityState<Entity>>;\nexport function upsertEntity<Entity, Collection extends string>(\n entity: Entity,\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function upsertEntity<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entity: Entity,\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function upsertEntity<Entity>(\n entity: Entity,\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function upsertEntity(\n entity: any,\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntityMutably(clonedState, entity, selectId, false);\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { PartialStateUpdater } from '@ngrx/signals';\nimport {\n EntityId,\n EntityState,\n NamedEntityState,\n SelectEntityId,\n} from '../models';\nimport {\n cloneEntityState,\n getEntityIdSelector,\n getEntityStateKeys,\n getEntityUpdaterResult,\n setEntitiesMutably,\n} from '../helpers';\n\nexport function upsertEntities<Entity extends { id: EntityId }>(\n entities: Entity[]\n): PartialStateUpdater<EntityState<Entity>>;\nexport function upsertEntities<Entity, Collection extends string>(\n entities: Entity[],\n config: { collection: Collection; selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function upsertEntities<\n Entity extends { id: EntityId },\n Collection extends string\n>(\n entities: Entity[],\n config: { collection: Collection }\n): PartialStateUpdater<NamedEntityState<Entity, Collection>>;\nexport function upsertEntities<Entity>(\n entities: Entity[],\n config: { selectId: SelectEntityId<NoInfer<Entity>> }\n): PartialStateUpdater<EntityState<Entity>>;\nexport function upsertEntities(\n entities: any[],\n config?: { collection?: string; selectId?: SelectEntityId<any> }\n): PartialStateUpdater<EntityState<any> | NamedEntityState<any, string>> {\n const selectId = getEntityIdSelector(config);\n const stateKeys = getEntityStateKeys(config);\n\n return (state) => {\n const clonedState = cloneEntityState(state, stateKeys);\n const didMutate = setEntitiesMutably(\n clonedState,\n entities,\n selectId,\n false\n );\n\n return getEntityUpdaterResult(clonedState, stateKeys, didMutate);\n };\n}\n","import { SelectEntityId } from './models';\n\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n selectId: SelectEntityId<NoInfer<Entity>>;\n}): typeof config;\nexport function entityConfig<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): typeof config;\nexport function entityConfig<Entity>(config: { entity: Entity }): typeof config;\nexport function entityConfig<Entity>(config: {\n entity: Entity;\n collection?: string;\n selectId?: SelectEntityId<Entity>;\n}): typeof config {\n return config;\n}\n","import { computed, Signal } from '@angular/core';\nimport {\n EmptyFeatureResult,\n SignalStoreFeature,\n signalStoreFeature,\n withComputed,\n withState,\n} from '@ngrx/signals';\nimport {\n EntityProps,\n EntityId,\n EntityMap,\n EntityState,\n NamedEntityProps,\n NamedEntityState,\n} from './models';\nimport { getEntityStateKeys } from './helpers';\n\nexport function withEntities<Entity>(): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity, Collection extends string>(config: {\n entity: Entity;\n collection: Collection;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: NamedEntityState<Entity, Collection>;\n props: NamedEntityProps<Entity, Collection>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config: {\n entity: Entity;\n}): SignalStoreFeature<\n EmptyFeatureResult,\n {\n state: EntityState<Entity>;\n props: EntityProps<Entity>;\n methods: {};\n }\n>;\nexport function withEntities<Entity>(config?: {\n entity: Entity;\n collection?: string;\n}): SignalStoreFeature {\n const { entityMapKey, idsKey, entitiesKey } = getEntityStateKeys(config);\n\n return signalStoreFeature(\n withState({\n [entityMapKey]: {},\n [idsKey]: [],\n }),\n withComputed((store: Record<string, Signal<unknown>>) => ({\n [entitiesKey]: computed(() => {\n const entityMap = store[entityMapKey]() as EntityMap<Entity>;\n const ids = store[idsKey]() as EntityId[];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AS,GAAG,kBAAkB,CAClC,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,KAAK,CACN;QAED,OAAO,sBAAsB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC;AAClE,KAAC;AACH;;ACnCM,SAAU,YAAY,CAAS,MAIpC,EAAA;AACC,IAAA,OAAO,MAAM;AACf;;ACyBM,SAAU,YAAY,CAAS,MAGpC,EAAA;AACC,IAAA,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAExE,OAAO,kBAAkB,CACvB,SAAS,CAAC;QACR,CAAC,YAAY,GAAG,EAAE;QAClB,CAAC,MAAM,GAAG,EAAE;KACb,CAAC,EACF,YAAY,CAAC,CAAC,KAAsC,MAAM;AACxD,QAAA,CAAC,WAAW,GAAG,QAAQ,CAAC,MAAK;AAC3B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,EAAuB;AAC5D,YAAA,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,EAAgB;AAEzC,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CAAC;AACvC,SAAC,CAAC;KACH,CAAC,CAAC,CACJ;AACH;;ACnEA;;AAEG;;;;"}
|
|
@@ -14,7 +14,14 @@ function rxMethod(generator, config) {
|
|
|
14
14
|
source$.next(input);
|
|
15
15
|
return { destroy: noop };
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const callerInjector = getCallerInjector();
|
|
18
|
+
if (typeof ngDevMode !== 'undefined' &&
|
|
19
|
+
ngDevMode &&
|
|
20
|
+
config?.injector === undefined &&
|
|
21
|
+
callerInjector === undefined) {
|
|
22
|
+
console.warn('@ngrx/signals/rxjs-interop: The reactive method was called outside', 'the injection context with a signal or observable. This may lead to', 'a memory leak. Make sure to call it within the injection context', '(e.g. in a constructor or field initializer) or pass an injector', 'explicitly via the config parameter.\n\nFor more information, see:', 'https://ngrx.io/guide/signals/rxjs-integration#reactive-methods-and-injector-hierarchies');
|
|
23
|
+
}
|
|
24
|
+
const instanceInjector = config?.injector ?? callerInjector ?? sourceInjector;
|
|
18
25
|
if (isSignal(input)) {
|
|
19
26
|
const watcher = effect(() => {
|
|
20
27
|
const value = input();
|
|
@@ -43,7 +50,7 @@ function getCallerInjector() {
|
|
|
43
50
|
return inject(Injector);
|
|
44
51
|
}
|
|
45
52
|
catch {
|
|
46
|
-
return
|
|
53
|
+
return undefined;
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngrx-signals-rxjs-interop.mjs","sources":["../../../../modules/signals/rxjs-interop/src/rx-method.ts","../../../../modules/signals/rxjs-interop/ngrx-signals-rxjs-interop.ts"],"sourcesContent":["import {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n isSignal,\n Signal,\n untracked,\n} from '@angular/core';\nimport { isObservable, noop, Observable, Subject } from 'rxjs';\n\ntype RxMethodRef = {\n destroy: () => void;\n};\n\
|
|
1
|
+
{"version":3,"file":"ngrx-signals-rxjs-interop.mjs","sources":["../../../../modules/signals/rxjs-interop/src/rx-method.ts","../../../../modules/signals/rxjs-interop/ngrx-signals-rxjs-interop.ts"],"sourcesContent":["import {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n isSignal,\n Signal,\n untracked,\n} from '@angular/core';\nimport { isObservable, noop, Observable, Subject } from 'rxjs';\n\ndeclare const ngDevMode: unknown;\n\ntype RxMethodRef = {\n destroy: () => void;\n};\n\nexport type RxMethod<Input> = ((\n input: Input | Signal<Input> | Observable<Input>,\n config?: { injector?: Injector }\n) => RxMethodRef) &\n RxMethodRef;\n\nexport function rxMethod<Input>(\n generator: (source$: Observable<Input>) => Observable<unknown>,\n config?: { injector?: Injector }\n): RxMethod<Input> {\n if (!config?.injector) {\n assertInInjectionContext(rxMethod);\n }\n\n const sourceInjector = config?.injector ?? inject(Injector);\n const source$ = new Subject<Input>();\n const sourceSub = generator(source$).subscribe();\n sourceInjector.get(DestroyRef).onDestroy(() => sourceSub.unsubscribe());\n\n const rxMethodFn = (\n input: Input | Signal<Input> | Observable<Input>,\n config?: { injector?: Injector }\n ): RxMethodRef => {\n if (isStatic(input)) {\n source$.next(input);\n return { destroy: noop };\n }\n\n const callerInjector = getCallerInjector();\n if (\n typeof ngDevMode !== 'undefined' &&\n ngDevMode &&\n config?.injector === undefined &&\n callerInjector === undefined\n ) {\n console.warn(\n '@ngrx/signals/rxjs-interop: The reactive method was called outside',\n 'the injection context with a signal or observable. This may lead to',\n 'a memory leak. Make sure to call it within the injection context',\n '(e.g. in a constructor or field initializer) or pass an injector',\n 'explicitly via the config parameter.\\n\\nFor more information, see:',\n 'https://ngrx.io/guide/signals/rxjs-integration#reactive-methods-and-injector-hierarchies'\n );\n }\n\n const instanceInjector =\n config?.injector ?? callerInjector ?? sourceInjector;\n\n if (isSignal(input)) {\n const watcher = effect(\n () => {\n const value = input();\n untracked(() => source$.next(value));\n },\n { injector: instanceInjector }\n );\n sourceSub.add({ unsubscribe: () => watcher.destroy() });\n\n return watcher;\n }\n\n const instanceSub = input.subscribe((value) => source$.next(value));\n sourceSub.add(instanceSub);\n\n if (instanceInjector !== sourceInjector) {\n instanceInjector\n .get(DestroyRef)\n .onDestroy(() => instanceSub.unsubscribe());\n }\n\n return { destroy: () => instanceSub.unsubscribe() };\n };\n rxMethodFn.destroy = sourceSub.unsubscribe.bind(sourceSub);\n\n return rxMethodFn;\n}\n\nfunction isStatic<T>(value: T | Signal<T> | Observable<T>): value is T {\n return !isSignal(value) && !isObservable(value);\n}\n\nfunction getCallerInjector(): Injector | undefined {\n try {\n return inject(Injector);\n } catch {\n return undefined;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAwBgB,SAAA,QAAQ,CACtB,SAA8D,EAC9D,M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SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;AAEvD,YAAA,OAAO,OAAO;;AAGhB,QAAA,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,QAAA,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC;AAE1B,QAAA,IAAI,gBAAgB,KAAK,cAAc,EAAE;YACvC;iBACG,GAAG,CAAC,UAAU;iBACd,SAAS,CAAC,MAAM,WAAW,CAAC,WAAW,EAAE,CAAC;;QAG/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC,WAAW,EAAE,EAAE;AACrD,KAAC;IACD,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;AAE1D,IAAA,OAAO,UAAU;AACnB;AAEA,SAAS,QAAQ,CAAI,KAAoC,EAAA;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;AACjD;AAEA,SAAS,iBAAiB,GAAA;AACxB,IAAA,IAAI;AACF,QAAA,OAAO,MAAM,CAAC,QAAQ,CAAC;;AACvB,IAAA,MAAM;AACN,QAAA,OAAO,SAAS;;AAEpB;;ACzGA;;AAEG;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isWritableStateSource } from '@ngrx/signals';
|
|
2
|
+
|
|
3
|
+
function unprotected(source) {
|
|
4
|
+
if (isWritableStateSource(source)) {
|
|
5
|
+
return source;
|
|
6
|
+
}
|
|
7
|
+
throw new Error('@ngrx/signals: The provided source is not writable.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generated bundle index. Do not edit.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { unprotected };
|
|
15
|
+
//# sourceMappingURL=ngrx-signals-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngrx-signals-testing.mjs","sources":["../../../../modules/signals/testing/src/unprotected.ts","../../../../modules/signals/testing/ngrx-signals-testing.ts"],"sourcesContent":["import {\n isWritableStateSource,\n Prettify,\n StateSource,\n WritableStateSource,\n} from '@ngrx/signals';\n\ntype UnprotectedSource<Source extends StateSource<object>> =\n Source extends StateSource<infer State>\n ? Prettify<\n Omit<Source, keyof StateSource<State>> & WritableStateSource<State>\n >\n : never;\n\nexport function unprotected<Source extends StateSource<object>>(\n source: Source\n): UnprotectedSource<Source> {\n if (isWritableStateSource(source)) {\n return source as UnprotectedSource<Source>;\n }\n\n throw new Error('@ngrx/signals: The provided source is not writable.');\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAcM,SAAU,WAAW,CACzB,MAAc,EAAA;AAEd,IAAA,IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE;AACjC,QAAA,OAAO,MAAmC;;AAG5C,IAAA,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC;AACxE;;ACtBA;;AAEG;;;;"}
|