@wix/sdk 1.15.21 → 1.15.23

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.
@@ -17,6 +17,7 @@ export declare function SiteSessionAuth(config: {
17
17
  getTokens: () => Tokens;
18
18
  isSessionSynced: typeof isVisitorCookieWarmedUp;
19
19
  syncToWixPages: typeof preWarmVisitorCookie;
20
+ shouldUseCDN: boolean;
20
21
  };
21
22
  export interface TokenResponse {
22
23
  access_token: string;
@@ -73,6 +73,7 @@ export function SiteSessionAuth(config) {
73
73
  getTokens: () => _tokens,
74
74
  isSessionSynced: isVisitorCookieWarmedUp,
75
75
  syncToWixPages: preWarmVisitorCookie,
76
+ shouldUseCDN: true,
76
77
  };
77
78
  }
78
79
  const fetchTokens = async (payload, headers = {}) => {
@@ -355,6 +355,7 @@ export function OAuthStrategy(config) {
355
355
  isSessionSynced: isVisitorCookieWarmedUp,
356
356
  syncToWixPages: preWarmVisitorCookie,
357
357
  },
358
+ shouldUseCDN: true,
358
359
  };
359
360
  }
360
361
  const fetchTokens = async (payload, headers = {}) => {
@@ -85,6 +85,7 @@ export interface IOAuthStrategy extends AuthenticationStrategy {
85
85
  force?: boolean;
86
86
  }) => Promise<void>;
87
87
  };
88
+ shouldUseCDN: true;
88
89
  }
89
90
  export declare enum LoginState {
90
91
  SUCCESS = "SUCCESS",
package/build/common.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare const PUBLIC_METADATA_KEY = "__metadata";
2
2
  export declare const DEFAULT_API_URL = "www.wixapis.com";
3
+ export declare const DEFAULT_EDGE_API_URL = "edge.wixapis.com";
3
4
  export declare const FORCE_WRITE_API_URLS: string[];
package/build/common.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export const PUBLIC_METADATA_KEY = '__metadata';
2
2
  export const DEFAULT_API_URL = 'www.wixapis.com';
3
+ export const DEFAULT_EDGE_API_URL = 'edge.wixapis.com';
3
4
  export const FORCE_WRITE_API_URLS = ['/ecom/v1/carts/current'];
@@ -2,4 +2,4 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor } from '@wix/
2
2
  export type RESTModuleOptions = {
3
3
  HTTPHost?: string;
4
4
  };
5
- export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
@@ -1,7 +1,7 @@
1
1
  import { biHeaderGenerator } from './bi/biHeaderGenerator.js';
2
- import { DEFAULT_API_URL } from './common.js';
2
+ import { DEFAULT_API_URL, DEFAULT_EDGE_API_URL } from './common.js';
3
3
  import { runWithoutContext } from '@wix/sdk-runtime/context';
4
- export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName) {
4
+ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
5
5
  return runWithoutContext(() => origFunc({
6
6
  request: async (factory) => {
7
7
  const requestOptions = factory({
@@ -14,7 +14,7 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPI
14
14
  request = requestOptions.fallback[0];
15
15
  }
16
16
  const domain = options?.HTTPHost ?? DEFAULT_API_URL;
17
- let url = `https://${domain}${request.url}`;
17
+ let url = `https://${useCDN ? DEFAULT_EDGE_API_URL : domain}${request.url}`;
18
18
  if (request.params && request.params.toString()) {
19
19
  url += `?${request.params.toString()}`;
20
20
  }
@@ -53,5 +53,6 @@ export declare function createClient<H extends Host<any> | undefined = undefined
53
53
  auth?: Z;
54
54
  headers?: Headers;
55
55
  host?: H;
56
+ useCDN?: boolean;
56
57
  }): WixClient<H, Z, T>;
57
58
  export {};
@@ -94,6 +94,7 @@ export function createClient(config) {
94
94
  return modules;
95
95
  }
96
96
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
97
+ const shouldUseCDN = config.useCDN === undefined ? config.auth?.shouldUseCDN : config.useCDN;
97
98
  return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules))
98
99
  ? toHTTPModule(modules)
99
100
  : modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
@@ -101,7 +102,7 @@ export function createClient(config) {
101
102
  finalUrl.host = apiBaseUrl;
102
103
  finalUrl.protocol = 'https';
103
104
  return boundFetch(finalUrl.toString(), fetchOptions);
104
- }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
105
+ }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
105
106
  }
