import { SortDirection } from '@angular/material/sort'; import { Observable } from 'rxjs'; import { MigImageData, Page } from 'projects/mat-image-grid-lib/src'; type UnionKeys = T extends T ? keyof T : never; type StrictUnionHelper = T extends T ? T & Partial, keyof T>, undefined>> : never; type StrictUnion = StrictUnionHelper; /** Sort direction with 'asc ' or 'desc' only */ export type SortDirectionAscDesc = Omit; /** * Type defining the sorting a column. * @template T - type defining the data of an image */ export type FieldSortDefinition = { fieldName: keyof T; sortDirection: SortDirectionAscDesc; }; /** * Definition of a simple string filter for an image. * @template T - type defining the data of an image */ export type FieldFilterDefinitionSimple = { fieldName: keyof T; value: string | number | Date; }; /** * Definition of a range filter for an image. * @template T - type defining the data of an image */ export type FieldFilterDefinitionRange = { fieldName: keyof T; valueFrom: string | number | Date; valueTo: string | number | Date; }; /** * Definition of a field to filter a list of images. * @template T - type defining the data of an image */ export type FieldFilterDefinition = StrictUnion | FieldFilterDefinitionRange>; /** * Interface defining the properties of a requests for a range of images. */ export interface RequestImagesRange { startImageIndex: number; numberOfImages: number; } /** * Interface defining the methods of a class fetching image data from a server. * @template T - type defining the data of an image */ export interface DataStoreAdapter { /** * Fetching data from the datastore respecting sorting and filtering. * @param imagesRange - range of images to get data for * @param sorts - optional array of objects with the sorting definition * @param filters - optional array of objects with the filter definition * @returns observable emitting a Page object */ getPagedData: (imagesRange: RequestImagesRange, sorts?: FieldSortDefinition[], filters?: FieldFilterDefinition[]) => Observable>; } export {};