@ngrx/data 18.0.0-rc.0 → 18.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ngrx-data.mjs","sources":["../../../../modules/data/src/actions/entity-action-factory.ts","../../../../modules/data/src/actions/entity-action-guard.ts","../../../../modules/data/src/utils/utilities.ts","../../../../modules/data/src/actions/entity-action-operators.ts","../../../../modules/data/src/actions/entity-cache-change-set.ts","../../../../modules/data/src/actions/merge-strategy.ts","../../../../modules/data/src/actions/entity-cache-action.ts","../../../../modules/data/src/actions/entity-op.ts","../../../../modules/data/src/dataservices/data-service-error.ts","../../../../modules/data/src/dataservices/default-data-service-config.ts","../../../../modules/data/src/utils/interfaces.ts","../../../../modules/data/src/dataservices/http-url-generator.ts","../../../../modules/data/src/dataservices/default-data.service.ts","../../../../modules/data/src/entity-metadata/entity-definition.ts","../../../../modules/data/src/entity-metadata/entity-metadata.ts","../../../../modules/data/src/entity-metadata/entity-definition.service.ts","../../../../modules/data/src/dataservices/entity-cache-data.service.ts","../../../../modules/data/src/dataservices/entity-data.service.ts","../../../../modules/data/src/dataservices/persistence-result-handler.service.ts","../../../../modules/data/src/dispatchers/entity-dispatcher.ts","../../../../modules/data/src/utils/correlation-id-generator.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-default-options.ts","../../../../modules/data/src/dispatchers/entity-cache-dispatcher.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-base.ts","../../../../modules/data/src/reducers/constants.ts","../../../../modules/data/src/selectors/entity-cache-selector.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-factory.ts","../../../../modules/data/src/effects/entity-effects-scheduler.ts","../../../../modules/data/src/effects/entity-cache-effects.ts","../../../../modules/data/src/effects/entity-effects.ts","../../../../modules/data/src/entity-metadata/entity-filters.ts","../../../../modules/data/src/entity-services/entity-collection-service-base.ts","../../../../modules/data/src/reducers/entity-collection-creator.ts","../../../../modules/data/src/selectors/entity-selectors.ts","../../../../modules/data/src/selectors/entity-selectors$.ts","../../../../modules/data/src/entity-services/entity-collection-service-elements-factory.ts","../../../../modules/data/src/entity-services/entity-collection-service-factory.ts","../../../../modules/data/src/entity-services/entity-services-elements.ts","../../../../modules/data/src/entity-services/entity-services-base.ts","../../../../modules/data/src/entity-services/entity-services.ts","../../../../modules/data/src/reducers/entity-collection.ts","../../../../modules/data/src/reducers/entity-change-tracker-base.ts","../../../../modules/data/src/reducers/entity-collection-reducer-methods.ts","../../../../modules/data/src/reducers/entity-collection-reducer.ts","../../../../modules/data/src/reducers/entity-collection-reducer-registry.ts","../../../../modules/data/src/reducers/entity-cache-reducer.ts","../../../../modules/data/src/utils/default-logger.ts","../../../../modules/data/src/utils/default-pluralizer.ts","../../../../modules/data/src/utils/guid-fns.ts","../../../../modules/data/src/provide-entity-data.ts","../../../../modules/data/src/entity-data-without-effects.module.ts","../../../../modules/data/src/entity-data.module.ts","../../../../modules/data/src/index.ts","../../../../modules/data/index.ts","../../../../modules/data/ngrx-data.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { EntityOp } from './entity-op';\nimport {\n EntityAction,\n EntityActionOptions,\n EntityActionPayload,\n} from './entity-action';\n@Injectable()\nexport class EntityActionFactory {\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param entityName Name of the entity type\n * @param entityOp Operation to perform (EntityOp)\n * @param [data] data for the operation\n * @param [options] additional options\n */\n create<P = any>(\n entityName: string,\n entityOp: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param payload Defines the EntityAction and its options\n */\n create<P = any>(payload: EntityActionPayload<P>): EntityAction<P>;\n\n // polymorphic create for the two signatures\n create<P = any>(\n nameOrPayload: EntityActionPayload<P> | string,\n entityOp?: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n const payload: EntityActionPayload<P> =\n typeof nameOrPayload === 'string'\n ? ({\n ...(options || {}),\n entityName: nameOrPayload,\n entityOp,\n data,\n } as EntityActionPayload<P>)\n : nameOrPayload;\n return this.createCore(payload);\n }\n\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param payload Defines the EntityAction and its options\n */\n protected createCore<P = any>(payload: EntityActionPayload<P>) {\n const { entityName, entityOp, tag } = payload;\n if (!entityName) {\n throw new Error('Missing entity name for new action');\n }\n if (entityOp == null) {\n throw new Error('Missing EntityOp for new action');\n }\n const type = this.formatActionType(entityOp, tag || entityName);\n return { type, payload };\n }\n\n /**\n * Create an EntityAction from another EntityAction, replacing properties with those from newPayload;\n * @param from Source action that is the base for the new action\n * @param newProperties New EntityAction properties that replace the source action properties\n */\n createFromAction<P = any>(\n from: EntityAction,\n newProperties: Partial<EntityActionPayload<P>>\n ): EntityAction<P> {\n return this.create({ ...from.payload, ...newProperties });\n }\n\n formatActionType(op: string, tag: string) {\n return `[${tag}] ${op}`;\n // return `${op} [${tag}]`.toUpperCase(); // example of an alternative\n }\n}\n","import { IdSelector, Update } from '@ngrx/entity';\n\nimport { EntityAction } from './entity-action';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Guard methods that ensure EntityAction payload is as expected.\n * Each method returns that payload if it passes the guard or\n * throws an error.\n */\nexport class EntityActionGuard<T> {\n constructor(private entityName: string, private selectId: IdSelector<T>) {}\n\n /** Throw if the action payload is not an entity with a valid key */\n mustBeEntity(action: EntityAction<T>): T {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should have a single entity.`);\n }\n const id = this.selectId(data);\n if (this.isNotKeyType(id)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data as T;\n }\n\n /** Throw if the action payload is not an array of entities with valid keys */\n mustBeEntities(action: EntityAction<T[]>): T[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entities`);\n }\n data.forEach((entity, i) => {\n const id = this.selectId(entity);\n if (this.isNotKeyType(id)) {\n const msg = `, item ${i + 1}, does not have a valid entity key (id)`;\n this.throwError(action, msg);\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not a single, valid key */\n mustBeKey(action: EntityAction<string | number>): string | number | never {\n const data = this.extractData(action);\n if (data === undefined) {\n throw new Error(`should be a single entity key`);\n }\n if (this.isNotKeyType(data)) {\n throw new Error(`is not a valid key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of valid keys */\n mustBeKeys(action: EntityAction<(string | number)[]>): (string | number)[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity keys (id)`);\n }\n data.forEach((id, i) => {\n if (this.isNotKeyType(id)) {\n const msg = `${this.entityName} ', item ${\n i + 1\n }, is not a valid entity key (id)`;\n this.throwError(action, msg);\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not an update with a valid key (id) */\n mustBeUpdate(action: EntityAction<Update<T>>): Update<T> {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should be a single entity update`);\n }\n const { id, changes } = data;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of updates with valid keys (ids) */\n mustBeUpdates(action: EntityAction<Update<T>[]>): Update<T>[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity updates`);\n }\n data.forEach((item, i) => {\n const { id, changes } = item;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(\n action,\n `, item ${i + 1}, has a missing or invalid entity key (id)`\n );\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not an update response with a valid key (id) */\n mustBeUpdateResponse(\n action: EntityAction<UpdateResponseData<T>>\n ): UpdateResponseData<T> {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should be a single entity update`);\n }\n const { id, changes } = data;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of update responses with valid keys (ids) */\n mustBeUpdateResponses(\n action: EntityAction<UpdateResponseData<T>[]>\n ): UpdateResponseData<T>[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity updates`);\n }\n data.forEach((item, i) => {\n const { id, changes } = item;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(\n action,\n `, item ${i + 1}, has a missing or invalid entity key (id)`\n );\n }\n });\n return data;\n }\n\n private extractData<T>(action: EntityAction<T>) {\n return action.payload && action.payload.data;\n }\n\n /** Return true if this key (id) is invalid */\n private isNotKeyType(id: any) {\n return typeof id !== 'string' && typeof id !== 'number';\n }\n\n private throwError(action: EntityAction, msg: string): never {\n throw new Error(\n `${this.entityName} EntityAction guard for \"${action.type}\": payload ${msg}`\n );\n }\n}\n","import { IdSelector, Update } from '@ngrx/entity';\n\n/**\n * Default function that returns the entity's primary key (pkey).\n * Assumes that the entity has an `id` pkey property.\n * Returns `undefined` if no entity or `id`.\n * Every selectId fn must return `undefined` when it cannot produce a full pkey.\n */\nexport function defaultSelectId(entity: any) {\n return entity == null ? undefined : entity.id;\n}\n\n/**\n * Flatten first arg if it is an array\n * Allows fn with ...rest signature to be called with an array instead of spread\n * Example:\n * ```\n * // See entity-action-operators.ts\n * const persistOps = [EntityOp.QUERY_ALL, EntityOp.ADD, ...];\n * actions.pipe(ofEntityOp(...persistOps)) // works\n * actions.pipe(ofEntityOp(persistOps)) // also works\n * ```\n * */\nexport function flattenArgs<T>(args?: any[]): T[] {\n if (args == null) {\n return [];\n }\n if (Array.isArray(args[0])) {\n const [head, ...tail] = args;\n args = [...head, ...tail];\n }\n return args;\n}\n\n/**\n * Return a function that converts an entity (or partial entity) into the `Update<T>`\n * whose `id` is the primary key and\n * `changes` is the entity (or partial entity of changes).\n */\nexport function toUpdateFactory<T>(selectId?: IdSelector<T>) {\n selectId = selectId || (defaultSelectId as IdSelector<T>);\n /**\n * Convert an entity (or partial entity) into the `Update<T>`\n * whose `id` is the primary key and\n * `changes` is the entity (or partial entity of changes).\n * @param selectId function that returns the entity's primary key (id)\n */\n return function toUpdate(entity: Partial<T>): Update<T> {\n const id: any = selectId!(entity as T);\n if (id == null) {\n throw new Error('Primary key may not be null/undefined.');\n }\n return entity && { id, changes: entity };\n };\n}\n","import { OperatorFunction } from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { EntityAction } from './entity-action';\nimport { EntityOp } from './entity-op';\nimport { flattenArgs } from '../utils/utilities';\n\n/**\n * Select actions concerning one of the allowed Entity operations\n * @param allowedEntityOps Entity operations (e.g, EntityOp.QUERY_ALL) whose actions should be selected\n * Example:\n * ```\n * this.actions.pipe(ofEntityOp(EntityOp.QUERY_ALL, EntityOp.QUERY_MANY), ...)\n * this.actions.pipe(ofEntityOp(...queryOps), ...)\n * this.actions.pipe(ofEntityOp(queryOps), ...)\n * this.actions.pipe(ofEntityOp(), ...) // any action with a defined `entityOp` property\n * ```\n */\nexport function ofEntityOp<T extends EntityAction>(\n allowedOps: string[] | EntityOp[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityOp<T extends EntityAction>(\n ...allowedOps: (string | EntityOp)[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityOp<T extends EntityAction>(\n ...allowedEntityOps: any[]\n): OperatorFunction<EntityAction, T> {\n const ops: string[] = flattenArgs(allowedEntityOps);\n switch (ops.length) {\n case 0:\n return filter(\n (action: EntityAction): action is T =>\n action.payload && action.payload.entityOp != null\n );\n case 1:\n const op = ops[0];\n return filter(\n (action: EntityAction): action is T =>\n action.payload && op === action.payload.entityOp\n );\n default:\n return filter((action: EntityAction): action is T => {\n const entityOp = action.payload && action.payload.entityOp;\n return entityOp && ops.some((o) => o === entityOp);\n });\n }\n}\n\n/**\n * Select actions concerning one of the allowed Entity types\n * @param allowedEntityNames Entity-type names (e.g, 'Hero') whose actions should be selected\n * Example:\n * ```\n * this.actions.pipe(ofEntityType(), ...) // ayn EntityAction with a defined entity type property\n * this.actions.pipe(ofEntityType('Hero'), ...) // EntityActions for the Hero entity\n * this.actions.pipe(ofEntityType('Hero', 'Villain', 'Sidekick'), ...)\n * this.actions.pipe(ofEntityType(...theChosen), ...)\n * this.actions.pipe(ofEntityType(theChosen), ...)\n * ```\n */\nexport function ofEntityType<T extends EntityAction>(\n allowedEntityNames?: string[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityType<T extends EntityAction>(\n ...allowedEntityNames: string[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityType<T extends EntityAction>(\n ...allowedEntityNames: any[]\n): OperatorFunction<EntityAction, T> {\n const names: string[] = flattenArgs(allowedEntityNames);\n switch (names.length) {\n case 0:\n return filter(\n (action: EntityAction): action is T =>\n action.payload && action.payload.entityName != null\n );\n case 1:\n const name = names[0];\n return filter(\n (action: EntityAction): action is T =>\n action.payload && name === action.payload.entityName\n );\n default:\n return filter((action: EntityAction): action is T => {\n const entityName = action.payload && action.payload.entityName;\n return !!entityName && names.some((n) => n === entityName);\n });\n }\n}\n","import { Update } from '@ngrx/entity';\n\nexport enum ChangeSetOperation {\n Add = 'Add',\n Delete = 'Delete',\n Update = 'Update',\n Upsert = 'Upsert',\n}\nexport interface ChangeSetAdd<T = any> {\n op: ChangeSetOperation.Add;\n entityName: string;\n entities: T[];\n}\n\nexport interface ChangeSetDelete {\n op: ChangeSetOperation.Delete;\n entityName: string;\n entities: string[] | number[];\n}\n\nexport interface ChangeSetUpdate<T = any> {\n op: ChangeSetOperation.Update;\n entityName: string;\n entities: Update<T>[];\n}\n\nexport interface ChangeSetUpsert<T = any> {\n op: ChangeSetOperation.Upsert;\n entityName: string;\n entities: T[];\n}\n\n/**\n * A entities of a single entity type, which are changed in the same way by a ChangeSetOperation\n */\nexport type ChangeSetItem =\n | ChangeSetAdd\n | ChangeSetDelete\n | ChangeSetUpdate\n | ChangeSetUpsert;\n\n/*\n * A set of entity Changes, typically to be saved.\n */\nexport interface ChangeSet<T = any> {\n /** An array of ChangeSetItems to be processed in the array order */\n changes: ChangeSetItem[];\n\n /**\n * An arbitrary, serializable object that should travel with the ChangeSet.\n * Meaningful to the ChangeSet producer and consumer. Ignored by @ngrx/data.\n */\n extras?: T;\n\n /** An arbitrary string, identifying the ChangeSet and perhaps its purpose */\n tag?: string;\n}\n\n/**\n * Factory to create a ChangeSetItem for a ChangeSetOperation\n */\nexport class ChangeSetItemFactory {\n /** Create the ChangeSetAdd for new entities of the given entity type */\n add<T>(entityName: string, entities: T | T[]): ChangeSetAdd<T> {\n entities = Array.isArray(entities) ? entities : entities ? [entities] : [];\n return { entityName, op: ChangeSetOperation.Add, entities };\n }\n\n /** Create the ChangeSetDelete for primary keys of the given entity type */\n delete(\n entityName: string,\n keys: number | number[] | string | string[]\n ): ChangeSetDelete {\n const ids = Array.isArray(keys)\n ? keys\n : keys\n ? ([keys] as string[] | number[])\n : [];\n return { entityName, op: ChangeSetOperation.Delete, entities: ids };\n }\n\n /** Create the ChangeSetUpdate for Updates of entities of the given entity type */\n update<T extends { id: string | number }>(\n entityName: string,\n updates: Update<T> | Update<T>[]\n ): ChangeSetUpdate<T> {\n updates = Array.isArray(updates) ? updates : updates ? [updates] : [];\n return { entityName, op: ChangeSetOperation.Update, entities: updates };\n }\n\n /** Create the ChangeSetUpsert for new or existing entities of the given entity type */\n upsert<T>(entityName: string, entities: T | T[]): ChangeSetUpsert<T> {\n entities = Array.isArray(entities) ? entities : entities ? [entities] : [];\n return { entityName, op: ChangeSetOperation.Upsert, entities };\n }\n}\n\n/**\n * Instance of a factory to create a ChangeSetItem for a ChangeSetOperation\n */\nexport const changeSetItemFactory = new ChangeSetItemFactory();\n\n/**\n * Return ChangeSet after filtering out null and empty ChangeSetItems.\n * @param changeSet ChangeSet with changes to filter\n */\nexport function excludeEmptyChangeSetItems(changeSet: ChangeSet): ChangeSet {\n changeSet = changeSet && changeSet.changes ? changeSet : { changes: [] };\n const changes = changeSet.changes.filter(\n (c) => c != null && c.entities && c.entities.length > 0\n );\n return { ...changeSet, changes };\n}\n","/** How to merge an entity, after query or save, when the corresponding entity in the collection has unsaved changes. */\nexport enum MergeStrategy {\n /**\n * Update the collection entities and ignore all change tracking for this operation.\n * Each entity's `changeState` is untouched.\n */\n IgnoreChanges,\n /**\n * Updates current values for unchanged entities.\n * For each changed entity it preserves the current value and overwrites the `originalValue` with the merge entity.\n * This is the query-success default.\n */\n PreserveChanges,\n /**\n * Replace the current collection entities.\n * For each merged entity it discards the `changeState` and sets the `changeType` to \"unchanged\".\n * This is the save-success default.\n */\n OverwriteChanges,\n}\n","/*\n * Actions dedicated to the EntityCache as a whole\n */\nimport { Action } from '@ngrx/store';\n\nimport { ChangeSet, ChangeSetOperation } from './entity-cache-change-set';\nexport { ChangeSet, ChangeSetOperation } from './entity-cache-change-set';\n\nimport { DataServiceError } from '../dataservices/data-service-error';\nimport { EntityActionOptions } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { MergeStrategy } from '../actions/merge-strategy';\n\nexport enum EntityCacheAction {\n CLEAR_COLLECTIONS = '@ngrx/data/entity-cache/clear-collections',\n LOAD_COLLECTIONS = '@ngrx/data/entity-cache/load-collections',\n MERGE_QUERY_SET = '@ngrx/data/entity-cache/merge-query-set',\n SET_ENTITY_CACHE = '@ngrx/data/entity-cache/set-cache',\n\n SAVE_ENTITIES = '@ngrx/data/entity-cache/save-entities',\n SAVE_ENTITIES_CANCEL = '@ngrx/data/entity-cache/save-entities-cancel',\n SAVE_ENTITIES_CANCELED = '@ngrx/data/entity-cache/save-entities-canceled',\n SAVE_ENTITIES_ERROR = '@ngrx/data/entity-cache/save-entities-error',\n SAVE_ENTITIES_SUCCESS = '@ngrx/data/entity-cache/save-entities-success',\n}\n\n/**\n * Hash of entities keyed by EntityCollection name,\n * typically the result of a query that returned results from a multi-collection query\n * that will be merged into an EntityCache via the `MergeQuerySet` action.\n */\nexport interface EntityCacheQuerySet {\n [entityName: string]: any[];\n}\n\n/**\n * Clear the collections identified in the collectionSet.\n * @param [collections] Array of names of the collections to clear.\n * If empty array, does nothing. If no array, clear all collections.\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class ClearCollections implements Action {\n readonly payload: { collections?: string[]; tag?: string };\n readonly type = EntityCacheAction.CLEAR_COLLECTIONS;\n\n constructor(collections?: string[], tag?: string) {\n this.payload = { collections, tag };\n }\n}\n\n/**\n * Create entity cache action that loads multiple entity collections at the same time.\n * before any selectors$ observables emit.\n * @param querySet The collections to load, typically the result of a query.\n * @param [tag] Optional tag to identify the operation from the app perspective.\n * in the form of a map of entity collections.\n */\nexport class LoadCollections implements Action {\n readonly payload: { collections: EntityCacheQuerySet; tag?: string };\n readonly type = EntityCacheAction.LOAD_COLLECTIONS;\n\n constructor(collections: EntityCacheQuerySet, tag?: string) {\n this.payload = { collections, tag };\n }\n}\n\n/**\n * Create entity cache action that merges entities from a query result\n * that returned entities from multiple collections.\n * Corresponding entity cache reducer should add and update all collections\n * at the same time, before any selectors$ observables emit.\n * @param querySet The result of the query in the form of a map of entity collections.\n * These are the entity data to merge into the respective collections.\n * @param mergeStrategy How to merge a queried entity when it is already in the collection.\n * The default is MergeStrategy.PreserveChanges\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class MergeQuerySet implements Action {\n readonly payload: {\n querySet: EntityCacheQuerySet;\n mergeStrategy?: MergeStrategy;\n tag?: string;\n };\n\n readonly type = EntityCacheAction.MERGE_QUERY_SET;\n\n constructor(\n querySet: EntityCacheQuerySet,\n mergeStrategy?: MergeStrategy,\n tag?: string\n ) {\n this.payload = {\n querySet,\n mergeStrategy:\n mergeStrategy === null ? MergeStrategy.PreserveChanges : mergeStrategy,\n tag,\n };\n }\n}\n\n/**\n * Create entity cache action for replacing the entire entity cache.\n * Dangerous because brute force but useful as when re-hydrating an EntityCache\n * from local browser storage when the application launches.\n * @param cache New state of the entity cache\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class SetEntityCache implements Action {\n readonly payload: { cache: EntityCache; tag?: string };\n readonly type = EntityCacheAction.SET_ENTITY_CACHE;\n\n constructor(public readonly cache: EntityCache, tag?: string) {\n this.payload = { cache, tag };\n }\n}\n\n// #region SaveEntities\nexport class SaveEntities implements Action {\n readonly payload: {\n readonly changeSet: ChangeSet;\n readonly url: string;\n readonly correlationId?: any;\n readonly isOptimistic?: boolean;\n readonly mergeStrategy?: MergeStrategy;\n readonly tag?: string;\n error?: Error;\n skip?: boolean; // not used\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES;\n\n constructor(\n changeSet: ChangeSet,\n url: string,\n options?: EntityActionOptions\n ) {\n options = options || {};\n if (changeSet) {\n changeSet.tag = changeSet.tag || options.tag;\n }\n this.payload = { changeSet, url, ...options, tag: changeSet.tag };\n }\n}\n\nexport class SaveEntitiesCancel implements Action {\n readonly payload: {\n readonly correlationId: any;\n readonly reason?: string;\n readonly entityNames?: string[];\n readonly tag?: string;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_CANCEL;\n\n constructor(\n correlationId: any,\n reason?: string,\n entityNames?: string[],\n tag?: string\n ) {\n this.payload = { correlationId, reason, entityNames, tag };\n }\n}\n\nexport class SaveEntitiesCanceled implements Action {\n readonly payload: {\n readonly correlationId: any;\n readonly reason?: string;\n readonly tag?: string;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_CANCELED;\n\n constructor(correlationId: any, reason?: string, tag?: string) {\n this.payload = { correlationId, reason, tag };\n }\n}\n\nexport class SaveEntitiesError {\n readonly payload: {\n readonly error: DataServiceError;\n readonly originalAction: SaveEntities;\n readonly correlationId: any;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_ERROR;\n constructor(error: DataServiceError, originalAction: SaveEntities) {\n const correlationId = originalAction.payload.correlationId;\n this.payload = { error, originalAction, correlationId };\n }\n}\n\nexport class SaveEntitiesSuccess implements Action {\n readonly payload: {\n readonly changeSet: ChangeSet;\n readonly url: string;\n readonly correlationId?: any;\n readonly isOptimistic?: boolean;\n readonly mergeStrategy?: MergeStrategy;\n readonly tag?: string;\n error?: Error;\n skip?: boolean; // not used\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_SUCCESS;\n\n constructor(\n changeSet: ChangeSet,\n url: string,\n options?: EntityActionOptions\n ) {\n options = options || {};\n if (changeSet) {\n changeSet.tag = changeSet.tag || options.tag;\n }\n this.payload = { changeSet, url, ...options, tag: changeSet.tag };\n }\n}\n// #endregion SaveEntities\n","// Ensure that these suffix values and the EntityOp suffixes match\n// Cannot do that programmatically.\n\n/** General purpose entity action operations, good for any entity type */\nexport enum EntityOp {\n // Persistance operations\n CANCEL_PERSIST = '@ngrx/data/cancel-persist',\n CANCELED_PERSIST = '@ngrx/data/canceled-persist',\n\n QUERY_ALL = '@ngrx/data/query-all',\n QUERY_ALL_SUCCESS = '@ngrx/data/query-all/success',\n QUERY_ALL_ERROR = '@ngrx/data/query-all/error',\n\n QUERY_LOAD = '@ngrx/data/query-load',\n QUERY_LOAD_SUCCESS = '@ngrx/data/query-load/success',\n QUERY_LOAD_ERROR = '@ngrx/data/query-load/error',\n\n QUERY_MANY = '@ngrx/data/query-many',\n QUERY_MANY_SUCCESS = '@ngrx/data/query-many/success',\n QUERY_MANY_ERROR = '@ngrx/data/query-many/error',\n\n QUERY_BY_KEY = '@ngrx/data/query-by-key',\n QUERY_BY_KEY_SUCCESS = '@ngrx/data/query-by-key/success',\n QUERY_BY_KEY_ERROR = '@ngrx/data/query-by-key/error',\n\n SAVE_ADD_MANY = '@ngrx/data/save/add-many',\n SAVE_ADD_MANY_ERROR = '@ngrx/data/save/add-many/error',\n SAVE_ADD_MANY_SUCCESS = '@ngrx/data/save/add-many/success',\n\n SAVE_ADD_ONE = '@ngrx/data/save/add-one',\n SAVE_ADD_ONE_ERROR = '@ngrx/data/save/add-one/error',\n SAVE_ADD_ONE_SUCCESS = '@ngrx/data/save/add-one/success',\n\n SAVE_DELETE_MANY = '@ngrx/data/save/delete-many',\n SAVE_DELETE_MANY_SUCCESS = '@ngrx/data/save/delete-many/success',\n SAVE_DELETE_MANY_ERROR = '@ngrx/data/save/delete-many/error',\n\n SAVE_DELETE_ONE = '@ngrx/data/save/delete-one',\n SAVE_DELETE_ONE_SUCCESS = '@ngrx/data/save/delete-one/success',\n SAVE_DELETE_ONE_ERROR = '@ngrx/data/save/delete-one/error',\n\n SAVE_UPDATE_MANY = '@ngrx/data/save/update-many',\n SAVE_UPDATE_MANY_SUCCESS = '@ngrx/data/save/update-many/success',\n SAVE_UPDATE_MANY_ERROR = '@ngrx/data/save/update-many/error',\n\n SAVE_UPDATE_ONE = '@ngrx/data/save/update-one',\n SAVE_UPDATE_ONE_SUCCESS = '@ngrx/data/save/update-one/success',\n SAVE_UPDATE_ONE_ERROR = '@ngrx/data/save/update-one/error',\n\n // Use only if the server supports upsert;\n SAVE_UPSERT_MANY = '@ngrx/data/save/upsert-many',\n SAVE_UPSERT_MANY_SUCCESS = '@ngrx/data/save/upsert-many/success',\n SAVE_UPSERT_MANY_ERROR = '@ngrx/data/save/upsert-many/error',\n\n // Use only if the server supports upsert;\n SAVE_UPSERT_ONE = '@ngrx/data/save/upsert-one',\n SAVE_UPSERT_ONE_SUCCESS = '@ngrx/data/save/upsert-one/success',\n SAVE_UPSERT_ONE_ERROR = '@ngrx/data/save/upsert-one/error',\n\n // Cache operations\n ADD_ALL = '@ngrx/data/add-all',\n ADD_MANY = '@ngrx/data/add-many',\n ADD_ONE = '@ngrx/data/add-one',\n REMOVE_ALL = '@ngrx/data/remove-all',\n REMOVE_MANY = '@ngrx/data/remove-many',\n REMOVE_ONE = '@ngrx/data/remove-one',\n UPDATE_MANY = '@ngrx/data/update-many',\n UPDATE_ONE = '@ngrx/data/update-one',\n UPSERT_MANY = '@ngrx/data/upsert-many',\n UPSERT_ONE = '@ngrx/data/upsert-one',\n\n COMMIT_ALL = '@ngrx/data/commit-all',\n COMMIT_MANY = '@ngrx/data/commit-many',\n COMMIT_ONE = '@ngrx/data/commit-one',\n UNDO_ALL = '@ngrx/data/undo-all',\n UNDO_MANY = '@ngrx/data/undo-many',\n UNDO_ONE = '@ngrx/data/undo-one',\n\n SET_CHANGE_STATE = '@ngrx/data/set-change-state',\n SET_COLLECTION = '@ngrx/data/set-collection',\n SET_FILTER = '@ngrx/data/set-filter',\n SET_LOADED = '@ngrx/data/set-loaded',\n SET_LOADING = '@ngrx/data/set-loading',\n}\n\n/** \"Success\" suffix appended to EntityOps that are successful.*/\nexport const OP_SUCCESS = '/success';\n\n/** \"Error\" suffix appended to EntityOps that have failed.*/\nexport const OP_ERROR = '/error';\n\n/** Make the error EntityOp corresponding to the given EntityOp */\nexport function makeErrorOp(op: EntityOp): EntityOp {\n return <EntityOp>(op + OP_ERROR);\n}\n\n/** Make the success EntityOp corresponding to the given EntityOp */\nexport function makeSuccessOp(op: EntityOp): EntityOp {\n return <EntityOp>(op + OP_SUCCESS);\n}\n","import { EntityAction } from '../actions/entity-action';\nimport { RequestData } from './interfaces';\n\n/**\n * Error from a DataService\n * The source error either comes from a failed HTTP response or was thrown within the service.\n * @param error the HttpErrorResponse or the error thrown by the service\n * @param requestData the HTTP request information such as the method and the url.\n */\nexport class DataServiceError extends Error {\n constructor(public error: any, public requestData: RequestData | null) {\n super(\n typeof error === 'string' ? error : extractMessage(error) ?? undefined\n );\n this.name = this.constructor.name;\n }\n}\n\n// Many ways the error can be shaped. These are the ways we recognize.\nfunction extractMessage(sourceError: any): string | null {\n const { error, body, message } = sourceError;\n let errMessage: string | null = null;\n if (error) {\n // prefer HttpErrorResponse.error to its message property\n errMessage = typeof error === 'string' ? error : error.message;\n } else if (message) {\n errMessage = message;\n } else if (body) {\n // try the body if no error or message property\n errMessage = typeof body === 'string' ? body : body.error;\n }\n\n return typeof errMessage === 'string'\n ? errMessage\n : errMessage\n ? JSON.stringify(errMessage)\n : null;\n}\n\n/** Payload for an EntityAction data service error such as QUERY_ALL_ERROR */\nexport interface EntityActionDataServiceError {\n error: DataServiceError;\n originalAction: EntityAction;\n}\n","import { EntityHttpResourceUrls } from './http-url-generator';\n\n/**\n * Optional configuration settings for an entity collection data service\n * such as the `DefaultDataService<T>`.\n */\nexport abstract class DefaultDataServiceConfig {\n /**\n * root path of the web api. may also include protocol, domain, and port\n * for remote api, e.g.: `'https://api-domain.com:8000/api/v1'` (default: 'api')\n */\n root?: string;\n /**\n * Known entity HttpResourceUrls.\n * HttpUrlGenerator will create these URLs for entity types not listed here.\n */\n entityHttpResourceUrls?: EntityHttpResourceUrls;\n /** Is a DELETE 404 really OK? (default: true) */\n delete404OK?: boolean;\n /** Simulate GET latency in a demo (default: 0) */\n getDelay?: number;\n /** Simulate save method (PUT/POST/DELETE) latency in a demo (default: 0) */\n saveDelay?: number;\n /** request timeout in MS (default: 0)*/\n timeout?: number; //\n /** to keep leading & trailing slashes or not; false by default */\n trailingSlashEndpoints?: boolean;\n}\n","import { InjectionToken } from '@angular/core';\n\nexport abstract class Logger {\n abstract error(message?: any, ...optionalParams: any[]): void;\n abstract log(message?: any, ...optionalParams: any[]): void;\n abstract warn(message?: any, ...optionalParams: any[]): void;\n}\n\n/**\n * Mapping of entity type name to its plural\n */\nexport interface EntityPluralNames {\n [entityName: string]: string;\n}\n\nexport const PLURAL_NAMES_TOKEN = new InjectionToken<EntityPluralNames>(\n '@ngrx/data Plural Names'\n);\n\nexport abstract class Pluralizer {\n abstract pluralize(name: string): string;\n}\n","import { Injectable } from '@angular/core';\nimport { Pluralizer } from '../utils/interfaces';\n\n/**\n * Known resource URLS for specific entity types.\n * Each entity's resource URLS are endpoints that\n * target single entity and multi-entity HTTP operations.\n * Used by the `DefaultHttpUrlGenerator`.\n */\nexport abstract class EntityHttpResourceUrls {\n [entityName: string]: HttpResourceUrls;\n}\n\n/**\n * Resource URLS for HTTP operations that target single entity\n * and multi-entity endpoints.\n */\nexport interface HttpResourceUrls {\n /**\n * The URL path for a single entity endpoint, e.g, `some-api-root/hero/`\n * such as you'd use to add a hero.\n * Example: `httpClient.post<Hero>('some-api-root/hero/', addedHero)`.\n * Note trailing slash (/).\n */\n entityResourceUrl: string;\n /**\n * The URL path for a multiple-entity endpoint, e.g, `some-api-root/heroes/`\n * such as you'd use when getting all heroes.\n * Example: `httpClient.get<Hero[]>('some-api-root/heroes/')`\n * Note trailing slash (/).\n */\n collectionResourceUrl: string;\n}\n\n/**\n * Generate the base part of an HTTP URL for\n * single entity or entity collection resource\n */\nexport abstract class HttpUrlGenerator {\n /**\n * Return the base URL for a single entity resource,\n * e.g., the base URL to get a single hero by its id\n */\n abstract entityResource(\n entityName: string,\n root: string,\n trailingSlashEndpoints: boolean\n ): string;\n\n /**\n * Return the base URL for a collection resource,\n * e.g., the base URL to get all heroes\n */\n abstract collectionResource(entityName: string, root: string): string;\n\n /**\n * Register known single-entity and collection resource URLs for HTTP calls\n * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names\n */\n abstract registerHttpResourceUrls(\n entityHttpResourceUrls?: EntityHttpResourceUrls\n ): void;\n}\n\n@Injectable()\nexport class DefaultHttpUrlGenerator implements HttpUrlGenerator {\n /**\n * Known single-entity and collection resource URLs for HTTP calls.\n * Generator methods returns these resource URLs for a given entity type name.\n * If the resources for an entity type name are not know, it generates\n * and caches a resource name for future use\n */\n protected knownHttpResourceUrls: EntityHttpResourceUrls = {};\n\n constructor(private pluralizer: Pluralizer) {}\n\n /**\n * Get or generate the entity and collection resource URLs for the given entity type name\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n */\n protected getResourceUrls(\n entityName: string,\n root: string,\n trailingSlashEndpoints = false\n ): HttpResourceUrls {\n let resourceUrls = this.knownHttpResourceUrls[entityName];\n if (!resourceUrls) {\n const nRoot = trailingSlashEndpoints ? root : normalizeRoot(root);\n resourceUrls = {\n entityResourceUrl: `${nRoot}/${entityName}/`.toLowerCase(),\n collectionResourceUrl: `${nRoot}/${this.pluralizer.pluralize(\n entityName\n )}/`.toLowerCase(),\n };\n this.registerHttpResourceUrls({ [entityName]: resourceUrls });\n }\n return resourceUrls;\n }\n\n /**\n * Create the path to a single entity resource\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n * @returns complete path to resource, e.g, 'some-api/hero'\n */\n entityResource(\n entityName: string,\n root: string,\n trailingSlashEndpoints: boolean\n ): string {\n return this.getResourceUrls(entityName, root, trailingSlashEndpoints)\n .entityResourceUrl;\n }\n\n /**\n * Create the path to a multiple entity (collection) resource\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n * @returns complete path to resource, e.g, 'some-api/heroes'\n */\n collectionResource(entityName: string, root: string): string {\n return this.getResourceUrls(entityName, root).collectionResourceUrl;\n }\n\n /**\n * Register known single-entity and collection resource URLs for HTTP calls\n * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names\n * Well-formed resource urls end in a '/';\n * Note: this method does not ensure that resource urls are well-formed.\n */\n registerHttpResourceUrls(\n entityHttpResourceUrls: EntityHttpResourceUrls\n ): void {\n this.knownHttpResourceUrls = {\n ...this.knownHttpResourceUrls,\n ...(entityHttpResourceUrls || {}),\n };\n }\n}\n\n/** Remove leading & trailing spaces or slashes */\nexport function normalizeRoot(root: string) {\n return root.replace(/^[/\\s]+|[/\\s]+$/g, '');\n}\n","import { Injectable, isDevMode, Optional } from '@angular/core';\nimport {\n HttpClient,\n HttpErrorResponse,\n HttpHeaders,\n HttpParams,\n} from '@angular/common/http';\n\nimport { Observable, of, throwError } from 'rxjs';\nimport { catchError, delay, map, timeout } from 'rxjs/operators';\n\nimport { Update } from '@ngrx/entity';\n\nimport { DataServiceError } from './data-service-error';\nimport { DefaultDataServiceConfig } from './default-data-service-config';\nimport {\n EntityCollectionDataService,\n HttpMethods,\n HttpOptions,\n QueryParams,\n RequestData,\n} from './interfaces';\nimport { HttpUrlGenerator } from './http-url-generator';\n\n/**\n * A basic, generic entity data service\n * suitable for persistence of most entities.\n * Assumes a common REST-y web API\n */\nexport class DefaultDataService<T> implements EntityCollectionDataService<T> {\n protected _name: string;\n protected delete404OK: boolean;\n protected entityName: string;\n protected entityUrl: string;\n protected entitiesUrl: string;\n protected getDelay = 0;\n protected saveDelay = 0;\n protected timeout = 0;\n protected trailingSlashEndpoints = false;\n\n get name() {\n return this._name;\n }\n\n constructor(\n entityName: string,\n protected http: HttpClient,\n protected httpUrlGenerator: HttpUrlGenerator,\n config?: DefaultDataServiceConfig\n ) {\n this._name = `${entityName} DefaultDataService`;\n this.entityName = entityName;\n const {\n root = 'api',\n delete404OK = true,\n getDelay = 0,\n saveDelay = 0,\n timeout: to = 0,\n trailingSlashEndpoints = false,\n } = config || {};\n this.delete404OK = delete404OK;\n this.entityUrl = httpUrlGenerator.entityResource(\n entityName,\n root,\n trailingSlashEndpoints\n );\n this.entitiesUrl = httpUrlGenerator.collectionResource(entityName, root);\n this.getDelay = getDelay;\n this.saveDelay = saveDelay;\n this.timeout = to;\n }\n\n add(entity: T, options?: HttpOptions): Observable<T> {\n const entityOrError =\n entity || new Error(`No \"${this.entityName}\" entity to add`);\n return this.execute('POST', this.entityUrl, entityOrError, null, options);\n }\n\n delete(\n key: number | string,\n options?: HttpOptions\n ): Observable<number | string> {\n let err: Error | undefined;\n if (key == null) {\n err = new Error(`No \"${this.entityName}\" key to delete`);\n }\n\n return this.execute(\n 'DELETE',\n this.entityUrl + key,\n err,\n null,\n options\n ).pipe(\n // forward the id of deleted entity as the result of the HTTP DELETE\n map((result) => key as number | string)\n );\n }\n\n getAll(options?: HttpOptions): Observable<T[]> {\n return this.execute('GET', this.entitiesUrl, null, null, options);\n }\n\n getById(key: number | string, options?: HttpOptions): Observable<T> {\n let err: Error | undefined;\n if (key == null) {\n err = new Error(`No \"${this.entityName}\" key to get`);\n }\n return this.execute('GET', this.entityUrl + key, err, null, options);\n }\n\n getWithQuery(\n queryParams: QueryParams | string | undefined,\n options?: HttpOptions\n ): Observable<T[]> {\n const qParams =\n typeof queryParams === 'string'\n ? { fromString: queryParams }\n : { fromObject: queryParams };\n const params = new HttpParams(qParams);\n\n return this.execute(\n 'GET',\n this.entitiesUrl,\n undefined,\n { params },\n options\n );\n }\n\n update(update: Update<T>, options?: HttpOptions): Observable<T> {\n const id = update && update.id;\n const updateOrError =\n id == null\n ? new Error(`No \"${this.entityName}\" update data or id`)\n : update.changes;\n return this.execute(\n 'PUT',\n this.entityUrl + id,\n updateOrError,\n null,\n options\n );\n }\n\n // Important! Only call if the backend service supports upserts as a POST to the target URL\n upsert(entity: T, options?: HttpOptions): Observable<T> {\n const entityOrError =\n entity || new Error(`No \"${this.entityName}\" entity to upsert`);\n return this.execute('POST', this.entityUrl, entityOrError, null, options);\n }\n\n protected execute(\n method: HttpMethods,\n url: string,\n data?: any, // data, error, or undefined/null\n options?: any, // options or undefined/null\n httpOptions?: HttpOptions // these override any options passed via options\n ): Observable<any> {\n let entityActionHttpClientOptions: any = undefined;\n if (httpOptions) {\n entityActionHttpClientOptions = {\n headers: httpOptions?.httpHeaders\n ? new HttpHeaders(httpOptions?.httpHeaders)\n : undefined,\n params: httpOptions?.httpParams\n ? new HttpParams(httpOptions?.httpParams)\n : undefined,\n };\n }\n\n // Now we may have:\n // options: containing headers, params, or any other allowed http options already in angular's api\n // entityActionHttpClientOptions: headers and params in angular's api\n\n // We therefore need to merge these so that the action ones override the\n // existing keys where applicable.\n\n // If any options have been specified, pass them to http client. Note\n // the new http options, if specified, will override any options passed\n // from the deprecated options parameter\n let mergedOptions: any = undefined;\n if (options || entityActionHttpClientOptions) {\n if (isDevMode() && options && entityActionHttpClientOptions) {\n console.warn(\n '@ngrx/data: options.httpParams will be merged with queryParams when both are are provided to getWithQuery(). In the event of a conflict HttpOptions.httpParams will override queryParams`. The queryParams parameter of getWithQuery() will be removed in next major release.'\n );\n }\n\n mergedOptions = {\n ...options,\n headers: entityActionHttpClientOptions?.headers ?? options?.headers,\n params: entityActionHttpClientOptions?.params ?? options?.params,\n };\n }\n\n const req: RequestData = {\n method,\n url,\n data,\n options: mergedOptions,\n };\n\n if (data instanceof Error) {\n return this.handleError(req)(data);\n }\n\n let result$: Observable<ArrayBuffer>;\n\n switch (method) {\n case 'DELETE': {\n result$ = this.http.delete(url, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n case 'GET': {\n result$ = this.http.get(url, mergedOptions);\n if (this.getDelay) {\n result$ = result$.pipe(delay(this.getDelay));\n }\n break;\n }\n case 'POST': {\n result$ = this.http.post(url, data, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n // N.B.: It must return an Update<T>\n case 'PUT': {\n result$ = this.http.put(url, data, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n default: {\n const error = new Error('Unimplemented HTTP method, ' + method);\n result$ = throwError(error);\n }\n }\n if (this.timeout) {\n result$ = result$.pipe(timeout(this.timeout + this.saveDelay));\n }\n return result$.pipe(catchError(this.handleError(req)));\n }\n\n private handleError(reqData: RequestData) {\n return (err: any) => {\n const ok = this.handleDelete404(err, reqData);\n if (ok) {\n return ok;\n }\n const error = new DataServiceError(err, reqData);\n return throwError(error);\n };\n }\n\n private handleDelete404(error: HttpErrorResponse, reqData: RequestData) {\n if (\n error.status === 404 &&\n reqData.method === 'DELETE' &&\n this.delete404OK\n ) {\n return of({});\n }\n return undefined;\n }\n}\n\n/**\n * Create a basic, generic entity data service\n * suitable for persistence of most entities.\n * Assumes a common REST-y web API\n */\n@Injectable()\nexport class DefaultDataServiceFactory {\n constructor(\n protected http: HttpClient,\n protected httpUrlGenerator: HttpUrlGenerator,\n @Optional() protected config?: DefaultDataServiceConfig\n ) {\n config = config || {};\n httpUrlGenerator.registerHttpResourceUrls(config.entityHttpResourceUrls);\n }\n\n /**\n * Create a default {EntityCollectionDataService} for the given entity type\n * @param entityName {string} Name of the entity type for this data service\n */\n create<T>(entityName: string): EntityCollectionDataService<T> {\n return new DefaultDataService<T>(\n entityName,\n this.http,\n this.httpUrlGenerator,\n this.config\n );\n }\n}\n","import { EntityAdapter, createEntityAdapter } from '@ngrx/entity';\nimport { Comparer, IdSelector } from '@ngrx/entity';\n\nimport { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher-default-options';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityCollection } from '../reducers/entity-collection';\nimport { EntityMetadata } from './entity-metadata';\n\nexport interface EntityDefinition<T = any> {\n entityName: string;\n entityAdapter: EntityAdapter<T>;\n entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;\n initialState: EntityCollection<T>;\n metadata: EntityMetadata<T>;\n noChangeTracking: boolean;\n selectId: IdSelector<T>;\n sortComparer: false | Comparer<T>;\n}\n\nexport function createEntityDefinition<T, S extends object>(\n metadata: EntityMetadata<T, S>\n): EntityDefinition<T> {\n let entityName = metadata.entityName;\n if (!entityName) {\n throw new Error('Missing required entityName');\n }\n metadata.entityName = entityName = entityName.trim();\n const selectId = metadata.selectId || defaultSelectId;\n const sortComparer = (metadata.sortComparer = metadata.sortComparer || false);\n\n const entityAdapter = createEntityAdapter<T>({ selectId, sortComparer });\n\n const entityDispatcherOptions: Partial<EntityDispatcherDefaultOptions> =\n metadata.entityDispatcherOptions || {};\n\n const initialState: EntityCollection<T> = entityAdapter.getInitialState({\n entityName,\n filter: '',\n loaded: false,\n loading: false,\n changeState: {},\n ...(metadata.additionalCollectionState || {}),\n });\n\n const noChangeTracking = metadata.noChangeTracking === true; // false by default\n\n return {\n entityName,\n entityAdapter,\n entityDispatcherOptions,\n initialState,\n metadata,\n noChangeTracking,\n selectId,\n sortComparer,\n };\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { IdSelector, Comparer } from '@ngrx/entity';\n\nimport { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher-default-options';\nimport { EntityFilterFn } from './entity-filters';\n\nexport const ENTITY_METADATA_TOKEN = new InjectionToken<EntityMetadataMap>(\n '@ngrx/data Entity Metadata'\n);\n\n/** Metadata that describe an entity type and its collection to @ngrx/data */\nexport interface EntityMetadata<T = any, S extends object = {}> {\n entityName: string;\n entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;\n filterFn?: EntityFilterFn<T>;\n noChangeTracking?: boolean;\n selectId?: IdSelector<T>;\n sortComparer?: false | Comparer<T>;\n additionalCollectionState?: S;\n}\n\n/** Map entity-type name to its EntityMetadata */\nexport interface EntityMetadataMap {\n [entityName: string]: Partial<EntityMetadata<any>>;\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { createEntityDefinition, EntityDefinition } from './entity-definition';\nimport {\n EntityMetadata,\n EntityMetadataMap,\n ENTITY_METADATA_TOKEN,\n} from './entity-metadata';\n\nexport interface EntityDefinitions {\n [entityName: string]: EntityDefinition<any>;\n}\n\n/** Registry of EntityDefinitions for all cached entity types */\n@Injectable()\nexport class EntityDefinitionService {\n /** {EntityDefinition} for all cached entity types */\n private readonly definitions: EntityDefinitions = {};\n\n constructor(\n @Optional()\n @Inject(ENTITY_METADATA_TOKEN)\n entityMetadataMaps: EntityMetadataMap[]\n ) {\n if (entityMetadataMaps) {\n entityMetadataMaps.forEach((map) => this.registerMetadataMap(map));\n }\n }\n\n /**\n * Get (or create) a data service for entity type\n * @param entityName - the name of the type\n *\n * Examples:\n * getDefinition('Hero'); // definition for Heroes, untyped\n * getDefinition<Hero>(`Hero`); // definition for Heroes, typed with Hero interface\n */\n getDefinition<T>(\n entityName: string,\n shouldThrow = true\n ): EntityDefinition<T> {\n entityName = entityName.trim();\n const definition = this.definitions[entityName];\n if (!definition && shouldThrow) {\n throw new Error(`No EntityDefinition for entity type \"${entityName}\".`);\n }\n return definition;\n }\n\n //////// Registration methods //////////\n\n /**\n * Create and register the {EntityDefinition} for the {EntityMetadata} of an entity type\n * @param name - the name of the entity type\n * @param definition - {EntityMetadata} for a collection for that entity type\n *\n * Examples:\n * registerMetadata(myHeroEntityDefinition);\n */\n registerMetadata(metadata: EntityMetadata) {\n if (metadata) {\n const definition = createEntityDefinition(metadata);\n this.registerDefinition(definition);\n }\n }\n\n /**\n * Register an EntityMetadataMap.\n * @param metadataMap - a map of entityType names to entity metadata\n *\n * Examples:\n * registerMetadataMap({\n * 'Hero': myHeroMetadata,\n * Villain: myVillainMetadata\n * });\n */\n registerMetadataMap(metadataMap: EntityMetadataMap = {}) {\n // The entity type name should be the same as the map key\n Object.keys(metadataMap || {}).forEach((entityName) =>\n this.registerMetadata({ entityName, ...metadataMap[entityName] })\n );\n }\n\n /**\n * Register an {EntityDefinition} for an entity type\n * @param definition - EntityDefinition of a collection for that entity type\n *\n * Examples:\n * registerDefinition('Hero', myHeroEntityDefinition);\n */\n registerDefinition<T>(definition: EntityDefinition<T>) {\n this.definitions[definition.entityName] = definition;\n }\n\n /**\n * Register a batch of EntityDefinitions.\n * @param definitions - map of entityType name and associated EntityDefinitions to merge.\n *\n * Examples:\n * registerDefinitions({\n * 'Hero': myHeroEntityDefinition,\n * Villain: myVillainEntityDefinition\n * });\n */\n registerDefinitions(definitions: EntityDefinitions) {\n Object.assign(this.definitions, definitions);\n }\n}\n","import { Injectable, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\n\nimport { Observable, throwError } from 'rxjs';\nimport { catchError, delay, map, timeout } from 'rxjs/operators';\n\nimport { IdSelector } from '@ngrx/entity';\n\nimport {\n ChangeSetOperation,\n ChangeSet,\n ChangeSetItem,\n ChangeSetUpdate,\n excludeEmptyChangeSetItems,\n} from '../actions/entity-cache-change-set';\nimport { DataServiceError } from './data-service-error';\nimport { DefaultDataServiceConfig } from './default-data-service-config';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport { RequestData } from './interfaces';\n\nconst updateOp = ChangeSetOperation.Update;\n\n/**\n * Default data service for making remote service calls targeting the entire EntityCache.\n * See EntityDataService for services that target a single EntityCollection\n */\n@Injectable()\nexport class EntityCacheDataService {\n protected idSelectors: { [entityName: string]: IdSelector<any> } = {};\n protected saveDelay = 0;\n protected timeout = 0;\n\n constructor(\n protected entityDefinitionService: EntityDefinitionService,\n protected http: HttpClient,\n @Optional() config?: DefaultDataServiceConfig\n ) {\n const { saveDelay = 0, timeout: to = 0 } = config || {};\n this.saveDelay = saveDelay;\n this.timeout = to;\n }\n\n /**\n * Save changes to multiple entities across one or more entity collections.\n * Server endpoint must understand the essential SaveEntities protocol,\n * in particular the ChangeSet interface (except for Update<T>).\n * This implementation extracts the entity changes from a ChangeSet Update<T>[] and sends those.\n * It then reconstructs Update<T>[] in the returned observable result.\n * @param changeSet An array of SaveEntityItems.\n * Each SaveEntityItem describe a change operation for one or more entities of a single collection,\n * known by its 'entityName'.\n * @param url The server endpoint that receives this request.\n */\n saveEntities(changeSet: ChangeSet, url: string): Observable<ChangeSet> {\n changeSet = this.filterChangeSet(changeSet);\n // Assume server doesn't understand @ngrx/entity Update<T> structure;\n // Extract the entity changes from the Update<T>[] and restore on the return from server\n changeSet = this.flattenUpdates(changeSet);\n\n let result$: Observable<ChangeSet> = this.http\n .post<ChangeSet>(url, changeSet)\n .pipe(\n map((result) => this.restoreUpdates(result)),\n catchError(this.handleError({ method: 'POST', url, data: changeSet }))\n );\n\n if (this.timeout) {\n result$ = result$.pipe(timeout(this.timeout));\n }\n\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n\n return result$;\n }\n\n // #region helpers\n protected handleError(reqData: RequestData) {\n return (err: any) => {\n const error = new DataServiceError(err, reqData);\n return throwError(error);\n };\n }\n\n /**\n * Filter changeSet to remove unwanted ChangeSetItems.\n * This implementation excludes null and empty ChangeSetItems.\n * @param changeSet ChangeSet with changes to filter\n */\n protected filterChangeSet(changeSet: ChangeSet): ChangeSet {\n return excludeEmptyChangeSetItems(changeSet);\n }\n\n /**\n * Convert the entities in update changes from @ngrx Update<T> structure to just T.\n * Reverse of restoreUpdates().\n */\n protected flattenUpdates(changeSet: ChangeSet): ChangeSet {\n let changes = changeSet.changes;\n if (changes.length === 0) {\n return changeSet;\n }\n let hasMutated = false;\n changes = changes.map((item) => {\n if (item.op === updateOp && item.entities.length > 0) {\n hasMutated = true;\n return {\n ...item,\n entities: (item as ChangeSetUpdate).entities.map((u) => u.changes),\n };\n } else {\n return item;\n }\n }) as ChangeSetItem[];\n return hasMutated ? { ...changeSet, changes } : changeSet;\n }\n\n /**\n * Convert the flattened T entities in update changes back to @ngrx Update<T> structures.\n * Reverse of flattenUpdates().\n */\n protected restoreUpdates(changeSet: ChangeSet): ChangeSet {\n if (changeSet == null) {\n // Nothing? Server probably responded with 204 - No Content because it made no changes to the inserted or updated entities\n return changeSet;\n }\n let changes = changeSet.changes;\n if (changes.length === 0) {\n return changeSet;\n }\n let hasMutated = false;\n changes = changes.map((item) => {\n if (item.op === updateOp) {\n // These are entities, not Updates; convert back to Updates\n hasMutated = true;\n const selectId = this.getIdSelector(item.entityName);\n return {\n ...item,\n entities: item.entities.map((u: any) => ({\n id: selectId(u),\n changes: u,\n })),\n } as ChangeSetUpdate;\n } else {\n return item;\n }\n }) as ChangeSetItem[];\n return hasMutated ? { ...changeSet, changes } : changeSet;\n }\n\n /**\n * Get the id (primary key) selector function for an entity type\n * @param entityName name of the entity type\n */\n protected getIdSelector(entityName: string) {\n let idSelector = this.idSelectors[entityName];\n if (!idSelector) {\n idSelector =\n this.entityDefinitionService.getDefinition(entityName).selectId;\n this.idSelectors[entityName] = idSelector;\n }\n return idSelector;\n }\n // #endregion helpers\n}\n","import { Injectable } from '@angular/core';\n\nimport { EntityCollectionDataService } from './interfaces';\nimport { DefaultDataServiceFactory } from './default-data.service';\n\n/**\n * Registry of EntityCollection data services that make REST-like CRUD calls\n * to entity collection endpoints.\n */\n@Injectable()\nexport class EntityDataService {\n protected services: { [name: string]: EntityCollectionDataService<any> } = {};\n\n // TODO: Optionally inject specialized entity data services\n // for those that aren't derived from BaseDataService.\n constructor(protected defaultDataServiceFactory: DefaultDataServiceFactory) {}\n\n /**\n * Get (or create) a data service for entity type\n * @param entityName - the name of the type\n *\n * Examples:\n * getService('Hero'); // data service for Heroes, untyped\n * getService<Hero>('Hero'); // data service for Heroes, typed as Hero\n */\n getService<T>(entityName: string): EntityCollectionDataService<T> {\n entityName = entityName.trim();\n let service = this.services[entityName];\n if (!service) {\n service = this.defaultDataServiceFactory.create(entityName);\n this.services[entityName] = service;\n }\n return service;\n }\n\n /**\n * Register an EntityCollectionDataService for an entity type\n * @param entityName - the name of the entity type\n * @param service - data service for that entity type\n *\n * Examples:\n * registerService('Hero', myHeroDataService);\n * registerService('Villain', myVillainDataService);\n */\n registerService<T>(\n entityName: string,\n service: EntityCollectionDataService<T>\n ) {\n this.services[entityName.trim()] = service;\n }\n\n /**\n * Register a batch of data services.\n * @param services - data services to merge into existing services\n *\n * Examples:\n * registerServices({\n * Hero: myHeroDataService,\n * Villain: myVillainDataService\n * });\n */\n registerServices(services: {\n [name: string]: EntityCollectionDataService<any>;\n }) {\n this.services = { ...this.services, ...services };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action } from '@ngrx/store';\n\nimport {\n DataServiceError,\n EntityActionDataServiceError,\n} from './data-service-error';\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { makeErrorOp, makeSuccessOp } from '../actions/entity-op';\nimport { Logger } from '../utils/interfaces';\n\n/**\n * Handling of responses from persistence operation\n */\nexport abstract class PersistenceResultHandler {\n /** Handle successful result of persistence operation for an action */\n abstract handleSuccess(originalAction: EntityAction): (data: any) => Action;\n\n /** Handle error result of persistence operation for an action */\n abstract handleError(\n originalAction: EntityAction\n ): (\n error: DataServiceError | Error\n ) => EntityAction<EntityActionDataServiceError>;\n}\n\n/**\n * Default handling of responses from persistence operation,\n * specifically an EntityDataService\n */\n@Injectable()\nexport class DefaultPersistenceResultHandler\n implements PersistenceResultHandler\n{\n constructor(\n private logger: Logger,\n private entityActionFactory: EntityActionFactory\n ) {}\n\n /** Handle successful result of persistence operation on an EntityAction */\n handleSuccess(originalAction: EntityAction): (data: any) => Action {\n const successOp = makeSuccessOp(originalAction.payload.entityOp);\n return (data: any) =>\n this.entityActionFactory.createFromAction(originalAction, {\n entityOp: successOp,\n data,\n });\n }\n\n /** Handle error result of persistence operation on an EntityAction */\n handleError(\n originalAction: EntityAction\n ): (\n error: DataServiceError | Error\n ) => EntityAction<EntityActionDataServiceError> {\n const errorOp = makeErrorOp(originalAction.payload.entityOp);\n\n return (err: DataServiceError | Error) => {\n const error =\n err instanceof DataServiceError ? err : new DataServiceError(err, null);\n const errorData: EntityActionDataServiceError = { error, originalAction };\n this.logger.error(errorData);\n const action =\n this.entityActionFactory.createFromAction<EntityActionDataServiceError>(\n originalAction,\n {\n entityOp: errorOp,\n data: errorData,\n }\n );\n return action;\n };\n }\n}\n","import { Action, Store } from '@ngrx/store';\nimport { IdSelector, Update } from '@ngrx/entity';\n\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityCommands } from './entity-commands';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityOp } from '../actions/entity-op';\n\n/**\n * Dispatches EntityCollection actions to their reducers and effects.\n * The substance of the interface is in EntityCommands.\n */\nexport interface EntityDispatcher<T> extends EntityCommands<T> {\n /** Name of the entity type */\n readonly entityName: string;\n\n /**\n * Utility class with methods to validate EntityAction payloads.\n */\n readonly guard: EntityActionGuard<T>;\n\n /** Returns the primary key (id) of this entity */\n readonly selectId: IdSelector<T>;\n\n /** Returns the store, scoped to the EntityCache */\n readonly store: Store<EntityCache>;\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate(entity: Partial<T>): Update<T>;\n}\n\n/**\n * Persistence operation canceled\n */\nexport class PersistanceCanceled {\n constructor(public readonly message?: string) {\n this.message = message || 'Canceled by user';\n }\n}\n","import { Injectable } from '@angular/core';\n\n/**\n * Generates a string id beginning 'CRID',\n * followed by a monotonically increasing integer for use as a correlation id.\n * As they are produced locally by a singleton service,\n * these ids are guaranteed to be unique only\n * for the duration of a single client browser instance.\n * Ngrx entity dispatcher query and save methods call this service to generate default correlation ids.\n * Do NOT use for entity keys.\n */\n@Injectable()\nexport class CorrelationIdGenerator {\n /** Seed for the ids */\n protected seed = 0;\n /** Prefix of the id, 'CRID; */\n protected prefix = 'CRID';\n /** Return the next correlation id */\n next() {\n this.seed += 1;\n return this.prefix + this.seed;\n }\n}\n","import { Injectable } from '@angular/core';\n/**\n * Default options for EntityDispatcher behavior\n * such as whether `add()` is optimistic or pessimistic by default.\n * An optimistic save modifies the collection immediately and before saving to the server.\n * A pessimistic save modifies the collection after the server confirms the save was successful.\n * This class initializes the defaults to the safest values.\n * Provide an alternative to change the defaults for all entity collections.\n */\n@Injectable()\nexport class EntityDispatcherDefaultOptions {\n /** True if added entities are saved optimistically; false if saved pessimistically. */\n optimisticAdd = false;\n /** True if deleted entities are saved optimistically; false if saved pessimistically. */\n optimisticDelete = true;\n /** True if updated entities are saved optimistically; false if saved pessimistically. */\n optimisticUpdate = false;\n /** True if upsert entities are saved optimistically; false if saved pessimistically. */\n optimisticUpsert = false;\n /** True if entities in a cache saveEntities request are saved optimistically; false if saved pessimistically. */\n optimisticSaveEntities = false;\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Action, ScannedActionsSubject, Store } from '@ngrx/store';\n\nimport { Observable, of, Subscription, throwError } from 'rxjs';\nimport { filter, mergeMap, shareReplay, take } from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { EntityActionOptions } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\n\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { PersistanceCanceled } from './entity-dispatcher';\n\nimport { ChangeSet, ChangeSetItem } from '../actions/entity-cache-change-set';\nimport {\n ClearCollections,\n EntityCacheAction,\n EntityCacheQuerySet,\n LoadCollections,\n MergeQuerySet,\n SetEntityCache,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\n\n/**\n * Dispatches Entity Cache actions to the EntityCache reducer\n */\n@Injectable()\nexport class EntityCacheDispatcher {\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n reducedActions$: Observable<Action>;\n private raSubscription: Subscription;\n\n constructor(\n /** Generates correlation ids for query and save methods */\n private correlationIdGenerator: CorrelationIdGenerator,\n /**\n * Dispatcher options configure dispatcher behavior such as\n * whether add is optimistic or pessimistic by default.\n */\n private defaultDispatcherOptions: EntityDispatcherDefaultOptions,\n /** Actions scanned by the store after it processed them with reducers. */\n @Inject(ScannedActionsSubject) scannedActions$: Observable<Action>,\n /** The store, scoped to the EntityCache */\n private store: Store<EntityCache>\n ) {\n // Replay because sometimes in tests will fake data service with synchronous observable\n // which makes subscriber miss the dispatched actions.\n // Of course that's a testing mistake. But easy to forget, leading to painful debugging.\n this.reducedActions$ = scannedActions$.pipe(shareReplay(1));\n // Start listening so late subscriber won't miss the most recent action.\n this.raSubscription = this.reducedActions$.subscribe();\n }\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n this.store.dispatch(action);\n return action;\n }\n\n /**\n * Dispatch action to cancel the saveEntities request with matching correlation id.\n * @param correlationId The correlation id for the corresponding action\n * @param [reason] explains why canceled and by whom.\n * @param [entityNames] array of entity names so can turn off loading flag for their collections.\n * @param [tag] tag to identify the operation from the app perspective.\n */\n cancelSaveEntities(\n correlationId: any,\n reason?: string,\n entityNames?: string[],\n tag?: string\n ): void {\n if (!correlationId) {\n throw new Error('Missing correlationId');\n }\n const action = new SaveEntitiesCancel(\n correlationId,\n reason,\n entityNames,\n tag\n );\n this.dispatch(action);\n }\n\n /** Clear the named entity collections in cache\n * @param [collections] Array of names of the collections to clear.\n * If empty array, does nothing. If null/undefined/no array, clear all collections.\n * @param [tag] tag to identify the operation from the app perspective.\n */\n clearCollections(collections?: string[], tag?: string) {\n this.dispatch(new ClearCollections(collections, tag));\n }\n\n /**\n * Load multiple entity collections at the same time.\n * before any selectors$ observables emit.\n * @param collections The collections to load, typically the result of a query.\n * @param [tag] tag to identify the operation from the app perspective.\n * in the form of a map of entity collections.\n */\n loadCollections(collections: EntityCacheQuerySet, tag?: string) {\n this.dispatch(new LoadCollections(collections, tag));\n }\n\n /**\n * Merges entities from a query result\n * that returned entities from multiple collections.\n * Corresponding entity cache reducer should add and update all collections\n * at the same time, before any selectors$ observables emit.\n * @param querySet The result of the query in the form of a map of entity collections.\n * These are the entity data to merge into the respective collections.\n * @param mergeStrategy How to merge a queried entity when it is already in the collection.\n * The default is MergeStrategy.PreserveChanges\n * @param [tag] tag to identify the operation from the app perspective.\n */\n mergeQuerySet(\n querySet: EntityCacheQuerySet,\n mergeStrategy?: MergeStrategy,\n tag?: string\n ) {\n this.dispatch(new MergeQuerySet(querySet, mergeStrategy, tag));\n }\n\n /**\n * Create entity cache action for replacing the entire entity cache.\n * Dangerous because brute force but useful as when re-hydrating an EntityCache\n * from local browser storage when the application launches.\n * @param cache New state of the entity cache\n * @param [tag] tag to identify the operation from the app perspective.\n */\n setEntityCache(cache: EntityCache, tag?: string) {\n this.dispatch(new SetEntityCache(cache, tag));\n }\n\n /**\n * Dispatch action to save multiple entity changes to remote storage.\n * Relies on an Ngrx Effect such as EntityEffects.saveEntities$.\n * Important: only call if your server supports the SaveEntities protocol\n * through your EntityDataService.saveEntities method.\n * @param changes Either the entities to save, as an array of {ChangeSetItem}, or\n * a ChangeSet that holds such changes.\n * @param url The server url which receives the save request\n * @param [options] options such as tag, correlationId, isOptimistic, and mergeStrategy.\n * These values are defaulted if not supplied.\n * @returns A terminating Observable<ChangeSet> with data returned from the server\n * after server reports successful save OR the save error.\n * TODO: should return the matching entities from cache rather than the raw server data.\n */\n saveEntities(\n changes: ChangeSetItem[] | ChangeSet,\n url: string,\n options?: EntityActionOptions\n ): Observable<ChangeSet> {\n const changeSet = Array.isArray(changes) ? { changes } : changes;\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n const isOptimistic =\n options.isOptimistic == null\n ? this.defaultDispatcherOptions.optimisticSaveEntities || false\n : options.isOptimistic === true;\n const tag = options.tag || 'Save Entities';\n options = { ...options, correlationId, isOptimistic, tag };\n const action = new SaveEntities(changeSet, url, options);\n this.dispatch(action);\n return this.getSaveEntitiesResponseData$(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Return Observable of data from the server-success SaveEntities action with\n * the given Correlation Id, after that action was processed by the ngrx store.\n * or else put the server error on the Observable error channel.\n * @param crid The correlationId for both the save and response actions.\n */\n private getSaveEntitiesResponseData$(crid: any): Observable<ChangeSet> {\n /**\n * reducedActions$ must be replay observable of the most recent action reduced by the store.\n * because the response action might have been dispatched to the store\n * before caller had a chance to subscribe.\n */\n return this.reducedActions$.pipe(\n filter(\n (act: Action) =>\n act.type === EntityCacheAction.SAVE_ENTITIES_SUCCESS ||\n act.type === EntityCacheAction.SAVE_ENTITIES_ERROR ||\n act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL\n ),\n filter((act: Action) => crid === (act as any).payload.correlationId),\n take(1),\n mergeMap((act) => {\n return act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL\n ? throwError(\n new PersistanceCanceled(\n (act as SaveEntitiesCancel).payload.reason\n )\n )\n : act.type === EntityCacheAction.SAVE_ENTITIES_SUCCESS\n ? of((act as SaveEntitiesSuccess).payload.changeSet)\n : throwError((act as SaveEntitiesError).payload);\n })\n );\n }\n}\n","import { Action, createSelector, Store } from '@ngrx/store';\nimport { IdSelector, Update } from '@ngrx/entity';\n\nimport { Observable, of, throwError } from 'rxjs';\nimport {\n filter,\n map,\n mergeMap,\n shareReplay,\n withLatestFrom,\n take,\n} from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { defaultSelectId, toUpdateFactory } from '../utils/utilities';\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCacheSelector } from '../selectors/entity-cache-selector';\nimport { EntityCollection } from '../reducers/entity-collection';\nimport { EntityCommands } from './entity-commands';\nimport { EntityDispatcher, PersistanceCanceled } from './entity-dispatcher';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\nimport { EntityOp, OP_ERROR, OP_SUCCESS } from '../actions/entity-op';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { QueryParams } from '../dataservices/interfaces';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Dispatches EntityCollection actions to their reducers and effects (default implementation).\n * All save commands rely on an Ngrx Effect such as `EntityEffects.persist$`.\n */\nexport class EntityDispatcherBase<T> implements EntityDispatcher<T> {\n /** Utility class with methods to validate EntityAction payloads.*/\n guard: EntityActionGuard<T>;\n\n private entityCollection$: Observable<EntityCollection<T>>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate: (entity: Partial<T>) => Update<T>;\n\n constructor(\n /** Name of the entity type for which entities are dispatched */\n public entityName: string,\n /** Creates an {EntityAction} */\n public entityActionFactory: EntityActionFactory,\n /** The store, scoped to the EntityCache */\n public store: Store<EntityCache>,\n /** Returns the primary key (id) of this entity */\n public selectId: IdSelector<T> = defaultSelectId,\n /**\n * Dispatcher options configure dispatcher behavior such as\n * whether add is optimistic or pessimistic by default.\n */\n private defaultDispatcherOptions: EntityDispatcherDefaultOptions,\n /** Actions scanned by the store after it processed them with reducers. */\n private reducedActions$: Observable<Action>,\n /** Store selector for the EntityCache */\n entityCacheSelector: EntityCacheSelector,\n /** Generates correlation ids for query and save methods */\n private correlationIdGenerator: CorrelationIdGenerator\n ) {\n this.guard = new EntityActionGuard(entityName, selectId);\n this.toUpdate = toUpdateFactory<T>(selectId);\n\n const collectionSelector = createSelector(\n entityCacheSelector,\n (cache) => cache[entityName] as EntityCollection<T>\n );\n this.entityCollection$ = store.select(collectionSelector);\n }\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param entityOp {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n entityOp: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.entityActionFactory.create({\n entityName: this.entityName,\n entityOp,\n data,\n ...options,\n });\n }\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n const action = this.createEntityAction(op, data, options);\n this.dispatch(action);\n return action;\n }\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n this.store.dispatch(action);\n return action;\n }\n\n // #region Query and save operations\n\n /**\n * Dispatch action to save a new entity to remote storage.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @returns A terminating Observable of the entity\n * after server reports successful save or the save error.\n */\n add(entity: T, options?: EntityActionOptions): Observable<T> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticAdd\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_ADD_ONE,\n entity,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeEntity(action);\n }\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e)]!),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to cancel the persistence operation (query or save).\n * Will cause save observable to error with a PersistenceCancel error.\n * Caller is responsible for undoing changes in cache from pending optimistic save\n * @param correlationId The correlation id for the corresponding EntityAction\n * @param [reason] explains why canceled and by whom.\n */\n cancel(\n correlationId: any,\n reason?: string,\n options?: EntityActionOptions\n ): void {\n if (!correlationId) {\n throw new Error('Missing correlationId');\n }\n this.createAndDispatch(EntityOp.CANCEL_PERSIST, reason, { correlationId });\n }\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The primary key of the entity to remove\n * @returns A terminating Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(entity: T, options?: EntityActionOptions): Observable<number | string>;\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The entity to delete\n * @returns A terminating Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(\n key: number | string,\n options?: EntityActionOptions\n ): Observable<number | string>;\n delete(\n arg: number | string | T,\n options?: EntityActionOptions\n ): Observable<number | string> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticDelete\n );\n const key = this.getKey(arg);\n const action = this.createEntityAction(\n EntityOp.SAVE_DELETE_ONE,\n key,\n options\n );\n this.guard.mustBeKey(action);\n this.dispatch(action);\n return this.getResponseData$<number | string>(options.correlationId).pipe(\n map(() => key),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * merge the queried entities into the cached collection.\n * @returns A terminating Observable of the queried entities that are in the collection\n * after server reports success query or the query error.\n * @see load()\n */\n getAll(options?: EntityActionOptions): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_ALL, null, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n // Use the returned entity ids to get the entities from the collection\n // as they might be different from the entities returned from the server\n // because of unsaved changes (deletes or updates).\n withLatestFrom(this.entityCollection$),\n map(([entities, collection]) =>\n entities.reduce((acc, e) => {\n const entity = collection.entities[this.selectId(e)];\n if (entity) {\n acc.push(entity); // only return an entity found in the collection\n }\n return acc;\n }, [] as T[])\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entity with this primary key.\n * If the server returns an entity,\n * merge it into the cached collection.\n * @returns A terminating Observable of the collection\n * after server reports successful query or the query error.\n */\n getByKey(key: any, options?: EntityActionOptions): Observable<T> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_BY_KEY, key, options);\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(\n ([entity, collection]) => collection.entities[this.selectId(entity)]!\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and merge the results into the cached collection.\n * @param queryParams the query in a form understood by the server\n * @returns A terminating Observable of the queried entities\n * after server reports successful query or the query error.\n */\n getWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(\n EntityOp.QUERY_MANY,\n queryParams,\n options\n );\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n // Use the returned entity ids to get the entities from the collection\n // as they might be different from the entities returned from the server\n // because of unsaved changes (deletes or updates).\n withLatestFrom(this.entityCollection$),\n map(([entities, collection]) =>\n entities.reduce((acc, e) => {\n const entity = collection.entities[this.selectId(e)];\n if (entity) {\n acc.push(entity); // only return an entity found in the collection\n }\n return acc;\n }, [] as T[])\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * completely replace the cached collection with the queried entities.\n * @returns A terminating Observable of the entities in the collection\n * after server reports successful query or the query error.\n * @see getAll\n */\n load(options?: EntityActionOptions): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_LOAD, null, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and completely replace the cached collection with the queried entities.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence load behavior\n * @returns A terminating Observable of the queried entities\n * after server reports successful query or the query error.\n */\n loadWithQuery(queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_MANY, queryParams, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to save the updated entity (or partial entity) in remote storage.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity update entity, which might be a partial of T but must at least have its key.\n * @returns A terminating Observable of the updated entity\n * after server reports successful save or the save error.\n */\n update(entity: Partial<T>, options?: EntityActionOptions): Observable<T> {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n const update = this.toUpdate(entity);\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticUpdate\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_UPDATE_ONE,\n update,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeUpdate(action);\n }\n this.dispatch(action);\n return this.getResponseData$<UpdateResponseData<T>>(\n options.correlationId\n ).pipe(\n // Use the update entity data id to get the entity from the collection\n // as might be different from the entity returned from the server\n // because the id changed or there are unsaved changes.\n map((updateData) => updateData.changes),\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e as T)]!),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to save a new or existing entity to remote storage.\n * Only dispatch this action if your server supports upsert.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @returns A terminating Observable of the entity\n * after server reports successful save or the save error.\n */\n upsert(entity: T, options?: EntityActionOptions): Observable<T> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticUpsert\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_UPSERT_ONE,\n entity,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeEntity(action);\n }\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e)]!),\n shareReplay(1)\n );\n }\n // #endregion Query and save operations\n\n // #region Cache-only operations that do not update remote storage\n\n // Unguarded for performance.\n // EntityCollectionReducer<T> runs a guard (which throws)\n // Developer should understand cache-only methods well enough\n // to call them with the proper entities.\n // May reconsider and add guards in future.\n\n /**\n * Replace all entities in the cached collection.\n * Does not save to remote storage.\n */\n addAllToCache(entities: T[], options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_ALL, entities, options);\n }\n\n /**\n * Add a new entity directly to the cache.\n * Does not save to remote storage.\n * Ignored if an entity with the same primary key is already in cache.\n */\n addOneToCache(entity: T, options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_ONE, entity, options);\n }\n\n /**\n * Add multiple new entities directly to the cache.\n * Does not save to remote storage.\n * Entities with primary keys already in cache are ignored.\n */\n addManyToCache(entities: T[], options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_MANY, entities, options);\n }\n\n /** Clear the cached entity collection */\n clearCache(options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.REMOVE_ALL, undefined, options);\n }\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param entity The entity to remove\n */\n removeOneFromCache(entity: T, options?: EntityActionOptions): void;\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param key The primary key of the entity to remove\n */\n removeOneFromCache(key: number | string, options?: EntityActionOptions): void;\n removeOneFromCache(\n arg: (number | string) | T,\n options?: EntityActionOptions\n ): void {\n this.createAndDispatch(EntityOp.REMOVE_ONE, this.getKey(arg), options);\n }\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param entity The entities to remove\n */\n removeManyFromCache(entities: T[], options?: EntityActionOptions): void;\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param keys The primary keys of the entities to remove\n */\n removeManyFromCache(\n keys: (number | string)[],\n options?: EntityActionOptions\n ): void;\n removeManyFromCache(\n args: (number | string)[] | T[],\n options?: EntityActionOptions\n ): void {\n if (!args || args.length === 0) {\n return;\n }\n const keys =\n typeof args[0] === 'object'\n ? // if array[0] is a key, assume they're all keys\n (<T[]>args).map((arg) => this.getKey(arg))\n : args;\n this.createAndDispatch(EntityOp.REMOVE_MANY, keys, options);\n }\n\n /**\n * Update a cached entity directly.\n * Does not update that entity in remote storage.\n * Ignored if an entity with matching primary key is not in cache.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n */\n updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n const update: Update<T> = this.toUpdate(entity);\n this.createAndDispatch(EntityOp.UPDATE_ONE, update, options);\n }\n\n /**\n * Update multiple cached entities directly.\n * Does not update these entities in remote storage.\n * Entities whose primary keys are not in cache are ignored.\n * Update entities may be partial but must at least have their keys.\n * such partial entities patch their cached counterparts.\n */\n updateManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n if (!entities || entities.length === 0) {\n return;\n }\n const updates: Update<T>[] = entities.map((entity) =>\n this.toUpdate(entity)\n );\n this.createAndDispatch(EntityOp.UPDATE_MANY, updates, options);\n }\n\n /**\n * Add or update a new entity directly to the cache.\n * Does not save to remote storage.\n * Upsert entity might be a partial of T but must at least have its key.\n * Pass the Update<T> structure as the payload\n */\n upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.UPSERT_ONE, entity, options);\n }\n\n /**\n * Add or update multiple cached entities directly.\n * Does not save to remote storage.\n */\n upsertManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n if (!entities || entities.length === 0) {\n return;\n }\n this.createAndDispatch(EntityOp.UPSERT_MANY, entities, options);\n }\n\n /**\n * Set the pattern that the collection's filter applies\n * when using the `filteredEntities` selector.\n */\n setFilter(pattern: any): void {\n this.createAndDispatch(EntityOp.SET_FILTER, pattern);\n }\n\n /** Set the loaded flag */\n setLoaded(isLoaded: boolean): void {\n this.createAndDispatch(EntityOp.SET_LOADED, !!isLoaded);\n }\n\n /** Set the loading flag */\n setLoading(isLoading: boolean): void {\n this.createAndDispatch(EntityOp.SET_LOADING, !!isLoading);\n }\n // #endregion Cache-only operations that do not update remote storage\n\n // #region private helpers\n\n /** Get key from entity (unless arg is already a key) */\n private getKey(arg: number | string | T) {\n return typeof arg === 'object'\n ? this.selectId(arg)\n : (arg as number | string);\n }\n\n /**\n * Return Observable of data from the server-success EntityAction with\n * the given Correlation Id, after that action was processed by the ngrx store.\n * or else put the server error on the Observable error channel.\n * @param crid The correlationId for both the save and response actions.\n */\n private getResponseData$<D = any>(crid: any): Observable<D> {\n /**\n * reducedActions$ must be replay observable of the most recent action reduced by the store.\n * because the response action might have been dispatched to the store\n * before caller had a chance to subscribe.\n */\n return this.reducedActions$.pipe(\n filter((act: any) => !!act.payload),\n filter((act: EntityAction) => {\n const { correlationId, entityName, entityOp } = act.payload;\n return (\n entityName === this.entityName &&\n correlationId === crid &&\n (entityOp.endsWith(OP_SUCCESS) ||\n entityOp.endsWith(OP_ERROR) ||\n entityOp === EntityOp.CANCEL_PERSIST)\n );\n }),\n take(1),\n mergeMap((act) => {\n const { entityOp } = act.payload;\n return entityOp === EntityOp.CANCEL_PERSIST\n ? throwError(new PersistanceCanceled(act.payload.data))\n : entityOp.endsWith(OP_SUCCESS)\n ? of(act.payload.data as D)\n : throwError(act.payload.data.error);\n })\n );\n }\n\n private setQueryEntityActionOptions(\n options?: EntityActionOptions\n ): EntityActionOptions {\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n return { ...options, correlationId };\n }\n\n private setSaveEntityActionOptions(\n options?: EntityActionOptions,\n defaultOptimism?: boolean\n ): EntityActionOptions {\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n const isOptimistic =\n options.isOptimistic == null\n ? defaultOptimism || false\n : options.isOptimistic === true;\n return { ...options, correlationId, isOptimistic };\n }\n // #endregion private helpers\n}\n","import { InjectionToken } from '@angular/core';\nimport { MetaReducer } from '@ngrx/store';\nimport { EntityCache } from './entity-cache';\n\nexport const ENTITY_CACHE_NAME = 'entityCache';\nexport const ENTITY_CACHE_NAME_TOKEN = new InjectionToken<string>(\n '@ngrx/data Entity Cache Name'\n);\n\nexport const ENTITY_CACHE_META_REDUCERS = new InjectionToken<\n MetaReducer<any, any>[]\n>('@ngrx/data Entity Cache Meta Reducers');\nexport const ENTITY_COLLECTION_META_REDUCERS = new InjectionToken<\n MetaReducer<any, any>[]\n>('@ngrx/data Entity Collection Meta Reducers');\n\nexport const INITIAL_ENTITY_CACHE_STATE = new InjectionToken<\n EntityCache | (() => EntityCache)\n>('@ngrx/data Initial Entity Cache State');\n","import { InjectionToken, Optional, FactoryProvider } from '@angular/core';\nimport { createFeatureSelector, MemoizedSelector } from '@ngrx/store';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n} from '../reducers/constants';\n\nexport const ENTITY_CACHE_SELECTOR_TOKEN = new InjectionToken<\n MemoizedSelector<Object, EntityCache>\n>('@ngrx/data Entity Cache Selector');\n\nexport const entityCacheSelectorProvider: FactoryProvider = {\n provide: ENTITY_CACHE_SELECTOR_TOKEN,\n useFactory: createEntityCacheSelector,\n deps: [[new Optional(), ENTITY_CACHE_NAME_TOKEN]],\n};\n\nexport type EntityCacheSelector = MemoizedSelector<Object, EntityCache>;\n\nexport function createEntityCacheSelector(\n entityCacheName?: string\n): MemoizedSelector<Object, EntityCache> {\n entityCacheName = entityCacheName || ENTITY_CACHE_NAME;\n return createFeatureSelector<EntityCache>(entityCacheName);\n}\n","import { Inject, Injectable, OnDestroy } from '@angular/core';\nimport { Action, Store, ScannedActionsSubject } from '@ngrx/store';\nimport { IdSelector } from '@ngrx/entity';\nimport { Observable, Subscription } from 'rxjs';\nimport { shareReplay } from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n EntityCacheSelector,\n ENTITY_CACHE_SELECTOR_TOKEN,\n} from '../selectors/entity-cache-selector';\nimport { EntityDispatcher } from './entity-dispatcher';\nimport { EntityDispatcherBase } from './entity-dispatcher-base';\n\n/** Creates EntityDispatchers for entity collections */\n@Injectable()\nexport class EntityDispatcherFactory implements OnDestroy {\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n reducedActions$: Observable<Action>;\n private raSubscription: Subscription;\n\n constructor(\n private entityActionFactory: EntityActionFactory,\n private store: Store<EntityCache>,\n private entityDispatcherDefaultOptions: EntityDispatcherDefaultOptions,\n @Inject(ScannedActionsSubject) scannedActions$: Observable<Action>,\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n private entityCacheSelector: EntityCacheSelector,\n private correlationIdGenerator: CorrelationIdGenerator\n ) {\n // Replay because sometimes in tests will fake data service with synchronous observable\n // which makes subscriber miss the dispatched actions.\n // Of course that's a testing mistake. But easy to forget, leading to painful debugging.\n this.reducedActions$ = scannedActions$.pipe(shareReplay(1));\n // Start listening so late subscriber won't miss the most recent action.\n this.raSubscription = this.reducedActions$.subscribe();\n }\n\n /**\n * Create an `EntityDispatcher` for an entity type `T` and store.\n */\n create<T>(\n /** Name of the entity type */\n entityName: string,\n /**\n * Function that returns the primary key for an entity `T`.\n * Usually acquired from `EntityDefinition` metadata.\n * @param {IdSelector<T>} selectId\n */\n selectId: IdSelector<T> = defaultSelectId,\n /** Defaults for options that influence dispatcher behavior such as whether\n * `add()` is optimistic or pessimistic;\n * @param {Partial<EntityDispatcherDefaultOptions>} defaultOptions\n */\n defaultOptions: Partial<EntityDispatcherDefaultOptions> = {}\n ): EntityDispatcher<T> {\n // merge w/ defaultOptions with injected defaults\n const options: EntityDispatcherDefaultOptions = {\n ...this.entityDispatcherDefaultOptions,\n ...defaultOptions,\n };\n return new EntityDispatcherBase<T>(\n entityName,\n this.entityActionFactory,\n this.store,\n selectId,\n options,\n this.reducedActions$,\n this.entityCacheSelector,\n this.correlationIdGenerator\n );\n }\n\n ngOnDestroy() {\n this.raSubscription.unsubscribe();\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { SchedulerLike } from 'rxjs';\n\n// See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n/** Token to inject a special RxJS Scheduler during marble tests. */\nexport const ENTITY_EFFECTS_SCHEDULER = new InjectionToken<SchedulerLike>(\n '@ngrx/data Entity Effects Scheduler'\n);\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { Action } from '@ngrx/store';\nimport { Actions, ofType, createEffect } from '@ngrx/effects';\n\nimport {\n asyncScheduler,\n Observable,\n of,\n merge,\n race,\n SchedulerLike,\n} from 'rxjs';\nimport {\n concatMap,\n catchError,\n delay,\n filter,\n map,\n mergeMap,\n} from 'rxjs/operators';\n\nimport { DataServiceError } from '../dataservices/data-service-error';\nimport {\n ChangeSet,\n excludeEmptyChangeSetItems,\n} from '../actions/entity-cache-change-set';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityOp } from '../actions/entity-op';\n\nimport {\n EntityCacheAction,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesCanceled,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\nimport { EntityCacheDataService } from '../dataservices/entity-cache-data.service';\nimport { ENTITY_EFFECTS_SCHEDULER } from './entity-effects-scheduler';\nimport { Logger } from '../utils/interfaces';\n\n@Injectable()\nexport class EntityCacheEffects {\n // See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */\n private responseDelay = 10;\n\n constructor(\n private actions: Actions,\n private dataService: EntityCacheDataService,\n private entityActionFactory: EntityActionFactory,\n private logger: Logger,\n /**\n * Injecting an optional Scheduler that will be undefined\n * in normal application usage, but its injected here so that you can mock out\n * during testing using the RxJS TestScheduler for simulating passages of time.\n */\n @Optional()\n @Inject(ENTITY_EFFECTS_SCHEDULER)\n private scheduler: SchedulerLike\n ) {}\n\n /**\n * Observable of SAVE_ENTITIES_CANCEL actions with non-null correlation ids\n */\n saveEntitiesCancel$: Observable<SaveEntitiesCancel> = createEffect(\n () =>\n this.actions.pipe(\n ofType(EntityCacheAction.SAVE_ENTITIES_CANCEL),\n filter((a: SaveEntitiesCancel) => a.payload.correlationId != null)\n ),\n { dispatch: false }\n );\n\n // Concurrent persistence requests considered unsafe.\n // `mergeMap` allows for concurrent requests which may return in any order\n saveEntities$: Observable<Action> = createEffect(() =>\n this.actions.pipe(\n ofType(EntityCacheAction.SAVE_ENTITIES),\n mergeMap((action: SaveEntities) => this.saveEntities(action))\n )\n );\n\n /**\n * Perform the requested SaveEntities actions and return a scalar Observable<Action>\n * that the effect should dispatch to the store after the server responds.\n * @param action The SaveEntities action\n */\n saveEntities(action: SaveEntities): Observable<Action> {\n const error = action.payload.error;\n if (error) {\n return this.handleSaveEntitiesError$(action)(error);\n }\n try {\n const changeSet = excludeEmptyChangeSetItems(action.payload.changeSet);\n const { correlationId, mergeStrategy, tag, url } = action.payload;\n const options = { correlationId, mergeStrategy, tag };\n\n if (changeSet.changes.length === 0) {\n // nothing to save\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // Cancellation: returns Observable<SaveEntitiesCanceled> for a saveEntities action\n // whose correlationId matches the cancellation correlationId\n const c = this.saveEntitiesCancel$.pipe(\n filter((a) => correlationId === a.payload.correlationId),\n map(\n (a) =>\n new SaveEntitiesCanceled(\n correlationId,\n a.payload.reason,\n a.payload.tag\n )\n )\n );\n\n // Data: SaveEntities result as a SaveEntitiesSuccess action\n const d = this.dataService.saveEntities(changeSet, url).pipe(\n concatMap((result) =>\n this.handleSaveEntitiesSuccess$(\n action,\n this.entityActionFactory\n )(result)\n ),\n catchError(this.handleSaveEntitiesError$(action))\n );\n\n // Emit which ever gets there first; the other observable is terminated.\n return race(c, d);\n } catch (err: any) {\n return this.handleSaveEntitiesError$(action)(err);\n }\n }\n\n /** return handler of error result of saveEntities, returning a scalar observable of error action */\n private handleSaveEntitiesError$(\n action: SaveEntities\n ): (err: DataServiceError | Error) => Observable<Action> {\n // Although error may return immediately,\n // ensure observable takes some time,\n // as app likely assumes asynchronous response.\n return (err: DataServiceError | Error) => {\n const error =\n err instanceof DataServiceError ? err : new DataServiceError(err, null);\n return of(new SaveEntitiesError(error, action)).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n };\n }\n\n /** return handler of the ChangeSet result of successful saveEntities() */\n private handleSaveEntitiesSuccess$(\n action: SaveEntities,\n entityActionFactory: EntityActionFactory\n ): (changeSet: ChangeSet) => Observable<Action> {\n const { url, correlationId, mergeStrategy, tag } = action.payload;\n const options = { correlationId, mergeStrategy, tag };\n\n return (changeSet) => {\n // DataService returned a ChangeSet with possible updates to the saved entities\n if (changeSet) {\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // No ChangeSet = Server probably responded '204 - No Content' because\n // it made no changes to the inserted/updated entities.\n // Respond with success action best on the ChangeSet in the request.\n changeSet = action.payload.changeSet;\n\n // If pessimistic save, return success action with the original ChangeSet\n if (!action.payload.isOptimistic) {\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // If optimistic save, avoid cache grinding by just turning off the loading flags\n // for all collections in the original ChangeSet\n const entityNames = changeSet.changes.reduce(\n (acc, item) =>\n acc.indexOf(item.entityName) === -1\n ? acc.concat(item.entityName)\n : acc,\n [] as string[]\n );\n return merge(\n entityNames.map((name) =>\n entityActionFactory.create(name, EntityOp.SET_LOADING, false)\n )\n );\n };\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { Action } from '@ngrx/store';\nimport { Actions, createEffect } from '@ngrx/effects';\nimport { Update } from '@ngrx/entity';\n\nimport { asyncScheduler, Observable, of, race, SchedulerLike } from 'rxjs';\nimport { catchError, delay, filter, map, mergeMap } from 'rxjs/operators';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { ENTITY_EFFECTS_SCHEDULER } from './entity-effects-scheduler';\nimport { EntityOp, makeSuccessOp } from '../actions/entity-op';\nimport { ofEntityOp } from '../actions/entity-action-operators';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\nimport { EntityDataService } from '../dataservices/entity-data.service';\nimport { PersistenceResultHandler } from '../dataservices/persistence-result-handler.service';\n\nexport const persistOps: EntityOp[] = [\n EntityOp.QUERY_ALL,\n EntityOp.QUERY_LOAD,\n EntityOp.QUERY_BY_KEY,\n EntityOp.QUERY_MANY,\n EntityOp.SAVE_ADD_ONE,\n EntityOp.SAVE_DELETE_ONE,\n EntityOp.SAVE_UPDATE_ONE,\n EntityOp.SAVE_UPSERT_ONE,\n];\n\n@Injectable()\nexport class EntityEffects {\n // See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */\n private responseDelay = 10;\n\n /**\n * Observable of non-null cancellation correlation ids from CANCEL_PERSIST actions\n */\n cancel$: Observable<any> = createEffect(\n () =>\n this.actions.pipe(\n ofEntityOp(EntityOp.CANCEL_PERSIST),\n map((action: EntityAction) => action.payload.correlationId),\n filter((id) => id != null)\n ),\n { dispatch: false }\n );\n\n // `mergeMap` allows for concurrent requests which may return in any order\n persist$: Observable<Action> = createEffect(() =>\n this.actions.pipe(\n ofEntityOp(persistOps),\n mergeMap((action) => this.persist(action))\n )\n );\n\n constructor(\n private actions: Actions<EntityAction>,\n private dataService: EntityDataService,\n private entityActionFactory: EntityActionFactory,\n private resultHandler: PersistenceResultHandler,\n /**\n * Injecting an optional Scheduler that will be undefined\n * in normal application usage, but its injected here so that you can mock out\n * during testing using the RxJS TestScheduler for simulating passages of time.\n */\n @Optional()\n @Inject(ENTITY_EFFECTS_SCHEDULER)\n private scheduler: SchedulerLike\n ) {}\n\n /**\n * Perform the requested persistence operation and return a scalar Observable<Action>\n * that the effect should dispatch to the store after the server responds.\n * @param action A persistence operation EntityAction\n */\n persist(action: EntityAction): Observable<Action> {\n if (action.payload.skip) {\n // Should not persist. Pretend it succeeded.\n return this.handleSkipSuccess$(action);\n }\n if (action.payload.error) {\n return this.handleError$(action)(action.payload.error);\n }\n try {\n // Cancellation: returns Observable of CANCELED_PERSIST for a persistence EntityAction\n // whose correlationId matches cancellation correlationId\n const c = this.cancel$.pipe(\n filter((id) => action.payload.correlationId === id),\n map((id) =>\n this.entityActionFactory.createFromAction(action, {\n entityOp: EntityOp.CANCELED_PERSIST,\n })\n )\n );\n\n // Data: entity collection DataService result as a successful persistence EntityAction\n const d = this.callDataService(action).pipe(\n map(this.resultHandler.handleSuccess(action)),\n catchError(this.handleError$(action))\n );\n\n // Emit which ever gets there first; the other observable is terminated.\n return race(c, d);\n } catch (err: any) {\n return this.handleError$(action)(err);\n }\n }\n\n private callDataService(action: EntityAction) {\n const { entityName, entityOp, data, httpOptions } = action.payload;\n const service = this.dataService.getService(entityName);\n switch (entityOp) {\n case EntityOp.QUERY_ALL:\n case EntityOp.QUERY_LOAD:\n return service.getAll(httpOptions);\n\n case EntityOp.QUERY_BY_KEY:\n return service.getById(data, httpOptions);\n\n case EntityOp.QUERY_MANY:\n return service.getWithQuery(data, httpOptions);\n\n case EntityOp.SAVE_ADD_ONE:\n return service.add(data, httpOptions);\n\n case EntityOp.SAVE_DELETE_ONE:\n return service.delete(data, httpOptions);\n\n case EntityOp.SAVE_UPDATE_ONE:\n const { id, changes } = data as Update<any>; // data must be Update<T>\n return service.update(data, httpOptions).pipe(\n map((updatedEntity: any) => {\n // Return an Update<T> with updated entity data.\n // If server returned entity data, merge with the changes that were sent\n // and set the 'changed' flag to true.\n // If server did not return entity data,\n // assume it made no additional changes of its own, return the original changes,\n // and set the `changed` flag to `false`.\n const hasData =\n updatedEntity && Object.keys(updatedEntity).length > 0;\n const responseData: UpdateResponseData<any> = hasData\n ? { id, changes: { ...changes, ...updatedEntity }, changed: true }\n : { id, changes, changed: false };\n return responseData;\n })\n );\n\n case EntityOp.SAVE_UPSERT_ONE:\n return service.upsert(data, httpOptions).pipe(\n map((upsertedEntity: any) => {\n const hasData =\n upsertedEntity && Object.keys(upsertedEntity).length > 0;\n return hasData ? upsertedEntity : data; // ensure a returned entity value.\n })\n );\n default:\n throw new Error(`Persistence action \"${entityOp}\" is not implemented.`);\n }\n }\n\n /**\n * Handle error result of persistence operation on an EntityAction,\n * returning a scalar observable of error action\n */\n private handleError$(\n action: EntityAction\n ): (error: Error) => Observable<EntityAction> {\n // Although error may return immediately,\n // ensure observable takes some time,\n // as app likely assumes asynchronous response.\n return (error: Error) =>\n of(this.resultHandler.handleError(action)(error)).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n }\n\n /**\n * Because EntityAction.payload.skip is true, skip the persistence step and\n * return a scalar success action that looks like the operation succeeded.\n */\n private handleSkipSuccess$(\n originalAction: EntityAction\n ): Observable<EntityAction> {\n const successOp = makeSuccessOp(originalAction.payload.entityOp);\n const successAction = this.entityActionFactory.createFromAction(\n originalAction,\n {\n entityOp: successOp,\n }\n );\n // Although returns immediately,\n // ensure observable takes one tick (by using a promise),\n // as app likely assumes asynchronous response.\n return of(successAction).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n }\n}\n","/**\n * Filters the `entities` array argument and returns the original `entities`,\n * or a new filtered array of entities.\n * NEVER mutate the original `entities` array itself.\n **/\nexport type EntityFilterFn<T> = (entities: T[], pattern?: any) => T[];\n\n/**\n * Creates an {EntityFilterFn} that matches RegExp or RegExp string pattern\n * anywhere in any of the given props of an entity.\n * If pattern is a string, spaces are significant and ignores case.\n */\nexport function PropsFilterFnFactory<T = any>(\n props: (keyof T)[] = []\n): EntityFilterFn<T> {\n if (props.length === 0) {\n // No properties -> nothing could match -> return unfiltered\n return (entities: T[], pattern: string) => entities;\n }\n\n return (entities: T[], pattern: string | RegExp) => {\n if (!entities) {\n return [];\n }\n\n const regExp =\n typeof pattern === 'string' ? new RegExp(pattern, 'i') : pattern;\n if (regExp) {\n const predicate = (e: any) => props.some((prop) => regExp.test(e[prop]));\n return entities.filter(predicate);\n }\n return entities;\n };\n}\n","import { Action, Store } from '@ngrx/store';\nimport { Dictionary, IdSelector, Update } from '@ngrx/entity';\n\nimport { Observable } from 'rxjs';\n\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\nimport { EntityDispatcher } from '../dispatchers/entity-dispatcher';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';\nimport { EntityOp } from '../actions/entity-op';\nimport { EntitySelectors } from '../selectors/entity-selectors';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\nimport { QueryParams } from '../dataservices/interfaces';\n\n/**\n * Base class for a concrete EntityCollectionService<T>.\n * Can be instantiated. Cannot be injected. Use EntityCollectionServiceFactory to create.\n * @param EntityCollectionServiceElements The ingredients for this service\n * as a source of supporting services for creating an EntityCollectionService<T> instance.\n */\nexport class EntityCollectionServiceBase<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n> implements EntityCollectionService<T>\n{\n /** Dispatcher of EntityCommands (EntityActions) */\n readonly dispatcher: EntityDispatcher<T>;\n\n /** All selectors of entity collection properties */\n readonly selectors: EntitySelectors<T>;\n\n /** All selectors$ (observables of entity collection properties) */\n readonly selectors$: S$;\n\n constructor(\n /** Name of the entity type of this collection service */\n public readonly entityName: string,\n /** Creates the core elements of the EntityCollectionService for this entity type */\n serviceElementsFactory: EntityCollectionServiceElementsFactory\n ) {\n entityName = entityName.trim();\n const { dispatcher, selectors, selectors$ } = serviceElementsFactory.create<\n T,\n S$\n >(entityName);\n\n this.entityName = entityName;\n this.dispatcher = dispatcher;\n this.guard = dispatcher.guard;\n this.selectId = dispatcher.selectId;\n this.toUpdate = dispatcher.toUpdate;\n\n this.selectors = selectors;\n this.selectors$ = selectors$;\n this.collection$ = selectors$.collection$;\n this.count$ = selectors$.count$;\n this.entities$ = selectors$.entities$;\n this.entityActions$ = selectors$.entityActions$;\n this.entityMap$ = selectors$.entityMap$;\n this.errors$ = selectors$.errors$;\n this.filter$ = selectors$.filter$;\n this.filteredEntities$ = selectors$.filteredEntities$;\n this.keys$ = selectors$.keys$;\n this.loaded$ = selectors$.loaded$;\n this.loading$ = selectors$.loading$;\n this.changeState$ = selectors$.changeState$;\n }\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.dispatcher.createEntityAction(op, data, options);\n }\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.dispatcher.createAndDispatch(op, data, options);\n }\n\n /**\n * Dispatch an action of any type to the ngrx store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n return this.dispatcher.dispatch(action);\n }\n\n /** The NgRx Store for the {EntityCache} */\n get store() {\n return this.dispatcher.store;\n }\n\n /**\n * Utility class with methods to validate EntityAction payloads.\n */\n guard: EntityActionGuard<T>;\n\n /** Returns the primary key (id) of this entity */\n selectId: IdSelector<T>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate: (entity: Partial<T>) => Update<T>;\n\n // region Dispatch commands\n\n /**\n * Dispatch action to save a new entity to remote storage.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the entity\n * after server reports successful save or the save error.\n */\n add(\n entity: Partial<T>,\n options: EntityActionOptions & { isOptimistic: false }\n ): Observable<T>;\n add(entity: T, options?: EntityActionOptions): Observable<T>;\n add(entity: T, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.add(entity, options);\n }\n\n /**\n * Dispatch action to cancel the persistence operation (query or save) with the given correlationId.\n * @param correlationId The correlation id for the corresponding EntityAction\n * @param [reason] explains why canceled and by whom.\n * @param [options] options such as the tag and mergeStrategy\n */\n cancel(\n correlationId: any,\n reason?: string,\n options?: EntityActionOptions\n ): void {\n this.dispatcher.cancel(correlationId, reason, options);\n }\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The entity to delete\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(entity: T, options?: EntityActionOptions): Observable<number | string>;\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The primary key of the entity to remove\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(\n key: number | string,\n options?: EntityActionOptions\n ): Observable<number | string>;\n delete(\n arg: number | string | T,\n options?: EntityActionOptions\n ): Observable<number | string> {\n return this.dispatcher.delete(arg as any, options);\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * merge the queried entities into the cached collection.\n * @param [options] options that influence merge behavior\n * @returns Observable of the collection\n * after server reports successful query or the query error.\n * @see load()\n */\n getAll(options?: EntityActionOptions): Observable<T[]> {\n return this.dispatcher.getAll(options);\n }\n\n /**\n * Dispatch action to query remote storage for the entity with this primary key.\n * If the server returns an entity,\n * merge it into the cached collection.\n * @param key The primary key of the entity to get.\n * @param [options] options that influence merge behavior\n * @returns Observable of the queried entity that is in the collection\n * after server reports success or the query error.\n */\n getByKey(key: any, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.getByKey(key, options);\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and merge the results into the cached collection.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence merge behavior\n * @returns Observable of the queried entities\n * after server reports successful query or the query error.\n */\n getWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n return this.dispatcher.getWithQuery(queryParams, options);\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * completely replace the cached collection with the queried entities.\n * @param [options] options that influence load behavior\n * @returns Observable of the collection\n * after server reports successful query or the query error.\n * @see getAll\n */\n load(options?: EntityActionOptions): Observable<T[]> {\n return this.dispatcher.load(options);\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and completely replace the cached collection with the queried entities.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence load behavior\n * @returns Observable of the queried entities\n * after server reports successful query or the query error.\n */\n loadWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n return this.dispatcher.loadWithQuery(queryParams, options);\n }\n\n /**\n * Dispatch action to save the updated entity (or partial entity) in remote storage.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity update entity, which might be a partial of T but must at least have its key.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the updated entity\n * after server reports successful save or the save error.\n */\n update(entity: Partial<T>, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.update(entity, options);\n }\n\n /**\n * Dispatch action to save a new or existing entity to remote storage.\n * Call only if the server supports upsert.\n * @param entity entity to add or upsert.\n * It may omit its key if an add, and is pessimistic, and the server creates the key;\n * must have a key if optimistic save.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the entity\n * after server reports successful save or the save error.\n */\n upsert(entity: T, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.upsert(entity, options);\n }\n\n /*** Cache-only operations that do not update remote storage ***/\n\n /**\n * Replace all entities in the cached collection.\n * Does not save to remote storage.\n * @param entities to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addAllToCache(entities: T[], options?: EntityActionOptions): void {\n this.dispatcher.addAllToCache(entities, options);\n }\n\n /**\n * Add a new entity directly to the cache.\n * Does not save to remote storage.\n * Ignored if an entity with the same primary key is already in cache.\n * @param entity to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addOneToCache(entity: T, options?: EntityActionOptions): void {\n this.dispatcher.addOneToCache(entity, options);\n }\n\n /**\n * Add multiple new entities directly to the cache.\n * Does not save to remote storage.\n * Entities with primary keys already in cache are ignored.\n * @param entities to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addManyToCache(entities: T[], options?: EntityActionOptions): void {\n this.dispatcher.addManyToCache(entities, options);\n }\n\n /** Clear the cached entity collection */\n clearCache(): void {\n this.dispatcher.clearCache();\n }\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param entity The entity to remove\n * @param [options] options such as mergeStrategy\n */\n removeOneFromCache(entity: T, options?: EntityActionOptions): void;\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param key The primary key of the entity to remove\n * @param [options] options such as mergeStrategy\n */\n removeOneFromCache(key: number | string, options?: EntityActionOptions): void;\n removeOneFromCache(\n arg: (number | string) | T,\n options?: EntityActionOptions\n ): void {\n this.dispatcher.removeOneFromCache(arg as any, options);\n }\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param entity The entities to remove\n * @param [options] options such as mergeStrategy\n */\n removeManyFromCache(entities: T[], options?: EntityActionOptions): void;\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param keys The primary keys of the entities to remove\n * @param [options] options such as mergeStrategy\n */\n removeManyFromCache(\n keys: (number | string)[],\n options?: EntityActionOptions\n ): void;\n removeManyFromCache(\n args: (number | string)[] | T[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.removeManyFromCache(args as any[], options);\n }\n\n /**\n * Update a cached entity directly.\n * Does not update that entity in remote storage.\n * Ignored if an entity with matching primary key is not in cache.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity to update directly in cache.\n * @param [options] options such as mergeStrategy\n */\n updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n this.dispatcher.updateOneInCache(entity, options);\n }\n\n /**\n * Update multiple cached entities directly.\n * Does not update these entities in remote storage.\n * Entities whose primary keys are not in cache are ignored.\n * Update entities may be partial but must at least have their keys.\n * such partial entities patch their cached counterparts.\n * @param entities to update directly in cache.\n * @param [options] options such as mergeStrategy\n */\n updateManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.updateManyInCache(entities, options);\n }\n\n /**\n * Insert or update a cached entity directly.\n * Does not save to remote storage.\n * Upsert entity might be a partial of T but must at least have its key.\n * Pass the Update<T> structure as the payload.\n * @param entity to upsert directly in cache.\n * @param [options] options such as mergeStrategy\n */\n upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n this.dispatcher.upsertOneInCache(entity, options);\n }\n\n /**\n * Insert or update multiple cached entities directly.\n * Does not save to remote storage.\n * Upsert entities might be partial but must at least have their keys.\n * Pass an array of the Update<T> structure as the payload.\n * @param entities to upsert directly in cache.\n * @param [options] options such as mergeStrategy\n */\n upsertManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.upsertManyInCache(entities, options);\n }\n\n /**\n * Set the pattern that the collection's filter applies\n * when using the `filteredEntities` selector.\n */\n setFilter(pattern: any): void {\n this.dispatcher.setFilter(pattern);\n }\n\n /** Set the loaded flag */\n setLoaded(isLoaded: boolean): void {\n this.dispatcher.setLoaded(!!isLoaded);\n }\n\n /** Set the loading flag */\n setLoading(isLoading: boolean): void {\n this.dispatcher.setLoading(!!isLoading);\n }\n\n // endregion Dispatch commands\n\n // region Selectors$\n /** Observable of the collection as a whole */\n collection$: Observable<EntityCollection<T>> | Store<EntityCollection<T>>;\n\n /** Observable of count of entities in the cached collection. */\n count$: Observable<number> | Store<number>;\n\n /** Observable of all entities in the cached collection. */\n entities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of actions related to this entity type. */\n entityActions$: Observable<EntityAction>;\n\n /** Observable of the map of entity keys to entities */\n entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;\n\n /** Observable of error actions related to this entity type. */\n errors$: Observable<EntityAction>;\n\n /** Observable of the filter pattern applied by the entity collection's filter function */\n filter$: Observable<any> | Store<any>;\n\n /** Observable of entities in the cached collection that pass the filter function */\n filteredEntities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of the keys of the cached collection, in the collection's native sort order */\n keys$: Observable<string[] | number[]> | Store<string[] | number[]>;\n\n /** Observable true when the collection has been loaded */\n loaded$: Observable<boolean> | Store<boolean>;\n\n /** Observable true when a multi-entity query command is in progress. */\n loading$: Observable<boolean> | Store<boolean>;\n\n /** Original entity values for entities with unsaved changes */\n changeState$: Observable<ChangeStateMap<T>> | Store<ChangeStateMap<T>>;\n\n // endregion Selectors$\n}\n","import { Injectable, Optional } from '@angular/core';\n\nimport { EntityCollection } from './entity-collection';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\n\n@Injectable()\nexport class EntityCollectionCreator {\n constructor(\n @Optional() private entityDefinitionService?: EntityDefinitionService\n ) {}\n\n /**\n * Create the default collection for an entity type.\n * @param entityName {string} entity type name\n */\n create<T = any, S extends EntityCollection<T> = EntityCollection<T>>(\n entityName: string\n ): S {\n const def =\n this.entityDefinitionService &&\n this.entityDefinitionService.getDefinition<T>(\n entityName,\n false /*shouldThrow*/\n );\n\n const initialState = def && def.initialState;\n\n return <S>(initialState || createEmptyEntityCollection<T>(entityName));\n }\n}\n\nexport function createEmptyEntityCollection<T>(\n entityName?: string\n): EntityCollection<T> {\n return {\n entityName,\n ids: [],\n entities: {},\n filter: undefined,\n loaded: false,\n loading: false,\n changeState: {},\n } as EntityCollection<T>;\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\n// Prod build requires `MemoizedSelector even though not used.\nimport { MemoizedSelector } from '@ngrx/store';\nimport { createSelector, Selector } from '@ngrx/store';\nimport { Dictionary } from '@ngrx/entity';\n\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n EntityCacheSelector,\n createEntityCacheSelector,\n} from './entity-cache-selector';\nimport { ENTITY_CACHE_NAME } from '../reducers/constants';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\nimport { EntityCollectionCreator } from '../reducers/entity-collection-creator';\nimport { EntityMetadata } from '../entity-metadata/entity-metadata';\n\n/**\n * The selector functions for entity collection members,\n * Selects from the entity collection to the collection member\n * Contrast with {EntitySelectors}.\n */\nexport interface CollectionSelectors<T> {\n readonly [selector: string]: any;\n\n /** Count of entities in the cached collection. */\n readonly selectCount: Selector<EntityCollection<T>, number>;\n\n /** All entities in the cached collection. */\n readonly selectEntities: Selector<EntityCollection<T>, T[]>;\n\n /** Map of entity keys to entities */\n readonly selectEntityMap: Selector<EntityCollection<T>, Dictionary<T>>;\n\n /** Filter pattern applied by the entity collection's filter function */\n readonly selectFilter: Selector<EntityCollection<T>, string>;\n\n /** Entities in the cached collection that pass the filter function */\n readonly selectFilteredEntities: Selector<EntityCollection<T>, T[]>;\n\n /** Keys of the cached collection, in the collection's native sort order */\n readonly selectKeys: Selector<EntityCollection<T>, string[] | number[]>;\n\n /** True when the collection has been fully loaded. */\n readonly selectLoaded: Selector<EntityCollection<T>, boolean>;\n\n /** True when a multi-entity query command is in progress. */\n readonly selectLoading: Selector<EntityCollection<T>, boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly selectChangeState: Selector<EntityCollection<T>, ChangeStateMap<T>>;\n}\n\n/**\n * The selector functions for entity collection members,\n * Selects from store root, through EntityCache, to the entity collection member\n * Contrast with {CollectionSelectors}.\n */\nexport interface EntitySelectors<T> {\n /** Name of the entity collection for these selectors */\n readonly entityName: string;\n\n readonly [name: string]: MemoizedSelector<EntityCollection<T>, any> | string;\n\n /** The cached EntityCollection itself */\n readonly selectCollection: MemoizedSelector<Object, EntityCollection<T>>;\n\n /** Count of entities in the cached collection. */\n readonly selectCount: MemoizedSelector<Object, number>;\n\n /** All entities in the cached collection. */\n readonly selectEntities: MemoizedSelector<Object, T[]>;\n\n /** The EntityCache */\n readonly selectEntityCache: MemoizedSelector<Object, EntityCache>;\n\n /** Map of entity keys to entities */\n readonly selectEntityMap: MemoizedSelector<Object, Dictionary<T>>;\n\n /** Filter pattern applied by the entity collection's filter function */\n readonly selectFilter: MemoizedSelector<Object, string>;\n\n /** Entities in the cached collection that pass the filter function */\n readonly selectFilteredEntities: MemoizedSelector<Object, T[]>;\n\n /** Keys of the cached collection, in the collection's native sort order */\n readonly selectKeys: MemoizedSelector<Object, string[] | number[]>;\n\n /** True when the collection has been fully loaded. */\n readonly selectLoaded: MemoizedSelector<Object, boolean>;\n\n /** True when a multi-entity query command is in progress. */\n readonly selectLoading: MemoizedSelector<Object, boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly selectChangeState: MemoizedSelector<Object, ChangeStateMap<T>>;\n}\n\n/** Creates EntitySelector functions for entity collections. */\n@Injectable()\nexport class EntitySelectorsFactory {\n private entityCollectionCreator: EntityCollectionCreator;\n private selectEntityCache: EntityCacheSelector;\n\n constructor(\n @Optional() entityCollectionCreator?: EntityCollectionCreator,\n @Optional()\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n selectEntityCache?: EntityCacheSelector\n ) {\n this.entityCollectionCreator =\n entityCollectionCreator || new EntityCollectionCreator();\n this.selectEntityCache =\n selectEntityCache || createEntityCacheSelector(ENTITY_CACHE_NAME);\n }\n\n /**\n * Create the NgRx selector from the store root to the named collection,\n * e.g. from Object to Heroes.\n * @param entityName the name of the collection\n */\n createCollectionSelector<\n T = any,\n C extends EntityCollection<T> = EntityCollection<T>\n >(entityName: string) {\n const getCollection = (cache: EntityCache = {}) =>\n <C>(\n (cache[entityName] ||\n this.entityCollectionCreator.create<T>(entityName))\n );\n return createSelector(this.selectEntityCache, getCollection);\n }\n\n /////// createCollectionSelectors //////////\n\n // Based on @ngrx/entity/state_selectors.ts\n\n /* eslint-disable @typescript-eslint/unified-signatures */\n // createCollectionSelectors(metadata) overload\n /**\n * Creates entity collection selectors from metadata.\n * @param metadata - EntityMetadata for the collection.\n * May be partial but much have `entityName`.\n */\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(metadata: EntityMetadata<T>): S;\n\n /* eslint-disable @typescript-eslint/unified-signatures */\n // createCollectionSelectors(entityName) overload\n /**\n * Creates default entity collection selectors for an entity type.\n * Use the metadata overload for additional collection selectors.\n * @param entityName - name of the entity type\n */\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(entityName: string): S;\n\n // createCollectionSelectors implementation\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(metadataOrName: EntityMetadata<T> | string): S {\n const metadata =\n typeof metadataOrName === 'string'\n ? { entityName: metadataOrName }\n : metadataOrName;\n const selectKeys = (c: EntityCollection<T>) => c.ids;\n const selectEntityMap = (c: EntityCollection<T>) => c.entities;\n\n const selectEntities: Selector<EntityCollection<T>, T[]> = createSelector(\n selectKeys,\n selectEntityMap,\n (keys: (number | string)[], entities: Dictionary<T>): T[] =>\n keys.map((key) => entities[key] as T)\n );\n\n const selectCount: Selector<EntityCollection<T>, number> = createSelector(\n selectKeys,\n (keys) => keys.length\n );\n\n // EntityCollection selectors that go beyond the ngrx/entity/EntityState selectors\n const selectFilter = (c: EntityCollection<T>) => c.filter;\n\n const filterFn = metadata.filterFn;\n const selectFilteredEntities: Selector<EntityCollection<T>, T[]> = filterFn\n ? createSelector(\n selectEntities,\n selectFilter,\n (entities: T[], pattern: any): T[] => filterFn(entities, pattern)\n )\n : selectEntities;\n\n const selectLoaded = (c: EntityCollection<T>) => c.loaded;\n const selectLoading = (c: EntityCollection<T>) => c.loading;\n const selectChangeState = (c: EntityCollection<T>) => c.changeState;\n\n // Create collection selectors for each `additionalCollectionState` property.\n // These all extend from `selectCollection`\n const extra = metadata.additionalCollectionState || {};\n const extraSelectors: {\n [name: string]: Selector<EntityCollection<T>, any>;\n } = {};\n Object.keys(extra).forEach((k) => {\n extraSelectors['select' + k[0].toUpperCase() + k.slice(1)] = (\n c: EntityCollection<T>\n ) => (<any>c)[k];\n });\n\n return {\n selectCount,\n selectEntities,\n selectEntityMap,\n selectFilter,\n selectFilteredEntities,\n selectKeys,\n selectLoaded,\n selectLoading,\n selectChangeState,\n ...extraSelectors,\n } as S;\n }\n\n /////// create //////////\n\n // create(metadata) overload\n /**\n * Creates the store-rooted selectors for an entity collection.\n * {EntitySelectors$Factory} turns them into selectors$.\n *\n * @param metadata - EntityMetadata for the collection.\n * May be partial but much have `entityName`.\n *\n * Based on ngrx/entity/state_selectors.ts\n * Differs in that these selectors select from the NgRx store root,\n * through the collection, to the collection members.\n */\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n metadata: EntityMetadata<T>\n ): S;\n\n // create(entityName) overload\n /**\n * Creates the default store-rooted selectors for an entity collection.\n * {EntitySelectors$Factory} turns them into selectors$.\n * Use the metadata overload for additional collection selectors.\n *\n * @param entityName - name of the entity type.\n *\n * Based on ngrx/entity/state_selectors.ts\n * Differs in that these selectors select from the NgRx store root,\n * through the collection, to the collection members.\n */\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n entityName: string\n ): S;\n\n // createCollectionSelectors implementation\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n metadataOrName: EntityMetadata<T> | string\n ): S {\n const metadata =\n typeof metadataOrName === 'string'\n ? { entityName: metadataOrName }\n : metadataOrName;\n const entityName = metadata.entityName;\n const selectCollection: Selector<\n Object,\n EntityCollection<T>\n > = this.createCollectionSelector<T>(entityName);\n const collectionSelectors = this.createCollectionSelectors<T>(metadata);\n\n const entitySelectors: {\n [name: string]: Selector<EntityCollection<T>, any>;\n } = {};\n Object.keys(collectionSelectors).forEach((k) => {\n entitySelectors[k] = createSelector(\n selectCollection,\n collectionSelectors[k]\n );\n });\n\n return {\n entityName,\n selectCollection,\n selectEntityCache: this.selectEntityCache,\n ...entitySelectors,\n } as S;\n }\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { Store } from '@ngrx/store';\nimport { Actions } from '@ngrx/effects';\nimport { Dictionary } from '@ngrx/entity';\n\nimport { Observable } from 'rxjs';\nimport { filter, shareReplay } from 'rxjs/operators';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { OP_ERROR } from '../actions/entity-op';\nimport { ofEntityType } from '../actions/entity-action-operators';\nimport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n EntityCacheSelector,\n} from './entity-cache-selector';\nimport { EntitySelectors } from './entity-selectors';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\n\n/**\n * The selector observable functions for entity collection members.\n */\nexport interface EntitySelectors$<T> {\n /** Name of the entity collection for these selectors$ */\n readonly entityName: string;\n\n /** Names from custom selectors from additionalCollectionState fits here, 'any' to avoid conflict with entityName */\n readonly [name: string]: Observable<any> | Store<any> | any;\n\n /** Observable of the collection as a whole */\n readonly collection$: Observable<EntityCollection> | Store<EntityCollection>;\n\n /** Observable of count of entities in the cached collection. */\n readonly count$: Observable<number> | Store<number>;\n\n /** Observable of all entities in the cached collection. */\n readonly entities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of actions related to this entity type. */\n readonly entityActions$: Observable<EntityAction>;\n\n /** Observable of the map of entity keys to entities */\n readonly entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;\n\n /** Observable of error actions related to this entity type. */\n readonly errors$: Observable<EntityAction>;\n\n /** Observable of the filter pattern applied by the entity collection's filter function */\n readonly filter$: Observable<string> | Store<string>;\n\n /** Observable of entities in the cached collection that pass the filter function */\n readonly filteredEntities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of the keys of the cached collection, in the collection's native sort order */\n readonly keys$: Observable<string[] | number[]> | Store<string[] | number[]>;\n\n /** Observable true when the collection has been loaded */\n readonly loaded$: Observable<boolean> | Store<boolean>;\n\n /** Observable true when a multi-entity query command is in progress. */\n readonly loading$: Observable<boolean> | Store<boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly changeState$:\n | Observable<ChangeStateMap<T>>\n | Store<ChangeStateMap<T>>;\n}\n\n/** Creates observable EntitySelectors$ for entity collections. */\n@Injectable()\nexport class EntitySelectors$Factory {\n /** Observable of the EntityCache */\n entityCache$: Observable<EntityCache>;\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n entityActionErrors$: Observable<EntityAction>;\n\n constructor(\n private store: Store<any>,\n private actions: Actions<EntityAction>,\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n private selectEntityCache: EntityCacheSelector\n ) {\n // This service applies to the cache in ngrx/store named `cacheName`\n this.entityCache$ = this.store.select(this.selectEntityCache);\n this.entityActionErrors$ = actions.pipe(\n filter(\n (ea: EntityAction) =>\n ea.payload &&\n ea.payload.entityOp &&\n ea.payload.entityOp.endsWith(OP_ERROR)\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Creates an entity collection's selectors$ observables for this factory's store.\n * `selectors$` are observable selectors of the cached entity collection.\n * @param entityName - is also the name of the collection.\n * @param selectors - selector functions for this collection.\n **/\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string,\n selectors: EntitySelectors<T>\n ): S$ {\n const selectors$: { [prop: string]: any } = {\n entityName,\n };\n\n Object.keys(selectors).forEach((name) => {\n if (name.startsWith('select')) {\n // strip 'select' prefix from the selector fn name and append `$`\n // Ex: 'selectEntities' => 'entities$'\n const name$ = name[6].toLowerCase() + name.substring(7) + '$';\n selectors$[name$] = this.store.select((<any>selectors)[name]);\n }\n });\n selectors$['entityActions$'] = this.actions.pipe(ofEntityType(entityName));\n selectors$['errors$'] = this.entityActionErrors$.pipe(\n ofEntityType(entityName)\n );\n return selectors$ as S$;\n }\n}\n","import { Injectable } from '@angular/core';\nimport { EntityDispatcher } from '../dispatchers/entity-dispatcher';\nimport { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport {\n EntitySelectors,\n EntitySelectorsFactory,\n} from '../selectors/entity-selectors';\nimport {\n EntitySelectors$,\n EntitySelectors$Factory,\n} from '../selectors/entity-selectors$';\n\n/** Core ingredients of an EntityCollectionService */\nexport interface EntityCollectionServiceElements<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n> {\n readonly dispatcher: EntityDispatcher<T>;\n readonly entityName: string;\n readonly selectors: EntitySelectors<T>;\n readonly selectors$: S$;\n}\n\n/** Creates the core elements of the EntityCollectionService for an entity type. */\n@Injectable()\nexport class EntityCollectionServiceElementsFactory {\n constructor(\n private entityDispatcherFactory: EntityDispatcherFactory,\n private entityDefinitionService: EntityDefinitionService,\n private entitySelectorsFactory: EntitySelectorsFactory,\n private entitySelectors$Factory: EntitySelectors$Factory\n ) {}\n\n /**\n * Get the ingredients for making an EntityCollectionService for this entity type\n * @param entityName - name of the entity type\n */\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string\n ): EntityCollectionServiceElements<T, S$> {\n entityName = entityName.trim();\n const definition =\n this.entityDefinitionService.getDefinition<T>(entityName);\n const dispatcher = this.entityDispatcherFactory.create<T>(\n entityName,\n definition.selectId,\n definition.entityDispatcherOptions\n );\n const selectors = this.entitySelectorsFactory.create<T>(\n definition.metadata\n );\n const selectors$ = this.entitySelectors$Factory.create<T, S$>(\n entityName,\n selectors\n );\n return {\n dispatcher,\n entityName,\n selectors,\n selectors$,\n };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceBase } from './entity-collection-service-base';\nimport { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\n\n/**\n * Creates EntityCollectionService instances for\n * a cached collection of T entities in the ngrx store.\n */\n@Injectable()\nexport class EntityCollectionServiceFactory {\n constructor(\n /** Creates the core elements of the EntityCollectionService for an entity type. */\n public entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory\n ) {}\n\n /**\n * Create an EntityCollectionService for an entity type\n * @param entityName - name of the entity type\n */\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string\n ): EntityCollectionService<T> {\n return new EntityCollectionServiceBase<T, S$>(\n entityName,\n this.entityCollectionServiceElementsFactory\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action, Store } from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';\nimport { EntitySelectors$Factory } from '../selectors/entity-selectors$';\nimport { EntityCollectionServiceFactory } from './entity-collection-service-factory';\n\n/** Core ingredients of an EntityServices class */\n@Injectable()\nexport class EntityServicesElements {\n constructor(\n /**\n * Creates EntityCollectionService instances for\n * a cached collection of T entities in the ngrx store.\n */\n public readonly entityCollectionServiceFactory: EntityCollectionServiceFactory,\n /** Creates EntityDispatchers for entity collections */\n entityDispatcherFactory: EntityDispatcherFactory,\n /** Creates observable EntitySelectors$ for entity collections. */\n entitySelectors$Factory: EntitySelectors$Factory,\n /** The ngrx store, scoped to the EntityCache */\n public readonly store: Store<EntityCache>\n ) {\n this.entityActionErrors$ = entitySelectors$Factory.entityActionErrors$;\n this.entityCache$ = entitySelectors$Factory.entityCache$;\n this.reducedActions$ = entityDispatcherFactory.reducedActions$;\n }\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n readonly entityActionErrors$: Observable<EntityAction>;\n\n /** Observable of the entire entity cache */\n readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n readonly reducedActions$: Observable<Action>;\n}\n","import { Injectable } from '@angular/core';\nimport { Action, Store } from '@ngrx/store';\n\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceFactory } from './entity-collection-service-factory';\nimport { EntityCollectionServiceMap, EntityServices } from './entity-services';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\nimport { EntityServicesElements } from './entity-services-elements';\n\n/**\n * Base/default class of a central registry of EntityCollectionServices for all entity types.\n * Create your own subclass to add app-specific members for an improved developer experience.\n *\n * @usageNotes\n * ```ts\n * export class EntityServices extends EntityServicesBase {\n * constructor(entityServicesElements: EntityServicesElements) {\n * super(entityServicesElements);\n * }\n * // Extend with well-known, app entity collection services\n * // Convenience property to return a typed custom entity collection service\n * get companyService() {\n * return this.getEntityCollectionService<Model.Company>('Company') as CompanyService;\n * }\n * // Convenience dispatch methods\n * clearCompany(companyId: string) {\n * this.dispatch(new ClearCompanyAction(companyId));\n * }\n * }\n * ```\n */\n@Injectable()\nexport class EntityServicesBase implements EntityServices {\n // Dear @ngrx/data developer: think hard before changing the constructor.\n // Doing so will break apps that derive from this base class,\n // and many apps will derive from this class.\n //\n // Do not give this constructor an implementation.\n // Doing so makes it hard to mock classes that derive from this class.\n // Use getter properties instead. For example, see entityCache$\n constructor(private entityServicesElements: EntityServicesElements) {}\n\n // #region EntityServicesElement-based properties\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n get entityActionErrors$(): Observable<EntityAction> {\n return this.entityServicesElements.entityActionErrors$;\n }\n\n /** Observable of the entire entity cache */\n get entityCache$(): Observable<EntityCache> | Store<EntityCache> {\n return this.entityServicesElements.entityCache$;\n }\n\n /** Factory to create a default instance of an EntityCollectionService */\n get entityCollectionServiceFactory(): EntityCollectionServiceFactory {\n return this.entityServicesElements.entityCollectionServiceFactory;\n }\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n get reducedActions$(): Observable<Action> {\n return this.entityServicesElements.reducedActions$;\n }\n\n /** The ngrx store, scoped to the EntityCache */\n protected get store(): Store<EntityCache> {\n return this.entityServicesElements.store;\n }\n\n // #endregion EntityServicesElement-based properties\n\n /** Dispatch any action to the store */\n dispatch(action: Action) {\n this.store.dispatch(action);\n }\n\n /** Registry of EntityCollectionService instances */\n private readonly EntityCollectionServices: EntityCollectionServiceMap = {};\n\n /**\n * Create a new default instance of an EntityCollectionService.\n * Prefer getEntityCollectionService() unless you really want a new default instance.\n * This one will NOT be registered with EntityServices!\n * @param entityName {string} Name of the entity type of the service\n */\n protected createEntityCollectionService<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n >(entityName: string): EntityCollectionService<T> {\n return this.entityCollectionServiceFactory.create<T, S$>(entityName);\n }\n\n /** Get (or create) the singleton instance of an EntityCollectionService\n * @param entityName {string} Name of the entity type of the service\n */\n getEntityCollectionService<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n >(entityName: string): EntityCollectionService<T> {\n let service = this.EntityCollectionServices[entityName];\n if (!service) {\n service = this.createEntityCollectionService<T, S$>(entityName);\n this.EntityCollectionServices[entityName] = service;\n }\n return service;\n }\n\n /** Register an EntityCollectionService under its entity type name.\n * Will replace a pre-existing service for that type.\n * @param service {EntityCollectionService} The entity service\n * @param serviceName {string} optional service name to use instead of the service's entityName\n */\n registerEntityCollectionService<T>(\n service: EntityCollectionService<T>,\n serviceName?: string\n ) {\n this.EntityCollectionServices[serviceName || service.entityName] = service;\n }\n\n /**\n * Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServices {EntityCollectionServiceMap | EntityCollectionService<any>[]}\n * EntityCollectionServices to register, either as a map or an array\n */\n registerEntityCollectionServices(\n entityCollectionServices:\n | EntityCollectionServiceMap\n | EntityCollectionService<any>[]\n ): void {\n if (Array.isArray(entityCollectionServices)) {\n entityCollectionServices.forEach((service) =>\n this.registerEntityCollectionService(service)\n );\n } else {\n Object.keys(entityCollectionServices || {}).forEach((serviceName) => {\n this.registerEntityCollectionService(\n entityCollectionServices[serviceName],\n serviceName\n );\n });\n }\n }\n}\n","import { Action, Store } from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCollectionService } from './entity-collection-service';\n\n/**\n * Class-Interface for EntityCache and EntityCollection services.\n * Serves as an Angular provider token for this service class.\n * Includes a registry of EntityCollectionServices for all entity types.\n * Creates a new default EntityCollectionService for any entity type not in the registry.\n * Optionally register specialized EntityCollectionServices for individual types\n */\nexport abstract class EntityServices {\n /** Dispatch any action to the store */\n abstract dispatch(action: Action): void;\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n abstract readonly entityActionErrors$: Observable<EntityAction>;\n\n /** Observable of the entire entity cache */\n abstract readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;\n\n /** Get (or create) the singleton instance of an EntityCollectionService\n * @param entityName {string} Name of the entity type of the service\n */\n abstract getEntityCollectionService<T = any>(\n entityName: string\n ): EntityCollectionService<T>;\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent Action (not just EntityAction) reduced by the store.\n */\n abstract readonly reducedActions$: Observable<Action>;\n\n // #region EntityCollectionService creation and registration API\n\n /** Register an EntityCollectionService under its entity type name.\n * Will replace a pre-existing service for that type.\n * @param service {EntityCollectionService} The entity service\n */\n abstract registerEntityCollectionService<T>(\n service: EntityCollectionService<T>\n ): void;\n\n /** Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServices Array of EntityCollectionServices to register\n */\n abstract registerEntityCollectionServices(\n entityCollectionServices: EntityCollectionService<any>[]\n ): void;\n\n /** Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServiceMap Map of service-name to entity-collection-service\n */\n abstract registerEntityCollectionServices(\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n entityCollectionServiceMap: EntityCollectionServiceMap\n ): void;\n // #endregion EntityCollectionService creation and registration API\n}\n\n/**\n * A map of service or entity names to their corresponding EntityCollectionServices.\n */\nexport interface EntityCollectionServiceMap {\n [entityName: string]: EntityCollectionService<any>;\n}\n","import { EntityState, Dictionary } from '@ngrx/entity';\n\n/** Types of change in a ChangeState instance */\nexport enum ChangeType {\n /** The entity has not changed from its last known server state. */\n Unchanged = 0,\n /** The entity was added to the collection */\n Added,\n /** The entity is scheduled for delete and was removed from the collection */\n Deleted,\n /** The entity in the collection was updated */\n Updated,\n}\n\n/**\n * Change state for an entity with unsaved changes;\n * an entry in an EntityCollection.changeState map\n */\nexport interface ChangeState<T> {\n changeType: ChangeType;\n originalValue?: T | undefined;\n}\n\n/**\n * Map of entity primary keys to entity ChangeStates.\n * Each entry represents an entity with unsaved changes.\n */\nexport type ChangeStateMap<T> = Dictionary<ChangeState<T>>;\n\n/**\n * Data and information about a collection of entities of a single type.\n * EntityCollections are maintained in the EntityCache within the ngrx store.\n */\nexport interface EntityCollection<T = any> extends EntityState<T> {\n /** Name of the entity type for this collection */\n entityName: string;\n /** A map of ChangeStates, keyed by id, for entities with unsaved changes */\n changeState: ChangeStateMap<T>;\n /** The user's current collection filter pattern */\n filter?: string;\n /** true if collection was ever filled by QueryAll; forced false if cleared */\n loaded: boolean;\n /** true when a query or save operation is in progress */\n loading: boolean;\n}\n","import { EntityAdapter, IdSelector, Update } from '@ngrx/entity';\n\nimport { ChangeType, EntityCollection } from './entity-collection';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityChangeTracker } from './entity-change-tracker';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * The default implementation of EntityChangeTracker with\n * methods for tracking, committing, and reverting/undoing unsaved entity changes.\n * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.\n * See EntityChangeTracker docs.\n */\nexport class EntityChangeTrackerBase<T> implements EntityChangeTracker<T> {\n constructor(\n private adapter: EntityAdapter<T>,\n private selectId: IdSelector<T>\n ) {\n /** Extract the primary key (id); default to `id` */\n this.selectId = selectId || defaultSelectId;\n }\n\n // #region commit methods\n /**\n * Commit all changes as when the collection has been completely reloaded from the server.\n * Harmless when there are no entity changes to commit.\n * @param collection The entity collection\n */\n commitAll(collection: EntityCollection<T>): EntityCollection<T> {\n return Object.keys(collection.changeState).length === 0\n ? collection\n : { ...collection, changeState: {} };\n }\n\n /**\n * Commit changes for the given entities as when they have been refreshed from the server.\n * Harmless when there are no entity changes to commit.\n * @param entityOrIdList The entities to clear tracking or their ids.\n * @param collection The entity collection\n */\n commitMany(\n entityOrIdList: (number | string | T)[],\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n if (entityOrIdList == null || entityOrIdList.length === 0) {\n return collection; // nothing to commit\n }\n let didMutate = false;\n const changeState = entityOrIdList.reduce((chgState, entityOrId) => {\n const id =\n typeof entityOrId === 'object'\n ? this.selectId(entityOrId)\n : (entityOrId as string | number);\n if (chgState[id]) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id];\n }\n return chgState;\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Commit changes for the given entity as when it have been refreshed from the server.\n * Harmless when no entity changes to commit.\n * @param entityOrId The entity to clear tracking or its id.\n * @param collection The entity collection\n */\n commitOne(\n entityOrId: number | string | T,\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return entityOrId == null\n ? collection\n : this.commitMany([entityOrId], collection);\n }\n\n // #endregion commit methods\n\n // #region merge query\n /**\n * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.\n * @param entities Entities returned from querying the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.PreserveChanges.\n * @returns The merged EntityCollection.\n */\n mergeQueryResults(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.PreserveChanges,\n mergeStrategy\n );\n }\n // #endregion merge query results\n\n // #region merge save results\n /**\n * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param entities Entities returned from saving new entities to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveAdds(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.OverwriteChanges,\n mergeStrategy\n );\n }\n\n /**\n * Merge successful result of deleting entities on the server that have the given primary keys\n * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.\n * @param entities keys primary keys of the entities to remove/delete.\n * @param collection The entity collection\n * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveDeletes(\n keys: (number | string)[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n mergeStrategy =\n mergeStrategy == null ? MergeStrategy.OverwriteChanges : mergeStrategy;\n // same logic for all non-ignore merge strategies: always clear (commit) the changes\n const deleteIds = keys as string[]; // make TypeScript happy\n collection =\n mergeStrategy === MergeStrategy.IgnoreChanges\n ? collection\n : this.commitMany(deleteIds, collection);\n return this.adapter.removeMany(deleteIds, collection);\n }\n\n /**\n * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param updateResponseData Entity response data returned from saving updated entities to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @param [skipUnchanged] True means skip update if server didn't change it. False by default.\n * If the update was optimistic and the server didn't make more changes of its own\n * then the updates are already in the collection and shouldn't make them again.\n * @returns The merged EntityCollection.\n */\n mergeSaveUpdates(\n updateResponseData: UpdateResponseData<T>[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy,\n skipUnchanged = false\n ): EntityCollection<T> {\n if (updateResponseData == null || updateResponseData.length === 0) {\n return collection; // nothing to merge.\n }\n\n let didMutate = false;\n let changeState = collection.changeState;\n mergeStrategy =\n mergeStrategy == null ? MergeStrategy.OverwriteChanges : mergeStrategy;\n let updates: Update<T>[];\n\n switch (mergeStrategy) {\n case MergeStrategy.IgnoreChanges:\n updates = filterChanged(updateResponseData);\n return this.adapter.updateMany(updates, collection);\n\n case MergeStrategy.OverwriteChanges:\n changeState = updateResponseData.reduce((chgState, update) => {\n const oldId = update.id;\n const change = chgState[oldId];\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[oldId];\n }\n return chgState;\n }, collection.changeState);\n\n collection = didMutate ? { ...collection, changeState } : collection;\n\n updates = filterChanged(updateResponseData);\n return this.adapter.updateMany(updates, collection);\n\n case MergeStrategy.PreserveChanges: {\n const updateableEntities = [] as UpdateResponseData<T>[];\n changeState = updateResponseData.reduce((chgState, update) => {\n const oldId = update.id;\n const change = chgState[oldId];\n if (change) {\n // Tracking a change so update original value but not the current value\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n const newId = this.selectId(update.changes as T);\n const oldChangeState = change;\n // If the server changed the id, register the new \"originalValue\" under the new id\n // and remove the change tracked under the old id.\n if (newId !== oldId) {\n delete chgState[oldId];\n }\n const newOrigValue = {\n ...(oldChangeState!.originalValue as any),\n ...(update.changes as any),\n };\n (chgState as any)[newId] = {\n ...oldChangeState,\n originalValue: newOrigValue,\n };\n } else {\n updateableEntities.push(update);\n }\n return chgState;\n }, collection.changeState);\n collection = didMutate ? { ...collection, changeState } : collection;\n\n updates = filterChanged(updateableEntities);\n return this.adapter.updateMany(updates, collection);\n }\n }\n\n /**\n * Conditionally keep only those updates that have additional server changes.\n * (e.g., for optimistic saves because they updates are already in the current collection)\n * Strip off the `changed` property.\n * @responseData Entity response data from server.\n * May be an UpdateResponseData<T>, a subclass of Update<T> with a 'changed' flag.\n * @returns Update<T> (without the changed flag)\n */\n function filterChanged(responseData: UpdateResponseData<T>[]): Update<T>[] {\n if (skipUnchanged === true) {\n // keep only those updates that the server changed (knowable if is UpdateResponseData<T>)\n responseData = responseData.filter((r) => r.changed === true);\n }\n // Strip unchanged property from responseData, leaving just the pure Update<T>\n // TODO: Remove? probably not necessary as the Update isn't stored and adapter will ignore `changed`.\n return responseData.map((r) => ({ id: r.id as any, changes: r.changes }));\n }\n }\n\n /**\n * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param entities Entities returned from saving upserts to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveUpserts(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.OverwriteChanges,\n mergeStrategy\n );\n }\n // #endregion merge save results\n\n // #region query & save helpers\n /**\n *\n * @param entities Entities to merge\n * @param collection Collection into which entities are merged\n * @param defaultMergeStrategy How to merge when action's MergeStrategy is unspecified\n * @param [mergeStrategy] The action's MergeStrategy\n */\n private mergeServerUpserts(\n entities: T[],\n collection: EntityCollection<T>,\n defaultMergeStrategy: MergeStrategy,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (entities == null || entities.length === 0) {\n return collection; // nothing to merge.\n }\n\n let didMutate = false;\n let changeState = collection.changeState;\n mergeStrategy =\n mergeStrategy == null ? defaultMergeStrategy : mergeStrategy;\n\n switch (mergeStrategy) {\n case MergeStrategy.IgnoreChanges:\n return this.adapter.upsertMany(entities, collection);\n\n case MergeStrategy.OverwriteChanges:\n collection = this.adapter.upsertMany(entities, collection);\n\n changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n const change = chgState[id];\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id];\n }\n return chgState;\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n\n case MergeStrategy.PreserveChanges: {\n const upsertEntities = [] as T[];\n changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n const change = chgState[id];\n if (change) {\n if (!didMutate) {\n chgState = {\n ...chgState,\n [id]: {\n ...chgState[id]!,\n originalValue: entity,\n },\n };\n didMutate = true;\n }\n } else {\n upsertEntities.push(entity);\n }\n return chgState;\n }, collection.changeState);\n\n collection = this.adapter.upsertMany(upsertEntities, collection);\n return didMutate ? { ...collection, changeState } : collection;\n }\n }\n }\n // #endregion query & save helpers\n\n // #region track methods\n /**\n * Track multiple entities before adding them to the collection.\n * Does NOT add to the collection (the reducer's job).\n * @param entities The entities to add. They must all have their ids.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackAddMany(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n entities == null ||\n entities.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity add requires a key to be tracked`\n );\n }\n const trackedChange = chgState[id];\n\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n chgState[id] = { changeType: ChangeType.Added };\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before adding it to the collection.\n * Does NOT add to the collection (the reducer's job).\n * @param entity The entity to add. It must have an id.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n * If not specified, implementation supplies a default strategy.\n */\n trackAddOne(\n entity: T,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return entity == null\n ? collection\n : this.trackAddMany([entity], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before removing them with the intention of deleting them on the server.\n * Does NOT remove from the collection (the reducer's job).\n * @param keys The primary keys of the entities to delete.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackDeleteMany(\n keys: (number | string)[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n keys == null ||\n keys.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = keys.reduce((chgState, id) => {\n const originalValue = entityMap[id];\n if (originalValue) {\n const trackedChange = chgState[id];\n if (trackedChange) {\n if (trackedChange.changeType === ChangeType.Added) {\n // Special case: stop tracking an added entity that you delete\n // The caller must also detect this, remove it immediately from the collection\n // and skip attempt to delete on the server.\n cloneChgStateOnce();\n delete chgState[id];\n } else if (trackedChange.changeType === ChangeType.Updated) {\n // Special case: switch change type from Updated to Deleted.\n cloneChgStateOnce();\n chgState[id] = { ...chgState[id], changeType: ChangeType.Deleted };\n }\n } else {\n // Start tracking this entity\n cloneChgStateOnce();\n chgState[id] = { changeType: ChangeType.Deleted, originalValue };\n }\n }\n return chgState;\n\n function cloneChgStateOnce() {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n }\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before it is removed with the intention of deleting it on the server.\n * Does NOT remove from the collection (the reducer's job).\n * @param key The primary key of the entity to delete.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackDeleteOne(\n key: number | string,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return key == null\n ? collection\n : this.trackDeleteMany([key], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before updating them in the collection.\n * Does NOT update the collection (the reducer's job).\n * @param updates The entities to update.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpdateMany(\n updates: Update<T>[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n updates == null ||\n updates.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = updates.reduce((chgState, update) => {\n const { id, changes: entity } = update;\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity update requires a key to be tracked`\n );\n }\n const originalValue = entityMap[id];\n // Only track if it is in the collection. Silently ignore if it is not.\n // @ngrx/entity adapter would also silently ignore.\n // Todo: should missing update entity really be reported as an error?\n if (originalValue) {\n const trackedChange = chgState[id];\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n chgState[id] = { changeType: ChangeType.Updated, originalValue };\n }\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before updating it in the collection.\n * Does NOT update the collection (the reducer's job).\n * @param update The entity to update.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpdateOne(\n update: Update<T>,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return update == null\n ? collection\n : this.trackUpdateMany([update], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before upserting (adding and updating) them to the collection.\n * Does NOT update the collection (the reducer's job).\n * @param entities The entities to add or update. They must be complete entities with ids.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpsertMany(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n entities == null ||\n entities.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity upsert requires a key to be tracked`\n );\n }\n const trackedChange = chgState[id];\n\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n\n const originalValue = entityMap[id];\n chgState[id] =\n originalValue == null\n ? { changeType: ChangeType.Added }\n : { changeType: ChangeType.Updated, originalValue };\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before upsert (adding and updating) it to the collection.\n * Does NOT update the collection (the reducer's job).\n * @param entities The entity to add or update. It must be a complete entity with its id.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpsertOne(\n entity: T,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return entity == null\n ? collection\n : this.trackUpsertMany([entity], collection, mergeStrategy);\n }\n // #endregion track methods\n\n // #region undo methods\n /**\n * Revert the unsaved changes for all collection.\n * Harmless when there are no entity changes to undo.\n * @param collection The entity collection\n */\n undoAll(collection: EntityCollection<T>): EntityCollection<T> {\n const ids = Object.keys(collection.changeState);\n\n const { remove, upsert } = ids.reduce(\n (acc, id) => {\n const changeState = acc.chgState[id]!;\n switch (changeState.changeType) {\n case ChangeType.Added:\n acc.remove.push(id);\n break;\n case ChangeType.Deleted:\n const removed = changeState!.originalValue;\n if (removed) {\n acc.upsert.push(removed);\n }\n break;\n case ChangeType.Updated:\n acc.upsert.push(changeState!.originalValue!);\n break;\n }\n return acc;\n },\n // entitiesToUndo\n {\n remove: [] as (number | string)[],\n upsert: [] as T[],\n chgState: collection.changeState,\n }\n );\n\n collection = this.adapter.removeMany(remove as string[], collection);\n collection = this.adapter.upsertMany(upsert, collection);\n\n return { ...collection, changeState: {} };\n }\n\n /**\n * Revert the unsaved changes for the given entities.\n * Harmless when there are no entity changes to undo.\n * @param entityOrIdList The entities to revert or their ids.\n * @param collection The entity collection\n */\n undoMany(\n entityOrIdList: (number | string | T)[],\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n if (entityOrIdList == null || entityOrIdList.length === 0) {\n return collection; // nothing to undo\n }\n let didMutate = false;\n\n const { changeState, remove, upsert } = entityOrIdList.reduce(\n (acc, entityOrId) => {\n let chgState = acc.changeState;\n const id =\n typeof entityOrId === 'object'\n ? this.selectId(entityOrId)\n : (entityOrId as string | number);\n const change = chgState[id]!;\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id]; // clear tracking of this entity\n acc.changeState = chgState;\n switch (change.changeType) {\n case ChangeType.Added:\n acc.remove.push(id);\n break;\n case ChangeType.Deleted:\n const removed = change!.originalValue;\n if (removed) {\n acc.upsert.push(removed);\n }\n break;\n case ChangeType.Updated:\n acc.upsert.push(change!.originalValue!);\n break;\n }\n }\n return acc;\n },\n // entitiesToUndo\n {\n remove: [] as (number | string)[],\n upsert: [] as T[],\n changeState: collection.changeState,\n }\n );\n\n collection = this.adapter.removeMany(remove as string[], collection);\n collection = this.adapter.upsertMany(upsert, collection);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Revert the unsaved changes for the given entity.\n * Harmless when there are no entity changes to undo.\n * @param entityOrId The entity to revert or its id.\n * @param collection The entity collection\n */\n undoOne(\n entityOrId: number | string | T,\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return entityOrId == null\n ? collection\n : this.undoMany([entityOrId], collection);\n }\n // #endregion undo methods\n}\n","import { Injectable } from '@angular/core';\nimport { EntityAdapter, IdSelector, Update } from '@ngrx/entity';\nimport {\n ChangeStateMap,\n ChangeType,\n EntityCollection,\n} from './entity-collection';\nimport { EntityChangeTrackerBase } from './entity-change-tracker-base';\nimport { toUpdateFactory } from '../utils/utilities';\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionDataServiceError } from '../dataservices/data-service-error';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityChangeTracker } from './entity-change-tracker';\nimport { EntityDefinition } from '../entity-metadata/entity-definition';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport { EntityOp } from '../actions/entity-op';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Map of {EntityOp} to reducer method for the operation.\n * If an operation is missing, caller should return the collection for that reducer.\n */\nexport interface EntityCollectionReducerMethodMap<T> {\n [method: string]: (\n collection: EntityCollection<T>,\n action: EntityAction\n ) => EntityCollection<T>;\n}\n\n/**\n * Base implementation of reducer methods for an entity collection.\n */\nexport class EntityCollectionReducerMethods<T> {\n protected adapter: EntityAdapter<T>;\n protected guard: EntityActionGuard<T>;\n /** True if this collection tracks unsaved changes */\n protected isChangeTracking: boolean;\n\n /** Extract the primary key (id); default to `id` */\n selectId: IdSelector<T>;\n\n /**\n * Track changes to entities since the last query or save\n * Can revert some or all of those changes\n */\n entityChangeTracker: EntityChangeTracker<T>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `id`: the primary key and\n * `changes`: the entity (or partial entity of changes).\n */\n protected toUpdate: (entity: Partial<T>) => Update<T>;\n\n /**\n * Dictionary of the {EntityCollectionReducerMethods} for this entity type,\n * keyed by the {EntityOp}\n */\n readonly methods: EntityCollectionReducerMethodMap<T> = {\n [EntityOp.CANCEL_PERSIST]: this.cancelPersist.bind(this),\n\n [EntityOp.QUERY_ALL]: this.queryAll.bind(this),\n [EntityOp.QUERY_ALL_ERROR]: this.queryAllError.bind(this),\n [EntityOp.QUERY_ALL_SUCCESS]: this.queryAllSuccess.bind(this),\n\n [EntityOp.QUERY_BY_KEY]: this.queryByKey.bind(this),\n [EntityOp.QUERY_BY_KEY_ERROR]: this.queryByKeyError.bind(this),\n [EntityOp.QUERY_BY_KEY_SUCCESS]: this.queryByKeySuccess.bind(this),\n\n [EntityOp.QUERY_LOAD]: this.queryLoad.bind(this),\n [EntityOp.QUERY_LOAD_ERROR]: this.queryLoadError.bind(this),\n [EntityOp.QUERY_LOAD_SUCCESS]: this.queryLoadSuccess.bind(this),\n\n [EntityOp.QUERY_MANY]: this.queryMany.bind(this),\n [EntityOp.QUERY_MANY_ERROR]: this.queryManyError.bind(this),\n [EntityOp.QUERY_MANY_SUCCESS]: this.queryManySuccess.bind(this),\n\n [EntityOp.SAVE_ADD_MANY]: this.saveAddMany.bind(this),\n [EntityOp.SAVE_ADD_MANY_ERROR]: this.saveAddManyError.bind(this),\n [EntityOp.SAVE_ADD_MANY_SUCCESS]: this.saveAddManySuccess.bind(this),\n\n [EntityOp.SAVE_ADD_ONE]: this.saveAddOne.bind(this),\n [EntityOp.SAVE_ADD_ONE_ERROR]: this.saveAddOneError.bind(this),\n [EntityOp.SAVE_ADD_ONE_SUCCESS]: this.saveAddOneSuccess.bind(this),\n\n [EntityOp.SAVE_DELETE_MANY]: this.saveDeleteMany.bind(this),\n [EntityOp.SAVE_DELETE_MANY_ERROR]: this.saveDeleteManyError.bind(this),\n [EntityOp.SAVE_DELETE_MANY_SUCCESS]: this.saveDeleteManySuccess.bind(this),\n\n [EntityOp.SAVE_DELETE_ONE]: this.saveDeleteOne.bind(this),\n [EntityOp.SAVE_DELETE_ONE_ERROR]: this.saveDeleteOneError.bind(this),\n [EntityOp.SAVE_DELETE_ONE_SUCCESS]: this.saveDeleteOneSuccess.bind(this),\n\n [EntityOp.SAVE_UPDATE_MANY]: this.saveUpdateMany.bind(this),\n [EntityOp.SAVE_UPDATE_MANY_ERROR]: this.saveUpdateManyError.bind(this),\n [EntityOp.SAVE_UPDATE_MANY_SUCCESS]: this.saveUpdateManySuccess.bind(this),\n\n [EntityOp.SAVE_UPDATE_ONE]: this.saveUpdateOne.bind(this),\n [EntityOp.SAVE_UPDATE_ONE_ERROR]: this.saveUpdateOneError.bind(this),\n [EntityOp.SAVE_UPDATE_ONE_SUCCESS]: this.saveUpdateOneSuccess.bind(this),\n\n [EntityOp.SAVE_UPSERT_MANY]: this.saveUpsertMany.bind(this),\n [EntityOp.SAVE_UPSERT_MANY_ERROR]: this.saveUpsertManyError.bind(this),\n [EntityOp.SAVE_UPSERT_MANY_SUCCESS]: this.saveUpsertManySuccess.bind(this),\n\n [EntityOp.SAVE_UPSERT_ONE]: this.saveUpsertOne.bind(this),\n [EntityOp.SAVE_UPSERT_ONE_ERROR]: this.saveUpsertOneError.bind(this),\n [EntityOp.SAVE_UPSERT_ONE_SUCCESS]: this.saveUpsertOneSuccess.bind(this),\n\n // Do nothing on save errors except turn the loading flag off.\n // See the ChangeTrackerMetaReducers\n // Or the app could listen for those errors and do something\n\n /// cache only operations ///\n\n [EntityOp.ADD_ALL]: this.addAll.bind(this),\n [EntityOp.ADD_MANY]: this.addMany.bind(this),\n [EntityOp.ADD_ONE]: this.addOne.bind(this),\n\n [EntityOp.REMOVE_ALL]: this.removeAll.bind(this),\n [EntityOp.REMOVE_MANY]: this.removeMany.bind(this),\n [EntityOp.REMOVE_ONE]: this.removeOne.bind(this),\n\n [EntityOp.UPDATE_MANY]: this.updateMany.bind(this),\n [EntityOp.UPDATE_ONE]: this.updateOne.bind(this),\n\n [EntityOp.UPSERT_MANY]: this.upsertMany.bind(this),\n [EntityOp.UPSERT_ONE]: this.upsertOne.bind(this),\n\n [EntityOp.COMMIT_ALL]: this.commitAll.bind(this),\n [EntityOp.COMMIT_MANY]: this.commitMany.bind(this),\n [EntityOp.COMMIT_ONE]: this.commitOne.bind(this),\n [EntityOp.UNDO_ALL]: this.undoAll.bind(this),\n [EntityOp.UNDO_MANY]: this.undoMany.bind(this),\n [EntityOp.UNDO_ONE]: this.undoOne.bind(this),\n\n [EntityOp.SET_CHANGE_STATE]: this.setChangeState.bind(this),\n [EntityOp.SET_COLLECTION]: this.setCollection.bind(this),\n [EntityOp.SET_FILTER]: this.setFilter.bind(this),\n [EntityOp.SET_LOADED]: this.setLoaded.bind(this),\n [EntityOp.SET_LOADING]: this.setLoading.bind(this),\n };\n\n constructor(\n public entityName: string,\n public definition: EntityDefinition<T>,\n /*\n * Track changes to entities since the last query or save\n * Can revert some or all of those changes\n */\n entityChangeTracker?: EntityChangeTracker<T>\n ) {\n this.adapter = definition.entityAdapter;\n this.isChangeTracking = definition.noChangeTracking !== true;\n this.selectId = definition.selectId;\n\n this.guard = new EntityActionGuard(entityName, this.selectId);\n this.toUpdate = toUpdateFactory(this.selectId);\n\n this.entityChangeTracker =\n entityChangeTracker ||\n new EntityChangeTrackerBase<T>(this.adapter, this.selectId);\n }\n\n /** Cancel a persistence operation */\n protected cancelPersist(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n // #region query operations\n\n protected queryAll(collection: EntityCollection<T>): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryAllError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Merges query results per the MergeStrategy\n * Sets loading flag to false and loaded flag to true.\n */\n protected queryAllSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n return {\n ...this.entityChangeTracker.mergeQueryResults(\n data,\n collection,\n mergeStrategy\n ),\n loaded: true,\n loading: false,\n };\n }\n\n protected queryByKey(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryByKeyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n protected queryByKeySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection =\n data == null\n ? collection\n : this.entityChangeTracker.mergeQueryResults(\n [data],\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n\n protected queryLoad(collection: EntityCollection<T>): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryLoadError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Replaces all entities in the collection\n * Sets loaded flag to true, loading flag to false,\n * and clears changeState for the entire collection.\n */\n protected queryLoadSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n return {\n ...this.adapter.setAll(data, collection),\n loading: false,\n loaded: true,\n changeState: {},\n };\n }\n\n protected queryMany(\n collection: EntityCollection<T>,\n action: EntityAction\n ): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n protected queryManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n return {\n ...this.entityChangeTracker.mergeQueryResults(\n data,\n collection,\n mergeStrategy\n ),\n loaded: true,\n loading: false,\n };\n }\n // #endregion query operations\n\n // #region save operations\n\n // #region saveAddMany\n /**\n * Save multiple new entities.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entities should be added.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of entities.\n * If saving optimistically, the entities must have their keys.\n */\n protected saveAddMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entities = this.guard.mustBeEntities(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddMany(\n entities,\n collection,\n mergeStrategy\n );\n collection = this.adapter.addMany(entities, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new entities failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new entities are not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveAddManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddMany\n\n // #region saveAddOne\n /**\n * Successfully saved new entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field),\n * and may even return additional new entities.\n * Therefore, upsert the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n * Note: saveAddManySuccess differs from saveAddOneSuccess when optimistic.\n * saveAddOneSuccess updates (not upserts) with the lone entity from the server.\n * There is no effect if the entity is not already in cache.\n * saveAddManySuccess will add an entity if it is not found in cache.\n */\n protected saveAddManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n if (this.isOptimistic(action)) {\n collection = this.entityChangeTracker.mergeSaveUpserts(\n entities,\n collection,\n mergeStrategy\n );\n } else {\n collection = this.entityChangeTracker.mergeSaveAdds(\n entities,\n collection,\n mergeStrategy\n );\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddMany\n\n // #region saveAddOne\n /**\n * Save a new entity.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add entity immediately.\n * @param collection The collection to which the entity should be added.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an entity.\n * If saving optimistically, the entity must have a key.\n */\n protected saveAddOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entity = this.guard.mustBeEntity(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddOne(\n entity,\n collection,\n mergeStrategy\n );\n collection = this.adapter.addOne(entity, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save a new entity failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity is not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entity is in the collection and\n * you may need to compensate for the error.\n */\n protected saveAddOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved a new entity to the server.\n * If saved pessimistically, add the entity from the server to the collection.\n * If saved optimistically, the added entity is already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned value (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveAddOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n if (this.isOptimistic(action)) {\n const update: UpdateResponseData<T> = this.toUpdate(entity);\n // Always update the cache with added entity returned from server\n collection = this.entityChangeTracker.mergeSaveUpdates(\n [update],\n collection,\n mergeStrategy,\n false /*never skip*/\n );\n } else {\n collection = this.entityChangeTracker.mergeSaveAdds(\n [entity],\n collection,\n mergeStrategy\n );\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddOne\n\n // #region saveAddMany\n // TODO MANY\n // #endregion saveAddMany\n\n // #region saveDeleteOne\n /**\n * Delete an entity from the server by key and remove it from the collection (if present).\n * If the entity is an unsaved new entity, remove it from the collection immediately\n * and skip the server delete request.\n * An optimistic save removes an existing entity from the collection immediately;\n * a pessimistic save removes it after the server confirms successful delete.\n * @param collection Will remove the entity with this key from the collection.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be a primary key or an entity with a key;\n * this reducer extracts the key from the entity.\n */\n protected saveDeleteOne(\n collection: EntityCollection<T>,\n action: EntityAction<number | string | T>\n ): EntityCollection<T> {\n const toDelete = this.extractData(action);\n const deleteId =\n typeof toDelete === 'object'\n ? this.selectId(toDelete)\n : (toDelete as string | number);\n const change = collection.changeState[deleteId];\n // If entity is already tracked ...\n if (change) {\n if (change.changeType === ChangeType.Added) {\n // Remove the added entity immediately and forget about its changes (via commit).\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n // Should not waste effort trying to delete on the server because it can't be there.\n action.payload.skip = true;\n } else {\n // Re-track it as a delete, even if tracking is turned off for this call.\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection\n );\n }\n }\n\n // If optimistic delete, track current state and remove immediately.\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection,\n mergeStrategy\n );\n collection = this.adapter.removeOne(deleteId as string, collection);\n }\n\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to delete the entity on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity could still be in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the entity is not in the collection and\n * you may need to compensate for the error.\n */\n protected saveDeleteOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully deleted entity on the server. The key of the deleted entity is in the action payload data.\n * If saved pessimistically, if the entity is still in the collection it will be removed.\n * If saved optimistically, the entity has already been removed from the collection.\n */\n protected saveDeleteOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n const deleteId = this.extractData(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveDeletes(\n [deleteId],\n collection,\n mergeStrategy\n );\n } else {\n // Pessimistic: ignore mergeStrategy. Remove entity from the collection and from change tracking.\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveDeleteOne\n\n // #region saveDeleteMany\n /**\n * Delete multiple entities from the server by key and remove them from the collection (if present).\n * Removes unsaved new entities from the collection immediately\n * but the id is still sent to the server for deletion even though the server will not find that entity.\n * Therefore, the server must be willing to ignore a delete request for an entity it cannot find.\n * An optimistic save removes existing entities from the collection immediately;\n * a pessimistic save removes them after the server confirms successful delete.\n * @param collection Removes entities from this collection.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of primary keys or entities with a key;\n * this reducer extracts the key from the entity.\n */\n protected saveDeleteMany(\n collection: EntityCollection<T>,\n action: EntityAction<(number | string | T)[]>\n ): EntityCollection<T> {\n const deleteIds = this.extractData(action).map((d) =>\n typeof d === 'object' ? this.selectId(d) : (d as string | number)\n );\n deleteIds.forEach((deleteId) => {\n const change = collection.changeState[deleteId];\n // If entity is already tracked ...\n if (change) {\n if (change.changeType === ChangeType.Added) {\n // Remove the added entity immediately and forget about its changes (via commit).\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n // Should not waste effort trying to delete on the server because it can't be there.\n action.payload.skip = true;\n } else {\n // Re-track it as a delete, even if tracking is turned off for this call.\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection\n );\n }\n }\n });\n // If optimistic delete, track current state and remove immediately.\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteMany(\n deleteIds,\n collection,\n mergeStrategy\n );\n collection = this.adapter.removeMany(deleteIds as string[], collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to delete the entities on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entities could still be in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the entities are not in the collection and\n * you may need to compensate for the error.\n */\n protected saveDeleteManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully deleted entities on the server. The keys of the deleted entities are in the action payload data.\n * If saved pessimistically, entities that are still in the collection will be removed.\n * If saved optimistically, the entities have already been removed from the collection.\n */\n protected saveDeleteManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<(number | string)[]>\n ): EntityCollection<T> {\n const deleteIds = this.extractData(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveDeletes(\n deleteIds,\n collection,\n mergeStrategy\n );\n } else {\n // Pessimistic: ignore mergeStrategy. Remove entity from the collection and from change tracking.\n collection = this.adapter.removeMany(deleteIds as string[], collection);\n collection = this.entityChangeTracker.commitMany(deleteIds, collection);\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveDeleteMany\n\n // #region saveUpdateOne\n /**\n * Save an update to an existing entity.\n * If saving pessimistically, update the entity in the collection after the server confirms success.\n * If saving optimistically, update the entity immediately, before the save request.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an {Update<T>}\n */\n protected saveUpdateOne(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>>\n ): EntityCollection<T> {\n const update = this.guard.mustBeUpdate(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateOne(\n update,\n collection,\n mergeStrategy\n );\n collection = this.adapter.updateOne(update, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to update the entity on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity in the collection is in the pre-save state\n * you may not have to compensate for the error.\n * If saved optimistically, the entity in the collection was updated\n * and you may need to compensate for the error.\n */\n protected saveUpdateOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved the updated entity to the server.\n * If saved pessimistically, update the entity in the collection with data from the server.\n * If saved optimistically, the entity was already updated in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned value (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic update to avoid this risk.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic, and\n * the update data which, must be an UpdateResponse<T> that corresponds to the Update sent to the server.\n * You must include an UpdateResponse even if the save was optimistic,\n * to ensure that the change tracking is properly reset.\n */\n protected saveUpdateOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<UpdateResponseData<T>>\n ): EntityCollection<T> {\n const update = this.guard.mustBeUpdateResponse(action);\n const isOptimistic = this.isOptimistic(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveUpdates(\n [update],\n collection,\n mergeStrategy,\n isOptimistic /*skip unchanged if optimistic */\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpdateOne\n\n // #region saveUpdateMany\n /**\n * Save updated entities.\n * If saving pessimistically, update the entities in the collection after the server confirms success.\n * If saving optimistically, update the entities immediately, before the save request.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an array of {Update<T>}.\n */\n protected saveUpdateMany(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>[]>\n ): EntityCollection<T> {\n const updates = this.guard.mustBeUpdates(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateMany(\n updates,\n collection,\n mergeStrategy\n );\n collection = this.adapter.updateMany(updates, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to update entities on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entities in the collection are in the pre-save state\n * you may not have to compensate for the error.\n * If saved optimistically, the entities in the collection were updated\n * and you may need to compensate for the error.\n */\n protected saveUpdateManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved the updated entities to the server.\n * If saved pessimistically, the entities in the collection will be updated with data from the server.\n * If saved optimistically, the entities in the collection were already updated.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic update to avoid this risk.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an array of UpdateResponse<T>.\n * You must include an UpdateResponse for every Update sent to the server,\n * even if the save was optimistic, to ensure that the change tracking is properly reset.\n */\n protected saveUpdateManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<UpdateResponseData<T>[]>\n ): EntityCollection<T> {\n const updates = this.guard.mustBeUpdateResponses(action);\n const isOptimistic = this.isOptimistic(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveUpdates(\n updates,\n collection,\n mergeStrategy,\n false /* never skip */\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpdateMany\n\n // #region saveUpsertOne\n /**\n * Save a new or existing entity.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entity should be upserted.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be a whole entity.\n * If saving optimistically, the entity must have its key.\n */\n protected saveUpsertOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entity = this.guard.mustBeEntity(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertOne(\n entity,\n collection,\n mergeStrategy\n );\n collection = this.adapter.upsertOne(entity, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new or existing entity failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new or updated entity is not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveUpsertOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved new or existing entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveUpsertOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n // Always update the cache with upserted entities returned from server\n collection = this.entityChangeTracker.mergeSaveUpserts(\n [entity],\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpsertOne\n\n // #region saveUpsertMany\n /**\n * Save multiple new or existing entities.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entities should be upserted.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of whole entities.\n * If saving optimistically, the entities must have their keys.\n */\n protected saveUpsertMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entities = this.guard.mustBeEntities(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertMany(\n entities,\n collection,\n mergeStrategy\n );\n collection = this.adapter.upsertMany(entities, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new or existing entities failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new entities are not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveUpsertManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved new or existing entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveUpsertManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n // Always update the cache with upserted entities returned from server\n collection = this.entityChangeTracker.mergeSaveUpserts(\n entities,\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpsertMany\n\n // #endregion save operations\n\n // #region cache-only operations\n\n /**\n * Replaces all entities in the collection\n * Sets loaded flag to true.\n * Merges query results, preserving unsaved changes\n */\n protected addAll(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const entities = this.guard.mustBeEntities(action);\n return {\n ...this.adapter.setAll(entities, collection),\n loading: false,\n loaded: true,\n changeState: {},\n };\n }\n\n protected addMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddMany(\n entities,\n collection,\n mergeStrategy\n );\n return this.adapter.addMany(entities, collection);\n }\n\n protected addOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddOne(\n entity,\n collection,\n mergeStrategy\n );\n return this.adapter.addOne(entity, collection);\n }\n\n protected removeMany(\n collection: EntityCollection<T>,\n action: EntityAction<number[] | string[]>\n ): EntityCollection<T> {\n // payload must be entity keys\n const keys = this.guard.mustBeKeys(action) as string[];\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteMany(\n keys,\n collection,\n mergeStrategy\n );\n return this.adapter.removeMany(keys, collection);\n }\n\n protected removeOne(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n // payload must be entity key\n const key = this.guard.mustBeKey(action) as string;\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteOne(\n key,\n collection,\n mergeStrategy\n );\n return this.adapter.removeOne(key, collection);\n }\n\n protected removeAll(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n return {\n ...this.adapter.removeAll(collection),\n loaded: false, // Only REMOVE_ALL sets loaded to false\n loading: false,\n changeState: {}, // Assume clearing the collection and not trying to delete all entities\n };\n }\n\n protected updateMany(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>[]>\n ): EntityCollection<T> {\n // payload must be an array of `Updates<T>`, not entities\n const updates = this.guard.mustBeUpdates(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateMany(\n updates,\n collection,\n mergeStrategy\n );\n return this.adapter.updateMany(updates, collection);\n }\n\n protected updateOne(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>>\n ): EntityCollection<T> {\n // payload must be an `Update<T>`, not an entity\n const update = this.guard.mustBeUpdate(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateOne(\n update,\n collection,\n mergeStrategy\n );\n return this.adapter.updateOne(update, collection);\n }\n\n protected upsertMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n // <v6: payload must be an array of `Updates<T>`, not entities\n // v6+: payload must be an array of T\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertMany(\n entities,\n collection,\n mergeStrategy\n );\n return this.adapter.upsertMany(entities, collection);\n }\n\n protected upsertOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n // <v6: payload must be an `Update<T>`, not an entity\n // v6+: payload must be a T\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertOne(\n entity,\n collection,\n mergeStrategy\n );\n return this.adapter.upsertOne(entity, collection);\n }\n\n protected commitAll(collection: EntityCollection<T>) {\n return this.entityChangeTracker.commitAll(collection);\n }\n\n protected commitMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n return this.entityChangeTracker.commitMany(\n this.extractData(action),\n collection\n );\n }\n\n protected commitOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n return this.entityChangeTracker.commitOne(\n this.extractData(action),\n collection\n );\n }\n\n protected undoAll(collection: EntityCollection<T>) {\n return this.entityChangeTracker.undoAll(collection);\n }\n\n protected undoMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n return this.entityChangeTracker.undoMany(\n this.extractData(action),\n collection\n );\n }\n\n protected undoOne(collection: EntityCollection<T>, action: EntityAction<T>) {\n return this.entityChangeTracker.undoOne(\n this.extractData(action),\n collection\n );\n }\n\n /** Dangerous: Completely replace the collection's ChangeState. Use rarely and wisely. */\n protected setChangeState(\n collection: EntityCollection<T>,\n action: EntityAction<ChangeStateMap<T>>\n ) {\n const changeState = this.extractData(action);\n return collection.changeState === changeState\n ? collection\n : { ...collection, changeState };\n }\n\n /**\n * Dangerous: Completely replace the collection.\n * Primarily for testing and rehydration from local storage.\n * Use rarely and wisely.\n */\n protected setCollection(\n collection: EntityCollection<T>,\n action: EntityAction<EntityCollection<T>>\n ) {\n const newCollection = this.extractData(action);\n return collection === newCollection ? collection : newCollection;\n }\n\n protected setFilter(\n collection: EntityCollection<T>,\n action: EntityAction<any>\n ): EntityCollection<T> {\n const filter = this.extractData(action);\n return collection.filter === filter\n ? collection\n : { ...collection, filter };\n }\n\n protected setLoaded(\n collection: EntityCollection<T>,\n action: EntityAction<boolean>\n ): EntityCollection<T> {\n const loaded = this.extractData(action) === true || false;\n return collection.loaded === loaded\n ? collection\n : { ...collection, loaded };\n }\n\n protected setLoading(\n collection: EntityCollection<T>,\n action: EntityAction<boolean>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, this.extractData(action));\n }\n\n protected setLoadingFalse(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, false);\n }\n\n protected setLoadingTrue(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, true);\n }\n\n /** Set the collection's loading flag */\n protected setLoadingFlag(collection: EntityCollection<T>, loading: boolean) {\n loading = loading === true ? true : false;\n return collection.loading === loading\n ? collection\n : { ...collection, loading };\n }\n // #endregion Cache-only operations\n\n // #region helpers\n /** Safely extract data from the EntityAction payload */\n protected extractData<D = any>(action: EntityAction<D>): D {\n return (action.payload && action.payload.data) as D;\n }\n\n /** Safely extract MergeStrategy from EntityAction. Set to IgnoreChanges if collection itself is not tracked. */\n protected extractMergeStrategy(action: EntityAction) {\n // If not tracking this collection, always ignore changes\n return this.isChangeTracking\n ? action.payload && action.payload.mergeStrategy\n : MergeStrategy.IgnoreChanges;\n }\n\n protected isOptimistic(action: EntityAction) {\n return action.payload && action.payload.isOptimistic === true;\n }\n\n // #endregion helpers\n}\n\n/**\n * Creates {EntityCollectionReducerMethods} for a given entity type.\n */\n@Injectable()\nexport class EntityCollectionReducerMethodsFactory {\n constructor(private entityDefinitionService: EntityDefinitionService) {}\n\n /** Create the {EntityCollectionReducerMethods} for the named entity type */\n create<T>(entityName: string): EntityCollectionReducerMethodMap<T> {\n const definition =\n this.entityDefinitionService.getDefinition<T>(entityName);\n const methodsClass = new EntityCollectionReducerMethods(\n entityName,\n definition\n );\n\n return methodsClass.methods;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCollection } from './entity-collection';\nimport { EntityCollectionReducerMethodsFactory } from './entity-collection-reducer-methods';\n\nexport type EntityCollectionReducer<T = any> = (\n collection: EntityCollection<T>,\n action: EntityAction\n) => EntityCollection<T>;\n\n/** Create a default reducer for a specific entity collection */\n@Injectable()\nexport class EntityCollectionReducerFactory {\n constructor(private methodsFactory: EntityCollectionReducerMethodsFactory) {}\n\n /** Create a default reducer for a collection of entities of T */\n create<T = any>(entityName: string): EntityCollectionReducer<T> {\n const methods = this.methodsFactory.create<T>(entityName);\n\n /** Perform Actions against a particular entity collection in the EntityCache */\n return function entityCollectionReducer(\n collection: EntityCollection<T>,\n action: EntityAction\n ): EntityCollection<T> {\n const reducerMethod = methods[action.payload.entityOp];\n return reducerMethod ? reducerMethod(collection, action) : collection;\n };\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { compose, MetaReducer } from '@ngrx/store';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCollection } from './entity-collection';\nimport { ENTITY_COLLECTION_META_REDUCERS } from './constants';\nimport {\n EntityCollectionReducer,\n EntityCollectionReducerFactory,\n} from './entity-collection-reducer';\n\n/** A hash of EntityCollectionReducers */\nexport interface EntityCollectionReducers {\n [entity: string]: EntityCollectionReducer<any>;\n}\n\n/**\n * Registry of entity types and their previously-constructed reducers.\n * Can create a new CollectionReducer, which it registers for subsequent use.\n */\n@Injectable()\nexport class EntityCollectionReducerRegistry {\n protected entityCollectionReducers: EntityCollectionReducers = {};\n private entityCollectionMetaReducer: MetaReducer<\n EntityCollection,\n EntityAction\n >;\n\n constructor(\n private entityCollectionReducerFactory: EntityCollectionReducerFactory,\n @Optional()\n @Inject(ENTITY_COLLECTION_META_REDUCERS)\n entityCollectionMetaReducers?: MetaReducer<EntityCollection, EntityAction>[]\n ) {\n // eslint-disable-next-line prefer-spread\n this.entityCollectionMetaReducer = compose.apply(\n null,\n entityCollectionMetaReducers || []\n ) as any;\n }\n\n /**\n * Get the registered EntityCollectionReducer<T> for this entity type or create one and register it.\n * @param entityName Name of the entity type for this reducer\n */\n getOrCreateReducer<T>(entityName: string): EntityCollectionReducer<T> {\n let reducer: EntityCollectionReducer<T> =\n this.entityCollectionReducers[entityName];\n\n if (!reducer) {\n reducer = this.entityCollectionReducerFactory.create<T>(entityName);\n reducer = this.registerReducer<T>(entityName, reducer);\n this.entityCollectionReducers[entityName] = reducer;\n }\n return reducer;\n }\n\n /**\n * Register an EntityCollectionReducer for an entity type\n * @param entityName - the name of the entity type\n * @param reducer - reducer for that entity type\n *\n * Examples:\n * registerReducer('Hero', myHeroReducer);\n * registerReducer('Villain', myVillainReducer);\n */\n registerReducer<T>(\n entityName: string,\n reducer: EntityCollectionReducer<T>\n ): EntityCollectionReducer<T> {\n reducer = this.entityCollectionMetaReducer(reducer as any);\n return (this.entityCollectionReducers[entityName.trim()] = reducer);\n }\n\n /**\n * Register a batch of EntityCollectionReducers.\n * @param reducers - reducers to merge into existing reducers\n *\n * Examples:\n * registerReducers({\n * Hero: myHeroReducer,\n * Villain: myVillainReducer\n * });\n */\n registerReducers(reducers: EntityCollectionReducers) {\n const keys = reducers ? Object.keys(reducers) : [];\n keys.forEach((key) => this.registerReducer(key, reducers[key]));\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action, ActionReducer } from '@ngrx/store';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from './entity-cache';\n\nimport {\n EntityCacheAction,\n ClearCollections,\n LoadCollections,\n MergeQuerySet,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\n\nimport {\n ChangeSetOperation,\n ChangeSetItem,\n} from '../actions/entity-cache-change-set';\n\nimport { EntityCollection } from './entity-collection';\nimport { EntityCollectionCreator } from './entity-collection-creator';\nimport { EntityCollectionReducerRegistry } from './entity-collection-reducer-registry';\nimport { EntityOp } from '../actions/entity-op';\nimport { Logger } from '../utils/interfaces';\nimport { MergeStrategy } from '../actions/merge-strategy';\n\n/**\n * Creates the EntityCacheReducer via its create() method\n */\n@Injectable()\nexport class EntityCacheReducerFactory {\n constructor(\n private entityCollectionCreator: EntityCollectionCreator,\n private entityCollectionReducerRegistry: EntityCollectionReducerRegistry,\n private logger: Logger\n ) {}\n\n /**\n * Create the @ngrx/data entity cache reducer which either responds to entity cache level actions\n * or (more commonly) delegates to an EntityCollectionReducer based on the action.payload.entityName.\n */\n create(): ActionReducer<EntityCache, Action> {\n // This technique ensures a named function appears in the debugger\n return entityCacheReducer.bind(this);\n\n function entityCacheReducer(\n this: EntityCacheReducerFactory,\n entityCache: EntityCache = {},\n action: { type: string; payload?: any }\n ): EntityCache {\n // EntityCache actions\n switch (action.type) {\n case EntityCacheAction.CLEAR_COLLECTIONS: {\n return this.clearCollectionsReducer(\n entityCache,\n action as ClearCollections\n );\n }\n\n case EntityCacheAction.LOAD_COLLECTIONS: {\n return this.loadCollectionsReducer(\n entityCache,\n action as LoadCollections\n );\n }\n\n case EntityCacheAction.MERGE_QUERY_SET: {\n return this.mergeQuerySetReducer(\n entityCache,\n action as MergeQuerySet\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES: {\n return this.saveEntitiesReducer(entityCache, action as SaveEntities);\n }\n\n case EntityCacheAction.SAVE_ENTITIES_CANCEL: {\n return this.saveEntitiesCancelReducer(\n entityCache,\n action as SaveEntitiesCancel\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES_ERROR: {\n return this.saveEntitiesErrorReducer(\n entityCache,\n action as SaveEntitiesError\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES_SUCCESS: {\n return this.saveEntitiesSuccessReducer(\n entityCache,\n action as SaveEntitiesSuccess\n );\n }\n\n case EntityCacheAction.SET_ENTITY_CACHE: {\n // Completely replace the EntityCache. Be careful!\n return action.payload.cache;\n }\n }\n\n // Apply entity collection reducer if this is a valid EntityAction for a collection\n const payload = action.payload;\n if (payload && payload.entityName && payload.entityOp && !payload.error) {\n return this.applyCollectionReducer(entityCache, action as EntityAction);\n }\n\n // Not a valid EntityAction\n return entityCache;\n }\n }\n\n /**\n * Reducer to clear multiple collections at the same time.\n * @param entityCache the entity cache\n * @param action a ClearCollections action whose payload is an array of collection names.\n * If empty array, does nothing. If no array, clears all the collections.\n */\n protected clearCollectionsReducer(\n entityCache: EntityCache,\n action: ClearCollections\n ) {\n // eslint-disable-next-line prefer-const\n let { collections, tag } = action.payload;\n const entityOp = EntityOp.REMOVE_ALL;\n\n if (!collections) {\n // Collections is not defined. Clear all collections.\n collections = Object.keys(entityCache);\n }\n\n entityCache = collections.reduce((newCache, entityName) => {\n const payload = { entityName, entityOp };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n /**\n * Reducer to load collection in the form of a hash of entity data for multiple collections.\n * @param entityCache the entity cache\n * @param action a LoadCollections action whose payload is the QuerySet of entity collections to load\n */\n protected loadCollectionsReducer(\n entityCache: EntityCache,\n action: LoadCollections\n ) {\n const { collections, tag } = action.payload;\n const entityOp = EntityOp.ADD_ALL;\n const entityNames = Object.keys(collections);\n entityCache = entityNames.reduce((newCache, entityName) => {\n const payload = {\n entityName,\n entityOp,\n data: collections[entityName],\n };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n /**\n * Reducer to merge query sets in the form of a hash of entity data for multiple collections.\n * @param entityCache the entity cache\n * @param action a MergeQuerySet action with the query set and a MergeStrategy\n */\n protected mergeQuerySetReducer(\n entityCache: EntityCache,\n action: MergeQuerySet\n ) {\n // eslint-disable-next-line prefer-const\n let { mergeStrategy, querySet, tag } = action.payload;\n mergeStrategy =\n mergeStrategy === null ? MergeStrategy.PreserveChanges : mergeStrategy;\n const entityOp = EntityOp.QUERY_MANY_SUCCESS;\n\n const entityNames = Object.keys(querySet);\n entityCache = entityNames.reduce((newCache, entityName) => {\n const payload = {\n entityName,\n entityOp,\n data: querySet[entityName],\n mergeStrategy,\n };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n // #region saveEntities reducers\n protected saveEntitiesReducer(\n entityCache: EntityCache,\n action: SaveEntities\n ) {\n const { changeSet, correlationId, isOptimistic, mergeStrategy, tag } =\n action.payload;\n\n try {\n changeSet.changes.forEach((item) => {\n const entityName = item.entityName;\n const payload = {\n entityName,\n entityOp: getEntityOp(item),\n data: item.entities,\n correlationId,\n isOptimistic,\n mergeStrategy,\n tag,\n };\n\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n entityCache = this.applyCollectionReducer(entityCache, act);\n if (act.payload.error) {\n throw act.payload.error;\n }\n });\n } catch (error: any) {\n action.payload.error = error;\n }\n\n return entityCache;\n function getEntityOp(item: ChangeSetItem) {\n switch (item.op) {\n case ChangeSetOperation.Add:\n return EntityOp.SAVE_ADD_MANY;\n case ChangeSetOperation.Delete:\n return EntityOp.SAVE_DELETE_MANY;\n case ChangeSetOperation.Update:\n return EntityOp.SAVE_UPDATE_MANY;\n case ChangeSetOperation.Upsert:\n return EntityOp.SAVE_UPSERT_MANY;\n }\n }\n }\n\n protected saveEntitiesCancelReducer(\n entityCache: EntityCache,\n action: SaveEntitiesCancel\n ) {\n // This implementation can only clear the loading flag for the collections involved\n // If the save was optimistic, you'll have to compensate to fix the cache as you think necessary\n return this.clearLoadingFlags(\n entityCache,\n action.payload.entityNames || []\n );\n }\n\n protected saveEntitiesErrorReducer(\n entityCache: EntityCache,\n action: SaveEntitiesError\n ) {\n const originalAction = action.payload.originalAction;\n const originalChangeSet = originalAction.payload.changeSet;\n\n // This implementation can only clear the loading flag for the collections involved\n // If the save was optimistic, you'll have to compensate to fix the cache as you think necessary\n const entityNames = originalChangeSet.changes.map(\n (item) => item.entityName\n );\n return this.clearLoadingFlags(entityCache, entityNames);\n }\n\n protected saveEntitiesSuccessReducer(\n entityCache: EntityCache,\n action: SaveEntitiesSuccess\n ) {\n const { changeSet, correlationId, isOptimistic, mergeStrategy, tag } =\n action.payload;\n\n changeSet.changes.forEach((item) => {\n const entityName = item.entityName;\n const payload = {\n entityName,\n entityOp: getEntityOp(item),\n data: item.entities,\n correlationId,\n isOptimistic,\n mergeStrategy,\n tag,\n };\n\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n entityCache = this.applyCollectionReducer(entityCache, act);\n });\n\n return entityCache;\n function getEntityOp(item: ChangeSetItem) {\n switch (item.op) {\n case ChangeSetOperation.Add:\n return EntityOp.SAVE_ADD_MANY_SUCCESS;\n case ChangeSetOperation.Delete:\n return EntityOp.SAVE_DELETE_MANY_SUCCESS;\n case ChangeSetOperation.Update:\n return EntityOp.SAVE_UPDATE_MANY_SUCCESS;\n case ChangeSetOperation.Upsert:\n return EntityOp.SAVE_UPSERT_MANY_SUCCESS;\n }\n }\n }\n // #endregion saveEntities reducers\n\n // #region helpers\n /** Apply reducer for the action's EntityCollection (if the action targets a collection) */\n private applyCollectionReducer(\n cache: EntityCache = {},\n action: EntityAction\n ) {\n const entityName = action.payload.entityName;\n const collection = cache[entityName];\n const reducer =\n this.entityCollectionReducerRegistry.getOrCreateReducer(entityName);\n\n let newCollection: EntityCollection;\n try {\n newCollection = collection\n ? reducer(collection, action)\n : reducer(this.entityCollectionCreator.create(entityName), action);\n } catch (error: any) {\n this.logger.error(error);\n action.payload.error = error;\n }\n\n return action.payload.error || collection === newCollection!\n ? cache\n : { ...cache, [entityName]: newCollection! };\n }\n\n /** Ensure loading is false for every collection in entityNames */\n private clearLoadingFlags(entityCache: EntityCache, entityNames: string[]) {\n let isMutated = false;\n entityNames.forEach((entityName) => {\n const collection = entityCache[entityName];\n if (collection.loading) {\n if (!isMutated) {\n entityCache = { ...entityCache };\n isMutated = true;\n }\n entityCache[entityName] = { ...collection, loading: false };\n }\n });\n return entityCache;\n }\n // #endregion helpers\n}\n","import { Injectable } from '@angular/core';\nimport { Logger } from './interfaces';\n\n@Injectable()\nexport class DefaultLogger implements Logger {\n error(message?: any, extra?: any) {\n if (message) {\n extra ? console.error(message, extra) : console.error(message);\n }\n }\n\n log(message?: any, extra?: any) {\n if (message) {\n extra ? console.log(message, extra) : console.log(message);\n }\n }\n\n warn(message?: any, extra?: any) {\n if (message) {\n extra ? console.warn(message, extra) : console.warn(message);\n }\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { EntityPluralNames, PLURAL_NAMES_TOKEN } from './interfaces';\n\nconst uncountable = [\n // 'sheep',\n // 'fish',\n // 'deer',\n // 'moose',\n // 'rice',\n // 'species',\n 'equipment',\n 'information',\n 'money',\n 'series',\n];\n\n@Injectable()\nexport class DefaultPluralizer {\n pluralNames: EntityPluralNames = {};\n\n constructor(\n @Optional()\n @Inject(PLURAL_NAMES_TOKEN)\n pluralNames: EntityPluralNames[]\n ) {\n // merge each plural names object\n if (pluralNames) {\n pluralNames.forEach((pn) => this.registerPluralNames(pn));\n }\n }\n\n /**\n * Pluralize a singular name using common English language pluralization rules\n * Examples: \"company\" -> \"companies\", \"employee\" -> \"employees\", \"tax\" -> \"taxes\"\n */\n pluralize(name: string) {\n const plural = this.pluralNames[name];\n if (plural) {\n return plural;\n }\n // singular and plural are the same\n if (uncountable.indexOf(name.toLowerCase()) >= 0) {\n return name;\n // vowel + y\n } else if (/[aeiou]y$/.test(name)) {\n return name + 's';\n // consonant + y\n } else if (name.endsWith('y')) {\n return name.substring(0, name.length - 1) + 'ies';\n // endings typically pluralized with 'es'\n } else if (/[s|ss|sh|ch|x|z]$/.test(name)) {\n return name + 'es';\n } else {\n return name + 's';\n }\n }\n\n /**\n * Register a mapping of entity type name to the entity name's plural\n * @param pluralNames {EntityPluralNames} plural names for entity types\n */\n registerPluralNames(pluralNames: EntityPluralNames): void {\n this.pluralNames = { ...this.pluralNames, ...(pluralNames || {}) };\n }\n}\n","/**\n Client-side id-generators\n\n These GUID utility functions are not used by @ngrx/data itself at this time.\n They are included as candidates for generating persistable correlation ids if that becomes desirable.\n They are also safe for generating unique entity ids on the client.\n\n Note they produce 32-character hexadecimal UUID strings,\n not the 128-bit representation found in server-side languages and databases.\n\n These utilities are experimental and may be withdrawn or replaced in future.\n*/\n\n/**\n * Creates a Universally Unique Identifier (AKA GUID)\n */\nfunction getUuid() {\n // The original implementation is based on this SO answer:\n // http://stackoverflow.com/a/2117523/200253\n return 'xxxxxxxxxx4xxyxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0,\n // eslint-disable-next-line no-bitwise\n v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/** Alias for getUuid(). Compare with getGuidComb(). */\nexport function getGuid() {\n return getUuid();\n}\n\n/**\n * Creates a sortable, pseudo-GUID (globally unique identifier)\n * whose trailing 6 bytes (12 hex digits) are time-based\n * Start either with the given getTime() value, seedTime,\n * or get the current time in ms.\n *\n * @param seed {number} - optional seed for reproducible time-part\n */\nexport function getGuidComb(seed?: number) {\n // Each new Guid is greater than next if more than 1ms passes\n // See http://thatextramile.be/blog/2009/05/using-the-guidcomb-identifier-strategy\n // Based on breeze.core.getUuid which is based on this StackOverflow answer\n // http://stackoverflow.com/a/2117523/200253\n //\n // Convert time value to hex: n.toString(16)\n // Make sure it is 6 bytes long: ('00'+ ...).slice(-12) ... from the rear\n // Replace LAST 6 bytes (12 hex digits) of regular Guid (that's where they sort in a Db)\n //\n // Play with this in jsFiddle: http://jsfiddle.net/wardbell/qS8aN/\n const timePart = ('00' + (seed || new Date().getTime()).toString(16)).slice(\n -12\n );\n return (\n 'xxxxxxxxxx4xxyxxx'.replace(/[xy]/g, function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0,\n v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }) + timePart\n );\n}\n\n// Sort comparison value that's good enough\nexport function guidComparer(l: string, r: string) {\n const lLow = l.slice(-12);\n const rLow = r.slice(-12);\n return lLow !== rLow\n ? lLow < rLow\n ? -1\n : +(lLow !== rLow)\n : l < r\n ? -1\n : +(l !== r);\n}\n","import {\n ENVIRONMENT_INITIALIZER,\n EnvironmentProviders,\n inject,\n InjectionToken,\n makeEnvironmentProviders,\n Provider,\n} from '@angular/core';\nimport {\n ActionReducerFactory,\n combineReducers,\n MetaReducer,\n ReducerManager,\n} from '@ngrx/store';\nimport { EffectSources } from '@ngrx/effects';\nimport { EntityDispatcherDefaultOptions } from './dispatchers/entity-dispatcher-default-options';\nimport { EntityActionFactory } from './actions/entity-action-factory';\nimport { EntityCacheDispatcher } from './dispatchers/entity-cache-dispatcher';\nimport { entityCacheSelectorProvider } from './selectors/entity-cache-selector';\nimport { EntityCollectionServiceElementsFactory } from './entity-services/entity-collection-service-elements-factory';\nimport { EntityCollectionServiceFactory } from './entity-services/entity-collection-service-factory';\nimport { EntityServices } from './entity-services/entity-services';\nimport { EntityCollectionCreator } from './reducers/entity-collection-creator';\nimport { EntityCollectionReducerFactory } from './reducers/entity-collection-reducer';\nimport { EntityCollectionReducerMethodsFactory } from './reducers/entity-collection-reducer-methods';\nimport { EntityCollectionReducerRegistry } from './reducers/entity-collection-reducer-registry';\nimport { EntityDispatcherFactory } from './dispatchers/entity-dispatcher-factory';\nimport { EntityDefinitionService } from './entity-metadata/entity-definition.service';\nimport { EntityCacheReducerFactory } from './reducers/entity-cache-reducer';\nimport {\n ENTITY_CACHE_META_REDUCERS,\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n ENTITY_COLLECTION_META_REDUCERS,\n INITIAL_ENTITY_CACHE_STATE,\n} from './reducers/constants';\nimport { EntityCache } from './reducers/entity-cache';\nimport { EntitySelectorsFactory } from './selectors/entity-selectors';\nimport { EntitySelectors$Factory } from './selectors/entity-selectors$';\nimport { EntityServicesBase } from './entity-services/entity-services-base';\nimport { EntityServicesElements } from './entity-services/entity-services-elements';\nimport { DefaultLogger } from './utils/default-logger';\nimport { Logger, PLURAL_NAMES_TOKEN, Pluralizer } from './utils/interfaces';\nimport { CorrelationIdGenerator } from './utils/correlation-id-generator';\nimport { ENTITY_METADATA_TOKEN } from './entity-metadata/entity-metadata';\nimport { DefaultDataServiceFactory } from './dataservices/default-data.service';\nimport {\n DefaultPersistenceResultHandler,\n PersistenceResultHandler,\n} from './dataservices/persistence-result-handler.service';\nimport {\n DefaultHttpUrlGenerator,\n HttpUrlGenerator,\n} from './dataservices/http-url-generator';\nimport { EntityCacheDataService } from './dataservices/entity-cache-data.service';\nimport { EntityDataService } from './dataservices/entity-data.service';\nimport { EntityCacheEffects } from './effects/entity-cache-effects';\nimport { EntityEffects } from './effects/entity-effects';\nimport { DefaultPluralizer } from './utils/default-pluralizer';\nimport { EntityDataModuleConfig } from './entity-data-config';\n\nexport const BASE_ENTITY_DATA_PROVIDERS: Provider[] = [\n CorrelationIdGenerator,\n EntityDispatcherDefaultOptions,\n EntityActionFactory,\n EntityCacheDispatcher,\n EntityCacheReducerFactory,\n entityCacheSelectorProvider,\n EntityCollectionCreator,\n EntityCollectionReducerFactory,\n EntityCollectionReducerMethodsFactory,\n EntityCollectionReducerRegistry,\n EntityCollectionServiceElementsFactory,\n EntityCollectionServiceFactory,\n EntityDefinitionService,\n EntityDispatcherFactory,\n EntitySelectorsFactory,\n EntitySelectors$Factory,\n EntityServicesElements,\n { provide: ENTITY_CACHE_NAME_TOKEN, useValue: ENTITY_CACHE_NAME },\n { provide: EntityServices, useClass: EntityServicesBase },\n { provide: Logger, useClass: DefaultLogger },\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => initializeBaseEntityData(),\n },\n];\n\nfunction initializeBaseEntityData(): void {\n const reducerManager = inject(ReducerManager);\n const entityCacheReducerFactory = inject(EntityCacheReducerFactory);\n const entityCacheName = inject(ENTITY_CACHE_NAME_TOKEN, {\n optional: true,\n });\n const initialStateOrFn = inject(INITIAL_ENTITY_CACHE_STATE, {\n optional: true,\n });\n const metaReducersOrTokens = inject<\n Array<MetaReducer<EntityCache> | InjectionToken<MetaReducer<EntityCache>>>\n >(ENTITY_CACHE_META_REDUCERS, {\n optional: true,\n });\n\n // Add the @ngrx/data feature to the Store's features\n const key = entityCacheName || ENTITY_CACHE_NAME;\n const metaReducers = (metaReducersOrTokens || []).map((mr) => {\n return mr instanceof InjectionToken ? inject(mr) : mr;\n });\n const initialState =\n typeof initialStateOrFn === 'function'\n ? initialStateOrFn()\n : initialStateOrFn;\n\n const entityCacheFeature = {\n key,\n reducers: entityCacheReducerFactory.create(),\n reducerFactory: combineReducers as ActionReducerFactory<EntityCache>,\n initialState: initialState || {},\n metaReducers: metaReducers,\n };\n reducerManager.addFeature(entityCacheFeature);\n}\n\nexport const ENTITY_DATA_EFFECTS_PROVIDERS: Provider[] = [\n DefaultDataServiceFactory,\n EntityCacheDataService,\n EntityDataService,\n EntityCacheEffects,\n EntityEffects,\n { provide: HttpUrlGenerator, useClass: DefaultHttpUrlGenerator },\n {\n provide: PersistenceResultHandler,\n useClass: DefaultPersistenceResultHandler,\n },\n { provide: Pluralizer, useClass: DefaultPluralizer },\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => initializeEntityDataEffects(),\n },\n];\n\nfunction initializeEntityDataEffects(): void {\n const effectsSources = inject(EffectSources);\n const entityCacheEffects = inject(EntityCacheEffects);\n const entityEffects = inject(EntityEffects);\n\n effectsSources.addEffects(entityCacheEffects);\n effectsSources.addEffects(entityEffects);\n}\n\nexport function provideEntityDataConfig(\n config: EntityDataModuleConfig\n): Provider[] {\n return [\n {\n provide: ENTITY_CACHE_META_REDUCERS,\n useValue: config.entityCacheMetaReducers\n ? config.entityCacheMetaReducers\n : [],\n },\n {\n provide: ENTITY_COLLECTION_META_REDUCERS,\n useValue: config.entityCollectionMetaReducers\n ? config.entityCollectionMetaReducers\n : [],\n },\n {\n provide: PLURAL_NAMES_TOKEN,\n multi: true,\n useValue: config.pluralNames ? config.pluralNames : {},\n },\n {\n provide: ENTITY_METADATA_TOKEN,\n multi: true,\n useValue: config.entityMetadata ? config.entityMetadata : [],\n },\n ];\n}\n\n/**\n * Sets up base entity data providers with entity config.\n * This function should to be used at the root level.\n *\n * @usageNotes\n *\n * ### Providing entity data with effects\n *\n * When used with `withEffects` feature, the `provideEntityData` function is\n * an alternative to `EntityDataModule.forRoot`\n *\n * ```ts\n * import { provideStore } from '@ngrx/store';\n * import { provideEffects } from '@ngrx/effects';\n * import {\n * EntityMetadataMap,\n * provideEntityData,\n * withEffects,\n * } from '@ngrx/data';\n *\n * const entityMetadata: EntityMetadataMap = {\n * Hero: {},\n * Villain: {},\n * };\n * const pluralNames = { Hero: 'Heroes' };\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideStore(),\n * provideEffects(),\n * provideEntityData({ entityMetadata, pluralNames }, withEffects()),\n * ],\n * });\n * ```\n *\n * ### Providing entity data without effects\n *\n * When used without `withEffects` feature, the `provideEntityData` function is\n * an alternative to `EntityDataModuleWithoutEffects.forRoot`.\n *\n * ```ts\n * import { provideStore } from '@ngrx/store';\n * import { EntityMetadataMap, provideEntityData } from '@ngrx/data';\n *\n * const entityMetadata: EntityMetadataMap = {\n * Musician: {},\n * Song: {},\n * };\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideStore(),\n * provideEntityData({ entityMetadata }),\n * ],\n * });\n * ```\n *\n */\nexport function provideEntityData(\n config: EntityDataModuleConfig,\n ...features: EntityDataFeature[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n BASE_ENTITY_DATA_PROVIDERS,\n provideEntityDataConfig(config),\n ...features.map((feature) => feature.ɵproviders),\n ]);\n}\n\nenum EntityDataFeatureKind {\n WithEffects,\n}\n\ninterface EntityDataFeature {\n ɵkind: EntityDataFeatureKind;\n ɵproviders: Provider[];\n}\n\n/**\n * Registers entity data effects and provides HTTP data services.\n *\n * @see `provideEntityData`\n */\nexport function withEffects(): EntityDataFeature {\n return {\n ɵkind: EntityDataFeatureKind.WithEffects,\n ɵproviders: [ENTITY_DATA_EFFECTS_PROVIDERS],\n };\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EntityDataModuleConfig } from './entity-data-config';\nimport {\n BASE_ENTITY_DATA_PROVIDERS,\n provideEntityDataConfig,\n} from './provide-entity-data';\n\n/**\n * Module without effects or dataservices which means no HTTP calls\n * This module helpful for internal testing.\n * Also helpful for apps that handle server access on their own and\n * therefore opt-out of @ngrx/effects for entities\n */\n@NgModule({\n providers: [BASE_ENTITY_DATA_PROVIDERS],\n})\nexport class EntityDataModuleWithoutEffects {\n static forRoot(\n config: EntityDataModuleConfig\n ): ModuleWithProviders<EntityDataModuleWithoutEffects> {\n return {\n ngModule: EntityDataModuleWithoutEffects,\n providers: [provideEntityDataConfig(config)],\n };\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EntityDataModuleConfig } from './entity-data-config';\nimport { EntityDataModuleWithoutEffects } from './entity-data-without-effects.module';\nimport {\n ENTITY_DATA_EFFECTS_PROVIDERS,\n provideEntityDataConfig,\n} from './provide-entity-data';\n\n/**\n * entity-data main module includes effects and HTTP data services\n * Configure with `forRoot`.\n * No `forFeature` yet.\n */\n@NgModule({\n imports: [EntityDataModuleWithoutEffects],\n providers: [ENTITY_DATA_EFFECTS_PROVIDERS],\n})\nexport class EntityDataModule {\n static forRoot(\n config: EntityDataModuleConfig\n ): ModuleWithProviders<EntityDataModule> {\n return {\n ngModule: EntityDataModule,\n providers: [provideEntityDataConfig(config)],\n };\n }\n}\n","// actions\nexport { EntityActionFactory } from './actions/entity-action-factory';\nexport { EntityActionGuard } from './actions/entity-action-guard';\nexport { ofEntityOp, ofEntityType } from './actions/entity-action-operators';\nexport {\n EntityAction,\n EntityActionOptions,\n EntityActionPayload,\n} from './actions/entity-action';\nexport {\n EntityCacheAction,\n EntityCacheQuerySet,\n ClearCollections,\n LoadCollections,\n MergeQuerySet,\n SetEntityCache,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesCanceled,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from './actions/entity-cache-action';\nexport {\n ChangeSetOperation,\n ChangeSetAdd,\n ChangeSetDelete,\n ChangeSetUpdate,\n ChangeSetUpsert,\n ChangeSetItem,\n ChangeSet,\n ChangeSetItemFactory,\n changeSetItemFactory,\n excludeEmptyChangeSetItems,\n} from './actions/entity-cache-change-set';\n\nexport {\n EntityOp,\n OP_SUCCESS,\n OP_ERROR,\n makeErrorOp,\n makeSuccessOp,\n} from './actions/entity-op';\nexport { MergeStrategy } from './actions/merge-strategy';\nexport { UpdateResponseData } from './actions/update-response-data';\n\n// // dataservices\nexport { DataServiceError } from './dataservices/data-service-error';\nexport { EntityActionDataServiceError } from './dataservices/data-service-error';\nexport { DefaultDataServiceConfig } from './dataservices/default-data-service-config';\nexport { DefaultDataService } from './dataservices/default-data.service';\nexport { DefaultDataServiceFactory } from './dataservices/default-data.service';\nexport { EntityCacheDataService } from './dataservices/entity-cache-data.service';\nexport { EntityDataService } from './dataservices/entity-data.service';\nexport { EntityHttpResourceUrls } from './dataservices/http-url-generator';\nexport { HttpResourceUrls } from './dataservices/http-url-generator';\nexport { HttpUrlGenerator } from './dataservices/http-url-generator';\nexport { DefaultHttpUrlGenerator } from './dataservices/http-url-generator';\nexport { normalizeRoot } from './dataservices/http-url-generator';\nexport {\n EntityCollectionDataService,\n HttpMethods,\n RequestData,\n QueryParams,\n} from './dataservices/interfaces';\nexport {\n PersistenceResultHandler,\n DefaultPersistenceResultHandler,\n} from './dataservices/persistence-result-handler.service';\n\n// // dispatchers\nexport { EntityCacheDispatcher } from './dispatchers/entity-cache-dispatcher';\nexport {\n EntityServerCommands,\n EntityCacheCommands,\n EntityCommands,\n} from './dispatchers/entity-commands';\nexport { EntityDispatcherBase } from './dispatchers/entity-dispatcher-base';\nexport { EntityDispatcherDefaultOptions } from './dispatchers/entity-dispatcher-default-options';\nexport { EntityDispatcherFactory } from './dispatchers/entity-dispatcher-factory';\nexport {\n EntityDispatcher,\n PersistanceCanceled,\n} from './dispatchers/entity-dispatcher';\n\n// // effects\nexport { EntityCacheEffects } from './effects/entity-cache-effects';\nexport { persistOps, EntityEffects } from './effects/entity-effects';\n\n// // entity-metadata\nexport {\n EntityDefinitions,\n EntityDefinitionService,\n} from './entity-metadata/entity-definition.service';\nexport {\n EntityDefinition,\n createEntityDefinition,\n} from './entity-metadata/entity-definition';\nexport {\n EntityFilterFn,\n PropsFilterFnFactory,\n} from './entity-metadata/entity-filters';\nexport {\n ENTITY_METADATA_TOKEN,\n EntityMetadata,\n EntityMetadataMap,\n} from './entity-metadata/entity-metadata';\n\n// // entity-services\nexport { EntityCollectionServiceBase } from './entity-services/entity-collection-service-base';\nexport {\n EntityCollectionServiceElements,\n EntityCollectionServiceElementsFactory,\n} from './entity-services/entity-collection-service-elements-factory';\nexport { EntityCollectionServiceFactory } from './entity-services/entity-collection-service-factory';\nexport { EntityCollectionService } from './entity-services/entity-collection-service';\nexport { EntityServicesBase } from './entity-services/entity-services-base';\nexport { EntityServicesElements } from './entity-services/entity-services-elements';\nexport {\n EntityServices,\n EntityCollectionServiceMap,\n} from './entity-services/entity-services';\n\n// // reducers\nexport {\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n ENTITY_CACHE_META_REDUCERS,\n ENTITY_COLLECTION_META_REDUCERS,\n INITIAL_ENTITY_CACHE_STATE,\n} from './reducers/constants';\nexport { EntityCacheReducerFactory } from './reducers/entity-cache-reducer';\nexport { EntityCache } from './reducers/entity-cache';\nexport { EntityChangeTrackerBase } from './reducers/entity-change-tracker-base';\nexport { EntityChangeTracker } from './reducers/entity-change-tracker';\nexport {\n EntityCollectionCreator,\n createEmptyEntityCollection,\n} from './reducers/entity-collection-creator';\nexport {\n EntityCollectionReducerMethodMap,\n EntityCollectionReducerMethods,\n EntityCollectionReducerMethodsFactory,\n} from './reducers/entity-collection-reducer-methods';\nexport {\n EntityCollectionReducers,\n EntityCollectionReducerRegistry,\n} from './reducers/entity-collection-reducer-registry';\nexport {\n EntityCollectionReducer,\n EntityCollectionReducerFactory,\n} from './reducers/entity-collection-reducer';\nexport {\n ChangeType,\n ChangeState,\n ChangeStateMap,\n EntityCollection,\n} from './reducers/entity-collection';\n\n// // selectors\nexport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n entityCacheSelectorProvider,\n EntityCacheSelector,\n createEntityCacheSelector,\n} from './selectors/entity-cache-selector';\nexport {\n CollectionSelectors,\n EntitySelectors,\n EntitySelectorsFactory,\n} from './selectors/entity-selectors';\nexport {\n EntitySelectors$,\n EntitySelectors$Factory,\n} from './selectors/entity-selectors$';\n\n// // Utils\nexport { CorrelationIdGenerator } from './utils/correlation-id-generator';\nexport { DefaultLogger } from './utils/default-logger';\nexport { DefaultPluralizer } from './utils/default-pluralizer';\nexport { getGuid, getGuidComb, guidComparer } from './utils/guid-fns';\nexport {\n Logger,\n EntityPluralNames,\n PLURAL_NAMES_TOKEN,\n Pluralizer,\n} from './utils/interfaces';\nexport {\n defaultSelectId,\n flattenArgs,\n toUpdateFactory,\n} from './utils/utilities';\n\n// // EntityDataConfig\nexport { EntityDataModuleConfig } from './entity-data-config';\n\n// // EntityDataModule\nexport { EntityDataModuleWithoutEffects } from './entity-data-without-effects.module';\nexport { EntityDataModule } from './entity-data.module';\n\n// // Standalone APIs\nexport { provideEntityData, withEffects } from './provide-entity-data';\n","/**\n * DO NOT EDIT\n *\n * This file is automatically generated at build\n */\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.Pluralizer","i2.HttpUrlGenerator","i3.DefaultDataServiceConfig","i1.EntityDefinitionService","i2","i1.DefaultDataServiceFactory","i1.Logger","i2.EntityActionFactory","i1.EntityActionFactory","i3.EntityDispatcherDefaultOptions","i4.CorrelationIdGenerator","i1.EntityDispatcherFactory","i2.EntityDefinitionService","i3.EntitySelectorsFactory","i4.EntitySelectors$Factory","i1.EntityCollectionServiceElementsFactory","i1.EntityCollectionServiceFactory","i2.EntityDispatcherFactory","i3.EntitySelectors$Factory","i4","i1.EntityServicesElements","i1.EntityCollectionReducerMethodsFactory","i1.EntityCollectionCreator","i2.EntityCollectionReducerRegistry","i3.Logger"],"mappings":";;;;;;;;;;;;;MASa,mBAAmB,CAAA;;AAwB9B,IAAA,MAAM,CACJ,aAA8C,EAC9C,QAAmB,EACnB,IAAQ,EACR,OAA6B,EAAA;AAE7B,QAAA,MAAM,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AAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA,EAAA;AAAhB,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,YAHjB,8BAA8B,CAAA,EAAA,CAAA,CAAA,EAAA;AAG7B,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,EAFhB,SAAA,EAAA,CAAC,6BAA6B,CAAC,YADhC,8BAA8B,CAAA,EAAA,CAAA,CAAA,EAAA;;2FAG7B,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,8BAA8B,CAAC;oBACzC,SAAS,EAAE,CAAC,6BAA6B,CAAC;AAC3C,iBAAA,CAAA;;;AChBD;;ACAA;;;;AAIG;;ACJH;;AAEG;;;;"}
1
+ {"version":3,"file":"ngrx-data.mjs","sources":["../../../../modules/data/src/actions/entity-action-factory.ts","../../../../modules/data/src/actions/entity-action-guard.ts","../../../../modules/data/src/utils/utilities.ts","../../../../modules/data/src/actions/entity-action-operators.ts","../../../../modules/data/src/actions/entity-cache-change-set.ts","../../../../modules/data/src/actions/merge-strategy.ts","../../../../modules/data/src/actions/entity-cache-action.ts","../../../../modules/data/src/actions/entity-op.ts","../../../../modules/data/src/dataservices/data-service-error.ts","../../../../modules/data/src/dataservices/default-data-service-config.ts","../../../../modules/data/src/utils/interfaces.ts","../../../../modules/data/src/dataservices/http-url-generator.ts","../../../../modules/data/src/dataservices/default-data.service.ts","../../../../modules/data/src/entity-metadata/entity-definition.ts","../../../../modules/data/src/entity-metadata/entity-metadata.ts","../../../../modules/data/src/entity-metadata/entity-definition.service.ts","../../../../modules/data/src/dataservices/entity-cache-data.service.ts","../../../../modules/data/src/dataservices/entity-data.service.ts","../../../../modules/data/src/dataservices/persistence-result-handler.service.ts","../../../../modules/data/src/dispatchers/entity-dispatcher.ts","../../../../modules/data/src/utils/correlation-id-generator.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-default-options.ts","../../../../modules/data/src/dispatchers/entity-cache-dispatcher.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-base.ts","../../../../modules/data/src/reducers/constants.ts","../../../../modules/data/src/selectors/entity-cache-selector.ts","../../../../modules/data/src/dispatchers/entity-dispatcher-factory.ts","../../../../modules/data/src/effects/entity-effects-scheduler.ts","../../../../modules/data/src/effects/entity-cache-effects.ts","../../../../modules/data/src/effects/entity-effects.ts","../../../../modules/data/src/entity-metadata/entity-filters.ts","../../../../modules/data/src/entity-services/entity-collection-service-base.ts","../../../../modules/data/src/reducers/entity-collection-creator.ts","../../../../modules/data/src/selectors/entity-selectors.ts","../../../../modules/data/src/selectors/entity-selectors$.ts","../../../../modules/data/src/entity-services/entity-collection-service-elements-factory.ts","../../../../modules/data/src/entity-services/entity-collection-service-factory.ts","../../../../modules/data/src/entity-services/entity-services-elements.ts","../../../../modules/data/src/entity-services/entity-services-base.ts","../../../../modules/data/src/entity-services/entity-services.ts","../../../../modules/data/src/reducers/entity-collection.ts","../../../../modules/data/src/reducers/entity-change-tracker-base.ts","../../../../modules/data/src/reducers/entity-collection-reducer-methods.ts","../../../../modules/data/src/reducers/entity-collection-reducer.ts","../../../../modules/data/src/reducers/entity-collection-reducer-registry.ts","../../../../modules/data/src/reducers/entity-cache-reducer.ts","../../../../modules/data/src/utils/default-logger.ts","../../../../modules/data/src/utils/default-pluralizer.ts","../../../../modules/data/src/utils/guid-fns.ts","../../../../modules/data/src/provide-entity-data.ts","../../../../modules/data/src/entity-data-without-effects.module.ts","../../../../modules/data/src/entity-data.module.ts","../../../../modules/data/src/index.ts","../../../../modules/data/index.ts","../../../../modules/data/ngrx-data.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { EntityOp } from './entity-op';\nimport {\n EntityAction,\n EntityActionOptions,\n EntityActionPayload,\n} from './entity-action';\n@Injectable()\nexport class EntityActionFactory {\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param entityName Name of the entity type\n * @param entityOp Operation to perform (EntityOp)\n * @param [data] data for the operation\n * @param [options] additional options\n */\n create<P = any>(\n entityName: string,\n entityOp: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param payload Defines the EntityAction and its options\n */\n create<P = any>(payload: EntityActionPayload<P>): EntityAction<P>;\n\n // polymorphic create for the two signatures\n create<P = any>(\n nameOrPayload: EntityActionPayload<P> | string,\n entityOp?: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n const payload: EntityActionPayload<P> =\n typeof nameOrPayload === 'string'\n ? ({\n ...(options || {}),\n entityName: nameOrPayload,\n entityOp,\n data,\n } as EntityActionPayload<P>)\n : nameOrPayload;\n return this.createCore(payload);\n }\n\n /**\n * Create an EntityAction to perform an operation (op) for a particular entity type\n * (entityName) with optional data and other optional flags\n * @param payload Defines the EntityAction and its options\n */\n protected createCore<P = any>(payload: EntityActionPayload<P>) {\n const { entityName, entityOp, tag } = payload;\n if (!entityName) {\n throw new Error('Missing entity name for new action');\n }\n if (entityOp == null) {\n throw new Error('Missing EntityOp for new action');\n }\n const type = this.formatActionType(entityOp, tag || entityName);\n return { type, payload };\n }\n\n /**\n * Create an EntityAction from another EntityAction, replacing properties with those from newPayload;\n * @param from Source action that is the base for the new action\n * @param newProperties New EntityAction properties that replace the source action properties\n */\n createFromAction<P = any>(\n from: EntityAction,\n newProperties: Partial<EntityActionPayload<P>>\n ): EntityAction<P> {\n return this.create({ ...from.payload, ...newProperties });\n }\n\n formatActionType(op: string, tag: string) {\n return `[${tag}] ${op}`;\n // return `${op} [${tag}]`.toUpperCase(); // example of an alternative\n }\n}\n","import { IdSelector, Update } from '@ngrx/entity';\n\nimport { EntityAction } from './entity-action';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Guard methods that ensure EntityAction payload is as expected.\n * Each method returns that payload if it passes the guard or\n * throws an error.\n */\nexport class EntityActionGuard<T> {\n constructor(private entityName: string, private selectId: IdSelector<T>) {}\n\n /** Throw if the action payload is not an entity with a valid key */\n mustBeEntity(action: EntityAction<T>): T {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should have a single entity.`);\n }\n const id = this.selectId(data);\n if (this.isNotKeyType(id)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data as T;\n }\n\n /** Throw if the action payload is not an array of entities with valid keys */\n mustBeEntities(action: EntityAction<T[]>): T[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entities`);\n }\n data.forEach((entity, i) => {\n const id = this.selectId(entity);\n if (this.isNotKeyType(id)) {\n const msg = `, item ${i + 1}, does not have a valid entity key (id)`;\n this.throwError(action, msg);\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not a single, valid key */\n mustBeKey(action: EntityAction<string | number>): string | number | never {\n const data = this.extractData(action);\n if (data === undefined) {\n throw new Error(`should be a single entity key`);\n }\n if (this.isNotKeyType(data)) {\n throw new Error(`is not a valid key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of valid keys */\n mustBeKeys(action: EntityAction<(string | number)[]>): (string | number)[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity keys (id)`);\n }\n data.forEach((id, i) => {\n if (this.isNotKeyType(id)) {\n const msg = `${this.entityName} ', item ${\n i + 1\n }, is not a valid entity key (id)`;\n this.throwError(action, msg);\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not an update with a valid key (id) */\n mustBeUpdate(action: EntityAction<Update<T>>): Update<T> {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should be a single entity update`);\n }\n const { id, changes } = data;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of updates with valid keys (ids) */\n mustBeUpdates(action: EntityAction<Update<T>[]>): Update<T>[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity updates`);\n }\n data.forEach((item, i) => {\n const { id, changes } = item;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(\n action,\n `, item ${i + 1}, has a missing or invalid entity key (id)`\n );\n }\n });\n return data;\n }\n\n /** Throw if the action payload is not an update response with a valid key (id) */\n mustBeUpdateResponse(\n action: EntityAction<UpdateResponseData<T>>\n ): UpdateResponseData<T> {\n const data = this.extractData(action);\n if (!data) {\n return this.throwError(action, `should be a single entity update`);\n }\n const { id, changes } = data;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(action, `has a missing or invalid entity key (id)`);\n }\n return data;\n }\n\n /** Throw if the action payload is not an array of update responses with valid keys (ids) */\n mustBeUpdateResponses(\n action: EntityAction<UpdateResponseData<T>[]>\n ): UpdateResponseData<T>[] {\n const data = this.extractData(action);\n if (!Array.isArray(data)) {\n return this.throwError(action, `should be an array of entity updates`);\n }\n data.forEach((item, i) => {\n const { id, changes } = item;\n const id2 = this.selectId(changes as T);\n if (this.isNotKeyType(id) || this.isNotKeyType(id2)) {\n this.throwError(\n action,\n `, item ${i + 1}, has a missing or invalid entity key (id)`\n );\n }\n });\n return data;\n }\n\n private extractData<T>(action: EntityAction<T>) {\n return action.payload && action.payload.data;\n }\n\n /** Return true if this key (id) is invalid */\n private isNotKeyType(id: any) {\n return typeof id !== 'string' && typeof id !== 'number';\n }\n\n private throwError(action: EntityAction, msg: string): never {\n throw new Error(\n `${this.entityName} EntityAction guard for \"${action.type}\": payload ${msg}`\n );\n }\n}\n","import { IdSelector, Update } from '@ngrx/entity';\n\n/**\n * Default function that returns the entity's primary key (pkey).\n * Assumes that the entity has an `id` pkey property.\n * Returns `undefined` if no entity or `id`.\n * Every selectId fn must return `undefined` when it cannot produce a full pkey.\n */\nexport function defaultSelectId(entity: any) {\n return entity == null ? undefined : entity.id;\n}\n\n/**\n * Flatten first arg if it is an array\n * Allows fn with ...rest signature to be called with an array instead of spread\n * Example:\n * ```\n * // See entity-action-operators.ts\n * const persistOps = [EntityOp.QUERY_ALL, EntityOp.ADD, ...];\n * actions.pipe(ofEntityOp(...persistOps)) // works\n * actions.pipe(ofEntityOp(persistOps)) // also works\n * ```\n * */\nexport function flattenArgs<T>(args?: any[]): T[] {\n if (args == null) {\n return [];\n }\n if (Array.isArray(args[0])) {\n const [head, ...tail] = args;\n args = [...head, ...tail];\n }\n return args;\n}\n\n/**\n * Return a function that converts an entity (or partial entity) into the `Update<T>`\n * whose `id` is the primary key and\n * `changes` is the entity (or partial entity of changes).\n */\nexport function toUpdateFactory<T>(selectId?: IdSelector<T>) {\n selectId = selectId || (defaultSelectId as IdSelector<T>);\n /**\n * Convert an entity (or partial entity) into the `Update<T>`\n * whose `id` is the primary key and\n * `changes` is the entity (or partial entity of changes).\n * @param selectId function that returns the entity's primary key (id)\n */\n return function toUpdate(entity: Partial<T>): Update<T> {\n const id: any = selectId!(entity as T);\n if (id == null) {\n throw new Error('Primary key may not be null/undefined.');\n }\n return entity && { id, changes: entity };\n };\n}\n","import { OperatorFunction } from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\nimport { EntityAction } from './entity-action';\nimport { EntityOp } from './entity-op';\nimport { flattenArgs } from '../utils/utilities';\n\n/**\n * Select actions concerning one of the allowed Entity operations\n * @param allowedEntityOps Entity operations (e.g, EntityOp.QUERY_ALL) whose actions should be selected\n * Example:\n * ```\n * this.actions.pipe(ofEntityOp(EntityOp.QUERY_ALL, EntityOp.QUERY_MANY), ...)\n * this.actions.pipe(ofEntityOp(...queryOps), ...)\n * this.actions.pipe(ofEntityOp(queryOps), ...)\n * this.actions.pipe(ofEntityOp(), ...) // any action with a defined `entityOp` property\n * ```\n */\nexport function ofEntityOp<T extends EntityAction>(\n allowedOps: string[] | EntityOp[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityOp<T extends EntityAction>(\n ...allowedOps: (string | EntityOp)[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityOp<T extends EntityAction>(\n ...allowedEntityOps: any[]\n): OperatorFunction<EntityAction, T> {\n const ops: string[] = flattenArgs(allowedEntityOps);\n switch (ops.length) {\n case 0:\n return filter(\n (action: EntityAction): action is T =>\n action.payload && action.payload.entityOp != null\n );\n case 1:\n const op = ops[0];\n return filter(\n (action: EntityAction): action is T =>\n action.payload && op === action.payload.entityOp\n );\n default:\n return filter((action: EntityAction): action is T => {\n const entityOp = action.payload && action.payload.entityOp;\n return entityOp && ops.some((o) => o === entityOp);\n });\n }\n}\n\n/**\n * Select actions concerning one of the allowed Entity types\n * @param allowedEntityNames Entity-type names (e.g, 'Hero') whose actions should be selected\n * Example:\n * ```\n * this.actions.pipe(ofEntityType(), ...) // ayn EntityAction with a defined entity type property\n * this.actions.pipe(ofEntityType('Hero'), ...) // EntityActions for the Hero entity\n * this.actions.pipe(ofEntityType('Hero', 'Villain', 'Sidekick'), ...)\n * this.actions.pipe(ofEntityType(...theChosen), ...)\n * this.actions.pipe(ofEntityType(theChosen), ...)\n * ```\n */\nexport function ofEntityType<T extends EntityAction>(\n allowedEntityNames?: string[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityType<T extends EntityAction>(\n ...allowedEntityNames: string[]\n): OperatorFunction<EntityAction, T>;\nexport function ofEntityType<T extends EntityAction>(\n ...allowedEntityNames: any[]\n): OperatorFunction<EntityAction, T> {\n const names: string[] = flattenArgs(allowedEntityNames);\n switch (names.length) {\n case 0:\n return filter(\n (action: EntityAction): action is T =>\n action.payload && action.payload.entityName != null\n );\n case 1:\n const name = names[0];\n return filter(\n (action: EntityAction): action is T =>\n action.payload && name === action.payload.entityName\n );\n default:\n return filter((action: EntityAction): action is T => {\n const entityName = action.payload && action.payload.entityName;\n return !!entityName && names.some((n) => n === entityName);\n });\n }\n}\n","import { Update } from '@ngrx/entity';\n\nexport enum ChangeSetOperation {\n Add = 'Add',\n Delete = 'Delete',\n Update = 'Update',\n Upsert = 'Upsert',\n}\nexport interface ChangeSetAdd<T = any> {\n op: ChangeSetOperation.Add;\n entityName: string;\n entities: T[];\n}\n\nexport interface ChangeSetDelete {\n op: ChangeSetOperation.Delete;\n entityName: string;\n entities: string[] | number[];\n}\n\nexport interface ChangeSetUpdate<T = any> {\n op: ChangeSetOperation.Update;\n entityName: string;\n entities: Update<T>[];\n}\n\nexport interface ChangeSetUpsert<T = any> {\n op: ChangeSetOperation.Upsert;\n entityName: string;\n entities: T[];\n}\n\n/**\n * A entities of a single entity type, which are changed in the same way by a ChangeSetOperation\n */\nexport type ChangeSetItem =\n | ChangeSetAdd\n | ChangeSetDelete\n | ChangeSetUpdate\n | ChangeSetUpsert;\n\n/*\n * A set of entity Changes, typically to be saved.\n */\nexport interface ChangeSet<T = any> {\n /** An array of ChangeSetItems to be processed in the array order */\n changes: ChangeSetItem[];\n\n /**\n * An arbitrary, serializable object that should travel with the ChangeSet.\n * Meaningful to the ChangeSet producer and consumer. Ignored by @ngrx/data.\n */\n extras?: T;\n\n /** An arbitrary string, identifying the ChangeSet and perhaps its purpose */\n tag?: string;\n}\n\n/**\n * Factory to create a ChangeSetItem for a ChangeSetOperation\n */\nexport class ChangeSetItemFactory {\n /** Create the ChangeSetAdd for new entities of the given entity type */\n add<T>(entityName: string, entities: T | T[]): ChangeSetAdd<T> {\n entities = Array.isArray(entities) ? entities : entities ? [entities] : [];\n return { entityName, op: ChangeSetOperation.Add, entities };\n }\n\n /** Create the ChangeSetDelete for primary keys of the given entity type */\n delete(\n entityName: string,\n keys: number | number[] | string | string[]\n ): ChangeSetDelete {\n const ids = Array.isArray(keys)\n ? keys\n : keys\n ? ([keys] as string[] | number[])\n : [];\n return { entityName, op: ChangeSetOperation.Delete, entities: ids };\n }\n\n /** Create the ChangeSetUpdate for Updates of entities of the given entity type */\n update<T extends { id: string | number }>(\n entityName: string,\n updates: Update<T> | Update<T>[]\n ): ChangeSetUpdate<T> {\n updates = Array.isArray(updates) ? updates : updates ? [updates] : [];\n return { entityName, op: ChangeSetOperation.Update, entities: updates };\n }\n\n /** Create the ChangeSetUpsert for new or existing entities of the given entity type */\n upsert<T>(entityName: string, entities: T | T[]): ChangeSetUpsert<T> {\n entities = Array.isArray(entities) ? entities : entities ? [entities] : [];\n return { entityName, op: ChangeSetOperation.Upsert, entities };\n }\n}\n\n/**\n * Instance of a factory to create a ChangeSetItem for a ChangeSetOperation\n */\nexport const changeSetItemFactory = new ChangeSetItemFactory();\n\n/**\n * Return ChangeSet after filtering out null and empty ChangeSetItems.\n * @param changeSet ChangeSet with changes to filter\n */\nexport function excludeEmptyChangeSetItems(changeSet: ChangeSet): ChangeSet {\n changeSet = changeSet && changeSet.changes ? changeSet : { changes: [] };\n const changes = changeSet.changes.filter(\n (c) => c != null && c.entities && c.entities.length > 0\n );\n return { ...changeSet, changes };\n}\n","/** How to merge an entity, after query or save, when the corresponding entity in the collection has unsaved changes. */\nexport enum MergeStrategy {\n /**\n * Update the collection entities and ignore all change tracking for this operation.\n * Each entity's `changeState` is untouched.\n */\n IgnoreChanges,\n /**\n * Updates current values for unchanged entities.\n * For each changed entity it preserves the current value and overwrites the `originalValue` with the merge entity.\n * This is the query-success default.\n */\n PreserveChanges,\n /**\n * Replace the current collection entities.\n * For each merged entity it discards the `changeState` and sets the `changeType` to \"unchanged\".\n * This is the save-success default.\n */\n OverwriteChanges,\n}\n","/*\n * Actions dedicated to the EntityCache as a whole\n */\nimport { Action } from '@ngrx/store';\n\nimport { ChangeSet, ChangeSetOperation } from './entity-cache-change-set';\nexport { ChangeSet, ChangeSetOperation } from './entity-cache-change-set';\n\nimport { DataServiceError } from '../dataservices/data-service-error';\nimport { EntityActionOptions } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { MergeStrategy } from '../actions/merge-strategy';\n\nexport enum EntityCacheAction {\n CLEAR_COLLECTIONS = '@ngrx/data/entity-cache/clear-collections',\n LOAD_COLLECTIONS = '@ngrx/data/entity-cache/load-collections',\n MERGE_QUERY_SET = '@ngrx/data/entity-cache/merge-query-set',\n SET_ENTITY_CACHE = '@ngrx/data/entity-cache/set-cache',\n\n SAVE_ENTITIES = '@ngrx/data/entity-cache/save-entities',\n SAVE_ENTITIES_CANCEL = '@ngrx/data/entity-cache/save-entities-cancel',\n SAVE_ENTITIES_CANCELED = '@ngrx/data/entity-cache/save-entities-canceled',\n SAVE_ENTITIES_ERROR = '@ngrx/data/entity-cache/save-entities-error',\n SAVE_ENTITIES_SUCCESS = '@ngrx/data/entity-cache/save-entities-success',\n}\n\n/**\n * Hash of entities keyed by EntityCollection name,\n * typically the result of a query that returned results from a multi-collection query\n * that will be merged into an EntityCache via the `MergeQuerySet` action.\n */\nexport interface EntityCacheQuerySet {\n [entityName: string]: any[];\n}\n\n/**\n * Clear the collections identified in the collectionSet.\n * @param [collections] Array of names of the collections to clear.\n * If empty array, does nothing. If no array, clear all collections.\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class ClearCollections implements Action {\n readonly payload: { collections?: string[]; tag?: string };\n readonly type = EntityCacheAction.CLEAR_COLLECTIONS;\n\n constructor(collections?: string[], tag?: string) {\n this.payload = { collections, tag };\n }\n}\n\n/**\n * Create entity cache action that loads multiple entity collections at the same time.\n * before any selectors$ observables emit.\n * @param querySet The collections to load, typically the result of a query.\n * @param [tag] Optional tag to identify the operation from the app perspective.\n * in the form of a map of entity collections.\n */\nexport class LoadCollections implements Action {\n readonly payload: { collections: EntityCacheQuerySet; tag?: string };\n readonly type = EntityCacheAction.LOAD_COLLECTIONS;\n\n constructor(collections: EntityCacheQuerySet, tag?: string) {\n this.payload = { collections, tag };\n }\n}\n\n/**\n * Create entity cache action that merges entities from a query result\n * that returned entities from multiple collections.\n * Corresponding entity cache reducer should add and update all collections\n * at the same time, before any selectors$ observables emit.\n * @param querySet The result of the query in the form of a map of entity collections.\n * These are the entity data to merge into the respective collections.\n * @param mergeStrategy How to merge a queried entity when it is already in the collection.\n * The default is MergeStrategy.PreserveChanges\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class MergeQuerySet implements Action {\n readonly payload: {\n querySet: EntityCacheQuerySet;\n mergeStrategy?: MergeStrategy;\n tag?: string;\n };\n\n readonly type = EntityCacheAction.MERGE_QUERY_SET;\n\n constructor(\n querySet: EntityCacheQuerySet,\n mergeStrategy?: MergeStrategy,\n tag?: string\n ) {\n this.payload = {\n querySet,\n mergeStrategy:\n mergeStrategy === null ? MergeStrategy.PreserveChanges : mergeStrategy,\n tag,\n };\n }\n}\n\n/**\n * Create entity cache action for replacing the entire entity cache.\n * Dangerous because brute force but useful as when re-hydrating an EntityCache\n * from local browser storage when the application launches.\n * @param cache New state of the entity cache\n * @param [tag] Optional tag to identify the operation from the app perspective.\n */\nexport class SetEntityCache implements Action {\n readonly payload: { cache: EntityCache; tag?: string };\n readonly type = EntityCacheAction.SET_ENTITY_CACHE;\n\n constructor(public readonly cache: EntityCache, tag?: string) {\n this.payload = { cache, tag };\n }\n}\n\n// #region SaveEntities\nexport class SaveEntities implements Action {\n readonly payload: {\n readonly changeSet: ChangeSet;\n readonly url: string;\n readonly correlationId?: any;\n readonly isOptimistic?: boolean;\n readonly mergeStrategy?: MergeStrategy;\n readonly tag?: string;\n error?: Error;\n skip?: boolean; // not used\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES;\n\n constructor(\n changeSet: ChangeSet,\n url: string,\n options?: EntityActionOptions\n ) {\n options = options || {};\n if (changeSet) {\n changeSet.tag = changeSet.tag || options.tag;\n }\n this.payload = { changeSet, url, ...options, tag: changeSet.tag };\n }\n}\n\nexport class SaveEntitiesCancel implements Action {\n readonly payload: {\n readonly correlationId: any;\n readonly reason?: string;\n readonly entityNames?: string[];\n readonly tag?: string;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_CANCEL;\n\n constructor(\n correlationId: any,\n reason?: string,\n entityNames?: string[],\n tag?: string\n ) {\n this.payload = { correlationId, reason, entityNames, tag };\n }\n}\n\nexport class SaveEntitiesCanceled implements Action {\n readonly payload: {\n readonly correlationId: any;\n readonly reason?: string;\n readonly tag?: string;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_CANCELED;\n\n constructor(correlationId: any, reason?: string, tag?: string) {\n this.payload = { correlationId, reason, tag };\n }\n}\n\nexport class SaveEntitiesError {\n readonly payload: {\n readonly error: DataServiceError;\n readonly originalAction: SaveEntities;\n readonly correlationId: any;\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_ERROR;\n constructor(error: DataServiceError, originalAction: SaveEntities) {\n const correlationId = originalAction.payload.correlationId;\n this.payload = { error, originalAction, correlationId };\n }\n}\n\nexport class SaveEntitiesSuccess implements Action {\n readonly payload: {\n readonly changeSet: ChangeSet;\n readonly url: string;\n readonly correlationId?: any;\n readonly isOptimistic?: boolean;\n readonly mergeStrategy?: MergeStrategy;\n readonly tag?: string;\n error?: Error;\n skip?: boolean; // not used\n };\n readonly type = EntityCacheAction.SAVE_ENTITIES_SUCCESS;\n\n constructor(\n changeSet: ChangeSet,\n url: string,\n options?: EntityActionOptions\n ) {\n options = options || {};\n if (changeSet) {\n changeSet.tag = changeSet.tag || options.tag;\n }\n this.payload = { changeSet, url, ...options, tag: changeSet.tag };\n }\n}\n// #endregion SaveEntities\n","// Ensure that these suffix values and the EntityOp suffixes match\n// Cannot do that programmatically.\n\n/** General purpose entity action operations, good for any entity type */\nexport enum EntityOp {\n // Persistance operations\n CANCEL_PERSIST = '@ngrx/data/cancel-persist',\n CANCELED_PERSIST = '@ngrx/data/canceled-persist',\n\n QUERY_ALL = '@ngrx/data/query-all',\n QUERY_ALL_SUCCESS = '@ngrx/data/query-all/success',\n QUERY_ALL_ERROR = '@ngrx/data/query-all/error',\n\n QUERY_LOAD = '@ngrx/data/query-load',\n QUERY_LOAD_SUCCESS = '@ngrx/data/query-load/success',\n QUERY_LOAD_ERROR = '@ngrx/data/query-load/error',\n\n QUERY_MANY = '@ngrx/data/query-many',\n QUERY_MANY_SUCCESS = '@ngrx/data/query-many/success',\n QUERY_MANY_ERROR = '@ngrx/data/query-many/error',\n\n QUERY_BY_KEY = '@ngrx/data/query-by-key',\n QUERY_BY_KEY_SUCCESS = '@ngrx/data/query-by-key/success',\n QUERY_BY_KEY_ERROR = '@ngrx/data/query-by-key/error',\n\n SAVE_ADD_MANY = '@ngrx/data/save/add-many',\n SAVE_ADD_MANY_ERROR = '@ngrx/data/save/add-many/error',\n SAVE_ADD_MANY_SUCCESS = '@ngrx/data/save/add-many/success',\n\n SAVE_ADD_ONE = '@ngrx/data/save/add-one',\n SAVE_ADD_ONE_ERROR = '@ngrx/data/save/add-one/error',\n SAVE_ADD_ONE_SUCCESS = '@ngrx/data/save/add-one/success',\n\n SAVE_DELETE_MANY = '@ngrx/data/save/delete-many',\n SAVE_DELETE_MANY_SUCCESS = '@ngrx/data/save/delete-many/success',\n SAVE_DELETE_MANY_ERROR = '@ngrx/data/save/delete-many/error',\n\n SAVE_DELETE_ONE = '@ngrx/data/save/delete-one',\n SAVE_DELETE_ONE_SUCCESS = '@ngrx/data/save/delete-one/success',\n SAVE_DELETE_ONE_ERROR = '@ngrx/data/save/delete-one/error',\n\n SAVE_UPDATE_MANY = '@ngrx/data/save/update-many',\n SAVE_UPDATE_MANY_SUCCESS = '@ngrx/data/save/update-many/success',\n SAVE_UPDATE_MANY_ERROR = '@ngrx/data/save/update-many/error',\n\n SAVE_UPDATE_ONE = '@ngrx/data/save/update-one',\n SAVE_UPDATE_ONE_SUCCESS = '@ngrx/data/save/update-one/success',\n SAVE_UPDATE_ONE_ERROR = '@ngrx/data/save/update-one/error',\n\n // Use only if the server supports upsert;\n SAVE_UPSERT_MANY = '@ngrx/data/save/upsert-many',\n SAVE_UPSERT_MANY_SUCCESS = '@ngrx/data/save/upsert-many/success',\n SAVE_UPSERT_MANY_ERROR = '@ngrx/data/save/upsert-many/error',\n\n // Use only if the server supports upsert;\n SAVE_UPSERT_ONE = '@ngrx/data/save/upsert-one',\n SAVE_UPSERT_ONE_SUCCESS = '@ngrx/data/save/upsert-one/success',\n SAVE_UPSERT_ONE_ERROR = '@ngrx/data/save/upsert-one/error',\n\n // Cache operations\n ADD_ALL = '@ngrx/data/add-all',\n ADD_MANY = '@ngrx/data/add-many',\n ADD_ONE = '@ngrx/data/add-one',\n REMOVE_ALL = '@ngrx/data/remove-all',\n REMOVE_MANY = '@ngrx/data/remove-many',\n REMOVE_ONE = '@ngrx/data/remove-one',\n UPDATE_MANY = '@ngrx/data/update-many',\n UPDATE_ONE = '@ngrx/data/update-one',\n UPSERT_MANY = '@ngrx/data/upsert-many',\n UPSERT_ONE = '@ngrx/data/upsert-one',\n\n COMMIT_ALL = '@ngrx/data/commit-all',\n COMMIT_MANY = '@ngrx/data/commit-many',\n COMMIT_ONE = '@ngrx/data/commit-one',\n UNDO_ALL = '@ngrx/data/undo-all',\n UNDO_MANY = '@ngrx/data/undo-many',\n UNDO_ONE = '@ngrx/data/undo-one',\n\n SET_CHANGE_STATE = '@ngrx/data/set-change-state',\n SET_COLLECTION = '@ngrx/data/set-collection',\n SET_FILTER = '@ngrx/data/set-filter',\n SET_LOADED = '@ngrx/data/set-loaded',\n SET_LOADING = '@ngrx/data/set-loading',\n}\n\n/** \"Success\" suffix appended to EntityOps that are successful.*/\nexport const OP_SUCCESS = '/success';\n\n/** \"Error\" suffix appended to EntityOps that have failed.*/\nexport const OP_ERROR = '/error';\n\n/** Make the error EntityOp corresponding to the given EntityOp */\nexport function makeErrorOp(op: EntityOp): EntityOp {\n return <EntityOp>(op + OP_ERROR);\n}\n\n/** Make the success EntityOp corresponding to the given EntityOp */\nexport function makeSuccessOp(op: EntityOp): EntityOp {\n return <EntityOp>(op + OP_SUCCESS);\n}\n","import { EntityAction } from '../actions/entity-action';\nimport { RequestData } from './interfaces';\n\n/**\n * Error from a DataService\n * The source error either comes from a failed HTTP response or was thrown within the service.\n * @param error the HttpErrorResponse or the error thrown by the service\n * @param requestData the HTTP request information such as the method and the url.\n */\nexport class DataServiceError extends Error {\n constructor(public error: any, public requestData: RequestData | null) {\n super(\n typeof error === 'string' ? error : extractMessage(error) ?? undefined\n );\n this.name = this.constructor.name;\n }\n}\n\n// Many ways the error can be shaped. These are the ways we recognize.\nfunction extractMessage(sourceError: any): string | null {\n const { error, body, message } = sourceError;\n let errMessage: string | null = null;\n if (error) {\n // prefer HttpErrorResponse.error to its message property\n errMessage = typeof error === 'string' ? error : error.message;\n } else if (message) {\n errMessage = message;\n } else if (body) {\n // try the body if no error or message property\n errMessage = typeof body === 'string' ? body : body.error;\n }\n\n return typeof errMessage === 'string'\n ? errMessage\n : errMessage\n ? JSON.stringify(errMessage)\n : null;\n}\n\n/** Payload for an EntityAction data service error such as QUERY_ALL_ERROR */\nexport interface EntityActionDataServiceError {\n error: DataServiceError;\n originalAction: EntityAction;\n}\n","import { EntityHttpResourceUrls } from './http-url-generator';\n\n/**\n * Optional configuration settings for an entity collection data service\n * such as the `DefaultDataService<T>`.\n */\nexport abstract class DefaultDataServiceConfig {\n /**\n * root path of the web api. may also include protocol, domain, and port\n * for remote api, e.g.: `'https://api-domain.com:8000/api/v1'` (default: 'api')\n */\n root?: string;\n /**\n * Known entity HttpResourceUrls.\n * HttpUrlGenerator will create these URLs for entity types not listed here.\n */\n entityHttpResourceUrls?: EntityHttpResourceUrls;\n /** Is a DELETE 404 really OK? (default: true) */\n delete404OK?: boolean;\n /** Simulate GET latency in a demo (default: 0) */\n getDelay?: number;\n /** Simulate save method (PUT/POST/DELETE) latency in a demo (default: 0) */\n saveDelay?: number;\n /** request timeout in MS (default: 0)*/\n timeout?: number; //\n /** to keep leading & trailing slashes or not; false by default */\n trailingSlashEndpoints?: boolean;\n}\n","import { InjectionToken } from '@angular/core';\n\nexport abstract class Logger {\n abstract error(message?: any, ...optionalParams: any[]): void;\n abstract log(message?: any, ...optionalParams: any[]): void;\n abstract warn(message?: any, ...optionalParams: any[]): void;\n}\n\n/**\n * Mapping of entity type name to its plural\n */\nexport interface EntityPluralNames {\n [entityName: string]: string;\n}\n\nexport const PLURAL_NAMES_TOKEN = new InjectionToken<EntityPluralNames>(\n '@ngrx/data Plural Names'\n);\n\nexport abstract class Pluralizer {\n abstract pluralize(name: string): string;\n}\n","import { Injectable } from '@angular/core';\nimport { Pluralizer } from '../utils/interfaces';\n\n/**\n * Known resource URLS for specific entity types.\n * Each entity's resource URLS are endpoints that\n * target single entity and multi-entity HTTP operations.\n * Used by the `DefaultHttpUrlGenerator`.\n */\nexport abstract class EntityHttpResourceUrls {\n [entityName: string]: HttpResourceUrls;\n}\n\n/**\n * Resource URLS for HTTP operations that target single entity\n * and multi-entity endpoints.\n */\nexport interface HttpResourceUrls {\n /**\n * The URL path for a single entity endpoint, e.g, `some-api-root/hero/`\n * such as you'd use to add a hero.\n * Example: `httpClient.post<Hero>('some-api-root/hero/', addedHero)`.\n * Note trailing slash (/).\n */\n entityResourceUrl: string;\n /**\n * The URL path for a multiple-entity endpoint, e.g, `some-api-root/heroes/`\n * such as you'd use when getting all heroes.\n * Example: `httpClient.get<Hero[]>('some-api-root/heroes/')`\n * Note trailing slash (/).\n */\n collectionResourceUrl: string;\n}\n\n/**\n * Generate the base part of an HTTP URL for\n * single entity or entity collection resource\n */\nexport abstract class HttpUrlGenerator {\n /**\n * Return the base URL for a single entity resource,\n * e.g., the base URL to get a single hero by its id\n */\n abstract entityResource(\n entityName: string,\n root: string,\n trailingSlashEndpoints: boolean\n ): string;\n\n /**\n * Return the base URL for a collection resource,\n * e.g., the base URL to get all heroes\n */\n abstract collectionResource(entityName: string, root: string): string;\n\n /**\n * Register known single-entity and collection resource URLs for HTTP calls\n * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names\n */\n abstract registerHttpResourceUrls(\n entityHttpResourceUrls?: EntityHttpResourceUrls\n ): void;\n}\n\n@Injectable()\nexport class DefaultHttpUrlGenerator implements HttpUrlGenerator {\n /**\n * Known single-entity and collection resource URLs for HTTP calls.\n * Generator methods returns these resource URLs for a given entity type name.\n * If the resources for an entity type name are not know, it generates\n * and caches a resource name for future use\n */\n protected knownHttpResourceUrls: EntityHttpResourceUrls = {};\n\n constructor(private pluralizer: Pluralizer) {}\n\n /**\n * Get or generate the entity and collection resource URLs for the given entity type name\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n */\n protected getResourceUrls(\n entityName: string,\n root: string,\n trailingSlashEndpoints = false\n ): HttpResourceUrls {\n let resourceUrls = this.knownHttpResourceUrls[entityName];\n if (!resourceUrls) {\n const nRoot = trailingSlashEndpoints ? root : normalizeRoot(root);\n resourceUrls = {\n entityResourceUrl: `${nRoot}/${entityName}/`.toLowerCase(),\n collectionResourceUrl: `${nRoot}/${this.pluralizer.pluralize(\n entityName\n )}/`.toLowerCase(),\n };\n this.registerHttpResourceUrls({ [entityName]: resourceUrls });\n }\n return resourceUrls;\n }\n\n /**\n * Create the path to a single entity resource\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n * @returns complete path to resource, e.g, 'some-api/hero'\n */\n entityResource(\n entityName: string,\n root: string,\n trailingSlashEndpoints: boolean\n ): string {\n return this.getResourceUrls(entityName, root, trailingSlashEndpoints)\n .entityResourceUrl;\n }\n\n /**\n * Create the path to a multiple entity (collection) resource\n * @param entityName {string} Name of the entity type, e.g, 'Hero'\n * @param root {string} Root path to the resource, e.g., 'some-api`\n * @returns complete path to resource, e.g, 'some-api/heroes'\n */\n collectionResource(entityName: string, root: string): string {\n return this.getResourceUrls(entityName, root).collectionResourceUrl;\n }\n\n /**\n * Register known single-entity and collection resource URLs for HTTP calls\n * @param entityHttpResourceUrls {EntityHttpResourceUrls} resource urls for specific entity type names\n * Well-formed resource urls end in a '/';\n * Note: this method does not ensure that resource urls are well-formed.\n */\n registerHttpResourceUrls(\n entityHttpResourceUrls: EntityHttpResourceUrls\n ): void {\n this.knownHttpResourceUrls = {\n ...this.knownHttpResourceUrls,\n ...(entityHttpResourceUrls || {}),\n };\n }\n}\n\n/** Remove leading & trailing spaces or slashes */\nexport function normalizeRoot(root: string) {\n return root.replace(/^[/\\s]+|[/\\s]+$/g, '');\n}\n","import { Injectable, isDevMode, Optional } from '@angular/core';\nimport {\n HttpClient,\n HttpErrorResponse,\n HttpHeaders,\n HttpParams,\n} from '@angular/common/http';\n\nimport { Observable, of, throwError } from 'rxjs';\nimport { catchError, delay, map, timeout } from 'rxjs/operators';\n\nimport { Update } from '@ngrx/entity';\n\nimport { DataServiceError } from './data-service-error';\nimport { DefaultDataServiceConfig } from './default-data-service-config';\nimport {\n EntityCollectionDataService,\n HttpMethods,\n HttpOptions,\n QueryParams,\n RequestData,\n} from './interfaces';\nimport { HttpUrlGenerator } from './http-url-generator';\n\n/**\n * A basic, generic entity data service\n * suitable for persistence of most entities.\n * Assumes a common REST-y web API\n */\nexport class DefaultDataService<T> implements EntityCollectionDataService<T> {\n protected _name: string;\n protected delete404OK: boolean;\n protected entityName: string;\n protected entityUrl: string;\n protected entitiesUrl: string;\n protected getDelay = 0;\n protected saveDelay = 0;\n protected timeout = 0;\n protected trailingSlashEndpoints = false;\n\n get name() {\n return this._name;\n }\n\n constructor(\n entityName: string,\n protected http: HttpClient,\n protected httpUrlGenerator: HttpUrlGenerator,\n config?: DefaultDataServiceConfig\n ) {\n this._name = `${entityName} DefaultDataService`;\n this.entityName = entityName;\n const {\n root = 'api',\n delete404OK = true,\n getDelay = 0,\n saveDelay = 0,\n timeout: to = 0,\n trailingSlashEndpoints = false,\n } = config || {};\n this.delete404OK = delete404OK;\n this.entityUrl = httpUrlGenerator.entityResource(\n entityName,\n root,\n trailingSlashEndpoints\n );\n this.entitiesUrl = httpUrlGenerator.collectionResource(entityName, root);\n this.getDelay = getDelay;\n this.saveDelay = saveDelay;\n this.timeout = to;\n }\n\n add(entity: T, options?: HttpOptions): Observable<T> {\n const entityOrError =\n entity || new Error(`No \"${this.entityName}\" entity to add`);\n return this.execute('POST', this.entityUrl, entityOrError, null, options);\n }\n\n delete(\n key: number | string,\n options?: HttpOptions\n ): Observable<number | string> {\n let err: Error | undefined;\n if (key == null) {\n err = new Error(`No \"${this.entityName}\" key to delete`);\n }\n\n return this.execute(\n 'DELETE',\n this.entityUrl + key,\n err,\n null,\n options\n ).pipe(\n // forward the id of deleted entity as the result of the HTTP DELETE\n map((result) => key as number | string)\n );\n }\n\n getAll(options?: HttpOptions): Observable<T[]> {\n return this.execute('GET', this.entitiesUrl, null, null, options);\n }\n\n getById(key: number | string, options?: HttpOptions): Observable<T> {\n let err: Error | undefined;\n if (key == null) {\n err = new Error(`No \"${this.entityName}\" key to get`);\n }\n return this.execute('GET', this.entityUrl + key, err, null, options);\n }\n\n getWithQuery(\n queryParams: QueryParams | string | undefined,\n options?: HttpOptions\n ): Observable<T[]> {\n const qParams =\n typeof queryParams === 'string'\n ? { fromString: queryParams }\n : { fromObject: queryParams };\n const params = new HttpParams(qParams);\n\n return this.execute(\n 'GET',\n this.entitiesUrl,\n undefined,\n { params },\n options\n );\n }\n\n update(update: Update<T>, options?: HttpOptions): Observable<T> {\n const id = update && update.id;\n const updateOrError =\n id == null\n ? new Error(`No \"${this.entityName}\" update data or id`)\n : update.changes;\n return this.execute(\n 'PUT',\n this.entityUrl + id,\n updateOrError,\n null,\n options\n );\n }\n\n // Important! Only call if the backend service supports upserts as a POST to the target URL\n upsert(entity: T, options?: HttpOptions): Observable<T> {\n const entityOrError =\n entity || new Error(`No \"${this.entityName}\" entity to upsert`);\n return this.execute('POST', this.entityUrl, entityOrError, null, options);\n }\n\n protected execute(\n method: HttpMethods,\n url: string,\n data?: any, // data, error, or undefined/null\n options?: any, // options or undefined/null\n httpOptions?: HttpOptions // these override any options passed via options\n ): Observable<any> {\n let entityActionHttpClientOptions: any = undefined;\n if (httpOptions) {\n entityActionHttpClientOptions = {\n headers: httpOptions?.httpHeaders\n ? new HttpHeaders(httpOptions?.httpHeaders)\n : undefined,\n params: httpOptions?.httpParams\n ? new HttpParams(httpOptions?.httpParams)\n : undefined,\n };\n }\n\n // Now we may have:\n // options: containing headers, params, or any other allowed http options already in angular's api\n // entityActionHttpClientOptions: headers and params in angular's api\n\n // We therefore need to merge these so that the action ones override the\n // existing keys where applicable.\n\n // If any options have been specified, pass them to http client. Note\n // the new http options, if specified, will override any options passed\n // from the deprecated options parameter\n let mergedOptions: any = undefined;\n if (options || entityActionHttpClientOptions) {\n if (isDevMode() && options && entityActionHttpClientOptions) {\n console.warn(\n '@ngrx/data: options.httpParams will be merged with queryParams when both are are provided to getWithQuery(). In the event of a conflict HttpOptions.httpParams will override queryParams`. The queryParams parameter of getWithQuery() will be removed in next major release.'\n );\n }\n\n mergedOptions = {\n ...options,\n headers: entityActionHttpClientOptions?.headers ?? options?.headers,\n params: entityActionHttpClientOptions?.params ?? options?.params,\n };\n }\n\n const req: RequestData = {\n method,\n url,\n data,\n options: mergedOptions,\n };\n\n if (data instanceof Error) {\n return this.handleError(req)(data);\n }\n\n let result$: Observable<ArrayBuffer>;\n\n switch (method) {\n case 'DELETE': {\n result$ = this.http.delete(url, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n case 'GET': {\n result$ = this.http.get(url, mergedOptions);\n if (this.getDelay) {\n result$ = result$.pipe(delay(this.getDelay));\n }\n break;\n }\n case 'POST': {\n result$ = this.http.post(url, data, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n // N.B.: It must return an Update<T>\n case 'PUT': {\n result$ = this.http.put(url, data, mergedOptions);\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n break;\n }\n default: {\n const error = new Error('Unimplemented HTTP method, ' + method);\n result$ = throwError(error);\n }\n }\n if (this.timeout) {\n result$ = result$.pipe(timeout(this.timeout + this.saveDelay));\n }\n return result$.pipe(catchError(this.handleError(req)));\n }\n\n private handleError(reqData: RequestData) {\n return (err: any) => {\n const ok = this.handleDelete404(err, reqData);\n if (ok) {\n return ok;\n }\n const error = new DataServiceError(err, reqData);\n return throwError(error);\n };\n }\n\n private handleDelete404(error: HttpErrorResponse, reqData: RequestData) {\n if (\n error.status === 404 &&\n reqData.method === 'DELETE' &&\n this.delete404OK\n ) {\n return of({});\n }\n return undefined;\n }\n}\n\n/**\n * Create a basic, generic entity data service\n * suitable for persistence of most entities.\n * Assumes a common REST-y web API\n */\n@Injectable()\nexport class DefaultDataServiceFactory {\n constructor(\n protected http: HttpClient,\n protected httpUrlGenerator: HttpUrlGenerator,\n @Optional() protected config?: DefaultDataServiceConfig\n ) {\n config = config || {};\n httpUrlGenerator.registerHttpResourceUrls(config.entityHttpResourceUrls);\n }\n\n /**\n * Create a default {EntityCollectionDataService} for the given entity type\n * @param entityName {string} Name of the entity type for this data service\n */\n create<T>(entityName: string): EntityCollectionDataService<T> {\n return new DefaultDataService<T>(\n entityName,\n this.http,\n this.httpUrlGenerator,\n this.config\n );\n }\n}\n","import { EntityAdapter, createEntityAdapter } from '@ngrx/entity';\nimport { Comparer, IdSelector } from '@ngrx/entity';\n\nimport { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher-default-options';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityCollection } from '../reducers/entity-collection';\nimport { EntityMetadata } from './entity-metadata';\n\nexport interface EntityDefinition<T = any> {\n entityName: string;\n entityAdapter: EntityAdapter<T>;\n entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;\n initialState: EntityCollection<T>;\n metadata: EntityMetadata<T>;\n noChangeTracking: boolean;\n selectId: IdSelector<T>;\n sortComparer: false | Comparer<T>;\n}\n\nexport function createEntityDefinition<T, S extends object>(\n metadata: EntityMetadata<T, S>\n): EntityDefinition<T> {\n let entityName = metadata.entityName;\n if (!entityName) {\n throw new Error('Missing required entityName');\n }\n metadata.entityName = entityName = entityName.trim();\n const selectId = metadata.selectId || defaultSelectId;\n const sortComparer = (metadata.sortComparer = metadata.sortComparer || false);\n\n const entityAdapter = createEntityAdapter<T>({ selectId, sortComparer });\n\n const entityDispatcherOptions: Partial<EntityDispatcherDefaultOptions> =\n metadata.entityDispatcherOptions || {};\n\n const initialState: EntityCollection<T> = entityAdapter.getInitialState({\n entityName,\n filter: '',\n loaded: false,\n loading: false,\n changeState: {},\n ...(metadata.additionalCollectionState || {}),\n });\n\n const noChangeTracking = metadata.noChangeTracking === true; // false by default\n\n return {\n entityName,\n entityAdapter,\n entityDispatcherOptions,\n initialState,\n metadata,\n noChangeTracking,\n selectId,\n sortComparer,\n };\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { IdSelector, Comparer } from '@ngrx/entity';\n\nimport { EntityDispatcherDefaultOptions } from '../dispatchers/entity-dispatcher-default-options';\nimport { EntityFilterFn } from './entity-filters';\n\nexport const ENTITY_METADATA_TOKEN = new InjectionToken<EntityMetadataMap>(\n '@ngrx/data Entity Metadata'\n);\n\n/** Metadata that describe an entity type and its collection to @ngrx/data */\nexport interface EntityMetadata<T = any, S extends object = {}> {\n entityName: string;\n entityDispatcherOptions?: Partial<EntityDispatcherDefaultOptions>;\n filterFn?: EntityFilterFn<T>;\n noChangeTracking?: boolean;\n selectId?: IdSelector<T>;\n sortComparer?: false | Comparer<T>;\n additionalCollectionState?: S;\n}\n\n/** Map entity-type name to its EntityMetadata */\nexport interface EntityMetadataMap {\n [entityName: string]: Partial<EntityMetadata<any>>;\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\nimport { createEntityDefinition, EntityDefinition } from './entity-definition';\nimport {\n EntityMetadata,\n EntityMetadataMap,\n ENTITY_METADATA_TOKEN,\n} from './entity-metadata';\n\nexport interface EntityDefinitions {\n [entityName: string]: EntityDefinition<any>;\n}\n\n/** Registry of EntityDefinitions for all cached entity types */\n@Injectable()\nexport class EntityDefinitionService {\n /** {EntityDefinition} for all cached entity types */\n private readonly definitions: EntityDefinitions = {};\n\n constructor(\n @Optional()\n @Inject(ENTITY_METADATA_TOKEN)\n entityMetadataMaps: EntityMetadataMap[]\n ) {\n if (entityMetadataMaps) {\n entityMetadataMaps.forEach((map) => this.registerMetadataMap(map));\n }\n }\n\n /**\n * Get (or create) a data service for entity type\n * @param entityName - the name of the type\n *\n * Examples:\n * getDefinition('Hero'); // definition for Heroes, untyped\n * getDefinition<Hero>(`Hero`); // definition for Heroes, typed with Hero interface\n */\n getDefinition<T>(\n entityName: string,\n shouldThrow = true\n ): EntityDefinition<T> {\n entityName = entityName.trim();\n const definition = this.definitions[entityName];\n if (!definition && shouldThrow) {\n throw new Error(`No EntityDefinition for entity type \"${entityName}\".`);\n }\n return definition;\n }\n\n //////// Registration methods //////////\n\n /**\n * Create and register the {EntityDefinition} for the {EntityMetadata} of an entity type\n * @param name - the name of the entity type\n * @param definition - {EntityMetadata} for a collection for that entity type\n *\n * Examples:\n * registerMetadata(myHeroEntityDefinition);\n */\n registerMetadata(metadata: EntityMetadata) {\n if (metadata) {\n const definition = createEntityDefinition(metadata);\n this.registerDefinition(definition);\n }\n }\n\n /**\n * Register an EntityMetadataMap.\n * @param metadataMap - a map of entityType names to entity metadata\n *\n * Examples:\n * registerMetadataMap({\n * 'Hero': myHeroMetadata,\n * Villain: myVillainMetadata\n * });\n */\n registerMetadataMap(metadataMap: EntityMetadataMap = {}) {\n // The entity type name should be the same as the map key\n Object.keys(metadataMap || {}).forEach((entityName) =>\n this.registerMetadata({ entityName, ...metadataMap[entityName] })\n );\n }\n\n /**\n * Register an {EntityDefinition} for an entity type\n * @param definition - EntityDefinition of a collection for that entity type\n *\n * Examples:\n * registerDefinition('Hero', myHeroEntityDefinition);\n */\n registerDefinition<T>(definition: EntityDefinition<T>) {\n this.definitions[definition.entityName] = definition;\n }\n\n /**\n * Register a batch of EntityDefinitions.\n * @param definitions - map of entityType name and associated EntityDefinitions to merge.\n *\n * Examples:\n * registerDefinitions({\n * 'Hero': myHeroEntityDefinition,\n * Villain: myVillainEntityDefinition\n * });\n */\n registerDefinitions(definitions: EntityDefinitions) {\n Object.assign(this.definitions, definitions);\n }\n}\n","import { Injectable, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\n\nimport { Observable, throwError } from 'rxjs';\nimport { catchError, delay, map, timeout } from 'rxjs/operators';\n\nimport { IdSelector } from '@ngrx/entity';\n\nimport {\n ChangeSetOperation,\n ChangeSet,\n ChangeSetItem,\n ChangeSetUpdate,\n excludeEmptyChangeSetItems,\n} from '../actions/entity-cache-change-set';\nimport { DataServiceError } from './data-service-error';\nimport { DefaultDataServiceConfig } from './default-data-service-config';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport { RequestData } from './interfaces';\n\nconst updateOp = ChangeSetOperation.Update;\n\n/**\n * Default data service for making remote service calls targeting the entire EntityCache.\n * See EntityDataService for services that target a single EntityCollection\n */\n@Injectable()\nexport class EntityCacheDataService {\n protected idSelectors: { [entityName: string]: IdSelector<any> } = {};\n protected saveDelay = 0;\n protected timeout = 0;\n\n constructor(\n protected entityDefinitionService: EntityDefinitionService,\n protected http: HttpClient,\n @Optional() config?: DefaultDataServiceConfig\n ) {\n const { saveDelay = 0, timeout: to = 0 } = config || {};\n this.saveDelay = saveDelay;\n this.timeout = to;\n }\n\n /**\n * Save changes to multiple entities across one or more entity collections.\n * Server endpoint must understand the essential SaveEntities protocol,\n * in particular the ChangeSet interface (except for Update<T>).\n * This implementation extracts the entity changes from a ChangeSet Update<T>[] and sends those.\n * It then reconstructs Update<T>[] in the returned observable result.\n * @param changeSet An array of SaveEntityItems.\n * Each SaveEntityItem describe a change operation for one or more entities of a single collection,\n * known by its 'entityName'.\n * @param url The server endpoint that receives this request.\n */\n saveEntities(changeSet: ChangeSet, url: string): Observable<ChangeSet> {\n changeSet = this.filterChangeSet(changeSet);\n // Assume server doesn't understand @ngrx/entity Update<T> structure;\n // Extract the entity changes from the Update<T>[] and restore on the return from server\n changeSet = this.flattenUpdates(changeSet);\n\n let result$: Observable<ChangeSet> = this.http\n .post<ChangeSet>(url, changeSet)\n .pipe(\n map((result) => this.restoreUpdates(result)),\n catchError(this.handleError({ method: 'POST', url, data: changeSet }))\n );\n\n if (this.timeout) {\n result$ = result$.pipe(timeout(this.timeout));\n }\n\n if (this.saveDelay) {\n result$ = result$.pipe(delay(this.saveDelay));\n }\n\n return result$;\n }\n\n // #region helpers\n protected handleError(reqData: RequestData) {\n return (err: any) => {\n const error = new DataServiceError(err, reqData);\n return throwError(error);\n };\n }\n\n /**\n * Filter changeSet to remove unwanted ChangeSetItems.\n * This implementation excludes null and empty ChangeSetItems.\n * @param changeSet ChangeSet with changes to filter\n */\n protected filterChangeSet(changeSet: ChangeSet): ChangeSet {\n return excludeEmptyChangeSetItems(changeSet);\n }\n\n /**\n * Convert the entities in update changes from @ngrx Update<T> structure to just T.\n * Reverse of restoreUpdates().\n */\n protected flattenUpdates(changeSet: ChangeSet): ChangeSet {\n let changes = changeSet.changes;\n if (changes.length === 0) {\n return changeSet;\n }\n let hasMutated = false;\n changes = changes.map((item) => {\n if (item.op === updateOp && item.entities.length > 0) {\n hasMutated = true;\n return {\n ...item,\n entities: (item as ChangeSetUpdate).entities.map((u) => u.changes),\n };\n } else {\n return item;\n }\n }) as ChangeSetItem[];\n return hasMutated ? { ...changeSet, changes } : changeSet;\n }\n\n /**\n * Convert the flattened T entities in update changes back to @ngrx Update<T> structures.\n * Reverse of flattenUpdates().\n */\n protected restoreUpdates(changeSet: ChangeSet): ChangeSet {\n if (changeSet == null) {\n // Nothing? Server probably responded with 204 - No Content because it made no changes to the inserted or updated entities\n return changeSet;\n }\n let changes = changeSet.changes;\n if (changes.length === 0) {\n return changeSet;\n }\n let hasMutated = false;\n changes = changes.map((item) => {\n if (item.op === updateOp) {\n // These are entities, not Updates; convert back to Updates\n hasMutated = true;\n const selectId = this.getIdSelector(item.entityName);\n return {\n ...item,\n entities: item.entities.map((u: any) => ({\n id: selectId(u),\n changes: u,\n })),\n } as ChangeSetUpdate;\n } else {\n return item;\n }\n }) as ChangeSetItem[];\n return hasMutated ? { ...changeSet, changes } : changeSet;\n }\n\n /**\n * Get the id (primary key) selector function for an entity type\n * @param entityName name of the entity type\n */\n protected getIdSelector(entityName: string) {\n let idSelector = this.idSelectors[entityName];\n if (!idSelector) {\n idSelector =\n this.entityDefinitionService.getDefinition(entityName).selectId;\n this.idSelectors[entityName] = idSelector;\n }\n return idSelector;\n }\n // #endregion helpers\n}\n","import { Injectable } from '@angular/core';\n\nimport { EntityCollectionDataService } from './interfaces';\nimport { DefaultDataServiceFactory } from './default-data.service';\n\n/**\n * Registry of EntityCollection data services that make REST-like CRUD calls\n * to entity collection endpoints.\n */\n@Injectable()\nexport class EntityDataService {\n protected services: { [name: string]: EntityCollectionDataService<any> } = {};\n\n // TODO: Optionally inject specialized entity data services\n // for those that aren't derived from BaseDataService.\n constructor(protected defaultDataServiceFactory: DefaultDataServiceFactory) {}\n\n /**\n * Get (or create) a data service for entity type\n * @param entityName - the name of the type\n *\n * Examples:\n * getService('Hero'); // data service for Heroes, untyped\n * getService<Hero>('Hero'); // data service for Heroes, typed as Hero\n */\n getService<T>(entityName: string): EntityCollectionDataService<T> {\n entityName = entityName.trim();\n let service = this.services[entityName];\n if (!service) {\n service = this.defaultDataServiceFactory.create(entityName);\n this.services[entityName] = service;\n }\n return service;\n }\n\n /**\n * Register an EntityCollectionDataService for an entity type\n * @param entityName - the name of the entity type\n * @param service - data service for that entity type\n *\n * Examples:\n * registerService('Hero', myHeroDataService);\n * registerService('Villain', myVillainDataService);\n */\n registerService<T>(\n entityName: string,\n service: EntityCollectionDataService<T>\n ) {\n this.services[entityName.trim()] = service;\n }\n\n /**\n * Register a batch of data services.\n * @param services - data services to merge into existing services\n *\n * Examples:\n * registerServices({\n * Hero: myHeroDataService,\n * Villain: myVillainDataService\n * });\n */\n registerServices(services: {\n [name: string]: EntityCollectionDataService<any>;\n }) {\n this.services = { ...this.services, ...services };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action } from '@ngrx/store';\n\nimport {\n DataServiceError,\n EntityActionDataServiceError,\n} from './data-service-error';\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { makeErrorOp, makeSuccessOp } from '../actions/entity-op';\nimport { Logger } from '../utils/interfaces';\n\n/**\n * Handling of responses from persistence operation\n */\nexport abstract class PersistenceResultHandler {\n /** Handle successful result of persistence operation for an action */\n abstract handleSuccess(originalAction: EntityAction): (data: any) => Action;\n\n /** Handle error result of persistence operation for an action */\n abstract handleError(\n originalAction: EntityAction\n ): (\n error: DataServiceError | Error\n ) => EntityAction<EntityActionDataServiceError>;\n}\n\n/**\n * Default handling of responses from persistence operation,\n * specifically an EntityDataService\n */\n@Injectable()\nexport class DefaultPersistenceResultHandler\n implements PersistenceResultHandler\n{\n constructor(\n private logger: Logger,\n private entityActionFactory: EntityActionFactory\n ) {}\n\n /** Handle successful result of persistence operation on an EntityAction */\n handleSuccess(originalAction: EntityAction): (data: any) => Action {\n const successOp = makeSuccessOp(originalAction.payload.entityOp);\n return (data: any) =>\n this.entityActionFactory.createFromAction(originalAction, {\n entityOp: successOp,\n data,\n });\n }\n\n /** Handle error result of persistence operation on an EntityAction */\n handleError(\n originalAction: EntityAction\n ): (\n error: DataServiceError | Error\n ) => EntityAction<EntityActionDataServiceError> {\n const errorOp = makeErrorOp(originalAction.payload.entityOp);\n\n return (err: DataServiceError | Error) => {\n const error =\n err instanceof DataServiceError ? err : new DataServiceError(err, null);\n const errorData: EntityActionDataServiceError = { error, originalAction };\n this.logger.error(errorData);\n const action =\n this.entityActionFactory.createFromAction<EntityActionDataServiceError>(\n originalAction,\n {\n entityOp: errorOp,\n data: errorData,\n }\n );\n return action;\n };\n }\n}\n","import { Action, Store } from '@ngrx/store';\nimport { IdSelector, Update } from '@ngrx/entity';\n\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityCommands } from './entity-commands';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityOp } from '../actions/entity-op';\n\n/**\n * Dispatches EntityCollection actions to their reducers and effects.\n * The substance of the interface is in EntityCommands.\n */\nexport interface EntityDispatcher<T> extends EntityCommands<T> {\n /** Name of the entity type */\n readonly entityName: string;\n\n /**\n * Utility class with methods to validate EntityAction payloads.\n */\n readonly guard: EntityActionGuard<T>;\n\n /** Returns the primary key (id) of this entity */\n readonly selectId: IdSelector<T>;\n\n /** Returns the store, scoped to the EntityCache */\n readonly store: Store<EntityCache>;\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P>;\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate(entity: Partial<T>): Update<T>;\n}\n\n/**\n * Persistence operation canceled\n */\nexport class PersistanceCanceled {\n constructor(public readonly message?: string) {\n this.message = message || 'Canceled by user';\n }\n}\n","import { Injectable } from '@angular/core';\n\n/**\n * Generates a string id beginning 'CRID',\n * followed by a monotonically increasing integer for use as a correlation id.\n * As they are produced locally by a singleton service,\n * these ids are guaranteed to be unique only\n * for the duration of a single client browser instance.\n * Ngrx entity dispatcher query and save methods call this service to generate default correlation ids.\n * Do NOT use for entity keys.\n */\n@Injectable()\nexport class CorrelationIdGenerator {\n /** Seed for the ids */\n protected seed = 0;\n /** Prefix of the id, 'CRID; */\n protected prefix = 'CRID';\n /** Return the next correlation id */\n next() {\n this.seed += 1;\n return this.prefix + this.seed;\n }\n}\n","import { Injectable } from '@angular/core';\n/**\n * Default options for EntityDispatcher behavior\n * such as whether `add()` is optimistic or pessimistic by default.\n * An optimistic save modifies the collection immediately and before saving to the server.\n * A pessimistic save modifies the collection after the server confirms the save was successful.\n * This class initializes the defaults to the safest values.\n * Provide an alternative to change the defaults for all entity collections.\n */\n@Injectable()\nexport class EntityDispatcherDefaultOptions {\n /** True if added entities are saved optimistically; false if saved pessimistically. */\n optimisticAdd = false;\n /** True if deleted entities are saved optimistically; false if saved pessimistically. */\n optimisticDelete = true;\n /** True if updated entities are saved optimistically; false if saved pessimistically. */\n optimisticUpdate = false;\n /** True if upsert entities are saved optimistically; false if saved pessimistically. */\n optimisticUpsert = false;\n /** True if entities in a cache saveEntities request are saved optimistically; false if saved pessimistically. */\n optimisticSaveEntities = false;\n}\n","import { Injectable, Inject } from '@angular/core';\nimport { Action, ScannedActionsSubject, Store } from '@ngrx/store';\n\nimport { Observable, of, Subscription, throwError } from 'rxjs';\nimport { filter, mergeMap, shareReplay, take } from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { EntityActionOptions } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\n\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { PersistanceCanceled } from './entity-dispatcher';\n\nimport { ChangeSet, ChangeSetItem } from '../actions/entity-cache-change-set';\nimport {\n ClearCollections,\n EntityCacheAction,\n EntityCacheQuerySet,\n LoadCollections,\n MergeQuerySet,\n SetEntityCache,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\n\n/**\n * Dispatches Entity Cache actions to the EntityCache reducer\n */\n@Injectable()\nexport class EntityCacheDispatcher {\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n reducedActions$: Observable<Action>;\n private raSubscription: Subscription;\n\n constructor(\n /** Generates correlation ids for query and save methods */\n private correlationIdGenerator: CorrelationIdGenerator,\n /**\n * Dispatcher options configure dispatcher behavior such as\n * whether add is optimistic or pessimistic by default.\n */\n private defaultDispatcherOptions: EntityDispatcherDefaultOptions,\n /** Actions scanned by the store after it processed them with reducers. */\n @Inject(ScannedActionsSubject) scannedActions$: Observable<Action>,\n /** The store, scoped to the EntityCache */\n private store: Store<EntityCache>\n ) {\n // Replay because sometimes in tests will fake data service with synchronous observable\n // which makes subscriber miss the dispatched actions.\n // Of course that's a testing mistake. But easy to forget, leading to painful debugging.\n this.reducedActions$ = scannedActions$.pipe(shareReplay(1));\n // Start listening so late subscriber won't miss the most recent action.\n this.raSubscription = this.reducedActions$.subscribe();\n }\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n this.store.dispatch(action);\n return action;\n }\n\n /**\n * Dispatch action to cancel the saveEntities request with matching correlation id.\n * @param correlationId The correlation id for the corresponding action\n * @param [reason] explains why canceled and by whom.\n * @param [entityNames] array of entity names so can turn off loading flag for their collections.\n * @param [tag] tag to identify the operation from the app perspective.\n */\n cancelSaveEntities(\n correlationId: any,\n reason?: string,\n entityNames?: string[],\n tag?: string\n ): void {\n if (!correlationId) {\n throw new Error('Missing correlationId');\n }\n const action = new SaveEntitiesCancel(\n correlationId,\n reason,\n entityNames,\n tag\n );\n this.dispatch(action);\n }\n\n /** Clear the named entity collections in cache\n * @param [collections] Array of names of the collections to clear.\n * If empty array, does nothing. If null/undefined/no array, clear all collections.\n * @param [tag] tag to identify the operation from the app perspective.\n */\n clearCollections(collections?: string[], tag?: string) {\n this.dispatch(new ClearCollections(collections, tag));\n }\n\n /**\n * Load multiple entity collections at the same time.\n * before any selectors$ observables emit.\n * @param collections The collections to load, typically the result of a query.\n * @param [tag] tag to identify the operation from the app perspective.\n * in the form of a map of entity collections.\n */\n loadCollections(collections: EntityCacheQuerySet, tag?: string) {\n this.dispatch(new LoadCollections(collections, tag));\n }\n\n /**\n * Merges entities from a query result\n * that returned entities from multiple collections.\n * Corresponding entity cache reducer should add and update all collections\n * at the same time, before any selectors$ observables emit.\n * @param querySet The result of the query in the form of a map of entity collections.\n * These are the entity data to merge into the respective collections.\n * @param mergeStrategy How to merge a queried entity when it is already in the collection.\n * The default is MergeStrategy.PreserveChanges\n * @param [tag] tag to identify the operation from the app perspective.\n */\n mergeQuerySet(\n querySet: EntityCacheQuerySet,\n mergeStrategy?: MergeStrategy,\n tag?: string\n ) {\n this.dispatch(new MergeQuerySet(querySet, mergeStrategy, tag));\n }\n\n /**\n * Create entity cache action for replacing the entire entity cache.\n * Dangerous because brute force but useful as when re-hydrating an EntityCache\n * from local browser storage when the application launches.\n * @param cache New state of the entity cache\n * @param [tag] tag to identify the operation from the app perspective.\n */\n setEntityCache(cache: EntityCache, tag?: string) {\n this.dispatch(new SetEntityCache(cache, tag));\n }\n\n /**\n * Dispatch action to save multiple entity changes to remote storage.\n * Relies on an Ngrx Effect such as EntityEffects.saveEntities$.\n * Important: only call if your server supports the SaveEntities protocol\n * through your EntityDataService.saveEntities method.\n * @param changes Either the entities to save, as an array of {ChangeSetItem}, or\n * a ChangeSet that holds such changes.\n * @param url The server url which receives the save request\n * @param [options] options such as tag, correlationId, isOptimistic, and mergeStrategy.\n * These values are defaulted if not supplied.\n * @returns A terminating Observable<ChangeSet> with data returned from the server\n * after server reports successful save OR the save error.\n * TODO: should return the matching entities from cache rather than the raw server data.\n */\n saveEntities(\n changes: ChangeSetItem[] | ChangeSet,\n url: string,\n options?: EntityActionOptions\n ): Observable<ChangeSet> {\n const changeSet = Array.isArray(changes) ? { changes } : changes;\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n const isOptimistic =\n options.isOptimistic == null\n ? this.defaultDispatcherOptions.optimisticSaveEntities || false\n : options.isOptimistic === true;\n const tag = options.tag || 'Save Entities';\n options = { ...options, correlationId, isOptimistic, tag };\n const action = new SaveEntities(changeSet, url, options);\n this.dispatch(action);\n return this.getSaveEntitiesResponseData$(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Return Observable of data from the server-success SaveEntities action with\n * the given Correlation Id, after that action was processed by the ngrx store.\n * or else put the server error on the Observable error channel.\n * @param crid The correlationId for both the save and response actions.\n */\n private getSaveEntitiesResponseData$(crid: any): Observable<ChangeSet> {\n /**\n * reducedActions$ must be replay observable of the most recent action reduced by the store.\n * because the response action might have been dispatched to the store\n * before caller had a chance to subscribe.\n */\n return this.reducedActions$.pipe(\n filter(\n (act: Action) =>\n act.type === EntityCacheAction.SAVE_ENTITIES_SUCCESS ||\n act.type === EntityCacheAction.SAVE_ENTITIES_ERROR ||\n act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL\n ),\n filter((act: Action) => crid === (act as any).payload.correlationId),\n take(1),\n mergeMap((act) => {\n return act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL\n ? throwError(\n new PersistanceCanceled(\n (act as SaveEntitiesCancel).payload.reason\n )\n )\n : act.type === EntityCacheAction.SAVE_ENTITIES_SUCCESS\n ? of((act as SaveEntitiesSuccess).payload.changeSet)\n : throwError((act as SaveEntitiesError).payload);\n })\n );\n }\n}\n","import { Action, createSelector, Store } from '@ngrx/store';\nimport { IdSelector, Update } from '@ngrx/entity';\n\nimport { Observable, of, throwError } from 'rxjs';\nimport {\n filter,\n map,\n mergeMap,\n shareReplay,\n withLatestFrom,\n take,\n} from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { defaultSelectId, toUpdateFactory } from '../utils/utilities';\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCacheSelector } from '../selectors/entity-cache-selector';\nimport { EntityCollection } from '../reducers/entity-collection';\nimport { EntityCommands } from './entity-commands';\nimport { EntityDispatcher, PersistanceCanceled } from './entity-dispatcher';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\nimport { EntityOp, OP_ERROR, OP_SUCCESS } from '../actions/entity-op';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { QueryParams } from '../dataservices/interfaces';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Dispatches EntityCollection actions to their reducers and effects (default implementation).\n * All save commands rely on an Ngrx Effect such as `EntityEffects.persist$`.\n */\nexport class EntityDispatcherBase<T> implements EntityDispatcher<T> {\n /** Utility class with methods to validate EntityAction payloads.*/\n guard: EntityActionGuard<T>;\n\n private entityCollection$: Observable<EntityCollection<T>>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate: (entity: Partial<T>) => Update<T>;\n\n constructor(\n /** Name of the entity type for which entities are dispatched */\n public entityName: string,\n /** Creates an {EntityAction} */\n public entityActionFactory: EntityActionFactory,\n /** The store, scoped to the EntityCache */\n public store: Store<EntityCache>,\n /** Returns the primary key (id) of this entity */\n public selectId: IdSelector<T> = defaultSelectId,\n /**\n * Dispatcher options configure dispatcher behavior such as\n * whether add is optimistic or pessimistic by default.\n */\n private defaultDispatcherOptions: EntityDispatcherDefaultOptions,\n /** Actions scanned by the store after it processed them with reducers. */\n private reducedActions$: Observable<Action>,\n /** Store selector for the EntityCache */\n entityCacheSelector: EntityCacheSelector,\n /** Generates correlation ids for query and save methods */\n private correlationIdGenerator: CorrelationIdGenerator\n ) {\n this.guard = new EntityActionGuard(entityName, selectId);\n this.toUpdate = toUpdateFactory<T>(selectId);\n\n const collectionSelector = createSelector(\n entityCacheSelector,\n (cache) => cache[entityName] as EntityCollection<T>\n );\n this.entityCollection$ = store.select(collectionSelector);\n }\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param entityOp {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n entityOp: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.entityActionFactory.create({\n entityName: this.entityName,\n entityOp,\n data,\n ...options,\n });\n }\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n const action = this.createEntityAction(op, data, options);\n this.dispatch(action);\n return action;\n }\n\n /**\n * Dispatch an Action to the store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n this.store.dispatch(action);\n return action;\n }\n\n // #region Query and save operations\n\n /**\n * Dispatch action to save a new entity to remote storage.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @returns A terminating Observable of the entity\n * after server reports successful save or the save error.\n */\n add(entity: T, options?: EntityActionOptions): Observable<T> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticAdd\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_ADD_ONE,\n entity,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeEntity(action);\n }\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e)]!),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to cancel the persistence operation (query or save).\n * Will cause save observable to error with a PersistenceCancel error.\n * Caller is responsible for undoing changes in cache from pending optimistic save\n * @param correlationId The correlation id for the corresponding EntityAction\n * @param [reason] explains why canceled and by whom.\n */\n cancel(\n correlationId: any,\n reason?: string,\n options?: EntityActionOptions\n ): void {\n if (!correlationId) {\n throw new Error('Missing correlationId');\n }\n this.createAndDispatch(EntityOp.CANCEL_PERSIST, reason, { correlationId });\n }\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The primary key of the entity to remove\n * @returns A terminating Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(entity: T, options?: EntityActionOptions): Observable<number | string>;\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The entity to delete\n * @returns A terminating Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(\n key: number | string,\n options?: EntityActionOptions\n ): Observable<number | string>;\n delete(\n arg: number | string | T,\n options?: EntityActionOptions\n ): Observable<number | string> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticDelete\n );\n const key = this.getKey(arg);\n const action = this.createEntityAction(\n EntityOp.SAVE_DELETE_ONE,\n key,\n options\n );\n this.guard.mustBeKey(action);\n this.dispatch(action);\n return this.getResponseData$<number | string>(options.correlationId).pipe(\n map(() => key),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * merge the queried entities into the cached collection.\n * @returns A terminating Observable of the queried entities that are in the collection\n * after server reports success query or the query error.\n * @see load()\n */\n getAll(options?: EntityActionOptions): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_ALL, null, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n // Use the returned entity ids to get the entities from the collection\n // as they might be different from the entities returned from the server\n // because of unsaved changes (deletes or updates).\n withLatestFrom(this.entityCollection$),\n map(([entities, collection]) =>\n entities.reduce((acc, e) => {\n const entity = collection.entities[this.selectId(e)];\n if (entity) {\n acc.push(entity); // only return an entity found in the collection\n }\n return acc;\n }, [] as T[])\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entity with this primary key.\n * If the server returns an entity,\n * merge it into the cached collection.\n * @returns A terminating Observable of the collection\n * after server reports successful query or the query error.\n */\n getByKey(key: any, options?: EntityActionOptions): Observable<T> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_BY_KEY, key, options);\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(\n ([entity, collection]) => collection.entities[this.selectId(entity)]!\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and merge the results into the cached collection.\n * @param queryParams the query in a form understood by the server\n * @returns A terminating Observable of the queried entities\n * after server reports successful query or the query error.\n */\n getWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(\n EntityOp.QUERY_MANY,\n queryParams,\n options\n );\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n // Use the returned entity ids to get the entities from the collection\n // as they might be different from the entities returned from the server\n // because of unsaved changes (deletes or updates).\n withLatestFrom(this.entityCollection$),\n map(([entities, collection]) =>\n entities.reduce((acc, e) => {\n const entity = collection.entities[this.selectId(e)];\n if (entity) {\n acc.push(entity); // only return an entity found in the collection\n }\n return acc;\n }, [] as T[])\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * completely replace the cached collection with the queried entities.\n * @returns A terminating Observable of the entities in the collection\n * after server reports successful query or the query error.\n * @see getAll\n */\n load(options?: EntityActionOptions): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_LOAD, null, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and completely replace the cached collection with the queried entities.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence load behavior\n * @returns A terminating Observable of the queried entities\n * after server reports successful query or the query error.\n */\n loadWithQuery(queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n options = this.setQueryEntityActionOptions(options);\n const action = this.createEntityAction(EntityOp.QUERY_MANY, queryParams, options);\n this.dispatch(action);\n return this.getResponseData$<T[]>(options.correlationId).pipe(\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to save the updated entity (or partial entity) in remote storage.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity update entity, which might be a partial of T but must at least have its key.\n * @returns A terminating Observable of the updated entity\n * after server reports successful save or the save error.\n */\n update(entity: Partial<T>, options?: EntityActionOptions): Observable<T> {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n const update = this.toUpdate(entity);\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticUpdate\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_UPDATE_ONE,\n update,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeUpdate(action);\n }\n this.dispatch(action);\n return this.getResponseData$<UpdateResponseData<T>>(\n options.correlationId\n ).pipe(\n // Use the update entity data id to get the entity from the collection\n // as might be different from the entity returned from the server\n // because the id changed or there are unsaved changes.\n map((updateData) => updateData.changes),\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e as T)]!),\n shareReplay(1)\n );\n }\n\n /**\n * Dispatch action to save a new or existing entity to remote storage.\n * Only dispatch this action if your server supports upsert.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @returns A terminating Observable of the entity\n * after server reports successful save or the save error.\n */\n upsert(entity: T, options?: EntityActionOptions): Observable<T> {\n options = this.setSaveEntityActionOptions(\n options,\n this.defaultDispatcherOptions.optimisticUpsert\n );\n const action = this.createEntityAction(\n EntityOp.SAVE_UPSERT_ONE,\n entity,\n options\n );\n if (options.isOptimistic) {\n this.guard.mustBeEntity(action);\n }\n this.dispatch(action);\n return this.getResponseData$<T>(options.correlationId).pipe(\n // Use the returned entity data's id to get the entity from the collection\n // as it might be different from the entity returned from the server.\n withLatestFrom(this.entityCollection$),\n map(([e, collection]) => collection.entities[this.selectId(e)]!),\n shareReplay(1)\n );\n }\n // #endregion Query and save operations\n\n // #region Cache-only operations that do not update remote storage\n\n // Unguarded for performance.\n // EntityCollectionReducer<T> runs a guard (which throws)\n // Developer should understand cache-only methods well enough\n // to call them with the proper entities.\n // May reconsider and add guards in future.\n\n /**\n * Replace all entities in the cached collection.\n * Does not save to remote storage.\n */\n addAllToCache(entities: T[], options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_ALL, entities, options);\n }\n\n /**\n * Add a new entity directly to the cache.\n * Does not save to remote storage.\n * Ignored if an entity with the same primary key is already in cache.\n */\n addOneToCache(entity: T, options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_ONE, entity, options);\n }\n\n /**\n * Add multiple new entities directly to the cache.\n * Does not save to remote storage.\n * Entities with primary keys already in cache are ignored.\n */\n addManyToCache(entities: T[], options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.ADD_MANY, entities, options);\n }\n\n /** Clear the cached entity collection */\n clearCache(options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.REMOVE_ALL, undefined, options);\n }\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param entity The entity to remove\n */\n removeOneFromCache(entity: T, options?: EntityActionOptions): void;\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param key The primary key of the entity to remove\n */\n removeOneFromCache(key: number | string, options?: EntityActionOptions): void;\n removeOneFromCache(\n arg: (number | string) | T,\n options?: EntityActionOptions\n ): void {\n this.createAndDispatch(EntityOp.REMOVE_ONE, this.getKey(arg), options);\n }\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param entity The entities to remove\n */\n removeManyFromCache(entities: T[], options?: EntityActionOptions): void;\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param keys The primary keys of the entities to remove\n */\n removeManyFromCache(\n keys: (number | string)[],\n options?: EntityActionOptions\n ): void;\n removeManyFromCache(\n args: (number | string)[] | T[],\n options?: EntityActionOptions\n ): void {\n if (!args || args.length === 0) {\n return;\n }\n const keys =\n typeof args[0] === 'object'\n ? // if array[0] is a key, assume they're all keys\n (<T[]>args).map((arg) => this.getKey(arg))\n : args;\n this.createAndDispatch(EntityOp.REMOVE_MANY, keys, options);\n }\n\n /**\n * Update a cached entity directly.\n * Does not update that entity in remote storage.\n * Ignored if an entity with matching primary key is not in cache.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n */\n updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n const update: Update<T> = this.toUpdate(entity);\n this.createAndDispatch(EntityOp.UPDATE_ONE, update, options);\n }\n\n /**\n * Update multiple cached entities directly.\n * Does not update these entities in remote storage.\n * Entities whose primary keys are not in cache are ignored.\n * Update entities may be partial but must at least have their keys.\n * such partial entities patch their cached counterparts.\n */\n updateManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n if (!entities || entities.length === 0) {\n return;\n }\n const updates: Update<T>[] = entities.map((entity) =>\n this.toUpdate(entity)\n );\n this.createAndDispatch(EntityOp.UPDATE_MANY, updates, options);\n }\n\n /**\n * Add or update a new entity directly to the cache.\n * Does not save to remote storage.\n * Upsert entity might be a partial of T but must at least have its key.\n * Pass the Update<T> structure as the payload\n */\n upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n this.createAndDispatch(EntityOp.UPSERT_ONE, entity, options);\n }\n\n /**\n * Add or update multiple cached entities directly.\n * Does not save to remote storage.\n */\n upsertManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n if (!entities || entities.length === 0) {\n return;\n }\n this.createAndDispatch(EntityOp.UPSERT_MANY, entities, options);\n }\n\n /**\n * Set the pattern that the collection's filter applies\n * when using the `filteredEntities` selector.\n */\n setFilter(pattern: any): void {\n this.createAndDispatch(EntityOp.SET_FILTER, pattern);\n }\n\n /** Set the loaded flag */\n setLoaded(isLoaded: boolean): void {\n this.createAndDispatch(EntityOp.SET_LOADED, !!isLoaded);\n }\n\n /** Set the loading flag */\n setLoading(isLoading: boolean): void {\n this.createAndDispatch(EntityOp.SET_LOADING, !!isLoading);\n }\n // #endregion Cache-only operations that do not update remote storage\n\n // #region private helpers\n\n /** Get key from entity (unless arg is already a key) */\n private getKey(arg: number | string | T) {\n return typeof arg === 'object'\n ? this.selectId(arg)\n : (arg as number | string);\n }\n\n /**\n * Return Observable of data from the server-success EntityAction with\n * the given Correlation Id, after that action was processed by the ngrx store.\n * or else put the server error on the Observable error channel.\n * @param crid The correlationId for both the save and response actions.\n */\n private getResponseData$<D = any>(crid: any): Observable<D> {\n /**\n * reducedActions$ must be replay observable of the most recent action reduced by the store.\n * because the response action might have been dispatched to the store\n * before caller had a chance to subscribe.\n */\n return this.reducedActions$.pipe(\n filter((act: any) => !!act.payload),\n filter((act: EntityAction) => {\n const { correlationId, entityName, entityOp } = act.payload;\n return (\n entityName === this.entityName &&\n correlationId === crid &&\n (entityOp.endsWith(OP_SUCCESS) ||\n entityOp.endsWith(OP_ERROR) ||\n entityOp === EntityOp.CANCEL_PERSIST)\n );\n }),\n take(1),\n mergeMap((act) => {\n const { entityOp } = act.payload;\n return entityOp === EntityOp.CANCEL_PERSIST\n ? throwError(new PersistanceCanceled(act.payload.data))\n : entityOp.endsWith(OP_SUCCESS)\n ? of(act.payload.data as D)\n : throwError(act.payload.data.error);\n })\n );\n }\n\n private setQueryEntityActionOptions(\n options?: EntityActionOptions\n ): EntityActionOptions {\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n return { ...options, correlationId };\n }\n\n private setSaveEntityActionOptions(\n options?: EntityActionOptions,\n defaultOptimism?: boolean\n ): EntityActionOptions {\n options = options || {};\n const correlationId =\n options.correlationId == null\n ? this.correlationIdGenerator.next()\n : options.correlationId;\n const isOptimistic =\n options.isOptimistic == null\n ? defaultOptimism || false\n : options.isOptimistic === true;\n return { ...options, correlationId, isOptimistic };\n }\n // #endregion private helpers\n}\n","import { InjectionToken } from '@angular/core';\nimport { MetaReducer } from '@ngrx/store';\nimport { EntityCache } from './entity-cache';\n\nexport const ENTITY_CACHE_NAME = 'entityCache';\nexport const ENTITY_CACHE_NAME_TOKEN = new InjectionToken<string>(\n '@ngrx/data Entity Cache Name'\n);\n\nexport const ENTITY_CACHE_META_REDUCERS = new InjectionToken<\n MetaReducer<any, any>[]\n>('@ngrx/data Entity Cache Meta Reducers');\nexport const ENTITY_COLLECTION_META_REDUCERS = new InjectionToken<\n MetaReducer<any, any>[]\n>('@ngrx/data Entity Collection Meta Reducers');\n\nexport const INITIAL_ENTITY_CACHE_STATE = new InjectionToken<\n EntityCache | (() => EntityCache)\n>('@ngrx/data Initial Entity Cache State');\n","import { InjectionToken, Optional, FactoryProvider } from '@angular/core';\nimport { createFeatureSelector, MemoizedSelector } from '@ngrx/store';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n} from '../reducers/constants';\n\nexport const ENTITY_CACHE_SELECTOR_TOKEN = new InjectionToken<\n MemoizedSelector<Object, EntityCache>\n>('@ngrx/data Entity Cache Selector');\n\nexport const entityCacheSelectorProvider: FactoryProvider = {\n provide: ENTITY_CACHE_SELECTOR_TOKEN,\n useFactory: createEntityCacheSelector,\n deps: [[new Optional(), ENTITY_CACHE_NAME_TOKEN]],\n};\n\nexport type EntityCacheSelector = MemoizedSelector<Object, EntityCache>;\n\nexport function createEntityCacheSelector(\n entityCacheName?: string\n): MemoizedSelector<Object, EntityCache> {\n entityCacheName = entityCacheName || ENTITY_CACHE_NAME;\n return createFeatureSelector<EntityCache>(entityCacheName);\n}\n","import { Inject, Injectable, OnDestroy } from '@angular/core';\nimport { Action, Store, ScannedActionsSubject } from '@ngrx/store';\nimport { IdSelector } from '@ngrx/entity';\nimport { Observable, Subscription } from 'rxjs';\nimport { shareReplay } from 'rxjs/operators';\n\nimport { CorrelationIdGenerator } from '../utils/correlation-id-generator';\nimport { EntityDispatcherDefaultOptions } from './entity-dispatcher-default-options';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n EntityCacheSelector,\n ENTITY_CACHE_SELECTOR_TOKEN,\n} from '../selectors/entity-cache-selector';\nimport { EntityDispatcher } from './entity-dispatcher';\nimport { EntityDispatcherBase } from './entity-dispatcher-base';\n\n/** Creates EntityDispatchers for entity collections */\n@Injectable()\nexport class EntityDispatcherFactory implements OnDestroy {\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n reducedActions$: Observable<Action>;\n private raSubscription: Subscription;\n\n constructor(\n private entityActionFactory: EntityActionFactory,\n private store: Store<EntityCache>,\n private entityDispatcherDefaultOptions: EntityDispatcherDefaultOptions,\n @Inject(ScannedActionsSubject) scannedActions$: Observable<Action>,\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n private entityCacheSelector: EntityCacheSelector,\n private correlationIdGenerator: CorrelationIdGenerator\n ) {\n // Replay because sometimes in tests will fake data service with synchronous observable\n // which makes subscriber miss the dispatched actions.\n // Of course that's a testing mistake. But easy to forget, leading to painful debugging.\n this.reducedActions$ = scannedActions$.pipe(shareReplay(1));\n // Start listening so late subscriber won't miss the most recent action.\n this.raSubscription = this.reducedActions$.subscribe();\n }\n\n /**\n * Create an `EntityDispatcher` for an entity type `T` and store.\n */\n create<T>(\n /** Name of the entity type */\n entityName: string,\n /**\n * Function that returns the primary key for an entity `T`.\n * Usually acquired from `EntityDefinition` metadata.\n * @param {IdSelector<T>} selectId\n */\n selectId: IdSelector<T> = defaultSelectId,\n /** Defaults for options that influence dispatcher behavior such as whether\n * `add()` is optimistic or pessimistic;\n * @param {Partial<EntityDispatcherDefaultOptions>} defaultOptions\n */\n defaultOptions: Partial<EntityDispatcherDefaultOptions> = {}\n ): EntityDispatcher<T> {\n // merge w/ defaultOptions with injected defaults\n const options: EntityDispatcherDefaultOptions = {\n ...this.entityDispatcherDefaultOptions,\n ...defaultOptions,\n };\n return new EntityDispatcherBase<T>(\n entityName,\n this.entityActionFactory,\n this.store,\n selectId,\n options,\n this.reducedActions$,\n this.entityCacheSelector,\n this.correlationIdGenerator\n );\n }\n\n ngOnDestroy() {\n this.raSubscription.unsubscribe();\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { SchedulerLike } from 'rxjs';\n\n// See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n/** Token to inject a special RxJS Scheduler during marble tests. */\nexport const ENTITY_EFFECTS_SCHEDULER = new InjectionToken<SchedulerLike>(\n '@ngrx/data Entity Effects Scheduler'\n);\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { Action } from '@ngrx/store';\nimport { Actions, ofType, createEffect } from '@ngrx/effects';\n\nimport {\n asyncScheduler,\n Observable,\n of,\n merge,\n race,\n SchedulerLike,\n} from 'rxjs';\nimport {\n concatMap,\n catchError,\n delay,\n filter,\n map,\n mergeMap,\n} from 'rxjs/operators';\n\nimport { DataServiceError } from '../dataservices/data-service-error';\nimport {\n ChangeSet,\n excludeEmptyChangeSetItems,\n} from '../actions/entity-cache-change-set';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { EntityOp } from '../actions/entity-op';\n\nimport {\n EntityCacheAction,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesCanceled,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\nimport { EntityCacheDataService } from '../dataservices/entity-cache-data.service';\nimport { ENTITY_EFFECTS_SCHEDULER } from './entity-effects-scheduler';\nimport { Logger } from '../utils/interfaces';\n\n@Injectable()\nexport class EntityCacheEffects {\n // See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */\n private responseDelay = 10;\n\n constructor(\n private actions: Actions,\n private dataService: EntityCacheDataService,\n private entityActionFactory: EntityActionFactory,\n private logger: Logger,\n /**\n * Injecting an optional Scheduler that will be undefined\n * in normal application usage, but its injected here so that you can mock out\n * during testing using the RxJS TestScheduler for simulating passages of time.\n */\n @Optional()\n @Inject(ENTITY_EFFECTS_SCHEDULER)\n private scheduler: SchedulerLike\n ) {}\n\n /**\n * Observable of SAVE_ENTITIES_CANCEL actions with non-null correlation ids\n */\n saveEntitiesCancel$: Observable<SaveEntitiesCancel> = createEffect(\n () =>\n this.actions.pipe(\n ofType(EntityCacheAction.SAVE_ENTITIES_CANCEL),\n filter((a: SaveEntitiesCancel) => a.payload.correlationId != null)\n ),\n { dispatch: false }\n );\n\n // Concurrent persistence requests considered unsafe.\n // `mergeMap` allows for concurrent requests which may return in any order\n saveEntities$: Observable<Action> = createEffect(() =>\n this.actions.pipe(\n ofType(EntityCacheAction.SAVE_ENTITIES),\n mergeMap((action: SaveEntities) => this.saveEntities(action))\n )\n );\n\n /**\n * Perform the requested SaveEntities actions and return a scalar Observable<Action>\n * that the effect should dispatch to the store after the server responds.\n * @param action The SaveEntities action\n */\n saveEntities(action: SaveEntities): Observable<Action> {\n const error = action.payload.error;\n if (error) {\n return this.handleSaveEntitiesError$(action)(error);\n }\n try {\n const changeSet = excludeEmptyChangeSetItems(action.payload.changeSet);\n const { correlationId, mergeStrategy, tag, url } = action.payload;\n const options = { correlationId, mergeStrategy, tag };\n\n if (changeSet.changes.length === 0) {\n // nothing to save\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // Cancellation: returns Observable<SaveEntitiesCanceled> for a saveEntities action\n // whose correlationId matches the cancellation correlationId\n const c = this.saveEntitiesCancel$.pipe(\n filter((a) => correlationId === a.payload.correlationId),\n map(\n (a) =>\n new SaveEntitiesCanceled(\n correlationId,\n a.payload.reason,\n a.payload.tag\n )\n )\n );\n\n // Data: SaveEntities result as a SaveEntitiesSuccess action\n const d = this.dataService.saveEntities(changeSet, url).pipe(\n concatMap((result) =>\n this.handleSaveEntitiesSuccess$(\n action,\n this.entityActionFactory\n )(result)\n ),\n catchError(this.handleSaveEntitiesError$(action))\n );\n\n // Emit which ever gets there first; the other observable is terminated.\n return race(c, d);\n } catch (err: any) {\n return this.handleSaveEntitiesError$(action)(err);\n }\n }\n\n /** return handler of error result of saveEntities, returning a scalar observable of error action */\n private handleSaveEntitiesError$(\n action: SaveEntities\n ): (err: DataServiceError | Error) => Observable<Action> {\n // Although error may return immediately,\n // ensure observable takes some time,\n // as app likely assumes asynchronous response.\n return (err: DataServiceError | Error) => {\n const error =\n err instanceof DataServiceError ? err : new DataServiceError(err, null);\n return of(new SaveEntitiesError(error, action)).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n };\n }\n\n /** return handler of the ChangeSet result of successful saveEntities() */\n private handleSaveEntitiesSuccess$(\n action: SaveEntities,\n entityActionFactory: EntityActionFactory\n ): (changeSet: ChangeSet) => Observable<Action> {\n const { url, correlationId, mergeStrategy, tag } = action.payload;\n const options = { correlationId, mergeStrategy, tag };\n\n return (changeSet) => {\n // DataService returned a ChangeSet with possible updates to the saved entities\n if (changeSet) {\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // No ChangeSet = Server probably responded '204 - No Content' because\n // it made no changes to the inserted/updated entities.\n // Respond with success action best on the ChangeSet in the request.\n changeSet = action.payload.changeSet;\n\n // If pessimistic save, return success action with the original ChangeSet\n if (!action.payload.isOptimistic) {\n return of(new SaveEntitiesSuccess(changeSet, url, options));\n }\n\n // If optimistic save, avoid cache grinding by just turning off the loading flags\n // for all collections in the original ChangeSet\n const entityNames = changeSet.changes.reduce(\n (acc, item) =>\n acc.indexOf(item.entityName) === -1\n ? acc.concat(item.entityName)\n : acc,\n [] as string[]\n );\n return merge(\n entityNames.map((name) =>\n entityActionFactory.create(name, EntityOp.SET_LOADING, false)\n )\n );\n };\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { Action } from '@ngrx/store';\nimport { Actions, createEffect } from '@ngrx/effects';\nimport { Update } from '@ngrx/entity';\n\nimport { asyncScheduler, Observable, of, race, SchedulerLike } from 'rxjs';\nimport { catchError, delay, filter, map, mergeMap } from 'rxjs/operators';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionFactory } from '../actions/entity-action-factory';\nimport { ENTITY_EFFECTS_SCHEDULER } from './entity-effects-scheduler';\nimport { EntityOp, makeSuccessOp } from '../actions/entity-op';\nimport { ofEntityOp } from '../actions/entity-action-operators';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\nimport { EntityDataService } from '../dataservices/entity-data.service';\nimport { PersistenceResultHandler } from '../dataservices/persistence-result-handler.service';\n\nexport const persistOps: EntityOp[] = [\n EntityOp.QUERY_ALL,\n EntityOp.QUERY_LOAD,\n EntityOp.QUERY_BY_KEY,\n EntityOp.QUERY_MANY,\n EntityOp.SAVE_ADD_ONE,\n EntityOp.SAVE_DELETE_ONE,\n EntityOp.SAVE_UPDATE_ONE,\n EntityOp.SAVE_UPSERT_ONE,\n];\n\n@Injectable()\nexport class EntityEffects {\n // See https://github.com/ReactiveX/rxjs/blob/master/doc/marble-testing.md\n /** Delay for error and skip observables. Must be multiple of 10 for marble testing. */\n private responseDelay = 10;\n\n /**\n * Observable of non-null cancellation correlation ids from CANCEL_PERSIST actions\n */\n cancel$: Observable<any> = createEffect(\n () =>\n this.actions.pipe(\n ofEntityOp(EntityOp.CANCEL_PERSIST),\n map((action: EntityAction) => action.payload.correlationId),\n filter((id) => id != null)\n ),\n { dispatch: false }\n );\n\n // `mergeMap` allows for concurrent requests which may return in any order\n persist$: Observable<Action> = createEffect(() =>\n this.actions.pipe(\n ofEntityOp(persistOps),\n mergeMap((action) => this.persist(action))\n )\n );\n\n constructor(\n private actions: Actions<EntityAction>,\n private dataService: EntityDataService,\n private entityActionFactory: EntityActionFactory,\n private resultHandler: PersistenceResultHandler,\n /**\n * Injecting an optional Scheduler that will be undefined\n * in normal application usage, but its injected here so that you can mock out\n * during testing using the RxJS TestScheduler for simulating passages of time.\n */\n @Optional()\n @Inject(ENTITY_EFFECTS_SCHEDULER)\n private scheduler: SchedulerLike\n ) {}\n\n /**\n * Perform the requested persistence operation and return a scalar Observable<Action>\n * that the effect should dispatch to the store after the server responds.\n * @param action A persistence operation EntityAction\n */\n persist(action: EntityAction): Observable<Action> {\n if (action.payload.skip) {\n // Should not persist. Pretend it succeeded.\n return this.handleSkipSuccess$(action);\n }\n if (action.payload.error) {\n return this.handleError$(action)(action.payload.error);\n }\n try {\n // Cancellation: returns Observable of CANCELED_PERSIST for a persistence EntityAction\n // whose correlationId matches cancellation correlationId\n const c = this.cancel$.pipe(\n filter((id) => action.payload.correlationId === id),\n map((id) =>\n this.entityActionFactory.createFromAction(action, {\n entityOp: EntityOp.CANCELED_PERSIST,\n })\n )\n );\n\n // Data: entity collection DataService result as a successful persistence EntityAction\n const d = this.callDataService(action).pipe(\n map(this.resultHandler.handleSuccess(action)),\n catchError(this.handleError$(action))\n );\n\n // Emit which ever gets there first; the other observable is terminated.\n return race(c, d);\n } catch (err: any) {\n return this.handleError$(action)(err);\n }\n }\n\n private callDataService(action: EntityAction) {\n const { entityName, entityOp, data, httpOptions } = action.payload;\n const service = this.dataService.getService(entityName);\n switch (entityOp) {\n case EntityOp.QUERY_ALL:\n case EntityOp.QUERY_LOAD:\n return service.getAll(httpOptions);\n\n case EntityOp.QUERY_BY_KEY:\n return service.getById(data, httpOptions);\n\n case EntityOp.QUERY_MANY:\n return service.getWithQuery(data, httpOptions);\n\n case EntityOp.SAVE_ADD_ONE:\n return service.add(data, httpOptions);\n\n case EntityOp.SAVE_DELETE_ONE:\n return service.delete(data, httpOptions);\n\n case EntityOp.SAVE_UPDATE_ONE:\n const { id, changes } = data as Update<any>; // data must be Update<T>\n return service.update(data, httpOptions).pipe(\n map((updatedEntity: any) => {\n // Return an Update<T> with updated entity data.\n // If server returned entity data, merge with the changes that were sent\n // and set the 'changed' flag to true.\n // If server did not return entity data,\n // assume it made no additional changes of its own, return the original changes,\n // and set the `changed` flag to `false`.\n const hasData =\n updatedEntity && Object.keys(updatedEntity).length > 0;\n const responseData: UpdateResponseData<any> = hasData\n ? { id, changes: { ...changes, ...updatedEntity }, changed: true }\n : { id, changes, changed: false };\n return responseData;\n })\n );\n\n case EntityOp.SAVE_UPSERT_ONE:\n return service.upsert(data, httpOptions).pipe(\n map((upsertedEntity: any) => {\n const hasData =\n upsertedEntity && Object.keys(upsertedEntity).length > 0;\n return hasData ? upsertedEntity : data; // ensure a returned entity value.\n })\n );\n default:\n throw new Error(`Persistence action \"${entityOp}\" is not implemented.`);\n }\n }\n\n /**\n * Handle error result of persistence operation on an EntityAction,\n * returning a scalar observable of error action\n */\n private handleError$(\n action: EntityAction\n ): (error: Error) => Observable<EntityAction> {\n // Although error may return immediately,\n // ensure observable takes some time,\n // as app likely assumes asynchronous response.\n return (error: Error) =>\n of(this.resultHandler.handleError(action)(error)).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n }\n\n /**\n * Because EntityAction.payload.skip is true, skip the persistence step and\n * return a scalar success action that looks like the operation succeeded.\n */\n private handleSkipSuccess$(\n originalAction: EntityAction\n ): Observable<EntityAction> {\n const successOp = makeSuccessOp(originalAction.payload.entityOp);\n const successAction = this.entityActionFactory.createFromAction(\n originalAction,\n {\n entityOp: successOp,\n }\n );\n // Although returns immediately,\n // ensure observable takes one tick (by using a promise),\n // as app likely assumes asynchronous response.\n return of(successAction).pipe(\n delay(this.responseDelay, this.scheduler || asyncScheduler)\n );\n }\n}\n","/**\n * Filters the `entities` array argument and returns the original `entities`,\n * or a new filtered array of entities.\n * NEVER mutate the original `entities` array itself.\n **/\nexport type EntityFilterFn<T> = (entities: T[], pattern?: any) => T[];\n\n/**\n * Creates an {EntityFilterFn} that matches RegExp or RegExp string pattern\n * anywhere in any of the given props of an entity.\n * If pattern is a string, spaces are significant and ignores case.\n */\nexport function PropsFilterFnFactory<T = any>(\n props: (keyof T)[] = []\n): EntityFilterFn<T> {\n if (props.length === 0) {\n // No properties -> nothing could match -> return unfiltered\n return (entities: T[], pattern: string) => entities;\n }\n\n return (entities: T[], pattern: string | RegExp) => {\n if (!entities) {\n return [];\n }\n\n const regExp =\n typeof pattern === 'string' ? new RegExp(pattern, 'i') : pattern;\n if (regExp) {\n const predicate = (e: any) => props.some((prop) => regExp.test(e[prop]));\n return entities.filter(predicate);\n }\n return entities;\n };\n}\n","import { Action, Store } from '@ngrx/store';\nimport { Dictionary, IdSelector, Update } from '@ngrx/entity';\n\nimport { Observable } from 'rxjs';\n\nimport { EntityAction, EntityActionOptions } from '../actions/entity-action';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\nimport { EntityDispatcher } from '../dispatchers/entity-dispatcher';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';\nimport { EntityOp } from '../actions/entity-op';\nimport { EntitySelectors } from '../selectors/entity-selectors';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\nimport { QueryParams } from '../dataservices/interfaces';\n\n/**\n * Base class for a concrete EntityCollectionService<T>.\n * Can be instantiated. Cannot be injected. Use EntityCollectionServiceFactory to create.\n * @param EntityCollectionServiceElements The ingredients for this service\n * as a source of supporting services for creating an EntityCollectionService<T> instance.\n */\nexport class EntityCollectionServiceBase<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n> implements EntityCollectionService<T>\n{\n /** Dispatcher of EntityCommands (EntityActions) */\n readonly dispatcher: EntityDispatcher<T>;\n\n /** All selectors of entity collection properties */\n readonly selectors: EntitySelectors<T>;\n\n /** All selectors$ (observables of entity collection properties) */\n readonly selectors$: S$;\n\n constructor(\n /** Name of the entity type of this collection service */\n public readonly entityName: string,\n /** Creates the core elements of the EntityCollectionService for this entity type */\n serviceElementsFactory: EntityCollectionServiceElementsFactory\n ) {\n entityName = entityName.trim();\n const { dispatcher, selectors, selectors$ } = serviceElementsFactory.create<\n T,\n S$\n >(entityName);\n\n this.entityName = entityName;\n this.dispatcher = dispatcher;\n this.guard = dispatcher.guard;\n this.selectId = dispatcher.selectId;\n this.toUpdate = dispatcher.toUpdate;\n\n this.selectors = selectors;\n this.selectors$ = selectors$;\n this.collection$ = selectors$.collection$;\n this.count$ = selectors$.count$;\n this.entities$ = selectors$.entities$;\n this.entityActions$ = selectors$.entityActions$;\n this.entityMap$ = selectors$.entityMap$;\n this.errors$ = selectors$.errors$;\n this.filter$ = selectors$.filter$;\n this.filteredEntities$ = selectors$.filteredEntities$;\n this.keys$ = selectors$.keys$;\n this.loaded$ = selectors$.loaded$;\n this.loading$ = selectors$.loading$;\n this.changeState$ = selectors$.changeState$;\n }\n\n /**\n * Create an {EntityAction} for this entity type.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the EntityAction\n */\n createEntityAction<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.dispatcher.createEntityAction(op, data, options);\n }\n\n /**\n * Create an {EntityAction} for this entity type and\n * dispatch it immediately to the store.\n * @param op {EntityOp} the entity operation\n * @param [data] the action data\n * @param [options] additional options\n * @returns the dispatched EntityAction\n */\n createAndDispatch<P = any>(\n op: EntityOp,\n data?: P,\n options?: EntityActionOptions\n ): EntityAction<P> {\n return this.dispatcher.createAndDispatch(op, data, options);\n }\n\n /**\n * Dispatch an action of any type to the ngrx store.\n * @param action the Action\n * @returns the dispatched Action\n */\n dispatch(action: Action): Action {\n return this.dispatcher.dispatch(action);\n }\n\n /** The NgRx Store for the {EntityCache} */\n get store() {\n return this.dispatcher.store;\n }\n\n /**\n * Utility class with methods to validate EntityAction payloads.\n */\n guard: EntityActionGuard<T>;\n\n /** Returns the primary key (id) of this entity */\n selectId: IdSelector<T>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `update...` and `upsert...` methods take `Update<T>` args\n */\n toUpdate: (entity: Partial<T>) => Update<T>;\n\n // region Dispatch commands\n\n /**\n * Dispatch action to save a new entity to remote storage.\n * @param entity entity to add, which may omit its key if pessimistic and the server creates the key;\n * must have a key if optimistic save.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the entity\n * after server reports successful save or the save error.\n */\n add(\n entity: Partial<T>,\n options: EntityActionOptions & { isOptimistic: false }\n ): Observable<T>;\n add(entity: T, options?: EntityActionOptions): Observable<T>;\n add(entity: T, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.add(entity, options);\n }\n\n /**\n * Dispatch action to cancel the persistence operation (query or save) with the given correlationId.\n * @param correlationId The correlation id for the corresponding EntityAction\n * @param [reason] explains why canceled and by whom.\n * @param [options] options such as the tag and mergeStrategy\n */\n cancel(\n correlationId: any,\n reason?: string,\n options?: EntityActionOptions\n ): void {\n this.dispatcher.cancel(correlationId, reason, options);\n }\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The entity to delete\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(entity: T, options?: EntityActionOptions): Observable<number | string>;\n\n /**\n * Dispatch action to delete entity from remote storage by key.\n * @param key The primary key of the entity to remove\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the deleted key\n * after server reports successful save or the save error.\n */\n delete(\n key: number | string,\n options?: EntityActionOptions\n ): Observable<number | string>;\n delete(\n arg: number | string | T,\n options?: EntityActionOptions\n ): Observable<number | string> {\n return this.dispatcher.delete(arg as any, options);\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * merge the queried entities into the cached collection.\n * @param [options] options that influence merge behavior\n * @returns Observable of the collection\n * after server reports successful query or the query error.\n * @see load()\n */\n getAll(options?: EntityActionOptions): Observable<T[]> {\n return this.dispatcher.getAll(options);\n }\n\n /**\n * Dispatch action to query remote storage for the entity with this primary key.\n * If the server returns an entity,\n * merge it into the cached collection.\n * @param key The primary key of the entity to get.\n * @param [options] options that influence merge behavior\n * @returns Observable of the queried entity that is in the collection\n * after server reports success or the query error.\n */\n getByKey(key: any, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.getByKey(key, options);\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and merge the results into the cached collection.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence merge behavior\n * @returns Observable of the queried entities\n * after server reports successful query or the query error.\n */\n getWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n return this.dispatcher.getWithQuery(queryParams, options);\n }\n\n /**\n * Dispatch action to query remote storage for all entities and\n * completely replace the cached collection with the queried entities.\n * @param [options] options that influence load behavior\n * @returns Observable of the collection\n * after server reports successful query or the query error.\n * @see getAll\n */\n load(options?: EntityActionOptions): Observable<T[]> {\n return this.dispatcher.load(options);\n }\n\n /**\n * Dispatch action to query remote storage for the entities that satisfy a query expressed\n * with either a query parameter map or an HTTP URL query string,\n * and completely replace the cached collection with the queried entities.\n * @param queryParams the query in a form understood by the server\n * @param [options] options that influence load behavior\n * @returns Observable of the queried entities\n * after server reports successful query or the query error.\n */\n loadWithQuery(\n queryParams: QueryParams | string,\n options?: EntityActionOptions\n ): Observable<T[]> {\n return this.dispatcher.loadWithQuery(queryParams, options);\n }\n\n /**\n * Dispatch action to save the updated entity (or partial entity) in remote storage.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity update entity, which might be a partial of T but must at least have its key.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the updated entity\n * after server reports successful save or the save error.\n */\n update(entity: Partial<T>, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.update(entity, options);\n }\n\n /**\n * Dispatch action to save a new or existing entity to remote storage.\n * Call only if the server supports upsert.\n * @param entity entity to add or upsert.\n * It may omit its key if an add, and is pessimistic, and the server creates the key;\n * must have a key if optimistic save.\n * @param [options] options that influence save and merge behavior\n * @returns Observable of the entity\n * after server reports successful save or the save error.\n */\n upsert(entity: T, options?: EntityActionOptions): Observable<T> {\n return this.dispatcher.upsert(entity, options);\n }\n\n /*** Cache-only operations that do not update remote storage ***/\n\n /**\n * Replace all entities in the cached collection.\n * Does not save to remote storage.\n * @param entities to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addAllToCache(entities: T[], options?: EntityActionOptions): void {\n this.dispatcher.addAllToCache(entities, options);\n }\n\n /**\n * Add a new entity directly to the cache.\n * Does not save to remote storage.\n * Ignored if an entity with the same primary key is already in cache.\n * @param entity to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addOneToCache(entity: T, options?: EntityActionOptions): void {\n this.dispatcher.addOneToCache(entity, options);\n }\n\n /**\n * Add multiple new entities directly to the cache.\n * Does not save to remote storage.\n * Entities with primary keys already in cache are ignored.\n * @param entities to add directly to cache.\n * @param [options] options such as mergeStrategy\n */\n addManyToCache(entities: T[], options?: EntityActionOptions): void {\n this.dispatcher.addManyToCache(entities, options);\n }\n\n /** Clear the cached entity collection */\n clearCache(): void {\n this.dispatcher.clearCache();\n }\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param entity The entity to remove\n * @param [options] options such as mergeStrategy\n */\n removeOneFromCache(entity: T, options?: EntityActionOptions): void;\n\n /**\n * Remove an entity directly from the cache.\n * Does not delete that entity from remote storage.\n * @param key The primary key of the entity to remove\n * @param [options] options such as mergeStrategy\n */\n removeOneFromCache(key: number | string, options?: EntityActionOptions): void;\n removeOneFromCache(\n arg: (number | string) | T,\n options?: EntityActionOptions\n ): void {\n this.dispatcher.removeOneFromCache(arg as any, options);\n }\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param entity The entities to remove\n * @param [options] options such as mergeStrategy\n */\n removeManyFromCache(entities: T[], options?: EntityActionOptions): void;\n\n /**\n * Remove multiple entities directly from the cache.\n * Does not delete these entities from remote storage.\n * @param keys The primary keys of the entities to remove\n * @param [options] options such as mergeStrategy\n */\n removeManyFromCache(\n keys: (number | string)[],\n options?: EntityActionOptions\n ): void;\n removeManyFromCache(\n args: (number | string)[] | T[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.removeManyFromCache(args as any[], options);\n }\n\n /**\n * Update a cached entity directly.\n * Does not update that entity in remote storage.\n * Ignored if an entity with matching primary key is not in cache.\n * The update entity may be partial (but must have its key)\n * in which case it patches the existing entity.\n * @param entity to update directly in cache.\n * @param [options] options such as mergeStrategy\n */\n updateOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n // update entity might be a partial of T but must at least have its key.\n // pass the Update<T> structure as the payload\n this.dispatcher.updateOneInCache(entity, options);\n }\n\n /**\n * Update multiple cached entities directly.\n * Does not update these entities in remote storage.\n * Entities whose primary keys are not in cache are ignored.\n * Update entities may be partial but must at least have their keys.\n * such partial entities patch their cached counterparts.\n * @param entities to update directly in cache.\n * @param [options] options such as mergeStrategy\n */\n updateManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.updateManyInCache(entities, options);\n }\n\n /**\n * Insert or update a cached entity directly.\n * Does not save to remote storage.\n * Upsert entity might be a partial of T but must at least have its key.\n * Pass the Update<T> structure as the payload.\n * @param entity to upsert directly in cache.\n * @param [options] options such as mergeStrategy\n */\n upsertOneInCache(entity: Partial<T>, options?: EntityActionOptions): void {\n this.dispatcher.upsertOneInCache(entity, options);\n }\n\n /**\n * Insert or update multiple cached entities directly.\n * Does not save to remote storage.\n * Upsert entities might be partial but must at least have their keys.\n * Pass an array of the Update<T> structure as the payload.\n * @param entities to upsert directly in cache.\n * @param [options] options such as mergeStrategy\n */\n upsertManyInCache(\n entities: Partial<T>[],\n options?: EntityActionOptions\n ): void {\n this.dispatcher.upsertManyInCache(entities, options);\n }\n\n /**\n * Set the pattern that the collection's filter applies\n * when using the `filteredEntities` selector.\n */\n setFilter(pattern: any): void {\n this.dispatcher.setFilter(pattern);\n }\n\n /** Set the loaded flag */\n setLoaded(isLoaded: boolean): void {\n this.dispatcher.setLoaded(!!isLoaded);\n }\n\n /** Set the loading flag */\n setLoading(isLoading: boolean): void {\n this.dispatcher.setLoading(!!isLoading);\n }\n\n // endregion Dispatch commands\n\n // region Selectors$\n /** Observable of the collection as a whole */\n collection$: Observable<EntityCollection<T>> | Store<EntityCollection<T>>;\n\n /** Observable of count of entities in the cached collection. */\n count$: Observable<number> | Store<number>;\n\n /** Observable of all entities in the cached collection. */\n entities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of actions related to this entity type. */\n entityActions$: Observable<EntityAction>;\n\n /** Observable of the map of entity keys to entities */\n entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;\n\n /** Observable of error actions related to this entity type. */\n errors$: Observable<EntityAction>;\n\n /** Observable of the filter pattern applied by the entity collection's filter function */\n filter$: Observable<any> | Store<any>;\n\n /** Observable of entities in the cached collection that pass the filter function */\n filteredEntities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of the keys of the cached collection, in the collection's native sort order */\n keys$: Observable<string[] | number[]> | Store<string[] | number[]>;\n\n /** Observable true when the collection has been loaded */\n loaded$: Observable<boolean> | Store<boolean>;\n\n /** Observable true when a multi-entity query command is in progress. */\n loading$: Observable<boolean> | Store<boolean>;\n\n /** Original entity values for entities with unsaved changes */\n changeState$: Observable<ChangeStateMap<T>> | Store<ChangeStateMap<T>>;\n\n // endregion Selectors$\n}\n","import { Injectable, Optional } from '@angular/core';\n\nimport { EntityCollection } from './entity-collection';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\n\n@Injectable()\nexport class EntityCollectionCreator {\n constructor(\n @Optional() private entityDefinitionService?: EntityDefinitionService\n ) {}\n\n /**\n * Create the default collection for an entity type.\n * @param entityName {string} entity type name\n */\n create<T = any, S extends EntityCollection<T> = EntityCollection<T>>(\n entityName: string\n ): S {\n const def =\n this.entityDefinitionService &&\n this.entityDefinitionService.getDefinition<T>(\n entityName,\n false /*shouldThrow*/\n );\n\n const initialState = def && def.initialState;\n\n return <S>(initialState || createEmptyEntityCollection<T>(entityName));\n }\n}\n\nexport function createEmptyEntityCollection<T>(\n entityName?: string\n): EntityCollection<T> {\n return {\n entityName,\n ids: [],\n entities: {},\n filter: undefined,\n loaded: false,\n loading: false,\n changeState: {},\n } as EntityCollection<T>;\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\n\n// Prod build requires `MemoizedSelector even though not used.\nimport { MemoizedSelector } from '@ngrx/store';\nimport { createSelector, Selector } from '@ngrx/store';\nimport { Dictionary } from '@ngrx/entity';\n\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n EntityCacheSelector,\n createEntityCacheSelector,\n} from './entity-cache-selector';\nimport { ENTITY_CACHE_NAME } from '../reducers/constants';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\nimport { EntityCollectionCreator } from '../reducers/entity-collection-creator';\nimport { EntityMetadata } from '../entity-metadata/entity-metadata';\n\n/**\n * The selector functions for entity collection members,\n * Selects from the entity collection to the collection member\n * Contrast with {EntitySelectors}.\n */\nexport interface CollectionSelectors<T> {\n readonly [selector: string]: any;\n\n /** Count of entities in the cached collection. */\n readonly selectCount: Selector<EntityCollection<T>, number>;\n\n /** All entities in the cached collection. */\n readonly selectEntities: Selector<EntityCollection<T>, T[]>;\n\n /** Map of entity keys to entities */\n readonly selectEntityMap: Selector<EntityCollection<T>, Dictionary<T>>;\n\n /** Filter pattern applied by the entity collection's filter function */\n readonly selectFilter: Selector<EntityCollection<T>, string>;\n\n /** Entities in the cached collection that pass the filter function */\n readonly selectFilteredEntities: Selector<EntityCollection<T>, T[]>;\n\n /** Keys of the cached collection, in the collection's native sort order */\n readonly selectKeys: Selector<EntityCollection<T>, string[] | number[]>;\n\n /** True when the collection has been fully loaded. */\n readonly selectLoaded: Selector<EntityCollection<T>, boolean>;\n\n /** True when a multi-entity query command is in progress. */\n readonly selectLoading: Selector<EntityCollection<T>, boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly selectChangeState: Selector<EntityCollection<T>, ChangeStateMap<T>>;\n}\n\n/**\n * The selector functions for entity collection members,\n * Selects from store root, through EntityCache, to the entity collection member\n * Contrast with {CollectionSelectors}.\n */\nexport interface EntitySelectors<T> {\n /** Name of the entity collection for these selectors */\n readonly entityName: string;\n\n readonly [name: string]: MemoizedSelector<EntityCollection<T>, any> | string;\n\n /** The cached EntityCollection itself */\n readonly selectCollection: MemoizedSelector<Object, EntityCollection<T>>;\n\n /** Count of entities in the cached collection. */\n readonly selectCount: MemoizedSelector<Object, number>;\n\n /** All entities in the cached collection. */\n readonly selectEntities: MemoizedSelector<Object, T[]>;\n\n /** The EntityCache */\n readonly selectEntityCache: MemoizedSelector<Object, EntityCache>;\n\n /** Map of entity keys to entities */\n readonly selectEntityMap: MemoizedSelector<Object, Dictionary<T>>;\n\n /** Filter pattern applied by the entity collection's filter function */\n readonly selectFilter: MemoizedSelector<Object, string>;\n\n /** Entities in the cached collection that pass the filter function */\n readonly selectFilteredEntities: MemoizedSelector<Object, T[]>;\n\n /** Keys of the cached collection, in the collection's native sort order */\n readonly selectKeys: MemoizedSelector<Object, string[] | number[]>;\n\n /** True when the collection has been fully loaded. */\n readonly selectLoaded: MemoizedSelector<Object, boolean>;\n\n /** True when a multi-entity query command is in progress. */\n readonly selectLoading: MemoizedSelector<Object, boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly selectChangeState: MemoizedSelector<Object, ChangeStateMap<T>>;\n}\n\n/** Creates EntitySelector functions for entity collections. */\n@Injectable()\nexport class EntitySelectorsFactory {\n private entityCollectionCreator: EntityCollectionCreator;\n private selectEntityCache: EntityCacheSelector;\n\n constructor(\n @Optional() entityCollectionCreator?: EntityCollectionCreator,\n @Optional()\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n selectEntityCache?: EntityCacheSelector\n ) {\n this.entityCollectionCreator =\n entityCollectionCreator || new EntityCollectionCreator();\n this.selectEntityCache =\n selectEntityCache || createEntityCacheSelector(ENTITY_CACHE_NAME);\n }\n\n /**\n * Create the NgRx selector from the store root to the named collection,\n * e.g. from Object to Heroes.\n * @param entityName the name of the collection\n */\n createCollectionSelector<\n T = any,\n C extends EntityCollection<T> = EntityCollection<T>\n >(entityName: string) {\n const getCollection = (cache: EntityCache = {}) =>\n <C>(\n (cache[entityName] ||\n this.entityCollectionCreator.create<T>(entityName))\n );\n return createSelector(this.selectEntityCache, getCollection);\n }\n\n /////// createCollectionSelectors //////////\n\n // Based on @ngrx/entity/state_selectors.ts\n\n /* eslint-disable @typescript-eslint/unified-signatures */\n // createCollectionSelectors(metadata) overload\n /**\n * Creates entity collection selectors from metadata.\n * @param metadata - EntityMetadata for the collection.\n * May be partial but much have `entityName`.\n */\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(metadata: EntityMetadata<T>): S;\n\n /* eslint-disable @typescript-eslint/unified-signatures */\n // createCollectionSelectors(entityName) overload\n /**\n * Creates default entity collection selectors for an entity type.\n * Use the metadata overload for additional collection selectors.\n * @param entityName - name of the entity type\n */\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(entityName: string): S;\n\n // createCollectionSelectors implementation\n createCollectionSelectors<\n T,\n S extends CollectionSelectors<T> = CollectionSelectors<T>\n >(metadataOrName: EntityMetadata<T> | string): S {\n const metadata =\n typeof metadataOrName === 'string'\n ? { entityName: metadataOrName }\n : metadataOrName;\n const selectKeys = (c: EntityCollection<T>) => c.ids;\n const selectEntityMap = (c: EntityCollection<T>) => c.entities;\n\n const selectEntities: Selector<EntityCollection<T>, T[]> = createSelector(\n selectKeys,\n selectEntityMap,\n (keys: (number | string)[], entities: Dictionary<T>): T[] =>\n keys.map((key) => entities[key] as T)\n );\n\n const selectCount: Selector<EntityCollection<T>, number> = createSelector(\n selectKeys,\n (keys) => keys.length\n );\n\n // EntityCollection selectors that go beyond the ngrx/entity/EntityState selectors\n const selectFilter = (c: EntityCollection<T>) => c.filter;\n\n const filterFn = metadata.filterFn;\n const selectFilteredEntities: Selector<EntityCollection<T>, T[]> = filterFn\n ? createSelector(\n selectEntities,\n selectFilter,\n (entities: T[], pattern: any): T[] => filterFn(entities, pattern)\n )\n : selectEntities;\n\n const selectLoaded = (c: EntityCollection<T>) => c.loaded;\n const selectLoading = (c: EntityCollection<T>) => c.loading;\n const selectChangeState = (c: EntityCollection<T>) => c.changeState;\n\n // Create collection selectors for each `additionalCollectionState` property.\n // These all extend from `selectCollection`\n const extra = metadata.additionalCollectionState || {};\n const extraSelectors: {\n [name: string]: Selector<EntityCollection<T>, any>;\n } = {};\n Object.keys(extra).forEach((k) => {\n extraSelectors['select' + k[0].toUpperCase() + k.slice(1)] = (\n c: EntityCollection<T>\n ) => (<any>c)[k];\n });\n\n return {\n selectCount,\n selectEntities,\n selectEntityMap,\n selectFilter,\n selectFilteredEntities,\n selectKeys,\n selectLoaded,\n selectLoading,\n selectChangeState,\n ...extraSelectors,\n } as S;\n }\n\n /////// create //////////\n\n // create(metadata) overload\n /**\n * Creates the store-rooted selectors for an entity collection.\n * {EntitySelectors$Factory} turns them into selectors$.\n *\n * @param metadata - EntityMetadata for the collection.\n * May be partial but much have `entityName`.\n *\n * Based on ngrx/entity/state_selectors.ts\n * Differs in that these selectors select from the NgRx store root,\n * through the collection, to the collection members.\n */\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n metadata: EntityMetadata<T>\n ): S;\n\n // create(entityName) overload\n /**\n * Creates the default store-rooted selectors for an entity collection.\n * {EntitySelectors$Factory} turns them into selectors$.\n * Use the metadata overload for additional collection selectors.\n *\n * @param entityName - name of the entity type.\n *\n * Based on ngrx/entity/state_selectors.ts\n * Differs in that these selectors select from the NgRx store root,\n * through the collection, to the collection members.\n */\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n entityName: string\n ): S;\n\n // createCollectionSelectors implementation\n create<T, S extends EntitySelectors<T> = EntitySelectors<T>>(\n metadataOrName: EntityMetadata<T> | string\n ): S {\n const metadata =\n typeof metadataOrName === 'string'\n ? { entityName: metadataOrName }\n : metadataOrName;\n const entityName = metadata.entityName;\n const selectCollection: Selector<\n Object,\n EntityCollection<T>\n > = this.createCollectionSelector<T>(entityName);\n const collectionSelectors = this.createCollectionSelectors<T>(metadata);\n\n const entitySelectors: {\n [name: string]: Selector<EntityCollection<T>, any>;\n } = {};\n Object.keys(collectionSelectors).forEach((k) => {\n entitySelectors[k] = createSelector(\n selectCollection,\n collectionSelectors[k]\n );\n });\n\n return {\n entityName,\n selectCollection,\n selectEntityCache: this.selectEntityCache,\n ...entitySelectors,\n } as S;\n }\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { Store } from '@ngrx/store';\nimport { Actions } from '@ngrx/effects';\nimport { Dictionary } from '@ngrx/entity';\n\nimport { Observable } from 'rxjs';\nimport { filter, shareReplay } from 'rxjs/operators';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { OP_ERROR } from '../actions/entity-op';\nimport { ofEntityType } from '../actions/entity-action-operators';\nimport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n EntityCacheSelector,\n} from './entity-cache-selector';\nimport { EntitySelectors } from './entity-selectors';\nimport { EntityCache } from '../reducers/entity-cache';\nimport {\n EntityCollection,\n ChangeStateMap,\n} from '../reducers/entity-collection';\n\n/**\n * The selector observable functions for entity collection members.\n */\nexport interface EntitySelectors$<T> {\n /** Name of the entity collection for these selectors$ */\n readonly entityName: string;\n\n /** Names from custom selectors from additionalCollectionState fits here, 'any' to avoid conflict with entityName */\n readonly [name: string]: Observable<any> | Store<any> | any;\n\n /** Observable of the collection as a whole */\n readonly collection$: Observable<EntityCollection> | Store<EntityCollection>;\n\n /** Observable of count of entities in the cached collection. */\n readonly count$: Observable<number> | Store<number>;\n\n /** Observable of all entities in the cached collection. */\n readonly entities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of actions related to this entity type. */\n readonly entityActions$: Observable<EntityAction>;\n\n /** Observable of the map of entity keys to entities */\n readonly entityMap$: Observable<Dictionary<T>> | Store<Dictionary<T>>;\n\n /** Observable of error actions related to this entity type. */\n readonly errors$: Observable<EntityAction>;\n\n /** Observable of the filter pattern applied by the entity collection's filter function */\n readonly filter$: Observable<string> | Store<string>;\n\n /** Observable of entities in the cached collection that pass the filter function */\n readonly filteredEntities$: Observable<T[]> | Store<T[]>;\n\n /** Observable of the keys of the cached collection, in the collection's native sort order */\n readonly keys$: Observable<string[] | number[]> | Store<string[] | number[]>;\n\n /** Observable true when the collection has been loaded */\n readonly loaded$: Observable<boolean> | Store<boolean>;\n\n /** Observable true when a multi-entity query command is in progress. */\n readonly loading$: Observable<boolean> | Store<boolean>;\n\n /** ChangeState (including original values) of entities with unsaved changes */\n readonly changeState$:\n | Observable<ChangeStateMap<T>>\n | Store<ChangeStateMap<T>>;\n}\n\n/** Creates observable EntitySelectors$ for entity collections. */\n@Injectable()\nexport class EntitySelectors$Factory {\n /** Observable of the EntityCache */\n entityCache$: Observable<EntityCache>;\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n entityActionErrors$: Observable<EntityAction>;\n\n constructor(\n private store: Store<any>,\n private actions: Actions<EntityAction>,\n @Inject(ENTITY_CACHE_SELECTOR_TOKEN)\n private selectEntityCache: EntityCacheSelector\n ) {\n // This service applies to the cache in ngrx/store named `cacheName`\n this.entityCache$ = this.store.select(this.selectEntityCache);\n this.entityActionErrors$ = actions.pipe(\n filter(\n (ea: EntityAction) =>\n ea.payload &&\n ea.payload.entityOp &&\n ea.payload.entityOp.endsWith(OP_ERROR)\n ),\n shareReplay(1)\n );\n }\n\n /**\n * Creates an entity collection's selectors$ observables for this factory's store.\n * `selectors$` are observable selectors of the cached entity collection.\n * @param entityName - is also the name of the collection.\n * @param selectors - selector functions for this collection.\n **/\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string,\n selectors: EntitySelectors<T>\n ): S$ {\n const selectors$: { [prop: string]: any } = {\n entityName,\n };\n\n Object.keys(selectors).forEach((name) => {\n if (name.startsWith('select')) {\n // strip 'select' prefix from the selector fn name and append `$`\n // Ex: 'selectEntities' => 'entities$'\n const name$ = name[6].toLowerCase() + name.substring(7) + '$';\n selectors$[name$] = this.store.select((<any>selectors)[name]);\n }\n });\n selectors$['entityActions$'] = this.actions.pipe(ofEntityType(entityName));\n selectors$['errors$'] = this.entityActionErrors$.pipe(\n ofEntityType(entityName)\n );\n return selectors$ as S$;\n }\n}\n","import { Injectable } from '@angular/core';\nimport { EntityDispatcher } from '../dispatchers/entity-dispatcher';\nimport { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport {\n EntitySelectors,\n EntitySelectorsFactory,\n} from '../selectors/entity-selectors';\nimport {\n EntitySelectors$,\n EntitySelectors$Factory,\n} from '../selectors/entity-selectors$';\n\n/** Core ingredients of an EntityCollectionService */\nexport interface EntityCollectionServiceElements<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n> {\n readonly dispatcher: EntityDispatcher<T>;\n readonly entityName: string;\n readonly selectors: EntitySelectors<T>;\n readonly selectors$: S$;\n}\n\n/** Creates the core elements of the EntityCollectionService for an entity type. */\n@Injectable()\nexport class EntityCollectionServiceElementsFactory {\n constructor(\n private entityDispatcherFactory: EntityDispatcherFactory,\n private entityDefinitionService: EntityDefinitionService,\n private entitySelectorsFactory: EntitySelectorsFactory,\n private entitySelectors$Factory: EntitySelectors$Factory\n ) {}\n\n /**\n * Get the ingredients for making an EntityCollectionService for this entity type\n * @param entityName - name of the entity type\n */\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string\n ): EntityCollectionServiceElements<T, S$> {\n entityName = entityName.trim();\n const definition =\n this.entityDefinitionService.getDefinition<T>(entityName);\n const dispatcher = this.entityDispatcherFactory.create<T>(\n entityName,\n definition.selectId,\n definition.entityDispatcherOptions\n );\n const selectors = this.entitySelectorsFactory.create<T>(\n definition.metadata\n );\n const selectors$ = this.entitySelectors$Factory.create<T, S$>(\n entityName,\n selectors\n );\n return {\n dispatcher,\n entityName,\n selectors,\n selectors$,\n };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceBase } from './entity-collection-service-base';\nimport { EntityCollectionServiceElementsFactory } from './entity-collection-service-elements-factory';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\n\n/**\n * Creates EntityCollectionService instances for\n * a cached collection of T entities in the ngrx store.\n */\n@Injectable()\nexport class EntityCollectionServiceFactory {\n constructor(\n /** Creates the core elements of the EntityCollectionService for an entity type. */\n public entityCollectionServiceElementsFactory: EntityCollectionServiceElementsFactory\n ) {}\n\n /**\n * Create an EntityCollectionService for an entity type\n * @param entityName - name of the entity type\n */\n create<T, S$ extends EntitySelectors$<T> = EntitySelectors$<T>>(\n entityName: string\n ): EntityCollectionService<T> {\n return new EntityCollectionServiceBase<T, S$>(\n entityName,\n this.entityCollectionServiceElementsFactory\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action, Store } from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityDispatcherFactory } from '../dispatchers/entity-dispatcher-factory';\nimport { EntitySelectors$Factory } from '../selectors/entity-selectors$';\nimport { EntityCollectionServiceFactory } from './entity-collection-service-factory';\n\n/** Core ingredients of an EntityServices class */\n@Injectable()\nexport class EntityServicesElements {\n constructor(\n /**\n * Creates EntityCollectionService instances for\n * a cached collection of T entities in the ngrx store.\n */\n public readonly entityCollectionServiceFactory: EntityCollectionServiceFactory,\n /** Creates EntityDispatchers for entity collections */\n entityDispatcherFactory: EntityDispatcherFactory,\n /** Creates observable EntitySelectors$ for entity collections. */\n entitySelectors$Factory: EntitySelectors$Factory,\n /** The ngrx store, scoped to the EntityCache */\n public readonly store: Store<EntityCache>\n ) {\n this.entityActionErrors$ = entitySelectors$Factory.entityActionErrors$;\n this.entityCache$ = entitySelectors$Factory.entityCache$;\n this.reducedActions$ = entityDispatcherFactory.reducedActions$;\n }\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n readonly entityActionErrors$: Observable<EntityAction>;\n\n /** Observable of the entire entity cache */\n readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n readonly reducedActions$: Observable<Action>;\n}\n","import { Injectable } from '@angular/core';\nimport { Action, Store } from '@ngrx/store';\n\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCollectionService } from './entity-collection-service';\nimport { EntityCollectionServiceFactory } from './entity-collection-service-factory';\nimport { EntityCollectionServiceMap, EntityServices } from './entity-services';\nimport { EntitySelectors$ } from '../selectors/entity-selectors$';\nimport { EntityServicesElements } from './entity-services-elements';\n\n/**\n * Base/default class of a central registry of EntityCollectionServices for all entity types.\n * Create your own subclass to add app-specific members for an improved developer experience.\n *\n * @usageNotes\n * ```ts\n * export class EntityServices extends EntityServicesBase {\n * constructor(entityServicesElements: EntityServicesElements) {\n * super(entityServicesElements);\n * }\n * // Extend with well-known, app entity collection services\n * // Convenience property to return a typed custom entity collection service\n * get companyService() {\n * return this.getEntityCollectionService<Model.Company>('Company') as CompanyService;\n * }\n * // Convenience dispatch methods\n * clearCompany(companyId: string) {\n * this.dispatch(new ClearCompanyAction(companyId));\n * }\n * }\n * ```\n */\n@Injectable()\nexport class EntityServicesBase implements EntityServices {\n // Dear @ngrx/data developer: think hard before changing the constructor.\n // Doing so will break apps that derive from this base class,\n // and many apps will derive from this class.\n //\n // Do not give this constructor an implementation.\n // Doing so makes it hard to mock classes that derive from this class.\n // Use getter properties instead. For example, see entityCache$\n constructor(private entityServicesElements: EntityServicesElements) {}\n\n // #region EntityServicesElement-based properties\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n get entityActionErrors$(): Observable<EntityAction> {\n return this.entityServicesElements.entityActionErrors$;\n }\n\n /** Observable of the entire entity cache */\n get entityCache$(): Observable<EntityCache> | Store<EntityCache> {\n return this.entityServicesElements.entityCache$;\n }\n\n /** Factory to create a default instance of an EntityCollectionService */\n get entityCollectionServiceFactory(): EntityCollectionServiceFactory {\n return this.entityServicesElements.entityCollectionServiceFactory;\n }\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent action reduced by the store.\n */\n get reducedActions$(): Observable<Action> {\n return this.entityServicesElements.reducedActions$;\n }\n\n /** The ngrx store, scoped to the EntityCache */\n protected get store(): Store<EntityCache> {\n return this.entityServicesElements.store;\n }\n\n // #endregion EntityServicesElement-based properties\n\n /** Dispatch any action to the store */\n dispatch(action: Action) {\n this.store.dispatch(action);\n }\n\n /** Registry of EntityCollectionService instances */\n private readonly EntityCollectionServices: EntityCollectionServiceMap = {};\n\n /**\n * Create a new default instance of an EntityCollectionService.\n * Prefer getEntityCollectionService() unless you really want a new default instance.\n * This one will NOT be registered with EntityServices!\n * @param entityName {string} Name of the entity type of the service\n */\n protected createEntityCollectionService<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n >(entityName: string): EntityCollectionService<T> {\n return this.entityCollectionServiceFactory.create<T, S$>(entityName);\n }\n\n /** Get (or create) the singleton instance of an EntityCollectionService\n * @param entityName {string} Name of the entity type of the service\n */\n getEntityCollectionService<\n T,\n S$ extends EntitySelectors$<T> = EntitySelectors$<T>\n >(entityName: string): EntityCollectionService<T> {\n let service = this.EntityCollectionServices[entityName];\n if (!service) {\n service = this.createEntityCollectionService<T, S$>(entityName);\n this.EntityCollectionServices[entityName] = service;\n }\n return service;\n }\n\n /** Register an EntityCollectionService under its entity type name.\n * Will replace a pre-existing service for that type.\n * @param service {EntityCollectionService} The entity service\n * @param serviceName {string} optional service name to use instead of the service's entityName\n */\n registerEntityCollectionService<T>(\n service: EntityCollectionService<T>,\n serviceName?: string\n ) {\n this.EntityCollectionServices[serviceName || service.entityName] = service;\n }\n\n /**\n * Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServices {EntityCollectionServiceMap | EntityCollectionService<any>[]}\n * EntityCollectionServices to register, either as a map or an array\n */\n registerEntityCollectionServices(\n entityCollectionServices:\n | EntityCollectionServiceMap\n | EntityCollectionService<any>[]\n ): void {\n if (Array.isArray(entityCollectionServices)) {\n entityCollectionServices.forEach((service) =>\n this.registerEntityCollectionService(service)\n );\n } else {\n Object.keys(entityCollectionServices || {}).forEach((serviceName) => {\n this.registerEntityCollectionService(\n entityCollectionServices[serviceName],\n serviceName\n );\n });\n }\n }\n}\n","import { Action, Store } from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from '../reducers/entity-cache';\nimport { EntityCollectionService } from './entity-collection-service';\n\n/**\n * Class-Interface for EntityCache and EntityCollection services.\n * Serves as an Angular provider token for this service class.\n * Includes a registry of EntityCollectionServices for all entity types.\n * Creates a new default EntityCollectionService for any entity type not in the registry.\n * Optionally register specialized EntityCollectionServices for individual types\n */\nexport abstract class EntityServices {\n /** Dispatch any action to the store */\n abstract dispatch(action: Action): void;\n\n /** Observable of error EntityActions (e.g. QUERY_ALL_ERROR) for all entity types */\n abstract readonly entityActionErrors$: Observable<EntityAction>;\n\n /** Observable of the entire entity cache */\n abstract readonly entityCache$: Observable<EntityCache> | Store<EntityCache>;\n\n /** Get (or create) the singleton instance of an EntityCollectionService\n * @param entityName {string} Name of the entity type of the service\n */\n abstract getEntityCollectionService<T = any>(\n entityName: string\n ): EntityCollectionService<T>;\n\n /**\n * Actions scanned by the store after it processed them with reducers.\n * A replay observable of the most recent Action (not just EntityAction) reduced by the store.\n */\n abstract readonly reducedActions$: Observable<Action>;\n\n // #region EntityCollectionService creation and registration API\n\n /** Register an EntityCollectionService under its entity type name.\n * Will replace a pre-existing service for that type.\n * @param service {EntityCollectionService} The entity service\n */\n abstract registerEntityCollectionService<T>(\n service: EntityCollectionService<T>\n ): void;\n\n /** Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServices Array of EntityCollectionServices to register\n */\n abstract registerEntityCollectionServices(\n entityCollectionServices: EntityCollectionService<any>[]\n ): void;\n\n /** Register entity services for several entity types at once.\n * Will replace a pre-existing service for that type.\n * @param entityCollectionServiceMap Map of service-name to entity-collection-service\n */\n abstract registerEntityCollectionServices(\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n entityCollectionServiceMap: EntityCollectionServiceMap\n ): void;\n // #endregion EntityCollectionService creation and registration API\n}\n\n/**\n * A map of service or entity names to their corresponding EntityCollectionServices.\n */\nexport interface EntityCollectionServiceMap {\n [entityName: string]: EntityCollectionService<any>;\n}\n","import { EntityState, Dictionary } from '@ngrx/entity';\n\n/** Types of change in a ChangeState instance */\nexport enum ChangeType {\n /** The entity has not changed from its last known server state. */\n Unchanged = 0,\n /** The entity was added to the collection */\n Added,\n /** The entity is scheduled for delete and was removed from the collection */\n Deleted,\n /** The entity in the collection was updated */\n Updated,\n}\n\n/**\n * Change state for an entity with unsaved changes;\n * an entry in an EntityCollection.changeState map\n */\nexport interface ChangeState<T> {\n changeType: ChangeType;\n originalValue?: T | undefined;\n}\n\n/**\n * Map of entity primary keys to entity ChangeStates.\n * Each entry represents an entity with unsaved changes.\n */\nexport type ChangeStateMap<T> = Dictionary<ChangeState<T>>;\n\n/**\n * Data and information about a collection of entities of a single type.\n * EntityCollections are maintained in the EntityCache within the ngrx store.\n */\nexport interface EntityCollection<T = any> extends EntityState<T> {\n /** Name of the entity type for this collection */\n entityName: string;\n /** A map of ChangeStates, keyed by id, for entities with unsaved changes */\n changeState: ChangeStateMap<T>;\n /** The user's current collection filter pattern */\n filter?: string;\n /** true if collection was ever filled by QueryAll; forced false if cleared */\n loaded: boolean;\n /** true when a query or save operation is in progress */\n loading: boolean;\n}\n","import { EntityAdapter, IdSelector, Update } from '@ngrx/entity';\n\nimport { ChangeType, EntityCollection } from './entity-collection';\nimport { defaultSelectId } from '../utils/utilities';\nimport { EntityChangeTracker } from './entity-change-tracker';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * The default implementation of EntityChangeTracker with\n * methods for tracking, committing, and reverting/undoing unsaved entity changes.\n * Used by EntityCollectionReducerMethods which should call tracker methods BEFORE modifying the collection.\n * See EntityChangeTracker docs.\n */\nexport class EntityChangeTrackerBase<T> implements EntityChangeTracker<T> {\n constructor(\n private adapter: EntityAdapter<T>,\n private selectId: IdSelector<T>\n ) {\n /** Extract the primary key (id); default to `id` */\n this.selectId = selectId || defaultSelectId;\n }\n\n // #region commit methods\n /**\n * Commit all changes as when the collection has been completely reloaded from the server.\n * Harmless when there are no entity changes to commit.\n * @param collection The entity collection\n */\n commitAll(collection: EntityCollection<T>): EntityCollection<T> {\n return Object.keys(collection.changeState).length === 0\n ? collection\n : { ...collection, changeState: {} };\n }\n\n /**\n * Commit changes for the given entities as when they have been refreshed from the server.\n * Harmless when there are no entity changes to commit.\n * @param entityOrIdList The entities to clear tracking or their ids.\n * @param collection The entity collection\n */\n commitMany(\n entityOrIdList: (number | string | T)[],\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n if (entityOrIdList == null || entityOrIdList.length === 0) {\n return collection; // nothing to commit\n }\n let didMutate = false;\n const changeState = entityOrIdList.reduce((chgState, entityOrId) => {\n const id =\n typeof entityOrId === 'object'\n ? this.selectId(entityOrId)\n : (entityOrId as string | number);\n if (chgState[id]) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id];\n }\n return chgState;\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Commit changes for the given entity as when it have been refreshed from the server.\n * Harmless when no entity changes to commit.\n * @param entityOrId The entity to clear tracking or its id.\n * @param collection The entity collection\n */\n commitOne(\n entityOrId: number | string | T,\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return entityOrId == null\n ? collection\n : this.commitMany([entityOrId], collection);\n }\n\n // #endregion commit methods\n\n // #region merge query\n /**\n * Merge query results into the collection, adjusting the ChangeState per the mergeStrategy.\n * @param entities Entities returned from querying the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a queried entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.PreserveChanges.\n * @returns The merged EntityCollection.\n */\n mergeQueryResults(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.PreserveChanges,\n mergeStrategy\n );\n }\n // #endregion merge query results\n\n // #region merge save results\n /**\n * Merge result of saving new entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param entities Entities returned from saving new entities to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveAdds(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.OverwriteChanges,\n mergeStrategy\n );\n }\n\n /**\n * Merge successful result of deleting entities on the server that have the given primary keys\n * Clears the entity changeState for those keys unless the MergeStrategy is ignoreChanges.\n * @param entities keys primary keys of the entities to remove/delete.\n * @param collection The entity collection\n * @param [mergeStrategy] How to adjust change tracking when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveDeletes(\n keys: (number | string)[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n mergeStrategy =\n mergeStrategy == null ? MergeStrategy.OverwriteChanges : mergeStrategy;\n // same logic for all non-ignore merge strategies: always clear (commit) the changes\n const deleteIds = keys as string[]; // make TypeScript happy\n collection =\n mergeStrategy === MergeStrategy.IgnoreChanges\n ? collection\n : this.commitMany(deleteIds, collection);\n return this.adapter.removeMany(deleteIds, collection);\n }\n\n /**\n * Merge result of saving updated entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param updateResponseData Entity response data returned from saving updated entities to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @param [skipUnchanged] True means skip update if server didn't change it. False by default.\n * If the update was optimistic and the server didn't make more changes of its own\n * then the updates are already in the collection and shouldn't make them again.\n * @returns The merged EntityCollection.\n */\n mergeSaveUpdates(\n updateResponseData: UpdateResponseData<T>[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy,\n skipUnchanged = false\n ): EntityCollection<T> {\n if (updateResponseData == null || updateResponseData.length === 0) {\n return collection; // nothing to merge.\n }\n\n let didMutate = false;\n let changeState = collection.changeState;\n mergeStrategy =\n mergeStrategy == null ? MergeStrategy.OverwriteChanges : mergeStrategy;\n let updates: Update<T>[];\n\n switch (mergeStrategy) {\n case MergeStrategy.IgnoreChanges:\n updates = filterChanged(updateResponseData);\n return this.adapter.updateMany(updates, collection);\n\n case MergeStrategy.OverwriteChanges:\n changeState = updateResponseData.reduce((chgState, update) => {\n const oldId = update.id;\n const change = chgState[oldId];\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[oldId];\n }\n return chgState;\n }, collection.changeState);\n\n collection = didMutate ? { ...collection, changeState } : collection;\n\n updates = filterChanged(updateResponseData);\n return this.adapter.updateMany(updates, collection);\n\n case MergeStrategy.PreserveChanges: {\n const updateableEntities = [] as UpdateResponseData<T>[];\n changeState = updateResponseData.reduce((chgState, update) => {\n const oldId = update.id;\n const change = chgState[oldId];\n if (change) {\n // Tracking a change so update original value but not the current value\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n const newId = this.selectId(update.changes as T);\n const oldChangeState = change;\n // If the server changed the id, register the new \"originalValue\" under the new id\n // and remove the change tracked under the old id.\n if (newId !== oldId) {\n delete chgState[oldId];\n }\n const newOrigValue = {\n ...(oldChangeState!.originalValue as any),\n ...(update.changes as any),\n };\n (chgState as any)[newId] = {\n ...oldChangeState,\n originalValue: newOrigValue,\n };\n } else {\n updateableEntities.push(update);\n }\n return chgState;\n }, collection.changeState);\n collection = didMutate ? { ...collection, changeState } : collection;\n\n updates = filterChanged(updateableEntities);\n return this.adapter.updateMany(updates, collection);\n }\n }\n\n /**\n * Conditionally keep only those updates that have additional server changes.\n * (e.g., for optimistic saves because they updates are already in the current collection)\n * Strip off the `changed` property.\n * @responseData Entity response data from server.\n * May be an UpdateResponseData<T>, a subclass of Update<T> with a 'changed' flag.\n * @returns Update<T> (without the changed flag)\n */\n function filterChanged(responseData: UpdateResponseData<T>[]): Update<T>[] {\n if (skipUnchanged === true) {\n // keep only those updates that the server changed (knowable if is UpdateResponseData<T>)\n responseData = responseData.filter((r) => r.changed === true);\n }\n // Strip unchanged property from responseData, leaving just the pure Update<T>\n // TODO: Remove? probably not necessary as the Update isn't stored and adapter will ignore `changed`.\n return responseData.map((r) => ({ id: r.id as any, changes: r.changes }));\n }\n }\n\n /**\n * Merge result of saving upserted entities into the collection, adjusting the ChangeState per the mergeStrategy.\n * The default is MergeStrategy.OverwriteChanges.\n * @param entities Entities returned from saving upserts to the server.\n * @param collection The entity collection\n * @param [mergeStrategy] How to merge a saved entity when the corresponding entity in the collection has an unsaved change.\n * Defaults to MergeStrategy.OverwriteChanges.\n * @returns The merged EntityCollection.\n */\n mergeSaveUpserts(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return this.mergeServerUpserts(\n entities,\n collection,\n MergeStrategy.OverwriteChanges,\n mergeStrategy\n );\n }\n // #endregion merge save results\n\n // #region query & save helpers\n /**\n *\n * @param entities Entities to merge\n * @param collection Collection into which entities are merged\n * @param defaultMergeStrategy How to merge when action's MergeStrategy is unspecified\n * @param [mergeStrategy] The action's MergeStrategy\n */\n private mergeServerUpserts(\n entities: T[],\n collection: EntityCollection<T>,\n defaultMergeStrategy: MergeStrategy,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (entities == null || entities.length === 0) {\n return collection; // nothing to merge.\n }\n\n let didMutate = false;\n let changeState = collection.changeState;\n mergeStrategy =\n mergeStrategy == null ? defaultMergeStrategy : mergeStrategy;\n\n switch (mergeStrategy) {\n case MergeStrategy.IgnoreChanges:\n return this.adapter.upsertMany(entities, collection);\n\n case MergeStrategy.OverwriteChanges:\n collection = this.adapter.upsertMany(entities, collection);\n\n changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n const change = chgState[id];\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id];\n }\n return chgState;\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n\n case MergeStrategy.PreserveChanges: {\n const upsertEntities = [] as T[];\n changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n const change = chgState[id];\n if (change) {\n if (!didMutate) {\n chgState = {\n ...chgState,\n [id]: {\n ...chgState[id]!,\n originalValue: entity,\n },\n };\n didMutate = true;\n }\n } else {\n upsertEntities.push(entity);\n }\n return chgState;\n }, collection.changeState);\n\n collection = this.adapter.upsertMany(upsertEntities, collection);\n return didMutate ? { ...collection, changeState } : collection;\n }\n }\n }\n // #endregion query & save helpers\n\n // #region track methods\n /**\n * Track multiple entities before adding them to the collection.\n * Does NOT add to the collection (the reducer's job).\n * @param entities The entities to add. They must all have their ids.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackAddMany(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n entities == null ||\n entities.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity add requires a key to be tracked`\n );\n }\n const trackedChange = chgState[id];\n\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n chgState[id] = { changeType: ChangeType.Added };\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before adding it to the collection.\n * Does NOT add to the collection (the reducer's job).\n * @param entity The entity to add. It must have an id.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n * If not specified, implementation supplies a default strategy.\n */\n trackAddOne(\n entity: T,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return entity == null\n ? collection\n : this.trackAddMany([entity], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before removing them with the intention of deleting them on the server.\n * Does NOT remove from the collection (the reducer's job).\n * @param keys The primary keys of the entities to delete.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackDeleteMany(\n keys: (number | string)[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n keys == null ||\n keys.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = keys.reduce((chgState, id) => {\n const originalValue = entityMap[id];\n if (originalValue) {\n const trackedChange = chgState[id];\n if (trackedChange) {\n if (trackedChange.changeType === ChangeType.Added) {\n // Special case: stop tracking an added entity that you delete\n // The caller must also detect this, remove it immediately from the collection\n // and skip attempt to delete on the server.\n cloneChgStateOnce();\n delete chgState[id];\n } else if (trackedChange.changeType === ChangeType.Updated) {\n // Special case: switch change type from Updated to Deleted.\n cloneChgStateOnce();\n chgState[id] = { ...chgState[id], changeType: ChangeType.Deleted };\n }\n } else {\n // Start tracking this entity\n cloneChgStateOnce();\n chgState[id] = { changeType: ChangeType.Deleted, originalValue };\n }\n }\n return chgState;\n\n function cloneChgStateOnce() {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n }\n }, collection.changeState);\n\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before it is removed with the intention of deleting it on the server.\n * Does NOT remove from the collection (the reducer's job).\n * @param key The primary key of the entity to delete.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackDeleteOne(\n key: number | string,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return key == null\n ? collection\n : this.trackDeleteMany([key], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before updating them in the collection.\n * Does NOT update the collection (the reducer's job).\n * @param updates The entities to update.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpdateMany(\n updates: Update<T>[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n updates == null ||\n updates.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = updates.reduce((chgState, update) => {\n const { id, changes: entity } = update;\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity update requires a key to be tracked`\n );\n }\n const originalValue = entityMap[id];\n // Only track if it is in the collection. Silently ignore if it is not.\n // @ngrx/entity adapter would also silently ignore.\n // Todo: should missing update entity really be reported as an error?\n if (originalValue) {\n const trackedChange = chgState[id];\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n chgState[id] = { changeType: ChangeType.Updated, originalValue };\n }\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before updating it in the collection.\n * Does NOT update the collection (the reducer's job).\n * @param update The entity to update.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpdateOne(\n update: Update<T>,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return update == null\n ? collection\n : this.trackUpdateMany([update], collection, mergeStrategy);\n }\n\n /**\n * Track multiple entities before upserting (adding and updating) them to the collection.\n * Does NOT update the collection (the reducer's job).\n * @param entities The entities to add or update. They must be complete entities with ids.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpsertMany(\n entities: T[],\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n if (\n mergeStrategy === MergeStrategy.IgnoreChanges ||\n entities == null ||\n entities.length === 0\n ) {\n return collection; // nothing to track\n }\n let didMutate = false;\n const entityMap = collection.entities;\n const changeState = entities.reduce((chgState, entity) => {\n const id = this.selectId(entity);\n if (id == null || id === '') {\n throw new Error(\n `${collection.entityName} entity upsert requires a key to be tracked`\n );\n }\n const trackedChange = chgState[id];\n\n if (!trackedChange) {\n if (!didMutate) {\n didMutate = true;\n chgState = { ...chgState };\n }\n\n const originalValue = entityMap[id];\n chgState[id] =\n originalValue == null\n ? { changeType: ChangeType.Added }\n : { changeType: ChangeType.Updated, originalValue };\n }\n return chgState;\n }, collection.changeState);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Track an entity before upsert (adding and updating) it to the collection.\n * Does NOT update the collection (the reducer's job).\n * @param entities The entity to add or update. It must be a complete entity with its id.\n * @param collection The entity collection\n * @param [mergeStrategy] Track by default. Don't track if is MergeStrategy.IgnoreChanges.\n */\n trackUpsertOne(\n entity: T,\n collection: EntityCollection<T>,\n mergeStrategy?: MergeStrategy\n ): EntityCollection<T> {\n return entity == null\n ? collection\n : this.trackUpsertMany([entity], collection, mergeStrategy);\n }\n // #endregion track methods\n\n // #region undo methods\n /**\n * Revert the unsaved changes for all collection.\n * Harmless when there are no entity changes to undo.\n * @param collection The entity collection\n */\n undoAll(collection: EntityCollection<T>): EntityCollection<T> {\n const ids = Object.keys(collection.changeState);\n\n const { remove, upsert } = ids.reduce(\n (acc, id) => {\n const changeState = acc.chgState[id]!;\n switch (changeState.changeType) {\n case ChangeType.Added:\n acc.remove.push(id);\n break;\n case ChangeType.Deleted:\n const removed = changeState!.originalValue;\n if (removed) {\n acc.upsert.push(removed);\n }\n break;\n case ChangeType.Updated:\n acc.upsert.push(changeState!.originalValue!);\n break;\n }\n return acc;\n },\n // entitiesToUndo\n {\n remove: [] as (number | string)[],\n upsert: [] as T[],\n chgState: collection.changeState,\n }\n );\n\n collection = this.adapter.removeMany(remove as string[], collection);\n collection = this.adapter.upsertMany(upsert, collection);\n\n return { ...collection, changeState: {} };\n }\n\n /**\n * Revert the unsaved changes for the given entities.\n * Harmless when there are no entity changes to undo.\n * @param entityOrIdList The entities to revert or their ids.\n * @param collection The entity collection\n */\n undoMany(\n entityOrIdList: (number | string | T)[],\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n if (entityOrIdList == null || entityOrIdList.length === 0) {\n return collection; // nothing to undo\n }\n let didMutate = false;\n\n const { changeState, remove, upsert } = entityOrIdList.reduce(\n (acc, entityOrId) => {\n let chgState = acc.changeState;\n const id =\n typeof entityOrId === 'object'\n ? this.selectId(entityOrId)\n : (entityOrId as string | number);\n const change = chgState[id]!;\n if (change) {\n if (!didMutate) {\n chgState = { ...chgState };\n didMutate = true;\n }\n delete chgState[id]; // clear tracking of this entity\n acc.changeState = chgState;\n switch (change.changeType) {\n case ChangeType.Added:\n acc.remove.push(id);\n break;\n case ChangeType.Deleted:\n const removed = change!.originalValue;\n if (removed) {\n acc.upsert.push(removed);\n }\n break;\n case ChangeType.Updated:\n acc.upsert.push(change!.originalValue!);\n break;\n }\n }\n return acc;\n },\n // entitiesToUndo\n {\n remove: [] as (number | string)[],\n upsert: [] as T[],\n changeState: collection.changeState,\n }\n );\n\n collection = this.adapter.removeMany(remove as string[], collection);\n collection = this.adapter.upsertMany(upsert, collection);\n return didMutate ? { ...collection, changeState } : collection;\n }\n\n /**\n * Revert the unsaved changes for the given entity.\n * Harmless when there are no entity changes to undo.\n * @param entityOrId The entity to revert or its id.\n * @param collection The entity collection\n */\n undoOne(\n entityOrId: number | string | T,\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return entityOrId == null\n ? collection\n : this.undoMany([entityOrId], collection);\n }\n // #endregion undo methods\n}\n","import { Injectable } from '@angular/core';\nimport { EntityAdapter, IdSelector, Update } from '@ngrx/entity';\nimport {\n ChangeStateMap,\n ChangeType,\n EntityCollection,\n} from './entity-collection';\nimport { EntityChangeTrackerBase } from './entity-change-tracker-base';\nimport { toUpdateFactory } from '../utils/utilities';\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityActionDataServiceError } from '../dataservices/data-service-error';\nimport { EntityActionGuard } from '../actions/entity-action-guard';\nimport { EntityChangeTracker } from './entity-change-tracker';\nimport { EntityDefinition } from '../entity-metadata/entity-definition';\nimport { EntityDefinitionService } from '../entity-metadata/entity-definition.service';\nimport { EntityOp } from '../actions/entity-op';\nimport { MergeStrategy } from '../actions/merge-strategy';\nimport { UpdateResponseData } from '../actions/update-response-data';\n\n/**\n * Map of {EntityOp} to reducer method for the operation.\n * If an operation is missing, caller should return the collection for that reducer.\n */\nexport interface EntityCollectionReducerMethodMap<T> {\n [method: string]: (\n collection: EntityCollection<T>,\n action: EntityAction\n ) => EntityCollection<T>;\n}\n\n/**\n * Base implementation of reducer methods for an entity collection.\n */\nexport class EntityCollectionReducerMethods<T> {\n protected adapter: EntityAdapter<T>;\n protected guard: EntityActionGuard<T>;\n /** True if this collection tracks unsaved changes */\n protected isChangeTracking: boolean;\n\n /** Extract the primary key (id); default to `id` */\n selectId: IdSelector<T>;\n\n /**\n * Track changes to entities since the last query or save\n * Can revert some or all of those changes\n */\n entityChangeTracker: EntityChangeTracker<T>;\n\n /**\n * Convert an entity (or partial entity) into the `Update<T>` object\n * `id`: the primary key and\n * `changes`: the entity (or partial entity of changes).\n */\n protected toUpdate: (entity: Partial<T>) => Update<T>;\n\n /**\n * Dictionary of the {EntityCollectionReducerMethods} for this entity type,\n * keyed by the {EntityOp}\n */\n readonly methods: EntityCollectionReducerMethodMap<T> = {\n [EntityOp.CANCEL_PERSIST]: this.cancelPersist.bind(this),\n\n [EntityOp.QUERY_ALL]: this.queryAll.bind(this),\n [EntityOp.QUERY_ALL_ERROR]: this.queryAllError.bind(this),\n [EntityOp.QUERY_ALL_SUCCESS]: this.queryAllSuccess.bind(this),\n\n [EntityOp.QUERY_BY_KEY]: this.queryByKey.bind(this),\n [EntityOp.QUERY_BY_KEY_ERROR]: this.queryByKeyError.bind(this),\n [EntityOp.QUERY_BY_KEY_SUCCESS]: this.queryByKeySuccess.bind(this),\n\n [EntityOp.QUERY_LOAD]: this.queryLoad.bind(this),\n [EntityOp.QUERY_LOAD_ERROR]: this.queryLoadError.bind(this),\n [EntityOp.QUERY_LOAD_SUCCESS]: this.queryLoadSuccess.bind(this),\n\n [EntityOp.QUERY_MANY]: this.queryMany.bind(this),\n [EntityOp.QUERY_MANY_ERROR]: this.queryManyError.bind(this),\n [EntityOp.QUERY_MANY_SUCCESS]: this.queryManySuccess.bind(this),\n\n [EntityOp.SAVE_ADD_MANY]: this.saveAddMany.bind(this),\n [EntityOp.SAVE_ADD_MANY_ERROR]: this.saveAddManyError.bind(this),\n [EntityOp.SAVE_ADD_MANY_SUCCESS]: this.saveAddManySuccess.bind(this),\n\n [EntityOp.SAVE_ADD_ONE]: this.saveAddOne.bind(this),\n [EntityOp.SAVE_ADD_ONE_ERROR]: this.saveAddOneError.bind(this),\n [EntityOp.SAVE_ADD_ONE_SUCCESS]: this.saveAddOneSuccess.bind(this),\n\n [EntityOp.SAVE_DELETE_MANY]: this.saveDeleteMany.bind(this),\n [EntityOp.SAVE_DELETE_MANY_ERROR]: this.saveDeleteManyError.bind(this),\n [EntityOp.SAVE_DELETE_MANY_SUCCESS]: this.saveDeleteManySuccess.bind(this),\n\n [EntityOp.SAVE_DELETE_ONE]: this.saveDeleteOne.bind(this),\n [EntityOp.SAVE_DELETE_ONE_ERROR]: this.saveDeleteOneError.bind(this),\n [EntityOp.SAVE_DELETE_ONE_SUCCESS]: this.saveDeleteOneSuccess.bind(this),\n\n [EntityOp.SAVE_UPDATE_MANY]: this.saveUpdateMany.bind(this),\n [EntityOp.SAVE_UPDATE_MANY_ERROR]: this.saveUpdateManyError.bind(this),\n [EntityOp.SAVE_UPDATE_MANY_SUCCESS]: this.saveUpdateManySuccess.bind(this),\n\n [EntityOp.SAVE_UPDATE_ONE]: this.saveUpdateOne.bind(this),\n [EntityOp.SAVE_UPDATE_ONE_ERROR]: this.saveUpdateOneError.bind(this),\n [EntityOp.SAVE_UPDATE_ONE_SUCCESS]: this.saveUpdateOneSuccess.bind(this),\n\n [EntityOp.SAVE_UPSERT_MANY]: this.saveUpsertMany.bind(this),\n [EntityOp.SAVE_UPSERT_MANY_ERROR]: this.saveUpsertManyError.bind(this),\n [EntityOp.SAVE_UPSERT_MANY_SUCCESS]: this.saveUpsertManySuccess.bind(this),\n\n [EntityOp.SAVE_UPSERT_ONE]: this.saveUpsertOne.bind(this),\n [EntityOp.SAVE_UPSERT_ONE_ERROR]: this.saveUpsertOneError.bind(this),\n [EntityOp.SAVE_UPSERT_ONE_SUCCESS]: this.saveUpsertOneSuccess.bind(this),\n\n // Do nothing on save errors except turn the loading flag off.\n // See the ChangeTrackerMetaReducers\n // Or the app could listen for those errors and do something\n\n /// cache only operations ///\n\n [EntityOp.ADD_ALL]: this.addAll.bind(this),\n [EntityOp.ADD_MANY]: this.addMany.bind(this),\n [EntityOp.ADD_ONE]: this.addOne.bind(this),\n\n [EntityOp.REMOVE_ALL]: this.removeAll.bind(this),\n [EntityOp.REMOVE_MANY]: this.removeMany.bind(this),\n [EntityOp.REMOVE_ONE]: this.removeOne.bind(this),\n\n [EntityOp.UPDATE_MANY]: this.updateMany.bind(this),\n [EntityOp.UPDATE_ONE]: this.updateOne.bind(this),\n\n [EntityOp.UPSERT_MANY]: this.upsertMany.bind(this),\n [EntityOp.UPSERT_ONE]: this.upsertOne.bind(this),\n\n [EntityOp.COMMIT_ALL]: this.commitAll.bind(this),\n [EntityOp.COMMIT_MANY]: this.commitMany.bind(this),\n [EntityOp.COMMIT_ONE]: this.commitOne.bind(this),\n [EntityOp.UNDO_ALL]: this.undoAll.bind(this),\n [EntityOp.UNDO_MANY]: this.undoMany.bind(this),\n [EntityOp.UNDO_ONE]: this.undoOne.bind(this),\n\n [EntityOp.SET_CHANGE_STATE]: this.setChangeState.bind(this),\n [EntityOp.SET_COLLECTION]: this.setCollection.bind(this),\n [EntityOp.SET_FILTER]: this.setFilter.bind(this),\n [EntityOp.SET_LOADED]: this.setLoaded.bind(this),\n [EntityOp.SET_LOADING]: this.setLoading.bind(this),\n };\n\n constructor(\n public entityName: string,\n public definition: EntityDefinition<T>,\n /*\n * Track changes to entities since the last query or save\n * Can revert some or all of those changes\n */\n entityChangeTracker?: EntityChangeTracker<T>\n ) {\n this.adapter = definition.entityAdapter;\n this.isChangeTracking = definition.noChangeTracking !== true;\n this.selectId = definition.selectId;\n\n this.guard = new EntityActionGuard(entityName, this.selectId);\n this.toUpdate = toUpdateFactory(this.selectId);\n\n this.entityChangeTracker =\n entityChangeTracker ||\n new EntityChangeTrackerBase<T>(this.adapter, this.selectId);\n }\n\n /** Cancel a persistence operation */\n protected cancelPersist(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n // #region query operations\n\n protected queryAll(collection: EntityCollection<T>): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryAllError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Merges query results per the MergeStrategy\n * Sets loading flag to false and loaded flag to true.\n */\n protected queryAllSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n return {\n ...this.entityChangeTracker.mergeQueryResults(\n data,\n collection,\n mergeStrategy\n ),\n loaded: true,\n loading: false,\n };\n }\n\n protected queryByKey(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryByKeyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n protected queryByKeySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection =\n data == null\n ? collection\n : this.entityChangeTracker.mergeQueryResults(\n [data],\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n\n protected queryLoad(collection: EntityCollection<T>): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryLoadError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Replaces all entities in the collection\n * Sets loaded flag to true, loading flag to false,\n * and clears changeState for the entire collection.\n */\n protected queryLoadSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n return {\n ...this.adapter.setAll(data, collection),\n loading: false,\n loaded: true,\n changeState: {},\n };\n }\n\n protected queryMany(\n collection: EntityCollection<T>,\n action: EntityAction\n ): EntityCollection<T> {\n return this.setLoadingTrue(collection);\n }\n\n protected queryManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n protected queryManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const data = this.extractData(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n return {\n ...this.entityChangeTracker.mergeQueryResults(\n data,\n collection,\n mergeStrategy\n ),\n loaded: true,\n loading: false,\n };\n }\n // #endregion query operations\n\n // #region save operations\n\n // #region saveAddMany\n /**\n * Save multiple new entities.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entities should be added.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of entities.\n * If saving optimistically, the entities must have their keys.\n */\n protected saveAddMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entities = this.guard.mustBeEntities(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddMany(\n entities,\n collection,\n mergeStrategy\n );\n collection = this.adapter.addMany(entities, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new entities failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new entities are not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveAddManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddMany\n\n // #region saveAddOne\n /**\n * Successfully saved new entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field),\n * and may even return additional new entities.\n * Therefore, upsert the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n * Note: saveAddManySuccess differs from saveAddOneSuccess when optimistic.\n * saveAddOneSuccess updates (not upserts) with the lone entity from the server.\n * There is no effect if the entity is not already in cache.\n * saveAddManySuccess will add an entity if it is not found in cache.\n */\n protected saveAddManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n if (this.isOptimistic(action)) {\n collection = this.entityChangeTracker.mergeSaveUpserts(\n entities,\n collection,\n mergeStrategy\n );\n } else {\n collection = this.entityChangeTracker.mergeSaveAdds(\n entities,\n collection,\n mergeStrategy\n );\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddMany\n\n // #region saveAddOne\n /**\n * Save a new entity.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add entity immediately.\n * @param collection The collection to which the entity should be added.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an entity.\n * If saving optimistically, the entity must have a key.\n */\n protected saveAddOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entity = this.guard.mustBeEntity(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddOne(\n entity,\n collection,\n mergeStrategy\n );\n collection = this.adapter.addOne(entity, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save a new entity failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity is not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entity is in the collection and\n * you may need to compensate for the error.\n */\n protected saveAddOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved a new entity to the server.\n * If saved pessimistically, add the entity from the server to the collection.\n * If saved optimistically, the added entity is already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned value (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveAddOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n if (this.isOptimistic(action)) {\n const update: UpdateResponseData<T> = this.toUpdate(entity);\n // Always update the cache with added entity returned from server\n collection = this.entityChangeTracker.mergeSaveUpdates(\n [update],\n collection,\n mergeStrategy,\n false /*never skip*/\n );\n } else {\n collection = this.entityChangeTracker.mergeSaveAdds(\n [entity],\n collection,\n mergeStrategy\n );\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveAddOne\n\n // #region saveAddMany\n // TODO MANY\n // #endregion saveAddMany\n\n // #region saveDeleteOne\n /**\n * Delete an entity from the server by key and remove it from the collection (if present).\n * If the entity is an unsaved new entity, remove it from the collection immediately\n * and skip the server delete request.\n * An optimistic save removes an existing entity from the collection immediately;\n * a pessimistic save removes it after the server confirms successful delete.\n * @param collection Will remove the entity with this key from the collection.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be a primary key or an entity with a key;\n * this reducer extracts the key from the entity.\n */\n protected saveDeleteOne(\n collection: EntityCollection<T>,\n action: EntityAction<number | string | T>\n ): EntityCollection<T> {\n const toDelete = this.extractData(action);\n const deleteId =\n typeof toDelete === 'object'\n ? this.selectId(toDelete)\n : (toDelete as string | number);\n const change = collection.changeState[deleteId];\n // If entity is already tracked ...\n if (change) {\n if (change.changeType === ChangeType.Added) {\n // Remove the added entity immediately and forget about its changes (via commit).\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n // Should not waste effort trying to delete on the server because it can't be there.\n action.payload.skip = true;\n } else {\n // Re-track it as a delete, even if tracking is turned off for this call.\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection\n );\n }\n }\n\n // If optimistic delete, track current state and remove immediately.\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection,\n mergeStrategy\n );\n collection = this.adapter.removeOne(deleteId as string, collection);\n }\n\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to delete the entity on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity could still be in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the entity is not in the collection and\n * you may need to compensate for the error.\n */\n protected saveDeleteOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully deleted entity on the server. The key of the deleted entity is in the action payload data.\n * If saved pessimistically, if the entity is still in the collection it will be removed.\n * If saved optimistically, the entity has already been removed from the collection.\n */\n protected saveDeleteOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n const deleteId = this.extractData(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveDeletes(\n [deleteId],\n collection,\n mergeStrategy\n );\n } else {\n // Pessimistic: ignore mergeStrategy. Remove entity from the collection and from change tracking.\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveDeleteOne\n\n // #region saveDeleteMany\n /**\n * Delete multiple entities from the server by key and remove them from the collection (if present).\n * Removes unsaved new entities from the collection immediately\n * but the id is still sent to the server for deletion even though the server will not find that entity.\n * Therefore, the server must be willing to ignore a delete request for an entity it cannot find.\n * An optimistic save removes existing entities from the collection immediately;\n * a pessimistic save removes them after the server confirms successful delete.\n * @param collection Removes entities from this collection.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of primary keys or entities with a key;\n * this reducer extracts the key from the entity.\n */\n protected saveDeleteMany(\n collection: EntityCollection<T>,\n action: EntityAction<(number | string | T)[]>\n ): EntityCollection<T> {\n const deleteIds = this.extractData(action).map((d) =>\n typeof d === 'object' ? this.selectId(d) : (d as string | number)\n );\n deleteIds.forEach((deleteId) => {\n const change = collection.changeState[deleteId];\n // If entity is already tracked ...\n if (change) {\n if (change.changeType === ChangeType.Added) {\n // Remove the added entity immediately and forget about its changes (via commit).\n collection = this.adapter.removeOne(deleteId as string, collection);\n collection = this.entityChangeTracker.commitOne(deleteId, collection);\n // Should not waste effort trying to delete on the server because it can't be there.\n action.payload.skip = true;\n } else {\n // Re-track it as a delete, even if tracking is turned off for this call.\n collection = this.entityChangeTracker.trackDeleteOne(\n deleteId,\n collection\n );\n }\n }\n });\n // If optimistic delete, track current state and remove immediately.\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteMany(\n deleteIds,\n collection,\n mergeStrategy\n );\n collection = this.adapter.removeMany(deleteIds as string[], collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to delete the entities on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entities could still be in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the entities are not in the collection and\n * you may need to compensate for the error.\n */\n protected saveDeleteManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully deleted entities on the server. The keys of the deleted entities are in the action payload data.\n * If saved pessimistically, entities that are still in the collection will be removed.\n * If saved optimistically, the entities have already been removed from the collection.\n */\n protected saveDeleteManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<(number | string)[]>\n ): EntityCollection<T> {\n const deleteIds = this.extractData(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveDeletes(\n deleteIds,\n collection,\n mergeStrategy\n );\n } else {\n // Pessimistic: ignore mergeStrategy. Remove entity from the collection and from change tracking.\n collection = this.adapter.removeMany(deleteIds as string[], collection);\n collection = this.entityChangeTracker.commitMany(deleteIds, collection);\n }\n return this.setLoadingFalse(collection);\n }\n // #endregion saveDeleteMany\n\n // #region saveUpdateOne\n /**\n * Save an update to an existing entity.\n * If saving pessimistically, update the entity in the collection after the server confirms success.\n * If saving optimistically, update the entity immediately, before the save request.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an {Update<T>}\n */\n protected saveUpdateOne(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>>\n ): EntityCollection<T> {\n const update = this.guard.mustBeUpdate(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateOne(\n update,\n collection,\n mergeStrategy\n );\n collection = this.adapter.updateOne(update, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to update the entity on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entity in the collection is in the pre-save state\n * you may not have to compensate for the error.\n * If saved optimistically, the entity in the collection was updated\n * and you may need to compensate for the error.\n */\n protected saveUpdateOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved the updated entity to the server.\n * If saved pessimistically, update the entity in the collection with data from the server.\n * If saved optimistically, the entity was already updated in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned value (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic update to avoid this risk.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic, and\n * the update data which, must be an UpdateResponse<T> that corresponds to the Update sent to the server.\n * You must include an UpdateResponse even if the save was optimistic,\n * to ensure that the change tracking is properly reset.\n */\n protected saveUpdateOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<UpdateResponseData<T>>\n ): EntityCollection<T> {\n const update = this.guard.mustBeUpdateResponse(action);\n const isOptimistic = this.isOptimistic(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveUpdates(\n [update],\n collection,\n mergeStrategy,\n isOptimistic /*skip unchanged if optimistic */\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpdateOne\n\n // #region saveUpdateMany\n /**\n * Save updated entities.\n * If saving pessimistically, update the entities in the collection after the server confirms success.\n * If saving optimistically, update the entities immediately, before the save request.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an array of {Update<T>}.\n */\n protected saveUpdateMany(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>[]>\n ): EntityCollection<T> {\n const updates = this.guard.mustBeUpdates(action);\n if (this.isOptimistic(action)) {\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateMany(\n updates,\n collection,\n mergeStrategy\n );\n collection = this.adapter.updateMany(updates, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to update entities on the server failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, the entities in the collection are in the pre-save state\n * you may not have to compensate for the error.\n * If saved optimistically, the entities in the collection were updated\n * and you may need to compensate for the error.\n */\n protected saveUpdateManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved the updated entities to the server.\n * If saved pessimistically, the entities in the collection will be updated with data from the server.\n * If saved optimistically, the entities in the collection were already updated.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entity in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic update to avoid this risk.\n * @param collection The collection to update\n * @param action The action payload holds options, including if the save is optimistic,\n * and the data which, must be an array of UpdateResponse<T>.\n * You must include an UpdateResponse for every Update sent to the server,\n * even if the save was optimistic, to ensure that the change tracking is properly reset.\n */\n protected saveUpdateManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<UpdateResponseData<T>[]>\n ): EntityCollection<T> {\n const updates = this.guard.mustBeUpdateResponses(action);\n const isOptimistic = this.isOptimistic(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.mergeSaveUpdates(\n updates,\n collection,\n mergeStrategy,\n false /* never skip */\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpdateMany\n\n // #region saveUpsertOne\n /**\n * Save a new or existing entity.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entity should be upserted.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be a whole entity.\n * If saving optimistically, the entity must have its key.\n */\n protected saveUpsertOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entity = this.guard.mustBeEntity(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertOne(\n entity,\n collection,\n mergeStrategy\n );\n collection = this.adapter.upsertOne(entity, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new or existing entity failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new or updated entity is not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveUpsertOneError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved new or existing entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveUpsertOneSuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n // Always update the cache with upserted entities returned from server\n collection = this.entityChangeTracker.mergeSaveUpserts(\n [entity],\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpsertOne\n\n // #region saveUpsertMany\n /**\n * Save multiple new or existing entities.\n * If saving pessimistically, delay adding to collection until server acknowledges success.\n * If saving optimistically; add immediately.\n * @param collection The collection to which the entities should be upserted.\n * @param action The action payload holds options, including whether the save is optimistic,\n * and the data, which must be an array of whole entities.\n * If saving optimistically, the entities must have their keys.\n */\n protected saveUpsertMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n if (this.isOptimistic(action)) {\n const entities = this.guard.mustBeEntities(action); // ensure the entity has a PK\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertMany(\n entities,\n collection,\n mergeStrategy\n );\n collection = this.adapter.upsertMany(entities, collection);\n }\n return this.setLoadingTrue(collection);\n }\n\n /**\n * Attempt to save new or existing entities failed or timed-out.\n * Action holds the error.\n * If saved pessimistically, new entities are not in the collection and\n * you may not have to compensate for the error.\n * If saved optimistically, the unsaved entities are in the collection and\n * you may need to compensate for the error.\n */\n protected saveUpsertManyError(\n collection: EntityCollection<T>,\n action: EntityAction<EntityActionDataServiceError>\n ): EntityCollection<T> {\n return this.setLoadingFalse(collection);\n }\n\n /**\n * Successfully saved new or existing entities to the server.\n * If saved pessimistically, add the entities from the server to the collection.\n * If saved optimistically, the added entities are already in the collection.\n * However, the server might have set or modified other fields (e.g, concurrency field)\n * Therefore, update the entities in the collection with the returned values (if any)\n * Caution: in a race, this update could overwrite unsaved user changes.\n * Use pessimistic add to avoid this risk.\n */\n protected saveUpsertManySuccess(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n // For pessimistic save, ensure the server generated the primary key if the client didn't send one.\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n // Always update the cache with upserted entities returned from server\n collection = this.entityChangeTracker.mergeSaveUpserts(\n entities,\n collection,\n mergeStrategy\n );\n return this.setLoadingFalse(collection);\n }\n // #endregion saveUpsertMany\n\n // #endregion save operations\n\n // #region cache-only operations\n\n /**\n * Replaces all entities in the collection\n * Sets loaded flag to true.\n * Merges query results, preserving unsaved changes\n */\n protected addAll(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const entities = this.guard.mustBeEntities(action);\n return {\n ...this.adapter.setAll(entities, collection),\n loading: false,\n loaded: true,\n changeState: {},\n };\n }\n\n protected addMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddMany(\n entities,\n collection,\n mergeStrategy\n );\n return this.adapter.addMany(entities, collection);\n }\n\n protected addOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackAddOne(\n entity,\n collection,\n mergeStrategy\n );\n return this.adapter.addOne(entity, collection);\n }\n\n protected removeMany(\n collection: EntityCollection<T>,\n action: EntityAction<number[] | string[]>\n ): EntityCollection<T> {\n // payload must be entity keys\n const keys = this.guard.mustBeKeys(action) as string[];\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteMany(\n keys,\n collection,\n mergeStrategy\n );\n return this.adapter.removeMany(keys, collection);\n }\n\n protected removeOne(\n collection: EntityCollection<T>,\n action: EntityAction<number | string>\n ): EntityCollection<T> {\n // payload must be entity key\n const key = this.guard.mustBeKey(action) as string;\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackDeleteOne(\n key,\n collection,\n mergeStrategy\n );\n return this.adapter.removeOne(key, collection);\n }\n\n protected removeAll(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n return {\n ...this.adapter.removeAll(collection),\n loaded: false, // Only REMOVE_ALL sets loaded to false\n loading: false,\n changeState: {}, // Assume clearing the collection and not trying to delete all entities\n };\n }\n\n protected updateMany(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>[]>\n ): EntityCollection<T> {\n // payload must be an array of `Updates<T>`, not entities\n const updates = this.guard.mustBeUpdates(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateMany(\n updates,\n collection,\n mergeStrategy\n );\n return this.adapter.updateMany(updates, collection);\n }\n\n protected updateOne(\n collection: EntityCollection<T>,\n action: EntityAction<Update<T>>\n ): EntityCollection<T> {\n // payload must be an `Update<T>`, not an entity\n const update = this.guard.mustBeUpdate(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpdateOne(\n update,\n collection,\n mergeStrategy\n );\n return this.adapter.updateOne(update, collection);\n }\n\n protected upsertMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ): EntityCollection<T> {\n // <v6: payload must be an array of `Updates<T>`, not entities\n // v6+: payload must be an array of T\n const entities = this.guard.mustBeEntities(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertMany(\n entities,\n collection,\n mergeStrategy\n );\n return this.adapter.upsertMany(entities, collection);\n }\n\n protected upsertOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ): EntityCollection<T> {\n // <v6: payload must be an `Update<T>`, not an entity\n // v6+: payload must be a T\n const entity = this.guard.mustBeEntity(action);\n const mergeStrategy = this.extractMergeStrategy(action);\n collection = this.entityChangeTracker.trackUpsertOne(\n entity,\n collection,\n mergeStrategy\n );\n return this.adapter.upsertOne(entity, collection);\n }\n\n protected commitAll(collection: EntityCollection<T>) {\n return this.entityChangeTracker.commitAll(collection);\n }\n\n protected commitMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n return this.entityChangeTracker.commitMany(\n this.extractData(action),\n collection\n );\n }\n\n protected commitOne(\n collection: EntityCollection<T>,\n action: EntityAction<T>\n ) {\n return this.entityChangeTracker.commitOne(\n this.extractData(action),\n collection\n );\n }\n\n protected undoAll(collection: EntityCollection<T>) {\n return this.entityChangeTracker.undoAll(collection);\n }\n\n protected undoMany(\n collection: EntityCollection<T>,\n action: EntityAction<T[]>\n ) {\n return this.entityChangeTracker.undoMany(\n this.extractData(action),\n collection\n );\n }\n\n protected undoOne(collection: EntityCollection<T>, action: EntityAction<T>) {\n return this.entityChangeTracker.undoOne(\n this.extractData(action),\n collection\n );\n }\n\n /** Dangerous: Completely replace the collection's ChangeState. Use rarely and wisely. */\n protected setChangeState(\n collection: EntityCollection<T>,\n action: EntityAction<ChangeStateMap<T>>\n ) {\n const changeState = this.extractData(action);\n return collection.changeState === changeState\n ? collection\n : { ...collection, changeState };\n }\n\n /**\n * Dangerous: Completely replace the collection.\n * Primarily for testing and rehydration from local storage.\n * Use rarely and wisely.\n */\n protected setCollection(\n collection: EntityCollection<T>,\n action: EntityAction<EntityCollection<T>>\n ) {\n const newCollection = this.extractData(action);\n return collection === newCollection ? collection : newCollection;\n }\n\n protected setFilter(\n collection: EntityCollection<T>,\n action: EntityAction<any>\n ): EntityCollection<T> {\n const filter = this.extractData(action);\n return collection.filter === filter\n ? collection\n : { ...collection, filter };\n }\n\n protected setLoaded(\n collection: EntityCollection<T>,\n action: EntityAction<boolean>\n ): EntityCollection<T> {\n const loaded = this.extractData(action) === true || false;\n return collection.loaded === loaded\n ? collection\n : { ...collection, loaded };\n }\n\n protected setLoading(\n collection: EntityCollection<T>,\n action: EntityAction<boolean>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, this.extractData(action));\n }\n\n protected setLoadingFalse(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, false);\n }\n\n protected setLoadingTrue(\n collection: EntityCollection<T>\n ): EntityCollection<T> {\n return this.setLoadingFlag(collection, true);\n }\n\n /** Set the collection's loading flag */\n protected setLoadingFlag(collection: EntityCollection<T>, loading: boolean) {\n loading = loading === true ? true : false;\n return collection.loading === loading\n ? collection\n : { ...collection, loading };\n }\n // #endregion Cache-only operations\n\n // #region helpers\n /** Safely extract data from the EntityAction payload */\n protected extractData<D = any>(action: EntityAction<D>): D {\n return (action.payload && action.payload.data) as D;\n }\n\n /** Safely extract MergeStrategy from EntityAction. Set to IgnoreChanges if collection itself is not tracked. */\n protected extractMergeStrategy(action: EntityAction) {\n // If not tracking this collection, always ignore changes\n return this.isChangeTracking\n ? action.payload && action.payload.mergeStrategy\n : MergeStrategy.IgnoreChanges;\n }\n\n protected isOptimistic(action: EntityAction) {\n return action.payload && action.payload.isOptimistic === true;\n }\n\n // #endregion helpers\n}\n\n/**\n * Creates {EntityCollectionReducerMethods} for a given entity type.\n */\n@Injectable()\nexport class EntityCollectionReducerMethodsFactory {\n constructor(private entityDefinitionService: EntityDefinitionService) {}\n\n /** Create the {EntityCollectionReducerMethods} for the named entity type */\n create<T>(entityName: string): EntityCollectionReducerMethodMap<T> {\n const definition =\n this.entityDefinitionService.getDefinition<T>(entityName);\n const methodsClass = new EntityCollectionReducerMethods(\n entityName,\n definition\n );\n\n return methodsClass.methods;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCollection } from './entity-collection';\nimport { EntityCollectionReducerMethodsFactory } from './entity-collection-reducer-methods';\n\nexport type EntityCollectionReducer<T = any> = (\n collection: EntityCollection<T>,\n action: EntityAction\n) => EntityCollection<T>;\n\n/** Create a default reducer for a specific entity collection */\n@Injectable()\nexport class EntityCollectionReducerFactory {\n constructor(private methodsFactory: EntityCollectionReducerMethodsFactory) {}\n\n /** Create a default reducer for a collection of entities of T */\n create<T = any>(entityName: string): EntityCollectionReducer<T> {\n const methods = this.methodsFactory.create<T>(entityName);\n\n /** Perform Actions against a particular entity collection in the EntityCache */\n return function entityCollectionReducer(\n collection: EntityCollection<T>,\n action: EntityAction\n ): EntityCollection<T> {\n const reducerMethod = methods[action.payload.entityOp];\n return reducerMethod ? reducerMethod(collection, action) : collection;\n };\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { compose, MetaReducer } from '@ngrx/store';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCollection } from './entity-collection';\nimport { ENTITY_COLLECTION_META_REDUCERS } from './constants';\nimport {\n EntityCollectionReducer,\n EntityCollectionReducerFactory,\n} from './entity-collection-reducer';\n\n/** A hash of EntityCollectionReducers */\nexport interface EntityCollectionReducers {\n [entity: string]: EntityCollectionReducer<any>;\n}\n\n/**\n * Registry of entity types and their previously-constructed reducers.\n * Can create a new CollectionReducer, which it registers for subsequent use.\n */\n@Injectable()\nexport class EntityCollectionReducerRegistry {\n protected entityCollectionReducers: EntityCollectionReducers = {};\n private entityCollectionMetaReducer: MetaReducer<\n EntityCollection,\n EntityAction\n >;\n\n constructor(\n private entityCollectionReducerFactory: EntityCollectionReducerFactory,\n @Optional()\n @Inject(ENTITY_COLLECTION_META_REDUCERS)\n entityCollectionMetaReducers?: MetaReducer<EntityCollection, EntityAction>[]\n ) {\n // eslint-disable-next-line prefer-spread\n this.entityCollectionMetaReducer = compose.apply(\n null,\n entityCollectionMetaReducers || []\n ) as any;\n }\n\n /**\n * Get the registered EntityCollectionReducer<T> for this entity type or create one and register it.\n * @param entityName Name of the entity type for this reducer\n */\n getOrCreateReducer<T>(entityName: string): EntityCollectionReducer<T> {\n let reducer: EntityCollectionReducer<T> =\n this.entityCollectionReducers[entityName];\n\n if (!reducer) {\n reducer = this.entityCollectionReducerFactory.create<T>(entityName);\n reducer = this.registerReducer<T>(entityName, reducer);\n this.entityCollectionReducers[entityName] = reducer;\n }\n return reducer;\n }\n\n /**\n * Register an EntityCollectionReducer for an entity type\n * @param entityName - the name of the entity type\n * @param reducer - reducer for that entity type\n *\n * Examples:\n * registerReducer('Hero', myHeroReducer);\n * registerReducer('Villain', myVillainReducer);\n */\n registerReducer<T>(\n entityName: string,\n reducer: EntityCollectionReducer<T>\n ): EntityCollectionReducer<T> {\n reducer = this.entityCollectionMetaReducer(reducer as any);\n return (this.entityCollectionReducers[entityName.trim()] = reducer);\n }\n\n /**\n * Register a batch of EntityCollectionReducers.\n * @param reducers - reducers to merge into existing reducers\n *\n * Examples:\n * registerReducers({\n * Hero: myHeroReducer,\n * Villain: myVillainReducer\n * });\n */\n registerReducers(reducers: EntityCollectionReducers) {\n const keys = reducers ? Object.keys(reducers) : [];\n keys.forEach((key) => this.registerReducer(key, reducers[key]));\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Action, ActionReducer } from '@ngrx/store';\n\nimport { EntityAction } from '../actions/entity-action';\nimport { EntityCache } from './entity-cache';\n\nimport {\n EntityCacheAction,\n ClearCollections,\n LoadCollections,\n MergeQuerySet,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from '../actions/entity-cache-action';\n\nimport {\n ChangeSetOperation,\n ChangeSetItem,\n} from '../actions/entity-cache-change-set';\n\nimport { EntityCollection } from './entity-collection';\nimport { EntityCollectionCreator } from './entity-collection-creator';\nimport { EntityCollectionReducerRegistry } from './entity-collection-reducer-registry';\nimport { EntityOp } from '../actions/entity-op';\nimport { Logger } from '../utils/interfaces';\nimport { MergeStrategy } from '../actions/merge-strategy';\n\n/**\n * Creates the EntityCacheReducer via its create() method\n */\n@Injectable()\nexport class EntityCacheReducerFactory {\n constructor(\n private entityCollectionCreator: EntityCollectionCreator,\n private entityCollectionReducerRegistry: EntityCollectionReducerRegistry,\n private logger: Logger\n ) {}\n\n /**\n * Create the @ngrx/data entity cache reducer which either responds to entity cache level actions\n * or (more commonly) delegates to an EntityCollectionReducer based on the action.payload.entityName.\n */\n create(): ActionReducer<EntityCache, Action> {\n // This technique ensures a named function appears in the debugger\n return entityCacheReducer.bind(this);\n\n function entityCacheReducer(\n this: EntityCacheReducerFactory,\n entityCache: EntityCache = {},\n action: { type: string; payload?: any }\n ): EntityCache {\n // EntityCache actions\n switch (action.type) {\n case EntityCacheAction.CLEAR_COLLECTIONS: {\n return this.clearCollectionsReducer(\n entityCache,\n action as ClearCollections\n );\n }\n\n case EntityCacheAction.LOAD_COLLECTIONS: {\n return this.loadCollectionsReducer(\n entityCache,\n action as LoadCollections\n );\n }\n\n case EntityCacheAction.MERGE_QUERY_SET: {\n return this.mergeQuerySetReducer(\n entityCache,\n action as MergeQuerySet\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES: {\n return this.saveEntitiesReducer(entityCache, action as SaveEntities);\n }\n\n case EntityCacheAction.SAVE_ENTITIES_CANCEL: {\n return this.saveEntitiesCancelReducer(\n entityCache,\n action as SaveEntitiesCancel\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES_ERROR: {\n return this.saveEntitiesErrorReducer(\n entityCache,\n action as SaveEntitiesError\n );\n }\n\n case EntityCacheAction.SAVE_ENTITIES_SUCCESS: {\n return this.saveEntitiesSuccessReducer(\n entityCache,\n action as SaveEntitiesSuccess\n );\n }\n\n case EntityCacheAction.SET_ENTITY_CACHE: {\n // Completely replace the EntityCache. Be careful!\n return action.payload.cache;\n }\n }\n\n // Apply entity collection reducer if this is a valid EntityAction for a collection\n const payload = action.payload;\n if (payload && payload.entityName && payload.entityOp && !payload.error) {\n return this.applyCollectionReducer(entityCache, action as EntityAction);\n }\n\n // Not a valid EntityAction\n return entityCache;\n }\n }\n\n /**\n * Reducer to clear multiple collections at the same time.\n * @param entityCache the entity cache\n * @param action a ClearCollections action whose payload is an array of collection names.\n * If empty array, does nothing. If no array, clears all the collections.\n */\n protected clearCollectionsReducer(\n entityCache: EntityCache,\n action: ClearCollections\n ) {\n // eslint-disable-next-line prefer-const\n let { collections, tag } = action.payload;\n const entityOp = EntityOp.REMOVE_ALL;\n\n if (!collections) {\n // Collections is not defined. Clear all collections.\n collections = Object.keys(entityCache);\n }\n\n entityCache = collections.reduce((newCache, entityName) => {\n const payload = { entityName, entityOp };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n /**\n * Reducer to load collection in the form of a hash of entity data for multiple collections.\n * @param entityCache the entity cache\n * @param action a LoadCollections action whose payload is the QuerySet of entity collections to load\n */\n protected loadCollectionsReducer(\n entityCache: EntityCache,\n action: LoadCollections\n ) {\n const { collections, tag } = action.payload;\n const entityOp = EntityOp.ADD_ALL;\n const entityNames = Object.keys(collections);\n entityCache = entityNames.reduce((newCache, entityName) => {\n const payload = {\n entityName,\n entityOp,\n data: collections[entityName],\n };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n /**\n * Reducer to merge query sets in the form of a hash of entity data for multiple collections.\n * @param entityCache the entity cache\n * @param action a MergeQuerySet action with the query set and a MergeStrategy\n */\n protected mergeQuerySetReducer(\n entityCache: EntityCache,\n action: MergeQuerySet\n ) {\n // eslint-disable-next-line prefer-const\n let { mergeStrategy, querySet, tag } = action.payload;\n mergeStrategy =\n mergeStrategy === null ? MergeStrategy.PreserveChanges : mergeStrategy;\n const entityOp = EntityOp.QUERY_MANY_SUCCESS;\n\n const entityNames = Object.keys(querySet);\n entityCache = entityNames.reduce((newCache, entityName) => {\n const payload = {\n entityName,\n entityOp,\n data: querySet[entityName],\n mergeStrategy,\n };\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n newCache = this.applyCollectionReducer(newCache, act);\n return newCache;\n }, entityCache);\n return entityCache;\n }\n\n // #region saveEntities reducers\n protected saveEntitiesReducer(\n entityCache: EntityCache,\n action: SaveEntities\n ) {\n const { changeSet, correlationId, isOptimistic, mergeStrategy, tag } =\n action.payload;\n\n try {\n changeSet.changes.forEach((item) => {\n const entityName = item.entityName;\n const payload = {\n entityName,\n entityOp: getEntityOp(item),\n data: item.entities,\n correlationId,\n isOptimistic,\n mergeStrategy,\n tag,\n };\n\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n entityCache = this.applyCollectionReducer(entityCache, act);\n if (act.payload.error) {\n throw act.payload.error;\n }\n });\n } catch (error: any) {\n action.payload.error = error;\n }\n\n return entityCache;\n function getEntityOp(item: ChangeSetItem) {\n switch (item.op) {\n case ChangeSetOperation.Add:\n return EntityOp.SAVE_ADD_MANY;\n case ChangeSetOperation.Delete:\n return EntityOp.SAVE_DELETE_MANY;\n case ChangeSetOperation.Update:\n return EntityOp.SAVE_UPDATE_MANY;\n case ChangeSetOperation.Upsert:\n return EntityOp.SAVE_UPSERT_MANY;\n }\n }\n }\n\n protected saveEntitiesCancelReducer(\n entityCache: EntityCache,\n action: SaveEntitiesCancel\n ) {\n // This implementation can only clear the loading flag for the collections involved\n // If the save was optimistic, you'll have to compensate to fix the cache as you think necessary\n return this.clearLoadingFlags(\n entityCache,\n action.payload.entityNames || []\n );\n }\n\n protected saveEntitiesErrorReducer(\n entityCache: EntityCache,\n action: SaveEntitiesError\n ) {\n const originalAction = action.payload.originalAction;\n const originalChangeSet = originalAction.payload.changeSet;\n\n // This implementation can only clear the loading flag for the collections involved\n // If the save was optimistic, you'll have to compensate to fix the cache as you think necessary\n const entityNames = originalChangeSet.changes.map(\n (item) => item.entityName\n );\n return this.clearLoadingFlags(entityCache, entityNames);\n }\n\n protected saveEntitiesSuccessReducer(\n entityCache: EntityCache,\n action: SaveEntitiesSuccess\n ) {\n const { changeSet, correlationId, isOptimistic, mergeStrategy, tag } =\n action.payload;\n\n changeSet.changes.forEach((item) => {\n const entityName = item.entityName;\n const payload = {\n entityName,\n entityOp: getEntityOp(item),\n data: item.entities,\n correlationId,\n isOptimistic,\n mergeStrategy,\n tag,\n };\n\n const act: EntityAction = {\n type: `[${entityName}] ${action.type}`,\n payload,\n };\n entityCache = this.applyCollectionReducer(entityCache, act);\n });\n\n return entityCache;\n function getEntityOp(item: ChangeSetItem) {\n switch (item.op) {\n case ChangeSetOperation.Add:\n return EntityOp.SAVE_ADD_MANY_SUCCESS;\n case ChangeSetOperation.Delete:\n return EntityOp.SAVE_DELETE_MANY_SUCCESS;\n case ChangeSetOperation.Update:\n return EntityOp.SAVE_UPDATE_MANY_SUCCESS;\n case ChangeSetOperation.Upsert:\n return EntityOp.SAVE_UPSERT_MANY_SUCCESS;\n }\n }\n }\n // #endregion saveEntities reducers\n\n // #region helpers\n /** Apply reducer for the action's EntityCollection (if the action targets a collection) */\n private applyCollectionReducer(\n cache: EntityCache = {},\n action: EntityAction\n ) {\n const entityName = action.payload.entityName;\n const collection = cache[entityName];\n const reducer =\n this.entityCollectionReducerRegistry.getOrCreateReducer(entityName);\n\n let newCollection: EntityCollection;\n try {\n newCollection = collection\n ? reducer(collection, action)\n : reducer(this.entityCollectionCreator.create(entityName), action);\n } catch (error: any) {\n this.logger.error(error);\n action.payload.error = error;\n }\n\n return action.payload.error || collection === newCollection!\n ? cache\n : { ...cache, [entityName]: newCollection! };\n }\n\n /** Ensure loading is false for every collection in entityNames */\n private clearLoadingFlags(entityCache: EntityCache, entityNames: string[]) {\n let isMutated = false;\n entityNames.forEach((entityName) => {\n const collection = entityCache[entityName];\n if (collection.loading) {\n if (!isMutated) {\n entityCache = { ...entityCache };\n isMutated = true;\n }\n entityCache[entityName] = { ...collection, loading: false };\n }\n });\n return entityCache;\n }\n // #endregion helpers\n}\n","import { Injectable } from '@angular/core';\nimport { Logger } from './interfaces';\n\n@Injectable()\nexport class DefaultLogger implements Logger {\n error(message?: any, extra?: any) {\n if (message) {\n if (extra) {\n console.error(message, extra);\n } else {\n console.error(message);\n }\n }\n }\n\n log(message?: any, extra?: any) {\n if (message) {\n if (extra) {\n console.log(message, extra);\n } else {\n console.log(message);\n }\n }\n }\n\n warn(message?: any, extra?: any) {\n if (message) {\n if (extra) {\n console.warn(message, extra);\n } else {\n console.warn(message);\n }\n }\n }\n}\n","import { Inject, Injectable, Optional } from '@angular/core';\nimport { EntityPluralNames, PLURAL_NAMES_TOKEN } from './interfaces';\n\nconst uncountable = [\n // 'sheep',\n // 'fish',\n // 'deer',\n // 'moose',\n // 'rice',\n // 'species',\n 'equipment',\n 'information',\n 'money',\n 'series',\n];\n\n@Injectable()\nexport class DefaultPluralizer {\n pluralNames: EntityPluralNames = {};\n\n constructor(\n @Optional()\n @Inject(PLURAL_NAMES_TOKEN)\n pluralNames: EntityPluralNames[]\n ) {\n // merge each plural names object\n if (pluralNames) {\n pluralNames.forEach((pn) => this.registerPluralNames(pn));\n }\n }\n\n /**\n * Pluralize a singular name using common English language pluralization rules\n * Examples: \"company\" -> \"companies\", \"employee\" -> \"employees\", \"tax\" -> \"taxes\"\n */\n pluralize(name: string) {\n const plural = this.pluralNames[name];\n if (plural) {\n return plural;\n }\n // singular and plural are the same\n if (uncountable.indexOf(name.toLowerCase()) >= 0) {\n return name;\n // vowel + y\n } else if (/[aeiou]y$/.test(name)) {\n return name + 's';\n // consonant + y\n } else if (name.endsWith('y')) {\n return name.substring(0, name.length - 1) + 'ies';\n // endings typically pluralized with 'es'\n } else if (/[s|ss|sh|ch|x|z]$/.test(name)) {\n return name + 'es';\n } else {\n return name + 's';\n }\n }\n\n /**\n * Register a mapping of entity type name to the entity name's plural\n * @param pluralNames {EntityPluralNames} plural names for entity types\n */\n registerPluralNames(pluralNames: EntityPluralNames): void {\n this.pluralNames = { ...this.pluralNames, ...(pluralNames || {}) };\n }\n}\n","/**\n Client-side id-generators\n\n These GUID utility functions are not used by @ngrx/data itself at this time.\n They are included as candidates for generating persistable correlation ids if that becomes desirable.\n They are also safe for generating unique entity ids on the client.\n\n Note they produce 32-character hexadecimal UUID strings,\n not the 128-bit representation found in server-side languages and databases.\n\n These utilities are experimental and may be withdrawn or replaced in future.\n*/\n\n/**\n * Creates a Universally Unique Identifier (AKA GUID)\n */\nfunction getUuid() {\n // The original implementation is based on this SO answer:\n // http://stackoverflow.com/a/2117523/200253\n return 'xxxxxxxxxx4xxyxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n // eslint-disable-next-line no-bitwise\n const r = (Math.random() * 16) | 0,\n // eslint-disable-next-line no-bitwise\n v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/** Alias for getUuid(). Compare with getGuidComb(). */\nexport function getGuid() {\n return getUuid();\n}\n\n/**\n * Creates a sortable, pseudo-GUID (globally unique identifier)\n * whose trailing 6 bytes (12 hex digits) are time-based\n * Start either with the given getTime() value, seedTime,\n * or get the current time in ms.\n *\n * @param seed {number} - optional seed for reproducible time-part\n */\nexport function getGuidComb(seed?: number) {\n // Each new Guid is greater than next if more than 1ms passes\n // See http://thatextramile.be/blog/2009/05/using-the-guidcomb-identifier-strategy\n // Based on breeze.core.getUuid which is based on this StackOverflow answer\n // http://stackoverflow.com/a/2117523/200253\n //\n // Convert time value to hex: n.toString(16)\n // Make sure it is 6 bytes long: ('00'+ ...).slice(-12) ... from the rear\n // Replace LAST 6 bytes (12 hex digits) of regular Guid (that's where they sort in a Db)\n //\n // Play with this in jsFiddle: http://jsfiddle.net/wardbell/qS8aN/\n const timePart = ('00' + (seed || new Date().getTime()).toString(16)).slice(\n -12\n );\n return (\n 'xxxxxxxxxx4xxyxxx'.replace(/[xy]/g, function (c) {\n /* eslint-disable no-bitwise */\n const r = (Math.random() * 16) | 0,\n v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }) + timePart\n );\n}\n\n// Sort comparison value that's good enough\nexport function guidComparer(l: string, r: string) {\n const lLow = l.slice(-12);\n const rLow = r.slice(-12);\n return lLow !== rLow\n ? lLow < rLow\n ? -1\n : +(lLow !== rLow)\n : l < r\n ? -1\n : +(l !== r);\n}\n","import {\n ENVIRONMENT_INITIALIZER,\n EnvironmentProviders,\n inject,\n InjectionToken,\n makeEnvironmentProviders,\n Provider,\n} from '@angular/core';\nimport {\n ActionReducerFactory,\n combineReducers,\n MetaReducer,\n ReducerManager,\n} from '@ngrx/store';\nimport { EffectSources } from '@ngrx/effects';\nimport { EntityDispatcherDefaultOptions } from './dispatchers/entity-dispatcher-default-options';\nimport { EntityActionFactory } from './actions/entity-action-factory';\nimport { EntityCacheDispatcher } from './dispatchers/entity-cache-dispatcher';\nimport { entityCacheSelectorProvider } from './selectors/entity-cache-selector';\nimport { EntityCollectionServiceElementsFactory } from './entity-services/entity-collection-service-elements-factory';\nimport { EntityCollectionServiceFactory } from './entity-services/entity-collection-service-factory';\nimport { EntityServices } from './entity-services/entity-services';\nimport { EntityCollectionCreator } from './reducers/entity-collection-creator';\nimport { EntityCollectionReducerFactory } from './reducers/entity-collection-reducer';\nimport { EntityCollectionReducerMethodsFactory } from './reducers/entity-collection-reducer-methods';\nimport { EntityCollectionReducerRegistry } from './reducers/entity-collection-reducer-registry';\nimport { EntityDispatcherFactory } from './dispatchers/entity-dispatcher-factory';\nimport { EntityDefinitionService } from './entity-metadata/entity-definition.service';\nimport { EntityCacheReducerFactory } from './reducers/entity-cache-reducer';\nimport {\n ENTITY_CACHE_META_REDUCERS,\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n ENTITY_COLLECTION_META_REDUCERS,\n INITIAL_ENTITY_CACHE_STATE,\n} from './reducers/constants';\nimport { EntityCache } from './reducers/entity-cache';\nimport { EntitySelectorsFactory } from './selectors/entity-selectors';\nimport { EntitySelectors$Factory } from './selectors/entity-selectors$';\nimport { EntityServicesBase } from './entity-services/entity-services-base';\nimport { EntityServicesElements } from './entity-services/entity-services-elements';\nimport { DefaultLogger } from './utils/default-logger';\nimport { Logger, PLURAL_NAMES_TOKEN, Pluralizer } from './utils/interfaces';\nimport { CorrelationIdGenerator } from './utils/correlation-id-generator';\nimport { ENTITY_METADATA_TOKEN } from './entity-metadata/entity-metadata';\nimport { DefaultDataServiceFactory } from './dataservices/default-data.service';\nimport {\n DefaultPersistenceResultHandler,\n PersistenceResultHandler,\n} from './dataservices/persistence-result-handler.service';\nimport {\n DefaultHttpUrlGenerator,\n HttpUrlGenerator,\n} from './dataservices/http-url-generator';\nimport { EntityCacheDataService } from './dataservices/entity-cache-data.service';\nimport { EntityDataService } from './dataservices/entity-data.service';\nimport { EntityCacheEffects } from './effects/entity-cache-effects';\nimport { EntityEffects } from './effects/entity-effects';\nimport { DefaultPluralizer } from './utils/default-pluralizer';\nimport { EntityDataModuleConfig } from './entity-data-config';\n\nexport const BASE_ENTITY_DATA_PROVIDERS: Provider[] = [\n CorrelationIdGenerator,\n EntityDispatcherDefaultOptions,\n EntityActionFactory,\n EntityCacheDispatcher,\n EntityCacheReducerFactory,\n entityCacheSelectorProvider,\n EntityCollectionCreator,\n EntityCollectionReducerFactory,\n EntityCollectionReducerMethodsFactory,\n EntityCollectionReducerRegistry,\n EntityCollectionServiceElementsFactory,\n EntityCollectionServiceFactory,\n EntityDefinitionService,\n EntityDispatcherFactory,\n EntitySelectorsFactory,\n EntitySelectors$Factory,\n EntityServicesElements,\n { provide: ENTITY_CACHE_NAME_TOKEN, useValue: ENTITY_CACHE_NAME },\n { provide: EntityServices, useClass: EntityServicesBase },\n { provide: Logger, useClass: DefaultLogger },\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => initializeBaseEntityData(),\n },\n];\n\nfunction initializeBaseEntityData(): void {\n const reducerManager = inject(ReducerManager);\n const entityCacheReducerFactory = inject(EntityCacheReducerFactory);\n const entityCacheName = inject(ENTITY_CACHE_NAME_TOKEN, {\n optional: true,\n });\n const initialStateOrFn = inject(INITIAL_ENTITY_CACHE_STATE, {\n optional: true,\n });\n const metaReducersOrTokens = inject<\n Array<MetaReducer<EntityCache> | InjectionToken<MetaReducer<EntityCache>>>\n >(ENTITY_CACHE_META_REDUCERS, {\n optional: true,\n });\n\n // Add the @ngrx/data feature to the Store's features\n const key = entityCacheName || ENTITY_CACHE_NAME;\n const metaReducers = (metaReducersOrTokens || []).map((mr) => {\n return mr instanceof InjectionToken ? inject(mr) : mr;\n });\n const initialState =\n typeof initialStateOrFn === 'function'\n ? initialStateOrFn()\n : initialStateOrFn;\n\n const entityCacheFeature = {\n key,\n reducers: entityCacheReducerFactory.create(),\n reducerFactory: combineReducers as ActionReducerFactory<EntityCache>,\n initialState: initialState || {},\n metaReducers: metaReducers,\n };\n reducerManager.addFeature(entityCacheFeature);\n}\n\nexport const ENTITY_DATA_EFFECTS_PROVIDERS: Provider[] = [\n DefaultDataServiceFactory,\n EntityCacheDataService,\n EntityDataService,\n EntityCacheEffects,\n EntityEffects,\n { provide: HttpUrlGenerator, useClass: DefaultHttpUrlGenerator },\n {\n provide: PersistenceResultHandler,\n useClass: DefaultPersistenceResultHandler,\n },\n { provide: Pluralizer, useClass: DefaultPluralizer },\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => initializeEntityDataEffects(),\n },\n];\n\nfunction initializeEntityDataEffects(): void {\n const effectsSources = inject(EffectSources);\n const entityCacheEffects = inject(EntityCacheEffects);\n const entityEffects = inject(EntityEffects);\n\n effectsSources.addEffects(entityCacheEffects);\n effectsSources.addEffects(entityEffects);\n}\n\nexport function provideEntityDataConfig(\n config: EntityDataModuleConfig\n): Provider[] {\n return [\n {\n provide: ENTITY_CACHE_META_REDUCERS,\n useValue: config.entityCacheMetaReducers\n ? config.entityCacheMetaReducers\n : [],\n },\n {\n provide: ENTITY_COLLECTION_META_REDUCERS,\n useValue: config.entityCollectionMetaReducers\n ? config.entityCollectionMetaReducers\n : [],\n },\n {\n provide: PLURAL_NAMES_TOKEN,\n multi: true,\n useValue: config.pluralNames ? config.pluralNames : {},\n },\n {\n provide: ENTITY_METADATA_TOKEN,\n multi: true,\n useValue: config.entityMetadata ? config.entityMetadata : [],\n },\n ];\n}\n\n/**\n * Sets up base entity data providers with entity config.\n * This function should to be used at the root level.\n *\n * @usageNotes\n *\n * ### Providing entity data with effects\n *\n * When used with `withEffects` feature, the `provideEntityData` function is\n * an alternative to `EntityDataModule.forRoot`\n *\n * ```ts\n * import { provideStore } from '@ngrx/store';\n * import { provideEffects } from '@ngrx/effects';\n * import {\n * EntityMetadataMap,\n * provideEntityData,\n * withEffects,\n * } from '@ngrx/data';\n *\n * const entityMetadata: EntityMetadataMap = {\n * Hero: {},\n * Villain: {},\n * };\n * const pluralNames = { Hero: 'Heroes' };\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideStore(),\n * provideEffects(),\n * provideEntityData({ entityMetadata, pluralNames }, withEffects()),\n * ],\n * });\n * ```\n *\n * ### Providing entity data without effects\n *\n * When used without `withEffects` feature, the `provideEntityData` function is\n * an alternative to `EntityDataModuleWithoutEffects.forRoot`.\n *\n * ```ts\n * import { provideStore } from '@ngrx/store';\n * import { EntityMetadataMap, provideEntityData } from '@ngrx/data';\n *\n * const entityMetadata: EntityMetadataMap = {\n * Musician: {},\n * Song: {},\n * };\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideStore(),\n * provideEntityData({ entityMetadata }),\n * ],\n * });\n * ```\n *\n */\nexport function provideEntityData(\n config: EntityDataModuleConfig,\n ...features: EntityDataFeature[]\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n BASE_ENTITY_DATA_PROVIDERS,\n provideEntityDataConfig(config),\n ...features.map((feature) => feature.ɵproviders),\n ]);\n}\n\nenum EntityDataFeatureKind {\n WithEffects,\n}\n\ninterface EntityDataFeature {\n ɵkind: EntityDataFeatureKind;\n ɵproviders: Provider[];\n}\n\n/**\n * Registers entity data effects and provides HTTP data services.\n *\n * @see `provideEntityData`\n */\nexport function withEffects(): EntityDataFeature {\n return {\n ɵkind: EntityDataFeatureKind.WithEffects,\n ɵproviders: [ENTITY_DATA_EFFECTS_PROVIDERS],\n };\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EntityDataModuleConfig } from './entity-data-config';\nimport {\n BASE_ENTITY_DATA_PROVIDERS,\n provideEntityDataConfig,\n} from './provide-entity-data';\n\n/**\n * Module without effects or dataservices which means no HTTP calls\n * This module helpful for internal testing.\n * Also helpful for apps that handle server access on their own and\n * therefore opt-out of @ngrx/effects for entities\n */\n@NgModule({\n providers: [BASE_ENTITY_DATA_PROVIDERS],\n})\nexport class EntityDataModuleWithoutEffects {\n static forRoot(\n config: EntityDataModuleConfig\n ): ModuleWithProviders<EntityDataModuleWithoutEffects> {\n return {\n ngModule: EntityDataModuleWithoutEffects,\n providers: [provideEntityDataConfig(config)],\n };\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EntityDataModuleConfig } from './entity-data-config';\nimport { EntityDataModuleWithoutEffects } from './entity-data-without-effects.module';\nimport {\n ENTITY_DATA_EFFECTS_PROVIDERS,\n provideEntityDataConfig,\n} from './provide-entity-data';\n\n/**\n * entity-data main module includes effects and HTTP data services\n * Configure with `forRoot`.\n * No `forFeature` yet.\n */\n@NgModule({\n imports: [EntityDataModuleWithoutEffects],\n providers: [ENTITY_DATA_EFFECTS_PROVIDERS],\n})\nexport class EntityDataModule {\n static forRoot(\n config: EntityDataModuleConfig\n ): ModuleWithProviders<EntityDataModule> {\n return {\n ngModule: EntityDataModule,\n providers: [provideEntityDataConfig(config)],\n };\n }\n}\n","// actions\nexport { EntityActionFactory } from './actions/entity-action-factory';\nexport { EntityActionGuard } from './actions/entity-action-guard';\nexport { ofEntityOp, ofEntityType } from './actions/entity-action-operators';\nexport {\n EntityAction,\n EntityActionOptions,\n EntityActionPayload,\n} from './actions/entity-action';\nexport {\n EntityCacheAction,\n EntityCacheQuerySet,\n ClearCollections,\n LoadCollections,\n MergeQuerySet,\n SetEntityCache,\n SaveEntities,\n SaveEntitiesCancel,\n SaveEntitiesCanceled,\n SaveEntitiesError,\n SaveEntitiesSuccess,\n} from './actions/entity-cache-action';\nexport {\n ChangeSetOperation,\n ChangeSetAdd,\n ChangeSetDelete,\n ChangeSetUpdate,\n ChangeSetUpsert,\n ChangeSetItem,\n ChangeSet,\n ChangeSetItemFactory,\n changeSetItemFactory,\n excludeEmptyChangeSetItems,\n} from './actions/entity-cache-change-set';\n\nexport {\n EntityOp,\n OP_SUCCESS,\n OP_ERROR,\n makeErrorOp,\n makeSuccessOp,\n} from './actions/entity-op';\nexport { MergeStrategy } from './actions/merge-strategy';\nexport { UpdateResponseData } from './actions/update-response-data';\n\n// // dataservices\nexport { DataServiceError } from './dataservices/data-service-error';\nexport { EntityActionDataServiceError } from './dataservices/data-service-error';\nexport { DefaultDataServiceConfig } from './dataservices/default-data-service-config';\nexport { DefaultDataService } from './dataservices/default-data.service';\nexport { DefaultDataServiceFactory } from './dataservices/default-data.service';\nexport { EntityCacheDataService } from './dataservices/entity-cache-data.service';\nexport { EntityDataService } from './dataservices/entity-data.service';\nexport { EntityHttpResourceUrls } from './dataservices/http-url-generator';\nexport { HttpResourceUrls } from './dataservices/http-url-generator';\nexport { HttpUrlGenerator } from './dataservices/http-url-generator';\nexport { DefaultHttpUrlGenerator } from './dataservices/http-url-generator';\nexport { normalizeRoot } from './dataservices/http-url-generator';\nexport {\n EntityCollectionDataService,\n HttpMethods,\n RequestData,\n QueryParams,\n} from './dataservices/interfaces';\nexport {\n PersistenceResultHandler,\n DefaultPersistenceResultHandler,\n} from './dataservices/persistence-result-handler.service';\n\n// // dispatchers\nexport { EntityCacheDispatcher } from './dispatchers/entity-cache-dispatcher';\nexport {\n EntityServerCommands,\n EntityCacheCommands,\n EntityCommands,\n} from './dispatchers/entity-commands';\nexport { EntityDispatcherBase } from './dispatchers/entity-dispatcher-base';\nexport { EntityDispatcherDefaultOptions } from './dispatchers/entity-dispatcher-default-options';\nexport { EntityDispatcherFactory } from './dispatchers/entity-dispatcher-factory';\nexport {\n EntityDispatcher,\n PersistanceCanceled,\n} from './dispatchers/entity-dispatcher';\n\n// // effects\nexport { EntityCacheEffects } from './effects/entity-cache-effects';\nexport { persistOps, EntityEffects } from './effects/entity-effects';\n\n// // entity-metadata\nexport {\n EntityDefinitions,\n EntityDefinitionService,\n} from './entity-metadata/entity-definition.service';\nexport {\n EntityDefinition,\n createEntityDefinition,\n} from './entity-metadata/entity-definition';\nexport {\n EntityFilterFn,\n PropsFilterFnFactory,\n} from './entity-metadata/entity-filters';\nexport {\n ENTITY_METADATA_TOKEN,\n EntityMetadata,\n EntityMetadataMap,\n} from './entity-metadata/entity-metadata';\n\n// // entity-services\nexport { EntityCollectionServiceBase } from './entity-services/entity-collection-service-base';\nexport {\n EntityCollectionServiceElements,\n EntityCollectionServiceElementsFactory,\n} from './entity-services/entity-collection-service-elements-factory';\nexport { EntityCollectionServiceFactory } from './entity-services/entity-collection-service-factory';\nexport { EntityCollectionService } from './entity-services/entity-collection-service';\nexport { EntityServicesBase } from './entity-services/entity-services-base';\nexport { EntityServicesElements } from './entity-services/entity-services-elements';\nexport {\n EntityServices,\n EntityCollectionServiceMap,\n} from './entity-services/entity-services';\n\n// // reducers\nexport {\n ENTITY_CACHE_NAME,\n ENTITY_CACHE_NAME_TOKEN,\n ENTITY_CACHE_META_REDUCERS,\n ENTITY_COLLECTION_META_REDUCERS,\n INITIAL_ENTITY_CACHE_STATE,\n} from './reducers/constants';\nexport { EntityCacheReducerFactory } from './reducers/entity-cache-reducer';\nexport { EntityCache } from './reducers/entity-cache';\nexport { EntityChangeTrackerBase } from './reducers/entity-change-tracker-base';\nexport { EntityChangeTracker } from './reducers/entity-change-tracker';\nexport {\n EntityCollectionCreator,\n createEmptyEntityCollection,\n} from './reducers/entity-collection-creator';\nexport {\n EntityCollectionReducerMethodMap,\n EntityCollectionReducerMethods,\n EntityCollectionReducerMethodsFactory,\n} from './reducers/entity-collection-reducer-methods';\nexport {\n EntityCollectionReducers,\n EntityCollectionReducerRegistry,\n} from './reducers/entity-collection-reducer-registry';\nexport {\n EntityCollectionReducer,\n EntityCollectionReducerFactory,\n} from './reducers/entity-collection-reducer';\nexport {\n ChangeType,\n ChangeState,\n ChangeStateMap,\n EntityCollection,\n} from './reducers/entity-collection';\n\n// // selectors\nexport {\n ENTITY_CACHE_SELECTOR_TOKEN,\n entityCacheSelectorProvider,\n EntityCacheSelector,\n createEntityCacheSelector,\n} from './selectors/entity-cache-selector';\nexport {\n CollectionSelectors,\n EntitySelectors,\n EntitySelectorsFactory,\n} from './selectors/entity-selectors';\nexport {\n EntitySelectors$,\n EntitySelectors$Factory,\n} from './selectors/entity-selectors$';\n\n// // Utils\nexport { CorrelationIdGenerator } from './utils/correlation-id-generator';\nexport { DefaultLogger } from './utils/default-logger';\nexport { DefaultPluralizer } from './utils/default-pluralizer';\nexport { getGuid, getGuidComb, guidComparer } from './utils/guid-fns';\nexport {\n Logger,\n EntityPluralNames,\n PLURAL_NAMES_TOKEN,\n Pluralizer,\n} from './utils/interfaces';\nexport {\n defaultSelectId,\n flattenArgs,\n toUpdateFactory,\n} from './utils/utilities';\n\n// // EntityDataConfig\nexport { EntityDataModuleConfig } from './entity-data-config';\n\n// // EntityDataModule\nexport { EntityDataModuleWithoutEffects } from './entity-data-without-effects.module';\nexport { EntityDataModule } from './entity-data.module';\n\n// // Standalone APIs\nexport { provideEntityData, withEffects } from './provide-entity-data';\n","/**\n * DO NOT EDIT\n *\n * This file is automatically generated at build\n */\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.Pluralizer","i2.HttpUrlGenerator","i3.DefaultDataServiceConfig","i1.EntityDefinitionService","i2","i1.DefaultDataServiceFactory","i1.Logger","i2.EntityActionFactory","i1.EntityActionFactory","i3.EntityDispatcherDefaultOptions","i4.CorrelationIdGenerator","i1.EntityDispatcherFactory","i2.EntityDefinitionService","i3.EntitySelectorsFactory","i4.EntitySelectors$Factory","i1.EntityCollectionServiceElementsFactory","i1.EntityCollectionServiceFactory","i2.EntityDispatcherFactory","i3.EntitySelectors$Factory","i4","i1.EntityServicesElements","i1.EntityCollectionReducerMethodsFactory","i1.EntityCollectionCreator","i2.EntityCollectionReducerRegistry","i3.Logger"],"mappings":";;;;;;;;;;;;;MASa,mBAAmB,CAAA;;AAwB9B,IAAA,MAAM,CACJ,aAA8C,EAC9C,QAAmB,EACnB,IAAQ,EACR,OAA6B,EAAA;AAE7B,QAAA,MAAM,OAAO,GACX,OAAO,aAAa,KAAK,QAAQ;AAC/B,cAAG;AACC,gBAAA,IAAI,OAAO,IAAI,EAAE;AACjB,gBAAA,UAAU,EAAE,aAAa;gBACzB,QAAQ;gBACR,IAAI;AACsB,aAAA;cAC5B,aAAa,CAAC;AACpB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;KACjC;AAED;;;;AAIG;AACO,IAAA,UAAU,CAAU,OAA+B,EAAA;QAC3D,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QAC9C,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;AACD,QAAA,IAAI,QAAQ,IAAI,IAAI,EAAE;AACpB,YAA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