@hoover-institution/hubspot-lib
Version:
A toolkit for deep integration with HubSpot's Marketing Events API with a plugin-based architecture.
53 lines (47 loc) • 1.52 kB
TypeScript
// types/pluginRegistry.d.ts
/**
* Registers a plugin handler for a given hook point and bitmask.
*
* @param hookPoint - The event/hook name (e.g. "CREATE_EVENT")
* @param bitmask - A unique numeric plugin ID (bitmask flag)
* @param fn - The handler function to register
* @param options - Optional config including:
* - override: allow replacing an existing handler
* - pluginName: human-readable name for the plugin (used in reverse lookup)
*/
export function registerPlugin(
hookPoint: string,
bitmask: number,
fn: (payload: any) => any,
options?: {
override?: boolean;
pluginName?: string;
}
): void;
/**
* Retrieves all registered handlers for a given hook point.
*
* @param hookPoint - The event/hook name
* @returns A map of bitmask values to handler functions
*/
export function getHandlers(
hookPoint: string
): Record<number, (payload: any) => any>;
/**
* Retrieves the plugin name associated with a given bitmask.
*
* @param bitmask - The plugin's unique numeric ID
* @returns The plugin name, or fallback like "PLUGIN_8"
*/
export function getPluginName(bitmask: number): string;
/**
* Retrieves the bitmask associated with a plugin name.
*
* @param pluginName - The name of the plugin (e.g. "MONGO_SYNC")
* @returns The bitmask value, or undefined if not found
*/
export function getPluginId(pluginName: string): number | undefined;
/**
* Returns a combined bitmask representing all registered plugin IDs.
*/
export function getAllPluginBitmask(): number;