Member Junction
    Preparing search index...

    Server side cache of users and their roles.

    Dialect-neutral: UserCache.Refresh takes a DatabaseProviderBase and reads through ExecuteSQL / QuoteSchemaAndView, so SQL Server and PostgreSQL processes share one implementation rather than each hand-rolling a vwUsers + vwUserRoles load.

    Uses BaseSingleton to guarantee a single instance across the entire process, even if bundlers duplicate this module across multiple execution paths.

    NOTE: the class name UserCache is load-bearing — BaseSingleton keys its global store on the constructor name, so renaming it would hand every existing holder a second, empty instance.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    • 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 | null

    • Returns the system user, or undefined when the cache has not been refreshed or the row is absent — every caller already guards for that, and with _users defaulting to [] this can no longer throw. The declared return type stays UserInfo because widening it to UserInfo | undefined is a read-surface change, and Phase 1 of the provider refactor moves this class without touching its read surface. The new home compiles under strict, hence the explicit assertion where the old one silently inferred the same lie.

      Returns UserInfo

    • This method will refresh the cache with the latest data from the database

      Parameters

      • provider: DatabaseProviderBase

        the configured database provider to read through. Works on any dialect — the SQL is built with the provider's own quoting and core-schema name.

      • OptionalautoRefreshIntervalMS: number

        optional, if provided, the cache will be refreshed every interval as specified - denominated in milliseconds

      Returns Promise<void>

    • Replace the cached set with users the caller already materialized.

      The seam exists for callers that cannot take Refresh's path — the PostgreSQL bootstrap in testing-cli builds its UserInfo[] before there is a DatabaseProviderBase to read through, so it holds users but has nothing to hand Refresh.

      Without this, that caller reached in and assigned the private field by string index:

      (UserCache.Instance as unknown as Record<string, unknown>)['_users'] = userInfos;
      

      which type-checks forever and fails silently: rename _users and the cache is simply never populated — no compile error, no exception, and the symptom ("no users") surfaces arbitrarily far from the cause. A public method makes that rename a build error instead.

      Deliberately does NOT start the auto-refresh timer: the caller supplied this data, so there is no provider to re-read it through. Use Refresh when there is one.

      Parameters

      Returns void

    • 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