@aws-amplify/storage 6.11.2-unstable.a361dd1.0 → 6.11.2-unstable.b6d4c7a.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/cjs/internals/apis/remove.js +13 -12
- package/dist/cjs/internals/apis/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/internal/remove.js +53 -29
- package/dist/cjs/providers/s3/apis/internal/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/remove.js +6 -1
- package/dist/cjs/providers/s3/apis/remove.js.map +1 -1
- package/dist/cjs/providers/s3/apis/server/remove.js +6 -1
- package/dist/cjs/providers/s3/apis/server/remove.js.map +1 -1
- package/dist/cjs/providers/s3/utils/client/s3data/deleteObjects.js +70 -0
- package/dist/cjs/providers/s3/utils/client/s3data/deleteObjects.js.map +1 -0
- package/dist/cjs/providers/s3/utils/client/s3data/index.js +3 -1
- package/dist/cjs/providers/s3/utils/client/s3data/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/createAbortableTask.js +35 -0
- package/dist/cjs/providers/s3/utils/createAbortableTask.js.map +1 -0
- package/dist/cjs/providers/s3/utils/deleteFolderContents.js +80 -0
- package/dist/cjs/providers/s3/utils/deleteFolderContents.js.map +1 -0
- package/dist/cjs/providers/s3/utils/generateDeleteObjectsXml.js +38 -0
- package/dist/cjs/providers/s3/utils/generateDeleteObjectsXml.js.map +1 -0
- package/dist/cjs/providers/s3/utils/index.js +13 -1
- package/dist/cjs/providers/s3/utils/index.js.map +1 -1
- package/dist/cjs/providers/s3/utils/isPathFolder.js +38 -0
- package/dist/cjs/providers/s3/utils/isPathFolder.js.map +1 -0
- package/dist/cjs/providers/s3/utils/resolveFinalKey.js +22 -0
- package/dist/cjs/providers/s3/utils/resolveFinalKey.js.map +1 -0
- package/dist/cjs/providers/s3/utils/validateRemovePath.js +21 -0
- package/dist/cjs/providers/s3/utils/validateRemovePath.js.map +1 -0
- package/dist/esm/internals/apis/remove.d.ts +2 -1
- package/dist/esm/internals/apis/remove.mjs +13 -12
- package/dist/esm/internals/apis/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/copy.mjs +8 -7
- package/dist/esm/providers/s3/apis/internal/copy.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/downloadData.d.ts +1 -1
- package/dist/esm/providers/s3/apis/internal/downloadData.mjs +6 -5
- package/dist/esm/providers/s3/apis/internal/downloadData.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs +7 -6
- package/dist/esm/providers/s3/apis/internal/getProperties.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs +2 -1
- package/dist/esm/providers/s3/apis/internal/getUrl.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/list.mjs +8 -7
- package/dist/esm/providers/s3/apis/internal/list.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/remove.d.ts +3 -2
- package/dist/esm/providers/s3/apis/internal/remove.mjs +58 -27
- package/dist/esm/providers/s3/apis/internal/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs +13 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/index.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/initialUpload.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/initialUpload.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadCache.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadCache.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.mjs +6 -5
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadHandlers.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.mjs +1 -0
- package/dist/esm/providers/s3/apis/internal/uploadData/multipart/uploadPartExecutor.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.mjs +7 -6
- package/dist/esm/providers/s3/apis/internal/uploadData/putObjectJob.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/remove.d.ts +6 -6
- package/dist/esm/providers/s3/apis/remove.mjs +6 -1
- package/dist/esm/providers/s3/apis/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/apis/server/remove.d.ts +6 -6
- package/dist/esm/providers/s3/apis/server/remove.mjs +6 -1
- package/dist/esm/providers/s3/apis/server/remove.mjs.map +1 -1
- package/dist/esm/providers/s3/types/index.d.ts +1 -1
- package/dist/esm/providers/s3/types/inputs.d.ts +24 -1
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.d.ts +30 -0
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.mjs +74 -0
- package/dist/esm/providers/s3/utils/client/s3data/deleteObjects.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.d.ts +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.mjs +1 -0
- package/dist/esm/providers/s3/utils/client/s3data/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/client/s3data/types.d.ts +26 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.d.ts +6 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.mjs +33 -0
- package/dist/esm/providers/s3/utils/createAbortableTask.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.d.ts +16 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.mjs +90 -0
- package/dist/esm/providers/s3/utils/deleteFolderContents.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.d.ts +10 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.mjs +35 -0
- package/dist/esm/providers/s3/utils/generateDeleteObjectsXml.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/index.d.ts +6 -0
- package/dist/esm/providers/s3/utils/index.mjs +6 -0
- package/dist/esm/providers/s3/utils/index.mjs.map +1 -1
- package/dist/esm/providers/s3/utils/isPathFolder.d.ts +13 -0
- package/dist/esm/providers/s3/utils/isPathFolder.mjs +48 -0
- package/dist/esm/providers/s3/utils/isPathFolder.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.d.ts +9 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.mjs +20 -0
- package/dist/esm/providers/s3/utils/resolveFinalKey.mjs.map +1 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.d.ts +8 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.mjs +18 -0
- package/dist/esm/providers/s3/utils/validateRemovePath.mjs.map +1 -0
- package/dist/esm/types/common.d.ts +3 -0
- package/package.json +5 -5
- package/src/internals/apis/remove.ts +17 -10
- package/src/providers/s3/apis/internal/remove.ts +96 -41
- package/src/providers/s3/apis/remove.ts +11 -6
- package/src/providers/s3/apis/server/remove.ts +11 -6
- package/src/providers/s3/types/index.ts +2 -0
- package/src/providers/s3/types/inputs.ts +24 -1
- package/src/providers/s3/utils/client/s3data/deleteObjects.ts +122 -0
- package/src/providers/s3/utils/client/s3data/index.ts +5 -0
- package/src/providers/s3/utils/client/s3data/types.ts +20 -0
- package/src/providers/s3/utils/createAbortableTask.ts +45 -0
- package/src/providers/s3/utils/deleteFolderContents.ts +118 -0
- package/src/providers/s3/utils/generateDeleteObjectsXml.ts +38 -0
- package/src/providers/s3/utils/index.ts +6 -0
- package/src/providers/s3/utils/isPathFolder.ts +50 -0
- package/src/providers/s3/utils/resolveFinalKey.ts +22 -0
- package/src/providers/s3/utils/validateRemovePath.ts +16 -0
- package/src/types/common.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove.mjs","sources":["../../../../../../src/providers/s3/apis/server/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { remove as removeInternal } from '../internal/remove';\nexport function remove(contextSpec, input) {\n return removeInternal(getAmplifyServerContext(contextSpec).amplify, input);\n}\n"],"names":["removeInternal"],"mappings":";;;AAAA;AACA;AAGO,SAAS,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE;AAC3C,IAAI,OAAOA,QAAc,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"remove.mjs","sources":["../../../../../../src/providers/s3/apis/server/remove.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { remove as removeInternal } from '../internal/remove';\nexport function remove(contextSpec, input) {\n if ('key' in input) {\n return removeInternal(getAmplifyServerContext(contextSpec).amplify, input);\n }\n else {\n return removeInternal(getAmplifyServerContext(contextSpec).amplify, input);\n }\n}\n"],"names":["removeInternal"],"mappings":";;;AAAA;AACA;AAGO,SAAS,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE;AAC3C,IAAI,IAAI,KAAK,IAAI,KAAK,EAAE;AACxB,QAAQ,OAAOA,QAAc,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;AAClF,IAAI;AACJ,SAAS;AACT,QAAQ,OAAOA,QAAc,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;AAClF,IAAI;AACJ;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { GetUrlWithKeyOptions, GetUrlWithPathOptions, UploadDataWithPathOptions, UploadDataWithKeyOptions, GetPropertiesWithKeyOptions, GetPropertiesWithPathOptions, ListAllWithPrefixOptions, ListPaginateWithPrefixOptions, ListAllWithPathOptions, ListPaginateWithPathOptions, RemoveOptions, DownloadDataWithPathOptions, DownloadDataWithKeyOptions, CopyDestinationWithKeyOptions, CopySourceWithKeyOptions, } from './options';
|
|
2
2
|
export { UploadDataOutput, UploadDataWithPathOutput, DownloadDataOutput, DownloadDataWithPathOutput, RemoveOutput, RemoveWithPathOutput, ListAllOutput, ListAllWithPathOutput, ListPaginateOutput, ListPaginateWithPathOutput, GetPropertiesOutput, GetPropertiesWithPathOutput, CopyOutput, CopyWithPathOutput, GetUrlOutput, GetUrlWithPathOutput, ListOutputItem, ListOutputItemWithPath, } from './outputs';
|
|
3
|
-
export { CopyInput, CopyWithPathInput, GetPropertiesInput, GetPropertiesWithPathInput, GetUrlInput, GetUrlWithPathInput, RemoveWithPathInput, RemoveInput, DownloadDataInput, DownloadDataWithPathInput, UploadDataInput, UploadDataWithPathInput, ListAllInput, ListPaginateInput, ListAllWithPathInput, ListPaginateWithPathInput, } from './inputs';
|
|
3
|
+
export { CopyInput, CopyWithPathInput, GetPropertiesInput, GetPropertiesWithPathInput, GetUrlInput, GetUrlWithPathInput, RemoveWithPathInput, RemoveInput, RemoveOperation, ProgressInfo, DownloadDataInput, DownloadDataWithPathInput, UploadDataInput, UploadDataWithPathInput, ListAllInput, ListPaginateInput, ListAllWithPathInput, ListPaginateWithPathInput, } from './inputs';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StorageCopyInputWithKey, StorageCopyInputWithPath, StorageDownloadDataInputWithKey, StorageDownloadDataInputWithPath, StorageGetPropertiesInputWithKey, StorageGetPropertiesInputWithPath, StorageGetUrlInputWithKey, StorageGetUrlInputWithPath, StorageListInputWithPath, StorageListInputWithPrefix, StorageRemoveInputWithKey, StorageRemoveInputWithPath, StorageUploadDataInputWithKey, StorageUploadDataInputWithPath } from '../../../types';
|
|
2
|
+
import { NonPausableTransferTask } from '../../../types/common';
|
|
2
3
|
import { CopyDestinationWithKeyOptions, CopySourceWithKeyOptions, DownloadDataWithKeyOptions, DownloadDataWithPathOptions, GetPropertiesWithKeyOptions, GetPropertiesWithPathOptions, GetUrlWithKeyOptions, GetUrlWithPathOptions, ListAllWithPathOptions, ListAllWithPrefixOptions, ListPaginateWithPathOptions, ListPaginateWithPrefixOptions, RemoveOptions, UploadDataWithKeyOptions, UploadDataWithPathOptions } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* @deprecated Use {@link CopyWithPathInput} instead.
|
|
@@ -53,7 +54,29 @@ export type RemoveInput = StorageRemoveInputWithKey<RemoveOptions>;
|
|
|
53
54
|
/**
|
|
54
55
|
* Input type with path for S3 remove API.
|
|
55
56
|
*/
|
|
56
|
-
export type RemoveWithPathInput = StorageRemoveInputWithPath<Omit<RemoveOptions, 'accessLevel'
|
|
57
|
+
export type RemoveWithPathInput = StorageRemoveInputWithPath<Omit<RemoveOptions, 'accessLevel'> & {
|
|
58
|
+
/** Callback function invoked after each batch completes, providing progress updates with file counts and error details. */
|
|
59
|
+
onProgress?(progress: ProgressInfo): void;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Represents an ongoing remove operation with cancellation and state tracking capabilities
|
|
63
|
+
* @template T - The type of the result (RemoveWithPathOutput | RemoveOutput)
|
|
64
|
+
*/
|
|
65
|
+
export interface RemoveOperation<T> extends NonPausableTransferTask<T> {
|
|
66
|
+
then: Promise<T>['then'];
|
|
67
|
+
catch: Promise<T>['catch'];
|
|
68
|
+
finally: Promise<T>['finally'];
|
|
69
|
+
}
|
|
70
|
+
export interface ProgressInfo {
|
|
71
|
+
deleted?: {
|
|
72
|
+
path: string;
|
|
73
|
+
}[];
|
|
74
|
+
failed?: {
|
|
75
|
+
path: string;
|
|
76
|
+
code: string;
|
|
77
|
+
message: string;
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
57
80
|
/**
|
|
58
81
|
* @deprecated Use {@link DownloadDataWithPathInput} instead.
|
|
59
82
|
* Input type for S3 downloadData API.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Endpoint, HttpResponse } from '@aws-amplify/core/internals/aws-client-utils';
|
|
2
|
+
import type { DeleteObjectsCommandInput, DeleteObjectsCommandOutput } from './types';
|
|
3
|
+
export type DeleteObjectsInput = Pick<DeleteObjectsCommandInput, 'Bucket' | 'Delete' | 'ExpectedBucketOwner'> & {
|
|
4
|
+
ContentMD5?: string;
|
|
5
|
+
};
|
|
6
|
+
export type DeleteObjectsOutput = DeleteObjectsCommandOutput;
|
|
7
|
+
export declare const deleteObjects: (config: {
|
|
8
|
+
responseType?: "blob" | "text" | undefined;
|
|
9
|
+
service?: string | undefined;
|
|
10
|
+
endpointResolver?: (((options: import("@aws-amplify/core/internals/aws-client-utils").EndpointResolverOptions, input?: any) => Endpoint) & ((options: import("./base").S3EndpointResolverOptions, apiInput?: {
|
|
11
|
+
Bucket?: string;
|
|
12
|
+
}) => {
|
|
13
|
+
url: URL;
|
|
14
|
+
})) | undefined;
|
|
15
|
+
retryDecider?: (((response?: HttpResponse | undefined, error?: unknown, middlewareContext?: import("@aws-amplify/core/internals/aws-client-utils").MiddlewareContext) => Promise<import("@aws-amplify/core/internals/aws-client-utils").RetryDeciderOutput>) & import("../utils/createRetryDecider").RetryDecider) | undefined;
|
|
16
|
+
computeDelay?: ((attempt: number) => number) | undefined;
|
|
17
|
+
userAgentValue?: string | undefined;
|
|
18
|
+
useAccelerateEndpoint?: boolean | undefined;
|
|
19
|
+
uriEscapePath?: boolean | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
credentials: import("@aws-amplify/core/internals/aws-client-utils").Credentials | ((options?: import("@aws-amplify/core/internals/aws-client-utils").CredentialsProviderOptions) => Promise<import("@aws-amplify/core/internals/aws-client-utils").Credentials>);
|
|
22
|
+
region: string;
|
|
23
|
+
onDownloadProgress?: ((event: import("../../../../..").TransferProgressEvent) => void) | undefined;
|
|
24
|
+
onUploadProgress?: ((event: import("../../../../..").TransferProgressEvent) => void) | undefined;
|
|
25
|
+
abortSignal?: AbortSignal | undefined;
|
|
26
|
+
maxAttempts?: number | undefined;
|
|
27
|
+
customEndpoint?: string | undefined;
|
|
28
|
+
forcePathStyle?: boolean | undefined;
|
|
29
|
+
userAgentHeader?: string | undefined;
|
|
30
|
+
}, input: DeleteObjectsInput) => Promise<DeleteObjectsCommandOutput>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { parseMetadata } from '@aws-amplify/core/internals/aws-client-utils';
|
|
2
|
+
import { AmplifyUrl, AmplifyUrlSearchParams } from '@aws-amplify/core/internals/utils';
|
|
3
|
+
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
|
|
4
|
+
import { s3TransferHandler } from '../runtime/s3TransferHandler/fetch.mjs';
|
|
5
|
+
import 'fast-xml-parser';
|
|
6
|
+
import '../runtime/s3TransferHandler/xhr.mjs';
|
|
7
|
+
import 'buffer';
|
|
8
|
+
import { buildStorageServiceError } from '../utils/deserializeHelpers.mjs';
|
|
9
|
+
import { validateS3RequiredParameter, assignStringVariables } from '../utils/serializeHelpers.mjs';
|
|
10
|
+
import { generateDeleteObjectsXml } from '../../generateDeleteObjectsXml.mjs';
|
|
11
|
+
import { calculateContentMd5 } from '../../md5.mjs';
|
|
12
|
+
import { defaultConfig, parseXmlError } from './base.mjs';
|
|
13
|
+
|
|
14
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
const deleteObjectsSerializer = async (input, endpoint) => {
|
|
17
|
+
const url = new AmplifyUrl(endpoint.url.toString());
|
|
18
|
+
validateS3RequiredParameter(!!input.Delete, 'Delete');
|
|
19
|
+
url.pathname = '/';
|
|
20
|
+
url.search = new AmplifyUrlSearchParams({
|
|
21
|
+
delete: '',
|
|
22
|
+
}).toString();
|
|
23
|
+
const body = generateDeleteObjectsXml(input.Delete.Objects, input.Delete.Quiet ?? false);
|
|
24
|
+
const contentMd5 = input.ContentMD5 ?? (await calculateContentMd5(body));
|
|
25
|
+
const headers = assignStringVariables({
|
|
26
|
+
'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,
|
|
27
|
+
'content-type': 'application/xml',
|
|
28
|
+
'content-md5': contentMd5,
|
|
29
|
+
});
|
|
30
|
+
const request = {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers,
|
|
33
|
+
url,
|
|
34
|
+
body,
|
|
35
|
+
};
|
|
36
|
+
return request;
|
|
37
|
+
};
|
|
38
|
+
const deleteObjectsDeserializer = async (response) => {
|
|
39
|
+
if (response.statusCode >= 300) {
|
|
40
|
+
const error = await parseXmlError(response);
|
|
41
|
+
throw buildStorageServiceError(error);
|
|
42
|
+
}
|
|
43
|
+
const text = await response.body.text();
|
|
44
|
+
const deleted = [];
|
|
45
|
+
const errors = [];
|
|
46
|
+
const deletedMatches = text.matchAll(/<Deleted>[\s\S]*?<\/Deleted>/g);
|
|
47
|
+
for (const match of deletedMatches) {
|
|
48
|
+
const keyMatch = match[0].match(/<Key>(.*?)<\/Key>/);
|
|
49
|
+
if (keyMatch) {
|
|
50
|
+
deleted.push({ Key: keyMatch[1] });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const errorMatches = text.matchAll(/<Error>[\s\S]*?<\/Error>/g);
|
|
54
|
+
for (const match of errorMatches) {
|
|
55
|
+
const keyMatch = match[0].match(/<Key>(.*?)<\/Key>/);
|
|
56
|
+
const codeMatch = match[0].match(/<Code>(.*?)<\/Code>/);
|
|
57
|
+
const messageMatch = match[0].match(/<Message>(.*?)<\/Message>/);
|
|
58
|
+
errors.push({
|
|
59
|
+
Key: keyMatch?.[1],
|
|
60
|
+
Code: codeMatch?.[1],
|
|
61
|
+
Message: messageMatch?.[1],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const result = {
|
|
65
|
+
Deleted: deleted,
|
|
66
|
+
Errors: errors,
|
|
67
|
+
$metadata: parseMetadata(response),
|
|
68
|
+
};
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
const deleteObjects = composeServiceApi(s3TransferHandler, deleteObjectsSerializer, deleteObjectsDeserializer, { ...defaultConfig, responseType: 'text' });
|
|
72
|
+
|
|
73
|
+
export { deleteObjects };
|
|
74
|
+
//# sourceMappingURL=deleteObjects.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteObjects.mjs","sources":["../../../../../../../src/providers/s3/utils/client/s3data/deleteObjects.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { parseMetadata, } from '@aws-amplify/core/internals/aws-client-utils';\nimport { AmplifyUrl, AmplifyUrlSearchParams, } from '@aws-amplify/core/internals/utils';\nimport { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';\nimport { assignStringVariables, buildStorageServiceError, s3TransferHandler, validateS3RequiredParameter, } from '../utils';\nimport { generateDeleteObjectsXml } from '../../generateDeleteObjectsXml';\nimport { calculateContentMd5 } from '../../md5';\nimport { defaultConfig, parseXmlError } from './base';\nconst deleteObjectsSerializer = async (input, endpoint) => {\n const url = new AmplifyUrl(endpoint.url.toString());\n validateS3RequiredParameter(!!input.Delete, 'Delete');\n url.pathname = '/';\n url.search = new AmplifyUrlSearchParams({\n delete: '',\n }).toString();\n const body = generateDeleteObjectsXml(input.Delete.Objects, input.Delete.Quiet ?? false);\n const contentMd5 = input.ContentMD5 ?? (await calculateContentMd5(body));\n const headers = assignStringVariables({\n 'x-amz-expected-bucket-owner': input.ExpectedBucketOwner,\n 'content-type': 'application/xml',\n 'content-md5': contentMd5,\n });\n const request = {\n method: 'POST',\n headers,\n url,\n body,\n };\n return request;\n};\nconst deleteObjectsDeserializer = async (response) => {\n if (response.statusCode >= 300) {\n const error = await parseXmlError(response);\n throw buildStorageServiceError(error);\n }\n const text = await response.body.text();\n const deleted = [];\n const errors = [];\n const deletedMatches = text.matchAll(/<Deleted>[\\s\\S]*?<\\/Deleted>/g);\n for (const match of deletedMatches) {\n const keyMatch = match[0].match(/<Key>(.*?)<\\/Key>/);\n if (keyMatch) {\n deleted.push({ Key: keyMatch[1] });\n }\n }\n const errorMatches = text.matchAll(/<Error>[\\s\\S]*?<\\/Error>/g);\n for (const match of errorMatches) {\n const keyMatch = match[0].match(/<Key>(.*?)<\\/Key>/);\n const codeMatch = match[0].match(/<Code>(.*?)<\\/Code>/);\n const messageMatch = match[0].match(/<Message>(.*?)<\\/Message>/);\n errors.push({\n Key: keyMatch?.[1],\n Code: codeMatch?.[1],\n Message: messageMatch?.[1],\n });\n }\n const result = {\n Deleted: deleted,\n Errors: errors,\n $metadata: parseMetadata(response),\n };\n return result;\n};\nexport const deleteObjects = composeServiceApi(s3TransferHandler, deleteObjectsSerializer, deleteObjectsDeserializer, { ...defaultConfig, responseType: 'text' });\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,uBAAuB,GAAG,OAAO,KAAK,EAAE,QAAQ,KAAK;AAC3D,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACvD,IAAI,2BAA2B,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC;AACzD,IAAI,GAAG,CAAC,QAAQ,GAAG,GAAG;AACtB,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,sBAAsB,CAAC;AAC5C,QAAQ,MAAM,EAAE,EAAE;AAClB,KAAK,CAAC,CAAC,QAAQ,EAAE;AACjB,IAAI,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;AAC5F,IAAI,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,KAAK,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC5E,IAAI,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAC1C,QAAQ,6BAA6B,EAAE,KAAK,CAAC,mBAAmB;AAChE,QAAQ,cAAc,EAAE,iBAAiB;AACzC,QAAQ,aAAa,EAAE,UAAU;AACjC,KAAK,CAAC;AACN,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,OAAO;AACf,QAAQ,GAAG;AACX,QAAQ,IAAI;AACZ,KAAK;AACL,IAAI,OAAO,OAAO;AAClB,CAAC;AACD,MAAM,yBAAyB,GAAG,OAAO,QAAQ,KAAK;AACtD,IAAI,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;AACpC,QAAQ,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC;AACnD,QAAQ,MAAM,wBAAwB,CAAC,KAAK,CAAC;AAC7C,IAAI;AACJ,IAAI,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;AAC3C,IAAI,MAAM,OAAO,GAAG,EAAE;AACtB,IAAI,MAAM,MAAM,GAAG,EAAE;AACrB,IAAI,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,+BAA+B,CAAC;AACzE,IAAI,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE;AACxC,QAAQ,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;AAC5D,QAAQ,IAAI,QAAQ,EAAE;AACtB,YAAY,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9C,QAAQ;AACR,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;AACnE,IAAI,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;AACtC,QAAQ,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;AAC5D,QAAQ,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC;AAC/D,QAAQ,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC;AACxE,QAAQ,MAAM,CAAC,IAAI,CAAC;AACpB,YAAY,GAAG,EAAE,QAAQ,GAAG,CAAC,CAAC;AAC9B,YAAY,IAAI,EAAE,SAAS,GAAG,CAAC,CAAC;AAChC,YAAY,OAAO,EAAE,YAAY,GAAG,CAAC,CAAC;AACtC,SAAS,CAAC;AACV,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,MAAM,EAAE,MAAM;AACtB,QAAQ,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC;AAC1C,KAAK;AACL,IAAI,OAAO,MAAM;AACjB,CAAC;AACW,MAAC,aAAa,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE;;;;"}
|
|
@@ -10,4 +10,5 @@ export { abortMultipartUpload, AbortMultipartUploadInput, AbortMultipartUploadOu
|
|
|
10
10
|
export { copyObject, CopyObjectInput, CopyObjectOutput } from './copyObject';
|
|
11
11
|
export { headObject, HeadObjectInput, HeadObjectOutput } from './headObject';
|
|
12
12
|
export { deleteObject, DeleteObjectInput, DeleteObjectOutput, } from './deleteObject';
|
|
13
|
+
export { deleteObjects, DeleteObjectsInput, DeleteObjectsOutput, } from './deleteObjects';
|
|
13
14
|
export { CompletedPart, Part, _Object } from './types';
|
|
@@ -10,4 +10,5 @@ export { abortMultipartUpload } from './abortMultipartUpload.mjs';
|
|
|
10
10
|
export { copyObject } from './copyObject.mjs';
|
|
11
11
|
export { headObject } from './headObject.mjs';
|
|
12
12
|
export { deleteObject } from './deleteObject.mjs';
|
|
13
|
+
export { deleteObjects } from './deleteObjects.mjs';
|
|
13
14
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -5425,4 +5425,30 @@ export type StorageClass = (typeof StorageClass)[keyof typeof StorageClass];
|
|
|
5425
5425
|
* @public
|
|
5426
5426
|
*/
|
|
5427
5427
|
export type TaggingDirective = (typeof TaggingDirective)[keyof typeof TaggingDirective];
|
|
5428
|
+
/**
|
|
5429
|
+
* @public
|
|
5430
|
+
*/
|
|
5431
|
+
export interface DeleteObjectsCommandInput {
|
|
5432
|
+
Bucket: string;
|
|
5433
|
+
Delete: {
|
|
5434
|
+
Objects: Array<{
|
|
5435
|
+
Key: string;
|
|
5436
|
+
}>;
|
|
5437
|
+
Quiet?: boolean;
|
|
5438
|
+
};
|
|
5439
|
+
ExpectedBucketOwner?: string;
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* @public
|
|
5443
|
+
*/
|
|
5444
|
+
export interface DeleteObjectsCommandOutput extends __MetadataBearer {
|
|
5445
|
+
Deleted?: Array<{
|
|
5446
|
+
Key?: string;
|
|
5447
|
+
}>;
|
|
5448
|
+
Errors?: Array<{
|
|
5449
|
+
Key?: string;
|
|
5450
|
+
Code?: string;
|
|
5451
|
+
Message?: string;
|
|
5452
|
+
}>;
|
|
5453
|
+
}
|
|
5428
5454
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NonPausableTransferTask } from '../../../types/common';
|
|
2
|
+
export declare function createAbortableTask<T>(executor: (abortController: AbortController) => Promise<T>): NonPausableTransferTask<T> & {
|
|
3
|
+
then: Promise<T>['then'];
|
|
4
|
+
catch: Promise<T>['catch'];
|
|
5
|
+
finally: Promise<T>['finally'];
|
|
6
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
function createAbortableTask(executor) {
|
|
4
|
+
const abortController = new AbortController();
|
|
5
|
+
let state = 'IN_PROGRESS';
|
|
6
|
+
const resultPromise = executor(abortController);
|
|
7
|
+
const wrappedPromise = resultPromise
|
|
8
|
+
.then(result => {
|
|
9
|
+
state = 'SUCCESS';
|
|
10
|
+
return result;
|
|
11
|
+
})
|
|
12
|
+
.catch(error => {
|
|
13
|
+
state = abortController.signal.aborted ? 'CANCELED' : 'ERROR';
|
|
14
|
+
throw error;
|
|
15
|
+
});
|
|
16
|
+
const operation = {
|
|
17
|
+
result: wrappedPromise,
|
|
18
|
+
cancel: () => {
|
|
19
|
+
abortController.abort();
|
|
20
|
+
state = 'CANCELED';
|
|
21
|
+
},
|
|
22
|
+
get state() {
|
|
23
|
+
return state;
|
|
24
|
+
},
|
|
25
|
+
then: wrappedPromise.then.bind(wrappedPromise),
|
|
26
|
+
catch: wrappedPromise.catch.bind(wrappedPromise),
|
|
27
|
+
finally: wrappedPromise.finally.bind(wrappedPromise),
|
|
28
|
+
};
|
|
29
|
+
return operation;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createAbortableTask };
|
|
33
|
+
//# sourceMappingURL=createAbortableTask.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAbortableTask.mjs","sources":["../../../../../src/providers/s3/utils/createAbortableTask.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport function createAbortableTask(executor) {\n const abortController = new AbortController();\n let state = 'IN_PROGRESS';\n const resultPromise = executor(abortController);\n const wrappedPromise = resultPromise\n .then(result => {\n state = 'SUCCESS';\n return result;\n })\n .catch(error => {\n state = abortController.signal.aborted ? 'CANCELED' : 'ERROR';\n throw error;\n });\n const operation = {\n result: wrappedPromise,\n cancel: () => {\n abortController.abort();\n state = 'CANCELED';\n },\n get state() {\n return state;\n },\n then: wrappedPromise.then.bind(wrappedPromise),\n catch: wrappedPromise.catch.bind(wrappedPromise),\n finally: wrappedPromise.finally.bind(wrappedPromise),\n };\n return operation;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACO,SAAS,mBAAmB,CAAC,QAAQ,EAAE;AAC9C,IAAI,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE;AACjD,IAAI,IAAI,KAAK,GAAG,aAAa;AAC7B,IAAI,MAAM,aAAa,GAAG,QAAQ,CAAC,eAAe,CAAC;AACnD,IAAI,MAAM,cAAc,GAAG;AAC3B,SAAS,IAAI,CAAC,MAAM,IAAI;AACxB,QAAQ,KAAK,GAAG,SAAS;AACzB,QAAQ,OAAO,MAAM;AACrB,IAAI,CAAC;AACL,SAAS,KAAK,CAAC,KAAK,IAAI;AACxB,QAAQ,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,OAAO;AACrE,QAAQ,MAAM,KAAK;AACnB,IAAI,CAAC,CAAC;AACN,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,MAAM,EAAE,cAAc;AAC9B,QAAQ,MAAM,EAAE,MAAM;AACtB,YAAY,eAAe,CAAC,KAAK,EAAE;AACnC,YAAY,KAAK,GAAG,UAAU;AAC9B,QAAQ,CAAC;AACT,QAAQ,IAAI,KAAK,GAAG;AACpB,YAAY,OAAO,KAAK;AACxB,QAAQ,CAAC;AACT,QAAQ,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;AACtD,QAAQ,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC;AACxD,QAAQ,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC;AAC5D,KAAK;AACL,IAAI,OAAO,SAAS;AACpB;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ProgressInfo, RemoveWithPathOutput } from '../types';
|
|
2
|
+
export interface DeleteFolderContentsParams {
|
|
3
|
+
s3Config: any;
|
|
4
|
+
bucket: string;
|
|
5
|
+
folderKey: string;
|
|
6
|
+
expectedBucketOwner?: string;
|
|
7
|
+
onProgress?(progress: ProgressInfo): void;
|
|
8
|
+
abortSignal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Deletes all contents of a folder in S3 using batch operations
|
|
12
|
+
*
|
|
13
|
+
* @param params - Configuration object for the delete operation
|
|
14
|
+
* @returns Promise that resolves to the removal result
|
|
15
|
+
*/
|
|
16
|
+
export declare const deleteFolderContents: (params: DeleteFolderContentsParams) => Promise<RemoveWithPathOutput>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import { CanceledError } from '../../../errors/CanceledError.mjs';
|
|
3
|
+
import './client/s3data/base.mjs';
|
|
4
|
+
import './client/s3data/getObject.mjs';
|
|
5
|
+
import { listObjectsV2 } from './client/s3data/listObjectsV2.mjs';
|
|
6
|
+
import './client/s3data/putObject.mjs';
|
|
7
|
+
import './client/s3data/createMultipartUpload.mjs';
|
|
8
|
+
import './client/s3data/uploadPart.mjs';
|
|
9
|
+
import './client/s3data/completeMultipartUpload.mjs';
|
|
10
|
+
import './client/s3data/listParts.mjs';
|
|
11
|
+
import './client/s3data/abortMultipartUpload.mjs';
|
|
12
|
+
import './client/s3data/copyObject.mjs';
|
|
13
|
+
import './client/s3data/headObject.mjs';
|
|
14
|
+
import './client/s3data/deleteObject.mjs';
|
|
15
|
+
import { deleteObjects } from './client/s3data/deleteObjects.mjs';
|
|
16
|
+
import { getStorageUserAgentValue } from './userAgent.mjs';
|
|
17
|
+
|
|
18
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
20
|
+
const MAX_KEYS_PER_BATCH = 1000;
|
|
21
|
+
/**
|
|
22
|
+
* Deletes all contents of a folder in S3 using batch operations
|
|
23
|
+
*
|
|
24
|
+
* @param params - Configuration object for the delete operation
|
|
25
|
+
* @returns Promise that resolves to the removal result
|
|
26
|
+
*/
|
|
27
|
+
const deleteFolderContents = async (params) => {
|
|
28
|
+
const { s3Config, bucket, folderKey, expectedBucketOwner, onProgress, abortSignal, } = params;
|
|
29
|
+
try {
|
|
30
|
+
const prefix = folderKey.endsWith('/') ? folderKey : `${folderKey}/`;
|
|
31
|
+
const progressCallback = onProgress ??
|
|
32
|
+
(() => {
|
|
33
|
+
// no-op
|
|
34
|
+
});
|
|
35
|
+
let continuationToken;
|
|
36
|
+
do {
|
|
37
|
+
if (abortSignal?.aborted) {
|
|
38
|
+
throw new CanceledError({ message: 'Operation was canceled' });
|
|
39
|
+
}
|
|
40
|
+
const listResult = await listObjectsV2({
|
|
41
|
+
...s3Config,
|
|
42
|
+
userAgentValue: getStorageUserAgentValue(StorageAction.Remove),
|
|
43
|
+
abortSignal,
|
|
44
|
+
}, {
|
|
45
|
+
Bucket: bucket,
|
|
46
|
+
Prefix: prefix,
|
|
47
|
+
MaxKeys: MAX_KEYS_PER_BATCH,
|
|
48
|
+
ContinuationToken: continuationToken,
|
|
49
|
+
ExpectedBucketOwner: expectedBucketOwner,
|
|
50
|
+
});
|
|
51
|
+
if (!listResult.Contents || listResult.Contents.length === 0) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
if (abortSignal?.aborted) {
|
|
55
|
+
throw new CanceledError({ message: 'Operation was canceled' });
|
|
56
|
+
}
|
|
57
|
+
const batch = listResult.Contents.map(obj => ({ Key: obj.Key }));
|
|
58
|
+
const deleteResult = await deleteObjects({
|
|
59
|
+
...s3Config,
|
|
60
|
+
userAgentValue: getStorageUserAgentValue(StorageAction.Remove),
|
|
61
|
+
abortSignal,
|
|
62
|
+
}, {
|
|
63
|
+
Bucket: bucket,
|
|
64
|
+
Delete: {
|
|
65
|
+
Objects: batch,
|
|
66
|
+
Quiet: false,
|
|
67
|
+
},
|
|
68
|
+
ExpectedBucketOwner: expectedBucketOwner,
|
|
69
|
+
});
|
|
70
|
+
const deleted = deleteResult.Deleted?.map(obj => ({ path: obj.Key })) || [];
|
|
71
|
+
const failed = deleteResult.Errors?.map(err => ({
|
|
72
|
+
path: err.Key,
|
|
73
|
+
code: err.Code,
|
|
74
|
+
message: err.Message,
|
|
75
|
+
})) || [];
|
|
76
|
+
progressCallback({ deleted, failed });
|
|
77
|
+
continuationToken = listResult.NextContinuationToken;
|
|
78
|
+
} while (continuationToken);
|
|
79
|
+
return { path: folderKey };
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (abortSignal?.aborted) {
|
|
83
|
+
throw new CanceledError({ message: 'Operation was canceled' });
|
|
84
|
+
}
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { deleteFolderContents };
|
|
90
|
+
//# sourceMappingURL=deleteFolderContents.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteFolderContents.mjs","sources":["../../../../../src/providers/s3/utils/deleteFolderContents.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { CanceledError } from '../../../errors/CanceledError';\nimport { deleteObjects, listObjectsV2 } from './client/s3data';\nimport { getStorageUserAgentValue } from './userAgent';\nconst MAX_KEYS_PER_BATCH = 1000;\n/**\n * Deletes all contents of a folder in S3 using batch operations\n *\n * @param params - Configuration object for the delete operation\n * @returns Promise that resolves to the removal result\n */\nexport const deleteFolderContents = async (params) => {\n const { s3Config, bucket, folderKey, expectedBucketOwner, onProgress, abortSignal, } = params;\n try {\n const prefix = folderKey.endsWith('/') ? folderKey : `${folderKey}/`;\n const progressCallback = onProgress ??\n (() => {\n // no-op\n });\n let continuationToken;\n do {\n if (abortSignal?.aborted) {\n throw new CanceledError({ message: 'Operation was canceled' });\n }\n const listResult = await listObjectsV2({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Remove),\n abortSignal,\n }, {\n Bucket: bucket,\n Prefix: prefix,\n MaxKeys: MAX_KEYS_PER_BATCH,\n ContinuationToken: continuationToken,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n if (!listResult.Contents || listResult.Contents.length === 0) {\n break;\n }\n if (abortSignal?.aborted) {\n throw new CanceledError({ message: 'Operation was canceled' });\n }\n const batch = listResult.Contents.map(obj => ({ Key: obj.Key }));\n const deleteResult = await deleteObjects({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Remove),\n abortSignal,\n }, {\n Bucket: bucket,\n Delete: {\n Objects: batch,\n Quiet: false,\n },\n ExpectedBucketOwner: expectedBucketOwner,\n });\n const deleted = deleteResult.Deleted?.map(obj => ({ path: obj.Key })) || [];\n const failed = deleteResult.Errors?.map(err => ({\n path: err.Key,\n code: err.Code,\n message: err.Message,\n })) || [];\n progressCallback({ deleted, failed });\n continuationToken = listResult.NextContinuationToken;\n } while (continuationToken);\n return { path: folderKey };\n }\n catch (error) {\n if (abortSignal?.aborted) {\n throw new CanceledError({ message: 'Operation was canceled' });\n }\n throw error;\n }\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates XML for S3 batch delete operations
|
|
3
|
+
*
|
|
4
|
+
* @param objects - Array of objects to delete with their keys
|
|
5
|
+
* @param quiet - Whether to use quiet mode (default: true)
|
|
6
|
+
* @returns XML string for the delete request
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateDeleteObjectsXml: (objects: {
|
|
9
|
+
Key: string;
|
|
10
|
+
}[], quiet: boolean) => string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Escapes special XML characters in a string
|
|
5
|
+
* @param str - String to escape
|
|
6
|
+
* @returns XML-escaped string
|
|
7
|
+
*/
|
|
8
|
+
const escapeXml = (str) => {
|
|
9
|
+
return str
|
|
10
|
+
.replace(/&/g, '&')
|
|
11
|
+
.replace(/</g, '<')
|
|
12
|
+
.replace(/>/g, '>')
|
|
13
|
+
.replace(/"/g, '"')
|
|
14
|
+
.replace(/'/g, ''');
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Generates XML for S3 batch delete operations
|
|
18
|
+
*
|
|
19
|
+
* @param objects - Array of objects to delete with their keys
|
|
20
|
+
* @param quiet - Whether to use quiet mode (default: true)
|
|
21
|
+
* @returns XML string for the delete request
|
|
22
|
+
*/
|
|
23
|
+
const generateDeleteObjectsXml = (objects, quiet) => {
|
|
24
|
+
const objectsXml = objects
|
|
25
|
+
.map(obj => `<Object><Key>${escapeXml(obj.Key)}</Key></Object>`)
|
|
26
|
+
.join('');
|
|
27
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
28
|
+
<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
29
|
+
<Quiet>${quiet ? 'true' : 'false'}</Quiet>
|
|
30
|
+
${objectsXml}
|
|
31
|
+
</Delete>`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { generateDeleteObjectsXml };
|
|
35
|
+
//# sourceMappingURL=generateDeleteObjectsXml.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDeleteObjectsXml.mjs","sources":["../../../../../src/providers/s3/utils/generateDeleteObjectsXml.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Escapes special XML characters in a string\n * @param str - String to escape\n * @returns XML-escaped string\n */\nconst escapeXml = (str) => {\n return str\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n};\n/**\n * Generates XML for S3 batch delete operations\n *\n * @param objects - Array of objects to delete with their keys\n * @param quiet - Whether to use quiet mode (default: true)\n * @returns XML string for the delete request\n */\nexport const generateDeleteObjectsXml = (objects, quiet) => {\n const objectsXml = objects\n .map(obj => `<Object><Key>${escapeXml(obj.Key)}</Key></Object>`)\n .join('');\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Delete xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n\t<Quiet>${quiet ? 'true' : 'false'}</Quiet>\n\t${objectsXml}\n</Delete>`;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,SAAS,GAAG,CAAC,GAAG,KAAK;AAC3B,IAAI,OAAO;AACX,SAAS,OAAO,CAAC,IAAI,EAAE,OAAO;AAC9B,SAAS,OAAO,CAAC,IAAI,EAAE,MAAM;AAC7B,SAAS,OAAO,CAAC,IAAI,EAAE,MAAM;AAC7B,SAAS,OAAO,CAAC,IAAI,EAAE,QAAQ;AAC/B,SAAS,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;AAChC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,wBAAwB,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK;AAC5D,IAAI,MAAM,UAAU,GAAG;AACvB,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC;AACvE,SAAS,IAAI,CAAC,EAAE,CAAC;AACjB,IAAI,OAAO,CAAC;AACZ;AACA,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AACnC,CAAC,EAAE,UAAU;AACb,SAAS,CAAC;AACV;;;;"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export { calculateContentMd5 } from './md5';
|
|
2
|
+
export { deleteFolderContents } from './deleteFolderContents';
|
|
3
|
+
export { generateDeleteObjectsXml } from './generateDeleteObjectsXml';
|
|
2
4
|
export { resolveS3ConfigAndInput } from './resolveS3ConfigAndInput';
|
|
5
|
+
export { resolveFinalKey } from './resolveFinalKey';
|
|
3
6
|
export { createDownloadTask, createUploadTask } from './transferTask';
|
|
4
7
|
export { validateBucketOwnerID } from './validateBucketOwnerID';
|
|
8
|
+
export { validateRemovePath } from './validateRemovePath';
|
|
5
9
|
export { validateStorageOperationInput } from './validateStorageOperationInput';
|
|
6
10
|
export { validateStorageOperationInputWithPrefix } from './validateStorageOperationInputWithPrefix';
|
|
7
11
|
export { isInputWithPath } from './isInputWithPath';
|
|
12
|
+
export { isPathFolder } from './isPathFolder';
|
|
8
13
|
export { urlDecode } from './urlDecoder';
|
|
14
|
+
export { createAbortableTask } from './createAbortableTask';
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export { calculateContentMd5 } from './md5.mjs';
|
|
2
|
+
export { deleteFolderContents } from './deleteFolderContents.mjs';
|
|
3
|
+
export { generateDeleteObjectsXml } from './generateDeleteObjectsXml.mjs';
|
|
2
4
|
export { resolveS3ConfigAndInput } from './resolveS3ConfigAndInput.mjs';
|
|
5
|
+
export { resolveFinalKey } from './resolveFinalKey.mjs';
|
|
3
6
|
export { createDownloadTask, createUploadTask } from './transferTask.mjs';
|
|
4
7
|
export { validateBucketOwnerID } from './validateBucketOwnerID.mjs';
|
|
8
|
+
export { validateRemovePath } from './validateRemovePath.mjs';
|
|
5
9
|
export { validateStorageOperationInput } from './validateStorageOperationInput.mjs';
|
|
6
10
|
export { validateStorageOperationInputWithPrefix } from './validateStorageOperationInputWithPrefix.mjs';
|
|
7
11
|
export { isInputWithPath } from './isInputWithPath.mjs';
|
|
12
|
+
export { isPathFolder } from './isPathFolder.mjs';
|
|
8
13
|
export { urlDecode } from './urlDecoder.mjs';
|
|
14
|
+
export { createAbortableTask } from './createAbortableTask.mjs';
|
|
9
15
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IsPathFolderParams {
|
|
2
|
+
s3Config: any;
|
|
3
|
+
bucket: string;
|
|
4
|
+
key: string;
|
|
5
|
+
expectedBucketOwner?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Determines if a given S3 key represents a folder by checking if objects exist with that prefix.
|
|
9
|
+
*
|
|
10
|
+
* @param params - Configuration object for the folder check
|
|
11
|
+
* @returns Promise that resolves to true if the key represents a folder, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export declare const isPathFolder: (params: IsPathFolderParams) => Promise<boolean>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { StorageAction } from '@aws-amplify/core/internals/utils';
|
|
2
|
+
import './client/s3data/base.mjs';
|
|
3
|
+
import './client/s3data/getObject.mjs';
|
|
4
|
+
import { listObjectsV2 } from './client/s3data/listObjectsV2.mjs';
|
|
5
|
+
import './client/s3data/putObject.mjs';
|
|
6
|
+
import './client/s3data/createMultipartUpload.mjs';
|
|
7
|
+
import './client/s3data/uploadPart.mjs';
|
|
8
|
+
import './client/s3data/completeMultipartUpload.mjs';
|
|
9
|
+
import './client/s3data/listParts.mjs';
|
|
10
|
+
import './client/s3data/abortMultipartUpload.mjs';
|
|
11
|
+
import './client/s3data/copyObject.mjs';
|
|
12
|
+
import './client/s3data/headObject.mjs';
|
|
13
|
+
import './client/s3data/deleteObject.mjs';
|
|
14
|
+
import './client/s3data/deleteObjects.mjs';
|
|
15
|
+
import { getStorageUserAgentValue } from './userAgent.mjs';
|
|
16
|
+
|
|
17
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
18
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
/**
|
|
20
|
+
* Determines if a given S3 key represents a folder by checking if objects exist with that prefix.
|
|
21
|
+
*
|
|
22
|
+
* @param params - Configuration object for the folder check
|
|
23
|
+
* @returns Promise that resolves to true if the key represents a folder, false otherwise
|
|
24
|
+
*/
|
|
25
|
+
const isPathFolder = async (params) => {
|
|
26
|
+
const { s3Config, bucket, key, expectedBucketOwner } = params;
|
|
27
|
+
try {
|
|
28
|
+
const prefix = key.endsWith('/') ? key : `${key}/`;
|
|
29
|
+
const result = await listObjectsV2({
|
|
30
|
+
...s3Config,
|
|
31
|
+
userAgentValue: getStorageUserAgentValue(StorageAction.Remove),
|
|
32
|
+
}, {
|
|
33
|
+
Bucket: bucket,
|
|
34
|
+
Prefix: prefix,
|
|
35
|
+
MaxKeys: 1,
|
|
36
|
+
ExpectedBucketOwner: expectedBucketOwner,
|
|
37
|
+
});
|
|
38
|
+
const isFolder = !!(result.Contents && result.Contents.length > 0) ||
|
|
39
|
+
!!(result.CommonPrefixes && result.CommonPrefixes.length > 0);
|
|
40
|
+
return isFolder;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { isPathFolder };
|
|
48
|
+
//# sourceMappingURL=isPathFolder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPathFolder.mjs","sources":["../../../../../src/providers/s3/utils/isPathFolder.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { StorageAction } from '@aws-amplify/core/internals/utils';\nimport { listObjectsV2 } from './client/s3data';\nimport { getStorageUserAgentValue } from './userAgent';\n/**\n * Determines if a given S3 key represents a folder by checking if objects exist with that prefix.\n *\n * @param params - Configuration object for the folder check\n * @returns Promise that resolves to true if the key represents a folder, false otherwise\n */\nexport const isPathFolder = async (params) => {\n const { s3Config, bucket, key, expectedBucketOwner } = params;\n try {\n const prefix = key.endsWith('/') ? key : `${key}/`;\n const result = await listObjectsV2({\n ...s3Config,\n userAgentValue: getStorageUserAgentValue(StorageAction.Remove),\n }, {\n Bucket: bucket,\n Prefix: prefix,\n MaxKeys: 1,\n ExpectedBucketOwner: expectedBucketOwner,\n });\n const isFolder = !!(result.Contents && result.Contents.length > 0) ||\n !!(result.CommonPrefixes && result.CommonPrefixes.length > 0);\n return isFolder;\n }\n catch (error) {\n return false;\n }\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,YAAY,GAAG,OAAO,MAAM,KAAK;AAC9C,IAAI,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,MAAM;AACjE,IAAI,IAAI;AACR,QAAQ,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1D,QAAQ,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;AAC3C,YAAY,GAAG,QAAQ;AACvB,YAAY,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC,MAAM,CAAC;AAC1E,SAAS,EAAE;AACX,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,OAAO,EAAE,CAAC;AACtB,YAAY,mBAAmB,EAAE,mBAAmB;AACpD,SAAS,CAAC;AACV,QAAQ,MAAM,QAAQ,GAAG,CAAC,EAAE,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AAC1E,YAAY,CAAC,EAAE,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;AACzE,QAAQ,OAAO,QAAQ;AACvB,IAAI;AACJ,IAAI,OAAO,KAAK,EAAE;AAClB,QAAQ,OAAO,KAAK;AACpB,IAAI;AACJ;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the final S3 key based on input type and key prefix.
|
|
3
|
+
*
|
|
4
|
+
* @param inputType - The type of input (key-based or path-based)
|
|
5
|
+
* @param objectKey - The object key from the input
|
|
6
|
+
* @param keyPrefix - The key prefix to prepend for key-based inputs
|
|
7
|
+
* @returns The final S3 key to use for the operation
|
|
8
|
+
*/
|
|
9
|
+
export declare const resolveFinalKey: (inputType: string, objectKey: string, keyPrefix: string) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { STORAGE_INPUT_KEY } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the final S3 key based on input type and key prefix.
|
|
7
|
+
*
|
|
8
|
+
* @param inputType - The type of input (key-based or path-based)
|
|
9
|
+
* @param objectKey - The object key from the input
|
|
10
|
+
* @param keyPrefix - The key prefix to prepend for key-based inputs
|
|
11
|
+
* @returns The final S3 key to use for the operation
|
|
12
|
+
*/
|
|
13
|
+
const resolveFinalKey = (inputType, objectKey, keyPrefix) => {
|
|
14
|
+
return inputType === STORAGE_INPUT_KEY
|
|
15
|
+
? `${keyPrefix}${objectKey}`
|
|
16
|
+
: objectKey;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { resolveFinalKey };
|
|
20
|
+
//# sourceMappingURL=resolveFinalKey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveFinalKey.mjs","sources":["../../../../../src/providers/s3/utils/resolveFinalKey.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { STORAGE_INPUT_KEY } from './constants';\n/**\n * Resolves the final S3 key based on input type and key prefix.\n *\n * @param inputType - The type of input (key-based or path-based)\n * @param objectKey - The object key from the input\n * @param keyPrefix - The key prefix to prepend for key-based inputs\n * @returns The final S3 key to use for the operation\n */\nexport const resolveFinalKey = (inputType, objectKey, keyPrefix) => {\n return inputType === STORAGE_INPUT_KEY\n ? `${keyPrefix}${objectKey}`\n : objectKey;\n};\n"],"names":[],"mappings":";;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,eAAe,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,KAAK;AACpE,IAAI,OAAO,SAAS,KAAK;AACzB,UAAU,CAAC,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC;AACnC,UAAU,SAAS;AACnB;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates that the path is safe for removal operations.
|
|
3
|
+
* Prevents deletion of dangerous paths that could affect entire buckets.
|
|
4
|
+
*
|
|
5
|
+
* @param path - The path to validate
|
|
6
|
+
* @throws Error if the path is considered dangerous
|
|
7
|
+
*/
|
|
8
|
+
export declare const validateRemovePath: (path: string) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* Validates that the path is safe for removal operations.
|
|
5
|
+
* Prevents deletion of dangerous paths that could affect entire buckets.
|
|
6
|
+
*
|
|
7
|
+
* @param path - The path to validate
|
|
8
|
+
* @throws Error if the path is considered dangerous
|
|
9
|
+
*/
|
|
10
|
+
const validateRemovePath = (path) => {
|
|
11
|
+
const DANGEROUS_PATHS = ['', '/', '*'];
|
|
12
|
+
if (DANGEROUS_PATHS.includes(path.trim())) {
|
|
13
|
+
throw new Error('Cannot delete root or bucket-wide paths');
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { validateRemovePath };
|
|
18
|
+
//# sourceMappingURL=validateRemovePath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateRemovePath.mjs","sources":["../../../../../src/providers/s3/utils/validateRemovePath.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Validates that the path is safe for removal operations.\n * Prevents deletion of dangerous paths that could affect entire buckets.\n *\n * @param path - The path to validate\n * @throws Error if the path is considered dangerous\n */\nexport const validateRemovePath = (path) => {\n const DANGEROUS_PATHS = ['', '/', '*'];\n if (DANGEROUS_PATHS.includes(path.trim())) {\n throw new Error('Cannot delete root or bucket-wide paths');\n }\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,CAAC,IAAI,KAAK;AAC5C,IAAI,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC;AAC1C,IAAI,IAAI,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;AAC/C,QAAQ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;AAClE,IAAI;AACJ;;;;"}
|