declare module '@jpmorganchase/perspective' { /**** object types ****/ export const enum TypeNames { STRING = 'string', FLOAT = 'float', INTEGER = 'integer', BOOLEAN = 'boolean', DATE = 'date' } export type ValuesByType = { [ key in TypeNames ]: Array } export type ValueByType = { TypeNames: Array } export const enum SortOrders { ASC = 'asc', ASC_ABS = 'asc abs', DESC = 'desc', DESC_ABS = 'desc abs', NONE = 'none', } export const enum NumericRelation { GT = '>', LT = '<', EQ = '==', NEQ = '!=', GTE = '>=', LTE = '<=', NAN = 'is nan', NOT_NAN = 'is not nan', } enum NUMBER_AGGREGATES { ANY = 'any', AVERAGE = 'avg', COUNT = 'count', DISTINCT_COUNT = 'distinct count', DOMINANT = 'dominant', FIRST = 'first', LAST = 'last', HIGH = 'high', LOW = 'low', MEAN = 'mean', MEAN_COUNT = 'mean by count', MEDIAN = 'median', PCT_SUM_PARENT = 'pct sum parent', PCT_SUM_TOTAL = 'pct sum grand total', SUM = 'sum', SUM_ABS = 'sum abs', SUM_NOT_NULL = 'sum not null', UNIQUE = 'unique' } enum STRING_AGGREGATES { ANY = 'any', COUNT = 'count', DISTINCT_COUNT = 'distinct count', DISTINCT_LEAF = 'distinct leaf', DOMINANT = 'dominant', FIRST = 'first', LAST = 'last', MEAN_COUNT = 'mean by count', UNIQUE = 'unique' } enum BOOLEAN_AGGREGATES { AND = 'and', ANY = 'any', COUNT = 'count', DISTINCT_COUNT = 'distinct count', DISTINCT_LEAF = 'distinct leaf', DOMINANT = 'dominant', FIRST = 'first', LAST = 'last', MEAN_COUNT = 'mean by count', OR ='or', UNIQUE = 'unique' } /**** Schema ****/ type SchemaType = TypeNames | NUMBER_AGGREGATES | STRING_AGGREGATES | BOOLEAN_AGGREGATES; export type Schema = { [ key: string ]: TypeNames ; } /**** Flat result ****/ export type FlatOptions = { row_depth?: number; col_depth?: number; start_row?: number; start_col?: number; } export type FlatResult = { row_spans: any[][]; col_spans: any[][]; data: any[][]; } /**** View ****/ export type View = { delete(): Promise; num_columns(): Promise; expand_to_depth(depth: number, column: boolean | undefined): void; collapse_to_depth(depth: number, column: boolean | undefined): void; num_rows(): Promise; on_update(callback: UpdateCallback): void; on_delete(callback: Function): void; schema(): Promise; to_json(): Promise>; to_flat(options: FlatOptions): Promise; to_csv(): Promise; } /**** Table ****/ export type UpdateCallback = (data: Array) => void export type TableData = string | Array | { [key: string]: Array } | { [key: string]: string } export type TableOptions = { index: string } export type AggregateConfig = { column: string | Array; op: string; //NUMBER_AGGREGATES | STRING_AGGREGATES | BOOLEAN_AGGREGATES; name?: string; }; export type ViewConfig = { row_pivot?: Array; column_pivot?: Array; sort?: Array<[number, SortOrders]>; filter?: Array>; aggregate?: Array; }; export type Table = { add_computed(computed: Array): Table; columns(): Array; delete(): Promise; on_delete(callback: Function): void; schema(): Promise; size(): Promise; update(data: TableData): void; view(config: ViewConfig): View; } /**** perspective ****/ export enum PerspectiveEvents { PERSPECTIVE_READY = 'perspective-ready' } export type PerspectiveWorker = { table(data: TableData, options?: TableOptions): Table; } type perspective = { TYPE_AGGREGATES: ValuesByType, TYPE_FILTERS: ValuesByType, AGGREGATE_DEFAULTS: ValueByType, FILTER_DEFAULTS: ValueByType, SORT_ORDERS: SortOrders, table(): Table, worker(): PerspectiveWorker } const impl: perspective; export default impl; }