Repository for accessing problems from registered providers.

The repository is the primary interface for consumers to interact with problems. It provides a unified API for querying, counting, and retrieving problems from registered ProblemProviders.

Packages register their providers with the repository during initialization. Consumers then use the repository's query methods rather than interacting with providers directly.

Example

Registering a provider

const repository = platform.get(PlatformServiceName.ProblemRepository);
repository.registerProvider(new EmailProblemProvider());

Example

Fetching problems from a provider

const repository = platform.get(PlatformServiceName.ProblemRepository);
const problems = await repository.getProblems('email-integration', {
severity: ProblemSeverity.Critical
});

Example

Getting actions for a problem

const problem = await repository.get('email-integration', 'prob-123');
const provider = repository.getProvider(problem.providerId);
const actions = provider.getActions(problem);

See

ProblemProvider for the provider interface

Hierarchy

  • ProblemRepository

Methods

  • Retrieves a specific problem by provider and problem id.

    Returns

    A promise resolving to the problem if found, undefined otherwise.

    Throws

    Error if no provider with the given id is registered.

    Parameters

    • providerId: string

      The id of the provider that owns the problem.

    • problemId: string

      The id of the problem within that provider.

    Returns Promise<Problem<unknown>>

  • Returns the count of problems from a provider.

    More efficient than fetching all problems when only the count is needed.

    Returns

    A promise resolving to the count.

    Throws

    Error if no provider with the given id is registered.

    Parameters

    • providerId: string

      The provider id to query.

    • Optional options: ProblemQueryOptions

      Optional filtering options.

    Returns Promise<number>

  • Fetches problems from a provider matching the query options.

    Returns

    A promise resolving to an array of problems.

    Throws

    Error if no provider with the given id is registered.

    Example

    const emailProblems = await repository.getProblems('email-integration');

    const criticalProblems = await repository.getProblems(
    'email-integration',
    { severity: ProblemSeverity.Critical }
    );

    Parameters

    • providerId: string

      The provider id to query.

    • Optional options: ProblemQueryOptions

      Optional filtering and pagination options.

    Returns Promise<Problem<unknown>[]>

  • Returns a specific provider by its id.

    Returns

    The provider if found, undefined otherwise.

    Parameters

    • id: string

      The unique identifier of the provider.

    Returns ProblemProvider

  • Returns all registered providers.

    Useful for displaying provider information in the UI, such as provider titles and icons for filtering.

    Returns

    An array of all registered providers.

    Returns ProblemProvider[]

  • Registers a problem provider with the repository.

    The provider's id must be unique. Registering a provider with an id that already exists will throw an error.

    Throws

    Error if a provider with the same id is already registered.

    Parameters

    • provider: ProblemProvider

      The provider to register. Must have a unique id.

    Returns void