@lowdefy/plugin-aws 0.0.0-experimental-20261007124348 → 0.0.0-experimental-20261009073700

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.
@@ -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
- */ import AwsS3GetObject from './AwsS3GetObject/AwsS3GetObject.js';
15
+ */ import AwsS3DeleteObject from './AwsS3DeleteObject/AwsS3DeleteObject.js';
16
+ import AwsS3GetObject from './AwsS3GetObject/AwsS3GetObject.js';
16
17
  import AwsS3HeadObject from './AwsS3HeadObject/AwsS3HeadObject.js';
17
18
  import AwsS3PresignedGetObject from './AwsS3PresignedGetObject/AwsS3PresignedGetObject.js';
18
19
  import AwsS3PresignedPostPolicy from './AwsS3PresignedPostPolicy/AwsS3PresignedPostPolicy.js';
@@ -21,6 +22,7 @@ import schema from './schema.js';
21
22
  export default {
22
23
  schema,
23
24
  requests: {
25
+ AwsS3DeleteObject,
24
26
  AwsS3GetObject,
25
27
  AwsS3HeadObject,
26
28
  AwsS3PresignedGetObject,
@@ -0,0 +1,65 @@
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 { DeleteObjectCommand, DeleteObjectsCommand } from '@aws-sdk/client-s3';
16
+ import { type } from '@lowdefy/helpers';
17
+ import createS3Client from '../createS3Client.js';
18
+ import schema from './schema.js';
19
+ // Deletes only from the connection's bucket. S3 answers a delete of a key that does not exist as
20
+ // a success, so such a key is returned as deleted. With several keys, S3 reports each key it could
21
+ // not delete in the response instead of failing the call, so those come back as errors.
22
+ async function AwsS3DeleteObject({ request, connection }) {
23
+ const { bucket } = connection;
24
+ const { key, keys } = request;
25
+ const s3 = createS3Client({
26
+ connection
27
+ });
28
+ if (!type.isNone(key)) {
29
+ await s3.send(new DeleteObjectCommand({
30
+ Bucket: bucket,
31
+ Key: key
32
+ }));
33
+ return {
34
+ bucket,
35
+ deleted: [
36
+ key
37
+ ],
38
+ errors: []
39
+ };
40
+ }
41
+ const response = await s3.send(new DeleteObjectsCommand({
42
+ Bucket: bucket,
43
+ Delete: {
44
+ Objects: keys.map((objectKey)=>({
45
+ Key: objectKey
46
+ })),
47
+ Quiet: false
48
+ }
49
+ }));
50
+ return {
51
+ bucket,
52
+ deleted: (response.Deleted ?? []).map((deleted)=>deleted.Key),
53
+ errors: (response.Errors ?? []).map((error)=>({
54
+ key: error.Key,
55
+ code: error.Code,
56
+ message: error.Message
57
+ }))
58
+ };
59
+ }
60
+ AwsS3DeleteObject.schema = schema;
61
+ AwsS3DeleteObject.meta = {
62
+ checkRead: false,
63
+ checkWrite: true
64
+ };
65
+ export default AwsS3DeleteObject;
@@ -0,0 +1,86 @@
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
+ $schema: 'http://json-schema.org/draft-07/schema#',
17
+ title: 'Lowdefy Request Schema - AwsS3DeleteObject',
18
+ type: 'object',
19
+ // An empty key makes the SDK send DELETE to the bucket itself, which S3 reads as DeleteBucket.
20
+ properties: {
21
+ key: {
22
+ type: 'string',
23
+ minLength: 1,
24
+ description: 'Key of the object to delete. Give either key or keys.',
25
+ errorMessage: {
26
+ type: 'AwsS3DeleteObject request property "key" should be a string.',
27
+ minLength: 'AwsS3DeleteObject request property "key" should not be empty.'
28
+ }
29
+ },
30
+ keys: {
31
+ type: 'array',
32
+ minItems: 1,
33
+ maxItems: 1000,
34
+ items: {
35
+ type: 'string',
36
+ minLength: 1,
37
+ errorMessage: {
38
+ type: 'AwsS3DeleteObject request property "keys" should be an array of strings.',
39
+ minLength: 'AwsS3DeleteObject request property "keys" should not hold an empty key.'
40
+ }
41
+ },
42
+ description: 'Keys of the objects to delete, 1 to 1000. Give either key or keys.',
43
+ errorMessage: {
44
+ type: 'AwsS3DeleteObject request property "keys" should be an array of strings.',
45
+ minItems: 'AwsS3DeleteObject request property "keys" should have at least 1 key.',
46
+ maxItems: 'AwsS3DeleteObject request property "keys" should have at most 1000 keys.'
47
+ }
48
+ }
49
+ },
50
+ // The bucket always comes from the connection, so a stray "bucket" is refused rather than
51
+ // ignored: ignoring it would delete the same key in the connection's bucket.
52
+ additionalProperties: false,
53
+ if: {
54
+ type: 'object'
55
+ },
56
+ then: {
57
+ oneOf: [
58
+ {
59
+ required: [
60
+ 'key'
61
+ ],
62
+ not: {
63
+ required: [
64
+ 'keys'
65
+ ]
66
+ }
67
+ },
68
+ {
69
+ required: [
70
+ 'keys'
71
+ ],
72
+ not: {
73
+ required: [
74
+ 'key'
75
+ ]
76
+ }
77
+ }
78
+ ]
79
+ },
80
+ errorMessage: {
81
+ type: 'AwsS3DeleteObject request properties should be an object.',
82
+ additionalProperties: 'AwsS3DeleteObject request should only have "key" or "keys".',
83
+ // The `then` above is the only check without a message of its own.
84
+ _: 'AwsS3DeleteObject request should have either "key" or "keys", not both.'
85
+ }
86
+ };
package/dist/types.js CHANGED
@@ -27,6 +27,7 @@ export default {
27
27
  }
28
28
  },
