native-document 1.0.50 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +0 -1
- package/package.json +1 -1
- package/types/native-fetch.d.ts +71 -0
- package/types/service.d.ts +13 -0
- package/utils.d.ts +3 -0
- package/utils.js +3 -1
package/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import './src/utils/prototypes.js';
|
|
|
11
11
|
export * from './src/utils/property-accumulator';
|
|
12
12
|
export * from './src/utils/args-types';
|
|
13
13
|
export * from './src/utils/memoize';
|
|
14
|
-
export * from './src/utils/service';
|
|
15
14
|
export * from './src/data/Observable';
|
|
16
15
|
export * from './src/data/observable-helpers/array';
|
|
17
16
|
export * from './src/data/observable-helpers/batch';
|
package/package.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
2
|
+
|
|
3
|
+
interface FetchConfig {
|
|
4
|
+
method: HttpMethod;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
body?: string | FormData;
|
|
7
|
+
params?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FetchOptions {
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type RequestInterceptor = (
|
|
15
|
+
config: FetchConfig,
|
|
16
|
+
endpoint: string
|
|
17
|
+
) => Promise<FetchConfig | void> | FetchConfig | void;
|
|
18
|
+
|
|
19
|
+
type ResponseInterceptor = (
|
|
20
|
+
response: Response,
|
|
21
|
+
endpoint: string
|
|
22
|
+
) => Promise<Response | void> | Response | void;
|
|
23
|
+
|
|
24
|
+
interface NativeFetchError extends Error {
|
|
25
|
+
status: number;
|
|
26
|
+
data: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Interceptors {
|
|
30
|
+
request: (callback: RequestInterceptor) => void;
|
|
31
|
+
response: (callback: ResponseInterceptor) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare class NativeFetch {
|
|
35
|
+
constructor(baseUrl: string);
|
|
36
|
+
|
|
37
|
+
interceptors: Interceptors;
|
|
38
|
+
|
|
39
|
+
fetch<T = any>(
|
|
40
|
+
method: HttpMethod,
|
|
41
|
+
endpoint: string,
|
|
42
|
+
params?: Record<string, any> | FormData,
|
|
43
|
+
options?: FetchOptions
|
|
44
|
+
): Promise<T>;
|
|
45
|
+
|
|
46
|
+
get<T = any>(
|
|
47
|
+
endpoint: string,
|
|
48
|
+
params?: Record<string, any>,
|
|
49
|
+
options?: FetchOptions
|
|
50
|
+
): Promise<T>;
|
|
51
|
+
|
|
52
|
+
post<T = any>(
|
|
53
|
+
endpoint: string,
|
|
54
|
+
params?: Record<string, any> | FormData,
|
|
55
|
+
options?: FetchOptions
|
|
56
|
+
): Promise<T>;
|
|
57
|
+
|
|
58
|
+
put<T = any>(
|
|
59
|
+
endpoint: string,
|
|
60
|
+
params?: Record<string, any> | FormData,
|
|
61
|
+
options?: FetchOptions
|
|
62
|
+
): Promise<T>;
|
|
63
|
+
|
|
64
|
+
delete<T = any>(
|
|
65
|
+
endpoint: string,
|
|
66
|
+
params?: Record<string, any>,
|
|
67
|
+
options?: FetchOptions
|
|
68
|
+
): Promise<T>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default NativeFetch;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ServiceFactory<T> = () => T;
|
|
2
|
+
type MemoizedFactory<T, Args extends any[]> = (...args: Args) => T;
|
|
3
|
+
|
|
4
|
+
interface ServiceStatic {
|
|
5
|
+
|
|
6
|
+
once<T>(fn: ServiceFactory<T>): ServiceFactory<T>;
|
|
7
|
+
|
|
8
|
+
memoize<T, Args extends any[]>(
|
|
9
|
+
fn: MemoizedFactory<T, Args>
|
|
10
|
+
): MemoizedFactory<T, Args>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Service: ServiceStatic;
|
package/utils.d.ts
CHANGED