@wix/sdk 1.15.27 → 1.17.0

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.
@@ -10,6 +10,22 @@ export declare function getImageUrl(val: string): {
10
10
  altText?: string;
11
11
  filename?: string;
12
12
  };
13
+ export declare function getShapeUrl(val: string): {
14
+ id: string;
15
+ url: string;
16
+ height: number;
17
+ width: number;
18
+ altText?: string;
19
+ filename?: string;
20
+ };
21
+ export declare function getBaseImageUrl(val: string, baseUrl?: string): {
22
+ id: string;
23
+ url: string;
24
+ height: number;
25
+ width: number;
26
+ altText?: string;
27
+ filename?: string;
28
+ };
13
29
  export declare function getVideoUrl(val: string, resolution?: VideoResolution): {
14
30
  id: string;
15
31
  url: string;
@@ -5,6 +5,7 @@ const WIX_VIDEO = 'video';
5
5
  const WIX_AUDIO = 'audio';
6
6
  const WIX_DOCUMENT = 'document';
7
7
  const WIX_IMAGE_URL = 'https://static.wixstatic.com/media/';
8
+ const WIX_SHAPES_URL = 'https://static.wixstatic.com/shapes/';
8
9
  const WIX_VIDEO_URL = 'https://video.wixstatic.com/video/';
9
10
  const WIX_AUDIO_URL = 'https://static.wixstatic.com/mp3/';
10
11
  const WIX_DOCUMENT_URL = 'https://d945e594-8657-47e2-9cd9-e9033c3d8da0.usrfiles.com/ugd/';
@@ -21,10 +22,16 @@ export function getCroppedImageUrl(wixMediaIdentifier, cropX, cropY, cropWidth,
21
22
  return sdk.getCropImageURL(img.id, img.height, img.width, cropX, cropY, cropWidth, cropHeight, targetWidth, targetHeight, options);
22
23
  }
23
24
  export function getImageUrl(val) {
25
+ return getBaseImageUrl(val, WIX_IMAGE_URL);
26
+ }
27
+ export function getShapeUrl(val) {
28
+ return getBaseImageUrl(val, WIX_SHAPES_URL);
29
+ }
30
+ export function getBaseImageUrl(val, baseUrl = WIX_IMAGE_URL) {
24
31
  let id, filenameOrAltText;
25
32
  let height, width;
26
- if (val.startsWith(WIX_IMAGE_URL)) {
27
- id = val.split(WIX_IMAGE_URL).pop().split('/')[0];
33
+ if (val.startsWith(baseUrl)) {
34
+ id = val.split(baseUrl).pop().split('/')[0];
28
35
  width = val.split('/w_').pop().split(',')[0];
29
36
  height = val.split(',h_').pop().split(',')[0];
30
37
  }
@@ -42,7 +49,7 @@ export function getImageUrl(val) {
42
49
  const decodedFilenameOrAltText = decodeText(filenameOrAltText);
43
50
  const res = {
44
51
  id,
45
- url: `${WIX_IMAGE_URL}${id}`,
52
+ url: `${baseUrl}${id}`,
46
53
  height: Number(height),
47
54
  width: Number(width),
48
55
  };
@@ -11,7 +11,7 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorH
11
11
  let request = requestOptions;
12
12
  if (request.method === 'GET' &&
13
13
  request.fallback?.length &&
14
- request.params.toString().length > 4000) {
14
+ (request.params?.toString().length ?? 0) > 4000) {
15
15
  request = requestOptions.fallback[0];
16
16
  }
17
17
  const domain = options?.HTTPHost ?? DEFAULT_API_URL;
@@ -54,7 +54,17 @@ export function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorH
54
54
  });
55
55
  throw error;
56
56
  }
57
- const data = await res.json();
57
+ const rawData = await res.json();
58
+ const data =
59
+ // we only transform the response if the optInTransformResponse flag is set
60
+ // this is for backwards compatibility as some users might rely on not transforming the response
61
+ // in older modules. In that case the modules would not have the optInTransformResponse flag set
62
+ request.migrationOptions?.optInTransformResponse &&
63
+ request.transformResponse
64
+ ? Array.isArray(request.transformResponse)
65
+ ? request.transformResponse[0](rawData)
66
+ : request.transformResponse(rawData)
67
+ : rawData;
58
68
  return {
59
69
  data,
60
70
  headers: res.headers,
@@ -10,6 +10,22 @@ export declare function getImageUrl(val: string): {
10
10
  altText?: string;
11
11
  filename?: string;
12
12
  };
13
+ export declare function getShapeUrl(val: string): {
14
+ id: string;
15
+ url: string;
16
+ height: number;
17
+ width: number;
18
+ altText?: string;
19
+ filename?: string;
20
+ };
21
+ export declare function getBaseImageUrl(val: string, baseUrl?: string): {
22
+ id: string;
23
+ url: string;
24
+ height: number;
25
+ width: number;
26
+ altText?: string;
27
+ filename?: string;
28
+ };
13
29
  export declare function getVideoUrl(val: string, resolution?: VideoResolution): {
14
30
  id: string;
15
31
  url: string;
@@ -5,6 +5,8 @@ exports.getScaledToFillImageUrl = getScaledToFillImageUrl;
5
5
  exports.getScaledToFitImageUrl = getScaledToFitImageUrl;
6
6
  exports.getCroppedImageUrl = getCroppedImageUrl;
7
7
  exports.getImageUrl = getImageUrl;
8
+ exports.getShapeUrl = getShapeUrl;
9
+ exports.getBaseImageUrl = getBaseImageUrl;
8
10
  exports.getVideoUrl = getVideoUrl;
9
11
  exports.getAudioUrl = getAudioUrl;
10
12
  exports.getDocumentUrl = getDocumentUrl;
@@ -16,6 +18,7 @@ const WIX_VIDEO = 'video';
16
18
  const WIX_AUDIO = 'audio';
17
19
  const WIX_DOCUMENT = 'document';
18
20
  const WIX_IMAGE_URL = 'https://static.wixstatic.com/media/';
21
+ const WIX_SHAPES_URL = 'https://static.wixstatic.com/shapes/';
19
22
  const WIX_VIDEO_URL = 'https://video.wixstatic.com/video/';
20
23
  const WIX_AUDIO_URL = 'https://static.wixstatic.com/mp3/';
21
24
  const WIX_DOCUMENT_URL = 'https://d945e594-8657-47e2-9cd9-e9033c3d8da0.usrfiles.com/ugd/';
@@ -32,10 +35,16 @@ function getCroppedImageUrl(wixMediaIdentifier, cropX, cropY, cropWidth, cropHei
32
35
  return image_kit_1.sdk.getCropImageURL(img.id, img.height, img.width, cropX, cropY, cropWidth, cropHeight, targetWidth, targetHeight, options);
33
36
  }
34
37
  function getImageUrl(val) {
38
+ return getBaseImageUrl(val, WIX_IMAGE_URL);
39
+ }
40
+ function getShapeUrl(val) {
41
+ return getBaseImageUrl(val, WIX_SHAPES_URL);
42
+ }
43
+ function getBaseImageUrl(val, baseUrl = WIX_IMAGE_URL) {
35
44
  let id, filenameOrAltText;
36
45
  let height, width;
37
- if (val.startsWith(WIX_IMAGE_URL)) {
38
- id = val.split(WIX_IMAGE_URL).pop().split('/')[0];
46
+ if (val.startsWith(baseUrl)) {
47
+ id = val.split(baseUrl).pop().split('/')[0];
39
48
  width = val.split('/w_').pop().split(',')[0];
40
49
  height = val.split(',h_').pop().split(',')[0];
41
50
  }
@@ -53,7 +62,7 @@ function getImageUrl(val) {
53
62
  const decodedFilenameOrAltText = decodeText(filenameOrAltText);
54
63
  const res = {
55
64
  id,
56
- url: `${WIX_IMAGE_URL}${id}`,
65
+ url: `${baseUrl}${id}`,
57
66
  height: Number(height),
58
67
  width: Number(width),
59
68
  };
@@ -14,7 +14,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
14
14
  let request = requestOptions;
15
15
  if (request.method === 'GET' &&
16
16
  request.fallback?.length &&
17
- request.params.toString().length > 4000) {
17
+ (request.params?.toString().length ?? 0) > 4000) {
18
18
  request = requestOptions.fallback[0];
19
19
  }
20
20
  const domain = options?.HTTPHost ?? common_js_1.DEFAULT_API_URL;
@@ -57,7 +57,17 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
57
57
  });
58
58
  throw error;
59
59
  }
60
- const data = await res.json();
60
+ const rawData = await res.json();
61
+ const data =
62
+ // we only transform the response if the optInTransformResponse flag is set
63
+ // this is for backwards compatibility as some users might rely on not transforming the response
64
+ // in older modules. In that case the modules would not have the optInTransformResponse flag set
65
+ request.migrationOptions?.optInTransformResponse &&
66
+ request.transformResponse
67
+ ? Array.isArray(request.transformResponse)
68
+ ? request.transformResponse[0](rawData)
69
+ : request.transformResponse(rawData)
70
+ : rawData;
61
71
  return {
62
72
  data,
63
73
  headers: res.headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.15.27",
3
+ "version": "1.17.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsc && tsc --project tsconfig.cjs.json",
66
- "test": "vitest",
66
+ "test": "vitest run",
67
67
  "lint": "eslint --max-warnings=0 .",
68
68
  "lint:fix": "eslint --max-warnings=0 . --fix",
69
69
  "typecheck": "tsc --noEmit"
@@ -73,11 +73,11 @@
73
73
  },
74
74
  "dependencies": {
75
75
  "@wix/identity": "^1.0.104",
76
- "@wix/image-kit": "^1.112.0",
76
+ "@wix/image-kit": "^1.113.0",
77
77
  "@wix/redirects": "^1.0.70",
78
78
  "@wix/sdk-context": "0.0.1",
79
- "@wix/sdk-runtime": "0.3.62",
80
- "@wix/sdk-types": "^1.13.41",
79
+ "@wix/sdk-runtime": "0.4.0",
80
+ "@wix/sdk-types": "1.14.0",
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.19.10",
89
+ "@types/node": "^20.19.13",
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.62",
95
+ "@wix/sdk-runtime": "0.4.0",
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.10.4",
101
+ "msw": "^2.11.1",
102
102
  "typescript": "^5.9.2",
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": "1c0389f91287fec42f5eb0e61b95c742450981c51f61cbdd6089f828"
129
+ "falconPackageHash": "3d4bca7571d989d55bb10de4eb19477d546997c9a01969d8b4bc4e0f"
130
130
  }