skysync-cli
Version:
SkySync Command Line Interface
57 lines (56 loc) • 2.98 kB
TypeScript
import { IHttpClient } from '../http';
import { IEntityIdentifier } from '../models/base';
import { CancellationToken } from '../cancellation-token';
export declare function getTypedResponse<T>(result: any, type?: string): T;
export declare function getPagedResponse<T>(response: any, items: T[]): PagedResult<T>;
export declare function consumePagedResult<T>(handle: (item: T) => void, func: (params: any) => Promise<PagedResult<T>>, params?: any): Promise<void>;
export declare function consumePagedResource<T>(handle: (item: T) => void, resource: PagedResource<T>, params?: any): Promise<void>;
export declare class BaseResource {
protected httpClient: IHttpClient;
defaultParams: any;
constructor(httpClient: IHttpClient);
protected mergeDefaultParams(params: any): any;
protected mergeParams(lhs: any, rhs: any): any;
}
export declare class Resource<TResource> extends BaseResource {
protected singularName: string;
protected pluralName: string;
protected singularType?: string;
protected pluralType: string;
protected resourcePath: string;
constructor(httpClient: IHttpClient, singularName: string, pluralName?: string, singularType?: string, pluralType?: string, resourcePath?: string);
protected getList(result: any): TResource[];
protected getSingle(result: any): TResource;
list(params?: any, token?: CancellationToken): Promise<TResource[]>;
get(id: any, params?: any, token?: CancellationToken): Promise<TResource>;
}
declare type EditRequest = {
id: string;
payload?: any;
};
export declare function getEditRequest(body: any | string): EditRequest;
export declare class EditableResource<TResource extends IEntityIdentifier<string>> extends Resource<TResource> {
constructor(httpClient: IHttpClient, name: string, type?: string, pluralName?: string, pluralType?: string, resourcePath?: string);
add(body: TResource, params?: any, token?: CancellationToken): Promise<TResource>;
update(body: TResource | string, params?: any, token?: CancellationToken): Promise<TResource>;
patch(body: TResource | string, params?: any, token?: CancellationToken): Promise<TResource>;
delete(id: any, params?: any, token?: CancellationToken): Promise<boolean>;
deleteAll(params?: any, token?: CancellationToken): Promise<boolean>;
}
export interface PagedResult<TResource> {
offset?: number;
limit?: number;
totalCount?: number;
hasMore?: boolean;
next?: any;
previous?: any;
items: TResource[];
}
export declare class PagedResource<TResource> extends EditableResource<TResource> {
constructor(httpClient: IHttpClient, name: string, type?: string, pluralName?: string, pluralType?: string, resourcePath?: string);
page(params?: any, token?: CancellationToken): Promise<PagedResult<TResource>>;
}
export interface IDownloadFileProvider {
getDownloadRequestPath(id: string): string;
}
export {};