UNPKG

@controladad/ng-base

Version:
63 lines (62 loc) 2.12 kB
import { Observable } from 'rxjs'; import * as i0 from "@angular/core"; export interface StrapiOptions { search?: StrapiSearch[]; sort?: StrapiSort[]; pagination?: { page: number; perPage: number; }; filters?: StrapiFilter[]; } export interface StrapiSearch { strategy?: 'eq' | 'contains' | 'lte' | 'gte' | 'notNull' | 'null'; key: string; term: string; operator?: 'or' | 'and'; customKeyUsed?: boolean; } export interface StrapiSort { key: string; direction: 'asc' | 'desc'; customKeyUsed?: boolean; } export interface StrapiFilter { key: string; terms?: string | string[]; strategy?: 'eq' | 'ne' | 'in' | 'gte' | 'lte' | 'notNull' | 'null'; andConditionParam?: string; } export interface StrapiSingleResponse<T> { data: T; meta: {}; } export interface StrapiPaginatedResponse<T> { data: T[]; meta: { pagination: { page: number; pageSize: number; pageCount: number; total: number; }; }; } export declare class TableStrapiAdapter { private readonly http; createGetRequest<T>(url: string, mapFn?: (x: any) => StrapiPaginatedResponse<T>): (options?: StrapiOptions) => Observable<StrapiPaginatedResponse<T> | T[]>; createPostRequest<T>(url: string, body: any, requestOptions?: any): (options?: StrapiOptions) => Observable<StrapiPaginatedResponse<T> | T[]>; createSearchRequest<T>(url: string, searchOption: Omit<StrapiSearch, 'term'>[], term?: string): Observable<StrapiPaginatedResponse<T> | T[]>; generateMultiIdParam(ids: number[], key?: string): string; generateMultiIdBody(ids: number[], key?: string): any; private strapiFetchRequest; optionsToUrl(url: string, options: StrapiOptions | undefined, features?: { pagination?: boolean; }): string; private iterateObject; private keyToBracket; private keyToEndpointProcess; private strategyResolver; static ɵfac: i0.ɵɵFactoryDeclaration<TableStrapiAdapter, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TableStrapiAdapter>; }