Dossier API – getEntities and getEntitiesTotalCount

getEntities is used to search content. getEntitiesTotalCount is used to get the total number of entities matching the query.

An optional query argument can be used to filter the content and control the sort order.

The result is a connection which represents a page of entities. An optional paging argument can be used to control the paging.

interface DossierClient {
getEntities(
query?: EntityQuery,
paging?: Paging,
): PromiseResult<
Connection<Edge<Entity, ErrorType>> | null,
"BadRequest" | "NotAuthorized" | "Generic"
>;

getEntitiesTotalCount(
query?: EntitySharedQuery,
): PromiseResult<number, "BadRequest" | "NotAuthorized" | "Generic">;
}

interface EntitySharedQuery {
authKeys?: string[];
entityTypes?: string[];
componentTypes?: string[];
status?: EntityStatus[];
valid?: boolean;
linksTo?: EntityReference;
linksFrom?: EntityReference;
boundingBox?: BoundingBox;
text?: string;
}

interface EntityQuery extends EntitySharedQuery {
order?: EntityQueryOrder;
reverse?: boolean;
}

type EntityQueryOrder = "createdAt" | "updatedAt" | "name";

interface Paging {
first?: number;
after?: string;
last?: number;
before?: string;
}

interface Connection<T extends Edge<unknown, ErrorType>> {
pageInfo: PageInfo;
edges: T[];
}

interface Edge<TOk, TError extends ErrorType> {
node: Result<TOk, TError>;
cursor: string;
}

interface PageInfo {
hasPreviousPage: boolean;
hasNextPage: boolean;
startCursor: string;
endCursor: string;
}