laravel-request 1.1.27 → 1.1.29

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/types.d.ts +155 -0
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "laravel-request",
3
3
  "productName": "laravel-request",
4
- "version": "1.1.27",
4
+ "version": "1.1.29",
5
5
  "description": "laravel-request",
6
6
  "main": "src/index.js",
7
+ "module": "src/index.js",
7
8
  "scripts": {},
8
9
  "keywords": [],
9
10
  "author": {
package/src/types.d.ts ADDED
@@ -0,0 +1,155 @@
1
+ // Define an interface for the ApiRequest class
2
+ interface ApiRequest {
3
+ addArg(arg: string): ApiRequest;
4
+ setUrl(url: string): ApiRequest;
5
+ // Add other methods and properties as required
6
+ }
7
+
8
+ // Define the Api class type with all static methods
9
+ declare class Api {
10
+ static debug: boolean;
11
+ static requestClass: any;
12
+ static tokenResolver: () => Promise<string | null>;
13
+ static domainResolver: () => string;
14
+
15
+ static getArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest;
16
+ static postArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest;
17
+ static putArg(controller: string, action: string, arg: string, data?: Record<string, any>): ApiRequest;
18
+
19
+ static getUrl(url: string, data?: Record<string, any>): ApiRequest;
20
+ static postUrl(url: string, data?: Record<string, any>): ApiRequest;
21
+ static putUrl(url: string, data?: Record<string, any>): ApiRequest;
22
+
23
+ static get(controller: string, action: string, data?: Record<string, any>): ApiRequest;
24
+ static post(controller: string, action: string, data?: Record<string, any>): ApiRequest;
25
+ static put(controller: string, action: string, data?: Record<string, any>): ApiRequest;
26
+ static delete(controller: string, action: string, id: string, data?: Record<string, any>): ApiRequest;
27
+
28
+ static encodeQueryString(params: Record<string, any>): string;
29
+ static logRequest(request: {
30
+ url: string;
31
+ method: string;
32
+ data?: Record<string, any>;
33
+ params?: Record<string, any>;
34
+ headers?: Record<string, any>;
35
+ }): void;
36
+
37
+ static makeRequest(params: {
38
+ url: string;
39
+ method: string;
40
+ data?: Record<string, any>;
41
+ params?: Record<string, any>;
42
+ headers?: Record<string, any>;
43
+ success?: (response: any, status: number, xhr: any) => void;
44
+ error?: (xhr: any, statusCode: number, statusText: string) => void;
45
+ }): Promise<any>;
46
+ }
47
+
48
+ declare class Builder {
49
+ static availableMethod: string[];
50
+
51
+ query: Array<Record<string, any>>;
52
+
53
+ constructor();
54
+
55
+ add(method: string, args: any[]): Builder;
56
+
57
+ toArray(): Array<Record<string, any>>;
58
+
59
+ // Define dynamic method signatures for available methods
60
+ select(...args: any[]): Builder;
61
+ where(...args: any[]): Builder;
62
+ orWhere(...args: any[]): Builder;
63
+ whereDate(...args: any[]): Builder;
64
+ orWhereDate(...args: any[]): Builder;
65
+ whereYear(...args: any[]): Builder;
66
+ orWhereYear(...args: any[]): Builder;
67
+ whereMonth(...args: any[]): Builder;
68
+ orWhereMonth(...args: any[]): Builder;
69
+ has(...args: any[]): Builder;
70
+ whereIn(...args: any[]): Builder;
71
+ orWhereIn(...args: any[]): Builder;
72
+ whereNotIn(...args: any[]): Builder;
73
+ orWhereNotIn(...args: any[]): Builder;
74
+ whereHas(...args: any[]): Builder;
75
+ orWhereHas(...args: any[]): Builder;
76
+ whereHasMorph(...args: any[]): Builder;
77
+ orWhereHasMorph(...args: any[]): Builder;
78
+ whereDoesntHave(...args: any[]): Builder;
79
+ orWhereDoesntHave(...args: any[]): Builder;
80
+ whereNull(...args: any[]): Builder;
81
+ orWhereNull(...args: any[]): Builder;
82
+ whereNotNull(...args: any[]): Builder;
83
+ orWhereNotNull(...args: any[]): Builder;
84
+ orderBy(...args: any[]): Builder;
85
+ groupBy(...args: any[]): Builder;
86
+ with(...args: any[]): Builder;
87
+ withCount(...args: any[]): Builder;
88
+ offset(...args: any[]): Builder;
89
+ limit(...args: any[]): Builder;
90
+ distinct(...args: any[]): Builder;
91
+ owner(...args: any[]): Builder;
92
+ whereAbs(...args: any[]): Builder;
93
+ }
94
+
95
+ interface Target {
96
+ state: Record<string, any>;
97
+ setState(callback: (prevState: Record<string, any>) => Record<string, any>, onSuccess?: () => void): void;
98
+ }
99
+
100
+ declare class Binding {
101
+ target: Target;
102
+ pathTarget: string[];
103
+ pathData: string[];
104
+ callback?: () => void;
105
+ rerender: boolean;
106
+
107
+ constructor(
108
+ target: Target,
109
+ pathTarget: string,
110
+ pathData: string,
111
+ rerender: boolean,
112
+ onSuccess?: () => void
113
+ );
114
+
115
+ fire(data: Record<string, any>): void;
116
+
117
+ getData(value: Record<string, any>): any;
118
+ }
119
+
120
+ declare class ApiProxy {
121
+
122
+ }
123
+
124
+ interface Query {
125
+ orderBy(field: string, direction: string): Query;
126
+ where(field: string, operator: string, value: any): Query;
127
+ // Define other methods as required
128
+ }
129
+
130
+ interface OptionData {
131
+ value: string;
132
+ method?: (query: Query, value: string) => void;
133
+ field?: string;
134
+ operator?: string;
135
+ }
136
+
137
+ interface Options {
138
+ [key: string]: OptionData;
139
+ }
140
+
141
+ // Declare the UrlBind class
142
+ declare class UrlBind {
143
+ static parse: boolean;
144
+
145
+ static order(query: Query, options: { value: string }): Query;
146
+
147
+ static filter(query: Query, options: Options): Query;
148
+
149
+ static getParams(query: Query, options: Options): Query;
150
+
151
+ static urlParse(obj: Record<string, OptionData>): void;
152
+ }
153
+
154
+ // If necessary, export the types for external usage
155
+ export { ApiRequest, Api, Builder, Binding, ApiProxy, UrlBind, Query, OptionData, Options };