laravel-request 1.2.16 → 1.2.19
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/@types/Api.d.ts +48 -0
- package/@types/ApiProxy.d.ts +5 -0
- package/@types/ApiRequest.d.ts +154 -0
- package/@types/Binding.d.ts +30 -0
- package/@types/Builder.d.ts +14 -0
- package/@types/BuilderMethodSignatures.d.ts +47 -0
- package/@types/UrlBind.d.ts +30 -0
- package/@types/laravel-request.d.ts +9 -352
- package/package.json +1 -1
- package/src/Api.js +10 -10
package/@types/Api.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
declare module 'laravel-request' {
|
|
2
|
+
export class Api {
|
|
3
|
+
static debug: boolean;
|
|
4
|
+
static requestClass: any;
|
|
5
|
+
static tokenResolver: () => Promise<string | null>;
|
|
6
|
+
static domainResolver: () => string;
|
|
7
|
+
|
|
8
|
+
static getArg(controller: string, action: string, arg: string|number, data?: Record<string, any>): ApiRequest;
|
|
9
|
+
|
|
10
|
+
static postArg(controller: string, action: string, arg: string|number, data?: Record<string, any>): ApiRequest;
|
|
11
|
+
|
|
12
|
+
static putArg(controller: string, action: string, arg: string|number, data?: Record<string, any>): ApiRequest;
|
|
13
|
+
|
|
14
|
+
static getUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
15
|
+
|
|
16
|
+
static postUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
17
|
+
|
|
18
|
+
static putUrl(url: string, data?: Record<string, any>): ApiRequest;
|
|
19
|
+
|
|
20
|
+
static get(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
21
|
+
|
|
22
|
+
static post(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
23
|
+
|
|
24
|
+
static put(controller: string, action: string, data?: Record<string, any>): ApiRequest;
|
|
25
|
+
|
|
26
|
+
static delete(controller: string, action: string, id: string|number, data?: Record<string, any>): ApiRequest;
|
|
27
|
+
|
|
28
|
+
static encodeQueryString(params: Record<string, any>): string;
|
|
29
|
+
|
|
30
|
+
static logRequest(request: {
|
|
31
|
+
url: string;
|
|
32
|
+
method: string;
|
|
33
|
+
data?: Record<string, any>;
|
|
34
|
+
params?: Record<string, any>;
|
|
35
|
+
headers?: Record<string, any>;
|
|
36
|
+
}): void;
|
|
37
|
+
|
|
38
|
+
static makeRequest(params: {
|
|
39
|
+
url: string;
|
|
40
|
+
method: string;
|
|
41
|
+
data?: Record<string, any>;
|
|
42
|
+
params?: Record<string, any>;
|
|
43
|
+
headers?: Record<string, any>;
|
|
44
|
+
success?: (response: any, status: number, xhr: any) => void;
|
|
45
|
+
error?: (xhr: any, statusCode: number, statusText: string) => void;
|
|
46
|
+
}): Promise<any>;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
declare module 'laravel-request' {
|
|
2
|
+
import * as axios from "axios/index";
|
|
3
|
+
|
|
4
|
+
export interface ApiRequest extends BuilderMethodSignatures {}
|
|
5
|
+
|
|
6
|
+
export class ApiRequest {
|
|
7
|
+
url: string;
|
|
8
|
+
source: any;
|
|
9
|
+
static notifyClass: any | null;
|
|
10
|
+
domain: string;
|
|
11
|
+
target: string;
|
|
12
|
+
focus: string;
|
|
13
|
+
method: string;
|
|
14
|
+
data: any;
|
|
15
|
+
headers: any[];
|
|
16
|
+
arguments: any[];
|
|
17
|
+
builder: Builder;
|
|
18
|
+
notifyCallback: (status: number) => boolean;
|
|
19
|
+
responseBinding: Binding | Binding[] | null;
|
|
20
|
+
responseBindingErrors: Binding | null;
|
|
21
|
+
callSuccess: Function;
|
|
22
|
+
callError: Function;
|
|
23
|
+
|
|
24
|
+
constructor(target: string, focus: string, data?: object, method?: string);
|
|
25
|
+
|
|
26
|
+
getNotifyManager(): any | null;
|
|
27
|
+
|
|
28
|
+
setUrl(url: string): ApiRequest;
|
|
29
|
+
|
|
30
|
+
setDomain(domain: string): ApiRequest;
|
|
31
|
+
|
|
32
|
+
addArg(arg: any | any[]): ApiRequest;
|
|
33
|
+
|
|
34
|
+
first(
|
|
35
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
36
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
37
|
+
finalCallback?: () => void
|
|
38
|
+
): any;
|
|
39
|
+
|
|
40
|
+
all(
|
|
41
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
42
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
43
|
+
finalCallback?: () => void
|
|
44
|
+
): any;
|
|
45
|
+
|
|
46
|
+
paginate(
|
|
47
|
+
page?: number,
|
|
48
|
+
perPage?: number,
|
|
49
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
50
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
51
|
+
finalCallback?: () => void
|
|
52
|
+
): any;
|
|
53
|
+
|
|
54
|
+
pluck(
|
|
55
|
+
fields: any,
|
|
56
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
57
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
58
|
+
finalCallback?: () => void
|
|
59
|
+
): ApiRequest;
|
|
60
|
+
|
|
61
|
+
getUrl(): string;
|
|
62
|
+
|
|
63
|
+
getSource(): axios.CancelTokenSource | null;
|
|
64
|
+
|
|
65
|
+
call(
|
|
66
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
67
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
68
|
+
finalCallback?: () => void,
|
|
69
|
+
params?: object,
|
|
70
|
+
dataKey?: string,
|
|
71
|
+
argumentsKey?: string,
|
|
72
|
+
queryKey?: string,
|
|
73
|
+
byUrl?: boolean
|
|
74
|
+
): ApiRequest;
|
|
75
|
+
|
|
76
|
+
callSync(
|
|
77
|
+
successCallback?: (response: { data: any; result: string; meta?: any }) => void,
|
|
78
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
79
|
+
finalCallback?: () => void
|
|
80
|
+
): ApiRequest;
|
|
81
|
+
|
|
82
|
+
callUrl(
|
|
83
|
+
successCallback?: (response: { response: { data: any; result: string; meta?: any } }) => void,
|
|
84
|
+
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
85
|
+
finalCallback?: () => void,
|
|
86
|
+
params?: object,
|
|
87
|
+
dataKey?: string,
|
|
88
|
+
argumentsKey?: string,
|
|
89
|
+
queryKey?: string
|
|
90
|
+
): ApiRequest;
|
|
91
|
+
|
|
92
|
+
constructRequestData(
|
|
93
|
+
dataKey: string,
|
|
94
|
+
argumentsKey: string,
|
|
95
|
+
queryKey: string
|
|
96
|
+
): object;
|
|
97
|
+
|
|
98
|
+
getErrorNotification(
|
|
99
|
+
xhr: XMLHttpRequest,
|
|
100
|
+
errorText: string
|
|
101
|
+
): object | null;
|
|
102
|
+
|
|
103
|
+
defaultErrorMessage(
|
|
104
|
+
xhr: XMLHttpRequest,
|
|
105
|
+
errorText: string
|
|
106
|
+
): object | null;
|
|
107
|
+
|
|
108
|
+
getErrorNotificationFallback(e: Error): object | null;
|
|
109
|
+
|
|
110
|
+
executeRequest(
|
|
111
|
+
successCallback: (response: { data: any; result: string; meta?: any }) => void,
|
|
112
|
+
errorCallback: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
113
|
+
finalCallback?: () => void,
|
|
114
|
+
params?: object,
|
|
115
|
+
dataKey?: string,
|
|
116
|
+
argumentsKey?: string,
|
|
117
|
+
queryKey?: string,
|
|
118
|
+
byUrl?: boolean
|
|
119
|
+
): ApiRequest;
|
|
120
|
+
|
|
121
|
+
handleSuccessNotification(
|
|
122
|
+
response: any,
|
|
123
|
+
status: number
|
|
124
|
+
): object | null;
|
|
125
|
+
|
|
126
|
+
handleError(
|
|
127
|
+
notify: object | null,
|
|
128
|
+
errorCallback: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
129
|
+
xhr: XMLHttpRequest,
|
|
130
|
+
errorText: string
|
|
131
|
+
): void;
|
|
132
|
+
|
|
133
|
+
bind(
|
|
134
|
+
obj: any,
|
|
135
|
+
item: string | [string, string][],
|
|
136
|
+
rerender?: boolean,
|
|
137
|
+
cb?: Function
|
|
138
|
+
): ApiRequest;
|
|
139
|
+
|
|
140
|
+
toBind(response: any): void;
|
|
141
|
+
|
|
142
|
+
resetBindErrors(): void;
|
|
143
|
+
|
|
144
|
+
toBindErrors(response?: object): void;
|
|
145
|
+
|
|
146
|
+
withValidateForm(
|
|
147
|
+
obj: any,
|
|
148
|
+
item?: string,
|
|
149
|
+
key?: string
|
|
150
|
+
): ApiRequest;
|
|
151
|
+
|
|
152
|
+
withoutNotify(callback?: (status: number) => boolean): ApiRequest;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare module 'laravel-request' {
|
|
2
|
+
interface Target {
|
|
3
|
+
state: Record<string, any>;
|
|
4
|
+
|
|
5
|
+
setState(
|
|
6
|
+
callback: (prevState: Record<string, any>) => Record<string, any>,
|
|
7
|
+
onSuccess?: () => void
|
|
8
|
+
): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class Binding {
|
|
12
|
+
target: Target;
|
|
13
|
+
pathTarget: string[];
|
|
14
|
+
pathData: string[];
|
|
15
|
+
callback?: () => void;
|
|
16
|
+
rerender: boolean;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
target: Target,
|
|
20
|
+
pathTarget: string,
|
|
21
|
+
pathData: string,
|
|
22
|
+
rerender: boolean,
|
|
23
|
+
onSuccess?: () => void
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
fire(data: Record<string, any>): void;
|
|
27
|
+
|
|
28
|
+
getData(value: Record<string, any>): any;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'laravel-request' {
|
|
2
|
+
export interface Builder extends BuilderMethodSignatures {}
|
|
3
|
+
export class Builder {
|
|
4
|
+
static availableMethod: string[];
|
|
5
|
+
|
|
6
|
+
query: Array<Record<string, any>>;
|
|
7
|
+
|
|
8
|
+
constructor();
|
|
9
|
+
|
|
10
|
+
add(method: string, args: any[]): Builder;
|
|
11
|
+
|
|
12
|
+
toArray(): Array<Record<string, any>>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// BuilderMethodSignatures.d.ts
|
|
2
|
+
|
|
3
|
+
declare module 'laravel-request' {
|
|
4
|
+
/**
|
|
5
|
+
* Общий набор "флюентных" методов,
|
|
6
|
+
* которые динамически навешиваются и на Builder, и на ApiRequest.
|
|
7
|
+
*
|
|
8
|
+
* Все они возвращают `this`, чтобы цепочки методов (fluent API) типизировались правильно:
|
|
9
|
+
* - в Builder методы будут возвращать Builder,
|
|
10
|
+
* - в ApiRequest – ApiRequest.
|
|
11
|
+
*/
|
|
12
|
+
export interface BuilderMethodSignatures {
|
|
13
|
+
select(...args: any[]): this;
|
|
14
|
+
where(...args: any[]): this;
|
|
15
|
+
orWhere(...args: any[]): this;
|
|
16
|
+
whereDate(...args: any[]): this;
|
|
17
|
+
orWhereDate(...args: any[]): this;
|
|
18
|
+
whereYear(...args: any[]): this;
|
|
19
|
+
orWhereYear(...args: any[]): this;
|
|
20
|
+
whereMonth(...args: any[]): this;
|
|
21
|
+
orWhereMonth(...args: any[]): this;
|
|
22
|
+
has(...args: any[]): this;
|
|
23
|
+
whereIn(...args: any[]): this;
|
|
24
|
+
orWhereIn(...args: any[]): this;
|
|
25
|
+
whereNotIn(...args: any[]): this;
|
|
26
|
+
orWhereNotIn(...args: any[]): this;
|
|
27
|
+
whereHas(...args: any[]): this;
|
|
28
|
+
orWhereHas(...args: any[]): this;
|
|
29
|
+
whereHasMorph(...args: any[]): this;
|
|
30
|
+
orWhereHasMorph(...args: any[]): this;
|
|
31
|
+
whereDoesntHave(...args: any[]): this;
|
|
32
|
+
orWhereDoesntHave(...args: any[]): this;
|
|
33
|
+
whereNull(...args: any[]): this;
|
|
34
|
+
orWhereNull(...args: any[]): this;
|
|
35
|
+
whereNotNull(...args: any[]): this;
|
|
36
|
+
orWhereNotNull(...args: any[]): this;
|
|
37
|
+
orderBy(...args: any[]): this;
|
|
38
|
+
groupBy(...args: any[]): this;
|
|
39
|
+
with(...args: any[]): this;
|
|
40
|
+
withCount(...args: any[]): this;
|
|
41
|
+
offset(...args: any[]): this;
|
|
42
|
+
limit(...args: any[]): this;
|
|
43
|
+
distinct(...args: any[]): this;
|
|
44
|
+
owner(...args: any[]): this;
|
|
45
|
+
whereAbs(...args: any[]): this;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare module 'laravel-request' {
|
|
2
|
+
interface Query {
|
|
3
|
+
orderBy(field: string, direction: string): Query;
|
|
4
|
+
where(field: string, operator: string, value: any): Query;
|
|
5
|
+
// Добавляйте остальные методы по необходимости
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface OptionData {
|
|
9
|
+
value: string;
|
|
10
|
+
method?: (query: Query, value: string) => void;
|
|
11
|
+
field?: string;
|
|
12
|
+
operator?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Options {
|
|
16
|
+
[key: string]: OptionData;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class UrlBind {
|
|
20
|
+
static parse: boolean;
|
|
21
|
+
|
|
22
|
+
static order(query: Query, options: { value: string }): Query;
|
|
23
|
+
|
|
24
|
+
static filter(query: Query, options: Options): Query;
|
|
25
|
+
|
|
26
|
+
static getParams(query: Query, options: Options): Query;
|
|
27
|
+
|
|
28
|
+
static urlParse(obj: Record<string, OptionData>): void;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,352 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
domain: string;
|
|
11
|
-
target: string;
|
|
12
|
-
focus: string;
|
|
13
|
-
method: string;
|
|
14
|
-
data: any;
|
|
15
|
-
headers: any[];
|
|
16
|
-
arguments: any[];
|
|
17
|
-
builder: Builder;
|
|
18
|
-
notifyCallback: (status: number) => boolean;
|
|
19
|
-
responseBinding: Binding | Binding[] | null;
|
|
20
|
-
responseBindingErrors: Binding | null;
|
|
21
|
-
callSuccess: Function;
|
|
22
|
-
callError: Function;
|
|
23
|
-
|
|
24
|
-
constructor(target: string, focus: string, data?: object, method?: string);
|
|
25
|
-
|
|
26
|
-
getNotifyManager(): any | null;
|
|
27
|
-
|
|
28
|
-
setUrl(url: string): ApiRequest;
|
|
29
|
-
|
|
30
|
-
setDomain(domain: string): ApiRequest;
|
|
31
|
-
|
|
32
|
-
addArg(arg: any | any[]): ApiRequest;
|
|
33
|
-
|
|
34
|
-
first(
|
|
35
|
-
successCallback?: (response: {data: any, result: string, meta?: any, }) => void,
|
|
36
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
37
|
-
finalCallback?: () => void,
|
|
38
|
-
): any;
|
|
39
|
-
|
|
40
|
-
all(
|
|
41
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
42
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
43
|
-
finalCallback?: () => void,
|
|
44
|
-
): any;
|
|
45
|
-
|
|
46
|
-
paginate(
|
|
47
|
-
page?: number,
|
|
48
|
-
perPage?: number,
|
|
49
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
50
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
51
|
-
finalCallback?: () => void,
|
|
52
|
-
): any;
|
|
53
|
-
|
|
54
|
-
pluck(
|
|
55
|
-
fields: any,
|
|
56
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
57
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
58
|
-
finalCallback?: () => void,
|
|
59
|
-
): ApiRequest;
|
|
60
|
-
|
|
61
|
-
getUrl(): string;
|
|
62
|
-
|
|
63
|
-
getSource(): axios.CancelTokenSource|null;
|
|
64
|
-
|
|
65
|
-
call(
|
|
66
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
67
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
68
|
-
finalCallback?: () => void,
|
|
69
|
-
params?: object,
|
|
70
|
-
dataKey?: string,
|
|
71
|
-
argumentsKey?: string,
|
|
72
|
-
queryKey?: string,
|
|
73
|
-
byUrl?: boolean
|
|
74
|
-
): ApiRequest;
|
|
75
|
-
|
|
76
|
-
callSync(
|
|
77
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
78
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
79
|
-
finalCallback?: () => void
|
|
80
|
-
): ApiRequest;
|
|
81
|
-
|
|
82
|
-
callUrl(
|
|
83
|
-
successCallback?: (response: {response: {data: any, result: string, meta?: any}}) => void,
|
|
84
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
85
|
-
finalCallback?: () => void,
|
|
86
|
-
params?: object,
|
|
87
|
-
dataKey?: string,
|
|
88
|
-
argumentsKey?: string,
|
|
89
|
-
queryKey?: string
|
|
90
|
-
): ApiRequest;
|
|
91
|
-
|
|
92
|
-
constructRequestData(
|
|
93
|
-
dataKey: string,
|
|
94
|
-
argumentsKey: string,
|
|
95
|
-
queryKey: string
|
|
96
|
-
): object;
|
|
97
|
-
|
|
98
|
-
getErrorNotification(
|
|
99
|
-
xhr: XMLHttpRequest, errorText: string
|
|
100
|
-
): object | null;
|
|
101
|
-
|
|
102
|
-
defaultErrorMessage(
|
|
103
|
-
xhr: XMLHttpRequest, errorText: string
|
|
104
|
-
): object | null;
|
|
105
|
-
|
|
106
|
-
getErrorNotificationFallback(e: Error): object | null;
|
|
107
|
-
|
|
108
|
-
executeRequest(
|
|
109
|
-
successCallback: (response: {data: any, result: string, meta?: any}) => void,
|
|
110
|
-
errorCallback: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
111
|
-
finalCallback?: () => void,
|
|
112
|
-
params?: object,
|
|
113
|
-
dataKey?: string,
|
|
114
|
-
argumentsKey?: string,
|
|
115
|
-
queryKey?: string,
|
|
116
|
-
byUrl?: boolean
|
|
117
|
-
): ApiRequest;
|
|
118
|
-
|
|
119
|
-
handleSuccessNotification(
|
|
120
|
-
response: any,
|
|
121
|
-
status: number
|
|
122
|
-
): object | null;
|
|
123
|
-
|
|
124
|
-
handleError(
|
|
125
|
-
notify: object | null,
|
|
126
|
-
errorCallback: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
127
|
-
xhr: XMLHttpRequest,
|
|
128
|
-
errorText: string
|
|
129
|
-
): void;
|
|
130
|
-
|
|
131
|
-
bind(
|
|
132
|
-
obj: any,
|
|
133
|
-
item: string | [string, string][],
|
|
134
|
-
rerender?: boolean,
|
|
135
|
-
cb?: Function
|
|
136
|
-
): ApiRequest;
|
|
137
|
-
|
|
138
|
-
toBind(response: any): void;
|
|
139
|
-
|
|
140
|
-
resetBindErrors(): void;
|
|
141
|
-
|
|
142
|
-
toBindErrors(response?: object): void;
|
|
143
|
-
|
|
144
|
-
withValidateForm(
|
|
145
|
-
obj: any,
|
|
146
|
-
item?: string,
|
|
147
|
-
key?: string
|
|
148
|
-
): ApiRequest;
|
|
149
|
-
|
|
150
|
-
withoutNotify(callback?: (status: number) => boolean): ApiRequest;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Define the Api class type with all static methods
|
|
154
|
-
export class Api {
|
|
155
|
-
static debug: boolean;
|
|
156
|
-
static requestClass: any;
|
|
157
|
-
static tokenResolver: () => Promise<string | null>;
|
|
158
|
-
static domainResolver: () => string;
|
|
159
|
-
|
|
160
|
-
static getArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
161
|
-
|
|
162
|
-
static postArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
163
|
-
|
|
164
|
-
static putArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
165
|
-
|
|
166
|
-
static getUrl(url: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
167
|
-
|
|
168
|
-
static postUrl(url: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
169
|
-
|
|
170
|
-
static putUrl(url: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
171
|
-
|
|
172
|
-
static get(controller: string, action: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
173
|
-
|
|
174
|
-
static post(controller: string, action: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
175
|
-
|
|
176
|
-
static put(controller: string, action: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
177
|
-
|
|
178
|
-
static delete(controller: string, action: string, id: string, data?: Record<string, any>): ApiRequest|Builder;
|
|
179
|
-
|
|
180
|
-
static encodeQueryString(params: Record<string, any>): string;
|
|
181
|
-
|
|
182
|
-
static logRequest(request: {
|
|
183
|
-
url: string;
|
|
184
|
-
method: string;
|
|
185
|
-
data?: Record<string, any>;
|
|
186
|
-
params?: Record<string, any>;
|
|
187
|
-
headers?: Record<string, any>;
|
|
188
|
-
}): void;
|
|
189
|
-
|
|
190
|
-
static makeRequest(params: {
|
|
191
|
-
url: string;
|
|
192
|
-
method: string;
|
|
193
|
-
data?: Record<string, any>;
|
|
194
|
-
params?: Record<string, any>;
|
|
195
|
-
headers?: Record<string, any>;
|
|
196
|
-
success?: (response: any, status: number, xhr: any) => void;
|
|
197
|
-
error?: (xhr: any, statusCode: number, statusText: string) => void;
|
|
198
|
-
}): Promise<any>;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export class Builder {
|
|
202
|
-
static availableMethod: string[];
|
|
203
|
-
|
|
204
|
-
query: Array<Record<string, any>>;
|
|
205
|
-
|
|
206
|
-
constructor();
|
|
207
|
-
|
|
208
|
-
call(
|
|
209
|
-
successCallback?: (response: {data: any, result: string, meta?: any}) => void,
|
|
210
|
-
errorCallback?: (xhr: XMLHttpRequest, responseData: any) => void,
|
|
211
|
-
finalCallback?: () => void,
|
|
212
|
-
params?: object,
|
|
213
|
-
dataKey?: string,
|
|
214
|
-
argumentsKey?: string,
|
|
215
|
-
queryKey?: string,
|
|
216
|
-
byUrl?: boolean
|
|
217
|
-
): ApiRequest;
|
|
218
|
-
|
|
219
|
-
add(method: string, args: any[]): Builder;
|
|
220
|
-
|
|
221
|
-
toArray(): Array<Record<string, any>>;
|
|
222
|
-
|
|
223
|
-
// Define dynamic method signatures for available methods
|
|
224
|
-
select(...args: any): Builder|ApiRequest;
|
|
225
|
-
|
|
226
|
-
where(...args: any): Builder|ApiRequest;
|
|
227
|
-
|
|
228
|
-
orWhere(...args: any): Builder|ApiRequest;
|
|
229
|
-
|
|
230
|
-
whereDate(...args: any): Builder|ApiRequest;
|
|
231
|
-
|
|
232
|
-
orWhereDate(...args: any): Builder|ApiRequest;
|
|
233
|
-
|
|
234
|
-
whereYear(...args: any): Builder|ApiRequest;
|
|
235
|
-
|
|
236
|
-
orWhereYear(...args: any): Builder|ApiRequest;
|
|
237
|
-
|
|
238
|
-
whereMonth(...args: any): Builder|ApiRequest;
|
|
239
|
-
|
|
240
|
-
orWhereMonth(...args: any): Builder|ApiRequest;
|
|
241
|
-
|
|
242
|
-
has(...args: any): Builder|ApiRequest;
|
|
243
|
-
|
|
244
|
-
whereIn(...args: any): Builder|ApiRequest;
|
|
245
|
-
|
|
246
|
-
orWhereIn(...args: any): Builder|ApiRequest;
|
|
247
|
-
|
|
248
|
-
whereNotIn(...args: any): Builder|ApiRequest;
|
|
249
|
-
|
|
250
|
-
orWhereNotIn(...args: any): Builder|ApiRequest;
|
|
251
|
-
|
|
252
|
-
whereHas(...args: any): Builder|ApiRequest;
|
|
253
|
-
|
|
254
|
-
orWhereHas(...args: any): Builder|ApiRequest;
|
|
255
|
-
|
|
256
|
-
whereHasMorph(...args: any): Builder|ApiRequest;
|
|
257
|
-
|
|
258
|
-
orWhereHasMorph(...args: any): Builder|ApiRequest;
|
|
259
|
-
|
|
260
|
-
whereDoesntHave(...args: any): Builder|ApiRequest;
|
|
261
|
-
|
|
262
|
-
orWhereDoesntHave(...args: any): Builder|ApiRequest;
|
|
263
|
-
|
|
264
|
-
whereNull(...args: any): Builder|ApiRequest;
|
|
265
|
-
|
|
266
|
-
orWhereNull(...args: any): Builder|ApiRequest;
|
|
267
|
-
|
|
268
|
-
whereNotNull(...args: any): Builder|ApiRequest;
|
|
269
|
-
|
|
270
|
-
orWhereNotNull(...args: any): Builder|ApiRequest;
|
|
271
|
-
|
|
272
|
-
orderBy(...args: any): Builder|ApiRequest;
|
|
273
|
-
|
|
274
|
-
groupBy(...args: any): Builder|ApiRequest;
|
|
275
|
-
|
|
276
|
-
with(...args: any): Builder|ApiRequest;
|
|
277
|
-
|
|
278
|
-
withCount(...args: any): Builder|ApiRequest;
|
|
279
|
-
|
|
280
|
-
offset(...args: any): Builder|ApiRequest;
|
|
281
|
-
|
|
282
|
-
limit(...args: any): Builder|ApiRequest;
|
|
283
|
-
|
|
284
|
-
distinct(...args: any): Builder|ApiRequest;
|
|
285
|
-
|
|
286
|
-
owner(...args: any): Builder|ApiRequest;
|
|
287
|
-
|
|
288
|
-
whereAbs(...args: any): Builder|ApiRequest;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
interface Target {
|
|
292
|
-
state: Record<string, any>;
|
|
293
|
-
|
|
294
|
-
setState(callback: (prevState: Record<string, any>) => Record<string, any>, onSuccess?: () => void): void;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export class Binding {
|
|
298
|
-
target: Target;
|
|
299
|
-
pathTarget: string[];
|
|
300
|
-
pathData: string[];
|
|
301
|
-
callback?: () => void;
|
|
302
|
-
rerender: boolean;
|
|
303
|
-
|
|
304
|
-
constructor(
|
|
305
|
-
target: Target,
|
|
306
|
-
pathTarget: string,
|
|
307
|
-
pathData: string,
|
|
308
|
-
rerender: boolean,
|
|
309
|
-
onSuccess?: () => void
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
fire(data: Record<string, any>): void;
|
|
313
|
-
|
|
314
|
-
getData(value: Record<string, any>): any;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export class ApiProxy {
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
interface Query {
|
|
322
|
-
orderBy(field: string, direction: string): Query;
|
|
323
|
-
|
|
324
|
-
where(field: string, operator: string, value: any): Query;
|
|
325
|
-
|
|
326
|
-
// Define other methods as required
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
interface OptionData {
|
|
330
|
-
value: string;
|
|
331
|
-
method?: (query: Query, value: string) => void;
|
|
332
|
-
field?: string;
|
|
333
|
-
operator?: string;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
interface Options {
|
|
337
|
-
[key: string]: OptionData;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Declare the UrlBind class
|
|
341
|
-
export class UrlBind {
|
|
342
|
-
static parse: boolean;
|
|
343
|
-
|
|
344
|
-
static order(query: Query, options: { value: string }): Query;
|
|
345
|
-
|
|
346
|
-
static filter(query: Query, options: Options): Query;
|
|
347
|
-
|
|
348
|
-
static getParams(query: Query, options: Options): Query;
|
|
349
|
-
|
|
350
|
-
static urlParse(obj: Record<string, OptionData>): void;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
1
|
+
// index.d.ts
|
|
2
|
+
/// <reference path="./ApiRequest.d.ts" />
|
|
3
|
+
/// <reference path="./Api.d.ts" />
|
|
4
|
+
/// <reference path="./Builder.d.ts" />
|
|
5
|
+
/// <reference path="./Binding.d.ts" />
|
|
6
|
+
/// <reference path="./ApiProxy.d.ts" />
|
|
7
|
+
/// <reference path="./UrlBind.d.ts" />
|
|
8
|
+
|
|
9
|
+
export * from 'laravel-request';
|
package/package.json
CHANGED
package/src/Api.js
CHANGED
|
@@ -59,7 +59,7 @@ export default class Api {
|
|
|
59
59
|
* @param action
|
|
60
60
|
* @param arg
|
|
61
61
|
* @param data
|
|
62
|
-
* @return {ApiRequest
|
|
62
|
+
* @return {ApiRequest}
|
|
63
63
|
*/
|
|
64
64
|
static getArg(controller, action, arg, data = {}) {
|
|
65
65
|
return this.get(controller, action, data).addArg(arg);
|
|
@@ -71,7 +71,7 @@ export default class Api {
|
|
|
71
71
|
* @param action
|
|
72
72
|
* @param arg
|
|
73
73
|
* @param data
|
|
74
|
-
* @return {ApiRequest
|
|
74
|
+
* @return {ApiRequest}
|
|
75
75
|
*/
|
|
76
76
|
static postArg(controller, action, arg, data = {}) {
|
|
77
77
|
return this.post(controller, action, data).addArg(arg);
|
|
@@ -83,7 +83,7 @@ export default class Api {
|
|
|
83
83
|
* @param action
|
|
84
84
|
* @param arg
|
|
85
85
|
* @param data
|
|
86
|
-
* @return {ApiRequest
|
|
86
|
+
* @return {ApiRequest}
|
|
87
87
|
*/
|
|
88
88
|
static putArg(controller, action, arg, data = {}) {
|
|
89
89
|
return this.put(controller, action, data).addArg(arg);
|
|
@@ -93,7 +93,7 @@ export default class Api {
|
|
|
93
93
|
*
|
|
94
94
|
* @param url
|
|
95
95
|
* @param data
|
|
96
|
-
* @return {ApiRequest
|
|
96
|
+
* @return {ApiRequest}
|
|
97
97
|
*/
|
|
98
98
|
static getUrl(url, data = {})
|
|
99
99
|
{
|
|
@@ -104,7 +104,7 @@ export default class Api {
|
|
|
104
104
|
*
|
|
105
105
|
* @param url
|
|
106
106
|
* @param data
|
|
107
|
-
* @return {ApiRequest
|
|
107
|
+
* @return {ApiRequest}
|
|
108
108
|
*/
|
|
109
109
|
static postUrl(url, data = {})
|
|
110
110
|
{
|
|
@@ -115,7 +115,7 @@ export default class Api {
|
|
|
115
115
|
*
|
|
116
116
|
* @param url
|
|
117
117
|
* @param data
|
|
118
|
-
* @return {ApiRequest
|
|
118
|
+
* @return {ApiRequest}
|
|
119
119
|
*/
|
|
120
120
|
static putUrl(url, data = {})
|
|
121
121
|
{
|
|
@@ -127,7 +127,7 @@ export default class Api {
|
|
|
127
127
|
* @param controller
|
|
128
128
|
* @param action
|
|
129
129
|
* @param data
|
|
130
|
-
* @returns {ApiRequest
|
|
130
|
+
* @returns {ApiRequest}
|
|
131
131
|
*/
|
|
132
132
|
static get(controller, action, data = {}) {
|
|
133
133
|
return new this.requestClass(controller, action, data, 'GET');
|
|
@@ -137,7 +137,7 @@ export default class Api {
|
|
|
137
137
|
* @param controller
|
|
138
138
|
* @param action
|
|
139
139
|
* @param data
|
|
140
|
-
* @returns {ApiRequest
|
|
140
|
+
* @returns {ApiRequest}
|
|
141
141
|
*/
|
|
142
142
|
static post(controller, action, data = {}) {
|
|
143
143
|
return new this.requestClass(controller, action, data, 'POST');
|
|
@@ -147,7 +147,7 @@ export default class Api {
|
|
|
147
147
|
* @param controller
|
|
148
148
|
* @param action
|
|
149
149
|
* @param data
|
|
150
|
-
* @returns {ApiRequest
|
|
150
|
+
* @returns {ApiRequest}
|
|
151
151
|
*/
|
|
152
152
|
static put(controller, action, data = {}) {
|
|
153
153
|
return new this.requestClass(controller, action, data, 'PUT');
|
|
@@ -159,7 +159,7 @@ export default class Api {
|
|
|
159
159
|
* @param action
|
|
160
160
|
* @param id
|
|
161
161
|
* @param data
|
|
162
|
-
* @return {ApiRequest
|
|
162
|
+
* @return {ApiRequest}
|
|
163
163
|
*/
|
|
164
164
|
static delete(controller, action, id, data = {}) {
|
|
165
165
|
return new this.requestClass(controller, action, data, 'DELETE').addArg(id);
|