Options
All
  • Public
  • Public/Protected
  • All
Menu

The data schema used to define World manifest files. Extends the basic PackageData schema with some additional world-specific fields.

property

{string} system The game system name which this world relies upon

property

{string} coreVersion The version of the core software for which this world has been migrated

property

{string} systemVersion The version of the game system for which this world has been migrated

property

{string} [background] A web URL or local file path which provides a background banner image

property

{string} [nextSession] An ISO datetime string when the next game session is scheduled to occur

property

{boolean} [resetKeys] Should user access keys be reset as part of the next launch?

property

{boolean} [safeMode] Should the world launch in safe mode?

property

{string} [joinTheme] The theme to use for this world's join page.

Hierarchy

Index

Constructors

  • new BaseWorld(data: PackageManifestData, options?: any): BaseWorld

Properties

availability: number

An availability code in PACKAGE_AVAILABILITY_CODES which defines whether this package can be used.

locked: boolean

A flag which tracks whether this package is currently locked.

exclusive: boolean

A flag which tracks whether this package is a free Exclusive pack

owned: boolean

A flag which tracks whether this package is owned, if it is protected.

tags: string[]

A set of Tags that indicate what kind of Package this is, provided by the Website

hasStorage: boolean

A flag which tracks if this package has files stored in the persistent storage folder

_source: any

The source data object for this DataModel instance. Once constructed, the source object is sealed such that no keys may be added nor removed.

parent: DataModel

An immutable reverse-reference to a parent DataModel to which this model belongs.

#validationFailures: { fields: any; joint: any } = ...

Type declaration

  • fields: any
  • joint: any
type: string = "world"
override
icon: string = "fa-globe-asia"

The default icon used for this type of Package.

Accessors

  • get type(): string
  • The type of this package instance. A value in CONST.PACKAGE_TYPES.

    Returns string

  • get name(): string
  • The canonical identifier for this package

    deprecated

    Returns string

  • get unavailable(): boolean
  • A flag which defines whether this package is unavailable to be used.

    Returns boolean

  • get incompatibleWithCoreVersion(): boolean
  • Is this Package incompatible with the currently installed core Foundry VTT software version?

    Returns boolean

  • get data(): this
  • deprecated

    Returns this

  • Define the data schema for this document instance.

    Returns SchemaField

  • get invalid(): boolean
  • Is the current state of this DataModel invalid? The model is invalid if there is any unresolved failure.

    Returns boolean

  • get collection(): string
  • The named collection to which this package type belongs

    Returns string

  • The Data Schema for all instances of this DataModel.

    Returns SchemaField

