@lowdefy/plugin-aws 4.2.0 → 4.2.1

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.
Files changed (28) hide show
  1. package/dist/blocks/S3Download/S3Download.js +70 -0
  2. package/dist/blocks/S3Download/schema.json +85 -0
  3. package/dist/blocks/S3Download/style.less +17 -0
  4. package/dist/blocks/S3UploadButton/S3UploadButton.js +97 -0
  5. package/dist/blocks/S3UploadButton/__snapshots__/S3UploadButton.mock.test.js.snap +1597 -0
  6. package/dist/blocks/S3UploadButton/__snapshots__/S3UploadButton.test.js.snap +281 -0
  7. package/dist/blocks/S3UploadButton/examples.yaml +44 -0
  8. package/dist/blocks/S3UploadButton/schema.json +87 -0
  9. package/dist/blocks/S3UploadButton/style.less +18 -0
  10. package/dist/blocks/S3UploadDragger/S3UploadDragger.js +101 -0
  11. package/dist/blocks/S3UploadDragger/schema.json +81 -0
  12. package/dist/blocks/S3UploadDragger/style.less +17 -0
  13. package/dist/blocks/S3UploadPhoto/S3UploadPhoto.js +114 -0
  14. package/dist/blocks/S3UploadPhoto/schema.json +79 -0
  15. package/dist/blocks/S3UploadPhoto/style.less +17 -0
  16. package/dist/blocks/utils/getOnPaste.js +48 -0
  17. package/dist/blocks/utils/getS3Upload.js +81 -0
  18. package/dist/blocks/utils/useFileList.js +115 -0
  19. package/dist/blocks.js +18 -0
  20. package/dist/connections/AwsS3Bucket/AwsS3Bucket.js +24 -0
  21. package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js +41 -0
  22. package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/schema.js +64 -0
  23. package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +57 -0
  24. package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/schema.js +70 -0
  25. package/dist/connections/AwsS3Bucket/schema.js +80 -0
  26. package/dist/connections.js +15 -0
  27. package/dist/types.js +32 -0
  28. package/package.json +7 -7
