valyrian.js 7.2.12 → 8.0.1
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/README.md +6 -6
- package/dist/flux-store/index.d.ts +32 -0
- package/dist/flux-store/index.d.ts.map +1 -0
- package/dist/flux-store/index.js +267 -0
- package/dist/flux-store/index.js.map +7 -0
- package/dist/flux-store/index.min.js +1 -0
- package/dist/flux-store/index.min.js.map +1 -0
- package/dist/flux-store/index.mjs +246 -0
- package/dist/flux-store/index.mjs.map +7 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +35 -51
- package/dist/hooks/index.js.map +3 -3
- package/dist/hooks/index.min.js +1 -0
- package/dist/hooks/index.min.js.map +1 -0
- package/dist/hooks/index.mjs +36 -52
- package/dist/hooks/index.mjs.map +3 -3
- package/dist/index.d.ts +18 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +107 -88
- package/dist/index.js.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +107 -88
- package/dist/index.mjs.map +3 -3
- package/dist/native-store/index.d.ts +14 -0
- package/dist/native-store/index.d.ts.map +1 -0
- package/dist/native-store/index.js +103 -0
- package/dist/native-store/index.js.map +7 -0
- package/dist/native-store/index.min.js +1 -0
- package/dist/native-store/index.min.js.map +1 -0
- package/dist/native-store/index.mjs +82 -0
- package/dist/native-store/index.mjs.map +7 -0
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +125 -10
- package/dist/node/index.js.map +4 -4
- package/dist/node/index.mjs +125 -10
- package/dist/node/index.mjs.map +4 -4
- package/dist/node/node.sw.js +152 -0
- package/dist/node/utils/icons.d.ts +4 -5
- package/dist/node/utils/icons.d.ts.map +1 -1
- package/dist/node/utils/inline.d.ts +1 -1
- package/dist/node/utils/inline.d.ts.map +1 -1
- package/dist/node/utils/node.sw.js +152 -0
- package/dist/node/utils/session-storage.d.ts +22 -0
- package/dist/node/utils/session-storage.d.ts.map +1 -0
- package/dist/node/utils/sw.d.ts.map +1 -1
- package/dist/node/utils/tree-adapter.d.ts +5 -1
- package/dist/node/utils/tree-adapter.d.ts.map +1 -1
- package/dist/pulse-store/index.d.ts +16 -0
- package/dist/pulse-store/index.d.ts.map +1 -0
- package/dist/pulse-store/index.js +143 -0
- package/dist/pulse-store/index.js.map +7 -0
- package/dist/pulse-store/index.min.js +1 -0
- package/dist/pulse-store/index.min.js.map +1 -0
- package/dist/pulse-store/index.mjs +122 -0
- package/dist/pulse-store/index.mjs.map +7 -0
- package/dist/request/index.d.ts +11 -11
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +63 -84
- package/dist/request/index.js.map +2 -2
- package/dist/request/index.min.js +1 -0
- package/dist/request/index.min.js.map +1 -0
- package/dist/request/index.mjs +63 -84
- package/dist/request/index.mjs.map +2 -2
- package/dist/router/index.d.ts +36 -33
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +247 -96
- package/dist/router/index.js.map +3 -3
- package/dist/router/index.min.js +1 -0
- package/dist/router/index.min.js.map +1 -0
- package/dist/router/index.mjs +247 -96
- package/dist/router/index.mjs.map +3 -3
- package/dist/signals/index.d.ts +6 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +92 -0
- package/dist/signals/index.js.map +7 -0
- package/dist/signals/index.min.js +1 -0
- package/dist/signals/index.min.js.map +1 -0
- package/dist/signals/index.mjs +71 -0
- package/dist/signals/index.mjs.map +7 -0
- package/dist/suspense/index.d.ts +6 -0
- package/dist/suspense/index.d.ts.map +1 -0
- package/dist/suspense/index.js +67 -0
- package/dist/suspense/index.js.map +7 -0
- package/dist/suspense/index.min.js +1 -0
- package/dist/suspense/index.min.js.map +1 -0
- package/dist/suspense/index.mjs +46 -0
- package/dist/suspense/index.mjs.map +7 -0
- package/dist/sw/index.min.js +1 -0
- package/dist/sw/index.min.js.map +1 -0
- package/dist/translate/index.d.ts +19 -0
- package/dist/translate/index.d.ts.map +1 -0
- package/dist/translate/index.js +150 -0
- package/dist/translate/index.js.map +7 -0
- package/dist/translate/index.min.js +1 -0
- package/dist/translate/index.min.js.map +1 -0
- package/dist/translate/index.mjs +129 -0
- package/dist/translate/index.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/deep-freeze.d.ts +3 -0
- package/dist/utils/deep-freeze.d.ts.map +1 -0
- package/dist/utils/getter-setter.d.ts +3 -0
- package/dist/utils/getter-setter.d.ts.map +1 -0
- package/dist/utils/has-changed.d.ts +2 -0
- package/dist/utils/has-changed.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +138 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/index.min.js +1 -0
- package/dist/utils/index.min.js.map +1 -0
- package/dist/utils/index.mjs +115 -0
- package/dist/utils/index.mjs.map +7 -0
- package/lib/flux-store/index.ts +312 -0
- package/lib/hooks/index.ts +39 -57
- package/lib/index.ts +135 -118
- package/lib/native-store/index.ts +106 -0
- package/lib/node/index.ts +3 -1
- package/lib/node/utils/icons.ts +4 -4
- package/lib/node/utils/inline.ts +2 -0
- package/lib/node/utils/node.sw.js +152 -0
- package/lib/node/utils/session-storage.ts +117 -0
- package/lib/node/utils/sw.ts +34 -10
- package/lib/node/utils/tree-adapter.ts +19 -1
- package/lib/pulse-store/index.ts +188 -0
- package/lib/request/index.ts +92 -122
- package/lib/router/index.ts +353 -164
- package/lib/signals/index.ts +98 -0
- package/lib/suspense/index.ts +57 -0
- package/lib/translate/index.ts +156 -0
- package/lib/utils/deep-freeze.ts +54 -0
- package/lib/utils/getter-setter.ts +40 -0
- package/lib/utils/has-changed.ts +43 -0
- package/lib/utils/index.ts +3 -0
- package/package.json +40 -57
- package/tsconfig.json +5 -4
- package/dist/dataset/index.d.ts +0 -24
- package/dist/dataset/index.d.ts.map +0 -1
- package/dist/dataset/index.js +0 -178
- package/dist/dataset/index.js.map +0 -7
- package/dist/dataset/index.mjs +0 -157
- package/dist/dataset/index.mjs.map +0 -7
- package/dist/node/node.sw.tpl +0 -133
- package/dist/node/utils/node.sw.tpl +0 -133
- package/dist/proxy-signal/index.d.ts +0 -23
- package/dist/proxy-signal/index.d.ts.map +0 -1
- package/dist/proxy-signal/index.js +0 -138
- package/dist/proxy-signal/index.js.map +0 -7
- package/dist/proxy-signal/index.mjs +0 -117
- package/dist/proxy-signal/index.mjs.map +0 -7
- package/dist/signal/index.d.ts +0 -9
- package/dist/signal/index.d.ts.map +0 -1
- package/dist/signal/index.js +0 -76
- package/dist/signal/index.js.map +0 -7
- package/dist/signal/index.mjs +0 -55
- package/dist/signal/index.mjs.map +0 -7
- package/dist/store/index.d.ts +0 -16
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -93
- package/dist/store/index.js.map +0 -7
- package/dist/store/index.mjs +0 -72
- package/dist/store/index.mjs.map +0 -7
- package/lib/dataset/index.ts +0 -193
- package/lib/node/utils/node.sw.tpl +0 -133
- package/lib/proxy-signal/index.ts +0 -187
- package/lib/signal/index.ts +0 -86
- package/lib/store/index.ts +0 -101
package/lib/request/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { isNodeJs } from "valyrian.js";
|
|
2
|
+
import { get, set } from "valyrian.js/utils";
|
|
2
3
|
|
|
3
4
|
interface UrlOptions {
|
|
4
|
-
base
|
|
5
|
-
node
|
|
6
|
-
api
|
|
5
|
+
base?: string; // Used to prefix the url for scoped requests.
|
|
6
|
+
node?: string | null; // Used to redirect local requests to node server for server side rendering.
|
|
7
|
+
api?: string | null; // Used to redirect api requests to node server for server side rendering.
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
interface RequestOptions {
|
|
@@ -26,7 +27,7 @@ interface SendOptions extends RequestOptionsWithUrls, RequestInit {
|
|
|
26
27
|
|
|
27
28
|
export interface RequestInterface {
|
|
28
29
|
// eslint-disable-next-line no-unused-vars
|
|
29
|
-
(method: string, url: string, data?: Record<string, any
|
|
30
|
+
(method: string, url: string, data?: Record<string, any> | null, options?: Partial<SendOptions>): any | Response;
|
|
30
31
|
// eslint-disable-next-line no-unused-vars
|
|
31
32
|
new: (baseUrl: string, options?: RequestOptions) => RequestInterface;
|
|
32
33
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -34,58 +35,64 @@ export interface RequestInterface {
|
|
|
34
35
|
// eslint-disable-next-line no-unused-vars
|
|
35
36
|
getOptions: (key?: string) => RequestOptions | void;
|
|
36
37
|
// eslint-disable-next-line no-unused-vars
|
|
37
|
-
get: (url: string, data?: Record<string, any
|
|
38
|
+
get: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
38
39
|
// eslint-disable-next-line no-unused-vars
|
|
39
|
-
post: (url: string, data?: Record<string, any
|
|
40
|
+
post: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
40
41
|
// eslint-disable-next-line no-unused-vars
|
|
41
|
-
put: (url: string, data?: Record<string, any
|
|
42
|
+
put: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
42
43
|
// eslint-disable-next-line no-unused-vars
|
|
43
|
-
patch: (url: string, data?: Record<string, any
|
|
44
|
+
patch: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
44
45
|
// eslint-disable-next-line no-unused-vars
|
|
45
|
-
delete: (url: string, data?: Record<string, any
|
|
46
|
+
delete: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
46
47
|
// eslint-disable-next-line no-unused-vars
|
|
47
|
-
head: (url: string, data?: Record<string, any
|
|
48
|
+
head: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
48
49
|
// eslint-disable-next-line no-unused-vars
|
|
49
|
-
options: (url: string, data?: Record<string, any
|
|
50
|
+
options: (url: string, data?: Record<string, any> | null, options?: Record<string, any>) => any | Response;
|
|
50
51
|
[key: string | number | symbol]: any;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
// This method is used to serialize an object into a query string.
|
|
54
|
-
function serialize(obj: Record<string, any>, prefix: string = ""):
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
55
|
+
function serialize(obj: Record<string, any>, prefix: string = ""): URLSearchParams {
|
|
56
|
+
const params = new URLSearchParams();
|
|
57
|
+
|
|
58
|
+
Object.keys(obj).forEach((prop: string) => {
|
|
59
|
+
const key = prefix ? `${prefix}[${prop}]` : prop;
|
|
60
|
+
if (typeof obj[prop] === "object") {
|
|
61
|
+
params.append(key, serialize(obj[prop], key).toString());
|
|
62
|
+
} else {
|
|
63
|
+
params.append(key, obj[prop]);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
return params;
|
|
68
|
+
}
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
function serializeFormData(data: Record<string, any>): FormData {
|
|
71
|
+
return Object.entries(data).reduce((fd, [key, value]) => {
|
|
72
|
+
fd.append(key, value);
|
|
73
|
+
return fd;
|
|
74
|
+
}, new FormData());
|
|
75
|
+
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
77
|
+
function parseUrl(url: string, options: RequestOptionsWithUrls) {
|
|
78
|
+
const urlWithoutSlash = url.replace(/\/+$/, "").trim();
|
|
79
|
+
const u = /^https?/gi.test(urlWithoutSlash) ? urlWithoutSlash : `${options.urls.base}${urlWithoutSlash}`;
|
|
74
80
|
|
|
75
81
|
if (isNodeJs && typeof options.urls.node === "string") {
|
|
76
|
-
options.urls.node = options.urls.node;
|
|
77
|
-
|
|
78
82
|
if (typeof options.urls.api === "string") {
|
|
79
|
-
options.urls.api
|
|
80
|
-
u = u.replace(options.urls.api, options.urls.node);
|
|
83
|
+
return new URL(u.replace(options.urls.api, options.urls.node));
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
if (!/^https?/gi.test(u)) {
|
|
84
|
-
u
|
|
87
|
+
return new URL(u, options.urls.node);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
|
|
91
|
+
if (/^https?/gi.test(u)) {
|
|
92
|
+
return new URL(u);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return new URL(u, options.urls.base);
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
const defaultOptions: RequestOptions = { allowedMethods: ["get", "post", "put", "patch", "delete", "head", "options"] };
|
|
@@ -114,7 +121,13 @@ function Requester(baseUrl = "", options: RequestOptions = defaultOptions) {
|
|
|
114
121
|
}
|
|
115
122
|
};
|
|
116
123
|
|
|
117
|
-
|
|
124
|
+
// eslint-disable-next-line complexity
|
|
125
|
+
const request = async function request(
|
|
126
|
+
method: string,
|
|
127
|
+
url: string,
|
|
128
|
+
data?: Record<string, any> | null,
|
|
129
|
+
options: Record<string, any> = {}
|
|
130
|
+
) {
|
|
118
131
|
const innerOptions: SendOptions = {
|
|
119
132
|
method: method.toUpperCase(),
|
|
120
133
|
headers: {},
|
|
@@ -123,6 +136,8 @@ function Requester(baseUrl = "", options: RequestOptions = defaultOptions) {
|
|
|
123
136
|
...options
|
|
124
137
|
} as SendOptions;
|
|
125
138
|
|
|
139
|
+
innerOptions.headers = { ...innerOptions.headers, ...opts.headers, ...options.headers };
|
|
140
|
+
|
|
126
141
|
if (!innerOptions.headers.Accept) {
|
|
127
142
|
innerOptions.headers.Accept = "application/json";
|
|
128
143
|
}
|
|
@@ -130,37 +145,31 @@ function Requester(baseUrl = "", options: RequestOptions = defaultOptions) {
|
|
|
130
145
|
const acceptType = innerOptions.headers.Accept;
|
|
131
146
|
const contentType = innerOptions.headers["Content-Type"] || innerOptions.headers["content-type"] || "";
|
|
132
147
|
|
|
133
|
-
if (innerOptions.allowedMethods.
|
|
134
|
-
throw new Error(
|
|
148
|
+
if (!innerOptions.allowedMethods.includes(method)) {
|
|
149
|
+
throw new Error(`Method ${method} not allowed. Allowed methods: ${innerOptions.allowedMethods.join(", ")}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let finalUrl: URL;
|
|
153
|
+
try {
|
|
154
|
+
finalUrl = parseUrl(url, opts);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
throw new Error(`Failed to parse URL: ${url}`);
|
|
135
157
|
}
|
|
136
158
|
|
|
137
159
|
if (data) {
|
|
138
|
-
|
|
139
|
-
url += `?${serialize(data)}`;
|
|
140
|
-
}
|
|
160
|
+
const isJson = /json/gi.test(contentType);
|
|
141
161
|
|
|
142
|
-
if (innerOptions.method
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let formData;
|
|
147
|
-
if (data instanceof FormData) {
|
|
148
|
-
formData = data;
|
|
149
|
-
} else {
|
|
150
|
-
formData = new FormData();
|
|
151
|
-
for (const i in data) {
|
|
152
|
-
formData.append(i, data[i]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
innerOptions.body = formData;
|
|
156
|
-
}
|
|
162
|
+
if (innerOptions.method === "GET" && typeof data === "object") {
|
|
163
|
+
finalUrl.search = serialize(data).toString();
|
|
164
|
+
} else if (innerOptions.method !== "GET") {
|
|
165
|
+
innerOptions.body = isJson ? JSON.stringify(data) : serializeFormData(data);
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
const response = await fetch(
|
|
169
|
+
const response = await fetch(finalUrl.toString(), innerOptions);
|
|
161
170
|
let body = null;
|
|
162
171
|
if (!response.ok) {
|
|
163
|
-
const err = new Error(response.statusText) as Error & { response?: any; body?: any };
|
|
172
|
+
const err = new Error(`${response.status}: ${response.statusText}`) as Error & { response?: any; body?: any };
|
|
164
173
|
err.response = response;
|
|
165
174
|
if (/text/gi.test(acceptType)) {
|
|
166
175
|
err.body = await response.text();
|
|
@@ -170,7 +179,9 @@ function Requester(baseUrl = "", options: RequestOptions = defaultOptions) {
|
|
|
170
179
|
try {
|
|
171
180
|
err.body = await response.json();
|
|
172
181
|
} catch (error) {
|
|
173
|
-
|
|
182
|
+
err.body = null;
|
|
183
|
+
// eslint-disable-next-line no-console
|
|
184
|
+
console.warn("Failed to parse JSON response:", error);
|
|
174
185
|
}
|
|
175
186
|
}
|
|
176
187
|
|
|
@@ -183,88 +194,47 @@ function Requester(baseUrl = "", options: RequestOptions = defaultOptions) {
|
|
|
183
194
|
|
|
184
195
|
if (/text/gi.test(acceptType)) {
|
|
185
196
|
body = await response.text();
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (/json/gi.test(acceptType)) {
|
|
197
|
+
} else if (/json/gi.test(acceptType)) {
|
|
190
198
|
try {
|
|
191
199
|
body = await response.json();
|
|
192
|
-
return body;
|
|
193
200
|
} catch (error) {
|
|
194
|
-
//
|
|
201
|
+
// eslint-disable-next-line no-console
|
|
202
|
+
console.warn("Failed to parse JSON response:", error);
|
|
203
|
+
body = null;
|
|
195
204
|
}
|
|
205
|
+
} else if (/blob/gi.test(acceptType)) {
|
|
206
|
+
body = await response.blob();
|
|
207
|
+
} else if (/arraybuffer/gi.test(acceptType)) {
|
|
208
|
+
body = await response.arrayBuffer();
|
|
209
|
+
} else {
|
|
210
|
+
body = response;
|
|
196
211
|
}
|
|
197
212
|
|
|
198
|
-
return response;
|
|
213
|
+
return body || response;
|
|
199
214
|
} as unknown as RequestInterface;
|
|
200
215
|
|
|
201
216
|
request.new = (baseUrl: string, options?: RequestOptions) => Requester(baseUrl, { ...opts, ...(options || {}) });
|
|
202
217
|
|
|
203
218
|
request.setOption = (key: string, value: any) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const parsed = key.split(".");
|
|
207
|
-
let next;
|
|
208
|
-
|
|
209
|
-
while (parsed.length) {
|
|
210
|
-
next = parsed.shift() as string;
|
|
211
|
-
|
|
212
|
-
const nextIsArray = next.indexOf("[") > -1;
|
|
213
|
-
if (nextIsArray) {
|
|
214
|
-
const idx = next.replace(/\D/gi, "");
|
|
215
|
-
next = next.split("[")[0];
|
|
216
|
-
parsed.unshift(idx);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (parsed.length > 0 && typeof result[next] !== "object") {
|
|
220
|
-
result[next] = nextIsArray ? [] : {};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (parsed.length === 0 && typeof value !== "undefined") {
|
|
224
|
-
result[next] = value;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
result = result[next];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return result;
|
|
219
|
+
set(opts, key, value);
|
|
220
|
+
return opts;
|
|
231
221
|
};
|
|
232
222
|
|
|
233
223
|
request.getOptions = (key?: string) => {
|
|
234
|
-
if (
|
|
235
|
-
return opts;
|
|
224
|
+
if (key) {
|
|
225
|
+
return get(opts, key);
|
|
236
226
|
}
|
|
237
227
|
|
|
238
|
-
|
|
239
|
-
const parsed = key.split(".");
|
|
240
|
-
let next;
|
|
241
|
-
|
|
242
|
-
while (parsed.length) {
|
|
243
|
-
next = parsed.shift() as string;
|
|
244
|
-
|
|
245
|
-
const nextIsArray = next.indexOf("[") > -1;
|
|
246
|
-
if (nextIsArray) {
|
|
247
|
-
const idx = next.replace(/\D/gi, "");
|
|
248
|
-
next = next.split("[")[0];
|
|
249
|
-
parsed.unshift(idx);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (parsed.length > 0 && typeof result[next] !== "object") {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (parsed.length === 0) {
|
|
257
|
-
return result[next];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
result = result[next];
|
|
261
|
-
}
|
|
228
|
+
return opts;
|
|
262
229
|
};
|
|
263
230
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
231
|
+
Object.assign(
|
|
232
|
+
request,
|
|
233
|
+
opts.allowedMethods.reduce((acc: Record<string, any>, method) => {
|
|
234
|
+
acc[method] = (url: string, data?: Record<string, any> | null, options?: Record<string, any>) =>
|
|
235
|
+
request(method, url, data, options);
|
|
236
|
+
return acc;
|
|
237
|
+
}, {})
|
|
268
238
|
);
|
|
269
239
|
|
|
270
240
|
return request;
|