import type { Store } from '@reduxjs/toolkit'; import type { BroadcastEventCallback, BroadcastEventArgs, ExtendableDataSourceDefinition, PresetUtility, RootDataSourcesDefinition, IDataSourceRegistry, SearchCountsInfo } from '@splunk/dashboard-types'; import DataSourceController, { type ControlOptionTypes } from './DataSourceController'; import RiskyCommandController from './RiskyCommandController'; type DataSourceContext = Record; /** * A module that create reuseable DataSource controller */ declare class DataSourceRegistry implements IDataSourceRegistry { definition: Record; preset: PresetUtility; store: Store; dataSourceContext?: DataSourceContext; controllers: Record; riskyCommandController: RiskyCommandController; broadcastCallback: BroadcastEventCallback; /** * Creates a registry for data source controllers and initializes * default event broadcasting behavior. * * @param args - Constructor arguments. * @param args.preset - Preset utility used to resolve data source metadata. * @param args.dataSourceContext - Optional shared context passed to controllers. */ constructor({ preset, dataSourceContext, }: { preset: PresetUtility; dataSourceContext?: DataSourceContext; }); /** * Updates the shared context used for newly allocated data source controllers. * * @param ctx - Arbitrary runtime context for data sources. */ setDataSourceContext(ctx: DataSourceContext): void; /** * Replaces the preset utility used by this registry. * * @param preset - Preset utility containing data source type definitions. */ setPreset(preset: PresetUtility): void; /** * Subscribes the registry to a Redux store for event dispatching. * * @param store - Redux store used to dispatch data source events. */ subscribeToStore(store: Store): void; /** * Replaces the data source definition map and selectively reallocates * base/chain data source controllers that changed and are active in chain usage. * * @param args - Update arguments. * @param args.definition - New root data source definition map. * @param args.consumersInLayout - Optional set of consumer IDs currently in layout. */ updateDefinition({ definition, consumersInLayout, }: { definition: RootDataSourcesDefinition; consumersInLayout?: string[]; }): void; /** * Returns an existing controller matching the data source definition hash, * or allocates and wires a new one. * * @param args - Allocation arguments. * @param args.dataSourceId - Data source identifier to allocate. * @returns Matching or newly created data source controller. */ allocate: ({ dataSourceId, }: { dataSourceId: string; }) => DataSourceController; /** * Looks up the definition for a data source and throws if it is missing/empty. * * @param dataSourceId - Data source identifier to resolve. * @returns Resolved data source definition. */ private getDataSourceDefOrThrow; /** * Instantiates a new data source controller and attaches teardown/event handlers. * * @param dataSourceId - Data source identifier for the controller. * @param dataSourceDef - Data source definition used to construct the controller. * @param key - Definition hash key used by the registry cache. * @returns Newly constructed data source controller. */ private createDataSourceController; /** * Applies base/chain relationship setup rules to a new controller. * * @param newController - Newly allocated controller instance. * @param dataSourceId - Data source identifier for the controller. * @param dataSourceDef - Definition associated with the controller. */ private setupControllerRelationships; /** * Sets base chain model and reparents active chain controllers to this base. * * @param newController - Base data source controller. * @param dataSourceId - Base data source identifier. */ private setupBaseDataSourceController; /** * Validates and wires a chain data source to its parent/base relationships. * * @param newController - Chain data source controller. * @param dataSourceId - Chain data source identifier. * @param dataSourceDef - Chain data source definition. */ private setupChainDataSourceController; /** * Finds or allocates the parent controller for a chain data source. * Also handles the single-subscription cancellation override edge case. * * @param dataSourceId - Chain data source identifier being allocated. * @param parentDataSourceId - Parent data source identifier from `extend`. * @returns Parent controller for the chain data source. */ private getOrAllocateParentControllerForChainDataSource; /** * Reparents active chain controllers to a new parent controller and * resubscribes them to parent updates. * * @param parentDataSourceId - Identifier whose chain descendants should be updated. * @param parentController - Controller that should become the new parent. */ private reparentChainControllers; /** * Recomputes and updates the base chain model for a chain data source's base, * when both base ID and base controller are available. * * @param dataSourceId - Chain data source identifier. */ private refreshBaseChainModelForChainDataSource; /** * Returns the controller for a data source ID using the current definition hash. * * @param dataSourceId - Data source identifier to resolve. * @returns Matching controller if present, otherwise `undefined`. */ getDataSourceController: (dataSourceId: string) => DataSourceController | undefined; /** * Removes a controller entry from the registry cache. * * @param key - Controller cache key (definition hash). */ handleDataSourceTeardown: (key: number) => void; /** * Pauses all controllers or a filtered set of controllers by data source ID. * * @param dataSourceIds - Optional data source IDs to pause; all if omitted. * @param options - Optional pause control flags. * @param options.checkIfInUse - When true, skip pausing if controller is in use. * @returns Promise resolving to settled results for each pause attempt. */ pauseDataSources: (dataSourceIds?: string[], { checkIfInUse }?: ControlOptionTypes) => Promise[]>; /** * Resumes all controllers or a filtered set of controllers by data source ID. * * @param dataSourceIds - Optional data source IDs to resume; all if omitted. * @returns Promise resolving to settled results for each resume attempt. */ resumeDataSources: (dataSourceIds?: string[]) => Promise[]>; /** * Broadcasts a data source event through the configured callback. * * @param event - Event payload emitted by a controller. */ broadcastDataSourceEvent: (event: BroadcastEventArgs) => void; /** * Registers a callback used to broadcast data source events. * * @param callback - Event broadcast handler. */ onEventBroadcast: (callback: BroadcastEventCallback) => void; /** * Captures last-known subscription state for all active controllers. * * @returns Snapshot keyed by controller ID and additional data source IDs. */ snapshot(): Record>; /** * Returns active chain controllers currently extending a parent data source. * * @param parentDataSourceId - Parent data source identifier. * @returns Map of child data source ID to active controller. */ getActiveChainControllers(parentDataSourceId: string): Record; /** * Validates that a chain data source has a valid parent path and respects * chain constraints (no cycles, max depth, and allowed parent/child types). * * @param dataSourceId - Data source identifier to validate. */ dataSourceValidation(dataSourceId: string): void; /** * Returns the count of unique search jobs and their completion status. * * @returns Object with total, running, and completed counts of unique searches. */ getSearchCounts(): SearchCountsInfo; /** * Returns the registry cache of allocated controllers. * * @returns Controller cache keyed by data source definition hash. */ getDataSourceControllers(): Record; /** * Tears down all currently allocated controllers. */ teardown(): void; /** * Returns controllers directly or indirectly associated with provided IDs. * * @param dataSourceIds - Data source IDs to match against controller IDs and aliases. * @returns Matching controller instances. */ private getControllersByIds; } export default DataSourceRegistry; //# sourceMappingURL=DataSourceRegistry.d.ts.map