/**
 * Shared types for Salesforce Pub/Sub API client
 *
 * These types are used by both CDC (Change Data Capture) and Platform Event subscribers.
 */

/**
 * Callback signature for Pub/Sub event subscriptions
 */
export type PubSubCallback = (
  subscription: { topicName?: string },
  callbackType: string,
  data: unknown
) => void | Promise<void>;

/**
 * Pub/Sub client interface
 */
export interface PubSubClient {
  connect(): Promise<void>;
  subscribe(topic: string, cb: PubSubCallback, numRequested?: number): Promise<void>;
  close(): Promise<void>;
}

/**
 * Constructor type for Pub/Sub client
 */
export type PubSubClientConstructor = new (opts: {
  authType: string;
  accessToken: string;
  instanceUrl: string;
  pubSubEndpoint: string;
}) => PubSubClient;

/**
 * CDC ChangeEventHeader structure
 */
export interface ChangeEventHeader {
  recordIds?: unknown;
  changedFields?: unknown;
  entityName?: unknown;
  changeType?: unknown;
}
