@wix/sdk 1.2.7 → 1.2.8

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.
@@ -1,6 +1,8 @@
1
1
  // src/common.ts
2
2
  var PUBLIC_METADATA_KEY = "__metadata";
3
3
  var API_URL = "www.wixapis.com";
4
+ var READ_ONLY_API_URL = "readonly.wixapis.com";
5
+ var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
4
6
 
5
7
  // src/helpers.ts
6
8
  var getDefaultContentHeader = (options) => {
@@ -40,7 +42,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
40
42
  request: async (factory) => {
41
43
  var _a;
42
44
  const requestOptions = factory({ host: API_URL });
43
- let url = `https://${API_URL}${requestOptions.url}`;
45
+ const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
46
+ let url = `https://${domain}${requestOptions.url}`;
44
47
  if (requestOptions.params && requestOptions.params.toString()) {
45
48
  url += `?${requestOptions.params.toString()}`;
46
49
  }
package/build/index.js CHANGED
@@ -44,6 +44,8 @@ module.exports = __toCommonJS(src_exports);
44
44
  // src/common.ts
45
45
  var PUBLIC_METADATA_KEY = "__metadata";
46
46
  var API_URL = "www.wixapis.com";
47
+ var READ_ONLY_API_URL = "readonly.wixapis.com";
48
+ var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
47
49
 
48
50
  // src/helpers.ts
49
51
  var getDefaultContentHeader = (options) => {
@@ -81,7 +83,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
81
83
  return origFunc({
82
84
  request: async (factory) => {
83
85
  const requestOptions = factory({ host: API_URL });
84
- let url = `https://${API_URL}${requestOptions.url}`;
86
+ const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
87
+ let url = `https://${domain}${requestOptions.url}`;
85
88
  if (requestOptions.params && requestOptions.params.toString()) {
86
89
  url += `?${requestOptions.params.toString()}`;
87
90
  }
package/build/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  // src/common.ts
2
2
  var PUBLIC_METADATA_KEY = "__metadata";
3
3
  var API_URL = "www.wixapis.com";
4
+ var READ_ONLY_API_URL = "readonly.wixapis.com";
5
+ var FORCE_WRITE_API_URLS = ["/ecom/v1/carts/current"];
4
6
 
5
7
  // src/helpers.ts
6
8
  var getDefaultContentHeader = (options) => {
@@ -38,7 +40,8 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch) {
38
40
  return origFunc({
39
41
  request: async (factory) => {
40
42
  const requestOptions = factory({ host: API_URL });
41
- let url = `https://${API_URL}${requestOptions.url}`;
43
+ const domain = requestOptions.method === "GET" && !FORCE_WRITE_API_URLS.some((url2) => requestOptions.url === url2) ? READ_ONLY_API_URL : API_URL;
44
+ let url = `https://${domain}${requestOptions.url}`;
42
45
  if (requestOptions.params && requestOptions.params.toString()) {
43
46
  url += `?${requestOptions.params.toString()}`;
44
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -34,7 +34,7 @@
34
34
  "@wix/identity": "^1.0.47",
35
35
  "@wix/image-kit": "^1.35.0",
36
36
  "@wix/redirects": "^1.0.22",
37
- "@wix/sdk-types": "1.2.7",
37
+ "@wix/sdk-types": "1.2.8",
38
38
  "pkce-challenge": "^3.1.0",
39
39
  "querystring": "^0.2.1",
40
40
  "type-fest": "^3.13.1"
@@ -79,5 +79,5 @@
79
79
  "wallaby": {
80
80
  "autoDetect": true
81
81
  },
82
- "falconPackageHash": "0180e73db01d9fbc1b95a4afb3f5d9e3a6e79c043617f083429ad6da"
82
+ "falconPackageHash": "07eb178e34d03b5584413811900bdedde21e79d9438809689ff22469"
83
83
  }