@lafken/bucket 0.13.2 → 0.13.4
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.
|
@@ -37,10 +37,9 @@ const createRepository = (bucket) => {
|
|
|
37
37
|
return bucketClient.send(command);
|
|
38
38
|
},
|
|
39
39
|
async moveObject(props) {
|
|
40
|
+
const source = (0, repository_utils_1.parseCopySource)(props.CopySource);
|
|
40
41
|
await this.copyObject(props);
|
|
41
|
-
await
|
|
42
|
-
Key: props.Key,
|
|
43
|
-
});
|
|
42
|
+
await bucketClient.send(new client_s3_1.DeleteObjectCommand(source));
|
|
44
43
|
},
|
|
45
44
|
async listObjects(props) {
|
|
46
45
|
let allContents = [];
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { ClassResource } from '@lafken/common';
|
|
2
2
|
export declare const getBucketInformation: <T>(bucket: ClassResource) => T;
|
|
3
|
+
/**
|
|
4
|
+
* Splits a CopySource value (`/sourceBucket/sourceKey?versionId=id`) into the
|
|
5
|
+
* bucket, key and version of the object being copied. The key is URL decoded,
|
|
6
|
+
* as required by the S3 CopyObject API.
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseCopySource: (copySource: string | undefined) => {
|
|
9
|
+
Bucket: string;
|
|
10
|
+
Key: string;
|
|
11
|
+
VersionId: string | undefined;
|
|
12
|
+
};
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBucketInformation = void 0;
|
|
3
|
+
exports.parseCopySource = exports.getBucketInformation = void 0;
|
|
4
4
|
const bucket_1 = require("../../main/bucket");
|
|
5
5
|
const getBucketInformation = (bucket) => {
|
|
6
6
|
const bucketProps = Reflect.getMetadata(bucket_1.BucketMetadataKeys.bucket, bucket);
|
|
7
7
|
return bucketProps;
|
|
8
8
|
};
|
|
9
9
|
exports.getBucketInformation = getBucketInformation;
|
|
10
|
+
/**
|
|
11
|
+
* Splits a CopySource value (`/sourceBucket/sourceKey?versionId=id`) into the
|
|
12
|
+
* bucket, key and version of the object being copied. The key is URL decoded,
|
|
13
|
+
* as required by the S3 CopyObject API.
|
|
14
|
+
*/
|
|
15
|
+
const parseCopySource = (copySource) => {
|
|
16
|
+
const [source, query] = (copySource || '').replace(/^\//, '').split('?');
|
|
17
|
+
const separatorIndex = source.indexOf('/');
|
|
18
|
+
if (separatorIndex < 1 || separatorIndex === source.length - 1) {
|
|
19
|
+
throw new Error(`Invalid CopySource "${copySource}", expected format "sourceBucket/sourceKey"`);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
Bucket: source.slice(0, separatorIndex),
|
|
23
|
+
Key: decodeURIComponent(source.slice(separatorIndex + 1)),
|
|
24
|
+
VersionId: query
|
|
25
|
+
? new URLSearchParams(query).get('versionId') || undefined
|
|
26
|
+
: undefined,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.parseCopySource = parseCopySource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/bucket",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Define S3 buckets using TypeScript decorators - automatic infrastructure generation with Lafken",
|
|
6
6
|
"keywords": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"reflect-metadata": "^0.2.2",
|
|
60
|
-
"@lafken/resolver": "0.13.
|
|
60
|
+
"@lafken/resolver": "0.13.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@aws-sdk/client-s3": "^3.1090.0",
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
"typescript": "7.0.2",
|
|
72
72
|
"unplugin-swc": "^1.5.9",
|
|
73
73
|
"vitest": "^4.1.10",
|
|
74
|
-
"@lafken/common": "0.13.
|
|
74
|
+
"@lafken/common": "0.13.4"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@cdktn/provider-aws": ">=23.0.0",
|
|
78
78
|
"cdktn": ">=0.22.0",
|
|
79
79
|
"constructs": "^10.4.5",
|
|
80
|
-
"@lafken/common": "0.13.
|
|
80
|
+
"@lafken/common": "0.13.4"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=20.19"
|