breeze-client 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"entity-aspect.js","sourceRoot":"","sources":["../../src/entity/entity-aspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAG,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAiE,MAAM,gCAAgC,CAAC;AAC3H,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAiFpD;;;;;;;;;;;;;;;EAeE;AACF,MAAM,OAAO,YAAY;IACvB,qEAAqE;IACrE,MAAM,CAAU;IAChB,yEAAyE;IACzE,aAAa,CAAiB;IAC9B,yBAAyB;IACzB,WAAW,CAAe;IAC1B,wBAAwB;IACxB,YAAY,CAAe;IAC3B,wFAAwF;IACxF,+FAA+F;IAC/F,+FAA+F;IAC/F,gGAAgG;IAChG,uFAAuF;IACvF,4DAA4D;IAC5D,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,IAAI,WAAW,CAAC,WAAwB;QACtC,IAAI,CAAC,Y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Ae,CAAC,IAAI,CAAC,cAAe,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;IAC5E,CAAC;CAEF;AAED,SAAS,mBAAmB,CAAC,MAAW;IACtC,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,aAAa,CAAC;IACzD,MAAM,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,CAAC;IACpD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAO;QAC/C,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;YAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACnC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { core } from '../core/core.js';\nimport { config } from '../config/config.js';\nimport { BreezeEvent } from '../core/event.js';\nimport { assertParam, paramError } from '../core/assert-param.js';\nimport { EntityState } from './entity-state.js';\nimport { EntityAction } from './entity-action.js';\nimport { EntityType, ComplexType, DataProperty, NavigationProperty, EntityProperty } from '../metadata/entity-metadata.js';\nimport { observableArray } from './observable-array.js';\nimport { EntityKey } from './entity-key.js';\nimport { EntityGroup } from './entity-group.js';\nimport { EntityManager, QueryResult, QueryErrorCallback, QuerySuccessCallback, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js';\nimport { Validator, ValidationError } from '../validation/validate.js';\nimport { EntityQuery } from '../query/entity-query.js';\nimport type { DataKeys, OriginalValues } from '../query/property-path.js';\nimport { DataType } from '../metadata/data-type.js';\n\n/** An instance of an {@link EntityType}: an object with a key, tracked by an {@link EntityManager}\nonce attached. Breeze gives every entity these members, whether its class declares them or not. */\nexport interface Entity {\n /** The {@link EntityAspect} that holds this entity's Breeze state: its {@link EntityState}, key,\n original values, validation errors and manager. */\n entityAspect: EntityAspect;\n /** The {@link EntityType} that describes this entity. */\n entityType: EntityType;\n /** Get the property with the given name */\n getProperty(prop: string): any;\n /** Set the property with the given name, exactly as assigning it would.\n\n With the backing-store model library it returns the object itself, so calls can be chained.\n The return type is `any` rather than `this` so that a class declaring `setProperty` as returning\n `void` still implements this interface.\n\n A name that is not a property of the type is not an error: like an assignment, it creates an\n ordinary property, which Breeze does not track. */\n setProperty(prop: any, value: any): any;\n /** @hidden @internal */\n prototype?: { _$typeName: string };\n /** @hidden @internal */\n _$entityType?: EntityType;\n}\n\n/** An instance of a {@link ComplexType}: a value with no key of its own, held in a complex property\nof an entity or of another complex object. */\nexport interface ComplexObject {\n /** The {@link ComplexAspect} that holds this object's parent, parent property and original values. */\n complexAspect: ComplexAspect;\n /** The {@link ComplexType} that describes this object. */\n complexType: ComplexType;\n /** Get the property with the given name */\n getProperty(prop: string): any;\n /** Set the property with the given name, exactly as assigning it would. Returns the object\n itself with the backing-store model library - see {@link Entity.setProperty}. */\n setProperty(prop: any, value: any): any;\n /** @hidden @internal */\n prototype?: { _$typeName: string };\n}\n\n/** An entity or a complex object - either kind of object Breeze tracks the properties of. Used where\neither is accepted, such as {@link ComplexAspect.parent}. */\nexport type StructuralObject = Entity | ComplexObject;\n\n/**\n * The type of the results of a query built from entities you already have, such as\n * {@link EntityQuery.fromEntities} or {@link RelationArray.load}: the entities' own class when it\n * is known - `QueriedAs<Customer>` is `Customer` - and `any` when all that is known is\n * {@link Entity}, so that `results[0].companyName` compiles without a cast.\n */\n// `any` rather than `Entity` for the plain case: that is what these results were before the type\n// parameters existed, and narrowing it would break every existing caller.\nexport type QueriedAs<U> = Entity extends U ? any : U;\n\n/** The argument to an entity's {@link EntityAspect.propertyChanged} event. It is also the `args` of\nan {@link EntityChangedEventArgs} for {@link EntityAction.PropertyChange}. */\nexport interface PropertyChangedEventArgs {\n /** The entity that changed. For a property of a complex object, the entity that holds it. */\n entity: Entity;\n /** The name of the property that changed. For a property of a complex object it is a path from\n the entity, such as `\"location.city\"`, with no index for an element of a complex array.\n\n `null` when any number of properties may have changed at once - when a query or save merges\n values into the entity, or its changes are rejected. The other members are then not set. */\n propertyName: string | null;\n /** The object whose property was set: the entity itself, or the complex object that owns the\n property. */\n parent?: StructuralObject;\n /** The {@link DataProperty} or {@link NavigationProperty} that changed. It belongs to the type of\n `parent`, which is not the entity's type when `parent` is a complex object. */\n property?: EntityProperty;\n /** The value before the change. */\n oldValue?: any;\n /** The value after the change, converted to the property's data type where Breeze can. */\n newValue?: any;\n}\n\n\n/**\nAn EntityAspect instance is associated with every attached entity and is accessed via the entity's 'entityAspect' property.\n\nThe EntityAspect itself provides properties to determine and modify the EntityState of the entity and has methods\nthat provide a variety of services including validation and change tracking.\n\nAn EntityAspect will almost never need to be constructed directly. You will usually get an EntityAspect by accessing\nan entities 'entityAspect' property. This property will be automatically attached when an entity is created via either\na query, import or {@link EntityManager.createEntity} call.\n```ts\n// assume order is an order entity attached to an EntityManager.\nvar aspect = order.entityAspect;\nvar currentState = aspect.entityState;\n```\n\n*/\nexport class EntityAspect {\n /** The Entity that this aspect is associated with. __Read Only__ */\n entity?: Entity;\n /** The {@link EntityManager} that contains this entity. __Read Only__ */\n entityManager?: EntityManager;\n /** @hidden @internal */\n entityGroup?: EntityGroup;\n /** @hidden @internal */\n _entityState!: EntityState;\n // An accessor rather than a plain field because the entity's group keeps the set of its\n // entities that are not Unchanged, and this is the one place every state change passes through\n // - setEntityState, _detach, the attach and merge paths, and anything an application or plugin\n // assigns. Working the set out by scanning instead is what made hasChanges cost the size of the\n // cache, once per state change. See \"Cache lookups that were scans\" in CHANGES-DEV.md.\n /** The {@link EntityState} of this entity. __Read Only__ */\n get entityState(): EntityState {\n return this._entityState;\n }\n set entityState(entityState: EntityState) {\n this._entityState = entityState;\n const group = this.entityGroup;\n if (group === undefined) return; // detached: nothing is tracking it\n if (entityState === EntityState.Unchanged || entityState === EntityState.Detached) {\n group._changedEntities.delete(this.entity!);\n } else {\n group._changedEntities.add(this.entity!);\n }\n }\n /** Whether this entity is in the process of being saved. __Read Only__ */\n isBeingSaved: boolean;\n /** The 'original values' of this entity where they are different from the 'current values'.\n This is a map where the key is a property name and the value is the 'original value' of the property. */\n originalValues: Record<string, any>;\n /** Whether this entity has any validation errors. __Read Only__ */\n hasValidationErrors: boolean;\n /** Whether this entity has a temporary {@link EntityKey}. */\n hasTempKey?: boolean;\n /** Whether this entity was created by being loaded from the database */\n wasLoaded?: boolean;\n /** Extra metadata about this entity such as the entity's etag.\n You may extend this object with your own metadata information.\n Breeze (de)serializes this object when importing/exporting the entity. */\n extraMetadata?: any;\n /**\n A {@link BreezeEvent} that fires whenever any of the validation errors on this entity change.\n Note that this might be the removal of an error when some data on the entity is fixed.\n @eventArgs - \n - entity - The entity on which the validation errors are being added or removed.\n - added - An array containing any newly added {@link ValidationError}s\n - removed - An array containing any newly removed {@link ValidationError}s. This is those\n errors that have been 'fixed'.\n\n```ts\n// assume order is an order entity attached to an EntityManager.\norder.entityAspect.validationErrorsChanged.subscribe(\nfunction (validationChangeArgs) {\n // this code will be executed anytime a property value changes on the 'order' entity.\n var entity == validationChangeArgs.entity; // Note: entity === order\n var errorsAdded = validationChangeArgs.added;\n var errorsCleared = validationChangeArgs.removed;\n});\n```\n @event\n */\n validationErrorsChanged: BreezeEvent<ValidationErrorsChangedEventArgs>;\n /**\n A {@link BreezeEvent} that fires whenever a value of one of this entity's properties change.\n @eventArgs -\n - entity - The entity whose property has changed.\n - property - The {@link DataProperty} that changed.\n - propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes\n queries, imports and saves that require a merge. The remaining parameters will not exist in this case either. This will actually be a \"property path\"\n for any properties of a complex type.\n - oldValue - The old value of this property before the change.\n - newValue - The new value of this property after the change.\n - parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity \n for any complex type or nested complex type properties.\n\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.propertyChanged.subscribe(\n function (propertyChangedArgs) {\n // this code will be executed anytime a property value changes on the 'order' entity.\n var entity = propertyChangedArgs.entity; // Note: entity === order\n var propertyNameChanged = propertyChangedArgs.propertyName;\n var oldValue = propertyChangedArgs.oldValue;\n var newValue = propertyChangedArgs.newValue;\n });\n ```\n @event\n */\n propertyChanged: BreezeEvent<PropertyChangedEventArgs>;\n\n /** @hidden @internal */\n _validationErrors: { [index: string]: ValidationError };\n /** @hidden @internal */\n _pendingValidationResult: any;\n /**\n The async validator runs in flight, by the key of the error each would add or remove: one run\n per check, so that a newer run replaces an older one rather than racing it. Created on first use.\n @hidden @internal\n */\n declare _asyncChecks?: Map<string, AsyncCheckRun>;\n\n /** Whether an async validator is still running for this entity - see\n {@link EntityAspect.validateEntityAsync}. __Read Only__ */\n get isValidating(): boolean {\n return !!this._asyncChecks && this._asyncChecks.size > 0;\n }\n /** @hidden @internal */\n _entityKey: EntityKey;\n /** @hidden @internal */\n _loadedNps: any[];\n /** @hidden @internal */\n _initialized?: boolean;\n /** @hidden @internal */\n _inProcess: any[]; // used in defaultPropertyInterceptor for temp storage.\n /** @hidden @internal */\n _inProcessEntity?: Entity; // used in EntityManager\n /** @hidden @internal */\n constructor(entity?: Entity) {\n\n // if called without new\n // if (!(this instanceof EntityAspect)) {\n // return new EntityAspect(entity);\n // }\n\n this.entity = entity;\n // TODO: keep public or not?\n this.entityGroup = undefined;\n this.entityManager = undefined;\n this.entityState = EntityState.Detached;\n this.isBeingSaved = false;\n this.originalValues = {};\n this.hasValidationErrors = false;\n this._validationErrors = {};\n\n // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method\n // this._loadedNavPropMap = {};\n\n this.validationErrorsChanged = new BreezeEvent(\"validationErrorsChanged\", this);\n this.propertyChanged = new BreezeEvent(\"propertyChanged\", this);\n // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent.\n\n if (entity != null) {\n // remove properties that should be on prototype but placed on instance by Babel\n if (entity.hasOwnProperty('entityType')) {\n // throw new Error(\"Entity instance has entityType property; should only be on prototype\");\n delete (entity as any).entityType;\n }\n entity.entityAspect = this;\n\n // entityType should already be on the entity from 'watch'\n let entityType = entity.entityType || entity._$entityType;\n if (!entityType) {\n let typeName = entity.prototype!._$typeName;\n if (!typeName) {\n throw new Error(\"This entity is not registered as a valid EntityType\");\n } else {\n throw new Error(\"Metadata for this entityType has not yet been resolved: \" + typeName);\n }\n }\n let entityCtor = entityType.getCtor();\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(entity, entityCtor.prototype);\n }\n }\n\n /** @hidden */\n // type-guard\n static isEntity(obj: StructuralObject): obj is Entity {\n return (obj as any).entityAspect != null;\n }\n\n // TODO: refactor this and the instance getPropertyValue method.\n /**\n Returns the value of a specified 'property path' for a specified entity.\n\n The propertyPath can be either a string delimited with '.' or a string array. \n */\n // used by EntityQuery and Predicate\n static getPropertyPathValue(obj: Entity, propertyPath: string | string[]) {\n let properties = Array.isArray(propertyPath) ? propertyPath : propertyPath.split(\".\");\n if (properties.length === 1) {\n // properties[0], not propertyPath. Given a single-element array this used to pass the array\n // itself to getProperty, and reached the right property only because a property lookup\n // coerces ['freight'] to 'freight'. Correct by accident, and slower than the real thing.\n return obj.getProperty(properties[0]);\n } else {\n let nextValue = obj;\n // hack use of some to perform mapFirst operation.\n properties.some((prop) => {\n nextValue = nextValue.getProperty(prop);\n return nextValue == null;\n });\n return nextValue;\n }\n }\n\n /**\n Returns the {@link EntityKey} for this Entity.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var entityKey = order.entityAspect.getKey();\n ```\n @param forceRefresh - (boolean=false) Forces the recalculation of the key. This should normally be unnecessary.\n @returns The {@link EntityKey} associated with this Entity.\n */\n getKey(forceRefresh: boolean = false) {\n // Inline, not assertParam: getKey runs several times per entity created and again on\n // every attach, merge and foreign key lookup. Same wording.\n if (forceRefresh != null && typeof forceRefresh !== 'boolean') {\n throw paramError('forceRefresh', \"is optional or it must be a 'boolean'\");\n }\n if (forceRefresh || !this._entityKey) {\n let entityType = this.entity!.entityType;\n let keyProps = entityType.keyProperties;\n let values = keyProps.map(function (p) {\n return this.entity.getProperty(p.name);\n }, this);\n this._entityKey = new EntityKey(entityType, values);\n }\n return this._entityKey;\n }\n\n /**\n Returns the entity to an {@link EntityState} of 'Unchanged' by committing all changes made since the entity was last queried\n had 'acceptChanges' called on it.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.acceptChanges();\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\n ```\n */\n acceptChanges() {\n if (!this.entity) return;\n this._checkOperation(\"acceptChanges\");\n let em = this.entityManager!;\n if (this.entityState.isDeleted()) {\n em.detachEntity(this.entity);\n } else {\n this.setUnchanged();\n }\n em.entityChanged.publish({ entityAction: EntityAction.AcceptChanges, entity: this.entity });\n }\n\n /**\n Returns the entity to an {@link EntityState} of 'Unchanged' by rejecting all changes made to it since the entity was last queried\n had 'rejectChanges' called on it.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.rejectChanges();\n // The 'order' entity will now be in an 'Unchanged' state with any changes rejected.\n ```\n */\n rejectChanges() {\n this._checkOperation(\"rejectChanges\");\n let entity = this.entity!;\n let entityManager = this.entityManager!;\n // we do not want PropertyChange or EntityChange events to occur here\n core.using(entityManager, \"isRejectingChanges\", true, function () {\n rejectChangesCore(entity);\n });\n if (this.entityState.isAdded()) {\n // next line is needed because the following line will cause this.entityManager -> null;\n entityManager.detachEntity(entity);\n // need to tell em that an entity that needed to be saved no longer does.\n entityManager._notifyStateChange(entity, false);\n } else {\n if (this.entityState.isDeleted()) {\n entityManager._linkRelatedEntities(entity);\n }\n this.setUnchanged();\n // propertyChanged propertyName is not specified because more than one property may have changed.\n this.propertyChanged.publish({ entity: entity, propertyName: null });\n entityManager.entityChanged.publish({ entityAction: EntityAction.RejectChanges, entity: entity });\n }\n }\n\n /** @hidden @internal */\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\n getPropertyPath(propName: string) {\n return propName;\n }\n\n /**\n Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {@link EntityManager.addEntity}\n because no key generation will occur for autogenerated keys as a result of this operation. As a result this operation can be problematic\n unless you are certain that the entity being marked 'Added' does not already exist in the database and does not have an autogenerated key.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setAdded();\n // The 'order' entity will now be in an 'Added' state.\n ```\n */\n setAdded() {\n return this.setEntityState(EntityState.Added);\n }\n\n /**\n Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling {@link EntityAspect.acceptChanges}.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setUnchanged();\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\n ```\n */\n setUnchanged = function () {\n return this.setEntityState(EntityState.Unchanged);\n };\n\n\n /**\n Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setModified();\n // The 'order' entity will now be in a 'Modified' state.\n ```\n */\n setModified = function () {\n return this.setEntityState(EntityState.Modified);\n };\n\n /**\n Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call\n but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setDeleted();\n // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.\n ```\n */\n setDeleted = function () {\n return this.setEntityState(EntityState.Deleted);\n };\n\n /**\n Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities.\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setDetached();\n // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.\n ```\n */\n setDetached = function () {\n return this.setEntityState(EntityState.Detached);\n };\n\n /**\n Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n order.entityAspect.setEntityState(EntityState.Unchanged);\n // The 'order' entity will now be in a 'Unchanged' state.\n ```\n */\n setEntityState(entityState: EntityState) {\n if (this.entityState === entityState) return false;\n this._checkOperation(\"setEntityState\");\n if (this.entityState.isDetached()) {\n throw new Error(\"You cannot set the 'entityState' of an entity when it is detached - except by first attaching it to an EntityManager\");\n }\n let entity = this.entity!;\n let em = this.entityManager!;\n let needsSave = true;\n if (entityState === EntityState.Unchanged) {\n clearOriginalValues(entity);\n this.hasTempKey = undefined; // not delete: every entity that becomes Unchanged runs this\n needsSave = false;\n } else if (entityState === EntityState.Added) {\n clearOriginalValues(entity);\n // TODO: more to do here... like regenerating key ???\n } else if (entityState === EntityState.Deleted) {\n if (this.entityState.isAdded()) {\n // turn it into a detach and exit early\n this.setEntityState(EntityState.Detached);\n return true;\n } else {\n // TODO: think about cascade deletes\n // entityState needs to be set it early in this one case to insure that fk's are not cleared.\n this.entityState = EntityState.Deleted;\n removeFromRelations(entity, EntityState.Deleted);\n }\n } else if (entityState === EntityState.Modified) {\n // nothing extra needed\n } else if (entityState === EntityState.Detached) {\n let group = this.entityGroup;\n // no group === already detached.\n if (!group) return false;\n group.detachEntity(entity);\n // An entity whose foreign keys named parents that are not in the cache is parked in the\n // unattached-children map, waiting for them. Detaching it has to take it back out, or the\n // manager holds it for good: clear() replaces the whole map, but detachEntity does not.\n em._unattachedChildrenMap.removeChild(entity);\n // needs to occur early here - so this IS deliberately redundent with the same code later in this method.\n this.entityState = entityState;\n removeFromRelations(entity, EntityState.Detached);\n this._detach();\n em.entityChanged.publish({ entityAction: EntityAction.Detach, entity: entity });\n needsSave = false;\n }\n this.entityState = entityState;\n em._notifyStateChange(entity, needsSave);\n return true;\n }\n\n loadNavigationProperty(navigationProperty: string): Promise<QueryResult>;\n loadNavigationProperty(navigationProperty: NavigationProperty): Promise<QueryResult>;\n /** @deprecated Await the returned promise instead of passing callbacks. */\n loadNavigationProperty(navigationProperty: string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\n /** @deprecated Await the returned promise instead of passing callbacks. */\n loadNavigationProperty(navigationProperty: NavigationProperty, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\n /**\n Performs a query for the value of a specified {@link NavigationProperty}. __Async__\n ```ts\n emp.entityAspect.loadNavigationProperty(\"Orders\").then(function (data) {\n var orders = data.results;\n }).catch(function (exception) {\n // handle exception here;\n });\n ```\n @param navigationProperty - The NavigationProperty or the name of the NavigationProperty to 'load'.\n @param callback - Deprecated. Function to call on success.\n @param errorCallback - Deprecated. Function to call on failure.\n @returns Promise with shape\n - results {Array of Entity}\n - query {EntityQuery} The original query\n - httpResponse {httpResponse} The HttpResponse returned from the server.\n */\n loadNavigationProperty(navigationProperty: NavigationProperty | string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult> {\n let entity = this.entity!;\n let navProperty = entity.entityType._checkNavProperty(navigationProperty);\n let query = EntityQuery.fromEntityNavigation(entity, navProperty);\n // return entity.entityAspect.entityManager.executeQuery(query, callback, errorCallback);\n let promise = entity.entityAspect.entityManager!.executeQuery(query);\n\n return promise.then((data) => {\n this._markAsLoaded(navProperty.name);\n if (callback) callback(data);\n return Promise.resolve(data);\n }, (error) => {\n if (errorCallback) errorCallback(error);\n return Promise.reject(error);\n });\n\n }\n\n /**\n Marks this navigationProperty on this entity as already having been loaded.\n ```ts\n emp.entityAspect.markNavigationPropertyAsLoaded(\"Orders\");\n ```\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\n */\n markNavigationPropertyAsLoaded(navigationProperty: NavigationProperty | string) {\n if (!this.entity) return;\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\n this._markAsLoaded(navProperty.name);\n }\n\n isNavigationPropertyLoaded(navigationProperty: string): boolean;\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean;\n /**\n Determines whether a navigationProperty on this entity has already been loaded.\n\n A navigation property is considered loaded when any of the following three conditions applies:\n\n 1. It was fetched from the backend server.\n <br/> This can be the result of an expand query or a call to the {@link EntityAspect.loadNavigationProperty} method.\n <br/> Note that even if the fetch returns nothing the property is still marked as loaded in this case.\n 1. The property is scalar and has been set to a nonnull value.\n 1. The {@link EntityAspect.markNavigationPropertyAsLoaded} was called.\n \n ```ts\n var wasLoaded = emp.entityAspect.isNavigationPropertyLoaded(\"Orders\");\n ```\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\n */\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty | string): boolean {\n // Both returns below used to hand back `undefined` - a bare `return`, and `this._loadedNps &&`\n // when nothing has been marked yet - while the overload signatures above promise `boolean`.\n // TypeScript does not check an implementation signature against its own overloads, so callers\n // were told `boolean` and could be given `undefined`.\n if (!this.entity) return false;\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\n if (navProperty.isScalar && this.entity.getProperty(navProperty.name) != null) {\n return true;\n }\n return !!this._loadedNps && this._loadedNps.indexOf(navProperty.name) >= 0;\n }\n\n /** @hidden @internal */\n _markAsLoaded(navPropName: string) {\n this._loadedNps = this._loadedNps || [];\n core.arrayAddItemUnique(this._loadedNps, navPropName);\n }\n\n\n /**\n Performs validation on the entity, any errors encountered during the validation are available via the\n {@link EntityAspect.getValidationErrors} method. Validating an entity means executing\n all of the validators on both the entity itself as well as those on each of its properties.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var isOk = order.entityAspect.validateEntity();\n // isOk will be 'true' if there are no errors on the entity.\n if (!isOk) {\n var errors = order.entityAspect.getValidationErrors();\n }\n ```\n @returns Whether the entity can be saved: every validator passes, and no error added with\n {@link EntityAspect.addValidationError} remains. Errors from the server are not counted - a save\n clears them before validating, and the server checks again. This is the check `saveChanges`\n makes, so the two always agree.\n */\n validateEntity() {\n let ok = true;\n this._processValidationOpAndPublish(function (that: any) {\n ok = validateTarget(that.entity);\n });\n // validateTarget re-runs the validators, so on its own it answers only for the errors\n // validators make. An error added with addValidationError is still an error, and the entity is\n // not valid while it stands - it used to be ignored here, and so saveChanges, which asks this,\n // sent the entity anyway. The server's errors are the exception: every save clears them before\n // validating, because the server checks again, and counting them here would make this answer\n // differ from the one a save gets.\n return ok && !this._hasBlockingErrors();\n }\n\n validateProperty(property: string, context?: any): boolean;\n validateProperty(property: DataProperty, context?: any): boolean;\n validateProperty(property: NavigationProperty, context?: any): boolean;\n /**\n Performs validation on a specific property of this entity, any errors encountered during the validation are available via the\n {@link EntityAspect.getValidationErrors} method. Validating a property means executing\n all of the validators on the specified property. This call is also made automatically anytime a property\n of an entity is changed.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var isOk = order.entityAspect.validateProperty(\"Order\");\n ```\n\n or\n ```ts\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\n var isOk = order.entityAspect.validateProperty(OrderDateProperty);\n ```\n @param property - The {@link DataProperty} or {@link NavigationProperty} to validate or a string \n with the name of the property or a property path with the path to a property of a complex object.\n @param context - A context object used to pass additional information to each {@link Validator}.\n @returns Whether the property can be saved: its validators pass, and no error added with\n {@link EntityAspect.addValidationError} about it remains. As with {@link EntityAspect.validateEntity},\n errors from the server are not counted.\n */\n validateProperty(property: EntityProperty | string, context: any) {\n let value = this.getPropertyValue(property); // performs validations\n // As validateEntity: an error added with addValidationError for this property counts too.\n const propertyName = typeof property === \"string\" ? property : property.name;\n if (value && value.complexAspect) {\n return validateTarget(value) && !this._hasBlockingErrors(propertyName);\n }\n context = context || {};\n context.entity = this.entity;\n if (typeof property === \"string\") {\n context.property = this.entity!.entityType.getProperty(property, true);\n context.propertyName = property;\n } else {\n context.property = property;\n context.propertyName = property.name;\n }\n\n return this._validateProperty(value, context) && !this._hasBlockingErrors(context.propertyName);\n }\n\n /**\n Validates the entity as {@link EntityAspect.validateEntity} does, and also runs its async\n validators - see {@link Validator.isAsync} - resolving when they have all answered. This is the\n check `saveChanges` makes when any of the entities it saves has an async validator.\n ```ts\n if (!await order.entityAspect.validateEntityAsync()) {\n const errors = order.entityAspect.getValidationErrors();\n }\n ```\n While it runs, {@link EntityAspect.isValidating} is true. If a property changes while one of its\n checks runs, the check is run again on the new value.\n @returns Whether the entity can be saved, as {@link EntityAspect.validateEntity} answers, once the\n async validators' answers are in.\n */\n async validateEntityAsync(): Promise<boolean> {\n this.validateEntity();\n await runAsyncChecks(this, collectAsyncChecks(this.entity));\n return !this._hasBlockingErrors();\n }\n\n /**\n Validates one property as {@link EntityAspect.validateProperty} does, and also runs its async\n validators, resolving when they have all answered.\n ```ts\n const isOk = await customer.entityAspect.validatePropertyAsync(\"companyName\");\n ```\n @param property - The property, by {@link DataProperty}, {@link NavigationProperty}, name, or path\n to a property of a complex object.\n @param context - Additional context for each {@link Validator}.\n @returns Whether the property can be saved, once the async validators' answers are in.\n */\n async validatePropertyAsync(property: EntityProperty | string, context?: any): Promise<boolean> {\n this.validateProperty(property as any, context && { ...context });\n await runAsyncChecks(this, collectAsyncPropertyChecks(this, property, context));\n return !this._hasBlockingErrors(typeof property === \"string\" ? property : property.name);\n }\n\n getValidationErrors(): ValidationError[];\n getValidationErrors(property: string): ValidationError[];\n getValidationErrors(property: EntityProperty): ValidationError[];\n /**\n Returns the validation errors associated with either the entire entity or any specified property.\n \n This method can return all of the errors for an Entity\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var valErrors = order.entityAspect.getValidationErrors();\n ```\n\n as well as those for just a specific property.\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var orderDateErrors = order.entityAspect.getValidationErrors(\"OrderDate\");\n ```\n\n which can also be expressed as\n ```ts\n // assume order is an order entity attached to an EntityManager.\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\n var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);\n ```\n @param property - The property for which validation errors should be retrieved.\n If omitted, all of the validation errors for this entity will be returned.\n @returns A array of validation errors.\n */\n getValidationErrors(property?: DataProperty | NavigationProperty | string) {\n assertParam(property, \"property\").isOptional().isEntityProperty().or().isString().check();\n let result = core.getOwnPropertyValues(this._validationErrors);\n if (property) {\n let propertyName = typeof (property) === 'string' ? property : property.name;\n // By propertyName as well as by the property object: an error added with only a\n // propertyName in its context - as the validation guide shows - has no property object, and\n // was missing from this list while validateProperty reported the property invalid because\n // of it. A form asking \"why is this field wrong?\" got an empty answer.\n result = result.filter(function (ve: ValidationError) {\n return (ve.property && ve.property.name === propertyName) || ve.propertyName === propertyName;\n });\n }\n return result;\n }\n\n /**\n The value a property had before the entity's pending changes: its original value if it has been\n edited since the entity was last saved or accepted, and its current value if not. So it answers\n \"what was this?\" without first asking whether it changed.\n ```ts\n order.freight = 99;\n order.entityAspect.getOriginalValue('freight'); // the freight before the edit\n order.entityAspect.getOriginalValue('shipCity'); // unchanged, so its current value\n ```\n Also takes a path into a complex property, such as `'location.city'`.\n @param propertyName - A data property of this entity, or a path to one in a complex property.\n */\n getOriginalValue(propertyName: string): any {\n let target: any = this.entity;\n let name = propertyName;\n const dot = name.lastIndexOf('.');\n if (dot >= 0) {\n target = this.getPropertyValue(name.slice(0, dot));\n name = name.slice(dot + 1);\n }\n const originals = (target.entityAspect || target.complexAspect).originalValues;\n return Object.prototype.hasOwnProperty.call(originals, name) ? originals[name] : target.getProperty(name);\n }\n\n /**\n The data properties whose value now differs from the one the entity was last saved or accepted\n with - as paths, such as `'location.city'`, for those of a complex property, and by name for an\n array property whose contents changed. A property edited and then set back is not included,\n although it stays in {@link EntityAspect.originalValues}. Dates are compared by time.\n ```ts\n order.freight = 99;\n order.shipCity = order.shipCity; // set, but to the same value\n order.entityAspect.getChangedProperties(); // ['freight']\n ```\n Always empty for an `Added` entity, which has no original values to differ from.\n */\n getChangedProperties(): string[] {\n return this.entity ? changedPropertyPaths(this.entity, this.originalValues, '') : [];\n }\n\n /**\n Adds a validation error.\n\n An error added here stops the entity being saved - `validateEntity` returns false and\n `saveChanges` rejects - until it is removed with {@link EntityAspect.removeValidationError} or\n {@link EntityAspect.clearValidationErrors}. Editing the property does not remove it: Breeze\n cannot re-check a rule it did not run. Give the error a key, and a failed save names it by that\n key in `errorName`.\n */\n addValidationError(validationError: ValidationError) {\n assertParam(validationError, \"validationError\").isInstanceOf(ValidationError).check();\n this._processValidationOpAndPublish(function (that: any) {\n that._addValidationError(validationError);\n });\n }\n\n removeValidationError(validationError: ValidationError): void;\n removeValidationError(validationKey: string): void;\n removeValidationError(validator: Validator): void;\n /**\n Removes a validation error.\n @param validationErrorOrKey - A ValidationError, a ValidationError 'key' value, or a Validator -\n in which case every error that validator produced on this entity is removed.\n */\n removeValidationError(validationErrorOrKey: ValidationError | string | Validator) {\n assertParam(validationErrorOrKey, \"validationErrorOrKey\").isString().or().isInstanceOf(ValidationError).or().isInstanceOf(Validator).check();\n\n let keys: string[];\n if (typeof (validationErrorOrKey) === \"string\") {\n keys = [validationErrorOrKey];\n } else if (validationErrorOrKey instanceof Validator) {\n // A Validator has no key of its own - reading one used to remove nothing, silently.\n const errors = this._validationErrors as Record<string, ValidationError>;\n keys = Object.keys(errors).filter(k => errors[k]?.validator === validationErrorOrKey);\n } else {\n keys = [validationErrorOrKey.key];\n }\n this._processValidationOpAndPublish(function (that: any) {\n keys.forEach(key => that._removeValidationError(key));\n });\n }\n\n /**\n Removes all of the validation errors for a specified entity\n */\n clearValidationErrors() {\n this._processValidationOpAndPublish(function (that: any) {\n core.objectForEach(that._validationErrors, function (key: string, valError: ValidationError) {\n if (valError) {\n delete that._validationErrors[key];\n that._pendingValidationResult.removed.push(valError);\n }\n });\n that.hasValidationErrors = !core.isEmpty(that._validationErrors);\n });\n }\n\n /**\n Returns an {@link EntityKey} for the entity pointed to by the specified scalar NavigationProperty.\n This only returns an EntityKey if the current entity is a 'child' entity along the specified NavigationProperty. \n i.e. has a single parent.\n\n @param navigationProperty - The {@link NavigationProperty} ( pointing to a parent). \n @returns Either a parent EntityKey if this is a 'child' entity or null; \n */\n getParentKey(navigationProperty: NavigationProperty) {\n if (!this.entity) return null;\n let fkNames = navigationProperty.foreignKeyNames;\n if (fkNames.length === 0) return null;\n let that = this;\n let fkValues = fkNames.map(function (fkn) {\n return that.entity!.getProperty(fkn);\n });\n return new EntityKey(navigationProperty.entityType, fkValues);\n }\n\n // TODO: refactor this and the static getPropertyPathValue.\n /**\n Returns the value of a specified DataProperty or NavigationProperty or 'property path'. \n */\n getPropertyValue(property: string | DataProperty | NavigationProperty) {\n assertParam(property, \"property\").isString().or().isEntityProperty().check();\n let value: any;\n if (typeof (property) === 'string') {\n let propNames = property.trim().split(\".\");\n let propName = propNames.shift();\n value = this.entity;\n value = value.getProperty(propName);\n while (propNames.length > 0) {\n propName = propNames.shift();\n value = value.getProperty(propName);\n }\n } else {\n if (!(property.parentType instanceof EntityType)) {\n throw new Error(\"The validateProperty method does not accept a 'property' parameter whose parentType is a ComplexType; \" +\n \"Pass a 'property path' string as the 'property' parameter instead \");\n }\n value = this.entity!.getProperty(property.name);\n }\n return value;\n }\n\n // internal methods\n /** @hidden @internal */\n _checkOperation(operationName: string) {\n if (this.isBeingSaved) {\n throw new Error(\"Cannot perform a '\" + operationName + \"' on an entity that is in the process of being saved\");\n }\n // allows chaining\n return this;\n }\n\n /** @hidden @internal */\n _detach() {\n this.entityGroup = undefined;\n this.entityManager = undefined;\n this.entityState = EntityState.Detached;\n this.originalValues = {};\n this._validationErrors = {};\n this.hasValidationErrors = false;\n this.validationErrorsChanged.clear();\n this.propertyChanged.clear();\n if (this._asyncChecks) {\n this._asyncChecks.forEach(run => run.controller.abort());\n this._asyncChecks = undefined;\n }\n }\n\n\n // called from defaultInterceptor.\n /** @hidden @internal */\n _validateProperty(value: any, context: any) {\n let ok = true;\n this._processValidationOpAndPublish(function (that: any) {\n context.property.getAllValidators().forEach(function (validator: Validator) {\n ok = validate(that, validator, value, context) && ok;\n });\n });\n return ok;\n }\n\n /** @hidden @internal */\n _processValidationOpAndPublish(validationFn: any) {\n if (this._pendingValidationResult) {\n // only top level processValidations call publishes\n validationFn(this);\n } else {\n try {\n this._pendingValidationResult = { entity: this.entity, added: [], removed: [] };\n validationFn(this);\n if (this._pendingValidationResult.added.length > 0 || this._pendingValidationResult.removed.length > 0) {\n this.validationErrorsChanged.publish(this._pendingValidationResult);\n // this might be a detached entity hence the guard below.\n this.entityManager && this.entityManager.validationErrorsChanged.publish(this._pendingValidationResult);\n\n }\n } finally {\n this._pendingValidationResult = undefined;\n }\n }\n }\n\n /** @hidden @internal */\n // Whether an error stands that should stop this entity being saved - every error except the\n // server's, which a save clears before validating. With a property name, only errors about that\n // property, or about a property inside it when it is a complex property.\n _hasBlockingErrors(propertyName?: string) {\n if (!this.hasValidationErrors) return false;\n const errors = this._validationErrors;\n for (const key in errors) {\n const ve = errors[key];\n if (!ve || ve.isServerError) continue;\n if (propertyName == null || isAbout(ve, propertyName)) return true;\n }\n return false;\n }\n\n /** @hidden @internal */\n // Drops the errors about a property that its edit has made stale: the server's, and those of\n // async validators, which cannot run again until the next save or validateEntityAsync. Both were\n // about a value the entity no longer has. Runs on every edit that is not part of a load, so the\n // entity with no errors - nearly all of them - pays one flag check.\n _clearStaleErrors(propertyName: string) {\n if (!this.hasValidationErrors) return;\n const keys: string[] = [];\n const errors = this._validationErrors;\n for (const key in errors) {\n const ve = errors[key];\n if (ve && (ve.isServerError || ve.validator?.isAsync) && isAbout(ve, propertyName)) keys.push(key);\n }\n if (keys.length === 0) return;\n this._processValidationOpAndPublish(function (that: EntityAspect) {\n keys.forEach(key => that._removeValidationError(key));\n });\n }\n\n /** @hidden @internal */\n _addValidationError(validationError: ValidationError) {\n this._validationErrors[validationError.key] = validationError;\n this.hasValidationErrors = true;\n this._pendingValidationResult.added.push(validationError);\n }\n\n /** @hidden @internal */\n _removeValidationError(key: string) {\n let valError = this._validationErrors[key];\n if (valError) {\n delete this._validationErrors[key];\n this.hasValidationErrors = !core.isEmpty(this._validationErrors);\n this._pendingValidationResult.removed.push(valError);\n }\n }\n\n}\n\nBreezeEvent.bubbleEvent(EntityAspect.prototype, function () {\n return this.entityManager;\n});\n\nfunction rejectChangesCore(target: any) {\n let aspect = target.entityAspect || target.complexAspect;\n let stype = target.entityType || target.complexType;\n let originalValues = aspect.originalValues;\n for (let propName in originalValues) {\n target.setProperty(propName, originalValues[propName]);\n }\n stype.complexProperties.forEach(function (cp: any) {\n let cos = target.getProperty(cp.name);\n if (cp.isScalar) {\n rejectChangesCore(cos);\n } else {\n observableArray.rejectChanges(cos);\n cos.forEach(rejectChangesCore);\n }\n });\n}\n\n/**\n * The value of a property as stored, without creating anything. A collection navigation is built\n * on first read, so code that only wants to look at *existing* related entities - attaching,\n * deleting - asks with this. Falls back to getProperty for a model library that cannot peek,\n * which just means the collection is created as it was before.\n * @hidden @internal\n */\nexport function peekProperty(entity: StructuralObject, propertyName: string): any {\n const modelLibrary = config.interfaceRegistry.modelLibrary.getDefaultInstance() as any;\n return modelLibrary.peekProperty\n ? modelLibrary.peekProperty(entity, propertyName)\n : (entity as any).getProperty(propertyName);\n}\n\nfunction removeFromRelations(entity: Entity, entityState: EntityState) {\n // remove this entity from any collections.\n // mark the entity deleted or detached\n\n let isDeleted = entityState.isDeleted();\n if (isDeleted) {\n removeFromRelationsCore(entity);\n } else {\n core.using(entity.entityAspect.entityManager!, \"isLoading\", true, function () {\n removeFromRelationsCore(entity);\n });\n }\n}\n\nfunction removeFromRelationsCore(entity: Entity) {\n entity.entityType.navigationProperties.forEach(function (np) {\n let inverseNp = np.inverse;\n // A collection that has never been read holds no related entities, and reading it here would\n // create an array only to empty it.\n let npValue = np.isScalar ? entity.getProperty(np.name) : peekProperty(entity, np.name);\n if (np.isScalar) {\n if (npValue) {\n if (inverseNp) {\n if (inverseNp.isScalar) {\n npValue.setProperty(inverseNp.name, null);\n } else {\n let collection = npValue.getProperty(inverseNp.name);\n if (collection.length) {\n core.arrayRemoveItem(collection, entity);\n }\n }\n }\n entity.setProperty(np.name, null);\n }\n } else {\n if (npValue == null) return;\n // Empty it in one go rather than letting each child splice itself out, which is O(n) per\n // child and one event per child. clearAll nulls each child's reference to this entity\n // first - so the child still gets its navigation property and foreign key cleared - then\n // truncates and publishes a single arrayChanged. A many-to-many inverse has nothing to\n // null on the other side, so it is emptied with no per-child step. (TODO: many to many.)\n const clearChild = inverseNp != null && inverseNp.isScalar\n ? (v: any) => v.setProperty(inverseNp!.name, null)\n : undefined;\n observableArray.clearAll(npValue, clearChild);\n }\n });\n\n}\n\n// note entityAspect only - ( no complex aspect allowed on the call).\n/** Whether a validation error concerns a property: that property, or one inside it by path. */\nfunction isAbout(ve: ValidationError, propertyName: string) {\n const name = ve.propertyName;\n return name === propertyName || (name != null && name.startsWith(propertyName + '.'));\n}\n\nfunction validate(entityAspect: EntityAspect, validator: Validator, value: any, context?: any) {\n // Nothing here can wait for an async validator's answer, so it is not asked; its last settled\n // answer stands. It runs from validateEntityAsync, and when the entity is saved.\n if (validator.isAsync) return true;\n let ve = validator.validate(value, context);\n if (ve) {\n entityAspect._addValidationError(ve);\n return false;\n } else {\n let key = ValidationError.getKey(validator, context ? context.propertyName : null);\n entityAspect._removeValidationError(key);\n return true;\n }\n}\n\n/** One async validator to run: the value to check, the context it gets, and how to read the value\nagain - to tell whether it changed while it was being checked. */\ninterface AsyncCheck {\n validator: Validator;\n value: any;\n context?: any;\n read: () => any;\n}\n\n/** @hidden @internal */\nexport interface AsyncCheckRun {\n controller: AbortController;\n done: Promise<void>;\n}\n\n/** How many times a check is run again because its value keeps changing while it is checked. */\nconst MAX_ASYNC_ROUNDS = 3;\n\n/** The async validators of an entity or complex object, walked as validateTarget walks the sync ones. */\nfunction collectAsyncChecks(target: any, coIndex?: number): AsyncCheck[] {\n const checks: AsyncCheck[] = [];\n const stype = target.entityType || target.complexType;\n const aspect = target.entityAspect || target.complexAspect;\n const entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\n\n stype.getProperties().forEach((p: any) => {\n const read = () => p.isNavigationProperty && !p.isScalar ? peekProperty(target, p.name) : target.getProperty(p.name);\n const value = read();\n const asyncValidators = p.getAllValidators().filter((v: Validator) => v.isAsync);\n if (asyncValidators.length > 0) {\n // A context of its own for each property: validateTarget reuses one, which an async check,\n // still reading it later, would see changed underneath it.\n const context: any = { entity: entityAspect.entity, property: p, propertyName: aspect.getPropertyPath(p.name) };\n if (coIndex !== undefined) context.index = coIndex;\n asyncValidators.forEach((validator: Validator) => checks.push({ validator, value, context, read }));\n }\n if (p.isComplexProperty) {\n if (p.isScalar) {\n checks.push(...collectAsyncChecks(value));\n } else {\n value.forEach((co: any, ix: number) => checks.push(...collectAsyncChecks(co, ix)));\n }\n }\n });\n\n stype.getAllValidators().filter((v: Validator) => v.isAsync).forEach((validator: Validator) => {\n checks.push({ validator, value: target, read: () => target });\n });\n return checks;\n}\n\n/** The async validators of one property, found as validateProperty finds the sync ones. */\nfunction collectAsyncPropertyChecks(aspect: EntityAspect, property: EntityProperty | string, context?: any): AsyncCheck[] {\n const read = () => aspect.getPropertyValue(property);\n const value = read();\n if (value && value.complexAspect) return collectAsyncChecks(value);\n const prop = typeof property === \"string\" ? aspect.entity!.entityType.getProperty(property, true)! : property; // throws if not found\n const propertyName = typeof property === \"string\" ? property : property.name;\n const checkContext = { ...context, entity: aspect.entity, property: prop, propertyName };\n return prop.getAllValidators().filter((v: Validator) => v.isAsync)\n .map((validator: Validator) => ({ validator, value, context: checkContext, read }));\n}\n\nfunction runAsyncChecks(aspect: EntityAspect, checks: AsyncCheck[]) {\n return Promise.all(checks.map(check => runAsyncCheck(aspect, check, 1)));\n}\n\n/**\nRuns one async check and applies its answer, unless the answer is no longer wanted: a newer run of\nthe same check has started - whose answer is then the one waited for - or the entity was detached.\nIf the value changed while it was checked, the check runs again on the new value.\n*/\nfunction runAsyncCheck(aspect: EntityAspect, check: AsyncCheck, round: number): Promise<void> {\n const key = ValidationError.getKey(check.validator, check.context && check.context.propertyName);\n const runs = aspect._asyncChecks || (aspect._asyncChecks = new Map());\n runs.get(key)?.controller.abort();\n const controller = new AbortController();\n const run = { controller } as AsyncCheckRun;\n runs.set(key, run);\n\n run.done = check.validator.validateAsync(check.value, { ...check.context, signal: controller.signal }).then(ve => {\n const current = aspect._asyncChecks?.get(key);\n if (current !== run) return current?.done; // replaced, or detached\n aspect._asyncChecks!.delete(key);\n const valueNow = check.read();\n if (valueNow !== check.value) {\n return round < MAX_ASYNC_ROUNDS ? runAsyncCheck(aspect, { ...check, value: valueNow }, round + 1) : undefined;\n }\n aspect._processValidationOpAndPublish((that: EntityAspect) => {\n if (ve) {\n that._addValidationError(ve);\n } else {\n that._removeValidationError(key);\n }\n });\n });\n return run.done;\n}\n\n/** The paths of target's data properties whose value differs from its original one. */\nfunction changedPropertyPaths(target: any, originalValues: Record<string, any>, prefix: string): string[] {\n const stype = target.entityType || target.complexType;\n const paths: string[] = [];\n stype.dataProperties.forEach((dp: DataProperty) => {\n const path = prefix + dp.name;\n if (dp.isComplexProperty) {\n const value = target.getProperty(dp.name);\n if (dp.isScalar) {\n if (value) paths.push(...changedPropertyPaths(value, value.complexAspect.originalValues, path + '.'));\n } else if (arrayContentsChanged(value) ||\n (value || []).some((co: any) => changedPropertyPaths(co, co.complexAspect.originalValues, '').length > 0)) {\n paths.push(path);\n }\n } else if (!dp.isScalar) {\n if (arrayContentsChanged(target.getProperty(dp.name))) paths.push(path);\n } else if (Object.prototype.hasOwnProperty.call(originalValues, dp.name)) {\n const comparable = DataType.getComparableFn(dp.dataType as DataType);\n if (comparable(originalValues[dp.name]) !== comparable(target.getProperty(dp.name))) paths.push(path);\n }\n });\n return paths;\n}\n\n/** Whether an array property's contents differ from those it had before its entity was changed. */\nfunction arrayContentsChanged(arr: any): boolean {\n const original = observableArray.originalContents(arr);\n if (!original) return false;\n return original.length !== arr.length || original.some((item: any, ix: number) => item !== arr[ix]);\n}\n\n// coIndex is only used where target is a complex object that is part of an array of complex objects\n// in which case ctIndex is the index of the target within the array.\nfunction validateTarget(target: any, coIndex?: number) {\n let ok = true;\n let stype = target.entityType || target.complexType;\n let aspect = target.entityAspect || target.complexAspect;\n let entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\n let context = <any>{ entity: entityAspect.entity };\n if (coIndex !== undefined) {\n context.index = coIndex;\n }\n\n stype.getProperties().forEach(function (p: any) {\n let value = p.isNavigationProperty && !p.isScalar\n ? peekProperty(target, p.name)\n : target.getProperty(p.name);\n let validators = p.getAllValidators();\n if (validators.length > 0) {\n context.property = p;\n context.propertyName = aspect.getPropertyPath(p.name);\n ok = entityAspect._validateProperty(value, context) && ok;\n }\n if (p.isComplexProperty) {\n if (p.isScalar) {\n ok = validateTarget(value) && ok;\n } else {\n ok = value.reduce(function (pv: any, cv: any, ix: number) {\n return validateTarget(cv, ix) && pv;\n }, ok);\n }\n }\n });\n\n\n // then target level\n stype.getAllValidators().forEach(function (validator: Validator) {\n ok = validate(entityAspect, validator, target) && ok;\n });\n return ok;\n}\n\n/**\nAn ComplexAspect instance is associated with every complex object instance and is accessed via the complex object's 'complexAspect' property.\n\nThe ComplexAspect itself provides properties to determine the parent object, parent property and original values for the complex object.\n\nA ComplexAspect will almost never need to be constructed directly. You will usually get an ComplexAspect by accessing\nan entities 'complexAspect' property. This property will be automatically attached when an complex object is created as part of an\nentity via either a query, import or EntityManager.createEntity call.\n```ts\n// assume address is a complex property on the 'Customer' type\nvar aspect = aCustomer.address.complexAspect;\n// aCustomer === aspect.parent;\n```\n*/\nexport class ComplexAspect {\n\n /** The complex object that this aspect is associated with. __Read Only__ */\n complexObject: ComplexObject;\n /** The 'original values' of this complex object where they are different from the 'current values'.\n This is a map where the key is a property name and the value is the 'original value' of the property.\n __Read Only__ */\n originalValues: Record<string, any>;\n /** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */\n parent?: StructuralObject;\n /** The {@link DataProperty} on the 'parent' that contains this complex object. __Read Only__ */\n parentProperty?: DataProperty;\n /** Unlike {@link EntityAspect.extraMetadata}, Breeze does not fill this in and does not export it.\n An application may use it to hold its own data about the complex object. */\n extraMetadata?: any;\n\n /** You will rarely, if ever, create a ComplexAspect directly. */\n constructor(complexObject: ComplexObject, parent: StructuralObject, parentProperty: DataProperty) {\n if (!complexObject) {\n throw new Error(\"The ComplexAspect ctor requires an entity as its only argument.\");\n }\n if (complexObject.complexAspect) {\n return complexObject.complexAspect;\n }\n // if called without new\n if (!(this instanceof ComplexAspect)) {\n return new ComplexAspect(complexObject, parent, parentProperty);\n }\n\n // entityType should already be on the entity from 'watch'\n this.complexObject = complexObject;\n complexObject.complexAspect = this;\n\n // TODO: keep public or not?\n this.originalValues = {};\n\n // if a standalone complexObject\n if (parent != null) {\n this.parent = parent;\n this.parentProperty = parentProperty;\n }\n\n let complexType = complexObject.complexType;\n if (!complexType) {\n let typeName = complexObject.prototype!._$typeName;\n if (!typeName) {\n throw new Error(\"This entity is not registered as a valid ComplexType\");\n } else {\n throw new Error(\"Metadata for this complexType has not yet been resolved: \" + typeName);\n }\n }\n let complexCtor = complexType.getCtor();\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(complexObject, complexCtor.prototype);\n\n }\n\n\n /**\n Returns the EntityAspect for the top level entity that contains this complex object.\n */\n getEntityAspect() {\n let parent = <any>this.parent;\n if (!parent) return new EntityAspect();\n let entityAspect = parent.entityAspect;\n while (parent && !entityAspect) {\n parent = parent.complexAspect && parent.complexAspect.parent;\n entityAspect = parent && parent.entityAspect;\n }\n return entityAspect || new EntityAspect();\n }\n\n /** @hidden @internal */\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\n getPropertyPath(propName: string) {\n let parent = <any>this.parent;\n if (!parent) return null;\n let aspect = parent.complexAspect || parent.entityAspect;\n return aspect.getPropertyPath(this.parentProperty!.name + \".\" + propName);\n }\n\n}\n\nfunction clearOriginalValues(target: any) {\n let aspect = target.entityAspect || target.complexAspect;\n aspect.originalValues = {};\n let stype = target.entityType || target.complexType;\n stype.complexProperties.forEach(function (cp: any) {\n let cos = target.getProperty(cp.name);\n if (cp.isScalar) {\n clearOriginalValues(cos);\n } else {\n observableArray.acceptChanges(cos);\n cos.forEach(clearOriginalValues);\n }\n });\n}\n\n\n\n/**\nAn {@link EntityAspect} that knows its entity's class, `T`: the type a generated entity class gives\nits `entityAspect`, as `EntityAspectOf<this>`. It is the same object; only the types are narrower -\nproperty names are checked, and values have their properties' types:\n```ts\norder.freight = 99;\norder.entityAspect.originalValues.freight; // number | undefined\norder.entityAspect.getOriginalValue('freight'); // number\norder.entityAspect.getOriginalValue('frieght'); // error: not a property of Order\norder.entityAspect.getChangedProperties(); // ('freight' | 'shipCity' | …)[]\n```\nAn interface extending the class, rather than a type parameter on it, so that it is an\n`EntityAspect` by declaration: a generic `EntityAspect<T>` whose members read `keyof T` would not be\none, and every generated class needs its aspect to be. And typed only by `T`'s own data properties:\nto reach through a navigation property, the types would have to ask whether the entity at the other\nend is an `Entity` - which asks about its aspect, and so about this one.\n*/\nexport interface EntityAspectOf<T> extends EntityAspect {\n /** {@link EntityAspect.originalValues}, keyed and typed by `T`'s data properties. */\n originalValues: OriginalValues<T>;\n /** {@link EntityAspect.getOriginalValue}, with the name checked against `T` and the value typed. */\n getOriginalValue<K extends DataKeys<T>>(propertyName: K): T[K];\n /** {@link EntityAspect.getOriginalValue} for a path into a complex property, such as `'location.city'`: untyped. */\n getOriginalValue(propertyPath: `${string}.${string}`): any;\n /** {@link EntityAspect.getChangedProperties}: `T`'s data properties, and paths into its complex ones. */\n getChangedProperties(): (DataKeys<T> | `${string}.${string}`)[];\n}\n\n/**\nA {@link ComplexAspect} that knows its complex object's class, `T`: the type a generated complex type\nclass gives its `complexAspect`, as `ComplexAspectOf<this>`. See {@link EntityAspectOf}.\n*/\nexport interface ComplexAspectOf<T> extends ComplexAspect {\n /** {@link ComplexAspect.originalValues}, keyed and typed by `T`'s data properties. */\n originalValues: OriginalValues<T>;\n}\n"]}
1
+ {"version":3,"file":"entity-aspect.js","sourceRoot":"","sources":["../../src/entity/entity-aspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAG,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAiE,MAAM,gCAAgC,CAAC;AAC3H,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAiFpD;;;;;;;;;;;;;;;EAeE;AACF,MAAM,OAAO,YAAY;IACvB,qEAAqE;IACrE,MAAM,CAAU;IAChB,yEAAyE;IACzE,aAAa,CAAiB;IAC9B,yBAAyB;IACzB,WAAW,CAAe;IAC1B,wBAAwB;IACxB,YAAY,CAAe;IAC3B,wFAAwF;IACxF,+FAA+F;IAC/F,+FAA+F;IAC/F,gGAAgG;IAChG,uFAAuF;IACvF,4DAA4D;IAC5D,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,IAAI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,YAAY,CAAC;QACzD,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,cAAe,CAAC,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAC;IAC5E,CAAC;CAEF;AAED,SAAS,mBAAmB,CAAC,MAAW;IACtC,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,aAAa,CAAC;IACzD,MAAM,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,CAAC;IACpD,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAO;QAC/C,IAAI,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;YAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACnC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { core } from '../core/core.js';\r\nimport { config } from '../config/config.js';\r\nimport { BreezeEvent } from '../core/event.js';\r\nimport { assertParam, paramError } from '../core/assert-param.js';\r\nimport { EntityState } from './entity-state.js';\r\nimport { EntityAction } from './entity-action.js';\r\nimport { EntityType, ComplexType, DataProperty, NavigationProperty, EntityProperty } from '../metadata/entity-metadata.js';\r\nimport { observableArray } from './observable-array.js';\r\nimport { EntityKey } from './entity-key.js';\r\nimport { EntityGroup } from './entity-group.js';\r\nimport { EntityManager, QueryResult, QueryErrorCallback, QuerySuccessCallback, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js';\r\nimport { Validator, ValidationError } from '../validation/validate.js';\r\nimport { EntityQuery } from '../query/entity-query.js';\r\nimport type { DataKeys, OriginalValues } from '../query/property-path.js';\r\nimport { DataType } from '../metadata/data-type.js';\r\n\r\n/** An instance of an {@link EntityType}: an object with a key, tracked by an {@link EntityManager}\r\nonce attached. Breeze gives every entity these members, whether its class declares them or not. */\r\nexport interface Entity {\r\n /** The {@link EntityAspect} that holds this entity's Breeze state: its {@link EntityState}, key,\r\n original values, validation errors and manager. */\r\n entityAspect: EntityAspect;\r\n /** The {@link EntityType} that describes this entity. */\r\n entityType: EntityType;\r\n /** Get the property with the given name */\r\n getProperty(prop: string): any;\r\n /** Set the property with the given name, exactly as assigning it would.\r\n\r\n With the backing-store model library it returns the object itself, so calls can be chained.\r\n The return type is `any` rather than `this` so that a class declaring `setProperty` as returning\r\n `void` still implements this interface.\r\n\r\n A name that is not a property of the type is not an error: like an assignment, it creates an\r\n ordinary property, which Breeze does not track. */\r\n setProperty(prop: any, value: any): any;\r\n /** @hidden @internal */\r\n prototype?: { _$typeName: string };\r\n /** @hidden @internal */\r\n _$entityType?: EntityType;\r\n}\r\n\r\n/** An instance of a {@link ComplexType}: a value with no key of its own, held in a complex property\r\nof an entity or of another complex object. */\r\nexport interface ComplexObject {\r\n /** The {@link ComplexAspect} that holds this object's parent, parent property and original values. */\r\n complexAspect: ComplexAspect;\r\n /** The {@link ComplexType} that describes this object. */\r\n complexType: ComplexType;\r\n /** Get the property with the given name */\r\n getProperty(prop: string): any;\r\n /** Set the property with the given name, exactly as assigning it would. Returns the object\r\n itself with the backing-store model library - see {@link Entity.setProperty}. */\r\n setProperty(prop: any, value: any): any;\r\n /** @hidden @internal */\r\n prototype?: { _$typeName: string };\r\n}\r\n\r\n/** An entity or a complex object - either kind of object Breeze tracks the properties of. Used where\r\neither is accepted, such as {@link ComplexAspect.parent}. */\r\nexport type StructuralObject = Entity | ComplexObject;\r\n\r\n/**\r\n * The type of the results of a query built from entities you already have, such as\r\n * {@link EntityQuery.fromEntities} or {@link RelationArray.load}: the entities' own class when it\r\n * is known - `QueriedAs<Customer>` is `Customer` - and `any` when all that is known is\r\n * {@link Entity}, so that `results[0].companyName` compiles without a cast.\r\n */\r\n// `any` rather than `Entity` for the plain case: that is what these results were before the type\r\n// parameters existed, and narrowing it would break every existing caller.\r\nexport type QueriedAs<U> = Entity extends U ? any : U;\r\n\r\n/** The argument to an entity's {@link EntityAspect.propertyChanged} event. It is also the `args` of\r\nan {@link EntityChangedEventArgs} for {@link EntityAction.PropertyChange}. */\r\nexport interface PropertyChangedEventArgs {\r\n /** The entity that changed. For a property of a complex object, the entity that holds it. */\r\n entity: Entity;\r\n /** The name of the property that changed. For a property of a complex object it is a path from\r\n the entity, such as `\"location.city\"`, with no index for an element of a complex array.\r\n\r\n `null` when any number of properties may have changed at once - when a query or save merges\r\n values into the entity, or its changes are rejected. The other members are then not set. */\r\n propertyName: string | null;\r\n /** The object whose property was set: the entity itself, or the complex object that owns the\r\n property. */\r\n parent?: StructuralObject;\r\n /** The {@link DataProperty} or {@link NavigationProperty} that changed. It belongs to the type of\r\n `parent`, which is not the entity's type when `parent` is a complex object. */\r\n property?: EntityProperty;\r\n /** The value before the change. */\r\n oldValue?: any;\r\n /** The value after the change, converted to the property's data type where Breeze can. */\r\n newValue?: any;\r\n}\r\n\r\n\r\n/**\r\nAn EntityAspect instance is associated with every attached entity and is accessed via the entity's 'entityAspect' property.\r\n\r\nThe EntityAspect itself provides properties to determine and modify the EntityState of the entity and has methods\r\nthat provide a variety of services including validation and change tracking.\r\n\r\nAn EntityAspect will almost never need to be constructed directly. You will usually get an EntityAspect by accessing\r\nan entities 'entityAspect' property. This property will be automatically attached when an entity is created via either\r\na query, import or {@link EntityManager.createEntity} call.\r\n```ts\r\n// assume order is an order entity attached to an EntityManager.\r\nvar aspect = order.entityAspect;\r\nvar currentState = aspect.entityState;\r\n```\r\n\r\n*/\r\nexport class EntityAspect {\r\n /** The Entity that this aspect is associated with. __Read Only__ */\r\n entity?: Entity;\r\n /** The {@link EntityManager} that contains this entity. __Read Only__ */\r\n entityManager?: EntityManager;\r\n /** @hidden @internal */\r\n entityGroup?: EntityGroup;\r\n /** @hidden @internal */\r\n _entityState!: EntityState;\r\n // An accessor rather than a plain field because the entity's group keeps the set of its\r\n // entities that are not Unchanged, and this is the one place every state change passes through\r\n // - setEntityState, _detach, the attach and merge paths, and anything an application or plugin\r\n // assigns. Working the set out by scanning instead is what made hasChanges cost the size of the\r\n // cache, once per state change. See \"Cache lookups that were scans\" in CHANGES-DEV.md.\r\n /** The {@link EntityState} of this entity. __Read Only__ */\r\n get entityState(): EntityState {\r\n return this._entityState;\r\n }\r\n set entityState(entityState: EntityState) {\r\n this._entityState = entityState;\r\n const group = this.entityGroup;\r\n if (group === undefined) return; // detached: nothing is tracking it\r\n if (entityState === EntityState.Unchanged || entityState === EntityState.Detached) {\r\n group._changedEntities.delete(this.entity!);\r\n } else {\r\n group._changedEntities.add(this.entity!);\r\n }\r\n }\r\n /** Whether this entity is in the process of being saved. __Read Only__ */\r\n isBeingSaved: boolean;\r\n /** The 'original values' of this entity where they are different from the 'current values'.\r\n This is a map where the key is a property name and the value is the 'original value' of the property. */\r\n originalValues: Record<string, any>;\r\n /** Whether this entity has any validation errors. __Read Only__ */\r\n hasValidationErrors: boolean;\r\n /** Whether this entity has a temporary {@link EntityKey}. */\r\n hasTempKey?: boolean;\r\n /** Whether this entity was created by being loaded from the database */\r\n wasLoaded?: boolean;\r\n /** Extra metadata about this entity such as the entity's etag.\r\n You may extend this object with your own metadata information.\r\n Breeze (de)serializes this object when importing/exporting the entity. */\r\n extraMetadata?: any;\r\n /**\r\n A {@link BreezeEvent} that fires whenever any of the validation errors on this entity change.\r\n Note that this might be the removal of an error when some data on the entity is fixed.\r\n @eventArgs - \r\n - entity - The entity on which the validation errors are being added or removed.\r\n - added - An array containing any newly added {@link ValidationError}s\r\n - removed - An array containing any newly removed {@link ValidationError}s. This is those\r\n errors that have been 'fixed'.\r\n\r\n```ts\r\n// assume order is an order entity attached to an EntityManager.\r\norder.entityAspect.validationErrorsChanged.subscribe(\r\nfunction (validationChangeArgs) {\r\n // this code will be executed anytime a property value changes on the 'order' entity.\r\n var entity == validationChangeArgs.entity; // Note: entity === order\r\n var errorsAdded = validationChangeArgs.added;\r\n var errorsCleared = validationChangeArgs.removed;\r\n});\r\n```\r\n @event\r\n */\r\n validationErrorsChanged: BreezeEvent<ValidationErrorsChangedEventArgs>;\r\n /**\r\n A {@link BreezeEvent} that fires whenever a value of one of this entity's properties change.\r\n @eventArgs -\r\n - entity - The entity whose property has changed.\r\n - property - The {@link DataProperty} that changed.\r\n - propertyName - The name of the property that changed. This value will be 'null' for operations that replace the entire entity. This includes\r\n queries, imports and saves that require a merge. The remaining parameters will not exist in this case either. This will actually be a \"property path\"\r\n for any properties of a complex type.\r\n - oldValue - The old value of this property before the change.\r\n - newValue - The new value of this property after the change.\r\n - parent - The immediate parent object for the changed property. This will be a ComplexType instance as opposed to an Entity \r\n for any complex type or nested complex type properties.\r\n\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.propertyChanged.subscribe(\r\n function (propertyChangedArgs) {\r\n // this code will be executed anytime a property value changes on the 'order' entity.\r\n var entity = propertyChangedArgs.entity; // Note: entity === order\r\n var propertyNameChanged = propertyChangedArgs.propertyName;\r\n var oldValue = propertyChangedArgs.oldValue;\r\n var newValue = propertyChangedArgs.newValue;\r\n });\r\n ```\r\n @event\r\n */\r\n propertyChanged: BreezeEvent<PropertyChangedEventArgs>;\r\n\r\n /** @hidden @internal */\r\n _validationErrors: { [index: string]: ValidationError };\r\n /** @hidden @internal */\r\n _pendingValidationResult: any;\r\n /**\r\n The async validator runs in flight, by the key of the error each would add or remove: one run\r\n per check, so that a newer run replaces an older one rather than racing it. Created on first use.\r\n @hidden @internal\r\n */\r\n declare _asyncChecks?: Map<string, AsyncCheckRun>;\r\n\r\n /** Whether an async validator is still running for this entity - see\r\n {@link EntityAspect.validateEntityAsync}. __Read Only__ */\r\n get isValidating(): boolean {\r\n return !!this._asyncChecks && this._asyncChecks.size > 0;\r\n }\r\n /** @hidden @internal */\r\n _entityKey: EntityKey;\r\n /** @hidden @internal */\r\n _loadedNps: any[];\r\n /** @hidden @internal */\r\n _initialized?: boolean;\r\n /** @hidden @internal */\r\n _inProcess: any[]; // used in defaultPropertyInterceptor for temp storage.\r\n /** @hidden @internal */\r\n _inProcessEntity?: Entity; // used in EntityManager\r\n /** @hidden @internal */\r\n constructor(entity?: Entity) {\r\n\r\n // if called without new\r\n // if (!(this instanceof EntityAspect)) {\r\n // return new EntityAspect(entity);\r\n // }\r\n\r\n this.entity = entity;\r\n // TODO: keep public or not?\r\n this.entityGroup = undefined;\r\n this.entityManager = undefined;\r\n this.entityState = EntityState.Detached;\r\n this.isBeingSaved = false;\r\n this.originalValues = {};\r\n this.hasValidationErrors = false;\r\n this._validationErrors = {};\r\n\r\n // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method\r\n // this._loadedNavPropMap = {};\r\n\r\n this.validationErrorsChanged = new BreezeEvent(\"validationErrorsChanged\", this);\r\n this.propertyChanged = new BreezeEvent(\"propertyChanged\", this);\r\n // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent.\r\n\r\n if (entity != null) {\r\n // remove properties that should be on prototype but placed on instance by Babel\r\n if (entity.hasOwnProperty('entityType')) {\r\n // throw new Error(\"Entity instance has entityType property; should only be on prototype\");\r\n delete (entity as any).entityType;\r\n }\r\n entity.entityAspect = this;\r\n\r\n // entityType should already be on the entity from 'watch'\r\n let entityType = entity.entityType || entity._$entityType;\r\n if (!entityType) {\r\n let typeName = entity.prototype!._$typeName;\r\n if (!typeName) {\r\n throw new Error(\"This entity is not registered as a valid EntityType\");\r\n } else {\r\n throw new Error(\"Metadata for this entityType has not yet been resolved: \" + typeName);\r\n }\r\n }\r\n let entityCtor = entityType.getCtor();\r\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(entity, entityCtor.prototype);\r\n }\r\n }\r\n\r\n /** @hidden */\r\n // type-guard\r\n static isEntity(obj: StructuralObject): obj is Entity {\r\n return (obj as any).entityAspect != null;\r\n }\r\n\r\n // TODO: refactor this and the instance getPropertyValue method.\r\n /**\r\n Returns the value of a specified 'property path' for a specified entity.\r\n\r\n The propertyPath can be either a string delimited with '.' or a string array. \r\n */\r\n // used by EntityQuery and Predicate\r\n static getPropertyPathValue(obj: Entity, propertyPath: string | string[]) {\r\n let properties = Array.isArray(propertyPath) ? propertyPath : propertyPath.split(\".\");\r\n if (properties.length === 1) {\r\n // properties[0], not propertyPath. Given a single-element array this used to pass the array\r\n // itself to getProperty, and reached the right property only because a property lookup\r\n // coerces ['freight'] to 'freight'. Correct by accident, and slower than the real thing.\r\n return obj.getProperty(properties[0]);\r\n } else {\r\n let nextValue = obj;\r\n // hack use of some to perform mapFirst operation.\r\n properties.some((prop) => {\r\n nextValue = nextValue.getProperty(prop);\r\n return nextValue == null;\r\n });\r\n return nextValue;\r\n }\r\n }\r\n\r\n /**\r\n Returns the {@link EntityKey} for this Entity.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var entityKey = order.entityAspect.getKey();\r\n ```\r\n @param forceRefresh - (boolean=false) Forces the recalculation of the key. This should normally be unnecessary.\r\n @returns The {@link EntityKey} associated with this Entity.\r\n */\r\n getKey(forceRefresh: boolean = false) {\r\n // Inline, not assertParam: getKey runs several times per entity created and again on\r\n // every attach, merge and foreign key lookup. Same wording.\r\n if (forceRefresh != null && typeof forceRefresh !== 'boolean') {\r\n throw paramError('forceRefresh', \"is optional or it must be a 'boolean'\");\r\n }\r\n if (forceRefresh || !this._entityKey) {\r\n let entityType = this.entity!.entityType;\r\n let keyProps = entityType.keyProperties;\r\n let values = keyProps.map(function (p) {\r\n return this.entity.getProperty(p.name);\r\n }, this);\r\n this._entityKey = new EntityKey(entityType, values);\r\n }\r\n return this._entityKey;\r\n }\r\n\r\n /**\r\n Returns the entity to an {@link EntityState} of 'Unchanged' by committing all changes made since the entity was last queried\r\n had 'acceptChanges' called on it.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.acceptChanges();\r\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\r\n ```\r\n */\r\n acceptChanges() {\r\n if (!this.entity) return;\r\n this._checkOperation(\"acceptChanges\");\r\n let em = this.entityManager!;\r\n if (this.entityState.isDeleted()) {\r\n em.detachEntity(this.entity);\r\n } else {\r\n this.setUnchanged();\r\n }\r\n em.entityChanged.publish({ entityAction: EntityAction.AcceptChanges, entity: this.entity });\r\n }\r\n\r\n /**\r\n Returns the entity to an {@link EntityState} of 'Unchanged' by rejecting all changes made to it since the entity was last queried\r\n had 'rejectChanges' called on it.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.rejectChanges();\r\n // The 'order' entity will now be in an 'Unchanged' state with any changes rejected.\r\n ```\r\n */\r\n rejectChanges() {\r\n this._checkOperation(\"rejectChanges\");\r\n let entity = this.entity!;\r\n let entityManager = this.entityManager!;\r\n // we do not want PropertyChange or EntityChange events to occur here\r\n core.using(entityManager, \"isRejectingChanges\", true, function () {\r\n rejectChangesCore(entity);\r\n });\r\n if (this.entityState.isAdded()) {\r\n // next line is needed because the following line will cause this.entityManager -> null;\r\n entityManager.detachEntity(entity);\r\n // need to tell em that an entity that needed to be saved no longer does.\r\n entityManager._notifyStateChange(entity, false);\r\n } else {\r\n if (this.entityState.isDeleted()) {\r\n entityManager._linkRelatedEntities(entity);\r\n }\r\n this.setUnchanged();\r\n // propertyChanged propertyName is not specified because more than one property may have changed.\r\n this.propertyChanged.publish({ entity: entity, propertyName: null });\r\n entityManager.entityChanged.publish({ entityAction: EntityAction.RejectChanges, entity: entity });\r\n }\r\n }\r\n\r\n /** @hidden @internal */\r\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\r\n getPropertyPath(propName: string) {\r\n return propName;\r\n }\r\n\r\n /**\r\n Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling {@link EntityManager.addEntity}\r\n because no key generation will occur for autogenerated keys as a result of this operation. As a result this operation can be problematic\r\n unless you are certain that the entity being marked 'Added' does not already exist in the database and does not have an autogenerated key.\r\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setAdded();\r\n // The 'order' entity will now be in an 'Added' state.\r\n ```\r\n */\r\n setAdded() {\r\n return this.setEntityState(EntityState.Added);\r\n }\r\n\r\n /**\r\n Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling {@link EntityAspect.acceptChanges}.\r\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setUnchanged();\r\n // The 'order' entity will now be in an 'Unchanged' state with any changes committed.\r\n ```\r\n */\r\n setUnchanged = function () {\r\n return this.setEntityState(EntityState.Unchanged);\r\n };\r\n\r\n\r\n /**\r\n Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity.\r\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setModified();\r\n // The 'order' entity will now be in a 'Modified' state.\r\n ```\r\n */\r\n setModified = function () {\r\n return this.setEntityState(EntityState.Modified);\r\n };\r\n\r\n /**\r\n Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call\r\n but also removes the entity from all of its related entities. If the current entityState is 'Added', then `setDeleted()` will mark it 'Detached'\r\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setDeleted();\r\n // The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.\r\n ```\r\n */\r\n setDeleted = function () {\r\n return this.setEntityState(EntityState.Deleted);\r\n };\r\n\r\n /**\r\n Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities.\r\n The same operation can be performed by calling {@link EntityAspect.setEntityState}.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setDetached();\r\n // The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.\r\n ```\r\n */\r\n setDetached = function () {\r\n return this.setEntityState(EntityState.Detached);\r\n };\r\n\r\n /**\r\n Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n order.entityAspect.setEntityState(EntityState.Unchanged);\r\n // The 'order' entity will now be in a 'Unchanged' state.\r\n ```\r\n */\r\n setEntityState(entityState: EntityState) {\r\n if (this.entityState === entityState) return false;\r\n this._checkOperation(\"setEntityState\");\r\n if (this.entityState.isDetached()) {\r\n throw new Error(\"You cannot set the 'entityState' of an entity when it is detached - except by first attaching it to an EntityManager\");\r\n }\r\n let entity = this.entity!;\r\n let em = this.entityManager!;\r\n let needsSave = true;\r\n if (entityState === EntityState.Unchanged) {\r\n clearOriginalValues(entity);\r\n this.hasTempKey = undefined; // not delete: every entity that becomes Unchanged runs this\r\n needsSave = false;\r\n } else if (entityState === EntityState.Added) {\r\n clearOriginalValues(entity);\r\n // TODO: more to do here... like regenerating key ???\r\n } else if (entityState === EntityState.Deleted) {\r\n if (this.entityState.isAdded()) {\r\n // turn it into a detach and exit early\r\n this.setEntityState(EntityState.Detached);\r\n return true;\r\n } else {\r\n // TODO: think about cascade deletes\r\n // entityState needs to be set it early in this one case to insure that fk's are not cleared.\r\n this.entityState = EntityState.Deleted;\r\n removeFromRelations(entity, EntityState.Deleted);\r\n }\r\n } else if (entityState === EntityState.Modified) {\r\n // nothing extra needed\r\n } else if (entityState === EntityState.Detached) {\r\n let group = this.entityGroup;\r\n // no group === already detached.\r\n if (!group) return false;\r\n group.detachEntity(entity);\r\n // An entity whose foreign keys named parents that are not in the cache is parked in the\r\n // unattached-children map, waiting for them. Detaching it has to take it back out, or the\r\n // manager holds it for good: clear() replaces the whole map, but detachEntity does not.\r\n em._unattachedChildrenMap.removeChild(entity);\r\n // needs to occur early here - so this IS deliberately redundent with the same code later in this method.\r\n this.entityState = entityState;\r\n removeFromRelations(entity, EntityState.Detached);\r\n this._detach();\r\n em.entityChanged.publish({ entityAction: EntityAction.Detach, entity: entity });\r\n needsSave = false;\r\n }\r\n this.entityState = entityState;\r\n em._notifyStateChange(entity, needsSave);\r\n return true;\r\n }\r\n\r\n loadNavigationProperty(navigationProperty: string): Promise<QueryResult>;\r\n loadNavigationProperty(navigationProperty: NavigationProperty): Promise<QueryResult>;\r\n /** @deprecated Await the returned promise instead of passing callbacks. */\r\n loadNavigationProperty(navigationProperty: string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\r\n /** @deprecated Await the returned promise instead of passing callbacks. */\r\n loadNavigationProperty(navigationProperty: NavigationProperty, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult>;\r\n /**\r\n Performs a query for the value of a specified {@link NavigationProperty}. __Async__\r\n ```ts\r\n emp.entityAspect.loadNavigationProperty(\"Orders\").then(function (data) {\r\n var orders = data.results;\r\n }).catch(function (exception) {\r\n // handle exception here;\r\n });\r\n ```\r\n @param navigationProperty - The NavigationProperty or the name of the NavigationProperty to 'load'.\r\n @param callback - Deprecated. Function to call on success.\r\n @param errorCallback - Deprecated. Function to call on failure.\r\n @returns Promise with shape\r\n - results {Array of Entity}\r\n - query {EntityQuery} The original query\r\n - httpResponse {httpResponse} The HttpResponse returned from the server.\r\n */\r\n loadNavigationProperty(navigationProperty: NavigationProperty | string, callback?: QuerySuccessCallback, errorCallback?: QueryErrorCallback): Promise<QueryResult> {\r\n let entity = this.entity!;\r\n let navProperty = entity.entityType._checkNavProperty(navigationProperty);\r\n let query = EntityQuery.fromEntityNavigation(entity, navProperty);\r\n // return entity.entityAspect.entityManager.executeQuery(query, callback, errorCallback);\r\n let promise = entity.entityAspect.entityManager!.executeQuery(query);\r\n\r\n return promise.then((data) => {\r\n this._markAsLoaded(navProperty.name);\r\n if (callback) callback(data);\r\n return Promise.resolve(data);\r\n }, (error) => {\r\n if (errorCallback) errorCallback(error);\r\n return Promise.reject(error);\r\n });\r\n\r\n }\r\n\r\n /**\r\n Marks this navigationProperty on this entity as already having been loaded.\r\n ```ts\r\n emp.entityAspect.markNavigationPropertyAsLoaded(\"Orders\");\r\n ```\r\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\r\n */\r\n markNavigationPropertyAsLoaded(navigationProperty: NavigationProperty | string) {\r\n if (!this.entity) return;\r\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\r\n this._markAsLoaded(navProperty.name);\r\n }\r\n\r\n isNavigationPropertyLoaded(navigationProperty: string): boolean;\r\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean;\r\n /**\r\n Determines whether a navigationProperty on this entity has already been loaded.\r\n\r\n A navigation property is considered loaded when any of the following three conditions applies:\r\n\r\n 1. It was fetched from the backend server.\r\n <br/> This can be the result of an expand query or a call to the {@link EntityAspect.loadNavigationProperty} method.\r\n <br/> Note that even if the fetch returns nothing the property is still marked as loaded in this case.\r\n 1. The property is scalar and has been set to a nonnull value.\r\n 1. The {@link EntityAspect.markNavigationPropertyAsLoaded} was called.\r\n \r\n ```ts\r\n var wasLoaded = emp.entityAspect.isNavigationPropertyLoaded(\"Orders\");\r\n ```\r\n @param navigationProperty - The NavigationProperty or name of NavigationProperty to 'load'.\r\n */\r\n isNavigationPropertyLoaded(navigationProperty: NavigationProperty | string): boolean {\r\n // Both returns below used to hand back `undefined` - a bare `return`, and `this._loadedNps &&`\r\n // when nothing has been marked yet - while the overload signatures above promise `boolean`.\r\n // TypeScript does not check an implementation signature against its own overloads, so callers\r\n // were told `boolean` and could be given `undefined`.\r\n if (!this.entity) return false;\r\n let navProperty = this.entity.entityType._checkNavProperty(navigationProperty);\r\n if (navProperty.isScalar && this.entity.getProperty(navProperty.name) != null) {\r\n return true;\r\n }\r\n return !!this._loadedNps && this._loadedNps.indexOf(navProperty.name) >= 0;\r\n }\r\n\r\n /** @hidden @internal */\r\n _markAsLoaded(navPropName: string) {\r\n this._loadedNps = this._loadedNps || [];\r\n core.arrayAddItemUnique(this._loadedNps, navPropName);\r\n }\r\n\r\n\r\n /**\r\n Performs validation on the entity, any errors encountered during the validation are available via the\r\n {@link EntityAspect.getValidationErrors} method. Validating an entity means executing\r\n all of the validators on both the entity itself as well as those on each of its properties.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var isOk = order.entityAspect.validateEntity();\r\n // isOk will be 'true' if there are no errors on the entity.\r\n if (!isOk) {\r\n var errors = order.entityAspect.getValidationErrors();\r\n }\r\n ```\r\n @returns Whether the entity can be saved: every validator passes, and no error added with\r\n {@link EntityAspect.addValidationError} remains. Errors from the server are not counted - a save\r\n clears them before validating, and the server checks again. This is the check `saveChanges`\r\n makes, so the two always agree.\r\n */\r\n validateEntity() {\r\n let ok = true;\r\n this._processValidationOpAndPublish(function (that: any) {\r\n ok = validateTarget(that.entity);\r\n });\r\n // validateTarget re-runs the validators, so on its own it answers only for the errors\r\n // validators make. An error added with addValidationError is still an error, and the entity is\r\n // not valid while it stands - it used to be ignored here, and so saveChanges, which asks this,\r\n // sent the entity anyway. The server's errors are the exception: every save clears them before\r\n // validating, because the server checks again, and counting them here would make this answer\r\n // differ from the one a save gets.\r\n return ok && !this._hasBlockingErrors();\r\n }\r\n\r\n validateProperty(property: string, context?: any): boolean;\r\n validateProperty(property: DataProperty, context?: any): boolean;\r\n validateProperty(property: NavigationProperty, context?: any): boolean;\r\n /**\r\n Performs validation on a specific property of this entity, any errors encountered during the validation are available via the\r\n {@link EntityAspect.getValidationErrors} method. Validating a property means executing\r\n all of the validators on the specified property. This call is also made automatically anytime a property\r\n of an entity is changed.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var isOk = order.entityAspect.validateProperty(\"Order\");\r\n ```\r\n\r\n or\r\n ```ts\r\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\r\n var isOk = order.entityAspect.validateProperty(OrderDateProperty);\r\n ```\r\n @param property - The {@link DataProperty} or {@link NavigationProperty} to validate or a string \r\n with the name of the property or a property path with the path to a property of a complex object.\r\n @param context - A context object used to pass additional information to each {@link Validator}.\r\n @returns Whether the property can be saved: its validators pass, and no error added with\r\n {@link EntityAspect.addValidationError} about it remains. As with {@link EntityAspect.validateEntity},\r\n errors from the server are not counted.\r\n */\r\n validateProperty(property: EntityProperty | string, context: any) {\r\n let value = this.getPropertyValue(property); // performs validations\r\n // As validateEntity: an error added with addValidationError for this property counts too.\r\n const propertyName = typeof property === \"string\" ? property : property.name;\r\n if (value && value.complexAspect) {\r\n return validateTarget(value) && !this._hasBlockingErrors(propertyName);\r\n }\r\n context = context || {};\r\n context.entity = this.entity;\r\n if (typeof property === \"string\") {\r\n context.property = this.entity!.entityType.getProperty(property, true);\r\n context.propertyName = property;\r\n } else {\r\n context.property = property;\r\n context.propertyName = property.name;\r\n }\r\n\r\n return this._validateProperty(value, context) && !this._hasBlockingErrors(context.propertyName);\r\n }\r\n\r\n /**\r\n Validates the entity as {@link EntityAspect.validateEntity} does, and also runs its async\r\n validators - see {@link Validator.isAsync} - resolving when they have all answered. This is the\r\n check `saveChanges` makes when any of the entities it saves has an async validator.\r\n ```ts\r\n if (!await order.entityAspect.validateEntityAsync()) {\r\n const errors = order.entityAspect.getValidationErrors();\r\n }\r\n ```\r\n While it runs, {@link EntityAspect.isValidating} is true. If a property changes while one of its\r\n checks runs, the check is run again on the new value.\r\n @returns Whether the entity can be saved, as {@link EntityAspect.validateEntity} answers, once the\r\n async validators' answers are in.\r\n */\r\n async validateEntityAsync(): Promise<boolean> {\r\n this.validateEntity();\r\n await runAsyncChecks(this, collectAsyncChecks(this.entity));\r\n return !this._hasBlockingErrors();\r\n }\r\n\r\n /**\r\n Validates one property as {@link EntityAspect.validateProperty} does, and also runs its async\r\n validators, resolving when they have all answered.\r\n ```ts\r\n const isOk = await customer.entityAspect.validatePropertyAsync(\"companyName\");\r\n ```\r\n @param property - The property, by {@link DataProperty}, {@link NavigationProperty}, name, or path\r\n to a property of a complex object.\r\n @param context - Additional context for each {@link Validator}.\r\n @returns Whether the property can be saved, once the async validators' answers are in.\r\n */\r\n async validatePropertyAsync(property: EntityProperty | string, context?: any): Promise<boolean> {\r\n this.validateProperty(property as any, context && { ...context });\r\n await runAsyncChecks(this, collectAsyncPropertyChecks(this, property, context));\r\n return !this._hasBlockingErrors(typeof property === \"string\" ? property : property.name);\r\n }\r\n\r\n getValidationErrors(): ValidationError[];\r\n getValidationErrors(property: string): ValidationError[];\r\n getValidationErrors(property: EntityProperty): ValidationError[];\r\n /**\r\n Returns the validation errors associated with either the entire entity or any specified property.\r\n \r\n This method can return all of the errors for an Entity\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var valErrors = order.entityAspect.getValidationErrors();\r\n ```\r\n\r\n as well as those for just a specific property.\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var orderDateErrors = order.entityAspect.getValidationErrors(\"OrderDate\");\r\n ```\r\n\r\n which can also be expressed as\r\n ```ts\r\n // assume order is an order entity attached to an EntityManager.\r\n var orderDateProperty = order.entityType.getProperty(\"OrderDate\");\r\n var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);\r\n ```\r\n @param property - The property for which validation errors should be retrieved.\r\n If omitted, all of the validation errors for this entity will be returned.\r\n @returns A array of validation errors.\r\n */\r\n getValidationErrors(property?: DataProperty | NavigationProperty | string) {\r\n assertParam(property, \"property\").isOptional().isEntityProperty().or().isString().check();\r\n let result = core.getOwnPropertyValues(this._validationErrors);\r\n if (property) {\r\n let propertyName = typeof (property) === 'string' ? property : property.name;\r\n // By propertyName as well as by the property object: an error added with only a\r\n // propertyName in its context - as the validation guide shows - has no property object, and\r\n // was missing from this list while validateProperty reported the property invalid because\r\n // of it. A form asking \"why is this field wrong?\" got an empty answer.\r\n result = result.filter(function (ve: ValidationError) {\r\n return (ve.property && ve.property.name === propertyName) || ve.propertyName === propertyName;\r\n });\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n The value a property had before the entity's pending changes: its original value if it has been\r\n edited since the entity was last saved or accepted, and its current value if not. So it answers\r\n \"what was this?\" without first asking whether it changed.\r\n ```ts\r\n order.freight = 99;\r\n order.entityAspect.getOriginalValue('freight'); // the freight before the edit\r\n order.entityAspect.getOriginalValue('shipCity'); // unchanged, so its current value\r\n ```\r\n Also takes a path into a complex property, such as `'location.city'`.\r\n @param propertyName - A data property of this entity, or a path to one in a complex property.\r\n */\r\n getOriginalValue(propertyName: string): any {\r\n let target: any = this.entity;\r\n let name = propertyName;\r\n const dot = name.lastIndexOf('.');\r\n if (dot >= 0) {\r\n target = this.getPropertyValue(name.slice(0, dot));\r\n name = name.slice(dot + 1);\r\n }\r\n const originals = (target.entityAspect || target.complexAspect).originalValues;\r\n return Object.prototype.hasOwnProperty.call(originals, name) ? originals[name] : target.getProperty(name);\r\n }\r\n\r\n /**\r\n The data properties whose value now differs from the one the entity was last saved or accepted\r\n with - as paths, such as `'location.city'`, for those of a complex property, and by name for an\r\n array property whose contents changed. A property edited and then set back is not included,\r\n although it stays in {@link EntityAspect.originalValues}. Dates are compared by time.\r\n ```ts\r\n order.freight = 99;\r\n order.shipCity = order.shipCity; // set, but to the same value\r\n order.entityAspect.getChangedProperties(); // ['freight']\r\n ```\r\n Always empty for an `Added` entity, which has no original values to differ from.\r\n */\r\n getChangedProperties(): string[] {\r\n return this.entity ? changedPropertyPaths(this.entity, this.originalValues, '') : [];\r\n }\r\n\r\n /**\r\n Adds a validation error.\r\n\r\n An error added here stops the entity being saved - `validateEntity` returns false and\r\n `saveChanges` rejects - until it is removed with {@link EntityAspect.removeValidationError} or\r\n {@link EntityAspect.clearValidationErrors}. Editing the property does not remove it: Breeze\r\n cannot re-check a rule it did not run. Give the error a key, and a failed save names it by that\r\n key in `errorName`.\r\n */\r\n addValidationError(validationError: ValidationError) {\r\n assertParam(validationError, \"validationError\").isInstanceOf(ValidationError).check();\r\n this._processValidationOpAndPublish(function (that: any) {\r\n that._addValidationError(validationError);\r\n });\r\n }\r\n\r\n removeValidationError(validationError: ValidationError): void;\r\n removeValidationError(validationKey: string): void;\r\n removeValidationError(validator: Validator): void;\r\n /**\r\n Removes a validation error.\r\n @param validationErrorOrKey - A ValidationError, a ValidationError 'key' value, or a Validator -\r\n in which case every error that validator produced on this entity is removed.\r\n */\r\n removeValidationError(validationErrorOrKey: ValidationError | string | Validator) {\r\n assertParam(validationErrorOrKey, \"validationErrorOrKey\").isString().or().isInstanceOf(ValidationError).or().isInstanceOf(Validator).check();\r\n\r\n let keys: string[];\r\n if (typeof (validationErrorOrKey) === \"string\") {\r\n keys = [validationErrorOrKey];\r\n } else if (validationErrorOrKey instanceof Validator) {\r\n // A Validator has no key of its own - reading one used to remove nothing, silently.\r\n const errors = this._validationErrors as Record<string, ValidationError>;\r\n keys = Object.keys(errors).filter(k => errors[k]?.validator === validationErrorOrKey);\r\n } else {\r\n keys = [validationErrorOrKey.key];\r\n }\r\n this._processValidationOpAndPublish(function (that: any) {\r\n keys.forEach(key => that._removeValidationError(key));\r\n });\r\n }\r\n\r\n /**\r\n Removes all of the validation errors for a specified entity\r\n */\r\n clearValidationErrors() {\r\n this._processValidationOpAndPublish(function (that: any) {\r\n core.objectForEach(that._validationErrors, function (key: string, valError: ValidationError) {\r\n if (valError) {\r\n delete that._validationErrors[key];\r\n that._pendingValidationResult.removed.push(valError);\r\n }\r\n });\r\n that.hasValidationErrors = !core.isEmpty(that._validationErrors);\r\n });\r\n }\r\n\r\n /**\r\n Returns an {@link EntityKey} for the entity pointed to by the specified scalar NavigationProperty.\r\n This only returns an EntityKey if the current entity is a 'child' entity along the specified NavigationProperty. \r\n i.e. has a single parent.\r\n\r\n @param navigationProperty - The {@link NavigationProperty} ( pointing to a parent). \r\n @returns Either a parent EntityKey if this is a 'child' entity or null; \r\n */\r\n getParentKey(navigationProperty: NavigationProperty) {\r\n if (!this.entity) return null;\r\n let fkNames = navigationProperty.foreignKeyNames;\r\n if (fkNames.length === 0) return null;\r\n let that = this;\r\n let fkValues = fkNames.map(function (fkn) {\r\n return that.entity!.getProperty(fkn);\r\n });\r\n return new EntityKey(navigationProperty.entityType, fkValues);\r\n }\r\n\r\n // TODO: refactor this and the static getPropertyPathValue.\r\n /**\r\n Returns the value of a specified DataProperty or NavigationProperty or 'property path'. \r\n */\r\n getPropertyValue(property: string | DataProperty | NavigationProperty) {\r\n assertParam(property, \"property\").isString().or().isEntityProperty().check();\r\n let value: any;\r\n if (typeof (property) === 'string') {\r\n let propNames = property.trim().split(\".\");\r\n let propName = propNames.shift();\r\n value = this.entity;\r\n value = value.getProperty(propName);\r\n while (propNames.length > 0) {\r\n propName = propNames.shift();\r\n value = value.getProperty(propName);\r\n }\r\n } else {\r\n if (!(property.parentType instanceof EntityType)) {\r\n throw new Error(\"The validateProperty method does not accept a 'property' parameter whose parentType is a ComplexType; \" +\r\n \"Pass a 'property path' string as the 'property' parameter instead \");\r\n }\r\n value = this.entity!.getProperty(property.name);\r\n }\r\n return value;\r\n }\r\n\r\n // internal methods\r\n /** @hidden @internal */\r\n _checkOperation(operationName: string) {\r\n if (this.isBeingSaved) {\r\n throw new Error(\"Cannot perform a '\" + operationName + \"' on an entity that is in the process of being saved\");\r\n }\r\n // allows chaining\r\n return this;\r\n }\r\n\r\n /** @hidden @internal */\r\n _detach() {\r\n this.entityGroup = undefined;\r\n this.entityManager = undefined;\r\n this.entityState = EntityState.Detached;\r\n this.originalValues = {};\r\n this._validationErrors = {};\r\n this.hasValidationErrors = false;\r\n this.validationErrorsChanged.clear();\r\n this.propertyChanged.clear();\r\n if (this._asyncChecks) {\r\n this._asyncChecks.forEach(run => run.controller.abort());\r\n this._asyncChecks = undefined;\r\n }\r\n }\r\n\r\n\r\n // called from defaultInterceptor.\r\n /** @hidden @internal */\r\n _validateProperty(value: any, context: any) {\r\n let ok = true;\r\n this._processValidationOpAndPublish(function (that: any) {\r\n context.property.getAllValidators().forEach(function (validator: Validator) {\r\n ok = validate(that, validator, value, context) && ok;\r\n });\r\n });\r\n return ok;\r\n }\r\n\r\n /** @hidden @internal */\r\n _processValidationOpAndPublish(validationFn: any) {\r\n if (this._pendingValidationResult) {\r\n // only top level processValidations call publishes\r\n validationFn(this);\r\n } else {\r\n try {\r\n this._pendingValidationResult = { entity: this.entity, added: [], removed: [] };\r\n validationFn(this);\r\n if (this._pendingValidationResult.added.length > 0 || this._pendingValidationResult.removed.length > 0) {\r\n this.validationErrorsChanged.publish(this._pendingValidationResult);\r\n // this might be a detached entity hence the guard below.\r\n this.entityManager && this.entityManager.validationErrorsChanged.publish(this._pendingValidationResult);\r\n\r\n }\r\n } finally {\r\n this._pendingValidationResult = undefined;\r\n }\r\n }\r\n }\r\n\r\n /** @hidden @internal */\r\n // Whether an error stands that should stop this entity being saved - every error except the\r\n // server's, which a save clears before validating. With a property name, only errors about that\r\n // property, or about a property inside it when it is a complex property.\r\n _hasBlockingErrors(propertyName?: string) {\r\n if (!this.hasValidationErrors) return false;\r\n const errors = this._validationErrors;\r\n for (const key in errors) {\r\n const ve = errors[key];\r\n if (!ve || ve.isServerError) continue;\r\n if (propertyName == null || isAbout(ve, propertyName)) return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @hidden @internal */\r\n // Drops the errors about a property that its edit has made stale: the server's, and those of\r\n // async validators, which cannot run again until the next save or validateEntityAsync. Both were\r\n // about a value the entity no longer has. Runs on every edit that is not part of a load, so the\r\n // entity with no errors - nearly all of them - pays one flag check.\r\n _clearStaleErrors(propertyName: string) {\r\n if (!this.hasValidationErrors) return;\r\n const keys: string[] = [];\r\n const errors = this._validationErrors;\r\n for (const key in errors) {\r\n const ve = errors[key];\r\n if (ve && (ve.isServerError || ve.validator?.isAsync) && isAbout(ve, propertyName)) keys.push(key);\r\n }\r\n if (keys.length === 0) return;\r\n this._processValidationOpAndPublish(function (that: EntityAspect) {\r\n keys.forEach(key => that._removeValidationError(key));\r\n });\r\n }\r\n\r\n /** @hidden @internal */\r\n _addValidationError(validationError: ValidationError) {\r\n this._validationErrors[validationError.key] = validationError;\r\n this.hasValidationErrors = true;\r\n this._pendingValidationResult.added.push(validationError);\r\n }\r\n\r\n /** @hidden @internal */\r\n _removeValidationError(key: string) {\r\n let valError = this._validationErrors[key];\r\n if (valError) {\r\n delete this._validationErrors[key];\r\n this.hasValidationErrors = !core.isEmpty(this._validationErrors);\r\n this._pendingValidationResult.removed.push(valError);\r\n }\r\n }\r\n\r\n}\r\n\r\nBreezeEvent.bubbleEvent(EntityAspect.prototype, function () {\r\n return this.entityManager;\r\n});\r\n\r\nfunction rejectChangesCore(target: any) {\r\n let aspect = target.entityAspect || target.complexAspect;\r\n let stype = target.entityType || target.complexType;\r\n let originalValues = aspect.originalValues;\r\n for (let propName in originalValues) {\r\n target.setProperty(propName, originalValues[propName]);\r\n }\r\n stype.complexProperties.forEach(function (cp: any) {\r\n let cos = target.getProperty(cp.name);\r\n if (cp.isScalar) {\r\n rejectChangesCore(cos);\r\n } else {\r\n observableArray.rejectChanges(cos);\r\n cos.forEach(rejectChangesCore);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * The value of a property as stored, without creating anything. A collection navigation is built\r\n * on first read, so code that only wants to look at *existing* related entities - attaching,\r\n * deleting - asks with this. Falls back to getProperty for a model library that cannot peek,\r\n * which just means the collection is created as it was before.\r\n * @hidden @internal\r\n */\r\nexport function peekProperty(entity: StructuralObject, propertyName: string): any {\r\n const modelLibrary = config.interfaceRegistry.modelLibrary.getDefaultInstance() as any;\r\n return modelLibrary.peekProperty\r\n ? modelLibrary.peekProperty(entity, propertyName)\r\n : (entity as any).getProperty(propertyName);\r\n}\r\n\r\nfunction removeFromRelations(entity: Entity, entityState: EntityState) {\r\n // remove this entity from any collections.\r\n // mark the entity deleted or detached\r\n\r\n let isDeleted = entityState.isDeleted();\r\n if (isDeleted) {\r\n removeFromRelationsCore(entity);\r\n } else {\r\n core.using(entity.entityAspect.entityManager!, \"isLoading\", true, function () {\r\n removeFromRelationsCore(entity);\r\n });\r\n }\r\n}\r\n\r\nfunction removeFromRelationsCore(entity: Entity) {\r\n entity.entityType.navigationProperties.forEach(function (np) {\r\n let inverseNp = np.inverse;\r\n // A collection that has never been read holds no related entities, and reading it here would\r\n // create an array only to empty it.\r\n let npValue = np.isScalar ? entity.getProperty(np.name) : peekProperty(entity, np.name);\r\n if (np.isScalar) {\r\n if (npValue) {\r\n if (inverseNp) {\r\n if (inverseNp.isScalar) {\r\n npValue.setProperty(inverseNp.name, null);\r\n } else {\r\n let collection = npValue.getProperty(inverseNp.name);\r\n if (collection.length) {\r\n core.arrayRemoveItem(collection, entity);\r\n }\r\n }\r\n }\r\n entity.setProperty(np.name, null);\r\n }\r\n } else {\r\n if (npValue == null) return;\r\n // Empty it in one go rather than letting each child splice itself out, which is O(n) per\r\n // child and one event per child. clearAll nulls each child's reference to this entity\r\n // first - so the child still gets its navigation property and foreign key cleared - then\r\n // truncates and publishes a single arrayChanged. A many-to-many inverse has nothing to\r\n // null on the other side, so it is emptied with no per-child step. (TODO: many to many.)\r\n const clearChild = inverseNp != null && inverseNp.isScalar\r\n ? (v: any) => v.setProperty(inverseNp!.name, null)\r\n : undefined;\r\n observableArray.clearAll(npValue, clearChild);\r\n }\r\n });\r\n\r\n}\r\n\r\n// note entityAspect only - ( no complex aspect allowed on the call).\r\n/** Whether a validation error concerns a property: that property, or one inside it by path. */\r\nfunction isAbout(ve: ValidationError, propertyName: string) {\r\n const name = ve.propertyName;\r\n return name === propertyName || (name != null && name.startsWith(propertyName + '.'));\r\n}\r\n\r\nfunction validate(entityAspect: EntityAspect, validator: Validator, value: any, context?: any) {\r\n // Nothing here can wait for an async validator's answer, so it is not asked; its last settled\r\n // answer stands. It runs from validateEntityAsync, and when the entity is saved.\r\n if (validator.isAsync) return true;\r\n let ve = validator.validate(value, context);\r\n if (ve) {\r\n entityAspect._addValidationError(ve);\r\n return false;\r\n } else {\r\n let key = ValidationError.getKey(validator, context ? context.propertyName : null);\r\n entityAspect._removeValidationError(key);\r\n return true;\r\n }\r\n}\r\n\r\n/** One async validator to run: the value to check, the context it gets, and how to read the value\r\nagain - to tell whether it changed while it was being checked. */\r\ninterface AsyncCheck {\r\n validator: Validator;\r\n value: any;\r\n context?: any;\r\n read: () => any;\r\n}\r\n\r\n/** @hidden @internal */\r\nexport interface AsyncCheckRun {\r\n controller: AbortController;\r\n done: Promise<void>;\r\n}\r\n\r\n/** How many times a check is run again because its value keeps changing while it is checked. */\r\nconst MAX_ASYNC_ROUNDS = 3;\r\n\r\n/** The async validators of an entity or complex object, walked as validateTarget walks the sync ones. */\r\nfunction collectAsyncChecks(target: any, coIndex?: number): AsyncCheck[] {\r\n const checks: AsyncCheck[] = [];\r\n const stype = target.entityType || target.complexType;\r\n const aspect = target.entityAspect || target.complexAspect;\r\n const entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\r\n\r\n stype.getProperties().forEach((p: any) => {\r\n const read = () => p.isNavigationProperty && !p.isScalar ? peekProperty(target, p.name) : target.getProperty(p.name);\r\n const value = read();\r\n const asyncValidators = p.getAllValidators().filter((v: Validator) => v.isAsync);\r\n if (asyncValidators.length > 0) {\r\n // A context of its own for each property: validateTarget reuses one, which an async check,\r\n // still reading it later, would see changed underneath it.\r\n const context: any = { entity: entityAspect.entity, property: p, propertyName: aspect.getPropertyPath(p.name) };\r\n if (coIndex !== undefined) context.index = coIndex;\r\n asyncValidators.forEach((validator: Validator) => checks.push({ validator, value, context, read }));\r\n }\r\n if (p.isComplexProperty) {\r\n if (p.isScalar) {\r\n checks.push(...collectAsyncChecks(value));\r\n } else {\r\n value.forEach((co: any, ix: number) => checks.push(...collectAsyncChecks(co, ix)));\r\n }\r\n }\r\n });\r\n\r\n stype.getAllValidators().filter((v: Validator) => v.isAsync).forEach((validator: Validator) => {\r\n checks.push({ validator, value: target, read: () => target });\r\n });\r\n return checks;\r\n}\r\n\r\n/** The async validators of one property, found as validateProperty finds the sync ones. */\r\nfunction collectAsyncPropertyChecks(aspect: EntityAspect, property: EntityProperty | string, context?: any): AsyncCheck[] {\r\n const read = () => aspect.getPropertyValue(property);\r\n const value = read();\r\n if (value && value.complexAspect) return collectAsyncChecks(value);\r\n const prop = typeof property === \"string\" ? aspect.entity!.entityType.getProperty(property, true)! : property; // throws if not found\r\n const propertyName = typeof property === \"string\" ? property : property.name;\r\n const checkContext = { ...context, entity: aspect.entity, property: prop, propertyName };\r\n return prop.getAllValidators().filter((v: Validator) => v.isAsync)\r\n .map((validator: Validator) => ({ validator, value, context: checkContext, read }));\r\n}\r\n\r\nfunction runAsyncChecks(aspect: EntityAspect, checks: AsyncCheck[]) {\r\n return Promise.all(checks.map(check => runAsyncCheck(aspect, check, 1)));\r\n}\r\n\r\n/**\r\nRuns one async check and applies its answer, unless the answer is no longer wanted: a newer run of\r\nthe same check has started - whose answer is then the one waited for - or the entity was detached.\r\nIf the value changed while it was checked, the check runs again on the new value.\r\n*/\r\nfunction runAsyncCheck(aspect: EntityAspect, check: AsyncCheck, round: number): Promise<void> {\r\n const key = ValidationError.getKey(check.validator, check.context && check.context.propertyName);\r\n const runs = aspect._asyncChecks || (aspect._asyncChecks = new Map());\r\n runs.get(key)?.controller.abort();\r\n const controller = new AbortController();\r\n const run = { controller } as AsyncCheckRun;\r\n runs.set(key, run);\r\n\r\n run.done = check.validator.validateAsync(check.value, { ...check.context, signal: controller.signal }).then(ve => {\r\n const current = aspect._asyncChecks?.get(key);\r\n if (current !== run) return current?.done; // replaced, or detached\r\n aspect._asyncChecks!.delete(key);\r\n const valueNow = check.read();\r\n if (valueNow !== check.value) {\r\n return round < MAX_ASYNC_ROUNDS ? runAsyncCheck(aspect, { ...check, value: valueNow }, round + 1) : undefined;\r\n }\r\n aspect._processValidationOpAndPublish((that: EntityAspect) => {\r\n if (ve) {\r\n that._addValidationError(ve);\r\n } else {\r\n that._removeValidationError(key);\r\n }\r\n });\r\n });\r\n return run.done;\r\n}\r\n\r\n/** The paths of target's data properties whose value differs from its original one. */\r\nfunction changedPropertyPaths(target: any, originalValues: Record<string, any>, prefix: string): string[] {\r\n const stype = target.entityType || target.complexType;\r\n const paths: string[] = [];\r\n stype.dataProperties.forEach((dp: DataProperty) => {\r\n const path = prefix + dp.name;\r\n if (dp.isComplexProperty) {\r\n const value = target.getProperty(dp.name);\r\n if (dp.isScalar) {\r\n if (value) paths.push(...changedPropertyPaths(value, value.complexAspect.originalValues, path + '.'));\r\n } else if (arrayContentsChanged(value) ||\r\n (value || []).some((co: any) => changedPropertyPaths(co, co.complexAspect.originalValues, '').length > 0)) {\r\n paths.push(path);\r\n }\r\n } else if (!dp.isScalar) {\r\n if (arrayContentsChanged(target.getProperty(dp.name))) paths.push(path);\r\n } else if (Object.prototype.hasOwnProperty.call(originalValues, dp.name)) {\r\n const comparable = DataType.getComparableFn(dp.dataType as DataType);\r\n if (comparable(originalValues[dp.name]) !== comparable(target.getProperty(dp.name))) paths.push(path);\r\n }\r\n });\r\n return paths;\r\n}\r\n\r\n/** Whether an array property's contents differ from those it had before its entity was changed. */\r\nfunction arrayContentsChanged(arr: any): boolean {\r\n const original = observableArray.originalContents(arr);\r\n if (!original) return false;\r\n return original.length !== arr.length || original.some((item: any, ix: number) => item !== arr[ix]);\r\n}\r\n\r\n// coIndex is only used where target is a complex object that is part of an array of complex objects\r\n// in which case ctIndex is the index of the target within the array.\r\nfunction validateTarget(target: any, coIndex?: number) {\r\n let ok = true;\r\n let stype = target.entityType || target.complexType;\r\n let aspect = target.entityAspect || target.complexAspect;\r\n let entityAspect = target.entityAspect || target.complexAspect.getEntityAspect();\r\n let context = <any>{ entity: entityAspect.entity };\r\n if (coIndex !== undefined) {\r\n context.index = coIndex;\r\n }\r\n\r\n stype.getProperties().forEach(function (p: any) {\r\n let value = p.isNavigationProperty && !p.isScalar\r\n ? peekProperty(target, p.name)\r\n : target.getProperty(p.name);\r\n let validators = p.getAllValidators();\r\n if (validators.length > 0) {\r\n context.property = p;\r\n context.propertyName = aspect.getPropertyPath(p.name);\r\n ok = entityAspect._validateProperty(value, context) && ok;\r\n }\r\n if (p.isComplexProperty) {\r\n if (p.isScalar) {\r\n ok = validateTarget(value) && ok;\r\n } else {\r\n ok = value.reduce(function (pv: any, cv: any, ix: number) {\r\n return validateTarget(cv, ix) && pv;\r\n }, ok);\r\n }\r\n }\r\n });\r\n\r\n\r\n // then target level\r\n stype.getAllValidators().forEach(function (validator: Validator) {\r\n ok = validate(entityAspect, validator, target) && ok;\r\n });\r\n return ok;\r\n}\r\n\r\n/**\r\nAn ComplexAspect instance is associated with every complex object instance and is accessed via the complex object's 'complexAspect' property.\r\n\r\nThe ComplexAspect itself provides properties to determine the parent object, parent property and original values for the complex object.\r\n\r\nA ComplexAspect will almost never need to be constructed directly. You will usually get an ComplexAspect by accessing\r\nan entities 'complexAspect' property. This property will be automatically attached when an complex object is created as part of an\r\nentity via either a query, import or EntityManager.createEntity call.\r\n```ts\r\n// assume address is a complex property on the 'Customer' type\r\nvar aspect = aCustomer.address.complexAspect;\r\n// aCustomer === aspect.parent;\r\n```\r\n*/\r\nexport class ComplexAspect {\r\n\r\n /** The complex object that this aspect is associated with. __Read Only__ */\r\n complexObject: ComplexObject;\r\n /** The 'original values' of this complex object where they are different from the 'current values'.\r\n This is a map where the key is a property name and the value is the 'original value' of the property.\r\n __Read Only__ */\r\n originalValues: Record<string, any>;\r\n /** The parent object that to which this aspect belongs; this will either be an entity or another complex object. __Read Only__ */\r\n parent?: StructuralObject;\r\n /** The {@link DataProperty} on the 'parent' that contains this complex object. __Read Only__ */\r\n parentProperty?: DataProperty;\r\n /** Unlike {@link EntityAspect.extraMetadata}, Breeze does not fill this in and does not export it.\r\n An application may use it to hold its own data about the complex object. */\r\n extraMetadata?: any;\r\n\r\n /** You will rarely, if ever, create a ComplexAspect directly. */\r\n constructor(complexObject: ComplexObject, parent: StructuralObject, parentProperty: DataProperty) {\r\n if (!complexObject) {\r\n throw new Error(\"The ComplexAspect ctor requires an entity as its only argument.\");\r\n }\r\n if (complexObject.complexAspect) {\r\n return complexObject.complexAspect;\r\n }\r\n // if called without new\r\n if (!(this instanceof ComplexAspect)) {\r\n return new ComplexAspect(complexObject, parent, parentProperty);\r\n }\r\n\r\n // entityType should already be on the entity from 'watch'\r\n this.complexObject = complexObject;\r\n complexObject.complexAspect = this;\r\n\r\n // TODO: keep public or not?\r\n this.originalValues = {};\r\n\r\n // if a standalone complexObject\r\n if (parent != null) {\r\n this.parent = parent;\r\n this.parentProperty = parentProperty;\r\n }\r\n\r\n let complexType = complexObject.complexType;\r\n if (!complexType) {\r\n let typeName = complexObject.prototype!._$typeName;\r\n if (!typeName) {\r\n throw new Error(\"This entity is not registered as a valid ComplexType\");\r\n } else {\r\n throw new Error(\"Metadata for this complexType has not yet been resolved: \" + typeName);\r\n }\r\n }\r\n let complexCtor = complexType.getCtor();\r\n config.interfaceRegistry.modelLibrary.getDefaultInstance().startTracking(complexObject, complexCtor.prototype);\r\n\r\n }\r\n\r\n\r\n /**\r\n Returns the EntityAspect for the top level entity that contains this complex object.\r\n */\r\n getEntityAspect() {\r\n let parent = <any>this.parent;\r\n if (!parent) return new EntityAspect();\r\n let entityAspect = parent.entityAspect;\r\n while (parent && !entityAspect) {\r\n parent = parent.complexAspect && parent.complexAspect.parent;\r\n entityAspect = parent && parent.entityAspect;\r\n }\r\n return entityAspect || new EntityAspect();\r\n }\r\n\r\n /** @hidden @internal */\r\n // TODO: rename - and use '_'; used on both EntityAspect and ComplexAspect for polymorphic reasons.\r\n getPropertyPath(propName: string) {\r\n let parent = <any>this.parent;\r\n if (!parent) return null;\r\n let aspect = parent.complexAspect || parent.entityAspect;\r\n return aspect.getPropertyPath(this.parentProperty!.name + \".\" + propName);\r\n }\r\n\r\n}\r\n\r\nfunction clearOriginalValues(target: any) {\r\n let aspect = target.entityAspect || target.complexAspect;\r\n aspect.originalValues = {};\r\n let stype = target.entityType || target.complexType;\r\n stype.complexProperties.forEach(function (cp: any) {\r\n let cos = target.getProperty(cp.name);\r\n if (cp.isScalar) {\r\n clearOriginalValues(cos);\r\n } else {\r\n observableArray.acceptChanges(cos);\r\n cos.forEach(clearOriginalValues);\r\n }\r\n });\r\n}\r\n\r\n\r\n\r\n/**\r\nAn {@link EntityAspect} that knows its entity's class, `T`: the type a generated entity class gives\r\nits `entityAspect`, as `EntityAspectOf<this>`. It is the same object; only the types are narrower -\r\nproperty names are checked, and values have their properties' types:\r\n```ts\r\norder.freight = 99;\r\norder.entityAspect.originalValues.freight; // number | undefined\r\norder.entityAspect.getOriginalValue('freight'); // number\r\norder.entityAspect.getOriginalValue('frieght'); // error: not a property of Order\r\norder.entityAspect.getChangedProperties(); // ('freight' | 'shipCity' | …)[]\r\n```\r\nAn interface extending the class, rather than a type parameter on it, so that it is an\r\n`EntityAspect` by declaration: a generic `EntityAspect<T>` whose members read `keyof T` would not be\r\none, and every generated class needs its aspect to be. And typed only by `T`'s own data properties:\r\nto reach through a navigation property, the types would have to ask whether the entity at the other\r\nend is an `Entity` - which asks about its aspect, and so about this one.\r\n*/\r\nexport interface EntityAspectOf<T> extends EntityAspect {\r\n /** {@link EntityAspect.originalValues}, keyed and typed by `T`'s data properties. */\r\n originalValues: OriginalValues<T>;\r\n /** {@link EntityAspect.getOriginalValue}, with the name checked against `T` and the value typed. */\r\n getOriginalValue<K extends DataKeys<T>>(propertyName: K): T[K];\r\n /** {@link EntityAspect.getOriginalValue} for a path into a complex property, such as `'location.city'`: untyped. */\r\n getOriginalValue(propertyPath: `${string}.${string}`): any;\r\n /** {@link EntityAspect.getChangedProperties}: `T`'s data properties, and paths into its complex ones. */\r\n getChangedProperties(): (DataKeys<T> | `${string}.${string}`)[];\r\n}\r\n\r\n/**\r\nA {@link ComplexAspect} that knows its complex object's class, `T`: the type a generated complex type\r\nclass gives its `complexAspect`, as `ComplexAspectOf<this>`. See {@link EntityAspectOf}.\r\n*/\r\nexport interface ComplexAspectOf<T> extends ComplexAspect {\r\n /** {@link ComplexAspect.originalValues}, keyed and typed by `T`'s data properties. */\r\n originalValues: OriginalValues<T>;\r\n}\r\n"]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AC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,mFAAmF;AACnF,SAAS,eAAe,CAAC,UAAsB,EAAE,MAA2B;IAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,+BAA+B,UAAU,CAAC,IAAI,cAAc,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACvB,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,cAAc,UAAU,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;QAChH,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { core } from '../core/core.js';\nimport { paramError } from '../core/assert-param.js';\nimport { EntityType, MetadataStore, entityTypeForCtor } from '../metadata/entity-metadata.js';\nimport type { Entity } from './entity-aspect.js';\nimport { DataType } from '../metadata/data-type.js';\n\n/**\nAn EntityKey is an object that represents the unique identity of an entity. EntityKey's are immutable.\n\n\n*/\nexport class EntityKey {\n /** @hidden @internal */\n declare _$typeName: string; // actually placed on prototype\n /** @hidden @internal */\n static ENTITY_KEY_DELIMITER = \":::\";\n /** The 'EntityType' that this is a key for. __Read Only__ */\n entityType: EntityType;\n /** An array of the values for this key. This will usually only have a single element, \n unless the entity type has a multipart key. __Read Only__ */\n values: any[];\n /** @hidden @internal */\n _keyInGroup: string;\n /** @hidden @internal */\n _subtypes: EntityType[];\n\n /**\n Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.\n ```ts\n // assume Employee is registered with the MetadataStore\n const entityKey = new EntityKey(Employee, 1);\n ```\n\n EntityKey's may also be found by calling EntityAspect.getKey()\n ```ts\n // assume employee1 is an existing Employee entity\n const empKey = employee1.entityAspect.getKey();\n ```\n\n A key of more than one property is clearest given by name, in any order:\n ```ts\n const detailKey = new EntityKey(OrderDetail, { orderID: 10248, productID: 11 });\n ```\n\n or as an array, in the order of the type's {@link EntityType.keyProperties}: the order of the\n key's definition on the server - `HasKey(od => new { od.OrderID, od.ProductID })` - which a\n generated entity class states in its doc comment, as `Key: orderID, productID`.\n ```ts\n const sameKey = new EntityKey(OrderDetail, [10248, 11]);\n ```\n A wrong order is not an error - it is a valid key for another row - which is why the named form\n is better for these.\n @param entityType - The {@link EntityType} of the entity, or a class registered for it with\n {@link MetadataStore.registerEntityTypeCtor}.\n @param keyValues - The key's value; for a key of more than one property, an object of values by\n property name, or an array in key order. A named value that is not part of the key, or a key\n property with no value, throws.\n */\n constructor(entityType: EntityType | (new () => Entity), keyValues: any) {\n // A class stands for its registered type. Checked by typeof first, so the EntityType that\n // Breeze itself always passes costs one comparison.\n if (typeof entityType === \"function\") entityType = entityTypeForCtor(entityType);\n // Inline, not assertParam: an EntityKey is built for every entity and again for every\n // foreign key the relationship fixup resolves. Same wording.\n if (!(entityType instanceof EntityType)) {\n throw paramError('entityType', \"must be an instance of 'EntityType'\");\n }\n // Only types that take part in an inheritance hierarchy need this, and getSelfAndSubtypes\n // allocates an array and walks the hierarchy to find that out. Guarding on `subtypes` keeps\n // the common case - a type with no subtypes, where the walk can only return [this] -\n // allocation-free. `subtypes` is filled while metadata is built and not touched after.\n if (entityType.subtypes.length > 0) {\n let subtypes = entityType.getSelfAndSubtypes();\n if (subtypes.length > 1) {\n this._subtypes = subtypes.filter(function (st) {\n return st.isAbstract === false;\n });\n }\n }\n\n if (!Array.isArray(keyValues)) {\n keyValues = isPlainObject(keyValues) ? keyValuesByName(entityType, keyValues) : [keyValues];\n }\n\n this.entityType = entityType;\n entityType.keyProperties.forEach(function (kp, i) {\n // insure that guid keys are comparable.\n if (kp.dataType === DataType.Guid) {\n keyValues[i] = keyValues[i] && keyValues[i].toLowerCase ? keyValues[i].toLowerCase() : keyValues[i];\n }\n });\n\n this.values = keyValues;\n this._keyInGroup = EntityKey.createKeyString(keyValues);\n\n }\n\n\n /** Returns the plain form of this key - `{ entityType, values }`, with the entity type's qualified\n name - which `JSON.stringify` uses and {@link EntityKey.fromJSON} turns back into a key. Breeze\n uses it to record temporary keys in an {@link EntityManager.exportEntities} bundle. */\n toJSON() {\n return {\n /** The qualified name of the key's entity type, such as `\"Customer:#Northwind.Models\"`. */\n entityType: this.entityType.name,\n /** The key's values, one per key property. */\n values: this.values\n };\n }\n\n /** Recreates a key from the output of {@link EntityKey.toJSON}, looking its entity type up in\n `metadataStore`. Throws if the type is not there. Used by {@link EntityManager.importEntities}. */\n static fromJSON(json: any, metadataStore: MetadataStore) {\n let et = metadataStore._getStructuralType(json.entityType, true) as EntityType;\n return new EntityKey(et, json.values);\n }\n\n /**\n Used to compare EntityKeys are determine if they refer to the same Entity.\n There is also an static version of 'equals' with the same functionality.\n\n ```ts\n // assume Employee is registered with the MetadataStore\n const empKey1 = new EntityKey(Employee, 1);\n // assume employee1 is an existing Employee entity\n const empKey2 = employee1.entityAspect.getKey();\n if (empKey1.equals(empKey2)) {\n // do something ...\n }\n ```\n */\n equals(entityKey: EntityKey): boolean {\n if (!(entityKey instanceof EntityKey)) return false;\n return (this.entityType === entityKey.entityType) &&\n core.arrayEquals(this.values, entityKey.values);\n }\n\n /** Returns this key as a string: the entity type's qualified name, a hyphen, and the key values\n joined by `:::` - such as `\"Order:#Northwind.Models-10248\"`. Given `altEntityType`, that type's\n name is used instead. Breeze uses this form in error messages and as the property names of an\n {@link ITempKeyMap}. */\n /*\n Returns a human readable representation of this EntityKey.\n */\n toString(altEntityType?: EntityType) {\n return (altEntityType || this.entityType).name + '-' + this._keyInGroup;\n }\n\n /**\n Used to compare EntityKeys are determine if they refer to the same Entity.\n There is also an instance version of 'equals' with the same functionality.\n ```ts\n // assume Employee is registered with the MetadataStore\n const empKey1 = new EntityKey(Employee, 1);\n // assume employee1 is an existing Employee entity\n const empKey2 = employee1.entityAspect.getKey();\n if (EntityKey.equals(empKey1, empKey2)) {\n // do something ...\n }\n ```\n */\n static equals(k1: EntityKey, k2: EntityKey) {\n if (!(k1 instanceof EntityKey)) return false;\n return k1.equals(k2);\n }\n\n /** @hidden @internal */\n // TODO: we may want to compare to default values later.\n _isEmpty() {\n return this.values.join(\"\").length === 0;\n }\n\n /** hidden */\n // TODO: think about giving _ prefix or documenting.\n static createKeyString(keyValues: any[]) {\n return keyValues.join(EntityKey.ENTITY_KEY_DELIMITER);\n }\n\n}\nEntityKey.prototype._$typeName = \"EntityKey\";\n\n/** An object literal - not an array, a Date, or any other object a single key value could be. */\nfunction isPlainObject(value: any): value is Record<string, any> {\n if (value === null || typeof value !== 'object') return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/** The key values given by name, put in the order of the type's key properties. */\nfunction keyValuesByName(entityType: EntityType, values: Record<string, any>) {\n const keyProps = entityType.keyProperties;\n const names = keyProps.map(kp => kp.name);\n for (const name of Object.keys(values)) {\n if (!names.includes(name)) {\n throw new Error(`'${name}' is not part of the key of ${entityType.name}, which is ${names.join(', ')}.`);\n }\n }\n return keyProps.map(kp => {\n if (!(kp.name in values)) {\n throw new Error(`The key of ${entityType.name} is ${names.join(', ')}; no value was given for '${kp.name}'.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,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,mFAAmF;AACnF,SAAS,eAAe,CAAC,UAAsB,EAAE,MAA2B;IAC1E,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,+BAA+B,UAAU,CAAC,IAAI,cAAc,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3G,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACvB,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,cAAc,UAAU,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;QAChH,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { core } from '../core/core.js';\r\nimport { paramError } from '../core/assert-param.js';\r\nimport { EntityType, MetadataStore, entityTypeForCtor } from '../metadata/entity-metadata.js';\r\nimport type { Entity } from './entity-aspect.js';\r\nimport { DataType } from '../metadata/data-type.js';\r\n\r\n/**\r\nAn EntityKey is an object that represents the unique identity of an entity. EntityKey's are immutable.\r\n\r\n\r\n*/\r\nexport class EntityKey {\r\n /** @hidden @internal */\r\n declare _$typeName: string; // actually placed on prototype\r\n /** @hidden @internal */\r\n static ENTITY_KEY_DELIMITER = \":::\";\r\n /** The 'EntityType' that this is a key for. __Read Only__ */\r\n entityType: EntityType;\r\n /** An array of the values for this key. This will usually only have a single element, \r\n unless the entity type has a multipart key. __Read Only__ */\r\n values: any[];\r\n /** @hidden @internal */\r\n _keyInGroup: string;\r\n /** @hidden @internal */\r\n _subtypes: EntityType[];\r\n\r\n /**\r\n Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.\r\n ```ts\r\n // assume Employee is registered with the MetadataStore\r\n const entityKey = new EntityKey(Employee, 1);\r\n ```\r\n\r\n EntityKey's may also be found by calling EntityAspect.getKey()\r\n ```ts\r\n // assume employee1 is an existing Employee entity\r\n const empKey = employee1.entityAspect.getKey();\r\n ```\r\n\r\n A key of more than one property is clearest given by name, in any order:\r\n ```ts\r\n const detailKey = new EntityKey(OrderDetail, { orderID: 10248, productID: 11 });\r\n ```\r\n\r\n or as an array, in the order of the type's {@link EntityType.keyProperties}: the order of the\r\n key's definition on the server - `HasKey(od => new { od.OrderID, od.ProductID })` - which a\r\n generated entity class states in its doc comment, as `Key: orderID, productID`.\r\n ```ts\r\n const sameKey = new EntityKey(OrderDetail, [10248, 11]);\r\n ```\r\n A wrong order is not an error - it is a valid key for another row - which is why the named form\r\n is better for these.\r\n @param entityType - The {@link EntityType} of the entity, or a class registered for it with\r\n {@link MetadataStore.registerEntityTypeCtor}.\r\n @param keyValues - The key's value; for a key of more than one property, an object of values by\r\n property name, or an array in key order. A named value that is not part of the key, or a key\r\n property with no value, throws.\r\n */\r\n constructor(entityType: EntityType | (new () => Entity), keyValues: any) {\r\n // A class stands for its registered type. Checked by typeof first, so the EntityType that\r\n // Breeze itself always passes costs one comparison.\r\n if (typeof entityType === \"function\") entityType = entityTypeForCtor(entityType);\r\n // Inline, not assertParam: an EntityKey is built for every entity and again for every\r\n // foreign key the relationship fixup resolves. Same wording.\r\n if (!(entityType instanceof EntityType)) {\r\n throw paramError('entityType', \"must be an instance of 'EntityType'\");\r\n }\r\n // Only types that take part in an inheritance hierarchy need this, and getSelfAndSubtypes\r\n // allocates an array and walks the hierarchy to find that out. Guarding on `subtypes` keeps\r\n // the common case - a type with no subtypes, where the walk can only return [this] -\r\n // allocation-free. `subtypes` is filled while metadata is built and not touched after.\r\n if (entityType.subtypes.length > 0) {\r\n let subtypes = entityType.getSelfAndSubtypes();\r\n if (subtypes.length > 1) {\r\n this._subtypes = subtypes.filter(function (st) {\r\n return st.isAbstract === false;\r\n });\r\n }\r\n }\r\n\r\n if (!Array.isArray(keyValues)) {\r\n keyValues = isPlainObject(keyValues) ? keyValuesByName(entityType, keyValues) : [keyValues];\r\n }\r\n\r\n this.entityType = entityType;\r\n entityType.keyProperties.forEach(function (kp, i) {\r\n // insure that guid keys are comparable.\r\n if (kp.dataType === DataType.Guid) {\r\n keyValues[i] = keyValues[i] && keyValues[i].toLowerCase ? keyValues[i].toLowerCase() : keyValues[i];\r\n }\r\n });\r\n\r\n this.values = keyValues;\r\n this._keyInGroup = EntityKey.createKeyString(keyValues);\r\n\r\n }\r\n\r\n\r\n /** Returns the plain form of this key - `{ entityType, values }`, with the entity type's qualified\r\n name - which `JSON.stringify` uses and {@link EntityKey.fromJSON} turns back into a key. Breeze\r\n uses it to record temporary keys in an {@link EntityManager.exportEntities} bundle. */\r\n toJSON() {\r\n return {\r\n /** The qualified name of the key's entity type, such as `\"Customer:#Northwind.Models\"`. */\r\n entityType: this.entityType.name,\r\n /** The key's values, one per key property. */\r\n values: this.values\r\n };\r\n }\r\n\r\n /** Recreates a key from the output of {@link EntityKey.toJSON}, looking its entity type up in\r\n `metadataStore`. Throws if the type is not there. Used by {@link EntityManager.importEntities}. */\r\n static fromJSON(json: any, metadataStore: MetadataStore) {\r\n let et = metadataStore._getStructuralType(json.entityType, true) as EntityType;\r\n return new EntityKey(et, json.values);\r\n }\r\n\r\n /**\r\n Used to compare EntityKeys are determine if they refer to the same Entity.\r\n There is also an static version of 'equals' with the same functionality.\r\n\r\n ```ts\r\n // assume Employee is registered with the MetadataStore\r\n const empKey1 = new EntityKey(Employee, 1);\r\n // assume employee1 is an existing Employee entity\r\n const empKey2 = employee1.entityAspect.getKey();\r\n if (empKey1.equals(empKey2)) {\r\n // do something ...\r\n }\r\n ```\r\n */\r\n equals(entityKey: EntityKey): boolean {\r\n if (!(entityKey instanceof EntityKey)) return false;\r\n return (this.entityType === entityKey.entityType) &&\r\n core.arrayEquals(this.values, entityKey.values);\r\n }\r\n\r\n /** Returns this key as a string: the entity type's qualified name, a hyphen, and the key values\r\n joined by `:::` - such as `\"Order:#Northwind.Models-10248\"`. Given `altEntityType`, that type's\r\n name is used instead. Breeze uses this form in error messages and as the property names of an\r\n {@link ITempKeyMap}. */\r\n /*\r\n Returns a human readable representation of this EntityKey.\r\n */\r\n toString(altEntityType?: EntityType) {\r\n return (altEntityType || this.entityType).name + '-' + this._keyInGroup;\r\n }\r\n\r\n /**\r\n Used to compare EntityKeys are determine if they refer to the same Entity.\r\n There is also an instance version of 'equals' with the same functionality.\r\n ```ts\r\n // assume Employee is registered with the MetadataStore\r\n const empKey1 = new EntityKey(Employee, 1);\r\n // assume employee1 is an existing Employee entity\r\n const empKey2 = employee1.entityAspect.getKey();\r\n if (EntityKey.equals(empKey1, empKey2)) {\r\n // do something ...\r\n }\r\n ```\r\n */\r\n static equals(k1: EntityKey, k2: EntityKey) {\r\n if (!(k1 instanceof EntityKey)) return false;\r\n return k1.equals(k2);\r\n }\r\n\r\n /** @hidden @internal */\r\n // TODO: we may want to compare to default values later.\r\n _isEmpty() {\r\n return this.values.join(\"\").length === 0;\r\n }\r\n\r\n /** hidden */\r\n // TODO: think about giving _ prefix or documenting.\r\n static createKeyString(keyValues: any[]) {\r\n return keyValues.join(EntityKey.ENTITY_KEY_DELIMITER);\r\n }\r\n\r\n}\r\nEntityKey.prototype._$typeName = \"EntityKey\";\r\n\r\n/** An object literal - not an array, a Date, or any other object a single key value could be. */\r\nfunction isPlainObject(value: any): value is Record<string, any> {\r\n if (value === null || typeof value !== 'object') return false;\r\n const proto = Object.getPrototypeOf(value);\r\n return proto === Object.prototype || proto === null;\r\n}\r\n\r\n/** The key values given by name, put in the order of the type's key properties. */\r\nfunction keyValuesByName(entityType: EntityType, values: Record<string, any>) {\r\n const keyProps = entityType.keyProperties;\r\n const names = keyProps.map(kp => kp.name);\r\n for (const name of Object.keys(values)) {\r\n if (!names.includes(name)) {\r\n throw new Error(`'${name}' is not part of the key of ${entityType.name}, which is ${names.join(', ')}.`);\r\n }\r\n }\r\n return keyProps.map(kp => {\r\n if (!(kp.name in values)) {\r\n throw new Error(`The key of ${entityType.name} is ${names.join(', ')}; no value was given for '${kp.name}'.`);\r\n }\r\n return values[kp.name];\r\n });\r\n}\r\n\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"primitive-array.js","sourceRoot":"","sources":["../../src/entity/primitive-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAuC,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS7F;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;EAgBE;AAEF,MAAM,iBAAiB,GAAuB;IAE5C,wFAAwF;IACxF,WAAW,EAAE,UAAU,GAAmB,EAAE,IAAW;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,EAAE,UAAU,GAAmB;QACzC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,EAAE,UAAU,GAAmB,EAAE,IAAW;QACrD,iBAAiB;IACnB,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB,EAAE,OAAc;QAC3D,iBAAiB;IACnB,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB;QAC3C,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB;QAC3C,MAAM,EAAE,GAAG,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;QAC9D,OAAO,EAAE,IAAK,EAAU,CAAC,YAAY,CAAC;IACxC,CAAC;IAED,aAAa,EAAE,UAAU,GAAmB;QAC1C,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,EAAE,UAAU,GAAmB;QAC1C,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF;;;EAGE;AACF,MAAM,UAAU,kBAAkB,CAAC,GAAU,EAAE,MAAwB,EAAE,cAA4B;IACnG,MAAM,IAAI,GAAG,GAAU,CAAC;IACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACrC,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAC1D,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACpD,OAAO,IAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { BreezeEvent } from '../core/event.js';\nimport { ObservableArray, ObservableArrayOps, observableArray } from './observable-array.js';\nimport type { StructuralObject } from './entity-aspect.js';\nimport type { DataProperty } from '../metadata/entity-metadata.js';\n\nexport interface PrimitiveArray extends ObservableArray<any> {\n parent?: StructuralObject;\n parentProperty?: DataProperty;\n}\n\n/*\n Primitive arrays are not a class: they are real arrays whose mutating methods are replaced, so\n that changing one updates the entity that owns it. A primitive array is a collection of primitive\n values associated with a data property on a single entity or complex object, i.e.\n customer.invoiceNumbers.\n @class {primitiveArray}\n */\n\n/*\nAn {@link BreezeEvent} that fires whenever the contents of this array changed. This event\nis fired any time a new entity is attached or added to the EntityManager and happens to belong to this collection.\nAdds that occur as a result of query or import operations are batched so that all of the adds or removes to any individual\ncollections are collected into a single notification event for each relation array.\n@example\n // assume order is an order entity attached to an EntityManager.\n orders.arrayChanged.subscribe(\n function (arrayChangedArgs) {\n let addedEntities = arrayChangedArgs.added;\n let removedEntities = arrayChanged.removed;\n });\n@event arrayChanged\n@param added {Array of Primitives} An array of all of the items added to this collection.\n@param removed {Array of Primitives} An array of all of the items removed from this collection.\n@readOnly\n*/\n\nconst primitiveArrayOps: ObservableArrayOps = {\n\n // every value is welcome: there is nothing to attach, and no duplicate to guard against\n getGoodAdds: function (arr: PrimitiveArray, adds: any[]) {\n return adds;\n },\n\n beforeChange: function (arr: PrimitiveArray) {\n observableArray.updateEntityState(arr);\n },\n\n processAdds: function (arr: PrimitiveArray, adds: any[]) {\n // nothing needed\n },\n\n processRemoves: function (arr: PrimitiveArray, removes: any[]) {\n // nothing needed\n },\n\n getEventParent: function (arr: PrimitiveArray) {\n return observableArray.getEntityAspect(arr);\n },\n\n getPendingPubs: function (arr: PrimitiveArray) {\n const em = observableArray.getEntityAspect(arr).entityManager;\n return em && (em as any)._pendingPubs;\n },\n\n rejectChanges: function (arr: PrimitiveArray) {\n const origValues = arr._obs.origValues;\n if (!origValues) return;\n arr.length = 0;\n Array.prototype.push.apply(arr, origValues);\n },\n\n acceptChanges: function (arr: PrimitiveArray) {\n arr._obs.origValues = null;\n }\n};\n\n/** For use by breeze plugin authors only. The class is for use in building a {@link ModelLibraryAdapter} implementation.\n@adapter (see {@link ModelLibraryAdapter})\n@hidden\n*/\nexport function makePrimitiveArray(arr: any[], parent: StructuralObject, parentProperty: DataProperty): PrimitiveArray {\n const arrX = arr as any;\n arrX.parent = parent;\n arrX.parentProperty = parentProperty;\n arrX.arrayChanged = new BreezeEvent(\"arrayChanged\", arrX);\n observableArray.initialize(arrX, primitiveArrayOps);\n return arrX as PrimitiveArray;\n}\n"]}
1
+ {"version":3,"file":"primitive-array.js","sourceRoot":"","sources":["../../src/entity/primitive-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAuC,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS7F;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;EAgBE;AAEF,MAAM,iBAAiB,GAAuB;IAE5C,wFAAwF;IACxF,WAAW,EAAE,UAAU,GAAmB,EAAE,IAAW;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY,EAAE,UAAU,GAAmB;QACzC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,WAAW,EAAE,UAAU,GAAmB,EAAE,IAAW;QACrD,iBAAiB;IACnB,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB,EAAE,OAAc;QAC3D,iBAAiB;IACnB,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB;QAC3C,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,cAAc,EAAE,UAAU,GAAmB;QAC3C,MAAM,EAAE,GAAG,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;QAC9D,OAAO,EAAE,IAAK,EAAU,CAAC,YAAY,CAAC;IACxC,CAAC;IAED,aAAa,EAAE,UAAU,GAAmB;QAC1C,MAAM,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,EAAE,UAAU,GAAmB;QAC1C,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF;;;EAGE;AACF,MAAM,UAAU,kBAAkB,CAAC,GAAU,EAAE,MAAwB,EAAE,cAA4B;IACnG,MAAM,IAAI,GAAG,GAAU,CAAC;IACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACrC,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAC1D,eAAe,CAAC,UAAU,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IACpD,OAAO,IAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { BreezeEvent } from '../core/event.js';\r\nimport { ObservableArray, ObservableArrayOps, observableArray } from './observable-array.js';\r\nimport type { StructuralObject } from './entity-aspect.js';\r\nimport type { DataProperty } from '../metadata/entity-metadata.js';\r\n\r\nexport interface PrimitiveArray extends ObservableArray<any> {\r\n parent?: StructuralObject;\r\n parentProperty?: DataProperty;\r\n}\r\n\r\n/*\r\n Primitive arrays are not a class: they are real arrays whose mutating methods are replaced, so\r\n that changing one updates the entity that owns it. A primitive array is a collection of primitive\r\n values associated with a data property on a single entity or complex object, i.e.\r\n customer.invoiceNumbers.\r\n @class {primitiveArray}\r\n */\r\n\r\n/*\r\nAn {@link BreezeEvent} that fires whenever the contents of this array changed. This event\r\nis fired any time a new entity is attached or added to the EntityManager and happens to belong to this collection.\r\nAdds that occur as a result of query or import operations are batched so that all of the adds or removes to any individual\r\ncollections are collected into a single notification event for each relation array.\r\n@example\r\n // assume order is an order entity attached to an EntityManager.\r\n orders.arrayChanged.subscribe(\r\n function (arrayChangedArgs) {\r\n let addedEntities = arrayChangedArgs.added;\r\n let removedEntities = arrayChanged.removed;\r\n });\r\n@event arrayChanged\r\n@param added {Array of Primitives} An array of all of the items added to this collection.\r\n@param removed {Array of Primitives} An array of all of the items removed from this collection.\r\n@readOnly\r\n*/\r\n\r\nconst primitiveArrayOps: ObservableArrayOps = {\r\n\r\n // every value is welcome: there is nothing to attach, and no duplicate to guard against\r\n getGoodAdds: function (arr: PrimitiveArray, adds: any[]) {\r\n return adds;\r\n },\r\n\r\n beforeChange: function (arr: PrimitiveArray) {\r\n observableArray.updateEntityState(arr);\r\n },\r\n\r\n processAdds: function (arr: PrimitiveArray, adds: any[]) {\r\n // nothing needed\r\n },\r\n\r\n processRemoves: function (arr: PrimitiveArray, removes: any[]) {\r\n // nothing needed\r\n },\r\n\r\n getEventParent: function (arr: PrimitiveArray) {\r\n return observableArray.getEntityAspect(arr);\r\n },\r\n\r\n getPendingPubs: function (arr: PrimitiveArray) {\r\n const em = observableArray.getEntityAspect(arr).entityManager;\r\n return em && (em as any)._pendingPubs;\r\n },\r\n\r\n rejectChanges: function (arr: PrimitiveArray) {\r\n const origValues = arr._obs.origValues;\r\n if (!origValues) return;\r\n arr.length = 0;\r\n Array.prototype.push.apply(arr, origValues);\r\n },\r\n\r\n acceptChanges: function (arr: PrimitiveArray) {\r\n arr._obs.origValues = null;\r\n }\r\n};\r\n\r\n/** For use by breeze plugin authors only. The class is for use in building a {@link ModelLibraryAdapter} implementation.\r\n@adapter (see {@link ModelLibraryAdapter})\r\n@hidden\r\n*/\r\nexport function makePrimitiveArray(arr: any[], parent: StructuralObject, parentProperty: DataProperty): PrimitiveArray {\r\n const arrX = arr as any;\r\n arrX.parent = parent;\r\n arrX.parentProperty = parentProperty;\r\n arrX.arrayChanged = new BreezeEvent(\"arrayChanged\", arrX);\r\n observableArray.initialize(arrX, primitiveArrayOps);\r\n return arrX as PrimitiveArray;\r\n}\r\n"]}