106
107
  else if (isObject(modules)) {
107
108
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
@@ -17,6 +17,7 @@ export declare function SiteSessionAuth(config: {
17
17
  getTokens: () => Tokens;
18
18
  isSessionSynced: typeof isVisitorCookieWarmedUp;
19
19
  syncToWixPages: typeof preWarmVisitorCookie;
20
+ shouldUseCDN: boolean;
20
21
  };
21
22
  export interface TokenResponse {
22
23
  access_token: string;
@@ -76,6 +76,7 @@ function SiteSessionAuth(config) {
76
76
  getTokens: () => _tokens,
77
77
  isSessionSynced: pre_warm_cookie_js_1.isVisitorCookieWarmedUp,
78
78
  syncToWixPages: pre_warm_cookie_js_1.preWarmVisitorCookie,
79
+ shouldUseCDN: true,
79
80
  };
80
81
  }
81
82
  const fetchTokens = async (payload, headers = {}) => {
@@ -358,6 +358,7 @@ function OAuthStrategy(config) {
358
358
  isSessionSynced: pre_warm_cookie_js_1.isVisitorCookieWarmedUp,
359
359
  syncToWixPages: pre_warm_cookie_js_1.preWarmVisitorCookie,
360
360
  },
361
+ shouldUseCDN: true,
361
362
  };
362
363
  }
363
364
  const fetchTokens = async (payload, headers = {}) => {
@@ -85,6 +85,7 @@ export interface IOAuthStrategy extends AuthenticationStrategy {
85
85
  force?: boolean;
86
86
  }) => Promise<void>;
87
87
  };
88
+ shouldUseCDN: true;
88
89
  }
