UNPKG

@cruncher/adapter-utils

Version:

Utility functions for Cruncher adapters.

64 lines 1.86 kB
import { ControllerIndexParam, Search } from "@cruncher/qql/grammar"; import { ProcessedData } from "./logTypes"; import { z } from "zod/v4"; import { Brand } from "@cruncher/utils"; export type QueryOptions = { fromTime: Date; toTime: Date; limit: number; cancelToken: AbortSignal; onBatchDone: (data: ProcessedData[]) => void; }; export interface QueryProvider { getControllerParams(): Promise<Record<string, string[]>>; query(params: ControllerIndexParam[], searchTerm: Search, queryOptions: QueryOptions): Promise<void>; } type ObjectParam = { type: "object"; defaultValue?: object; }; type ArrayParam = { type: "array"; defaultValue?: unknown[]; }; type StringParam = { type: "string"; defaultValue?: string; }; type NumberParam = { type: "number"; defaultValue?: number; }; type BooleanParam = { type: "boolean"; defaultValue?: boolean; }; type DateParam = { type: "date"; defaultValue?: Date; }; export type Param = { name: string; description: string; } & (ObjectParam | ArrayParam | StringParam | NumberParam | BooleanParam | DateParam); export type FactoryParams = { params: Record<string, unknown>; }; export type PluginRef = Brand<string, "PluginRef">; export type ExternalAuthProvider = { getCookies(requestedUrl: string, cookies: string[], validate: (cookies: Record<string, string>) => Promise<boolean>): Promise<Record<string, string>>; }; export type AdapterContext = { externalAuthProvider: ExternalAuthProvider; }; export interface Adapter { name: string; ref: PluginRef; description: string; version: string; params: z.ZodObject; factory: (context: AdapterContext, params: FactoryParams) => QueryProvider; } export declare function newPluginRef(ref: string): PluginRef; export {}; //# sourceMappingURL=index.d.ts.map