Dossier API – getChangelogEvents and getChangelogEventsTotalCount

getChangelogEvents is used to get events that are generated as a side effect of making changes to Dossier. getChangelogEventsTotalCount is used to get the total number of events matching the query.

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

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

interface DossierClient {
getChangelogEvents(
query?: ChangelogEventQuery,
paging?: Paging,
): PromiseResult<
Connection<Edge<ChangelogEvent, "Generic">> | null,
"BadRequest" | "NotAuthorized" | "Generic"
>;

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

type EventType =
| "createPrincipal"
| "createEntity"
| "createAndPublishEntity"
| "updateEntity"
| "updateAndPublishEntity"
| "publishEntities"
| "unpublishEntities"
| "archiveEntity"
| "unarchiveEntity"
| "updateSchema";

interface ChangelogEventSharedQuery {
createdBy?: string;
entity?: EntityReference;
types?: EventType[];
}

interface ChangelogEventQuery extends ChangelogEventSharedQuery {
reverse?: boolean;
}

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

interface EventShared<TEventType extends EventType> {
id: string;
type: TEventType;
createdAt: Date;
createdBy: string;
}

type ChangelogEvent =
| CreatePrincipalChangelogEvent
| SchemaChangelogEvent
| EntityChangelogEvent;

type CreatePrincipalChangelogEvent = EventShared<"createPrincipal">;

interface SchemaChangelogEvent extends EventShared<"updateSchema"> {
version: number;
}

interface EntityChangelogEvent
extends EventShared<
| "createEntity"
| "createAndPublishEntity"
| "updateEntity"
| "updateAndPublishEntity"
| "publishEntities"
| "unpublishEntities"
| "archiveEntity"
| "unarchiveEntity"
> {
entities: {
id: string;
version: number;
type: string;
name: string;
}[];
unauthorizedEntityCount: number;
}

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;
}