@medic/cht-datasource
    Preparing search index...

    Interface Datasource

    Operations for working with targets.

    interface Datasource {
        getById: (id: string) => Promise<Nullable<Target.v1.Target>>;
        getByReportingPeriodContactIds: (
            reportingPeriod: string,
            contactIds: string | [string, ...string[]],
        ) => AsyncGenerator<Target.v1.Target, null>;
        getByReportingPeriodContactIdUsername: (
            reportingPeriod: string,
            contactId: string,
            username: string,
        ) => Promise<Nullable<Target.v1.Target>>;
        getPageByReportingPeriodContactIds: (
            reportingPeriod: string,
            contactIds: string | [string, ...string[]],
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ) => Promise<Page<Target.v1.Target>>;
    }
    Index

    Properties

    getById: (id: string) => Promise<Nullable<Target.v1.Target>>

    Returns a target by identifier.

    Type Declaration

    InvalidArgumentError if no identifier is provided

    getByReportingPeriodContactIds: (
        reportingPeriod: string,
        contactIds: string | [string, ...string[]],
    ) => AsyncGenerator<Target.v1.Target, null>

    Returns a generator for fetching all targets in the reporting period for the given contact identifiers.

    Type Declaration

      • (
            reportingPeriod: string,
            contactIds: string | [string, ...string[]],
        ): AsyncGenerator<Target.v1.Target, null>
      • Parameters

        • reportingPeriod: string

          the reporting period for the targets

        • contactIds: string | [string, ...string[]]

          the contact identifiers for the targets

        Returns AsyncGenerator<Target.v1.Target, null>

        a generator for fetching all targets with the given type

    InvalidArgumentError if no reporting period is provided

    InvalidArgumentError if no contact identifiers are provided

    getByReportingPeriodContactIdUsername: (
        reportingPeriod: string,
        contactId: string,
        username: string,
    ) => Promise<Nullable<Target.v1.Target>>

    Returns the target for the given username and reporting period.

    Type Declaration

      • (
            reportingPeriod: string,
            contactId: string,
            username: string,
        ): Promise<Nullable<Target.v1.Target>>
      • Parameters

        • reportingPeriod: string

          the reporting period for the target

        • contactId: string

          the contact identifier of the user for the target

        • username: string

          the username (without the "org.couchdb.user:" prefix) of the user for the target

        Returns Promise<Nullable<Target.v1.Target>>

        the target or null if no target is found

    InvalidArgumentError if no reporting period, contact identifier, and/or username is provided

    getPageByReportingPeriodContactIds: (
        reportingPeriod: string,
        contactIds: string | [string, ...string[]],
        cursor?: Nullable<string>,
        limit?: number | `${number}`,
    ) => Promise<Page<Target.v1.Target>>

    Returns an array of targets for the provided page specifications.

    Type Declaration

      • (
            reportingPeriod: string,
            contactIds: string | [string, ...string[]],
            cursor?: Nullable<string>,
            limit?: number | `${number}`,
        ): Promise<Page<Target.v1.Target>>
      • Parameters

        • reportingPeriod: string

          the reporting period for the targets

        • contactIds: string | [string, ...string[]]

          the contact identifiers for the targets

        • Optionalcursor: Nullable<string>

          the token identifying which page to retrieve. A null value indicates the first page should be returned. Subsequent pages can be retrieved by providing the cursor returned with the previous page.

        • Optionallimit: number | `${number}`

          the maximum number of targets to return. Default is 100.

        Returns Promise<Page<Target.v1.Target>>

        a page of targets for the provided specifications

    InvalidArgumentError if no reporting period is provided

    InvalidArgumentError if no contact identifiers are provided

    InvalidArgumentError if the provided cursor is not a valid page token or null

    InvalidArgumentError if the provided limit is <= 0

    getByReportingPeriodContactIds which provides the same data, but without having to manually account for paging