The source data object for this DataModel instance. Once constructed, the source object is sealed such that no keys may be added nor removed.
The events that are handled by the behavior.
An immutable reverse-reference to a parent DataModel to which this model belongs.
Static Internal_schemaThe defined and cached Data Schema for all instances of this DataModel.
StaticeventsStaticLOCALIZATION_A convenience reference to the RegionBehavior which contains this behavior sub-type.
Is the current state of this DataModel invalid? The model is invalid if there is any unresolved failure.
A convenience reference to the RegionDocument which contains this behavior sub-type.
Define the data schema for this document instance.
An array of validation failure instances which may have occurred when this instance was last validated.
StaticschemaCalled by ClientDocumentMixin#_onUpdate.
The differential data that was changed relative to the documents prior values
Additional options which modify the update request
The id of the User requesting the document update
InternalCalled by ClientDocument#_preCreate.
The initial data object provided to the document creation request
Additional options which modify the creation request
The User requesting the document creation
Return false to exclude this Document from the creation operation
Clone a model, creating a new data model by combining current data with provided overrides.
Optionaldata: object = {}Additional data which overrides current document data at the time of creation
Optionalcontext: DataModelConstructionContext = {}Context options passed to the data model constructor
The cloned instance
Prepare data related to this DataModel itself, before any derived data (including Active Effects) is computed. This is especially useful for initializing numbers, arrays, and sets you expect to be modified by active effects.
Called before ClientDocument#prepareBaseData in ClientDocument#prepareData.
prepareBaseData() {
// Ensures an active effect of `system.encumbrance.max | ADD | 10` doesn't produce `NaN`
this.encumbrance = {
max: 0
}
// If you need to access the owning Document, `this.parent` provides a reference for properties like the name
// or embedded collections, e.g. `this.parent.name` or `this.parent.items`
}
Apply transformations or derivations to the values of the source data object. Compute data fields whose values are not stored to the database.
Called before ClientDocument#prepareDerivedData in ClientDocument#prepareData.
Reset the state of this data instance back to mirror the contained source data, erasing any changes.
Convert this Document to some HTML display for embedding purposes.
Configuration for embedding behavior.
Optionaloptions: any = {}The original enrichment options for cases where the Document embed content also contains text that must be enriched.
Extract the source data for the DataModel into a simple object format that can be serialized.
The document source data expressed as a plain object
Copy and transform the DataModel into a plain object. Draw the values of the extracted object from the data source (by default) otherwise from its transformed values.
Optionalsource: boolean = trueDraw values from the underlying data source rather than transformed values
The extracted primitive object
Update the DataModel locally by applying an object of changes to its source data. The provided changes are expanded, cleaned, validated, and stored to the source data object for this model. The provided changes argument is mutated in this process. The source data is then re-initialized to apply those changes to the prepared data. The method returns an object of differential changes which modified the original data.
New values which should be applied to the data model
Options which determine how the new data is merged
An object containing differential keys and values that were changed
Validate the data contained in the document to check for type and content. If changes are provided, missing types are added to it before cleaning and validation. This mutates the provided changes. This function throws an error if data within the document is not valid.
Options which modify how the model is validated
Whether the data source or proposed change is reported as valid. A boolean is always returned if validation is non-strict.
Protected_configureProtectedConfigure the data model instance before validation and initialization workflows are performed.
Optionaloptions: object = {}Additional options modifying the configuration
Protected_handleProtectedHandle the Region event.
The Region event
Protected_initializeProtectedInitialize the instance by copying data from the source object to instance attributes. This mirrors the workflow of SchemaField#initialize but with some added functionality.
Optionaloptions: object = {}Options provided to the model constructor
Protected_initializeProtectedInitialize the source data for a new DataModel instance. One-time migrations and initial cleaning operations are applied to the source data.
The candidate source data from which the model will be constructed
Optionaloptions: object = {}Options provided to the model constructor
Migrated and cleaned source data which will be stored to the model instance,
which is the same object as the data argument
Protected_onProtectedCalled by ClientDocument#_onCreate.
The initial data object provided to the document creation request
Additional options which modify the creation request
The id of the User requesting the document update
Protected_onProtectedCalled by ClientDocumentMixin#_onDelete.
Additional options which modify the deletion request
The id of the User requesting the document update
Protected_preProtectedCalled by ClientDocumentMixin#_preDelete.
Additional options which modify the deletion request
The User requesting the document deletion
A return value of false indicates the deletion operation should be cancelled.
Protected_preProtectedCalled by ClientDocumentMixin#_preUpdate.
The candidate changes to the Document
Additional options which modify the update request
The User requesting the document update
A return value of false indicates the update operation should be cancelled.
StaticcleanClean a data source object to conform to a specific provided schema.
Optionalsource: object = {}The source data object
Optionaloptions: object = {}Additional options which are passed to field cleaning methods
The cleaned source data, which is the same object as the source argument
StaticdefineStaticfromJSONCreate a DataModel instance using a provided serialized JSON string.
Serialized document data in string format
A constructed data model instance
StaticfromCreate a new instance of this DataModel from a source record. The source is presumed to be trustworthy and is not strictly validated.
Initial document data which comes from a trusted source.
Optionalcontext: Omit<DataModelConstructionContext, "strict"> & DataModelFromSourceOptions = {}Model construction context
StaticmigrateMigrate candidate source data for this DataModel which may require initial cleaning or transformations.
The candidate source data from which the model will be constructed
Migrated source data, which is the same object as the source argument
StaticmigrateWrap data migration in a try/catch which attempts it safely
The candidate source data from which the model will be constructed
Migrated source data, which is the same object as the source argument
StaticshimTake data which conforms to the current data schema and add backwards-compatible accessors to it in order to support older code which uses this data.
Data which matches the current schema
Optionaloptions: { embedded?: boolean } = {}Additional shimming options
Optionalembedded?: booleanApply shims to embedded models?
Data with added backwards-compatible properties, which is the same object as
the data argument
StaticvalidateEvaluate joint validation rules which apply validation conditions across multiple fields of the model. Field-specific validation rules should be defined as part of the DataSchema for the model. This method allows for testing aggregate rules which impose requirements on the overall model.
Candidate data for the model
Protected Static_createProtectedCreate the events field.
Options which configure how the events field is declared
Optionalevents?: string[]The event names to restrict to.
Optionalinitial?: string[]The initial set of events that should be default for the field
Protected Static_initializationProtectedA generator that orders the DataFields in the DataSchema into an expected initialization order.
The data model for a behavior that allows to modify the movement cost within the Region.