|
1 | | -import { IOEndpoint, IOOptions, IOPromise } from 'type-r'; |
2 | | -export declare type Index = number[]; |
3 | | -export declare function create(key: string): LocalStorageEndpoint; |
4 | | -export { create as localStorageIO }; |
5 | | -export declare class LocalStorageEndpoint implements IOEndpoint { |
6 | | - key: string; |
7 | | - constructor(key: string); |
8 | | - resolve(value: any): IOPromise<any>; |
9 | | - reject(value: any): IOPromise<any>; |
10 | | - create(json: any, options: IOOptions): IOPromise<any>; |
11 | | - set(json: any): void; |
12 | | - get(id: any): any; |
13 | | - update(id: any, json: any, options: IOOptions): IOPromise<any>; |
14 | | - read(id: any, options: IOOptions): IOPromise<any>; |
15 | | - destroy(id: any, options: IOOptions): IOPromise<any>; |
16 | | - index: (string | number)[]; |
17 | | - list(options?: IOOptions): IOPromise<any>; |
| 1 | +import { IOEndpoint, IOOptions } from 'type-r'; |
| 2 | +export declare function create(url: string, fetchOptions?: Partial<RestfulFetchOptions>): RestfulEndpoint; |
| 3 | +export { create as restfulIO }; |
| 4 | +export interface RestfulIOOptions extends IOOptions { |
| 5 | + params?: object; |
| 6 | + options?: RequestInit; |
| 7 | +} |
| 8 | +export declare type RestfulFetchOptions = { |
| 9 | + cache?: RequestCache; |
| 10 | + credentials?: RequestCredentials; |
| 11 | + mode?: RequestMode; |
| 12 | + redirect?: RequestRedirect; |
| 13 | + referrerPolicy?: ReferrerPolicy; |
| 14 | +}; |
| 15 | +export declare class RestfulEndpoint implements IOEndpoint { |
| 16 | + url: string; |
| 17 | + fetchOptions: Partial<RestfulFetchOptions>; |
| 18 | + constructor(url: string, fetchOptions?: Partial<RestfulFetchOptions>); |
| 19 | + static defaultFetchOptions: RestfulFetchOptions; |
| 20 | + create(json: any, options: RestfulIOOptions, record: any): Promise<any>; |
| 21 | + update(id: any, json: any, options: RestfulIOOptions, record: any): Promise<any>; |
| 22 | + read(id: any, options: IOOptions, record: any): Promise<any>; |
| 23 | + destroy(id: any, options: RestfulIOOptions, record: any): Promise<any>; |
| 24 | + list(options: RestfulIOOptions, collection: any): Promise<any>; |
18 | 25 | subscribe(events: any): any; |
19 | 26 | unsubscribe(events: any): any; |
| 27 | + protected isRelativeUrl(url: any): boolean; |
| 28 | + protected removeTrailingSlash(url: string): string; |
| 29 | + protected getRootUrl(recordOrCollection: any): string; |
| 30 | + protected getUrl(record: any): string; |
| 31 | + protected objectUrl(record: any, id: any, options: any): any; |
| 32 | + protected collectionUrl(collection: any, options: any): any; |
| 33 | + protected buildRequestOptions(method: string, options?: RequestInit, body?: any): RequestInit; |
| 34 | + protected request(method: string, url: string, {options}: RestfulIOOptions, body?: any): Promise<any>; |
20 | 35 | } |
0 commit comments