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 Authorizations(): AuthorizationInfo[];
    get ConfigData(): ProviderConfigDataBase<any>;
    get CurrentUser(): UserInfo;
    get DatabaseConnection(): any;
    get Entities(): EntityInfo[];
    get LatestLocalMetadata(): MetadataInfo[];
    get LatestRemoteMetadata(): MetadataInfo[];
    get Libraries(): LibraryInfo[];
    get LocalStorageProvider(): ILocalStorageProvider;
    get ProviderType(): ProviderType;
    get Queries(): QueryInfo[];
    get QueryCategories(): QueryCategoryInfo[];
    get QueryEntities(): QueryEntityInfo[];
    get QueryFields(): QueryFieldInfo[];
    get QueryParameters(): QueryParameterInfo[];
    get QueryPermissions(): QueryPermissionInfo[];
    get Roles(): RoleInfo[];
    get RowLevelSecurityFilters(): RowLevelSecurityFilterInfo[];
    get VisibleExplorerNavigationItems(): ExplorerNavigationItem[];
    CacheDataset(datasetName, itemFilters, dataset): Promise<void>;
    CheckToSeeIfRefreshNeeded(providerToUse?): Promise<boolean>;
    ClearDatasetCache(datasetName, itemFilters?): Promise<void>;
    Config(configData, providerToUse?): Promise<boolean>;
    CreateTransactionGroup(): Promise<TransactionGroupBase>;
    GetAndCacheDatasetByName(datasetName, itemFilters?, contextUser?): Promise<DatasetResultType>;
    GetCachedDataset(datasetName, itemFilters?): Promise<DatasetResultType>;
    GetDatasetByName(datasetName, itemFilters?, contextUser?, providerToUse?): Promise<DatasetResultType>;
    GetDatasetCacheKey(datasetName, itemFilters?): string;
    GetDatasetStatusByName(datasetName, itemFilters?, contextUser?, providerToUse?): Promise<DatasetStatusResultType>;
    GetEntityDependencies(entityName): Promise<EntityDependency[]>;
    GetEntityObject<T>(entityName, contextUser?): Promise<T>;
    GetEntityObject<T>(entityName, loadKey, contextUser?): Promise<T>;
    GetEntityRecordName(entityName, compositeKey, contextUser?): Promise<string>;
    GetEntityRecordNames(info, contextUser?): Promise<EntityRecordNameResult[]>;
    GetLocalDatasetTimestamp(datasetName, itemFilters?): Promise<Date>;
    GetRecordDependencies(entityName, CompositeKey): Promise<RecordDependency[]>;
    GetRecordDuplicates(params, contextUser?): Promise<PotentialDuplicateResponse>;
    GetRecordFavoriteStatus(userId, entityName, CompositeKey, contextUser?): Promise<boolean>;
    IsDatasetCacheUpToDate(datasetName, itemFilters?): Promise<boolean>;
    IsDatasetCached(datasetName, itemFilters?): Promise<boolean>;
    LocalMetadataObsolete(type?): boolean;
    MergeRecords(request, contextUser?, options?): Promise<RecordMergeResult>;
    Refresh(providerToUse?): Promise<boolean>;
    RefreshIfNeeded(providerToUse?): Promise<boolean>;
    RefreshRemoteMetadataTimestamps(providerToUse?): Promise<boolean>;
    RemoveLocalMetadataFromStorage(): Promise<void>;
    SaveLocalMetadataToStorage(): Promise<void>;
    SetRecordFavoriteStatus(userId, entityName, CompositeKey, isFavorite, contextUser): Promise<void>;
}

Implemented by

Accessors

Methods

  • Stores a dataset in the local cache. If itemFilters are provided, the combination of datasetName and the filters are used to build a key and determine a match in the cache

    Parameters

    Returns Promise<void>

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

  • Gets a database by name, if required, and caches it in a format available to the client (e.g. IndexedDB, LocalStorage, File, etc). The cache method is Provider specific If itemFilters are provided, the combination of datasetName and the filters are used to determine a match in the cache

    Parameters

    Returns Promise<DatasetResultType>

  • 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")

    • Optional contextUser: 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

    • Optional contextUser: UserInfo

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

    Returns Promise<T>

    Promise resolving to the entity instance with the specified record loaded

    Throws

    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

    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

    • Optional itemFilters: 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 routine checks to see if the local cache version of a given datasetName/itemFilters combination is up to date with the server or not

    Parameters

    Returns Promise<boolean>

  • Determines if a given datasetName/itemFilters combination is cached locally or not

    Parameters

    Returns Promise<boolean>

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