@hyper-fetch/core 7.1.2 → 7.2.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/dist/browser/index.js +30 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/index.d.ts +6 -2
- package/dist/index.js +31 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/adapter/adapter.types.ts +2 -0
- package/src/client/client.create.ts +3 -1
- package/src/index.ts +1 -0
- package/src/request/request.ts +1 -1
- package/src/request/request.utils.ts +4 -6
- package/src/sdk/index.ts +1 -0
- package/src/sdk/sdk.ts +44 -0
package/dist/browser/index.js
CHANGED
|
@@ -360,7 +360,7 @@ var _Request = class _Request {
|
|
|
360
360
|
let stringEndpoint = String(endpoint);
|
|
361
361
|
if (params) {
|
|
362
362
|
Object.entries(params).forEach(([key, value]) => {
|
|
363
|
-
stringEndpoint =
|
|
363
|
+
stringEndpoint = stringEndpoint.replace(new RegExp(`:${key}`, "g"), String(value));
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
return stringEndpoint;
|
|
@@ -3605,6 +3605,34 @@ function createClient(options) {
|
|
|
3605
3605
|
options
|
|
3606
3606
|
);
|
|
3607
3607
|
}
|
|
3608
|
+
|
|
3609
|
+
// src/sdk/sdk.ts
|
|
3610
|
+
var createRecursiveProxy = (client, path) => {
|
|
3611
|
+
return new Proxy(() => {
|
|
3612
|
+
}, {
|
|
3613
|
+
get: (_target, key) => {
|
|
3614
|
+
if (typeof key === "symbol" || key === "inspect") {
|
|
3615
|
+
return void 0;
|
|
3616
|
+
}
|
|
3617
|
+
const endpoint = `/${path.join("/")}`;
|
|
3618
|
+
const method = key.toUpperCase();
|
|
3619
|
+
const request = client.createRequest()({ endpoint, method });
|
|
3620
|
+
const newPath = [...path, key.startsWith("$") ? `:${key.slice(1)}` : key];
|
|
3621
|
+
const deeperProxy = createRecursiveProxy(client, newPath);
|
|
3622
|
+
return new Proxy(request, {
|
|
3623
|
+
get: (reqTarget, reqKey) => {
|
|
3624
|
+
if (reqKey in reqTarget) {
|
|
3625
|
+
return reqTarget[reqKey];
|
|
3626
|
+
}
|
|
3627
|
+
return deeperProxy[reqKey];
|
|
3628
|
+
}
|
|
3629
|
+
});
|
|
3630
|
+
}
|
|
3631
|
+
});
|
|
3632
|
+
};
|
|
3633
|
+
var createSdk = (client) => {
|
|
3634
|
+
return createRecursiveProxy(client, []);
|
|
3635
|
+
};
|
|
3608
3636
|
export {
|
|
3609
3637
|
AbortError,
|
|
3610
3638
|
Adapter,
|
|
@@ -3629,6 +3657,7 @@ export {
|
|
|
3629
3657
|
appManagerInitialOptions,
|
|
3630
3658
|
canRetryRequest,
|
|
3631
3659
|
createClient,
|
|
3660
|
+
createSdk,
|
|
3632
3661
|
defaultMapper,
|
|
3633
3662
|
defaultTimeout,
|
|
3634
3663
|
getAbortByAbortKey,
|