89
90
  export declare enum LoginState {
90
91
  SUCCESS = "SUCCESS",
@@ -1,3 +1,4 @@
1
1
  export declare const PUBLIC_METADATA_KEY = "__metadata";
2
2
  export declare const DEFAULT_API_URL = "www.wixapis.com";
3
+ export declare const DEFAULT_EDGE_API_URL = "edge.wixapis.com";
3
4
  export declare const FORCE_WRITE_API_URLS: string[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORCE_WRITE_API_URLS = exports.DEFAULT_API_URL = exports.PUBLIC_METADATA_KEY = void 0;
3
+ exports.FORCE_WRITE_API_URLS = exports.DEFAULT_EDGE_API_URL = exports.DEFAULT_API_URL = exports.PUBLIC_METADATA_KEY = void 0;
4
4
  exports.PUBLIC_METADATA_KEY = '__metadata';
5
5
  exports.DEFAULT_API_URL = 'www.wixapis.com';
6
+ exports.DEFAULT_EDGE_API_URL = 'edge.wixapis.com';
6
7
  exports.FORCE_WRITE_API_URLS = ['/ecom/v1/carts/current'];
@@ -2,4 +2,4 @@ import { BuildRESTFunction, PublicMetadata, RESTFunctionDescriptor } from '@wix/
2
2
  export type RESTModuleOptions = {
3
3
  HTTPHost?: string;
4
4
  };
5
- export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined): BuildRESTFunction<T>;
5
+ export declare function buildRESTDescriptor<T extends RESTFunctionDescriptor>(origFunc: T, publicMetadata: PublicMetadata, boundFetch: typeof fetch, wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>, getActiveToken?: () => string | undefined, options?: RESTModuleOptions, hostName?: string | undefined, useCDN?: boolean): BuildRESTFunction<T>;
@@ -4,7 +4,7 @@ exports.buildRESTDescriptor = buildRESTDescriptor;
4
4
  const biHeaderGenerator_js_1 = require("./bi/biHeaderGenerator.js");
5
5
  const common_js_1 = require("./common.js");
6
6
  const context_1 = require("@wix/sdk-runtime/context");
7
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName) {
7
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
8
8
  return (0, context_1.runWithoutContext)(() => origFunc({
9
9
  request: async (factory) => {
10
10
  const requestOptions = factory({
@@ -17,7 +17,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
17
17
  request = requestOptions.fallback[0];
18
18
  }
19
19
  const domain = options?.HTTPHost ?? common_js_1.DEFAULT_API_URL;
20
- let url = `https://${domain}${request.url}`;
20
+ let url = `https://${useCDN ? common_js_1.DEFAULT_EDGE_API_URL : domain}${request.url}`;
21
21
  if (request.params && request.params.toString()) {
22
22
  url += `?${request.params.toString()}`;
23
23
  }
@@ -53,5 +53,6 @@ export declare function createClient<H extends Host<any> | undefined = undefined
53
53
  auth?: Z;
54
54
  headers?: Headers;
55
55
  host?: H;
56
+ useCDN?: boolean;
56
57
  }): WixClient<H, Z, T>;
57
58
  export {};
@@ -98,6 +98,7 @@ function createClient(config) {
98
98
  return modules;
99
99
  }
100
100
  const apiBaseUrl = config.host?.apiBaseUrl ?? common_js_1.DEFAULT_API_URL;
101
+ const shouldUseCDN = config.useCDN === undefined ? config.auth?.shouldUseCDN : config.useCDN;
101
102
  return (0, rest_modules_js_1.buildRESTDescriptor)((0, context_1.runWithoutContext)(() => (0, ambassador_modules_js_1.isAmbassadorModule)(modules))
102
103
  ? (0, ambassador_modules_js_1.toHTTPModule)(modules)
103
104
  : modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
@@ -105,7 +106,7 @@ function createClient(config) {
105
106
  finalUrl.host = apiBaseUrl;
106
107
  finalUrl.protocol = 'https';
107
108
  return boundFetch(finalUrl.toString(), fetchOptions);
108
- }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name);
109
+ }, authStrategy.getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
109
110
  }
110
111
  else if ((0, helpers_js_1.isObject)(modules)) {
111
112
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.15.21",
3
+ "version": "1.15.23",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -73,11 +73,11 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@wix/identity": "^1.0.104",
76
- "@wix/image-kit": "^1.108.0",
76
+ "@wix/image-kit": "^1.109.0",
77
77
  "@wix/redirects": "^1.0.70",
78
78
  "@wix/sdk-context": "0.0.1",
79
- "@wix/sdk-runtime": "0.3.50",
80
- "@wix/sdk-types": "^1.13.23",
79
+ "@wix/sdk-runtime": "0.3.54",
80
+ "@wix/sdk-types": "^1.13.30",
81
81
  "jose": "^5.10.0",
82
82
  "type-fest": "^4.41.0"
83
83
  },
@@ -86,19 +86,19 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/is-ci": "^3.0.4",
89
- "@types/node": "^20.17.47",
89
+ "@types/node": "^20.19.0",
90
90
  "@vitest/ui": "^1.6.1",
91
91
  "@wix/ecom": "^1.0.886",
92
92
  "@wix/events": "^1.0.382",
93
93
  "@wix/metro": "^1.0.93",
94
94
  "@wix/metro-runtime": "^1.1891.0",
95
- "@wix/sdk-runtime": "0.3.50",
95
+ "@wix/sdk-runtime": "0.3.54",
96
96
  "eslint": "^8.57.1",
97
97
  "eslint-config-sdk": "0.0.0",
98
98
  "graphql": "^16.8.0",
99
99
  "is-ci": "^3.0.1",
100
100
  "jsdom": "^22.1.0",
101
- "msw": "^2.8.3",
101
+ "msw": "^2.10.0",
102
102
  "typescript": "^5.8.3",
103
103
  "vitest": "^1.6.1",
104
104
  "vitest-teamcity-reporter": "^0.3.1"
@@ -126,5 +126,5 @@
126
126
  "wallaby": {
127
127
  "autoDetect": true
128
128
  },
129
- "falconPackageHash": "8c1d367b6aad183b6058702e0c56288c72e38fa7156fdacc2dcdd180"
129
+ "falconPackageHash": "22fd3f820965fd15526102c903e23d29c268e852ea5a4616a785e03c"
130
130
  }