@lowdefy/plugin-aws 4.0.0-alpha.6 → 4.0.0-alpha.9
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 +178 -0
- package/dist/blocks/S3UploadButton/schema.json +83 -0
- package/dist/{connections/AwsS3Bucket/AwsS3PresignedGetObject/index.js → blocks/S3UploadButton/style.less} +5 -11
- package/dist/connections/AwsS3Bucket/AwsS3Bucket.js +5 -6
- package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js +9 -3
- package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/schema.js +64 -0
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +9 -3
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/schema.js +70 -0
- package/dist/connections/AwsS3Bucket/schema.js +80 -0
- package/dist/{connections/AwsS3Bucket/AwsS3PresignedPostPolicy/index.js → connections.js} +2 -11
- package/dist/types.js +20 -0
- package/package.json +22 -7
- package/dist/connections/AwsS3Bucket/AwsS3BucketSchema.json +0 -61
- package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json +0 -48
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicySchema.json +0 -54
- package/dist/index.js +0 -7
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useEffect, useState } from 'react';
|
|
16
|
+
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
17
|
+
import { get } from '@lowdefy/helpers';
|
|
18
|
+
import { Button } from '@lowdefy/blocks-antd/blocks';
|
|
19
|
+
import { Upload } from 'antd';
|
|
20
|
+
const makeFileValue = (file, s3Parameters)=>{
|
|
21
|
+
const { lastModified , name , percent , size , status , type , uid } = file;
|
|
22
|
+
const { bucket , key } = get(s3Parameters, uid, {
|
|
23
|
+
default: {}
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
bucket,
|
|
27
|
+
key,
|
|
28
|
+
lastModified,
|
|
29
|
+
name,
|
|
30
|
+
percent,
|
|
31
|
+
size,
|
|
32
|
+
status,
|
|
33
|
+
type,
|
|
34
|
+
uid
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const makeOnChangeValue = (s3Parameters, changeEvent)=>{
|
|
38
|
+
const { file , fileList } = changeEvent;
|
|
39
|
+
return {
|
|
40
|
+
file: makeFileValue(file, s3Parameters),
|
|
41
|
+
fileList: fileList.map((fl)=>makeFileValue(fl, s3Parameters)
|
|
42
|
+
)
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const getDisabled = ({ properties , value })=>{
|
|
46
|
+
if (properties.disabled) return true;
|
|
47
|
+
if (properties.singleFile && value && (value.fileList || []).length >= 1) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
const getCustomRequest = ({ methods , setS3Parameters })=>async ({ file , onError , onProgress , onSuccess })=>{
|
|
53
|
+
try {
|
|
54
|
+
const { name , size , type , uid } = file;
|
|
55
|
+
const s3PostPolicyResponse = await methods.triggerEvent({
|
|
56
|
+
name: '__getS3PostPolicy',
|
|
57
|
+
event: {
|
|
58
|
+
filename: name,
|
|
59
|
+
size,
|
|
60
|
+
type,
|
|
61
|
+
uid
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (s3PostPolicyResponse.success !== true) {
|
|
65
|
+
throw new Error('S3 post policy request error.');
|
|
66
|
+
}
|
|
67
|
+
const { url , fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
|
|
68
|
+
const { bucket , key } = fields;
|
|
69
|
+
setS3Parameters((prevState)=>{
|
|
70
|
+
const ret = {
|
|
71
|
+
...prevState
|
|
72
|
+
};
|
|
73
|
+
ret[uid] = {
|
|
74
|
+
bucket,
|
|
75
|
+
key
|
|
76
|
+
};
|
|
77
|
+
return ret;
|
|
78
|
+
});
|
|
79
|
+
// Set 20 % progress on policy is acquired else user waits to long before progress is reported
|
|
80
|
+
onProgress({
|
|
81
|
+
percent: 20
|
|
82
|
+
});
|
|
83
|
+
// Create FormData with all required fields in S3 policy
|
|
84
|
+
const formData = new FormData();
|
|
85
|
+
Object.keys(fields).forEach((field)=>{
|
|
86
|
+
formData.append(field, fields[field]);
|
|
87
|
+
});
|
|
88
|
+
// file needs to be the last field in the form
|
|
89
|
+
formData.append('file', file);
|
|
90
|
+
const xhr = new XMLHttpRequest();
|
|
91
|
+
xhr.upload.onprogress = (event)=>{
|
|
92
|
+
if (event.lengthComputable) {
|
|
93
|
+
onProgress({
|
|
94
|
+
percent: event.loaded / event.total * 80 + 20
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
xhr.addEventListener('error', onError);
|
|
99
|
+
xhr.addEventListener('load', onSuccess);
|
|
100
|
+
xhr.open('post', url);
|
|
101
|
+
xhr.send(formData);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error(error);
|
|
104
|
+
onError(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
;
|
|
108
|
+
const S3UploadButtonBlock = ({ blockId , components , events , methods , properties , value })=>{
|
|
109
|
+
// Use state here because we need to set s3 bucket and key as block value
|
|
110
|
+
// The customRequest function does not have access to the updated block value,
|
|
111
|
+
// so it cannot set the value directly. customRequest sets the parameters to s3Parameters state,
|
|
112
|
+
// and then onChange updates the block value.
|
|
113
|
+
const [s3Parameters, setS3Parameters] = useState(value);
|
|
114
|
+
const customRequest = getCustomRequest({
|
|
115
|
+
methods,
|
|
116
|
+
setS3Parameters
|
|
117
|
+
});
|
|
118
|
+
useEffect(()=>{
|
|
119
|
+
methods.setValue({
|
|
120
|
+
file: null,
|
|
121
|
+
fileList: []
|
|
122
|
+
});
|
|
123
|
+
methods.registerEvent({
|
|
124
|
+
name: '__getS3PostPolicy',
|
|
125
|
+
actions: [
|
|
126
|
+
{
|
|
127
|
+
id: '__getS3PostPolicy',
|
|
128
|
+
type: 'Request',
|
|
129
|
+
params: [
|
|
130
|
+
properties.s3PostPolicyRequestId
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
}, []);
|
|
136
|
+
const disabled = getDisabled({
|
|
137
|
+
properties,
|
|
138
|
+
value
|
|
139
|
+
});
|
|
140
|
+
return(/*#__PURE__*/ React.createElement(Upload, {
|
|
141
|
+
accept: properties.accept,
|
|
142
|
+
customRequest: customRequest,
|
|
143
|
+
disabled: disabled,
|
|
144
|
+
id: blockId,
|
|
145
|
+
multiple: !properties.singleFile,
|
|
146
|
+
showUploadList: properties.showUploadList,
|
|
147
|
+
onChange: (event)=>{
|
|
148
|
+
methods.setValue(makeOnChangeValue(s3Parameters, event));
|
|
149
|
+
methods.triggerEvent({
|
|
150
|
+
name: 'onChange'
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, /*#__PURE__*/ React.createElement(Button, {
|
|
154
|
+
blockId: `${blockId}_button`,
|
|
155
|
+
components: components,
|
|
156
|
+
events: events,
|
|
157
|
+
properties: {
|
|
158
|
+
disabled,
|
|
159
|
+
icon: 'AiOutlineUpload',
|
|
160
|
+
title: 'Upload',
|
|
161
|
+
type: 'default',
|
|
162
|
+
...properties.button
|
|
163
|
+
},
|
|
164
|
+
methods: methods
|
|
165
|
+
})));
|
|
166
|
+
};
|
|
167
|
+
S3UploadButtonBlock.defaultProps = blockDefaultProps;
|
|
168
|
+
S3UploadButtonBlock.meta = {
|
|
169
|
+
valueType: 'object',
|
|
170
|
+
category: 'input',
|
|
171
|
+
icons: [
|
|
172
|
+
'AiOutlineUpload'
|
|
173
|
+
],
|
|
174
|
+
styles: [
|
|
175
|
+
'blocks/S3UploadButton/style.less'
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
export default S3UploadButtonBlock;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["s3PostPolicyRequestId"],
|
|
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
|
+
"s3PostPolicyRequestId": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.",
|
|
30
|
+
"docs": {
|
|
31
|
+
"displayType": "manual",
|
|
32
|
+
"block": {
|
|
33
|
+
"id": "block_properties_s3PostPolicyRequestId",
|
|
34
|
+
"layout": { "_global": "settings_input_layout" },
|
|
35
|
+
"type": "Label",
|
|
36
|
+
"required": true,
|
|
37
|
+
"properties": {
|
|
38
|
+
"title": "s3PostPolicyRequestId",
|
|
39
|
+
"span": 8,
|
|
40
|
+
"align": "right"
|
|
41
|
+
},
|
|
42
|
+
"blocks": [
|
|
43
|
+
{
|
|
44
|
+
"id": "block_properties_s3PostPolicyRequestId_text",
|
|
45
|
+
"type": "Markdown",
|
|
46
|
+
"style": {
|
|
47
|
+
"color": "#8c8c8c"
|
|
48
|
+
},
|
|
49
|
+
"properties": {
|
|
50
|
+
"content": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded."
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"getter": {}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"showUploadList": {
|
|
59
|
+
"type": "boolean",
|
|
60
|
+
"default": true,
|
|
61
|
+
"description": "Whether to show default upload list."
|
|
62
|
+
},
|
|
63
|
+
"singleFile": {
|
|
64
|
+
"type": "boolean",
|
|
65
|
+
"default": false,
|
|
66
|
+
"description": "Only allow a single file to be uploaded. Only one file can be selected in the prompt and the upload button is disabled after a file is uploaded."
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"events": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"properties": {
|
|
73
|
+
"onChange": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"description": "Triggered when the upload state is changing."
|
|
76
|
+
},
|
|
77
|
+
"onClick": {
|
|
78
|
+
"type": "array",
|
|
79
|
+
"description": "Triggered when the upload button is clicked."
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,13 +12,7 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
meta: {
|
|
21
|
-
checkRead: true,
|
|
22
|
-
checkWrite: false
|
|
23
|
-
}
|
|
24
|
-
};
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
@import 'antd/lib/upload/style/index.less';
|
|
18
|
+
@import '../Button/style.less';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,12 +12,11 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import AwsS3PresignedGetObject from './AwsS3PresignedGetObject/
|
|
16
|
-
import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy/
|
|
15
|
+
*/ import AwsS3PresignedGetObject from './AwsS3PresignedGetObject/AwsS3PresignedGetObject.js';
|
|
16
|
+
import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js';
|
|
17
|
+
import schema from './schema.js';
|
|
17
18
|
export default {
|
|
18
|
-
|
|
19
|
-
schema: 'connections/AwsS3Bucket/AwsS3BucketSchema.json'
|
|
20
|
-
},
|
|
19
|
+
schema,
|
|
21
20
|
requests: {
|
|
22
21
|
AwsS3PresignedGetObject,
|
|
23
22
|
AwsS3PresignedPostPolicy
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import AWS from 'aws-sdk';
|
|
16
|
-
|
|
16
|
+
import schema from './schema.js';
|
|
17
|
+
function AwsS3PresignedGetObject({ request , connection }) {
|
|
17
18
|
const { accessKeyId , secretAccessKey , region , bucket } = connection;
|
|
18
19
|
const { expires , key , versionId , responseContentDisposition , responseContentType } = request;
|
|
19
20
|
const params = {
|
|
@@ -32,4 +33,9 @@ function awsS3PresignedGetObject({ request , connection }) {
|
|
|
32
33
|
});
|
|
33
34
|
return s3.getSignedUrl('getObject', params);
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
AwsS3PresignedGetObject.schema = schema;
|
|
37
|
+
AwsS3PresignedGetObject.meta = {
|
|
38
|
+
checkRead: true,
|
|
39
|
+
checkWrite: false
|
|
40
|
+
};
|
|
41
|
+
export default AwsS3PresignedGetObject;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Request Schema - AwsS3PresignedGetObject',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'key'
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
expires: {
|
|
24
|
+
type: 'number',
|
|
25
|
+
description: 'Number of seconds for which the policy should be valid.',
|
|
26
|
+
default: 3600,
|
|
27
|
+
errorMessage: {
|
|
28
|
+
type: 'AwsS3PresignedGetObject request property "expires" should be a number.'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
key: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Key under which object is stored.',
|
|
34
|
+
errorMessage: {
|
|
35
|
+
type: 'AwsS3PresignedGetObject request property "key" should be a string.'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
responseContentDisposition: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Sets the Content-Disposition header of the response.',
|
|
41
|
+
errorMessage: {
|
|
42
|
+
type: 'AwsS3PresignedGetObject request property "responseContentDisposition" should be a string.'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
responseContentType: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'Sets the Content-Type header of the response.',
|
|
48
|
+
errorMessage: {
|
|
49
|
+
type: 'AwsS3PresignedGetObject request property "responseContentType" should be a string.'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
versionId: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'VersionId used to reference a specific version of the object.',
|
|
55
|
+
errorMessage: {
|
|
56
|
+
type: 'AwsS3PresignedGetObject request property "versionId" should be a string.'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
errorMessage: {
|
|
61
|
+
type: 'AwsS3PresignedGetObject request properties should be an object.',
|
|
62
|
+
required: 'AwsS3PresignedGetObject request should have required property "key".'
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import AWS from 'aws-sdk';
|
|
16
|
-
|
|
16
|
+
import schema from './schema.js';
|
|
17
|
+
function AwsS3PresignedPostPolicy({ request , connection }) {
|
|
17
18
|
const { accessKeyId , secretAccessKey , region , bucket } = connection;
|
|
18
19
|
const { acl , conditions , expires , key } = request;
|
|
19
20
|
const params = {
|
|
@@ -39,4 +40,9 @@ function awsS3PresignedPostPolicy({ request , connection }) {
|
|
|
39
40
|
});
|
|
40
41
|
return s3.createPresignedPost(params);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
AwsS3PresignedPostPolicy.schema = schema;
|
|
44
|
+
AwsS3PresignedPostPolicy.meta = {
|
|
45
|
+
checkRead: false,
|
|
46
|
+
checkWrite: true
|
|
47
|
+
};
|
|
48
|
+
export default AwsS3PresignedPostPolicy;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Request Schema - AwsS3PresignedPostPolicy',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'key'
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
acl: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: [
|
|
26
|
+
'private',
|
|
27
|
+
'public-read',
|
|
28
|
+
'public-read-write',
|
|
29
|
+
'aws-exec-read',
|
|
30
|
+
'authenticated-read',
|
|
31
|
+
'bucket-owner-read',
|
|
32
|
+
'bucket-owner-full-control',
|
|
33
|
+
],
|
|
34
|
+
description: 'Access control lists used to grant read and write access.',
|
|
35
|
+
errorMessage: {
|
|
36
|
+
type: 'AwsS3PresignedPostPolicy request property "acl" should be a string.',
|
|
37
|
+
enum: 'AwsS3PresignedPostPolicy request property "acl" is not one of "private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read", "bucket-owner-read", "bucket-owner-full-control".'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
conditions: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: {
|
|
43
|
+
type: 'array'
|
|
44
|
+
},
|
|
45
|
+
description: 'Conditions to be enforced on the request.',
|
|
46
|
+
errorMessage: {
|
|
47
|
+
type: 'AwsS3PresignedPostPolicy request property "conditions" should be a array.'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
expires: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
description: 'Number of seconds for which the policy should be valid.',
|
|
53
|
+
default: 3600,
|
|
54
|
+
errorMessage: {
|
|
55
|
+
type: 'AwsS3PresignedPostPolicy request property "expires" should be a number.'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
key: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Key under which object will be stored.',
|
|
61
|
+
errorMessage: {
|
|
62
|
+
type: 'AwsS3PresignedPostPolicy request property "key" should be a string.'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
errorMessage: {
|
|
67
|
+
type: 'AwsS3PresignedPostPolicy request properties should be an object.',
|
|
68
|
+
required: 'AwsS3PresignedPostPolicy request should have required property "key".'
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Connection Schema - AwsS3Bucket',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'accessKeyId',
|
|
21
|
+
'secretAccessKey',
|
|
22
|
+
'region',
|
|
23
|
+
'bucket'
|
|
24
|
+
],
|
|
25
|
+
properties: {
|
|
26
|
+
accessKeyId: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'AWS IAM access key id with s3 access.',
|
|
29
|
+
errorMessage: {
|
|
30
|
+
type: 'AwsS3Bucket connection property "accessKeyId" should be a string.'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
secretAccessKey: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'AWS IAM secret access key with s3 access.',
|
|
36
|
+
errorMessage: {
|
|
37
|
+
type: 'AwsS3Bucket connection property "secretAccessKey" should be a string.'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
region: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'AWS region the bucket is located in.',
|
|
43
|
+
errorMessage: {
|
|
44
|
+
type: 'AwsS3Bucket connection property "region" should be a string.'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
bucket: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'S3 bucket name.',
|
|
50
|
+
errorMessage: {
|
|
51
|
+
type: 'AwsS3Bucket connection property "bucket" should be a string.'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
read: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
default: true,
|
|
57
|
+
description: 'Allow reads from the bucket.',
|
|
58
|
+
errorMessage: {
|
|
59
|
+
type: 'AwsS3Bucket connection property "read" should be a boolean.'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
write: {
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
default: false,
|
|
65
|
+
description: 'Allow writes to the bucket.',
|
|
66
|
+
errorMessage: {
|
|
67
|
+
type: 'AwsS3Bucket connection property "write" should be a boolean.'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
errorMessage: {
|
|
72
|
+
type: 'AwsS3Bucket connection properties should be an object.',
|
|
73
|
+
required: {
|
|
74
|
+
accessKeyId: 'AwsS3Bucket connection should have required property "accessKeyId".',
|
|
75
|
+
secretAccessKey: 'AwsS3Bucket connection should have required property "secretAccessKey".',
|
|
76
|
+
region: 'AwsS3Bucket connection should have required property "region".',
|
|
77
|
+
bucket: 'AwsS3Bucket connection should have required property "bucket".'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,13 +12,4 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ export default
|
|
16
|
-
import: {
|
|
17
|
-
path: 'connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js',
|
|
18
|
-
schema: 'connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedPostPolicySchema.json'
|
|
19
|
-
},
|
|
20
|
-
meta: {
|
|
21
|
-
checkRead: false,
|
|
22
|
-
checkWrite: true
|
|
23
|
-
}
|
|
24
|
-
};
|
|
15
|
+
*/ export { default as AwsS3Bucket } from './connections/AwsS3Bucket/AwsS3Bucket.js';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* eslint-disable import/namespace */ /*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import * as connections from './connections.js';
|
|
16
|
+
export default {
|
|
17
|
+
connections: Object.keys(connections),
|
|
18
|
+
requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)
|
|
19
|
+
).flat()
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/plugin-aws",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.9",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -36,22 +36,37 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "yarn swc",
|
|
38
38
|
"clean": "rm -rf dist",
|
|
39
|
+
"copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
|
|
39
40
|
"prepare": "yarn build",
|
|
40
|
-
"swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start
|
|
41
|
+
"swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start && yarn copyfiles",
|
|
41
42
|
"test": "jest --coverage"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
+
"@lowdefy/block-utils": "4.0.0-alpha.9",
|
|
46
|
+
"@lowdefy/blocks-antd": "4.0.0-alpha.9",
|
|
47
|
+
"@lowdefy/helpers": "4.0.0-alpha.9",
|
|
48
|
+
"antd": "4.18.2",
|
|
49
|
+
"aws-sdk": "2.1066.0",
|
|
50
|
+
"react": "17.0.2",
|
|
51
|
+
"react-dom": "17.0.2"
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
47
|
-
"@
|
|
54
|
+
"@emotion/jest": "11.7.1",
|
|
55
|
+
"@lowdefy/ajv": "4.0.0-alpha.9",
|
|
56
|
+
"@lowdefy/block-dev": "4.0.0-alpha.9",
|
|
48
57
|
"@swc/cli": "0.1.55",
|
|
49
|
-
"@swc/core": "1.2.
|
|
58
|
+
"@swc/core": "1.2.135",
|
|
50
59
|
"@swc/jest": "0.2.17",
|
|
51
|
-
"
|
|
60
|
+
"@testing-library/dom": "8.11.3",
|
|
61
|
+
"@testing-library/react": "13.0.0-alpha.4",
|
|
62
|
+
"@testing-library/user-event": "14.0.0-alpha.14",
|
|
63
|
+
"copyfiles": "2.4.1",
|
|
64
|
+
"jest": "27.5.1",
|
|
65
|
+
"jest-serializer-html": "7.1.0",
|
|
66
|
+
"jest-transform-yaml": "1.0.0"
|
|
52
67
|
},
|
|
53
68
|
"publishConfig": {
|
|
54
69
|
"access": "public"
|
|
55
70
|
},
|
|
56
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
|
|
57
72
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Connection Schema - AwsS3Bucket",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["accessKeyId", "secretAccessKey", "region", "bucket"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"accessKeyId": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "AWS IAM access key id with s3 access.",
|
|
10
|
-
"errorMessage": {
|
|
11
|
-
"type": "AwsS3Bucket connection property \"accessKeyId\" should be a string."
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"secretAccessKey": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "AWS IAM secret access key with s3 access.",
|
|
17
|
-
"errorMessage": {
|
|
18
|
-
"type": "AwsS3Bucket connection property \"secretAccessKey\" should be a string."
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"region": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "AWS region the bucket is located in.",
|
|
24
|
-
"errorMessage": {
|
|
25
|
-
"type": "AwsS3Bucket connection property \"region\" should be a string."
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"bucket": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"description": "S3 bucket name.",
|
|
31
|
-
"errorMessage": {
|
|
32
|
-
"type": "AwsS3Bucket connection property \"bucket\" should be a string."
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"read": {
|
|
36
|
-
"type": "boolean",
|
|
37
|
-
"default": true,
|
|
38
|
-
"description": "Allow reads from the bucket.",
|
|
39
|
-
"errorMessage": {
|
|
40
|
-
"type": "AwsS3Bucket connection property \"read\" should be a boolean."
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"write": {
|
|
44
|
-
"type": "boolean",
|
|
45
|
-
"default": false,
|
|
46
|
-
"description": "Allow writes to the bucket.",
|
|
47
|
-
"errorMessage": {
|
|
48
|
-
"type": "AwsS3Bucket connection property \"write\" should be a boolean."
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"errorMessage": {
|
|
53
|
-
"type": "AwsS3Bucket connection properties should be an object.",
|
|
54
|
-
"required": {
|
|
55
|
-
"accessKeyId": "AwsS3Bucket connection should have required property \"accessKeyId\".",
|
|
56
|
-
"secretAccessKey": "AwsS3Bucket connection should have required property \"secretAccessKey\".",
|
|
57
|
-
"region": "AwsS3Bucket connection should have required property \"region\".",
|
|
58
|
-
"bucket": "AwsS3Bucket connection should have required property \"bucket\"."
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObjectSchema.json
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Request Schema - AwsS3PresignedGetObject",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["key"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"expires": {
|
|
8
|
-
"type": "number",
|
|
9
|
-
"description": "Number of seconds for which the policy should be valid.",
|
|
10
|
-
"default": 3600,
|
|
11
|
-
"errorMessage": {
|
|
12
|
-
"type": "AwsS3PresignedGetObject request property \"expires\" should be a number."
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"key": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "Key under which object is stored.",
|
|
18
|
-
"errorMessage": {
|
|
19
|
-
"type": "AwsS3PresignedGetObject request property \"key\" should be a string."
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"responseContentDisposition": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "Sets the Content-Disposition header of the response.",
|
|
25
|
-
"errorMessage": {
|
|
26
|
-
"type": "AwsS3PresignedGetObject request property \"responseContentDisposition\" should be a string."
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"responseContentType": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"description": "Sets the Content-Type header of the response.",
|
|
32
|
-
"errorMessage": {
|
|
33
|
-
"type": "AwsS3PresignedGetObject request property \"responseContentType\" should be a string."
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"versionId": {
|
|
37
|
-
"type": "string",
|
|
38
|
-
"description": "VersionId used to reference a specific version of the object.",
|
|
39
|
-
"errorMessage": {
|
|
40
|
-
"type": "AwsS3PresignedGetObject request property \"versionId\" should be a string."
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"errorMessage": {
|
|
45
|
-
"type": "AwsS3PresignedGetObject request properties should be an object.",
|
|
46
|
-
"required": "AwsS3PresignedGetObject request should have required property \"key\"."
|
|
47
|
-
}
|
|
48
|
-
}
|
package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicySchema.json
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Request Schema - AwsS3PresignedPostPolicy",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["key"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"acl": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"enum": [
|
|
10
|
-
"private",
|
|
11
|
-
"public-read",
|
|
12
|
-
"public-read-write",
|
|
13
|
-
"aws-exec-read",
|
|
14
|
-
"authenticated-read",
|
|
15
|
-
"bucket-owner-read",
|
|
16
|
-
"bucket-owner-full-control"
|
|
17
|
-
],
|
|
18
|
-
"description": "Access control lists used to grant read and write access.",
|
|
19
|
-
"errorMessage": {
|
|
20
|
-
"type": "AwsS3PresignedPostPolicy request property \"acl\" should be a string.",
|
|
21
|
-
"enum": "AwsS3PresignedPostPolicy request property \"acl\" is not one of \"private\", \"public-read\", \"public-read-write\", \"aws-exec-read\", \"authenticated-read\", \"bucket-owner-read\", \"bucket-owner-full-control\"."
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"conditions": {
|
|
25
|
-
"type": "array",
|
|
26
|
-
"items": {
|
|
27
|
-
"type": "array"
|
|
28
|
-
},
|
|
29
|
-
"description": "Conditions to be enforced on the request.",
|
|
30
|
-
"errorMessage": {
|
|
31
|
-
"type": "AwsS3PresignedPostPolicy request property \"conditions\" should be a array."
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"expires": {
|
|
35
|
-
"type": "number",
|
|
36
|
-
"description": "Number of seconds for which the policy should be valid.",
|
|
37
|
-
"default": 3600,
|
|
38
|
-
"errorMessage": {
|
|
39
|
-
"type": "AwsS3PresignedPostPolicy request property \"expires\" should be a number."
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"key": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"description": "Key under which object will be stored.",
|
|
45
|
-
"errorMessage": {
|
|
46
|
-
"type": "AwsS3PresignedPostPolicy request property \"key\" should be a string."
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"errorMessage": {
|
|
51
|
-
"type": "AwsS3PresignedPostPolicy request properties should be an object.",
|
|
52
|
-
"required": "AwsS3PresignedPostPolicy request should have required property \"key\"."
|
|
53
|
-
}
|
|
54
|
-
}
|