@@ -0,0 +1,281 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Render default - value[0] 1`] = `
4
+ <span
5
+ class=""
6
+ >
7
+ <div
8
+ class="ant-upload ant-upload-select ant-upload-select-text"
9
+ >
10
+ <span
11
+ class="ant-upload"
12
+ role="button"
13
+ tabindex="0"
14
+ >
15
+ <input
16
+ accept=""
17
+ id="default"
18
+ multiple=""
19
+ style="display: none;"
20
+ type="file"
21
+ />
22
+ <button
23
+ class="ant-btn emotion-0"
24
+ id="default_button"
25
+ type="button"
26
+ >
27
+ <svg
28
+ class="emotion-1"
29
+ data-testid="AiOutlineExclamationCircle"
30
+ id="default_button_icon"
31
+ />
32
+ <span
33
+ class="emotion-1"
34
+ >
35
+ Upload
36
+ </span>
37
+ </button>
38
+ </span>
39
+ </div>
40
+ <div
41
+ class="ant-upload-list ant-upload-list-text"
42
+ />
43
+ </span>
44
+ `;
45
+
46
+ exports[`Render properties.accept - value[0] 1`] = `
47
+ <span
48
+ class=""
49
+ >
50
+ <div
51
+ class="ant-upload ant-upload-select ant-upload-select-text"
52
+ >
53
+ <span
54
+ class="ant-upload"
55
+ role="button"
56
+ tabindex="0"
57
+ >
58
+ <input
59
+ accept=".png,.jpg"
60
+ id="properties.accept"
61
+ multiple=""
62
+ style="display: none;"
63
+ type="file"
64
+ />
65
+ <button
66
+ class="ant-btn emotion-0"
67
+ id="properties.accept_button"
68
+ type="button"
69
+ >
70
+ <svg
71
+ class="emotion-1"
72
+ data-testid="AiOutlineExclamationCircle"
73
+ id="properties.accept_button_icon"
74
+ />
75
+ <span
76
+ class="emotion-1"
77
+ >
78
+ Upload
79
+ </span>
80
+ </button>
81
+ </span>
82
+ </div>
83
+ <div
84
+ class="ant-upload-list ant-upload-list-text"
85
+ />
86
+ </span>
87
+ `;
88
+
89
+ exports[`Render properties.button - value[0] 1`] = `
90
+ <span
91
+ class=""
92
+ >
93
+ <div
94
+ class="ant-upload ant-upload-select ant-upload-select-text"
95
+ >
96
+ <span
97
+ class="ant-upload"
98
+ role="button"
99
+ tabindex="0"
100
+ >
101
+ <input
102
+ accept=""
103
+ id="properties.button"
104
+ multiple=""
105
+ style="display: none;"
106
+ type="file"
107
+ />
108
+ <button
109
+ class="ant-btn ant-btn-primary emotion-0"
110
+ id="properties.button_button"
111
+ type="button"
112
+ >
113
+ <svg
114
+ class="emotion-1"
115
+ data-testid="AiOutlineExclamationCircle"
116
+ id="properties.button_button_icon"
117
+ />
118
+ <span
119
+ class="emotion-1"
120
+ >
121
+ Upload
122
+ </span>
123
+ </button>
124
+ </span>
125
+ </div>
126
+ <div
127
+ class="ant-upload-list ant-upload-list-text"
128
+ />
129
+ </span>
130
+ `;
131
+
132
+ exports[`Render properties.disabled - value[0] 1`] = `
133
+ <span
134
+ class=""
135
+ >
136
+ <div
137
+ class="ant-upload ant-upload-select ant-upload-select-text ant-upload-disabled"
138
+ >
139
+ <span
140
+ class="ant-upload ant-upload-disabled"
141
+ role="button"
142
+ >
143
+ <input
144
+ accept=""
145
+ multiple=""
146
+ style="display: none;"
147
+ type="file"
148
+ />
149
+ <button
150
+ class="ant-btn emotion-0"
151
+ disabled=""
152
+ id="properties.disabled_button"
153
+ type="button"
154
+ >
155
+ <svg
156
+ class="emotion-1"
157
+ data-testid="AiOutlineExclamationCircle"
158
+ id="properties.disabled_button_icon"
159
+ />
160
+ <span
161
+ class="emotion-1"
162
+ >
163
+ Upload
164
+ </span>
165
+ </button>
166
+ </span>
167
+ </div>
168
+ <div
169
+ class="ant-upload-list ant-upload-list-text"
170
+ />
171
+ </span>
172
+ `;
173
+
174
+ exports[`Render properties.showUploadList - value[0] 1`] = `
175
+ <span
176
+ class=""
177
+ >
178
+ <div
179
+ class="ant-upload ant-upload-select ant-upload-select-text"
180
+ >
181
+ <span
182
+ class="ant-upload"
183
+ role="button"
184
+ tabindex="0"
185
+ >
186
+ <input
187
+ accept=""
188
+ id="properties.showUploadList"
189
+ multiple=""
190
+ style="display: none;"
191
+ type="file"
192
+ />
193
+ <button
194
+ class="ant-btn emotion-0"
195
+ id="properties.showUploadList_button"
196
+ type="button"
197
+ >
198
+ <svg
199
+ class="emotion-1"
200
+ data-testid="AiOutlineExclamationCircle"
201
+ id="properties.showUploadList_button_icon"
202
+ />
203
+ <span
204
+ class="emotion-1"
205
+ >
206
+ Upload
207
+ </span>
208
+ </button>
209
+ </span>
210
+ </div>
211
+ <div
212
+ class="ant-upload-list ant-upload-list-text"
213
+ />
214
+ </span>
215
+ `;
216
+
217
+ exports[`Render properties.singleFile - value[0] 1`] = `
218
+ <span
219
+ class=""
220
+ >
221
+ <div
222
+ class="ant-upload ant-upload-select ant-upload-select-text"
223
+ >
224
+ <span
225
+ class="ant-upload"
226
+ role="button"
227
+ tabindex="0"
228
+ >
229
+ <input
230
+ accept=""
231
+ id="properties.singleFile"
232
+ style="display: none;"
233
+ type="file"
234
+ />
235
+ <button
236
+ class="ant-btn emotion-0"
237
+ id="properties.singleFile_button"
238
+ type="button"
239
+ >
240
+ <svg
241
+ class="emotion-1"
242
+ data-testid="AiOutlineExclamationCircle"
243
+ id="properties.singleFile_button_icon"
244
+ />
245
+ <span
246
+ class="emotion-1"
247
+ >
248
+ Upload
249
+ </span>
250
+ </button>
251
+ </span>
252
+ </div>
253
+ <div
254
+ class="ant-upload-list ant-upload-list-text"
255
+ />
256
+ </span>
257
+ `;
258
+
259
+ exports[`Test Schema default 1`] = `true`;
260
+
261
+ exports[`Test Schema default 2`] = `null`;
262
+
263
+ exports[`Test Schema properties.accept 1`] = `true`;
264
+
265
+ exports[`Test Schema properties.accept 2`] = `null`;
266
+
267
+ exports[`Test Schema properties.button 1`] = `true`;
268
+
269
+ exports[`Test Schema properties.button 2`] = `null`;
270
+
271
+ exports[`Test Schema properties.disabled 1`] = `true`;
272
+
273
+ exports[`Test Schema properties.disabled 2`] = `null`;
274
+
275
+ exports[`Test Schema properties.showUploadList 1`] = `true`;
276
+
277
+ exports[`Test Schema properties.showUploadList 2`] = `null`;
278
+
279
+ exports[`Test Schema properties.singleFile 1`] = `true`;
280
+
281
+ exports[`Test Schema properties.singleFile 2`] = `null`;
@@ -0,0 +1,44 @@
1
+ # Copyright 2020-2024 Lowdefy, Inc
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ - id: default
16
+ type: S3UploadButton
17
+ properties:
18
+ s3PostPolicyRequestId: s3PostPolicyRequestId
19
+ - id: properties.accept
20
+ type: S3UploadButton
21
+ properties:
22
+ accept: '.png,.jpg'
23
+ s3PostPolicyRequestId: s3PostPolicyRequestId
24
+ - id: properties.button
25
+ type: S3UploadButton
26
+ properties:
27
+ button:
28
+ type: primary
29
+ s3PostPolicyRequestId: s3PostPolicyRequestId
30
+ - id: properties.disabled
31
+ type: S3UploadButton
32
+ properties:
33
+ disabled: true
34
+ s3PostPolicyRequestId: s3PostPolicyRequestId
35
+ - id: properties.showUploadList
36
+ type: S3UploadButton
37
+ properties:
38
+ s3PostPolicyRequestId: s3PostPolicyRequestId
39
+ showUploadList: true
40
+ - id: properties.singleFile
41
+ type: S3UploadButton
42
+ properties:
43
+ s3PostPolicyRequestId: s3PostPolicyRequestId
44
+ singleFile: true
@@ -0,0 +1,87 @@
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
+ "maxCount": {
28
+ "type": "number",
29
+ "description": "Maximum number of files that can be uploaded."
30
+ },
31
+ "s3PostPolicyRequestId": {
32
+ "type": "string",
33
+ "description": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.",
34
+ "docs": {
35
+ "displayType": "manual",
36
+ "block": {
37
+ "id": "block_properties_s3PostPolicyRequestId",
38
+ "layout": { "_global": "settings_input_layout" },
39
+ "type": "Label",
40
+ "required": true,
41
+ "properties": {
42
+ "title": "s3PostPolicyRequestId",
43
+ "span": 8,
44
+ "align": "right"
45
+ },
46
+ "blocks": [
47
+ {
48
+ "id": "block_properties_s3PostPolicyRequestId_text",
49
+ "type": "Markdown",
50
+ "style": {
51
+ "color": "#8c8c8c"
52
+ },
53
+ "properties": {
54
+ "content": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded."
55
+ }
56
+ }
57
+ ]
58
+ },
59
+ "getter": {}
60
+ }
61
+ },
62
+ "showUploadList": {
63
+ "type": "boolean",
64
+ "default": true,
65
+ "description": "Whether to show default upload list."
66
+ },
67
+ "singleFile": {
68
+ "type": "boolean",
69
+ "default": false,
70
+ "description": "Only allow a single file to be uploaded. Only one file can be selected in the prompt."
71
+ }
72
+ }
73
+ },
74
+ "events": {
75
+ "type": "object",
76
+ "properties": {
77
+ "onChange": {
78
+ "type": "array",
79
+ "description": "Triggered when the upload state is changing."
80
+ },
81
+ "onClick": {
82
+ "type": "array",
83
+ "description": "Triggered when the upload button is clicked."
84
+ }
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,18 @@
1
+ /*
2
+ Copyright 2020-2024 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
+ */
16
+
17
+ @import 'antd/lib/upload/style/index.less';
18
+ @import 'antd/lib/button/style/index.less';
@@ -0,0 +1,101 @@
1
+ /*
2
+ Copyright 2020-2024 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 } from 'react';
16
+ import { Upload } from 'antd';
17
+ import { blockDefaultProps, renderHtml } from '@lowdefy/block-utils';
18
+ import useFileList from '../utils/useFileList.js';
19
+ import getS3Upload from '../utils/getS3Upload.js';
20
+ import getOnPaste from '../utils/getOnPaste.js';
21
+ const { Dragger } = Upload;
22
+ const S3UploadDragger = ({ blockId, methods, properties, value })=>{
23
+ const [state, loadFileList, setFileList, removeFile, setValue] = useFileList({
24
+ properties,
25
+ methods,
26
+ value
27
+ });
28
+ const s3UploadRequest = getS3Upload({
29
+ methods,
30
+ setFileList
31
+ });
32
+ const onPaste = getOnPaste({
33
+ s3UploadRequest,
34
+ properties
35
+ });
36
+ useEffect(()=>{
37
+ methods.registerEvent({
38
+ name: '__getS3PostPolicy',
39
+ actions: [
40
+ {
41
+ id: '__getS3PostPolicy',
42
+ type: 'Request',
43
+ params: [
44
+ properties.s3PostPolicyRequestId
45
+ ]
46
+ }
47
+ ]
48
+ });
49
+ }, []);
50
+ useEffect(()=>{
51
+ if (JSON.stringify(value) !== JSON.stringify(state)) {
52
+ setValue(value);
53
+ }
54
+ }, [
55
+ value
56
+ ]);
57
+ useEffect(()=>{
58
+ methods.registerMethod('uploadFromPaste', async ()=>{
59
+ await onPaste();
60
+ });
61
+ }, [
62
+ onPaste
63
+ ]);
64
+ return /*#__PURE__*/ React.createElement("div", {
65
+ id: blockId,
66
+ onPaste: onPaste
67
+ }, /*#__PURE__*/ React.createElement(Dragger, {
68
+ accept: properties.accept ?? '*',
69
+ beforeUpload: loadFileList,
70
+ className: methods.makeCssClass([
71
+ properties.style
72
+ ]),
73
+ customRequest: s3UploadRequest,
74
+ disabled: properties.disabled,
75
+ fileList: state.fileList,
76
+ maxCount: properties.maxCount,
77
+ multiple: !properties.singleFile,
78
+ onRemove: removeFile,
79
+ showUploadList: properties.showUploadList,
80
+ onChange: ()=>{
81
+ methods.triggerEvent({
82
+ name: 'onChange'
83
+ });
84
+ }
85
+ }, /*#__PURE__*/ React.createElement("div", {
86
+ className: "ant-upload-hint"
87
+ }, renderHtml({
88
+ html: properties.title ?? 'Click or drag to add a file.',
89
+ methods
90
+ }))));
91
+ };
92
+ S3UploadDragger.defaultProps = blockDefaultProps;
93
+ S3UploadDragger.meta = {
94
+ valueType: 'object',
95
+ category: 'input',
96
+ icons: [],
97
+ styles: [
98
+ 'blocks/S3UploadDragger/style.less'
99
+ ]
100
+ };
101
+ export default S3UploadDragger;
@@ -0,0 +1,81 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "type": "object",
5
+ "required": ["s3PostPolicyRequestId"],
6
+ "properties": {
7
+ "title": {
8
+ "type": "string",
9
+ "description": "Title of the file input to be displayed on the draggable area."
10
+ },
11
+ "accept": {
12
+ "type": "string",
13
+ "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."
14
+ },
15
+ "disabled": {
16
+ "type": "boolean",
17
+ "description": "Disable the file input."
18
+ },
19
+ "maxCount": {
20
+ "type": "number",
21
+ "description": "Maximum number of files that can be uploaded."
22
+ },
23
+ "s3PostPolicyRequestId": {
24
+ "type": "string",
25
+ "description": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.",
26
+ "docs": {
27
+ "displayType": "manual",
28
+ "block": {
29
+ "id": "block_properties_s3PostPolicyRequestId",
30
+ "layout": { "_global": "settings_input_layout" },
31
+ "type": "Label",
32
+ "required": true,
33
+ "properties": {
34
+ "title": "s3PostPolicyRequestId",
35
+ "span": 8,
36
+ "align": "right"
37
+ },
38
+ "blocks": [
39
+ {
40
+ "id": "block_properties_s3PostPolicyRequestId_text",
41
+ "type": "Markdown",
42
+ "style": {
43
+ "color": "#8c8c8c"
44
+ },
45
+ "properties": {
46
+ "content": "Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded."
47
+ }
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ },
53
+ "showUploadList": {
54
+ "type": "boolean",
55
+ "default": true,
56
+ "description": "Whether to show default upload list."
57
+ },
58
+ "singleFile": {
59
+ "type": "boolean",
60
+ "default": false,
61
+ "description": "Only allow a single file to be uploaded. Only one file can be selected in the prompt."
62
+ },
63
+ "style": {
64
+ "type": "object",
65
+ "description": "Css style object to applied to draggable area.",
66
+ "docs": {
67
+ "displayType": "yaml"
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "events": {
73
+ "type": "object",
74
+ "properties": {
75
+ "onChange": {
76
+ "type": "array",
77
+ "description": "Triggered when the upload state is changing."
78
+ }
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ Copyright 2020-2024 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
+ */
16
+
17
+ @import 'antd/lib/upload/style/index.less';