Methods

  • _testRequiredDependencies(modulesCollection: Collection<string, Module>): Promise<boolean>
  • Test that the dependencies of a package are satisfied as compatible. This method assumes that all packages in modulesCollection have already had their own availability tested.

    internal

    Parameters

    • modulesCollection: Collection<string, Module>

      A collection which defines the set of available modules

    Returns Promise<boolean>

    Are all required dependencies satisfied?

  • reset(): void
  • Reset the state of this data instance back to mirror the contained source data, erasing any changes.

    Returns void

  • clone(data?: any, context?: any): Document | Promise<Document>
  • Clone a model, creating a new data model by combining current data with provided overrides.

    Parameters

    • data: any = {}
    • context: any = {}

    Returns Document | Promise<Document>

    The cloned Document instance

  • validate(options?: { changes: any; clean: boolean; fallback: boolean; dropInvalidEmbedded: boolean; strict: boolean; fields: boolean; joint: boolean }): boolean
  • Validate the data contained in the document to check for type and content This function throws an error if data within the document is not valid

    Parameters

    • options: { changes: any; clean: boolean; fallback: boolean; dropInvalidEmbedded: boolean; strict: boolean; fields: boolean; joint: boolean } = {}

      Optional parameters which customize how validation occurs.

      • changes: any
      • clean: boolean
      • fallback: boolean
      • dropInvalidEmbedded: boolean
      • strict: boolean
      • fields: boolean
      • joint: boolean

    Returns boolean

    An indicator for whether the document contains valid data

  • updateSource(changes?: any, options?: any): any
  • Update the DataModel locally by applying an object of changes to its source data. The provided changes are cleaned, validated, and stored to the source data object for this model. 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.

    Parameters

    • changes: any = {}

      New values which should be applied to the data model

    • options: any = {}

    Returns any

    An object containing the changed keys and values

  • toObject(source?: boolean): any
  • 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.

    Parameters

    • source: boolean = true

    Returns any

    The extracted primitive object

  • toJSON(): any
  • Extract the source data for the DataModel into a simple object format that can be serialized.

    Returns any

    The document source data expressed as a plain object

  • _configure(options?: {}): void
  • Configure the data model instance before validation and initialization workflows are performed.

    Parameters

    • options: {} = {}

      Returns void

    • _initializeSource(data: any, options?: any): any
    • Initialize the source data for a new DataModel instance. One-time migrations and initial cleaning operations are applied to the source data.

      Parameters

      • data: any

        The candidate source data from which the model will be constructed

      • options: any = {}

      Returns any

      Migrated and cleaned source data which will be stored to the model instance

    • _initialize(options?: any): void
    • Initialize the instance by copying data from the source object to instance attributes. This mirrors the workflow of SchemaField#initialize but with some added functionality.

      Parameters

      • options: any = {}

      Returns void

    • migrateData(data: any): any
    • Migrate candidate source data for this DataModel which may require initial cleaning or transformations.

      Parameters

      • data: any

        The candidate source data from which the model will be constructed

      Returns any

      Migrated source data, if necessary

    • testAvailability(data: any, release: any): any
    • Check the given compatibility data against the current installation state and determine its availability.

      Parameters

      • data: any

        The compatibility data to test.

      • release: any

      Returns any

    • isIncompatibleWithCoreVersion(availability: number): boolean
    • Test if a given availability is incompatible with the core version.

      Parameters

      • availability: number

        The availability value to test.

      Returns boolean

    • cleanData(source?: {}, __namedParameters?: { installed: any }): any
    • Clean a data source object to conform to a specific provided schema.

      Parameters

      • source: {} = {}
        • __namedParameters: { installed: any } = {}
          • installed: any

        Returns any

        The cleaned source data

      • validateId(id: string): void
      • Validate that a Package ID is allowed.

        throws

        An error if the candidate ID is invalid

        Parameters

        • id: string

          The candidate ID

        Returns void

      • _logWarning(packageId: string, message: string, options?: { installed: any }): void
      • A wrapper around the default compatibility warning logger which handles some package-specific interactions.

        internal

        Parameters

        • packageId: string

          The package ID being logged

        • message: string

          The warning or error being logged

        • options: { installed: any } = {}

          Logging options passed to foundry.utils.logCompatibilityWarning

          • installed: any

        Returns void

      • _migrateNameToId(data: any, logOptions: any): void
      • _migrateDependenciesNameToId(data: any, logOptions: any): void
      • _migrateToRelationships(data: any, logOptions: any): void
      • _migrateCompatibility(data: any, logOptions: any): void
      • _migrateMediaURL(data: any, logOptions: any): void
      • _migrateOwnership(data: any, logOptions: any): any
      • fromRemoteManifest(manifestUrl: string, options?: { strict: boolean }): Promise<ServerPackage>
      • Retrieve the latest Package manifest from a provided remote location.

        throws

        An error if the retrieved manifest data is invalid

        Parameters

        • manifestUrl: string

          A remote manifest URL to load

        • options: { strict: boolean } = {}

          Additional options which affect package construction

          • strict: boolean

        Returns Promise<ServerPackage>

        A Promise which resolves to a constructed ServerPackage instance

      • formatValidationErrors(errors: any, [options={}]?: { label: string; namespace: string }): string
      • Get an array of validation errors from the provided error structure

        Parameters

        • errors: any
        • [options={}]: { label: string; namespace: string } = {}
          • label: string
          • namespace: string

        Returns string

      • validateJoint(data: any): any
      • Evaluate 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.

        throws

        An error if a validation failure is detected

        Parameters

        • data: any

          Candidate data for the model

        Returns any

      • Create a new instance of this DataModel from a source record. The source is presumed to be trustworthy and is not strictly validated.

        Parameters

        • source: any

          Initial document data which comes from a trusted source.

        • [context]: DataValidationOptions = {}

          Model construction context

        Returns DataModel

      • Create a DataModel instance using a provided serialized JSON string.

        Parameters

        • json: string

          Serialized document data in string format

        Returns DataModel

        A constructed data model instance

      • migrateDataSafe(source: any): any
      • Wrap data migration in a try/catch which attempts it safely

        Parameters

        • source: any

          The candidate source data from which the model will be constructed

        Returns any

        Migrated source data, if necessary

      • shimData(data: any, [options={}]?: { embedded: boolean }): any
      • Take 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.

        Parameters

        • data: any

          Data which matches the current schema

        • [options={}]: { embedded: boolean } = {}

          Additional shimming options

          • embedded: boolean

        Returns any

        Data with added backwards-compatible properties

      • _initializationOrder(): Generator<[string, DataField], any, any>