UNPKG

@rest-api/react-models

Version:

[![npm version](https://img.shields.io/npm/v/@rest-api/react-models)](https://www.npmjs.com/package/@rest-api/react-models) [![codecov](https://codecov.io/gh/hector7/rest-api-react-models/branch/master/graph/badge.svg)](https://codecov.io/gh/hector7/rest-

48 lines (47 loc) 2.51 kB
import React from 'react'; import Model, { SchemaClass } from './src/DataTypes'; export { default as Model, Schema, SchemaClass } from './src/DataTypes'; declare const TRUE: true; export { TRUE as required, TRUE as idOnly }; export declare const useSelector: typeof import("react-redux").useSelector; export declare const useDispatch: typeof import("react-redux").useDispatch; export declare type Callback<T, Err = Error> = (err: Err | null, res?: T) => void; export declare class HttpError { readonly codeNumber: number; readonly date: Date; readonly message: string; constructor(status: number, message: string); } export declare function createAction<T extends string>(type: T): Action<T>; export declare function createAction<T extends string, P>(type: T, payload: P): Action<T, P>; export declare type ActionUnion<A extends { [actionsCreator: string]: (...args: any[]) => any; }> = ReturnType<A[keyof A]>; export declare type Action<T extends string, P = {}> = { type: T; } & P; declare type MakeMetaDataOptions<GetItem, Item, MetaData> = { getItems: (data: GetItem) => Item[]; getMetadata: (data: GetItem) => MetaData; }; declare type MakeOptions<GetItem, Item> = { getItems?: (data: GetItem) => Item[]; getMetadata?: never; }; declare type CommonOptions = { headers?: { [key: string]: string; }; trailingSlash?: boolean; }; export declare type Options<GetItem, Item, MetaData> = CommonOptions & (MetaData extends undefined ? MakeOptions<GetItem, Item> : MakeMetaDataOptions<GetItem, Item, MetaData>); export declare type ProjectionType<T, Projection extends Partial<{ [key in keyof T]: 1; }>> = Pick<T, { [k in keyof T]: Projection[k] extends 1 ? k : never; }[keyof T]>; export declare type ModelType<M extends Model<any, any, any, any> | SchemaClass<any>> = M extends Model<infer T, any, any, any> ? T["RealType"] : M extends SchemaClass<any> ? M["RealType"] : never; export declare type PopulatedModelType<M extends Model<any, any, any, any> | SchemaClass<any>> = M extends Model<infer T, any, any, any> ? T['PopulatedType'] : M extends SchemaClass<any> ? M['PopulatedType'] : never; export declare type FullPopulatedModelType<M extends Model<any, any, any, any> | SchemaClass<any>> = M extends Model<infer T, any, any, any> ? T['FullPopulatedType'] : M extends SchemaClass<any> ? M['FullPopulatedType'] : never; export declare function getProvider(): React.FC<{}>; export declare function filterNulls<T, Q = T | null>(array: Q[]): T[];