@wix/api-client
Advanced tools
Comparing version 1.1.69 to 1.1.70
@@ -7,3 +7,3 @@ "use strict"; | ||
var _common = require("./common"); | ||
const wrapperBuilder = (origFunc, authStrategy, headers, publicMetadata | ||
const wrapperBuilder = (origFunc, publicMetadata, boundFetch | ||
// @ts-expect-error | ||
@@ -21,5 +21,4 @@ ) => { | ||
try { | ||
const authHeaders = await authStrategy.getAuthHeaders(); | ||
const biHeader = (0, _biHeaderGenerator.biHeaderGenerator)(requestOptions, publicMetadata); | ||
const res = await fetch(url, { | ||
const res = await boundFetch(url, { | ||
method: requestOptions.method, | ||
@@ -30,4 +29,2 @@ ...(requestOptions.data && { | ||
headers: { | ||
...headers, | ||
...(authHeaders == null ? void 0 : authHeaders.headers), | ||
...biHeader | ||
@@ -92,2 +89,13 @@ } | ||
}; | ||
const boundFetch = async (url, options) => { | ||
const authHeaders = await authStrategy.getAuthHeaders(); | ||
return fetch(url, { | ||
...options, | ||
headers: { | ||
..._headers, | ||
...(authHeaders == null ? void 0 : authHeaders.headers), | ||
...(options == null ? void 0 : options.headers) | ||
} | ||
}); | ||
}; | ||
const isObject = val => val && typeof val === 'object' && !Array.isArray(val); | ||
@@ -99,3 +107,3 @@ const traverse = obj => { | ||
} else if (typeof obj[key] === 'function') { | ||
prev[key] = wrapperBuilder(value, authStrategy, _headers, obj[_common.PUBLIC_METADATA_KEY] ?? {}); | ||
prev[key] = wrapperBuilder(value, obj[_common.PUBLIC_METADATA_KEY] ?? {}, boundFetch); | ||
} else { | ||
@@ -116,5 +124,11 @@ prev[key] = value; | ||
auth: authStrategy, | ||
setHeaders | ||
setHeaders, | ||
fetch: (relativeUrl, options) => { | ||
const finalUrl = new URL(relativeUrl, `https://${_common.API_URL}`); | ||
finalUrl.host = _common.API_URL; | ||
finalUrl.protocol = 'https'; | ||
return boundFetch(finalUrl, options); | ||
} | ||
}; | ||
} | ||
//# sourceMappingURL=wixClient.js.map |
import { biHeaderGenerator } from './bi/biHeaderGenerator'; | ||
import { PUBLIC_METADATA_KEY, API_URL } from './common'; | ||
const wrapperBuilder = (origFunc, authStrategy, headers, publicMetadata | ||
const wrapperBuilder = (origFunc, publicMetadata, boundFetch | ||
// @ts-expect-error | ||
@@ -16,5 +16,4 @@ ) => { | ||
try { | ||
const authHeaders = await authStrategy.getAuthHeaders(); | ||
const biHeader = biHeaderGenerator(requestOptions, publicMetadata); | ||
const res = await fetch(url, { | ||
const res = await boundFetch(url, { | ||
method: requestOptions.method, | ||
@@ -25,4 +24,2 @@ ...(requestOptions.data && { | ||
headers: { | ||
...headers, | ||
...(authHeaders == null ? void 0 : authHeaders.headers), | ||
...biHeader | ||
@@ -87,2 +84,13 @@ } | ||
}; | ||
const boundFetch = async (url, options) => { | ||
const authHeaders = await authStrategy.getAuthHeaders(); | ||
return fetch(url, { | ||
...options, | ||
headers: { | ||
..._headers, | ||
...(authHeaders == null ? void 0 : authHeaders.headers), | ||
...(options == null ? void 0 : options.headers) | ||
} | ||
}); | ||
}; | ||
const isObject = val => val && typeof val === 'object' && !Array.isArray(val); | ||
@@ -96,3 +104,3 @@ const traverse = obj => { | ||
var _obj$PUBLIC_METADATA_; | ||
prev[key] = wrapperBuilder(value, authStrategy, _headers, (_obj$PUBLIC_METADATA_ = obj[PUBLIC_METADATA_KEY]) != null ? _obj$PUBLIC_METADATA_ : {}); | ||
prev[key] = wrapperBuilder(value, (_obj$PUBLIC_METADATA_ = obj[PUBLIC_METADATA_KEY]) != null ? _obj$PUBLIC_METADATA_ : {}, boundFetch); | ||
} else { | ||
@@ -113,5 +121,11 @@ prev[key] = value; | ||
auth: authStrategy, | ||
setHeaders | ||
setHeaders, | ||
fetch: (relativeUrl, options) => { | ||
const finalUrl = new URL(relativeUrl, "https://" + API_URL); | ||
finalUrl.host = API_URL; | ||
finalUrl.protocol = 'https'; | ||
return boundFetch(finalUrl, options); | ||
} | ||
}; | ||
} | ||
//# sourceMappingURL=wixClient.js.map |
@@ -12,2 +12,3 @@ import { Simplify } from 'type-fest'; | ||
auth: Z; | ||
fetch(relativeUrl: string, options: RequestInit): Promise<Response>; | ||
} | ||
@@ -14,0 +15,0 @@ export declare function createClient<T = any, Z extends AuthenticationStrategy = any>(config: { |
{ | ||
"name": "@wix/api-client", | ||
"version": "1.1.69", | ||
"version": "1.1.70", | ||
"license": "UNLICENSED", | ||
@@ -35,3 +35,3 @@ "author": { | ||
"@wix/redirects": "^1.0.13", | ||
"@wix/sdk-types": "1.1.69", | ||
"@wix/sdk-types": "1.1.70", | ||
"pkce-challenge": "^3.1.0", | ||
@@ -75,3 +75,3 @@ "querystring": "^0.2.1", | ||
}, | ||
"falconPackageHash": "1ded8d2f8b9f925d9ab1bf82e3686057ec4ab2ae0218bcdb99a69427" | ||
"falconPackageHash": "24c5f194c355795e6e670f56d7d3226d3b4c6d32242c36bf80459dc0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
474447
3652
+ Added@wix/sdk-types@1.1.70(transitive)
- Removed@wix/sdk-types@1.1.69(transitive)
Updated@wix/sdk-types@1.1.70