@wix/headless-forms 0.0.43 → 0.0.45

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.
@@ -2,29 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.uploadFile = exports.getUploadUrl = void 0;
4
4
  const forms_1 = require("@wix/forms");
5
- const essentials_1 = require("@wix/essentials");
6
5
  const getUploadUrl = async (formId, file) => {
7
6
  try {
8
7
  const { uploadUrl } = await forms_1.submissions.getMediaUploadUrl(formId, file.name, file.type);
9
8
  return uploadUrl;
10
9
  }
11
- catch {
12
- console.error('Cannot get uploadUrl for file upload!');
10
+ catch (e) {
11
+ console.error('Cannot get submissions.getMediaUploadUrl for file upload', e);
13
12
  return;
14
13
  }
15
14
  };
16
15
  exports.getUploadUrl = getUploadUrl;
17
16
  const uploadFile = async (file, uploadUrl) => {
18
- const headers = {
19
- 'Content-Type': 'application/octet-stream',
20
- };
21
- const { withErrorHandler } = essentials_1.errorHandler;
22
17
  try {
23
- const response = await withErrorHandler(() => essentials_1.httpClient.fetchWithAuth(uploadUrl, {
18
+ const response = await fetch(uploadUrl, {
24
19
  method: 'PUT',
20
+ headers: { 'Content-Type': 'application/octet-stream' },
25
21
  body: file,
26
- headers,
27
- }), {});
22
+ });
28
23
  const data = await response.json();
29
24
  if (!data) {
30
25
  return;
@@ -32,8 +27,8 @@ const uploadFile = async (file, uploadUrl) => {
32
27
  return data.file.url;
33
28
  }
34
29
  catch (e) {
35
- const resolvedError = essentials_1.errorHandler.getResolvedError(e);
36
- throw resolvedError;
30
+ console.error('Cannot upload file to uploadUrl', e);
31
+ throw e;
37
32
  }
38
33
  };
39
34
  exports.uploadFile = uploadFile;
@@ -1,26 +1,21 @@
1
1
  import { submissions } from '@wix/forms';
2
- import { httpClient, errorHandler } from '@wix/essentials';
3
2
  export const getUploadUrl = async (formId, file) => {
4
3
  try {
5
4
  const { uploadUrl } = await submissions.getMediaUploadUrl(formId, file.name, file.type);
6
5
  return uploadUrl;
7
6
  }
8
- catch {
9
- console.error('Cannot get uploadUrl for file upload!');
7
+ catch (e) {
8
+ console.error('Cannot get submissions.getMediaUploadUrl for file upload', e);
10
9
  return;
11
10
  }
12
11
  };
13
12
  export const uploadFile = async (file, uploadUrl) => {
14
- const headers = {
15
- 'Content-Type': 'application/octet-stream',
16
- };
17
- const { withErrorHandler } = errorHandler;
18
13
  try {
19
- const response = await withErrorHandler(() => httpClient.fetchWithAuth(uploadUrl, {
14
+ const response = await fetch(uploadUrl, {
20
15
  method: 'PUT',
16
+ headers: { 'Content-Type': 'application/octet-stream' },
21
17
  body: file,
22
- headers,
23
- }), {});
18
+ });
24
19
  const data = await response.json();
25
20
  if (!data) {
26
21
  return;
@@ -28,7 +23,7 @@ export const uploadFile = async (file, uploadUrl) => {
28
23
  return data.file.url;
29
24
  }
30
25
  catch (e) {
31
- const resolvedError = errorHandler.getResolvedError(e);
32
- throw resolvedError;
26
+ console.error('Cannot upload file to uploadUrl', e);
27
+ throw e;
33
28
  }
34
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-forms",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -47,8 +47,8 @@
47
47
  "vitest": "^3.1.4"
48
48
  },
49
49
  "dependencies": {
50
- "@wix/form-public": "^0.141.0",
51
- "@wix/forms": "^1.0.392",
50
+ "@wix/form-public": "^0.145.0",
51
+ "@wix/forms": "^1.0.399",
52
52
  "@wix/headless-utils": "0.0.12",
53
53
  "@wix/services-definitions": "^1.0.1",
54
54
  "@wix/services-manager-react": "^1.0.3",
@@ -64,5 +64,5 @@
64
64
  "groupId": "com.wixpress.headless-components"
65
65
  }
66
66
  },
67
- "falconPackageHash": "9bec5f9ca3c3098ed512b04fc6feb03f4facfdcfb2563fa691695442"
67
+ "falconPackageHash": "c7ca0742ab1beaa2492b07e6f464dd0e5c0ca940bb56716fe1e2da74"
68
68
  }