29
29
  requests: [
30
+ 'AwsS3DeleteObject',
30
31
  'AwsS3GetObject',
31
32
  'AwsS3HeadObject',
32
33
  'AwsS3PresignedGetObject',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/plugin-aws",
3
- "version": "0.0.0-experimental-20261007124348",
3
+ "version": "0.0.0-experimental-20261009073700",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -50,12 +50,12 @@
50
50
  "dist/*"
51
51
  ],
52
52
  "dependencies": {
53
- "@lowdefy/block-utils": "0.0.0-experimental-20261007124348",
54
- "@lowdefy/blocks-antd": "0.0.0-experimental-20261007124348",
55
- "@lowdefy/blocks-files": "0.0.0-experimental-20261007124348",
56
- "@lowdefy/errors": "0.0.0-experimental-20261007124348",
57
- "@lowdefy/helpers": "0.0.0-experimental-20261007124348",
58
- "@lowdefy/node-utils": "0.0.0-experimental-20261007124348",
53
+ "@lowdefy/block-utils": "0.0.0-experimental-20261009073700",
54
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20261009073700",
55
+ "@lowdefy/blocks-files": "0.0.0-experimental-20261009073700",
56
+ "@lowdefy/errors": "0.0.0-experimental-20261009073700",
57
+ "@lowdefy/helpers": "0.0.0-experimental-20261009073700",
58
+ "@lowdefy/node-utils": "0.0.0-experimental-20261009073700",
59
59
  "@aws-sdk/client-s3": "3.1141.0",
60
60
  "@aws-sdk/s3-presigned-post": "3.1141.0",
61
61
  "@aws-sdk/s3-request-presigner": "3.1141.0",
@@ -68,9 +68,9 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@jest/globals": "28.1.3",
71
- "@lowdefy/ajv": "0.0.0-experimental-20261007124348",
72
- "@lowdefy/block-dev": "0.0.0-experimental-20261007124348",
73
- "@lowdefy/jest-yaml-transform": "0.0.0-experimental-20261007124348",
71
+ "@lowdefy/ajv": "0.0.0-experimental-20261009073700",
72
+ "@lowdefy/block-dev": "0.0.0-experimental-20261009073700",
73
+ "@lowdefy/jest-yaml-transform": "0.0.0-experimental-20261009073700",
74
74
  "@swc/cli": "0.8.1",
75
75
  "@swc/core": "1.15.32",
76
76
  "@swc/jest": "0.2.39",