ThemeParks.wiki Parks API - v2.0.0
    Preparing search index...

    Class DestinationAbstract

    Index

    Constructors

    Properties

    cacheKeyPrefix?: string

    Optional cache key prefix for all cached methods. When set, this prefix is prepended to all cache keys, preventing cache collisions when multiple instances of the same base class exist (e.g., multiple parks using the same framework).

    Can be set directly as a string property, or implement getCacheKeyPrefix() method for dynamic prefixes.

    class MyPark extends Destination {
    constructor(options) {
    super(options);
    this.cacheKeyPrefix = `mypark:${this.parkId}`;
    }
    }
    config: { [key: string]: string | string[] } = {}
    hasLiveStream: boolean = false

    Whether this destination supports a real-time live data stream. Parks with WebSocket or database sync feeds set this to true. The collector checks this to decide whether to run a stream loop.

    false
    
    httpQueue: HttpQueue = ...
    language:
        | "en"
        | "en-gb"
        | "en-us"
        | "de"
        | "fr"
        | "es"
        | "it"
        | "nl"
        | "ja"
        | "ko"
        | "zh" = 'en'

    Default language for localized strings Can be overridden by subclasses or via {PREFIX}_LANGUAGE env var with

    decorator

    'en'
    
    proxyConfig: ProxyConfig | null = null
    timezone: string = 'UTC'

    Timezone for this destination. Subclasses should override this with the park's local timezone. Used by virtual queue helpers to format dates in the park's timezone.

    'UTC'
    

    Methods

    • Protected

      Internal initialization hook for subclasses

      Override this method to provide custom initialization logic. Called once per instance by init().

      Returns Promise<void>

    • Inject proxy settings into HTTP requests. Runs last (priority 999) so all auth/header injectors fire before the URL is rewritten to point at the proxy service.

      Parameters

      Returns Promise<void>

    • Unwrap proxy responses (e.g., Scrapfly wraps responses in JSON). Runs first (priority -999) so downstream response handlers see the unwrapped response, not the proxy envelope.

      Parameters

      Returns Promise<void>

    • Add a prefix to use when looking up config values from environment variables or config object. This allows multiple destinations to co-exist in the same environment without clashing on config keys.

      Parameters

      • prefix: string

        Prefix to add to config lookups (e.g. 'UNIVERSAL' to check UNIVERSAL_ env vars)

      Returns void

    • Helper to build boarding group queue data

      Constructs a BOARDING_GROUP queue object with allocation information. Automatically formats dates in the destination's timezone.

      Parameters

      • status: "AVAILABLE" | "PAUSED" | "CLOSED"

        Boarding group status (AVAILABLE, PAUSED, or CLOSED)

      • Optionaloptions: {
            currentGroupEnd?: number | null;
            currentGroupStart?: number | null;
            estimatedWait?: number | null;
            nextAllocationTime?: string | Date | null;
        }

        Additional boarding group information

      Returns {
          allocationStatus: "AVAILABLE" | "PAUSED" | "CLOSED";
          currentGroupEnd: number | null;
          currentGroupStart: number | null;
          estimatedWait: number | null;
          nextAllocationTime: string | null;
      }

      Boarding group queue object

      • allocationStatus: "AVAILABLE" | "PAUSED" | "CLOSED"

        State of boarding group availability

      • currentGroupEnd: number | null

        Current boarding group end number

      • currentGroupStart: number | null

        Current boarding group start number

      • estimatedWait: number | null

        Estimated wait time in minutes

      • nextAllocationTime: string | null

        Next boarding group allocation time

      // In buildLiveData() for Rise of the Resistance
      liveData.queue!.BOARDING_GROUP = this.buildBoardingGroupQueue('AVAILABLE', {
      currentGroupStart: 45,
      currentGroupEnd: 60,
      estimatedWait: 30
      });
    • Build the list of entities for this destination

      Subclasses should override this method to return their entities. The returned entities will automatically have their parkId and destinationId resolved based on the parent hierarchy.

      Returns Promise<Entity[]>

      List of entities (hierarchy will be resolved automatically)

    • Build live data for all entities in this destination

      Subclasses should override this method to return live data (wait times, operating status, showtimes, etc.) for their entities.

      Returns Promise<LiveData[]>

      List of live data for entities

    • Build a real-time stream of live data updates

      Override this method in parks that have a WebSocket or database sync feed. The default implementation is an empty generator (returns immediately, never yields).

      The connection to the live data source should be opened in _init(), not here. This method subscribes to the already-open connection and yields updates as they arrive.

      Returns AsyncGenerator<LiveData[]>

      Async generator yielding LiveData[] per update

    • Helper to build paid return time queue data

      Constructs a PAID_RETURN_TIME queue object with pricing information. Automatically formats dates in the destination's timezone.

      Parameters

      • state: "AVAILABLE" | "TEMP_FULL" | "FINISHED"

        Queue state (AVAILABLE, TEMP_FULL, or FINISHED)

      • returnStart: string | Date | null

        Start time of return window (Date or ISO string)

      • returnEnd: string | Date | null

        End time of return window (Date or ISO string)

      • currency: string

        Currency code (e.g., 'USD', 'EUR')

      • amountCents: number | null

        Price in cents (e.g., 1500 for $15.00)

      Returns {
          price: PriceData;
          returnEnd: string | null;
          returnStart: string | null;
          state: "AVAILABLE" | "TEMP_FULL" | "FINISHED";
      }

      Paid return time queue object

      • price: PriceData

        Price information for paid return time

      • returnEnd: string | null

        End time of return window

      • returnStart: string | null

        Start time of return window

      • state: "AVAILABLE" | "TEMP_FULL" | "FINISHED"

        State of return time availability

      // In buildLiveData() for Lightning Lane/Express Pass
      liveData.queue!.PAID_RETURN_TIME = this.buildPaidReturnTimeQueue(
      'AVAILABLE',
      new Date('2024-10-15T14:30:00'),
      null,
      'USD',
      1500
      );
    • Helper to build return time queue data

      Constructs a RETURN_TIME queue object with proper formatting. Automatically formats dates in the destination's timezone.

      Parameters

      • state: "AVAILABLE" | "TEMP_FULL" | "FINISHED"

        Queue state (AVAILABLE, TEMP_FULL, or FINISHED)

      • returnStart: string | Date | null

        Start time of return window (Date or ISO string)

      • returnEnd: string | Date | null

        End time of return window (Date or ISO string)

      Returns {
          returnEnd: string | null;
          returnStart: string | null;
          state: "AVAILABLE" | "TEMP_FULL" | "FINISHED";
      }

      Return time queue object

      • returnEnd: string | null

        End time of return window

      • returnStart: string | null

        Start time of return window

      • state: "AVAILABLE" | "TEMP_FULL" | "FINISHED"

        State of return time availability

      // In buildLiveData()
      liveData.queue!.RETURN_TIME = this.buildReturnTimeQueue(
      'AVAILABLE',
      new Date('2024-10-15T14:30:00'),
      new Date('2024-10-15T14:45:00')
      );
    • Build schedules for all entities in this destination

      Subclasses should override this method to return operating hours, show times, and other schedule information for their entities.

      Returns Promise<EntitySchedule[]>

      List of schedules for entities

    • Calculate return window based on current wait time

      Common pattern for parks like Efteling where virtual queue window is calculated as: now + waitTime to now + waitTime + windowDuration

      Parameters

      • waitMinutes: number

        Wait time in minutes to add to base time

      • Optionaloptions: { baseTime?: Date; windowMinutes?: number }

        Optional configuration

      Returns { end: string; start: string }

      Object with formatted start and end times

      // In buildLiveData() for calculated return windows
      const window = this.calculateReturnWindow(45, { windowMinutes: 15 });
      liveData.queue!.RETURN_TIME = this.buildReturnTimeQueue(
      'AVAILABLE',
      window.start,
      window.end
      );
    • Optional method to dynamically generate a cache key prefix. If implemented, this takes precedence over the cacheKeyPrefix property. Can return a string or Promise.

      Returns string | Promise<string>

      class MyPark extends Destination {
      getCacheKeyPrefix() {
      return `mypark:${this.parkId}`;
      }
      }
    • Get all entities (parks, attractions, dining, shows, hotels) for this destination

      ⚠️ DO NOT OVERRIDE THIS METHOD ⚠️

      This method automatically calls init() before fetching entities, and calls resolveEntityHierarchy() on the returned entities to set parkId and destinationId based on parent relationships.

      To provide entities, implement buildEntityList() instead.

      Returns Promise<Entity[]>

      List of entities with resolved hierarchy

      This method is final and should not be overridden.

    • Get live data for all entities in this destination

      ⚠️ DO NOT OVERRIDE THIS METHOD ⚠️

      This method automatically calls init() before fetching live data. If you need to provide post-processing or validation of live data, consider using the transform pattern in buildLiveData() instead.

      To provide live data, implement buildLiveData() instead.

      Returns Promise<LiveData[]>

      List of live data for entities

      This method is final and should not be overridden.

    • Get localized string value with fallback logic

      Handles both simple strings and multi-language objects. For multi-language objects, uses intelligent fallback: tries exact match, then base language (en-gb -> en), then fallback language, then first available.

      Parameters

      • value: LocalisedString

        LocalisedString (string or multi-language object)

      • Optionallanguage: "en" | "en-gb" | "en-us" | "de" | "fr" | "es" | "it" | "nl" | "ja" | "ko" | "zh"

        Preferred language code (defaults to instance language config)

      • fallbackLanguage: "en" | "en-gb" | "en-us" | "de" | "fr" | "es" | "it" | "nl" | "ja" | "ko" | "zh" = 'en'

        Fallback language if preferred unavailable (defaults to 'en')

      Returns string

      Localized string value

      // Simple string - returns as-is
      this.getLocalizedString("Space Mountain") // => "Space Mountain"

      // Multi-language object with exact match
      this.getLocalizedString({ en: "Space Mountain", fr: "Space Mountain" }, "fr")
      // => "Space Mountain"

      // Multi-language with base language fallback
      this.getLocalizedString({ en: "Space Mountain" }, "en-gb")
      // => "Space Mountain" (falls back to 'en')
    • Get schedules for all entities in this destination

      ⚠️ DO NOT OVERRIDE THIS METHOD ⚠️

      This method automatically calls init() before fetching schedules. If you need to provide post-processing or validation of schedules, consider using the transform pattern in buildSchedules() instead.

      To provide schedules, implement buildSchedules() instead.

      Returns Promise<EntitySchedule[]>

      List of schedules for entities

      This method is final and should not be overridden.

    • Initialize the destination

      This method is called automatically before any data retrieval methods (getEntities, getLiveData, getSchedules). It runs only once per instance, even if called multiple times, thanks to @reusable({forever: true}).

      Subclasses should override _init() instead of this method.

      Returns Promise<void>

      class MyPark extends Destination {
      protected async _init() {
      await this.connectToDatabase();
      await this.loadConfig();
      }
      }
    • Map array of source items to Entity objects

      Helper method to reduce boilerplate when converting API responses to Entity objects. Provides declarative mapping configuration instead of manual object construction.

      Note: This method does NOT set parkId automatically. Use resolveEntityHierarchy() after mapping all entities to correctly populate parkId and destinationId based on the parent chain.

      Type Parameters

      • T

      Parameters

      Returns Entity[]

      const entities = this.mapEntities(apiRides, {
      idField: 'Id',
      nameField: 'MblDisplayName',
      entityType: 'ATTRACTION',
      parentIdField: 'VenueId',
      locationFields: { lat: 'Latitude', lng: 'Longitude' },
      destinationId: 'universalorlando',
      timezone: 'America/New_York',
      filter: (ride) => ride.IsActive === true,
      });
    • Resolve entity hierarchy relationships (parkId and destinationId)

      Walks the parent chain for each entity to correctly set parkId and destinationId based on ancestor types. This handles edge cases like:

      • Attractions at destinations (no park) vs attractions at parks
      • Hotels inside parks vs hotels at destinations
      • Transport between parks vs transport within parks

      Rules:

      • DESTINATION entities: no parent, no parkId, destinationId = self
      • PARK entities: parent should be DESTINATION, no parkId
      • All other entities: parkId = first PARK ancestor (if any), destinationId = first DESTINATION ancestor

      Validation:

      • Throws error if circular parent references detected
      • Throws error if any entity has no DESTINATION in parent chain
      • Throws error if any PARK has no DESTINATION parent

      Parameters

      • entities: Entity[]

        Array of entities to resolve

      Returns Entity[]

      Same array with parkId and destinationId correctly set

      If circular references or missing destination in hierarchy

      async getEntities(): Promise<Entity[]> {
      const entities = [
      ...this.mapEntities(parks, ...),
      ...this.mapEntities(attractions, ...),
      ];
      return this.resolveEntityHierarchy(entities);
      }
    • Stream live data updates in real time

      Returns an async generator that yields LiveData[] arrays as updates arrive from the upstream feed. Each yield contains only the item(s) that changed — a single-element array for per-document sources (e.g. Couchbase Lite), or a full snapshot for sources that send all data at once (e.g. WebSocket).

      For parks without a live feed (hasLiveStream = false), the generator returns immediately without yielding.

      The generator ends when the upstream connection closes. The caller is responsible for reconnecting by calling streamLiveData() again in a loop.

      Returns AsyncGenerator<LiveData[]>