@lowdefy/plugin-aws 4.7.3 → 5.0.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.
- package/dist/blocks/S3Download/S3Download.js +6 -14
- package/dist/blocks/S3Download/gallery.yaml +234 -0
- package/dist/blocks/S3Download/meta.js +103 -0
- package/dist/blocks/S3Download/schema.js +107 -0
- package/dist/blocks/S3UploadButton/S3UploadButton.js +5 -14
- package/dist/blocks/S3UploadButton/gallery.yaml +349 -0
- package/dist/blocks/S3UploadButton/meta.js +156 -0
- package/dist/blocks/S3UploadButton/schema.js +121 -0
- package/dist/blocks/S3UploadDragger/S3UploadDragger.js +8 -16
- package/dist/blocks/S3UploadDragger/gallery.yaml +275 -0
- package/dist/blocks/S3UploadDragger/meta.js +102 -0
- package/dist/blocks/S3UploadDragger/schema.js +119 -0
- package/dist/blocks/S3UploadPhoto/S3UploadPhoto.js +20 -19
- package/dist/blocks/S3UploadPhoto/gallery.yaml +259 -0
- package/dist/blocks/S3UploadPhoto/meta.js +93 -0
- package/dist/blocks/S3UploadPhoto/schema.js +113 -0
- package/dist/blocks/utils/getS3Upload.js +35 -24
- package/dist/blocks/utils/useFileList.js +27 -4
- package/dist/blocks/withTheme.js +40 -0
- package/dist/connections/AwsS3Bucket/AwsS3PresignedGetObject/AwsS3PresignedGetObject.js +15 -11
- package/dist/connections/AwsS3Bucket/AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js +12 -11
- package/dist/{blocks/S3UploadButton/style.less → metas.js} +4 -4
- package/dist/types.js +11 -17
- package/package.json +20 -16
- package/dist/blocks/S3Download/schema.json +0 -85
- package/dist/blocks/S3Download/style.less +0 -17
- package/dist/blocks/S3UploadButton/schema.json +0 -103
- package/dist/blocks/S3UploadDragger/schema.json +0 -97
- package/dist/blocks/S3UploadDragger/style.less +0 -17
- package/dist/blocks/S3UploadPhoto/schema.json +0 -95
- package/dist/blocks/S3UploadPhoto/style.less +0 -17
- /package/dist/blocks/S3UploadButton/{examples.yaml → tests.yaml} +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Copyright 2020-2026 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
|
+
- title: Basic
|
|
16
|
+
blocks:
|
|
17
|
+
- id: basic_default
|
|
18
|
+
type: S3UploadPhoto
|
|
19
|
+
properties:
|
|
20
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
21
|
+
- id: basic_custom_title
|
|
22
|
+
type: S3UploadPhoto
|
|
23
|
+
properties:
|
|
24
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
25
|
+
title: Add Photo
|
|
26
|
+
- id: basic_html_title
|
|
27
|
+
type: S3UploadPhoto
|
|
28
|
+
properties:
|
|
29
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
30
|
+
title: 'Upload <b>profile</b> photo'
|
|
31
|
+
|
|
32
|
+
- title: Upload Limits
|
|
33
|
+
blocks:
|
|
34
|
+
- id: limit_single
|
|
35
|
+
type: S3UploadPhoto
|
|
36
|
+
properties:
|
|
37
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
38
|
+
singleFile: true
|
|
39
|
+
title: Single Photo
|
|
40
|
+
- id: limit_max_three
|
|
41
|
+
type: S3UploadPhoto
|
|
42
|
+
properties:
|
|
43
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
44
|
+
maxCount: 3
|
|
45
|
+
title: Max 3 Photos
|
|
46
|
+
- id: limit_single_hidden
|
|
47
|
+
type: S3UploadPhoto
|
|
48
|
+
properties:
|
|
49
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
50
|
+
singleFile: true
|
|
51
|
+
showUploadList: false
|
|
52
|
+
title: Single (No List)
|
|
53
|
+
|
|
54
|
+
- title: Upload List Visibility
|
|
55
|
+
blocks:
|
|
56
|
+
- id: list_visible
|
|
57
|
+
type: S3UploadPhoto
|
|
58
|
+
properties:
|
|
59
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
60
|
+
showUploadList: true
|
|
61
|
+
title: List Visible
|
|
62
|
+
- id: list_hidden
|
|
63
|
+
type: S3UploadPhoto
|
|
64
|
+
properties:
|
|
65
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
66
|
+
showUploadList: false
|
|
67
|
+
title: List Hidden
|
|
68
|
+
- id: list_multi_hidden
|
|
69
|
+
type: S3UploadPhoto
|
|
70
|
+
properties:
|
|
71
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
72
|
+
maxCount: 5
|
|
73
|
+
showUploadList: false
|
|
74
|
+
title: Multi (No List)
|
|
75
|
+
|
|
76
|
+
- title: Disabled State
|
|
77
|
+
blocks:
|
|
78
|
+
- id: disabled_default
|
|
79
|
+
type: S3UploadPhoto
|
|
80
|
+
properties:
|
|
81
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
82
|
+
disabled: true
|
|
83
|
+
- id: disabled_custom_title
|
|
84
|
+
type: S3UploadPhoto
|
|
85
|
+
properties:
|
|
86
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
87
|
+
disabled: true
|
|
88
|
+
title: Photo Locked
|
|
89
|
+
- id: disabled_hidden_list
|
|
90
|
+
type: S3UploadPhoto
|
|
91
|
+
properties:
|
|
92
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
93
|
+
disabled: true
|
|
94
|
+
showUploadList: false
|
|
95
|
+
title: Disabled (No List)
|
|
96
|
+
|
|
97
|
+
- title: Card Styling
|
|
98
|
+
blocks:
|
|
99
|
+
- id: style_rounded
|
|
100
|
+
type: S3UploadPhoto
|
|
101
|
+
properties:
|
|
102
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
103
|
+
title: Rounded
|
|
104
|
+
style:
|
|
105
|
+
borderRadius: 50%
|
|
106
|
+
- id: style_large
|
|
107
|
+
type: S3UploadPhoto
|
|
108
|
+
properties:
|
|
109
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
110
|
+
title: Large Card
|
|
111
|
+
style:
|
|
112
|
+
width: 150
|
|
113
|
+
height: 150
|
|
114
|
+
- id: style_colored
|
|
115
|
+
type: S3UploadPhoto
|
|
116
|
+
properties:
|
|
117
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
118
|
+
title: Tinted
|
|
119
|
+
style:
|
|
120
|
+
backgroundColor: '#f0f5ff'
|
|
121
|
+
color: '#1677ff'
|
|
122
|
+
|
|
123
|
+
- title: Style Overrides
|
|
124
|
+
blocks:
|
|
125
|
+
- id: style_element_bg
|
|
126
|
+
type: S3UploadPhoto
|
|
127
|
+
style:
|
|
128
|
+
.element:
|
|
129
|
+
background: '#f6ffed'
|
|
130
|
+
borderRadius: 8
|
|
131
|
+
padding: 8
|
|
132
|
+
properties:
|
|
133
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
134
|
+
title: Green Background
|
|
135
|
+
- id: style_element_border
|
|
136
|
+
type: S3UploadPhoto
|
|
137
|
+
style:
|
|
138
|
+
.element:
|
|
139
|
+
border: 2px solid #d3adf7
|
|
140
|
+
borderRadius: 12
|
|
141
|
+
properties:
|
|
142
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
143
|
+
title: Purple Border
|
|
144
|
+
- id: style_tailwind
|
|
145
|
+
type: S3UploadPhoto
|
|
146
|
+
class: shadow-md rounded-lg
|
|
147
|
+
properties:
|
|
148
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
149
|
+
title: Tailwind Shadow
|
|
150
|
+
|
|
151
|
+
- title: S3UploadPhoto in User Profile
|
|
152
|
+
blocks:
|
|
153
|
+
- id: profile_card
|
|
154
|
+
type: Card
|
|
155
|
+
properties:
|
|
156
|
+
title: Edit Profile
|
|
157
|
+
blocks:
|
|
158
|
+
- id: profile_photo
|
|
159
|
+
type: S3UploadPhoto
|
|
160
|
+
properties:
|
|
161
|
+
title: Profile Photo
|
|
162
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
163
|
+
singleFile: true
|
|
164
|
+
style:
|
|
165
|
+
borderRadius: 50%
|
|
166
|
+
- id: profile_name
|
|
167
|
+
type: TextInput
|
|
168
|
+
required: true
|
|
169
|
+
properties:
|
|
170
|
+
title: Full Name
|
|
171
|
+
placeholder: Enter your name
|
|
172
|
+
prefixIcon: AiOutlineUser
|
|
173
|
+
- id: profile_email
|
|
174
|
+
type: TextInput
|
|
175
|
+
properties:
|
|
176
|
+
title: Email
|
|
177
|
+
placeholder: you@example.com
|
|
178
|
+
prefixIcon: AiOutlineMail
|
|
179
|
+
- id: profile_save
|
|
180
|
+
type: Button
|
|
181
|
+
properties:
|
|
182
|
+
title: Save Profile
|
|
183
|
+
color: primary
|
|
184
|
+
variant: solid
|
|
185
|
+
icon: AiOutlineSave
|
|
186
|
+
events:
|
|
187
|
+
onClick:
|
|
188
|
+
- id: validate_profile
|
|
189
|
+
type: Validate
|
|
190
|
+
- id: save_msg
|
|
191
|
+
type: DisplayMessage
|
|
192
|
+
params:
|
|
193
|
+
content: Profile saved successfully!
|
|
194
|
+
status: success
|
|
195
|
+
|
|
196
|
+
- title: S3UploadPhoto in Product Listing
|
|
197
|
+
blocks:
|
|
198
|
+
- id: product_card
|
|
199
|
+
type: Card
|
|
200
|
+
properties:
|
|
201
|
+
title: Add Product
|
|
202
|
+
blocks:
|
|
203
|
+
- id: product_photos
|
|
204
|
+
type: S3UploadPhoto
|
|
205
|
+
properties:
|
|
206
|
+
title: Product Photos
|
|
207
|
+
s3PostPolicyRequestId: s3_upload_policy_request
|
|
208
|
+
maxCount: 5
|
|
209
|
+
events:
|
|
210
|
+
onChange:
|
|
211
|
+
- id: photo_state
|
|
212
|
+
type: SetState
|
|
213
|
+
params:
|
|
214
|
+
photosUploaded: true
|
|
215
|
+
- id: product_name
|
|
216
|
+
type: TextInput
|
|
217
|
+
required: true
|
|
218
|
+
properties:
|
|
219
|
+
title: Product Name
|
|
220
|
+
placeholder: Enter product name
|
|
221
|
+
- id: product_category
|
|
222
|
+
type: Selector
|
|
223
|
+
properties:
|
|
224
|
+
title: Category
|
|
225
|
+
placeholder: Select category
|
|
226
|
+
options:
|
|
227
|
+
- label: Electronics
|
|
228
|
+
value: electronics
|
|
229
|
+
- label: Clothing
|
|
230
|
+
value: clothing
|
|
231
|
+
- label: Home & Garden
|
|
232
|
+
value: home
|
|
233
|
+
- label: Sports
|
|
234
|
+
value: sports
|
|
235
|
+
- id: product_price
|
|
236
|
+
type: NumberInput
|
|
237
|
+
properties:
|
|
238
|
+
title: Price
|
|
239
|
+
placeholder: 0.00
|
|
240
|
+
min: 0
|
|
241
|
+
precision: 2
|
|
242
|
+
prefix: $
|
|
243
|
+
- id: product_submit
|
|
244
|
+
type: Button
|
|
245
|
+
properties:
|
|
246
|
+
title: List Product
|
|
247
|
+
color: primary
|
|
248
|
+
variant: solid
|
|
249
|
+
icon: AiOutlineCheck
|
|
250
|
+
block: true
|
|
251
|
+
events:
|
|
252
|
+
onClick:
|
|
253
|
+
- id: validate_product
|
|
254
|
+
type: Validate
|
|
255
|
+
- id: list_msg
|
|
256
|
+
type: DisplayMessage
|
|
257
|
+
params:
|
|
258
|
+
content: Product listed successfully!
|
|
259
|
+
status: success
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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
|
+
category: 'input',
|
|
17
|
+
icons: [
|
|
18
|
+
'AiOutlineLoading',
|
|
19
|
+
'AiOutlineCamera'
|
|
20
|
+
],
|
|
21
|
+
valueType: 'object',
|
|
22
|
+
cssKeys: {
|
|
23
|
+
element: 'The upload content area.',
|
|
24
|
+
icon: 'The icon in the S3UploadPhoto.',
|
|
25
|
+
title: 'The upload title text.'
|
|
26
|
+
},
|
|
27
|
+
events: {
|
|
28
|
+
onChange: 'Triggered when the upload state is changing.',
|
|
29
|
+
onProgress: {
|
|
30
|
+
description: 'Triggered when the upload state is in progress.',
|
|
31
|
+
event: {
|
|
32
|
+
file: 'The file being uploaded.',
|
|
33
|
+
fileList: 'The full list of files.'
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onSuccess: {
|
|
37
|
+
description: 'Triggered when the upload state is done uploading.',
|
|
38
|
+
event: {
|
|
39
|
+
file: 'The uploaded file.',
|
|
40
|
+
fileList: 'The full list of files.'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
onRemove: {
|
|
44
|
+
description: 'Triggered when the upload has been removed.',
|
|
45
|
+
event: {
|
|
46
|
+
file: 'The removed file.',
|
|
47
|
+
fileList: 'The full list of files.'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
onError: {
|
|
51
|
+
description: 'Triggered when the upload has failed.',
|
|
52
|
+
event: {
|
|
53
|
+
file: 'The file that failed.',
|
|
54
|
+
fileList: 'The full list of files.'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
properties: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
required: [
|
|
61
|
+
's3PostPolicyRequestId'
|
|
62
|
+
],
|
|
63
|
+
properties: {
|
|
64
|
+
title: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: "Title of the file input to be displayed instead of 'Upload image'.",
|
|
67
|
+
default: 'Upload image'
|
|
68
|
+
},
|
|
69
|
+
disabled: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
description: 'Disable the file input.'
|
|
72
|
+
},
|
|
73
|
+
maxCount: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
description: 'Maximum number of files that can be uploaded.'
|
|
76
|
+
},
|
|
77
|
+
s3PostPolicyRequestId: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
80
|
+
},
|
|
81
|
+
showUploadList: {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
default: true,
|
|
84
|
+
description: 'Whether to show default upload list.'
|
|
85
|
+
},
|
|
86
|
+
singleFile: {
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
default: false,
|
|
89
|
+
description: 'Only allow a single file to be uploaded. Only one file can be selected in the prompt.'
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
's3PostPolicyRequestId'
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
title: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: "Title of the file input to be displayed instead of 'Upload image'.",
|
|
26
|
+
default: 'Upload image'
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Disable the file input.'
|
|
31
|
+
},
|
|
32
|
+
maxCount: {
|
|
33
|
+
type: 'number',
|
|
34
|
+
description: 'Maximum number of files that can be uploaded.'
|
|
35
|
+
},
|
|
36
|
+
s3PostPolicyRequestId: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.',
|
|
39
|
+
docs: {
|
|
40
|
+
displayType: 'manual',
|
|
41
|
+
block: {
|
|
42
|
+
id: 'block_properties_s3PostPolicyRequestId',
|
|
43
|
+
layout: {
|
|
44
|
+
_global: 'settings_input_layout'
|
|
45
|
+
},
|
|
46
|
+
type: 'Label',
|
|
47
|
+
required: true,
|
|
48
|
+
properties: {
|
|
49
|
+
title: 's3PostPolicyRequestId',
|
|
50
|
+
span: 8,
|
|
51
|
+
align: 'right'
|
|
52
|
+
},
|
|
53
|
+
blocks: [
|
|
54
|
+
{
|
|
55
|
+
id: 'block_properties_s3PostPolicyRequestId_text',
|
|
56
|
+
type: 'Markdown',
|
|
57
|
+
style: {
|
|
58
|
+
color: '#8c8c8c'
|
|
59
|
+
},
|
|
60
|
+
properties: {
|
|
61
|
+
content: 'Id of a request of type AwsS3PresignedPostPolicy that defines to which S3 bucket and how the file should be uploaded.'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
getter: {}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
showUploadList: {
|
|
70
|
+
type: 'boolean',
|
|
71
|
+
default: true,
|
|
72
|
+
description: 'Whether to show default upload list.'
|
|
73
|
+
},
|
|
74
|
+
singleFile: {
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
default: false,
|
|
77
|
+
description: 'Only allow a single file to be uploaded. Only one file can be selected in the prompt.'
|
|
78
|
+
},
|
|
79
|
+
style: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
description: 'Css style object to applied to draggable area.',
|
|
82
|
+
docs: {
|
|
83
|
+
displayType: 'yaml'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
events: {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
onChange: {
|
|
92
|
+
type: 'array',
|
|
93
|
+
description: 'Triggered when the upload state is changing.'
|
|
94
|
+
},
|
|
95
|
+
onProgress: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
description: 'Triggered when the upload state is in progress.'
|
|
98
|
+
},
|
|
99
|
+
onSuccess: {
|
|
100
|
+
type: 'array',
|
|
101
|
+
description: 'Triggered when the upload state is done uploading.'
|
|
102
|
+
},
|
|
103
|
+
onRemove: {
|
|
104
|
+
type: 'array',
|
|
105
|
+
description: 'Triggered when the upload has been removed.'
|
|
106
|
+
},
|
|
107
|
+
onError: {
|
|
108
|
+
type: 'array',
|
|
109
|
+
description: 'Triggered when the upload has failed.'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
@@ -12,7 +12,8 @@
|
|
|
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
|
-
*/
|
|
15
|
+
*/ import { ServiceError } from '@lowdefy/errors';
|
|
16
|
+
const getS3Upload = ({ methods, setFileList, setLoading = ()=>null })=>async ({ file })=>{
|
|
16
17
|
if (!file) {
|
|
17
18
|
console.warn('File is undefined in useS3Upload');
|
|
18
19
|
return;
|
|
@@ -45,37 +46,47 @@
|
|
|
45
46
|
formData.append(field, fields[field]);
|
|
46
47
|
});
|
|
47
48
|
formData.append('file', file);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
await new Promise((resolve, reject)=>{
|
|
50
|
+
const xhr = new XMLHttpRequest();
|
|
51
|
+
xhr.upload.onprogress = async (event)=>{
|
|
52
|
+
if (event.lengthComputable) {
|
|
53
|
+
await setFileList({
|
|
54
|
+
event: 'onProgress',
|
|
55
|
+
file,
|
|
56
|
+
percent: event.loaded / event.total * 80 + 20
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
xhr.addEventListener('load', ()=>{
|
|
61
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
62
|
+
resolve();
|
|
63
|
+
} else {
|
|
64
|
+
reject(new Error(`S3 upload failed with status ${xhr.status}.`));
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
file
|
|
67
|
+
xhr.addEventListener('error', ()=>{
|
|
68
|
+
reject(new ServiceError(`S3 upload failed for "${name}" — CORS or network error. ` + `Check that the S3 bucket CORS configuration allows requests from this origin.`, {
|
|
69
|
+
service: 'S3'
|
|
70
|
+
}));
|
|
68
71
|
});
|
|
69
|
-
|
|
72
|
+
xhr.addEventListener('abort', ()=>{
|
|
73
|
+
reject(new Error(`S3 upload aborted for "${name}".`));
|
|
74
|
+
});
|
|
75
|
+
xhr.open('post', url);
|
|
76
|
+
xhr.send(formData);
|
|
77
|
+
});
|
|
78
|
+
await setFileList({
|
|
79
|
+
event: 'onSuccess',
|
|
80
|
+
file
|
|
70
81
|
});
|
|
71
|
-
|
|
72
|
-
xhr.send(formData);
|
|
82
|
+
setLoading(false);
|
|
73
83
|
} catch (error) {
|
|
74
|
-
console.error(error);
|
|
75
84
|
await setFileList({
|
|
76
85
|
event: 'onError',
|
|
77
86
|
file
|
|
78
87
|
});
|
|
88
|
+
setLoading(false);
|
|
89
|
+
throw error;
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
export default getS3Upload;
|
|
@@ -84,20 +84,43 @@ const useFileList = ({ properties, methods, value = {} })=>{
|
|
|
84
84
|
setValue(nextState);
|
|
85
85
|
methods.setValue(nextState);
|
|
86
86
|
};
|
|
87
|
-
const loadFileList = (file, nextFiles)=>{
|
|
87
|
+
const loadFileList = async (file, nextFiles)=>{
|
|
88
88
|
if (properties.singleFile === true && nextFiles.filter((f)=>type.isString(f.uid)).length > 1) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
if (type.isInt(properties.maxCount) && nextFiles.filter((f)=>type.isString(f.uid)).length > properties.maxCount) {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// Extract file properties into a serialization-safe plain object.
|
|
95
|
+
// Raw File/Blob objects are destroyed by serializer.copy() in _event resolution.
|
|
96
|
+
const fileData = {
|
|
97
|
+
name: file.name,
|
|
98
|
+
type: file.type,
|
|
99
|
+
size: file.size,
|
|
100
|
+
lastModified: file.lastModified,
|
|
101
|
+
uid: file.uid
|
|
102
|
+
};
|
|
103
|
+
if (file instanceof Blob || file instanceof File) {
|
|
104
|
+
fileData.url = URL.createObjectURL(file);
|
|
105
|
+
}
|
|
106
|
+
const result = await methods.triggerEvent({
|
|
107
|
+
name: 'onBeforeUpload',
|
|
108
|
+
event: {
|
|
109
|
+
file: fileData
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
if (result.success === false) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const nextState = {
|
|
116
|
+
file: fileData,
|
|
96
117
|
fileList: [
|
|
97
118
|
...nextFiles,
|
|
98
119
|
...state.fileList
|
|
99
120
|
]
|
|
100
|
-
}
|
|
121
|
+
};
|
|
122
|
+
setValue(nextState);
|
|
123
|
+
methods.setValue(nextState);
|
|
101
124
|
};
|
|
102
125
|
const removeFile = (file)=>{
|
|
103
126
|
state.fileList.splice(state.fileList.findIndex((f)=>f.uid === file.uid), 1);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 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 from 'react';
|
|
16
|
+
import { ConfigProvider } from 'antd';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
function withTheme(antdComponentName, BlockComponent) {
|
|
19
|
+
const Wrapped = (props)=>{
|
|
20
|
+
const { theme, ...restProperties } = props.properties;
|
|
21
|
+
// Only intercept object themes (design tokens for ConfigProvider).
|
|
22
|
+
// String themes (e.g. Menu's 'dark'/'light') pass through to the component.
|
|
23
|
+
if (!type.isObject(theme)) {
|
|
24
|
+
return /*#__PURE__*/ React.createElement(BlockComponent, props);
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/ React.createElement(ConfigProvider, {
|
|
27
|
+
theme: {
|
|
28
|
+
components: {
|
|
29
|
+
[antdComponentName]: theme
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/ React.createElement(BlockComponent, {
|
|
33
|
+
...props,
|
|
34
|
+
properties: restProperties
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
Wrapped.displayName = BlockComponent.displayName || BlockComponent.name;
|
|
38
|
+
return Wrapped;
|
|
39
|
+
}
|
|
40
|
+
export default withTheme;
|
|
@@ -12,26 +12,30 @@
|
|
|
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
|
|
15
|
+
*/ import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
|
|
16
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
16
17
|
import schema from './schema.js';
|
|
17
|
-
function AwsS3PresignedGetObject({ request, connection }) {
|
|
18
|
-
const { accessKeyId, secretAccessKey, region
|
|
18
|
+
async function AwsS3PresignedGetObject({ request, connection }) {
|
|
19
|
+
const { accessKeyId, secretAccessKey, region } = connection;
|
|
19
20
|
const { expires, key, versionId, responseContentDisposition, responseContentType } = request;
|
|
20
21
|
const params = {
|
|
21
|
-
Bucket: bucket,
|
|
22
|
+
Bucket: connection.bucket,
|
|
22
23
|
Key: key,
|
|
23
|
-
Expires: expires,
|
|
24
24
|
VersionId: versionId,
|
|
25
25
|
ResponseContentDisposition: responseContentDisposition,
|
|
26
26
|
ResponseContentType: responseContentType
|
|
27
27
|
};
|
|
28
|
-
const s3 = new
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const s3 = new S3Client({
|
|
29
|
+
credentials: {
|
|
30
|
+
accessKeyId,
|
|
31
|
+
secretAccessKey
|
|
32
|
+
},
|
|
33
|
+
region
|
|
34
|
+
});
|
|
35
|
+
const command = new GetObjectCommand(params);
|
|
36
|
+
return getSignedUrl(s3, command, {
|
|
37
|
+
expiresIn: expires
|
|
33
38
|
});
|
|
34
|
-
return s3.getSignedUrl('getObject', params);
|
|
35
39
|
}
|
|
36
40
|
AwsS3PresignedGetObject.schema = schema;
|
|
37
41
|
AwsS3PresignedGetObject.meta = {
|