Returns the source for CHT data.

Error if the provided context is invalid

  • Parameters

    Returns {
        v1: {
            hasAnyPermission: ((permissionsGroupList: string[][], userRoles: string[], chtPermissionsSettings: object) => boolean);
            hasPermissions: ((permissions: string | string[], userRoles: string[], chtPermissionsSettings: object) => boolean);
            person: {
                getByType: ((personType: string) => AsyncGenerator<Person, null, unknown>);
                getByUuid: ((uuid: string) => Promise<Nullable<Person>>);
                getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PersonWithLineage>>);
                getPageByType: ((personType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Person>>);
            };
            place: {
                getByType: ((placeType: string) => AsyncGenerator<Place, null, unknown>);
                getByUuid: ((uuid: string) => Promise<Nullable<Place>>);
                getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PlaceWithLineage>>);
                getPageByType: ((placeType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Place>>);
            };
        };
    }

    the CHT datasource API

    • v1: {
          hasAnyPermission: ((permissionsGroupList: string[][], userRoles: string[], chtPermissionsSettings: object) => boolean);
          hasPermissions: ((permissions: string | string[], userRoles: string[], chtPermissionsSettings: object) => boolean);
          person: {
              getByType: ((personType: string) => AsyncGenerator<Person, null, unknown>);
              getByUuid: ((uuid: string) => Promise<Nullable<Person>>);
              getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PersonWithLineage>>);
              getPageByType: ((personType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Person>>);
          };
          place: {
              getByType: ((placeType: string) => AsyncGenerator<Place, null, unknown>);
              getByUuid: ((uuid: string) => Promise<Nullable<Place>>);
              getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PlaceWithLineage>>);
              getPageByType: ((placeType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Place>>);
          };
      }
      • hasAnyPermission: ((permissionsGroupList: string[][], userRoles: string[], chtPermissionsSettings: object) => boolean)
          • (permissionsGroupList, userRoles, chtPermissionsSettings): boolean
          • Verify if the user's role has all the permissions of any of the provided groups.

            Parameters

            • permissionsGroupList: string[][]

              {string[][]} Array of groups of permissions due to the complexity of permission grouping

            • userRoles: string[]

              {string[]} Array of user roles.

            • chtPermissionsSettings: object

              {object} Object of configured permissions in CHT-Core's settings.

            Returns boolean

      • hasPermissions: ((permissions: string | string[], userRoles: string[], chtPermissionsSettings: object) => boolean)
          • (permissions, userRoles, chtPermissionsSettings): boolean
          • Verify if the user's role has the permission(s).

            Parameters

            • permissions: string | string[]

              {string | string[]} Permission(s) to verify

            • userRoles: string[]

              {string[]} Array of user roles.

            • chtPermissionsSettings: object

              {object} Object of configured permissions in CHT-Core's settings.

            Returns boolean

      • person: {
            getByType: ((personType: string) => AsyncGenerator<Person, null, unknown>);
            getByUuid: ((uuid: string) => Promise<Nullable<Person>>);
            getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PersonWithLineage>>);
            getPageByType: ((personType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Person>>);
        }
        • getByType: ((personType: string) => AsyncGenerator<Person, null, unknown>)

          Returns a generator for fetching all people with the given type.

          InvalidArgumentError if no type is provided or if the type is not for a person

            • (personType): AsyncGenerator<Person, null, unknown>
            • Parameters

              • personType: string

                the type of people to return

              Returns AsyncGenerator<Person, null, unknown>

              a generator for fetching all people with the given type

        • getByUuid: ((uuid: string) => Promise<Nullable<Person>>)

          Returns a person by their UUID.

          Error if no UUID is provided

            • (uuid): Promise<Nullable<Person>>
            • Parameters

              • uuid: string

                the UUID of the person to retrieve

              Returns Promise<Nullable<Person>>

              the person or null if no person is found for the UUID

        • getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PersonWithLineage>>)

          Returns a person by their UUID along with the person's parent lineage.

          Error if no UUID is provided

        • getPageByType: ((personType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Person>>)

          Returns an array of people for the provided page specifications.

          InvalidArgumentError if no type is provided or if the type is not for a person

          InvalidArgumentError if the provided limit is <= 0

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

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

            • (personType, cursor?, limit?): Promise<Page<Person>>
            • Parameters

              • personType: string

                the type of people to return

              • cursor: Nullable<string> = null

                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.

              • limit: number = 100

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

              Returns Promise<Page<Person>>

              a page of people for the provided specifications

      • place: {
            getByType: ((placeType: string) => AsyncGenerator<Place, null, unknown>);
            getByUuid: ((uuid: string) => Promise<Nullable<Place>>);
            getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PlaceWithLineage>>);
            getPageByType: ((placeType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Place>>);
        }
        • getByType: ((placeType: string) => AsyncGenerator<Place, null, unknown>)

          Returns a generator for fetching all places with the given type.

          InvalidArgumentError if no type if provided or if the type is not for a place

            • (placeType): AsyncGenerator<Place, null, unknown>
            • Parameters

              • placeType: string

                the type of place to return

              Returns AsyncGenerator<Place, null, unknown>

              a generator for fetching all places with the given type

        • getByUuid: ((uuid: string) => Promise<Nullable<Place>>)

          Returns a place by its UUID.

          Error if no UUID is provided

            • (uuid): Promise<Nullable<Place>>
            • Parameters

              • uuid: string

                the UUID of the place to retrieve

              Returns Promise<Nullable<Place>>

              the place or null if no place is found for the UUID

        • getByUuidWithLineage: ((uuid: string) => Promise<Nullable<PlaceWithLineage>>)

          Returns a place by its UUID along with the place's parent lineage.

          Error if no UUID is provided

        • getPageByType: ((placeType: string, cursor?: Nullable<string>, limit?: number) => Promise<Page<Place>>)

          Returns an array of places for the provided page specifications.

          InvalidArgumentError if no type is provided or if the type is not for a place

          InvalidArgumentError if the provided limit is <= 0

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

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

            • (placeType, cursor?, limit?): Promise<Page<Place>>
            • Parameters

              • placeType: string

                the type of place to return

              • cursor: Nullable<string> = null

                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.

              • limit: number = 100

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

              Returns Promise<Page<Place>>

              a page of places for the provided specifications