@jagoankode/api-client 1.0.0
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/dist/index.d.mts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +941 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +901 -0
- package/dist/index.mjs.map +1 -0
- package/dist/init.js +5650 -0
- package/dist/init.js.map +1 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as zustand_middleware from 'zustand/middleware';
|
|
3
|
+
import * as zustand from 'zustand';
|
|
4
|
+
|
|
5
|
+
declare function ApiTester(): react.JSX.Element;
|
|
6
|
+
|
|
7
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
8
|
+
interface KeyValuePair {
|
|
9
|
+
key: string;
|
|
10
|
+
value: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface RequestConfig {
|
|
14
|
+
url: string;
|
|
15
|
+
method: HttpMethod;
|
|
16
|
+
headers: KeyValuePair[];
|
|
17
|
+
params: KeyValuePair[];
|
|
18
|
+
body: string;
|
|
19
|
+
}
|
|
20
|
+
interface HistoryEntry {
|
|
21
|
+
id: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
config: RequestConfig;
|
|
24
|
+
response: {
|
|
25
|
+
status: number;
|
|
26
|
+
statusText: string;
|
|
27
|
+
body: string;
|
|
28
|
+
headers: Record<string, string>;
|
|
29
|
+
duration: number;
|
|
30
|
+
} | null;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
interface TesterState {
|
|
34
|
+
url: string;
|
|
35
|
+
method: HttpMethod;
|
|
36
|
+
headers: KeyValuePair[];
|
|
37
|
+
params: KeyValuePair[];
|
|
38
|
+
body: string;
|
|
39
|
+
history: HistoryEntry[];
|
|
40
|
+
loading: boolean;
|
|
41
|
+
setUrl: (url: string) => void;
|
|
42
|
+
setMethod: (method: HttpMethod) => void;
|
|
43
|
+
setHeaders: (headers: KeyValuePair[]) => void;
|
|
44
|
+
addHeader: () => void;
|
|
45
|
+
removeHeader: (index: number) => void;
|
|
46
|
+
updateHeader: (index: number, field: keyof KeyValuePair, value: string | boolean) => void;
|
|
47
|
+
setParams: (params: KeyValuePair[]) => void;
|
|
48
|
+
addParam: () => void;
|
|
49
|
+
removeParam: (index: number) => void;
|
|
50
|
+
updateParam: (index: number, field: keyof KeyValuePair, value: string | boolean) => void;
|
|
51
|
+
setBody: (body: string) => void;
|
|
52
|
+
executeRequest: () => Promise<HistoryEntry>;
|
|
53
|
+
loadFromHistory: (entry: HistoryEntry) => void;
|
|
54
|
+
clearHistory: () => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const useTesterStore: zustand.UseBoundStore<Omit<zustand.StoreApi<TesterState>, "setState" | "persist"> & {
|
|
58
|
+
setState(partial: TesterState | Partial<TesterState> | ((state: TesterState) => TesterState | Partial<TesterState>), replace?: false | undefined): unknown;
|
|
59
|
+
setState(state: TesterState | ((state: TesterState) => TesterState), replace: true): unknown;
|
|
60
|
+
persist: {
|
|
61
|
+
setOptions: (options: Partial<zustand_middleware.PersistOptions<TesterState, {
|
|
62
|
+
history: HistoryEntry[];
|
|
63
|
+
}, unknown>>) => void;
|
|
64
|
+
clearStorage: () => void;
|
|
65
|
+
rehydrate: () => Promise<void> | void;
|
|
66
|
+
hasHydrated: () => boolean;
|
|
67
|
+
onHydrate: (fn: (state: TesterState) => void) => () => void;
|
|
68
|
+
onFinishHydration: (fn: (state: TesterState) => void) => () => void;
|
|
69
|
+
getOptions: () => Partial<zustand_middleware.PersistOptions<TesterState, {
|
|
70
|
+
history: HistoryEntry[];
|
|
71
|
+
}, unknown>>;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
interface ExecuteResult {
|
|
76
|
+
status: number;
|
|
77
|
+
statusText: string;
|
|
78
|
+
body: string;
|
|
79
|
+
headers: Record<string, string>;
|
|
80
|
+
duration: number;
|
|
81
|
+
}
|
|
82
|
+
declare function getAuthInfo(): {
|
|
83
|
+
csrfToken: string | null;
|
|
84
|
+
authToken: string | null;
|
|
85
|
+
};
|
|
86
|
+
declare function executeRequest(config: RequestConfig): Promise<ExecuteResult>;
|
|
87
|
+
|
|
88
|
+
export { ApiTester, type HistoryEntry, type HttpMethod, type KeyValuePair, type RequestConfig, type TesterState, executeRequest, getAuthInfo, useTesterStore };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as zustand_middleware from 'zustand/middleware';
|
|
3
|
+
import * as zustand from 'zustand';
|
|
4
|
+
|
|
5
|
+
declare function ApiTester(): react.JSX.Element;
|
|
6
|
+
|
|
7
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
8
|
+
interface KeyValuePair {
|
|
9
|
+
key: string;
|
|
10
|
+
value: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface RequestConfig {
|
|
14
|
+
url: string;
|
|
15
|
+
method: HttpMethod;
|
|
16
|
+
headers: KeyValuePair[];
|
|
17
|
+
params: KeyValuePair[];
|
|
18
|
+
body: string;
|
|
19
|
+
}
|
|
20
|
+
interface HistoryEntry {
|
|
21
|
+
id: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
config: RequestConfig;
|
|
24
|
+
response: {
|
|
25
|
+
status: number;
|
|
26
|
+
statusText: string;
|
|
27
|
+
body: string;
|
|
28
|
+
headers: Record<string, string>;
|
|
29
|
+
duration: number;
|
|
30
|
+
} | null;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
interface TesterState {
|
|
34
|
+
url: string;
|
|
35
|
+
method: HttpMethod;
|
|
36
|
+
headers: KeyValuePair[];
|
|
37
|
+
params: KeyValuePair[];
|
|
38
|
+
body: string;
|
|
39
|
+
history: HistoryEntry[];
|
|
40
|
+
loading: boolean;
|
|
41
|
+
setUrl: (url: string) => void;
|
|
42
|
+
setMethod: (method: HttpMethod) => void;
|
|
43
|
+
setHeaders: (headers: KeyValuePair[]) => void;
|
|
44
|
+
addHeader: () => void;
|
|
45
|
+
removeHeader: (index: number) => void;
|
|
46
|
+
updateHeader: (index: number, field: keyof KeyValuePair, value: string | boolean) => void;
|
|
47
|
+
setParams: (params: KeyValuePair[]) => void;
|
|
48
|
+
addParam: () => void;
|
|
49
|
+
removeParam: (index: number) => void;
|
|
50
|
+
updateParam: (index: number, field: keyof KeyValuePair, value: string | boolean) => void;
|
|
51
|
+
setBody: (body: string) => void;
|
|
52
|
+
executeRequest: () => Promise<HistoryEntry>;
|
|
53
|
+
loadFromHistory: (entry: HistoryEntry) => void;
|
|
54
|
+
clearHistory: () => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare const useTesterStore: zustand.UseBoundStore<Omit<zustand.StoreApi<TesterState>, "setState" | "persist"> & {
|
|
58
|
+
setState(partial: TesterState | Partial<TesterState> | ((state: TesterState) => TesterState | Partial<TesterState>), replace?: false | undefined): unknown;
|
|
59
|
+
setState(state: TesterState | ((state: TesterState) => TesterState), replace: true): unknown;
|
|
60
|
+
persist: {
|
|
61
|
+
setOptions: (options: Partial<zustand_middleware.PersistOptions<TesterState, {
|
|
62
|
+
history: HistoryEntry[];
|
|
63
|
+
}, unknown>>) => void;
|
|
64
|
+
clearStorage: () => void;
|
|
65
|
+
rehydrate: () => Promise<void> | void;
|
|
66
|
+
hasHydrated: () => boolean;
|
|
67
|
+
onHydrate: (fn: (state: TesterState) => void) => () => void;
|
|
68
|
+
onFinishHydration: (fn: (state: TesterState) => void) => () => void;
|
|
69
|
+
getOptions: () => Partial<zustand_middleware.PersistOptions<TesterState, {
|
|
70
|
+
history: HistoryEntry[];
|
|
71
|
+
}, unknown>>;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
interface ExecuteResult {
|
|
76
|
+
status: number;
|
|
77
|
+
statusText: string;
|
|
78
|
+
body: string;
|
|
79
|
+
headers: Record<string, string>;
|
|
80
|
+
duration: number;
|
|
81
|
+
}
|
|
82
|
+
declare function getAuthInfo(): {
|
|
83
|
+
csrfToken: string | null;
|
|
84
|
+
authToken: string | null;
|
|
85
|
+
};
|
|
86
|
+
declare function executeRequest(config: RequestConfig): Promise<ExecuteResult>;
|
|
87
|
+
|
|
88
|
+
export { ApiTester, type HistoryEntry, type HttpMethod, type KeyValuePair, type RequestConfig, type TesterState, executeRequest, getAuthInfo, useTesterStore };
|