import DataSource from "./DataSource"; import LRU from "lru-cache"; import { JsonQLQuery } from "@mwater/jsonql"; import { Row } from "./types"; /** Caching data source for mWater. Requires jQuery. require explicitly: require('@mwater/expressions/lib/MWaterDataSource') */ export default class MWaterDataSource extends DataSource { apiUrl: string; client: string | null | undefined; cacheExpiry: number; options: { serverCaching?: boolean; localCaching?: boolean; imageApiUrl?: string; source?: string; }; cache?: LRU; origin: string | undefined; /** * @param apiUrl * @param options serverCaching: allows server to send cached results. default true * localCaching allows local MRU cache. default true * imageApiUrl: overrides apiUrl for images */ constructor(apiUrl: string, client?: string | null, /** * @param options Configuration options * @param options.serverCaching Allows server to send cached results. Default true. * @param options.localCaching Allows local MRU cache. Default true. * @param options.imageApiUrl Overrides apiUrl for images. * @param options.origin Origin of usage. e.g. "dashboards:43445364..." */ options?: { serverCaching?: boolean; localCaching?: boolean; imageApiUrl?: string; origin?: string; }); performQuery(query: JsonQLQuery): Promise; performQuery(query: JsonQLQuery, cb: (error: any, rows: Row[]) => void): void; getCacheExpiry(): number; clearCache(): void; /** Get the url to download an image (by id from an image or imagelist column) * Height, if specified, is minimum height needed. May return larger image */ getImageUrl(imageId: string, height?: number): string; /** Get the url to upload an image (by id from an image or imagelist column) POST to upload */ getImageUploadUrl(imageId: string): string; /** Get the url to download a file (by id from a file or filelist column). * filename optionally overrides the downloaded filename. */ getFileUrl(fileId: string, filename?: string): string; /** Get the url to upload a file (by id from a file or filelist column). POST to upload. */ getFileUploadUrl(fileId: string): string; }