Member Junction
    Preparing search index...

    BaseEngineRegistry is a central registry for tracking all BaseEngine instances.

    It provides:

    • Registration and tracking of engine singletons
    • Memory usage estimation across all engines
    • Cross-engine data sharing coordination
    • Bulk operations (refresh all, invalidate all)
    // Register an engine (typically done automatically by BaseEngine)
    BaseEngineRegistry.Instance.RegisterEngine(MyEngine.Instance);

    // Get memory stats
    const stats = BaseEngineRegistry.Instance.GetMemoryStats();
    console.log(`Total engines: ${stats.totalEngines}`);
    console.log(`Total memory: ${(stats.totalEstimatedMemoryBytes / 1024 / 1024).toFixed(2)} MB`);

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get GlobalKey(): string

      Returns string

    Methods

    • Find every loaded engine that caches the given entity, returning each match's engine + the full property config that produced it + a live pointer to the cached array — so a single call tells you whether you can serve a lookup from memory (instead of hitting the database) and gives you the data without a second call.

      Matches are ordered unfiltered-first: a config with no Filter holds the complete entity set and is the authoritative cache to prefer (e.g. for "show all rows on focus" or in-memory search); filtered caches (a subset) come after. When more than one engine caches the entity you get them all, so callers can pick the right one (e.g. by engineClassName or by inspecting config).

      Typical use (1-liner intent):

      const hit = BaseEngineRegistry.Instance.FindCachedEntity<UserInfo>('Users', { unfilteredOnly: true })[0];
      if (hit) {
      // Small/static entity already fully in memory — search/sort it locally, no DB call.
      const matches = hit.records.filter(u => u.Name.toLowerCase().includes(q));
      } else {
      // Not cached unfiltered → fall back to a normal RunView against the DB.
      }

      Notes:

      • Only loaded engines are considered (a registered-but-not-yet-loaded engine has no data to offer).
      • The returned records is the engine's live array — read it, don't mutate it. For 'simple' configs the rows are plain objects, not BaseEntity instances (check config.ResultType if you need ORM rows).

      Type Parameters

      Parameters

      • entityName: string

        Entity to look up (case-insensitive, whitespace-trimmed).

      • Optionaloptions: { unfilteredOnly?: boolean }
        • OptionalunfilteredOnly?: boolean

          When true, omit any cache that has a Filter (i.e. only return full-set caches). Default false.

      Returns CachedEntityMatch<T>[]

      Matches (unfiltered first); empty array when no loaded engine caches it.

    • Gets a list of engines that have loaded a specific entity.

      Parameters

      • entityName: string

        The name of the entity

      Returns string[]

      Array of engine class names that have loaded this entity

    • Returns the entity load tracking data as a Map suitable for TelemetryAnalyzerContext. Key: entity name, Value: array of engine class names that have loaded this entity.

      Returns Map<string, string[]>

    • The Global Object Store is a place to store global objects that need to be shared across the application. Depending on the execution environment, this could be the window object in a browser, or the global object in a node environment, or something else in other contexts. The key here is that in some cases static variables are not truly shared because it is possible that a given class might have copies of its code in multiple paths in a deployed application. This approach ensures that no matter how many code copies might exist, there is only one instance of the object in question by using the Global Object Store.

      Returns GlobalObjectStore

    • Records that an engine has loaded a specific entity. If another engine has already loaded this entity, a warning is queued.

      Parameters

      • engineClassName: string

        The class name of the engine loading the entity

      • entityName: string

        The name of the entity being loaded

      Returns void

    • Records that an engine has loaded multiple entities. Convenience method for batch recording. Uses instance identity to prevent false positives when a subclass and base class share the same singleton (e.g., AIEngine extends AIEngineBase).

      Parameters

      • engine: object

        The engine instance that loaded the entities

      • entityNames: string[]

        Array of entity names being loaded

      Returns void

    • Register an engine instance with the registry. This is typically called automatically by BaseEngine during Config().

      Parameters

      • engine: unknown

        The engine instance to register

      • OptionalclassName: string

        Optional class name override (uses constructor name by default)

      Returns void

    • Convenience wrapper over FindCachedEntity that returns just the best cached array for an entity (unfiltered preferred), or null when no loaded engine caches it. Use this for the common "if it's already in memory, use it; otherwise go to the DB" check.

      const rows = BaseEngineRegistry.Instance.TryGetCachedRecords<UserInfo>('Users', { unfilteredOnly: true });
      if (rows) { /* serve from memory */ } else { /* RunView fallback */ }

      Type Parameters

      Parameters

      • entityName: string

        Entity to look up (case-insensitive, trimmed).

      • Optionaloptions: { unfilteredOnly?: boolean }
        • OptionalunfilteredOnly?: boolean

          Require a full-set (no-Filter) cache. Default false.

      Returns T[]

      The live cached array, or null if not cached (per the options).

    • Returns the singleton instance of the class. If the instance does not exist, it is created and stored in the Global Object Store. If className is provided it will be used as part of the key in the Global Object Store, otherwise the actual class name will be used. NOTE: the class name used by default is the lowest level of the object hierarchy, so if you have a class that extends another class, the lowest level class name will be used.

      Type Parameters

      Parameters

      • this: new () => T
      • OptionalclassName: string

      Returns T