@wix/sdk 1.5.2 → 1.5.4

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,5 +1,4 @@
1
1
  // src/ambassador-modules.ts
2
- import { transformError } from "@wix/metro-runtime/velo";
3
2
  var parseMethod = (method) => {
4
3
  switch (method) {
5
4
  case "get":
@@ -61,7 +60,10 @@ var toHTTPModule = (factory) => (httpClient) => async (payload) => {
61
60
  });
62
61
  return data;
63
62
  } catch (e) {
64
- throw transformError(e);
63
+ if (typeof e === "object" && e !== null && "response" in e && typeof e.response === "object" && e.response !== null && "data" in e.response) {
64
+ throw e.response.data;
65
+ }
66
+ throw e;
65
67
  }
66
68
  };
67
69
  var ambassadorModuleOptions = () => ({
@@ -228,8 +230,13 @@ function createClient(config) {
228
230
  const authStrategy = config.auth || {
229
231
  getAuthHeaders: () => Promise.resolve({ headers: {} })
230
232
  };
233
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
234
+ void 0,
235
+ config.host
236
+ );
237
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
231
238
  const boundFetch = async (url, options) => {
232
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
239
+ const authHeaders = await boundGetAuthHeaders();
233
240
  const defaultContentTypeHeader = getDefaultContentHeader(options);
234
241
  return fetch(url, {
235
242
  ...options,
package/build/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
1
+ import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy, BoundAuthenticationStrategy } from '@wix/sdk-types';
2
2
  export * from '@wix/sdk-types';
3
3
  import { ConditionalExcept, EmptyObject } from 'type-fest';
4
4
  import { ImageTransformOptions } from '@wix/image-kit';
@@ -129,7 +129,7 @@ type TypedQueryInput<Result = {
129
129
  };
130
130
  type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
131
131
  setHeaders(headers: Headers): void;
132
- auth: Z;
132
+ auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy;
133
133
  fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
134
134
  use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
135
135
  graphql<Result, Variables>(query: string | ((string | String) & TypedQueryInput<Result, Variables>), variables?: Variables): Promise<{
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy } from '@wix/sdk-types';
1
+ import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy, BoundAuthenticationStrategy } from '@wix/sdk-types';
2
2
  export * from '@wix/sdk-types';
3
3
  import { ConditionalExcept, EmptyObject } from 'type-fest';
4
4
  import { ImageTransformOptions } from '@wix/image-kit';
@@ -129,7 +129,7 @@ type TypedQueryInput<Result = {
129
129
  };
130
130
  type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = Descriptors> = {
131
131
  setHeaders(headers: Headers): void;
132
- auth: Z;
132
+ auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy;
133
133
  fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
134
134
  use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
135
135
  graphql<Result, Variables>(query: string | ((string | String) & TypedQueryInput<Result, Variables>), variables?: Variables): Promise<{
package/build/index.js CHANGED
@@ -45,7 +45,6 @@ __export(src_exports, {
45
45
  module.exports = __toCommonJS(src_exports);
46
46
 
47
47
  // src/ambassador-modules.ts
48
- var import_velo = require("@wix/metro-runtime/velo");
49
48
  var parseMethod = (method) => {
50
49
  switch (method) {
51
50
  case "get":
@@ -107,7 +106,10 @@ var toHTTPModule = (factory) => (httpClient) => async (payload) => {
107
106
  });
108
107
  return data;
109
108
  } catch (e) {
110
- throw (0, import_velo.transformError)(e);
109
+ if (typeof e === "object" && e !== null && "response" in e && typeof e.response === "object" && e.response !== null && "data" in e.response) {
110
+ throw e.response.data;
111
+ }
112
+ throw e;
111
113
  }
112
114
  };
113
115
  var ambassadorModuleOptions = () => ({
@@ -272,8 +274,13 @@ function createClient(config) {
272
274
  const authStrategy = config.auth || {
273
275
  getAuthHeaders: () => Promise.resolve({ headers: {} })
274
276
  };
277
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
278
+ void 0,
279
+ config.host
280
+ );
281
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
275
282
  const boundFetch = async (url, options) => {
276
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
283
+ const authHeaders = await boundGetAuthHeaders();
277
284
  const defaultContentTypeHeader = getDefaultContentHeader(options);
278
285
  return fetch(url, {
279
286
  ...options,
package/build/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/ambassador-modules.ts
2
- import { transformError } from "@wix/metro-runtime/velo";
3
2
  var parseMethod = (method) => {
4
3
  switch (method) {
5
4
  case "get":
@@ -61,7 +60,10 @@ var toHTTPModule = (factory) => (httpClient) => async (payload) => {
61
60
  });
62
61
  return data;
63
62
  } catch (e) {
64
- throw transformError(e);
63
+ if (typeof e === "object" && e !== null && "response" in e && typeof e.response === "object" && e.response !== null && "data" in e.response) {
64
+ throw e.response.data;
65
+ }
66
+ throw e;
65
67
  }
66
68
  };
67
69
  var ambassadorModuleOptions = () => ({
@@ -226,8 +228,13 @@ function createClient(config) {
226
228
  const authStrategy = config.auth || {
227
229
  getAuthHeaders: () => Promise.resolve({ headers: {} })
228
230
  };
231
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
232
+ void 0,
233
+ config.host
234
+ );
235
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
229
236
  const boundFetch = async (url, options) => {
230
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
237
+ const authHeaders = await boundGetAuthHeaders();
231
238
  const defaultContentTypeHeader = getDefaultContentHeader(options);
232
239
  return fetch(url, {
233
240
  ...options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -30,12 +30,11 @@
30
30
  "*.{js,ts}": "yarn lint"
31
31
  },
32
32
  "dependencies": {
33
- "@babel/runtime": "^7.23.1",
33
+ "@babel/runtime": "^7.23.2",
34
34
  "@wix/identity": "^1.0.59",
35
35
  "@wix/image-kit": "^1.37.0",
36
- "@wix/metro-runtime": "^1.1532.0",
37
36
  "@wix/redirects": "^1.0.25",
38
- "@wix/sdk-types": "1.5.0",
37
+ "@wix/sdk-types": "1.5.1",
39
38
  "pkce-challenge": "^3.1.0",
40
39
  "querystring": "^0.2.1",
41
40
  "type-fest": "^3.13.1"
@@ -44,21 +43,22 @@
44
43
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
45
44
  },
46
45
  "devDependencies": {
47
- "@swc/core": "^1.3.90",
46
+ "@swc/core": "^1.3.93",
48
47
  "@swc/jest": "^0.2.29",
49
48
  "@types/jest": "^27.5.2",
50
- "@types/node": "^16.18.55",
49
+ "@types/node": "^16.18.58",
51
50
  "@types/node-fetch": "^2.6.6",
52
- "@wix/ecom": "^1.0.362",
53
- "@wix/events": "^1.0.122",
51
+ "@wix/ecom": "^1.0.368",
52
+ "@wix/events": "^1.0.123",
54
53
  "@wix/metro": "^1.0.67",
54
+ "@wix/metro-runtime": "^1.1535.0",
55
55
  "eslint": "^7.32.0",
56
56
  "eslint-config-sdk": "0.0.0",
57
57
  "graphql": "16.8.0",
58
58
  "is-ci": "^3.0.1",
59
59
  "jest": "^27.5.1",
60
60
  "jest-teamcity": "^1.11.0",
61
- "nock": "^13.3.3",
61
+ "nock": "^13.3.4",
62
62
  "node-fetch": "2.6.13",
63
63
  "ts-jest": "^27.1.5",
64
64
  "tsup": "^7.2.0",
@@ -87,5 +87,5 @@
87
87
  "wallaby": {
88
88
  "autoDetect": true
89
89
  },
90
- "falconPackageHash": "436f8b50b1fbb8db0e67f27ef487fa65cec40d5a6400f7e564e70a47"
90
+ "falconPackageHash": "e498be541d229f09abe203e6929470b0570c8260794f01c4c07b4c94"
91
91
  }