Member Junction
    Preparing search index...

    Interface IMetadataProvider

    Core interface for metadata providers in MemberJunction. Provides access to all system metadata including entities, applications, security, and queries. This is the primary interface for accessing MemberJunction's metadata layer. Implementations typically cache metadata locally for performance.

    interface IMetadataProvider {
        get AllExplorerNavigationItems(): ExplorerNavigationItem[];
        get AllMetadata(): AllMetadata;
        get Applications(): ApplicationInfo[];
        get AuditLogTypes(): AuditLogTypeInfo[];
        get AuthorizationRoles(): AuthorizationRoleInfo[];
        get Authorizations(): AuthorizationInfo[];
        get ConfigData(): ProviderConfigDataBase;
        get CurrentUser(): UserInfo;
        get DatabaseConnection(): any;
        get Entities(): EntityInfo[];
        get FileSystemProvider(): IFileSystemProvider;
        get InstanceConnectionString(): string;
        get LatestLocalMetadata(): MetadataInfo[];
        get LatestRemoteMetadata(): MetadataInfo[];
        get Libraries(): LibraryInfo[];
        get LocalStorageProvider(): ILocalStorageProvider;
        get ProviderType(): ProviderType;
        get Queries(): QueryInfo[];
        get QueryCategories(): QueryCategoryInfo[];
        get QueryDependencies(): QueryDependencyInfo[];
        get QueryEntities(): QueryEntityInfo[];
        get QueryFields(): QueryFieldInfo[];
        get QueryParameters(): QueryParameterInfo[];
        get QueryPermissions(): QueryPermissionInfo[];
        get QuerySQLs(): QuerySQLInfo[];
        get Roles(): RoleInfo[];
        get RowLevelSecurityFilters(): RowLevelSecurityFilterInfo[];
        get SQLDialects(): SQLDialectInfo[];
        get VisibleExplorerNavigationItems(): ExplorerNavigationItem[];
        CacheDataset(
            datasetName: string,
            itemFilters: DatasetItemFilterType[],
            dataset: DatasetResultType,
        ): Promise<void>;
        CheckToSeeIfRefreshNeeded(
            providerToUse?: IMetadataProvider,
        ): Promise<boolean>;
        ClearDatasetCache(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): Promise<void>;
        Config(
            configData: ProviderConfigDataBase,
            providerToUse?: IMetadataProvider,
        ): Promise<boolean>;
        CreateTransactionGroup(): Promise<TransactionGroupBase>;
        EntityByID(entityID: string): EntityInfo;
        EntityByName(entityName: string): EntityInfo;
        GetAndCacheDatasetByName(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
            contextUser?: UserInfo,
        ): Promise<DatasetResultType>;
        GetCachedDataset(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): Promise<DatasetResultType>;
        GetCachedRecordName(
            entityName: string,
            compositeKey: CompositeKey,
            loadIfNeeded?: boolean,
        ): Promise<string>;
        GetDatasetByName(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
            contextUser?: UserInfo,
            providerToUse?: IMetadataProvider,
            forceRefresh?: boolean,
        ): Promise<DatasetResultType>;
        GetDatasetCacheKey(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): string;
        GetDatasetStatusByName(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
            contextUser?: UserInfo,
            providerToUse?: IMetadataProvider,
        ): Promise<DatasetStatusResultType>;
        GetEntityDependencies(entityName: string): Promise<EntityDependency[]>;
        GetEntityObject<T extends BaseEntity<unknown>>(
            entityName: string,
            contextUser?: UserInfo,
        ): Promise<T>;
        GetEntityObject<T extends BaseEntity<unknown>>(
            entityName: string,
            loadKey: CompositeKey,
            contextUser?: UserInfo,
        ): Promise<T>;
        GetEntityRecordName(
            entityName: string,
            compositeKey: CompositeKey,
            contextUser?: UserInfo,
            forceRefresh?: boolean,
        ): Promise<string>;
        GetEntityRecordNames(
            info: EntityRecordNameInput[],
            contextUser?: UserInfo,
            forceRefresh?: boolean,
        ): Promise<EntityRecordNameResult[]>;
        GetLocalDatasetTimestamp(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): Promise<Date>;
        GetRecordDependencies(
            entityName: string,
            CompositeKey: CompositeKey,
        ): Promise<RecordDependency[]>;
        GetRecordDuplicates(
            params: PotentialDuplicateRequest,
            contextUser?: UserInfo,
        ): Promise<PotentialDuplicateResponse>;
        GetRecordFavoriteStatus(
            userId: string,
            entityName: string,
            CompositeKey: CompositeKey,
            contextUser?: UserInfo,
        ): Promise<boolean>;
        IsDatasetCached(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): Promise<boolean>;
        IsDatasetCacheUpToDate(
            datasetName: string,
            itemFilters?: DatasetItemFilterType[],
        ): Promise<boolean>;
        LocalMetadataObsolete(type?: string): boolean;
        MergeRecords(
            request: RecordMergeRequest,
            contextUser?: UserInfo,
            options?: EntityMergeOptions,
        ): Promise<RecordMergeResult>;
        Refresh(providerToUse?: IMetadataProvider): Promise<boolean>;
        RefreshIfNeeded(providerToUse?: IMetadataProvider): Promise<boolean>;
        RefreshRemoteMetadataTimestamps(
            providerToUse?: IMetadataProvider,
        ): Promise<boolean>;
        RemoveLocalMetadataFromStorage(): Promise<void>;
        SaveLocalMetadataToStorage(): Promise<void>;
        SetCachedRecordName(
            entityName: string,
            compositeKey: CompositeKey,
            recordName: string,
        ): void;
        SetRecordFavoriteStatus(
            userId: string,
            entityName: string,
            CompositeKey: CompositeKey,
            isFavorite: boolean,
            contextUser: UserInfo,
        ): Promise<void>;
    }

    Implemented by

    Index

    Accessors

    • get InstanceConnectionString(): string

      A stable string that uniquely identifies the underlying connection this provider points to (host/port/database/endpoint — never credentials). Two providers pointing at the same connection should return the same value. Used by BaseEngine to key its per-connection engine instance cache so transient per-request providers don't pollute the cache; same-connection lookups share one cached engine.

      Returns string

    Methods

    • If the specified datasetName is cached, this method will clear the cache. If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache

      Parameters

      Returns Promise<void>

    • Asynchronous lookup of a cached entity record name. Returns the cached name if available, or undefined if not cached. Use this for synchronous contexts (like template rendering) where you can't await GetEntityRecordName().

      Parameters

      • entityName: string

        The name of the entity

      • compositeKey: CompositeKey

        The primary key value(s) for the record

      • OptionalloadIfNeeded: boolean

        If set to true, will load from database if not already cached

      Returns Promise<string>

      The cached display name, or undefined if not in cache

    • Creates a new instance of a BaseEntity subclass for the specified entity and calls NewRecord() to initialize it. The UUID will be automatically generated for non-auto-increment uniqueidentifier primary keys.

      Type Parameters

      Parameters

      • entityName: string

        The name of the entity to create (e.g., "Users", "Customers")

      • OptionalcontextUser: UserInfo

        Optional context user for permissions (mainly used server-side)

      Returns Promise<T>

      Promise resolving to the newly created entity instance with NewRecord() already called

    • Creates a new instance of a BaseEntity subclass and loads an existing record using the provided key.

      Type Parameters

      Parameters

      • entityName: string

        The name of the entity to create (e.g., "Users", "Customers")

      • loadKey: CompositeKey

        CompositeKey containing the primary key value(s) to load

      • OptionalcontextUser: UserInfo

        Optional context user for permissions (mainly used server-side)

      Returns Promise<T>

      Promise resolving to the entity instance with the specified record loaded

      Error if the record cannot be found or loaded

    • Returns the Name of the specific recordId for a given entityName. This is done by looking for the IsNameField within the EntityFields collection for a given entity. If no IsNameField is found, but a field called "Name" exists, that value is returned. Otherwise null returned

      Parameters

      • entityName: string
      • compositeKey: CompositeKey
      • OptionalcontextUser: UserInfo

        optional user context for permissions

      • OptionalforceRefresh: boolean

        if true, bypasses cache and fetches fresh from database

      Returns Promise<string>

      the name of the record

    • Returns the timestamp of the local cached version of a given datasetName or null if there is no local cache for the specified dataset

      Parameters

      • datasetName: string

        the name of the dataset to check

      • OptionalitemFilters: DatasetItemFilterType[]

        optional filters to apply to the dataset

      Returns Promise<Date>

    • Returns a list of dependencies - records that are linked to the specified Entity/RecordID combination. A dependency is as defined by the relationships in the database. The MemberJunction metadata that is used for this simply reflects the foreign key relationships that exist in the database. The CodeGen tool is what detects all of the relationships and generates the metadata that is used by MemberJunction. The metadata in question is within the EntityField table and specifically the RelatedEntity and RelatedEntityField columns. In turn, this method uses that metadata and queries the database to determine the dependencies. To get the list of entity dependencies you can use the utility method GetEntityDependencies(), which doesn't check for dependencies on a specific record, but rather gets the metadata in one shot that can be used for dependency checking.

      Parameters

      • entityName: string

        the name of the entity to check

      • CompositeKey: CompositeKey

        the compositeKey for the record to check

      Returns Promise<RecordDependency[]>

    • This method will merge two or more records based on the request provided. The RecordMergeRequest type you pass in specifies the record that will survive the merge, the records to merge into the surviving record, and an optional field map that can update values in the surviving record, if desired. The process followed is:

      1. A transaction is started
      2. The surviving record is loaded and fields are updated from the field map, if provided, and the record is saved. If a FieldMap not provided within the request object, this step is skipped.
      3. For each of the records that will be merged INTO the surviving record, we call the GetEntityDependencies() method and get a list of all other records in the database are linked to the record to be deleted. We then go through each of those dependencies and update the link to point to the SurvivingRecordID and save the record.
      4. The record to be deleted is then deleted.
      5. The transaction is committed if all of the above steps are succesful, otherwise it is rolled back.

      The return value from this method contains detailed information about the execution of the process. In addition, all attempted merges are logged in the RecordMergeLog and RecordMergeDeletionLog tables.

      Parameters

      Returns Promise<RecordMergeResult>

    • Stores a record name in the cache for later synchronous retrieval via GetCachedRecordName(). Called automatically by BaseEntity after Load(), LoadFromData(), and Save() operations.

      Parameters

      • entityName: string

        The name of the entity

      • compositeKey: CompositeKey

        The primary key value(s) for the record

      • recordName: string

        The display name to cache

      Returns void