Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.2 KB
Raw Blame
export type ProjectBroadcastMessage = {
  type: string;
  projectId: string;
  taskId?: string;
  tasks?: Array<{ id: string; position: number; status?: string }>;
  sourceTaskId?: string;
  targetTaskId?: string;
  linksChanged?: boolean;
  taskTitleChanged?: boolean;
};

export type BroadcastMessage = {
  projectId: string;
  message: ProjectBroadcastMessage;
  excludeInitiatorId?: string;
  authorizationBatch?: string;
};

export type UserBroadcastMessage = {
  type: string;
  [key: string]: unknown;
};

export type UserBroadcast = {
  userId: string;
  message: UserBroadcastMessage;
  origin?: string;
};

export type BroadcastAdapter = {
  /** Publish a message to all instances watching this project */
  publish(msg: BroadcastMessage): Promise<void>;

  publishToUser(msg: UserBroadcast): Promise<void>;

  /** Subscribe to messages for delivery to local connections */
  subscribe(
    handler: (msg: BroadcastMessage) => void | Promise<void>,
  ): Promise<void>;

  subscribeToUser(
    handler: (msg: UserBroadcast) => void | Promise<void>,
    onRecovery?: () => Promise<void>,
  ): Promise<void>;

  /** Cleanup on shutdown */
  shutdown(): Promise<void>;
};