import { FilterPredicate } from '@bootkit/ng1/common'; import * as _angular_core from '@angular/core'; import * as rxjs from 'rxjs'; import { Observable } from 'rxjs'; import * as _bootkit_ng1_data from '@bootkit/ng1/data'; /** * DataRequest class represents a request for data with pagination, filtering, sorting, and field selection. * It is used to encapsulate the parameters needed to fetch data from a data source. * It can be used with various data sources such as HTTP services, in-memory arrays, etc. * */ declare class DataRequest { page?: DataRequestPage; filters?: DataRequestFilter[]; sort?: DataRequestSort; select?: string[]; computeTotal?: boolean; constructor(options?: { page?: DataRequestPage; filters?: DataRequestFilter[]; sort?: DataRequestSort; select?: string[]; computeTotal?: boolean; }); } /** * Represents a data request page. */ interface DataRequestPage { /** * Zero-based index of the page. */ index: number; /** * Size of the page, i.e., number of items in each page. */ size: number; } /** * Represents a sorting option in a DataRequest. * @property field The field to sort by. * @property asc Whether to sort in ascending order. */ interface DataRequestSort { field: string; asc?: boolean; } /** * Represents a filter in a DataRequest. */ interface DataRequestFilter { /** * The field to filter by. * It can be a string representing the property name of the data items. */ field?: string; /** * The value to filter by. * It can be a string, number, or any other type depending on the field. */ value?: string; /** * The operator to use for filtering. * It can be one of the standard filter operators like Contains, StartsWith, EndsWith, Equals, etc. */ operator?: string; /** * Indicates if the filter is case-sensitive. only for text columns. * Default is false. */ caseSensitive?: boolean; /** * A custom filter function to apply for filtering. */ filterBy?: FilterPredicate; } declare class DataResult { readonly data: T[]; readonly total?: number | undefined; constructor(data: T[], total?: number | undefined); } /** * DataLoader is a function that takes a DataRequest and returns an Observable of DataResult. * It is used by RemoteDataSource to load data asynchronously. */ type DataLoader = (request: DataRequest) => Observable>; /** * Abstract base class for data sources. * This class provides a common interface for loading data from various sources. */ declare abstract class DataSource { abstract readonly type: 'local' | 'remote'; protected _isLoading: _angular_core.WritableSignal; /** * Indicates whether the data source is currently loading data. */ isLoading: _angular_core.Signal; constructor(); /** * Loads data from the data source. * @param request The data request object containing pagination, sorting, and filtering information. */ abstract load(request: DataRequest): Observable; } /** * DataSourceLike is a type that can be used to represent any data source * that can be used with the table, autocomplete, dropdown and any component that requires data. * It can be an array of data, a function that returns an observable of data, * or an instance of DataSource. */ type DataSourceLike = Array | DataLoader | DataSource | Record | // enum: extract enum or object values undefined | null; /** * Converts a DataSourceLike to a DataSource instance. * @param source The data source to convert. * @returns A DataSource instance. */ declare function dataSourceAttribute(source: DataSourceLike): DataSource; /** * RemoteDataSource is a DataSource that loads data asynchronously using a DataLoader function. * It is used to fetch data from a remote source, such as an API. */ declare class RemoteDataSource extends DataSource { private readonly loader; readonly type = "remote"; constructor(loader: DataLoader); load(request: DataRequest): Observable<_bootkit_ng1_data.DataResult>; } /** * An implementation of DataSource that uses an array as the data source. * This is useful for static data or when you want to manage the data manually. */ declare class LocalDataSource extends DataSource { private items; readonly type = "local"; /** * Creates a new LocalDataSource. * @param items The array of items to be used as the data source. */ constructor(items: any[]); /** * Creates a LocalDataSource from enum values. * @param enumClass The enum class to extract values from. * @returns A LocalDataSource containing the enum values. */ static fromEnum(enumClass: Record): LocalDataSource; /** * Loads data from the local array based on the provided DataRequest. * @param request The DataRequest containing filtering, sorting, and pagination information. * @returns An observable of DataResult containing the requested data. */ load(request: DataRequest): rxjs.Observable>; } declare function toDataResult(dr: DataRequest): (source: Observable) => Observable>; /** * LogicalOperator is a list of predefined logical operators that can be used in data requests to filter data. */ type LogicalOperator = 'contains' | 'endsWith' | 'startsWith' | 'like' | 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; export { DataRequest, DataResult, DataSource, LocalDataSource, RemoteDataSource, dataSourceAttribute, toDataResult }; export type { DataLoader, DataRequestFilter, DataRequestPage, DataRequestSort, DataSourceLike, LogicalOperator };