@lowdefy/plugin-aws 4.0.0-rc.1 → 4.0.0-rc.11
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.
- package/dist/blocks/S3UploadButton/S3UploadButton.js +9 -9
- package/dist/blocks/S3UploadPhoto/S3UploadPhoto.js +9 -9
- package/dist/blocks/S3UploadPhoto/schema.json +0 -20
- package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js +3 -3
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +3 -3
- package/package.json +15 -15
|
@@ -18,8 +18,8 @@ import { get } from '@lowdefy/helpers';
|
|
|
18
18
|
import { Button } from '@lowdefy/blocks-antd/blocks';
|
|
19
19
|
import { Upload } from 'antd';
|
|
20
20
|
const makeFileValue = (file, s3Parameters)=>{
|
|
21
|
-
const { lastModified
|
|
22
|
-
const { bucket
|
|
21
|
+
const { lastModified, name, percent, size, status, type, uid } = file;
|
|
22
|
+
const { bucket, key } = get(s3Parameters, uid, {
|
|
23
23
|
default: {}
|
|
24
24
|
});
|
|
25
25
|
return {
|
|
@@ -35,22 +35,22 @@ const makeFileValue = (file, s3Parameters)=>{
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
const makeOnChangeValue = (s3Parameters, changeEvent)=>{
|
|
38
|
-
const { file
|
|
38
|
+
const { file, fileList } = changeEvent;
|
|
39
39
|
return {
|
|
40
40
|
file: makeFileValue(file, s3Parameters),
|
|
41
41
|
fileList: fileList.map((fl)=>makeFileValue(fl, s3Parameters))
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
const getDisabled = ({ properties
|
|
44
|
+
const getDisabled = ({ properties, value })=>{
|
|
45
45
|
if (properties.disabled) return true;
|
|
46
46
|
if (properties.singleFile && value && (value.fileList || []).length >= 1) {
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
return false;
|
|
50
50
|
};
|
|
51
|
-
const getCustomRequest = ({ methods
|
|
51
|
+
const getCustomRequest = ({ methods, setS3Parameters })=>async ({ file, onError, onProgress, onSuccess })=>{
|
|
52
52
|
try {
|
|
53
|
-
const { name
|
|
53
|
+
const { name, size, type, uid } = file;
|
|
54
54
|
const s3PostPolicyResponse = await methods.triggerEvent({
|
|
55
55
|
name: '__getS3PostPolicy',
|
|
56
56
|
event: {
|
|
@@ -63,8 +63,8 @@ const getCustomRequest = ({ methods , setS3Parameters })=>async ({ file , onErr
|
|
|
63
63
|
if (s3PostPolicyResponse.success !== true) {
|
|
64
64
|
throw new Error('S3 post policy request error.');
|
|
65
65
|
}
|
|
66
|
-
const { url
|
|
67
|
-
const { bucket
|
|
66
|
+
const { url, fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
|
|
67
|
+
const { bucket, key } = fields;
|
|
68
68
|
const meta1 = {
|
|
69
69
|
bucket,
|
|
70
70
|
key,
|
|
@@ -145,7 +145,7 @@ const getCustomRequest = ({ methods , setS3Parameters })=>async ({ file , onErr
|
|
|
145
145
|
onError(error);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
const S3UploadButtonBlock = ({ blockId
|
|
148
|
+
const S3UploadButtonBlock = ({ blockId, components, events, methods, properties, value })=>{
|
|
149
149
|
// Use state here because we need to set s3 bucket and key as block value
|
|
150
150
|
// The customRequest function does not have access to the updated block value,
|
|
151
151
|
// so it cannot set the value directly. customRequest sets the parameters to s3Parameters state,
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
*/ import React, { useEffect, useState } from 'react';
|
|
16
16
|
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
17
17
|
import { get } from '@lowdefy/helpers';
|
|
18
|
-
import {
|
|
18
|
+
import { Upload } from 'antd';
|
|
19
19
|
const makeFileValue = (file, s3Parameters)=>{
|
|
20
|
-
const { lastModified
|
|
21
|
-
const { bucket
|
|
20
|
+
const { lastModified, name, percent, size, status, type, uid } = file;
|
|
21
|
+
const { bucket, key } = get(s3Parameters, uid, {
|
|
22
22
|
default: {}
|
|
23
23
|
});
|
|
24
24
|
return {
|
|
@@ -34,16 +34,16 @@ const makeFileValue = (file, s3Parameters)=>{
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
const makeOnChangeValue = (s3Parameters, changeEvent)=>{
|
|
37
|
-
const { file
|
|
37
|
+
const { file, fileList } = changeEvent;
|
|
38
38
|
return {
|
|
39
39
|
file: makeFileValue(file, s3Parameters),
|
|
40
40
|
fileList: fileList.map((fl)=>makeFileValue(fl, s3Parameters))
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
const getCustomRequest = ({ methods
|
|
43
|
+
const getCustomRequest = ({ methods, setS3Parameters, setLoading })=>async ({ file, onError, onProgress, onSuccess })=>{
|
|
44
44
|
try {
|
|
45
45
|
setLoading(true);
|
|
46
|
-
const { name
|
|
46
|
+
const { name, size, type, uid } = file;
|
|
47
47
|
if (size > 1024 * 1024 * 10) throw new Error('File cannot exceed 10mb.');
|
|
48
48
|
const s3PostPolicyResponse = await methods.triggerEvent({
|
|
49
49
|
name: '__getS3PostPolicy',
|
|
@@ -57,8 +57,8 @@ const getCustomRequest = ({ methods , setS3Parameters , setLoading })=>async ({
|
|
|
57
57
|
if (s3PostPolicyResponse.success !== true) {
|
|
58
58
|
throw new Error('S3 post policy request error.');
|
|
59
59
|
}
|
|
60
|
-
const { url
|
|
61
|
-
const { bucket
|
|
60
|
+
const { url, fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
|
|
61
|
+
const { bucket, key } = fields;
|
|
62
62
|
const meta1 = {
|
|
63
63
|
bucket,
|
|
64
64
|
key,
|
|
@@ -140,7 +140,7 @@ const getCustomRequest = ({ methods , setS3Parameters , setLoading })=>async ({
|
|
|
140
140
|
onError(error);
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
const S3UploadPhoto = ({ blockId
|
|
143
|
+
const S3UploadPhoto = ({ blockId, components: { Icon }, events, methods, properties, value })=>{
|
|
144
144
|
// Use state here because we need to set s3 bucket and key as block value
|
|
145
145
|
// The customRequest function does not have access to the updated block value,
|
|
146
146
|
// so it cannot set the value directly. customRequest sets the parameters to s3Parameters state,
|
|
@@ -4,26 +4,6 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"required": ["s3PostPolicyRequestId"],
|
|
6
6
|
"properties": {
|
|
7
|
-
"accept": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "File types accepted by the input. See html file type input accept property at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept."
|
|
10
|
-
},
|
|
11
|
-
"button": {
|
|
12
|
-
"type": "object",
|
|
13
|
-
"description": "Button block properties.",
|
|
14
|
-
"default": {
|
|
15
|
-
"icon": "UploadOutlined",
|
|
16
|
-
"title": "Upload",
|
|
17
|
-
"type": "default"
|
|
18
|
-
},
|
|
19
|
-
"docs": {
|
|
20
|
-
"displayType": "button"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"disabled": {
|
|
24
|
-
"type": "boolean",
|
|
25
|
-
"description": "Disable the file input."
|
|
26
|
-
},
|
|
27
7
|
"s3PostPolicyRequestId": {
|
|
28
8
|
"type": "string",
|
|
29
9
|
"description": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import AWS from 'aws-sdk';
|
|
16
16
|
import schema from './schema.js';
|
|
17
|
-
function AwsS3PresignedGetObject({ request
|
|
18
|
-
const { accessKeyId
|
|
19
|
-
const { expires
|
|
17
|
+
function AwsS3PresignedGetObject({ request, connection }) {
|
|
18
|
+
const { accessKeyId, secretAccessKey, region, bucket } = connection;
|
|
19
|
+
const { expires, key, versionId, responseContentDisposition, responseContentType } = request;
|
|
20
20
|
const params = {
|
|
21
21
|
Bucket: bucket,
|
|
22
22
|
Key: key,
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import AWS from 'aws-sdk';
|
|
16
16
|
import schema from './schema.js';
|
|
17
|
-
function AwsS3PresignedPostPolicy({ request
|
|
18
|
-
const { accessKeyId
|
|
19
|
-
const { acl
|
|
17
|
+
function AwsS3PresignedPostPolicy({ request, connection }) {
|
|
18
|
+
const { accessKeyId, secretAccessKey, region, bucket } = connection;
|
|
19
|
+
const { acl, conditions, expires, key } = request;
|
|
20
20
|
const params = {
|
|
21
21
|
Bucket: bucket,
|
|
22
22
|
Fields: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/plugin-aws",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -45,32 +45,32 @@
|
|
|
45
45
|
"copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@lowdefy/block-utils": "4.0.0-rc.
|
|
49
|
-
"@lowdefy/blocks-antd": "4.0.0-rc.
|
|
50
|
-
"@lowdefy/helpers": "4.0.0-rc.
|
|
51
|
-
"antd": "4.24.
|
|
52
|
-
"aws-sdk": "2.
|
|
48
|
+
"@lowdefy/block-utils": "4.0.0-rc.11",
|
|
49
|
+
"@lowdefy/blocks-antd": "4.0.0-rc.11",
|
|
50
|
+
"@lowdefy/helpers": "4.0.0-rc.11",
|
|
51
|
+
"antd": "4.24.14",
|
|
52
|
+
"aws-sdk": "2.1459.0",
|
|
53
53
|
"react": "18.2.0",
|
|
54
54
|
"react-dom": "18.2.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@emotion/jest": "11.10.5",
|
|
58
|
-
"@lowdefy/ajv": "4.0.0-rc.
|
|
59
|
-
"@lowdefy/block-dev": "4.0.0-rc.
|
|
60
|
-
"@lowdefy/jest-yaml-transform": "4.0.0-rc.
|
|
61
|
-
"@swc/cli": "0.1.
|
|
62
|
-
"@swc/core": "1.3.
|
|
63
|
-
"@swc/jest": "0.2.
|
|
58
|
+
"@lowdefy/ajv": "4.0.0-rc.11",
|
|
59
|
+
"@lowdefy/block-dev": "4.0.0-rc.11",
|
|
60
|
+
"@lowdefy/jest-yaml-transform": "4.0.0-rc.11",
|
|
61
|
+
"@swc/cli": "0.1.62",
|
|
62
|
+
"@swc/core": "1.3.92",
|
|
63
|
+
"@swc/jest": "0.2.29",
|
|
64
64
|
"@testing-library/dom": "8.19.1",
|
|
65
65
|
"@testing-library/react": "13.4.0",
|
|
66
66
|
"@testing-library/user-event": "14.4.3",
|
|
67
67
|
"copyfiles": "2.4.1",
|
|
68
|
-
"jest": "28.1.
|
|
69
|
-
"jest-environment-jsdom": "28.1.
|
|
68
|
+
"jest": "28.1.3",
|
|
69
|
+
"jest-environment-jsdom": "28.1.3",
|
|
70
70
|
"jest-serializer-html": "7.1.0"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "dbc49d3688a6d2f44de25cc3f4bc071627f7ebfa"
|
|
76
76
|
}
|