@wix/sdk 1.5.3 → 1.5.5

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.
@@ -230,8 +230,13 @@ function createClient(config) {
230
230
  const authStrategy = config.auth || {
231
231
  getAuthHeaders: () => Promise.resolve({ headers: {} })
232
232
  };
233
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
234
+ void 0,
235
+ config.host
236
+ );
237
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
233
238
  const boundFetch = async (url, options) => {
234
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
239
+ const authHeaders = await boundGetAuthHeaders();
235
240
  const defaultContentTypeHeader = getDefaultContentHeader(options);
236
241
  return fetch(url, {
237
242
  ...options,
@@ -286,14 +291,19 @@ function createClient(config) {
286
291
  finalUrl.protocol = "https";
287
292
  return boundFetch(finalUrl, options);
288
293
  },
289
- async graphql(query, variables) {
290
- const res = await boundFetch(`https://${API_URL}/graphql`, {
291
- method: "POST",
292
- headers: {
293
- "Content-Type": "application/json"
294
- },
295
- body: JSON.stringify({ query, variables })
296
- });
294
+ async graphql(query, variables, opts = {
295
+ apiVersion: "alpha"
296
+ }) {
297
+ const res = await boundFetch(
298
+ `https://${API_URL}/graphql/${opts.apiVersion}`,
299
+ {
300
+ method: "POST",
301
+ headers: {
302
+ "Content-Type": "application/json"
303
+ },
304
+ body: JSON.stringify({ query, variables })
305
+ }
306
+ );
297
307
  if (res.status !== 200) {
298
308
  throw new FetchErrorResponse(
299
309
  `GraphQL request failed with status ${res.status}`,
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
@@ -274,8 +274,13 @@ function createClient(config) {
274
274
  const authStrategy = config.auth || {
275
275
  getAuthHeaders: () => Promise.resolve({ headers: {} })
276
276
  };
277
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
278
+ void 0,
279
+ config.host
280
+ );
281
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
277
282
  const boundFetch = async (url, options) => {
278
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
283
+ const authHeaders = await boundGetAuthHeaders();
279
284
  const defaultContentTypeHeader = getDefaultContentHeader(options);
280
285
  return fetch(url, {
281
286
  ...options,
@@ -330,14 +335,19 @@ function createClient(config) {
330
335
  finalUrl.protocol = "https";
331
336
  return boundFetch(finalUrl, options);
332
337
  },
333
- async graphql(query, variables) {
334
- const res = await boundFetch(`https://${API_URL}/graphql`, {
335
- method: "POST",
336
- headers: {
337
- "Content-Type": "application/json"
338
- },
339
- body: JSON.stringify({ query, variables })
340
- });
338
+ async graphql(query, variables, opts = {
339
+ apiVersion: "alpha"
340
+ }) {
341
+ const res = await boundFetch(
342
+ `https://${API_URL}/graphql/${opts.apiVersion}`,
343
+ {
344
+ method: "POST",
345
+ headers: {
346
+ "Content-Type": "application/json"
347
+ },
348
+ body: JSON.stringify({ query, variables })
349
+ }
350
+ );
341
351
  if (res.status !== 200) {
342
352
  throw new FetchErrorResponse(
343
353
  `GraphQL request failed with status ${res.status}`,
package/build/index.mjs CHANGED
@@ -228,8 +228,13 @@ function createClient(config) {
228
228
  const authStrategy = config.auth || {
229
229
  getAuthHeaders: () => Promise.resolve({ headers: {} })
230
230
  };
231
+ const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(
232
+ void 0,
233
+ config.host
234
+ );
235
+ authStrategy.getAuthHeaders = boundGetAuthHeaders;
231
236
  const boundFetch = async (url, options) => {
232
- const authHeaders = await authStrategy.getAuthHeaders(config.host);
237
+ const authHeaders = await boundGetAuthHeaders();
233
238
  const defaultContentTypeHeader = getDefaultContentHeader(options);
234
239
  return fetch(url, {
235
240
  ...options,
@@ -284,14 +289,19 @@ function createClient(config) {
284
289
  finalUrl.protocol = "https";
285
290
  return boundFetch(finalUrl, options);
286
291
  },
287
- async graphql(query, variables) {
288
- const res = await boundFetch(`https://${API_URL}/graphql`, {
289
- method: "POST",
290
- headers: {
291
- "Content-Type": "application/json"
292
- },
293
- body: JSON.stringify({ query, variables })
294
- });
292
+ async graphql(query, variables, opts = {
293
+ apiVersion: "alpha"
294
+ }) {
295
+ const res = await boundFetch(
296
+ `https://${API_URL}/graphql/${opts.apiVersion}`,
297
+ {
298
+ method: "POST",
299
+ headers: {
300
+ "Content-Type": "application/json"
301
+ },
302
+ body: JSON.stringify({ query, variables })
303
+ }
304
+ );
295
305
  if (res.status !== 200) {
296
306
  throw new FetchErrorResponse(
297
307
  `GraphQL request failed with status ${res.status}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -30,11 +30,11 @@
30
30
  "*.{js,ts}": "yarn lint"
31
31
  },
32
32
  "dependencies": {
33
- "@babel/runtime": "^7.23.1",
34
- "@wix/identity": "^1.0.59",
33
+ "@babel/runtime": "^7.23.2",
34
+ "@wix/identity": "^1.0.60",
35
35
  "@wix/image-kit": "^1.37.0",
36
- "@wix/redirects": "^1.0.25",
37
- "@wix/sdk-types": "1.5.0",
36
+ "@wix/redirects": "^1.0.26",
37
+ "@wix/sdk-types": "1.5.1",
38
38
  "pkce-challenge": "^3.1.0",
39
39
  "querystring": "^0.2.1",
40
40
  "type-fest": "^3.13.1"
@@ -43,22 +43,22 @@
43
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"
44
44
  },
45
45
  "devDependencies": {
46
- "@swc/core": "^1.3.90",
46
+ "@swc/core": "^1.3.93",
47
47
  "@swc/jest": "^0.2.29",
48
48
  "@types/jest": "^27.5.2",
49
- "@types/node": "^16.18.55",
50
- "@types/node-fetch": "^2.6.6",
51
- "@wix/ecom": "^1.0.362",
52
- "@wix/events": "^1.0.122",
49
+ "@types/node": "^16.18.59",
50
+ "@types/node-fetch": "^2.6.7",
51
+ "@wix/ecom": "^1.0.368",
52
+ "@wix/events": "^1.0.123",
53
53
  "@wix/metro": "^1.0.67",
54
- "@wix/metro-runtime": "^1.1532.0",
54
+ "@wix/metro-runtime": "^1.1542.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.6",
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": "8219aada4f2b926c1e6c891f568f63740ec5e81a092eedaf68a2024f"
90
+ "falconPackageHash": "7dd3b786429aec1b6fa9565fdc952b1c2634c917344e82dba377ff4d"
91
91
  }