@lowdefy/plugin-aws 4.0.0-rc.0 → 4.0.0-rc.10

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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 , name , percent , size , status , type , uid } = file;
22
- const { bucket , key } = get(s3Parameters, uid, {
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 , fileList } = changeEvent;
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 , value })=>{
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 , setS3Parameters })=>async ({ file , onError , onProgress , onSuccess })=>{
51
+ const getCustomRequest = ({ methods, setS3Parameters })=>async ({ file, onError, onProgress, onSuccess })=>{
52
52
  try {
53
- const { name , size , type , uid } = file;
53
+ const { name, size, type, uid } = file;
54
54
  const s3PostPolicyResponse = await methods.triggerEvent({
55
55
  name: '__getS3PostPolicy',
56
56
  event: {
@@ -63,9 +63,9 @@ 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 , fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
67
- const { bucket , key } = fields;
68
- const meta = {
66
+ const { url, fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
67
+ const { bucket, key } = fields;
68
+ const meta1 = {
69
69
  bucket,
70
70
  key,
71
71
  filename: name,
@@ -95,39 +95,39 @@ const getCustomRequest = ({ methods , setS3Parameters })=>async ({ file , onErr
95
95
  // file needs to be the last field in the form
96
96
  formData.append('file', file);
97
97
  const xhr = new XMLHttpRequest();
98
- xhr.upload.onprogress = (event)=>{
99
- if (event.lengthComputable) {
98
+ xhr.upload.onprogress = (event1)=>{
99
+ if (event1.lengthComputable) {
100
100
  onProgress({
101
- percent: event.loaded / event.total * 80 + 20
101
+ percent: event1.loaded / event1.total * 80 + 20
102
102
  });
103
103
  }
104
104
  };
105
- xhr.addEventListener('error', async (event)=>{
105
+ xhr.addEventListener('error', async (event1)=>{
106
106
  await methods.triggerEvent({
107
107
  name: 'onError',
108
108
  event: {
109
- meta,
110
- event
109
+ meta: meta1,
110
+ event: event1
111
111
  }
112
112
  });
113
- onError(event);
113
+ onError(event1);
114
114
  });
115
- xhr.addEventListener('load', async (event)=>{
115
+ xhr.addEventListener('load', async (event1)=>{
116
116
  await methods.triggerEvent({
117
117
  name: 'onSuccess',
118
118
  event: {
119
- meta,
120
- event
119
+ meta: meta1,
120
+ event: event1
121
121
  }
122
122
  });
123
- onSuccess(event);
123
+ onSuccess(event1);
124
124
  });
125
- xhr.addEventListener('loadend', async (event)=>{
125
+ xhr.addEventListener('loadend', async (event1)=>{
126
126
  await methods.triggerEvent({
127
127
  name: 'onDone',
128
128
  event: {
129
- meta,
130
- event
129
+ meta: meta1,
130
+ event: event1
131
131
  }
132
132
  });
133
133
  });
@@ -145,7 +145,7 @@ const getCustomRequest = ({ methods , setS3Parameters })=>async ({ file , onErr
145
145
  onError(error);
146
146
  }
147
147
  };
148
- const S3UploadButtonBlock = ({ blockId , components , events , methods , properties , value })=>{
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,
@@ -169,7 +169,7 @@ const S3UploadButtonBlock = ({ blockId , components , events , methods , propert
169
169
  params: [
170
170
  properties.s3PostPolicyRequestId
171
171
  ]
172
- },
172
+ }
173
173
  ]
174
174
  });
175
175
  }, []);
@@ -184,8 +184,8 @@ const S3UploadButtonBlock = ({ blockId , components , events , methods , propert
184
184
  id: blockId,
185
185
  multiple: !properties.singleFile,
186
186
  showUploadList: properties.showUploadList,
187
- onChange: (event)=>{
188
- methods.setValue(makeOnChangeValue(s3Parameters, event));
187
+ onChange: (event1)=>{
188
+ methods.setValue(makeOnChangeValue(s3Parameters, event1));
189
189
  methods.triggerEvent({
190
190
  name: 'onChange'
191
191
  });
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Lowdefy, Inc
1
+ # Copyright 2020-2023 Lowdefy, Inc
2
2
 
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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 { message, Upload } from 'antd';
18
+ import { Upload } from 'antd';
19
19
  const makeFileValue = (file, s3Parameters)=>{
20
- const { lastModified , name , percent , size , status , type , uid } = file;
21
- const { bucket , key } = get(s3Parameters, uid, {
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 , fileList } = changeEvent;
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 , setS3Parameters , setLoading })=>async ({ file , onError , onProgress , onSuccess })=>{
43
+ const getCustomRequest = ({ methods, setS3Parameters, setLoading })=>async ({ file, onError, onProgress, onSuccess })=>{
44
44
  try {
45
45
  setLoading(true);
46
- const { name , size , type , uid } = file;
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,9 +57,9 @@ 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 , fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
61
- const { bucket , key } = fields;
62
- const meta = {
60
+ const { url, fields } = s3PostPolicyResponse.responses.__getS3PostPolicy.response[0];
61
+ const { bucket, key } = fields;
62
+ const meta1 = {
63
63
  bucket,
64
64
  key,
65
65
  filename: name,
@@ -89,39 +89,39 @@ const getCustomRequest = ({ methods , setS3Parameters , setLoading })=>async ({
89
89
  // file needs to be the last field in the form
90
90
  formData.append('file', file);
91
91
  const xhr = new XMLHttpRequest();
92
- xhr.upload.onprogress = (event)=>{
93
- if (event.lengthComputable) {
92
+ xhr.upload.onprogress = (event1)=>{
93
+ if (event1.lengthComputable) {
94
94
  onProgress({
95
- percent: event.loaded / event.total * 80 + 20
95
+ percent: event1.loaded / event1.total * 80 + 20
96
96
  });
97
97
  }
98
98
  };
99
- xhr.addEventListener('error', async (event)=>{
99
+ xhr.addEventListener('error', async (event1)=>{
100
100
  await methods.triggerEvent({
101
101
  name: 'onError',
102
102
  event: {
103
- meta,
104
- event
103
+ meta: meta1,
104
+ event: event1
105
105
  }
106
106
  });
107
- onError(event);
107
+ onError(event1);
108
108
  });
109
- xhr.addEventListener('load', async (event)=>{
109
+ xhr.addEventListener('load', async (event1)=>{
110
110
  await methods.triggerEvent({
111
111
  name: 'onSuccess',
112
112
  event: {
113
- meta,
114
- event
113
+ meta: meta1,
114
+ event: event1
115
115
  }
116
116
  });
117
- onSuccess(event);
117
+ onSuccess(event1);
118
118
  });
119
- xhr.addEventListener('loadend', async (event)=>{
119
+ xhr.addEventListener('loadend', async (event1)=>{
120
120
  await methods.triggerEvent({
121
121
  name: 'onDone',
122
122
  event: {
123
- meta,
124
- event
123
+ meta: meta1,
124
+ event: event1
125
125
  }
126
126
  });
127
127
  setLoading(false);
@@ -140,7 +140,7 @@ const getCustomRequest = ({ methods , setS3Parameters , setLoading })=>async ({
140
140
  onError(error);
141
141
  }
142
142
  };
143
- const S3UploadPhoto = ({ blockId , components: { Icon } , events , methods , properties , value })=>{
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,
@@ -166,7 +166,7 @@ const S3UploadPhoto = ({ blockId , components: { Icon } , events , methods , pr
166
166
  params: [
167
167
  properties.s3PostPolicyRequestId
168
168
  ]
169
- },
169
+ }
170
170
  ]
171
171
  });
172
172
  }, []);
@@ -179,8 +179,8 @@ const S3UploadPhoto = ({ blockId , components: { Icon } , events , methods , pr
179
179
  id: blockId,
180
180
  multiple: !properties.singleFile,
181
181
  showUploadList: properties.showUploadList,
182
- onChange: (event)=>{
183
- methods.setValue(makeOnChangeValue(s3Parameters, event));
182
+ onChange: (event1)=>{
183
+ methods.setValue(makeOnChangeValue(s3Parameters, event1));
184
184
  methods.triggerEvent({
185
185
  name: 'onChange'
186
186
  });
@@ -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.",
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
package/dist/blocks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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 , connection }) {
18
- const { accessKeyId , secretAccessKey , region , bucket } = connection;
19
- const { expires , key , versionId , responseContentDisposition , responseContentType } = request;
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,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -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 , connection }) {
18
- const { accessKeyId , secretAccessKey , region , bucket } = connection;
19
- const { acl , conditions , expires , key } = request;
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: {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -29,7 +29,7 @@
29
29
  'aws-exec-read',
30
30
  'authenticated-read',
31
31
  'bucket-owner-read',
32
- 'bucket-owner-full-control',
32
+ 'bucket-owner-full-control'
33
33
  ],
34
34
  description: 'Access control lists used to grant read and write access.',
35
35
  errorMessage: {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
package/dist/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable import/namespace */ /*
2
- Copyright 2020-2022 Lowdefy, Inc
2
+ Copyright 2020-2023 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/plugin-aws",
3
- "version": "4.0.0-rc.0",
3
+ "version": "4.0.0-rc.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,36 +42,35 @@
42
42
  "scripts": {
43
43
  "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
44
44
  "clean": "rm -rf dist",
45
- "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\"",
46
- "prepare": "pnpm build"
45
+ "copyfiles": "copyfiles -u 1 \"./src/**/*\" dist -e \"./src/**/*.js\" -e \"./src/**/*.yaml\" -e \"./src/**/*.snap\""
47
46
  },
48
47
  "dependencies": {
49
- "@lowdefy/block-utils": "4.0.0-rc.0",
50
- "@lowdefy/blocks-antd": "4.0.0-rc.0",
51
- "@lowdefy/helpers": "4.0.0-rc.0",
48
+ "@lowdefy/block-utils": "4.0.0-rc.10",
49
+ "@lowdefy/blocks-antd": "4.0.0-rc.10",
50
+ "@lowdefy/helpers": "4.0.0-rc.10",
52
51
  "antd": "4.22.5",
53
- "aws-sdk": "2.1145.0",
52
+ "aws-sdk": "2.1286.0",
54
53
  "react": "18.2.0",
55
54
  "react-dom": "18.2.0"
56
55
  },
57
56
  "devDependencies": {
58
- "@emotion/jest": "11.9.1",
59
- "@lowdefy/ajv": "4.0.0-rc.0",
60
- "@lowdefy/block-dev": "4.0.0-rc.0",
61
- "@lowdefy/jest-yaml-transform": "4.0.0-rc.0",
62
- "@swc/cli": "0.1.57",
63
- "@swc/core": "1.2.194",
64
- "@swc/jest": "0.2.21",
65
- "@testing-library/dom": "8.13.0",
66
- "@testing-library/react": "13.3.0",
67
- "@testing-library/user-event": "14.2.0",
57
+ "@emotion/jest": "11.10.5",
58
+ "@lowdefy/ajv": "4.0.0-rc.10",
59
+ "@lowdefy/block-dev": "4.0.0-rc.10",
60
+ "@lowdefy/jest-yaml-transform": "4.0.0-rc.10",
61
+ "@swc/cli": "0.1.62",
62
+ "@swc/core": "1.3.70",
63
+ "@swc/jest": "0.2.27",
64
+ "@testing-library/dom": "8.19.1",
65
+ "@testing-library/react": "13.4.0",
66
+ "@testing-library/user-event": "14.4.3",
68
67
  "copyfiles": "2.4.1",
69
- "jest": "28.1.0",
70
- "jest-environment-jsdom": "28.1.0",
68
+ "jest": "28.1.3",
69
+ "jest-environment-jsdom": "28.1.3",
71
70
  "jest-serializer-html": "7.1.0"
72
71
  },
73
72
  "publishConfig": {
74
73
  "access": "public"
75
74
  },
76
- "gitHead": "f6872d7ff6da421710096536fce7b2016ef8f35c"
75
+ "gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
77
76
  }