larapi 0.2.18 → 0.2.20

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/src/types.ts CHANGED
@@ -2,7 +2,7 @@ export type TCacheBody = {
2
2
  data: any;
3
3
  group?: string;
4
4
  time: number;
5
- }
5
+ };
6
6
 
7
7
  export type TUser = {
8
8
  id: number;
@@ -11,19 +11,23 @@ export type TUser = {
11
11
 
12
12
  export type TCache = {
13
13
  [index: string]: TCacheBody;
14
- }
14
+ };
15
15
 
16
16
  export type TError = {
17
17
  message?: string;
18
- }
18
+ };
19
19
 
20
20
  export type TData = {
21
21
  [index: string]: any | ((...args: any) => any);
22
- }
22
+ };
23
23
 
24
24
  export type TGroupsData = {
25
25
  [index: string]: TData;
26
- }
26
+ };
27
+
28
+ export type TRequestHeaders = {
29
+ [index: string]: string;
30
+ };
27
31
 
28
32
  export type TMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'CONNECT' | 'TRACE';
29
33
 
@@ -55,6 +59,7 @@ export type TConfig = {
55
59
  host: string;
56
60
  reviver?: (this: any, key: string, value: any) => any;
57
61
  dataReviver?: TConfigDataReviver;
62
+ headers?: TRequestHeaders;
58
63
  };
59
64
 
60
65
  export type TResponseData = {
@@ -71,20 +76,46 @@ export type TParams<P = string | keyof TResponseData['success'], D extends ((...
71
76
  cacheClear?: TCacheControll | TCacheControll[];
72
77
  globalName?: string;
73
78
  queueThrottling?: boolean;
79
+ headers?: TRequestHeaders;
74
80
  success?: (data: ReturnType<D>) => void;
75
81
  error?: (error: E) => void;
76
82
  fail?: (fail: F) => void;
77
83
  complete?: (complete: any) => void;
78
84
  progress?: (progress: TRequestProgress) => void;
79
- }
85
+ };
80
86
 
81
87
  export type TRequestParams = {
82
88
  method: TMethod;
83
- headers?: {
84
- [index: string]: string;
85
- };
89
+ headers?: TRequestHeaders;
86
90
  body?: string;
87
91
  withoutResponse?: boolean;
88
- }
92
+ };
93
+
94
+ export type TListenerEvents = {
95
+ 'api-request-success': any;
96
+ 'api-request-fail': any;
97
+ 'api-request-error': any;
98
+ 'api-request-complete': any;
99
+ 'api-request-progress': any;
100
+ 'login': {
101
+ user: any;
102
+ token: string;
103
+ };
104
+ 'logout': any;
105
+ 'user-set': any;
106
+ 'user-update': any;
107
+ 'token-update': string;
108
+ 'csrf-token-update': string;
109
+ };
89
110
 
90
- export type TListenerEvents = 'api-request-success' | 'api-request-fail' | 'api-request-error' | 'api-request-complete' | 'api-request-progress' | 'login' | 'logout' | 'user-update';
111
+ // export type TListenerEvents = 'api-request-success' |
112
+ // 'api-request-fail' |
113
+ // 'api-request-error' |
114
+ // 'api-request-complete' |
115
+ // 'api-request-progress' |
116
+ // 'login' |
117
+ // 'logout' |
118
+ // 'user-set' |
119
+ // 'user-update' |
120
+ // 'token-update' |
121
+ // 'csrf-token-update';