import type { ValueOf } from './Helpers'; import type { JobStatus } from './Search'; export type TokenNamespace = string; export type TokenName = string; export type TokenValue = string | string[]; export type TokenRecord = Record; export type TokenBinding = Record; export interface ExtractedToken { namespace: string; name: string; filters: string[]; } export interface Token { token: TokenName; key?: string; value?: TokenValue; defaultValue?: TokenValue | null; } export type Tokens = Token[]; export interface SetTokenOptions { token?: TokenName; tokens?: Tokens; tokenNamespace?: TokenNamespace; key?: string; events?: string[]; fields?: string[]; } export interface ResetTokensOptions { tokenNames?: TokenName[]; tokenNamespaces?: TokenNamespace[]; events?: string[]; fields?: string[]; } export interface UnsetTokensOptions { tokenNames?: TokenName[]; tokenNamespaces?: TokenNamespace[]; events?: string[]; fields?: string[]; } export interface SetTimeRangeOptions { /** * time ranges are `$token.earliest$` and `$token.latest$` - omit the .earliest/.latest in the options */ token?: TokenName; tokenNamespace?: TokenNamespace; events: ['range.select']; } /** * Represents a TokenRecord which can store the value as TokenValue or a generic type */ export type GenericTokenRecord = Record | ValueTypes>; export type ExtendedJobStatus = JobStatus | 'inProgress' | 'cancelled'; export type JobStatusBooleans = { [status in `job.${ExtendedJobStatus}`]: boolean; }; export interface DataSourceSmartSourceTokens extends JobStatusBooleans { 'job.status': ExtendedJobStatus; 'job.messages': string[]; 'job.resultCount': number; 'job.sid': string; 'job.startTime': string; 'job.hasResults': boolean; 'job.fields': string[]; 'job.percentComplete': number; 'job.isRealTimeSearch': boolean; 'job.lastUpdated': string; [resultField: `result.${string}`]: unknown; } export type ValidSmartSource = 'ds' | 'expression' | 'eval'; export type SmartSourceTokenValue = string | boolean | number | null | SmartSourceTokenValue[] | { [key: string]: SmartSourceTokenValue; }; export type SmartSourceTokenRecord = Record; export type SmartSourceTokenState = Record; export type NullableSmartSourceTokenRecord = Record | undefined>; export type NullableSmartSourceTokenState = Record; export interface SmartSourceTokenEvent { type: 'setSmartSources'; payload: { tokens: NullableSmartSourceTokenState; source: SmartSource; }; } type SmartSourceEventFn = (payload: Payload) => Partial; export type HandledSmartSourceEvents = Record>; export type TokenState = TokenBinding | SmartSourceTokenState; export interface TokenItem { name: TokenName; namespace: TokenNamespace; value: TokenValue | SmartSourceTokenValue; } export type TokenCategory = 'dashboard' | 'search' | 'environment' | 'expression'; export interface TokenMatch extends ExtractedToken, TokenItem { match: string; start: number; end: number; } export type TokenMap = T extends string ? TokenMatch[] : T extends object ? { [K in keyof T]: TokenMap; } : unknown extends T ? { [key: string]: TokenMap; } : null; export {}; //# sourceMappingURL=Token.d.ts.map