Skip to content
63 changes: 49 additions & 14 deletions source/event_hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,37 @@ import {
} from "./error";
import { Data } from "./types";

export interface EventPayload {
type BaseActionData = {
selection: Array<{
entityId: string;
entityType: string;
}>;
};

type BaseEventPayload = {
target: string;
inReplyToEvent: string;
topic: string;
source: EventSource;
data: EventData;
id: string;
}
};

export interface EventSource {
clientToken: string;
applicationId: string;
user: {
username: string;
id: string;
};
id: string;
}
export type ActionDiscoverEventPayload = BaseEventPayload & {
topic: "ftrack.action.discover";
data: BaseActionData;
};

export type ActionLaunchEventData = BaseActionData & {
actionIdentifier: string;
description: string;
label: string;
};

export interface EventData {
export type ActionLaunchEventPayload = BaseEventPayload & {
topic: "ftrack.action.launch";
data: ActionLaunchEventData;
};

export interface UpdateEventData {
entities: EventEntity[];
pushToken: string;
parents: string[];
Expand All @@ -41,6 +52,30 @@ export interface EventData {
clientToken: string;
}

export type UpdateEventPayload = BaseEventPayload & {
topic: "ftrack.update";
data: UpdateEventData;
};

export type EventPayload =
| ActionLaunchEventPayload
| ActionDiscoverEventPayload
| UpdateEventPayload
| {
topic: unknown;
data: unknown;
};

export interface EventSource {
clientToken: string;
applicationId: string;
user: {
username: string;
id: string;
};
id: string;
}

export interface EventEntity {
entity_type: string;
keys: string[];
Expand Down