@scality/data-browser-library 1.0.0-preview.11
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/components/Editor.d.ts +12 -0
- package/dist/components/Editor.js +28 -0
- package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +408 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
- package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
- package/dist/components/__tests__/BucketList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketList.test.js +415 -0
- package/dist/components/__tests__/BucketNotificationCreatePage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +316 -0
- package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
- package/dist/components/__tests__/BucketOverview.test.js +769 -0
- package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketPolicyPage.test.js +268 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
- package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
- package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
- package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
- package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
- package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
- package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
- package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
- package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
- package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
- package/dist/components/__tests__/MetadataSearch.test.js +201 -0
- package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
- package/dist/components/__tests__/ObjectList.test.js +283 -0
- package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
- package/dist/components/__tests__/UploadButton.test.js +144 -0
- package/dist/components/buckets/BucketCreate.d.ts +49 -0
- package/dist/components/buckets/BucketCreate.js +237 -0
- package/dist/components/buckets/BucketDetails.d.ts +1 -0
- package/dist/components/buckets/BucketDetails.js +106 -0
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1085 -0
- package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
- package/dist/components/buckets/BucketLifecycleList.js +270 -0
- package/dist/components/buckets/BucketList.d.ts +15 -0
- package/dist/components/buckets/BucketList.js +146 -0
- package/dist/components/buckets/BucketLocation.d.ts +3 -0
- package/dist/components/buckets/BucketLocation.js +16 -0
- package/dist/components/buckets/BucketOverview.d.ts +88 -0
- package/dist/components/buckets/BucketOverview.js +291 -0
- package/dist/components/buckets/BucketPage.d.ts +2 -0
- package/dist/components/buckets/BucketPage.js +47 -0
- package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
- package/dist/components/buckets/BucketPolicyButton.js +18 -0
- package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
- package/dist/components/buckets/BucketPolicyPage.js +236 -0
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +834 -0
- package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
- package/dist/components/buckets/BucketReplicationList.js +189 -0
- package/dist/components/buckets/BucketVersioning.d.ts +4 -0
- package/dist/components/buckets/BucketVersioning.js +73 -0
- package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
- package/dist/components/buckets/DeleteBucketButton.js +78 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +18 -0
- package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
- package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
- package/dist/components/buckets/EmptyBucketButton.js +232 -0
- package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
- package/dist/components/buckets/EmptyBucketSummary.js +60 -0
- package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
- package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
- package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +234 -0
- package/dist/components/buckets/notifications/EventsSection.d.ts +1 -0
- package/dist/components/buckets/notifications/EventsSection.js +123 -0
- package/dist/components/buckets/notifications/events.d.ts +12 -0
- package/dist/components/buckets/notifications/events.js +27 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.js +22 -0
- package/dist/components/layouts/ArrowNavigation.d.ts +4 -0
- package/dist/components/layouts/ArrowNavigation.js +16 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +12 -0
- package/dist/components/layouts/BrowserPageLayout.js +51 -0
- package/dist/components/objects/CreateFolderButton.d.ts +29 -0
- package/dist/components/objects/CreateFolderButton.js +118 -0
- package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
- package/dist/components/objects/DeleteObjectButton.js +191 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +356 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +241 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
- package/dist/components/objects/ObjectDetails/ObjectTags.js +272 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
- package/dist/components/objects/ObjectDetails/index.js +75 -0
- package/dist/components/objects/ObjectList.d.ts +40 -0
- package/dist/components/objects/ObjectList.js +453 -0
- package/dist/components/objects/ObjectLock/EditRetentionButton.d.ts +4 -0
- package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
- package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettings.js +158 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
- package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
- package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
- package/dist/components/objects/ObjectPage.d.ts +1 -0
- package/dist/components/objects/ObjectPage.js +45 -0
- package/dist/components/objects/UploadButton.d.ts +34 -0
- package/dist/components/objects/UploadButton.js +229 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
- package/dist/components/providers/DataBrowserProvider.js +42 -0
- package/dist/components/search/MetadataSearch.d.ts +5 -0
- package/dist/components/search/MetadataSearch.js +162 -0
- package/dist/components/search/SearchHints.d.ts +8 -0
- package/dist/components/search/SearchHints.js +21 -0
- package/dist/components/ui/ArrayFieldActions.d.ts +36 -0
- package/dist/components/ui/ArrayFieldActions.js +43 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
- package/dist/components/ui/ConfirmDeleteRuleModal.js +43 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
- package/dist/components/ui/DeleteObjectModalContent.js +71 -0
- package/dist/components/ui/FilterFormSection.d.ts +44 -0
- package/dist/components/ui/FilterFormSection.js +159 -0
- package/dist/components/ui/Search.elements.d.ts +17 -0
- package/dist/components/ui/Search.elements.js +59 -0
- package/dist/components/ui/Table.elements.d.ts +36 -0
- package/dist/components/ui/Table.elements.js +87 -0
- package/dist/config/factory.d.ts +63 -0
- package/dist/config/factory.js +74 -0
- package/dist/config/types.d.ts +46 -0
- package/dist/config/types.js +0 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.d.ts +1 -0
- package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
- package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
- package/dist/hooks/bucketConfiguration.d.ts +168 -0
- package/dist/hooks/bucketConfiguration.js +67 -0
- package/dist/hooks/bucketOperations.d.ts +36 -0
- package/dist/hooks/bucketOperations.js +12 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +179 -0
- package/dist/hooks/factories/index.d.ts +18 -0
- package/dist/hooks/factories/index.js +5 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
- package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
- package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
- package/dist/hooks/factories/useCreateS3QueryHook.js +51 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/loginOperations.d.ts +21 -0
- package/dist/hooks/loginOperations.js +9 -0
- package/dist/hooks/objectOperations.d.ts +190 -0
- package/dist/hooks/objectOperations.js +67 -0
- package/dist/hooks/presignedOperations.d.ts +73 -0
- package/dist/hooks/presignedOperations.js +72 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +45 -0
- package/dist/hooks/useDeleteBucketConfigRule.d.ts +26 -0
- package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
- package/dist/hooks/useEmptyBucket.d.ts +27 -0
- package/dist/hooks/useEmptyBucket.js +116 -0
- package/dist/hooks/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
- package/dist/hooks/useIsBucketEmpty.js +36 -0
- package/dist/hooks/useLoginMutation.d.ts +21 -0
- package/dist/hooks/useLoginMutation.js +9 -0
- package/dist/hooks/useS3Client.d.ts +1 -0
- package/dist/hooks/useS3Client.js +13 -0
- package/dist/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/schemas/bucketPolicySchema.json +321 -0
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
- package/dist/test/msw/handlers/deleteBucket.js +14 -0
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketAcl.js +96 -0
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
- package/dist/test/msw/handlers/getBucketLocation.js +23 -0
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
- package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
- package/dist/test/msw/handlers/headObject.d.ts +1 -0
- package/dist/test/msw/handlers/headObject.js +17 -0
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
- package/dist/test/msw/handlers/listBuckets.js +24 -0
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
- package/dist/test/msw/handlers/listObjectVersions.js +83 -0
- package/dist/test/msw/handlers/listObjects.d.ts +1 -0
- package/dist/test/msw/handlers/listObjects.js +66 -0
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
- package/dist/test/msw/handlers/objectLegalHold.js +24 -0
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
- package/dist/test/msw/handlers/objectRetention.js +27 -0
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
- package/dist/test/msw/handlers/putBucketAcl.js +18 -0
- package/dist/test/msw/handlers/putObject.d.ts +1 -0
- package/dist/test/msw/handlers/putObject.js +16 -0
- package/dist/test/msw/handlers.d.ts +4 -0
- package/dist/test/msw/handlers.js +109 -0
- package/dist/test/msw/index.d.ts +2 -0
- package/dist/test/msw/index.js +3 -0
- package/dist/test/msw/server.d.ts +4 -0
- package/dist/test/msw/server.js +20 -0
- package/dist/test/msw/utils.d.ts +2 -0
- package/dist/test/msw/utils.js +13 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +90 -0
- package/dist/test/testUtils.d.ts +181 -0
- package/dist/test/testUtils.js +310 -0
- package/dist/test/utils/errorHandling.test.d.ts +1 -0
- package/dist/test/utils/errorHandling.test.js +423 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.js +9 -0
- package/dist/utils/deletion/index.d.ts +2 -0
- package/dist/utils/deletion/index.js +2 -0
- package/dist/utils/deletion/messages.d.ts +5 -0
- package/dist/utils/deletion/messages.js +29 -0
- package/dist/utils/deletion/types.d.ts +11 -0
- package/dist/utils/deletion/types.js +0 -0
- package/dist/utils/errorHandling.d.ts +63 -0
- package/dist/utils/errorHandling.js +84 -0
- package/dist/utils/hooks.d.ts +2 -0
- package/dist/utils/hooks.js +26 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/proxyMiddleware.d.ts +18 -0
- package/dist/utils/proxyMiddleware.js +56 -0
- package/dist/utils/s3Client.d.ts +5 -0
- package/dist/utils/s3Client.js +36 -0
- package/dist/utils/s3RuleUtils.d.ts +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- package/dist/utils/useFeatures.d.ts +1 -0
- package/dist/utils/useFeatures.js +7 -0
- package/package.json +84 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { InvalidObjectState, InvalidRequest, InvalidWriteOffset, NoSuchBucket, NoSuchKey, NoSuchUpload, ObjectAlreadyInActiveTierError, ObjectNotInActiveTierError } from "@aws-sdk/client-s3";
|
|
2
|
+
var errorHandling_ErrorCategory = /*#__PURE__*/ function(ErrorCategory) {
|
|
3
|
+
ErrorCategory["CLIENT_ERROR"] = "CLIENT_ERROR";
|
|
4
|
+
ErrorCategory["SERVER_ERROR"] = "SERVER_ERROR";
|
|
5
|
+
ErrorCategory["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
6
|
+
ErrorCategory["CANCELLATION"] = "CANCELLATION";
|
|
7
|
+
ErrorCategory["AUTHORIZATION"] = "AUTHORIZATION";
|
|
8
|
+
ErrorCategory["NOT_FOUND"] = "NOT_FOUND";
|
|
9
|
+
ErrorCategory["UNKNOWN"] = "UNKNOWN";
|
|
10
|
+
return ErrorCategory;
|
|
11
|
+
}({});
|
|
12
|
+
class EnhancedS3Error extends Error {
|
|
13
|
+
category;
|
|
14
|
+
statusCode;
|
|
15
|
+
metadata;
|
|
16
|
+
originalError;
|
|
17
|
+
context;
|
|
18
|
+
constructor(message, name, category, originalError, statusCode, metadata, context){
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.category = category;
|
|
22
|
+
this.statusCode = statusCode;
|
|
23
|
+
this.metadata = metadata;
|
|
24
|
+
this.originalError = originalError;
|
|
25
|
+
this.context = context;
|
|
26
|
+
Object.setPrototypeOf(this, EnhancedS3Error.prototype);
|
|
27
|
+
}
|
|
28
|
+
shouldRetry() {
|
|
29
|
+
return "SERVER_ERROR" === this.category || "NETWORK_ERROR" === this.category;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function classifyByStatusCode(statusCode) {
|
|
33
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
34
|
+
if (401 === statusCode || 403 === statusCode) return "AUTHORIZATION";
|
|
35
|
+
if (404 === statusCode) return "NOT_FOUND";
|
|
36
|
+
return "CLIENT_ERROR";
|
|
37
|
+
}
|
|
38
|
+
return statusCode >= 500 ? "SERVER_ERROR" : "UNKNOWN";
|
|
39
|
+
}
|
|
40
|
+
function isS3ServiceException(error) {
|
|
41
|
+
return error instanceof Error && "$metadata" in error;
|
|
42
|
+
}
|
|
43
|
+
function isEnhancedS3Error(error) {
|
|
44
|
+
return error instanceof EnhancedS3Error;
|
|
45
|
+
}
|
|
46
|
+
function createS3Error(error, context) {
|
|
47
|
+
if (error instanceof Error && "AbortError" === error.name) return new EnhancedS3Error("Operation was cancelled", "AbortError", "CANCELLATION", error, void 0, void 0, context);
|
|
48
|
+
if (error instanceof NoSuchBucket || error instanceof NoSuchKey || error instanceof NoSuchUpload) return new EnhancedS3Error(error.message, error.name, "NOT_FOUND", error, error.$metadata?.httpStatusCode, error.$metadata, context);
|
|
49
|
+
if (error instanceof InvalidRequest || error instanceof InvalidObjectState || error instanceof InvalidWriteOffset || error instanceof ObjectAlreadyInActiveTierError || error instanceof ObjectNotInActiveTierError) return new EnhancedS3Error(error.message, error.name, "CLIENT_ERROR", error, error.$metadata?.httpStatusCode, error.$metadata, context);
|
|
50
|
+
if (isS3ServiceException(error)) {
|
|
51
|
+
const category = error.$metadata?.httpStatusCode ? classifyByStatusCode(error.$metadata.httpStatusCode) : "UNKNOWN";
|
|
52
|
+
return new EnhancedS3Error(error.message, error.name, category, error, error.$metadata?.httpStatusCode, error.$metadata, context);
|
|
53
|
+
}
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
const isNetwork = /network|connection|timeout|dns/i.test(error.message) || error.name.includes("Network") || error.name.includes("Timeout");
|
|
56
|
+
return new EnhancedS3Error(error.message, error.name, isNetwork ? "NETWORK_ERROR" : "UNKNOWN", error, void 0, void 0, context);
|
|
57
|
+
}
|
|
58
|
+
const message = "string" == typeof error ? error : "Unknown error occurred";
|
|
59
|
+
return new EnhancedS3Error(message, "UnknownError", "UNKNOWN", new Error(message), void 0, void 0, context);
|
|
60
|
+
}
|
|
61
|
+
function createS3OperationError(error, operation, bucketName, objectKey) {
|
|
62
|
+
const context = {
|
|
63
|
+
operation,
|
|
64
|
+
bucketName,
|
|
65
|
+
objectKey,
|
|
66
|
+
timestamp: new Date().toISOString()
|
|
67
|
+
};
|
|
68
|
+
const enhancedError = createS3Error(error, context);
|
|
69
|
+
if (!enhancedError.message.includes(operation)) {
|
|
70
|
+
const prefix = bucketName ? `${operation} failed for bucket '${bucketName}'${objectKey ? `, key '${objectKey}'` : ""}` : `${operation} failed`;
|
|
71
|
+
return new EnhancedS3Error(`${prefix}: ${enhancedError.message}`, enhancedError.name, enhancedError.category, enhancedError.originalError, enhancedError.statusCode, enhancedError.metadata, context);
|
|
72
|
+
}
|
|
73
|
+
return enhancedError;
|
|
74
|
+
}
|
|
75
|
+
function shouldRetryError(error, failureCount, maxRetries = 3) {
|
|
76
|
+
if (failureCount >= maxRetries) return false;
|
|
77
|
+
return isEnhancedS3Error(error) ? error.shouldRetry() : createS3Error(error).shouldRetry();
|
|
78
|
+
}
|
|
79
|
+
function isNotFoundError(error) {
|
|
80
|
+
if (!error) return false;
|
|
81
|
+
const enhancedError = isEnhancedS3Error(error) ? error : createS3Error(error);
|
|
82
|
+
return "NOT_FOUND" === enhancedError.category;
|
|
83
|
+
}
|
|
84
|
+
export { EnhancedS3Error, errorHandling_ErrorCategory as ErrorCategory, createS3Error, createS3OperationError, isEnhancedS3Error, isNotFoundError, isS3ServiceException, shouldRetryError };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useLocation } from "react-router-dom";
|
|
3
|
+
const useQueryParams = ()=>{
|
|
4
|
+
const location = useLocation();
|
|
5
|
+
return useMemo(()=>new URLSearchParams(location.search), [
|
|
6
|
+
location.search
|
|
7
|
+
]);
|
|
8
|
+
};
|
|
9
|
+
const usePrefixWithSlash = ()=>{
|
|
10
|
+
const query = useQueryParams();
|
|
11
|
+
return useMemo(()=>{
|
|
12
|
+
const prefix = query.get("prefix");
|
|
13
|
+
if (!prefix) return "";
|
|
14
|
+
if (!prefix || "/" === prefix.slice(-1)) return prefix;
|
|
15
|
+
{
|
|
16
|
+
const prefixArr = prefix.split("/");
|
|
17
|
+
prefixArr.pop();
|
|
18
|
+
if (!prefixArr.length) return "";
|
|
19
|
+
const joinedPrefix = prefixArr.join("/");
|
|
20
|
+
return joinedPrefix ? "/" !== joinedPrefix.slice(-1) ? `${joinedPrefix}/` : joinedPrefix : "";
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
query
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
export { usePrefixWithSlash, useQueryParams };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Pluggable } from "@aws-sdk/types";
|
|
2
|
+
interface ProxyConfig {
|
|
3
|
+
realS3Host: string;
|
|
4
|
+
proxyBasePath: string;
|
|
5
|
+
proxyHost: string;
|
|
6
|
+
proxyPort: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a two-stage proxy middleware for AWS SDK v3
|
|
10
|
+
*
|
|
11
|
+
* This middleware enables proper S3 request signing through a development proxy:
|
|
12
|
+
* 1. Pre-signing: Modifies requests to use real S3 host for correct signature calculation
|
|
13
|
+
* 2. Post-signing: Routes signed requests through proxy to avoid CORS issues
|
|
14
|
+
*
|
|
15
|
+
* @param config Proxy configuration from build-time constants
|
|
16
|
+
*/
|
|
17
|
+
export declare const createProxyMiddleware: (config: ProxyConfig) => Pluggable<any, any>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { HttpRequest } from "@aws-sdk/protocol-http";
|
|
2
|
+
const createProxyMiddleware = (config)=>({
|
|
3
|
+
applyToStack: (clientStack)=>{
|
|
4
|
+
const preSigningMiddleware = (next)=>async (args)=>{
|
|
5
|
+
const { request } = args;
|
|
6
|
+
if (HttpRequest.isInstance(request) && request.hostname === config.proxyHost) {
|
|
7
|
+
const originalQuery = request.query || {};
|
|
8
|
+
if (request.path.startsWith(config.proxyBasePath)) {
|
|
9
|
+
request.path = request.path.replace(config.proxyBasePath, '');
|
|
10
|
+
if (!request.path.startsWith('/')) request.path = '/' + request.path;
|
|
11
|
+
}
|
|
12
|
+
request.hostname = config.realS3Host;
|
|
13
|
+
request.port = 443;
|
|
14
|
+
request.protocol = 'https:';
|
|
15
|
+
request.headers.host = config.realS3Host;
|
|
16
|
+
request.query = originalQuery;
|
|
17
|
+
console.log('Pre-signing: Modified for real S3 signing', {
|
|
18
|
+
path: request.path,
|
|
19
|
+
host: request.hostname,
|
|
20
|
+
query: request.query
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return next(args);
|
|
24
|
+
};
|
|
25
|
+
const postSigningMiddleware = (next)=>async (args)=>{
|
|
26
|
+
const { request } = args;
|
|
27
|
+
if (HttpRequest.isInstance(request) && request.hostname === config.realS3Host) {
|
|
28
|
+
const queryParams = request.query || {};
|
|
29
|
+
request.hostname = config.proxyHost;
|
|
30
|
+
request.port = config.proxyPort;
|
|
31
|
+
request.protocol = 'http:';
|
|
32
|
+
request.path = config.proxyBasePath + request.path;
|
|
33
|
+
request.headers.host = `${config.proxyHost}:${config.proxyPort}`;
|
|
34
|
+
request.query = queryParams;
|
|
35
|
+
console.log('Post-signing: Routed to proxy', {
|
|
36
|
+
host: request.hostname,
|
|
37
|
+
path: request.path,
|
|
38
|
+
query: request.query,
|
|
39
|
+
hasAuth: !!request.headers.authorization
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return next(args);
|
|
43
|
+
};
|
|
44
|
+
clientStack.add(preSigningMiddleware, {
|
|
45
|
+
step: "build",
|
|
46
|
+
name: "proxyPreSigningMiddleware",
|
|
47
|
+
priority: "high"
|
|
48
|
+
});
|
|
49
|
+
clientStack.add(postSigningMiddleware, {
|
|
50
|
+
step: "finalizeRequest",
|
|
51
|
+
name: "proxyPostSigningMiddleware",
|
|
52
|
+
priority: "high"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export { createProxyMiddleware };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
2
|
+
import { createProxyMiddleware } from "./proxyMiddleware.js";
|
|
3
|
+
import { S3ConfigurationFactory } from "../config/factory.js";
|
|
4
|
+
function extractProxyConfig(config) {
|
|
5
|
+
if (config.useDevProxy && config.realS3Host && config.proxyPath) return {
|
|
6
|
+
realS3Host: config.realS3Host,
|
|
7
|
+
proxyBasePath: config.proxyPath,
|
|
8
|
+
proxyHost: config.proxyHost || "localhost",
|
|
9
|
+
proxyPort: config.proxyPort || 8084
|
|
10
|
+
};
|
|
11
|
+
const proxyConfig = S3ConfigurationFactory.createProxyConfiguration();
|
|
12
|
+
if (proxyConfig.useProxy && proxyConfig.proxyConfig) return {
|
|
13
|
+
realS3Host: proxyConfig.proxyConfig.realHost,
|
|
14
|
+
proxyBasePath: proxyConfig.proxyConfig.proxyBasePath,
|
|
15
|
+
proxyHost: proxyConfig.proxyConfig.proxyHost,
|
|
16
|
+
proxyPort: proxyConfig.proxyConfig.proxyPort
|
|
17
|
+
};
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const createS3Client = (config)=>{
|
|
21
|
+
const client = new S3Client({
|
|
22
|
+
...config,
|
|
23
|
+
credentials: config.credentials,
|
|
24
|
+
forcePathStyle: config.forcePathStyle ?? true,
|
|
25
|
+
region: config.region
|
|
26
|
+
});
|
|
27
|
+
const proxyConfig = extractProxyConfig(config);
|
|
28
|
+
if (proxyConfig) client.middlewareStack.use(createProxyMiddleware({
|
|
29
|
+
realS3Host: proxyConfig.realS3Host,
|
|
30
|
+
proxyBasePath: proxyConfig.proxyBasePath,
|
|
31
|
+
proxyHost: proxyConfig.proxyHost,
|
|
32
|
+
proxyPort: proxyConfig.proxyPort
|
|
33
|
+
}));
|
|
34
|
+
return client;
|
|
35
|
+
};
|
|
36
|
+
export { createS3Client };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const AWS_RULE_LIMITS: {
|
|
2
|
+
RULE_ID_MAX_LENGTH: number;
|
|
3
|
+
TAG_KEY_MAX_LENGTH: number;
|
|
4
|
+
TAG_VALUE_MAX_LENGTH: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const STATUS_OPTIONS: readonly [{
|
|
7
|
+
readonly value: "Enabled";
|
|
8
|
+
readonly label: "Enabled";
|
|
9
|
+
}, {
|
|
10
|
+
readonly value: "Disabled";
|
|
11
|
+
readonly label: "Disabled";
|
|
12
|
+
}];
|
|
13
|
+
export type FilterType = "none" | "prefix" | "tags" | "and";
|
|
14
|
+
/**
|
|
15
|
+
* Filter data for S3 rules. All fields are present for form handling,
|
|
16
|
+
* but only certain fields are used based on filterType.
|
|
17
|
+
*/
|
|
18
|
+
export interface FilterData {
|
|
19
|
+
filterType: FilterType;
|
|
20
|
+
prefix: string;
|
|
21
|
+
tags: Array<{
|
|
22
|
+
key: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type-safe filter specification for S3 rule building.
|
|
28
|
+
* Each variant only includes the fields relevant to that filter type.
|
|
29
|
+
*/
|
|
30
|
+
export type FilterSpec = {
|
|
31
|
+
type: "none";
|
|
32
|
+
} | {
|
|
33
|
+
type: "prefix";
|
|
34
|
+
prefix: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "tags";
|
|
37
|
+
tags: Array<{
|
|
38
|
+
key: string;
|
|
39
|
+
value: string;
|
|
40
|
+
}>;
|
|
41
|
+
} | {
|
|
42
|
+
type: "and";
|
|
43
|
+
prefix: string;
|
|
44
|
+
tags: Array<{
|
|
45
|
+
key: string;
|
|
46
|
+
value: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Converts form FilterData to type-safe FilterSpec.
|
|
51
|
+
*/
|
|
52
|
+
export declare function toFilterSpec(data: FilterData): FilterSpec;
|
|
53
|
+
export declare function buildS3Filter(data: FilterData): Record<string, unknown>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const AWS_RULE_LIMITS = {
|
|
2
|
+
RULE_ID_MAX_LENGTH: 255,
|
|
3
|
+
TAG_KEY_MAX_LENGTH: 128,
|
|
4
|
+
TAG_VALUE_MAX_LENGTH: 256
|
|
5
|
+
};
|
|
6
|
+
const STATUS_OPTIONS = [
|
|
7
|
+
{
|
|
8
|
+
value: "Enabled",
|
|
9
|
+
label: "Enabled"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
value: "Disabled",
|
|
13
|
+
label: "Disabled"
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
function toFilterSpec(data) {
|
|
17
|
+
switch(data.filterType){
|
|
18
|
+
case "none":
|
|
19
|
+
return {
|
|
20
|
+
type: "none"
|
|
21
|
+
};
|
|
22
|
+
case "prefix":
|
|
23
|
+
return {
|
|
24
|
+
type: "prefix",
|
|
25
|
+
prefix: data.prefix
|
|
26
|
+
};
|
|
27
|
+
case "tags":
|
|
28
|
+
return {
|
|
29
|
+
type: "tags",
|
|
30
|
+
tags: data.tags
|
|
31
|
+
};
|
|
32
|
+
case "and":
|
|
33
|
+
return {
|
|
34
|
+
type: "and",
|
|
35
|
+
prefix: data.prefix,
|
|
36
|
+
tags: data.tags
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function buildS3Filter(data) {
|
|
41
|
+
const spec = toFilterSpec(data);
|
|
42
|
+
switch(spec.type){
|
|
43
|
+
case "none":
|
|
44
|
+
return {};
|
|
45
|
+
case "prefix":
|
|
46
|
+
return {
|
|
47
|
+
Prefix: spec.prefix
|
|
48
|
+
};
|
|
49
|
+
case "tags":
|
|
50
|
+
if (0 === spec.tags.length) return {};
|
|
51
|
+
if (1 === spec.tags.length) return {
|
|
52
|
+
Tag: {
|
|
53
|
+
Key: spec.tags[0].key,
|
|
54
|
+
Value: spec.tags[0].value
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
And: {
|
|
59
|
+
Tags: spec.tags.map((tag)=>({
|
|
60
|
+
Key: tag.key,
|
|
61
|
+
Value: tag.value
|
|
62
|
+
}))
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
case "and":
|
|
66
|
+
{
|
|
67
|
+
const hasPrefix = spec.prefix && "" !== spec.prefix.trim();
|
|
68
|
+
const hasTags = spec.tags.length > 0;
|
|
69
|
+
if (!hasTags && !hasPrefix) return {};
|
|
70
|
+
if (!hasTags && hasPrefix) return {
|
|
71
|
+
Prefix: spec.prefix
|
|
72
|
+
};
|
|
73
|
+
if (hasTags && !hasPrefix) {
|
|
74
|
+
if (1 === spec.tags.length) return {
|
|
75
|
+
Tag: {
|
|
76
|
+
Key: spec.tags[0].key,
|
|
77
|
+
Value: spec.tags[0].value
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
And: {
|
|
82
|
+
Tags: spec.tags.map((tag)=>({
|
|
83
|
+
Key: tag.key,
|
|
84
|
+
Value: tag.value
|
|
85
|
+
}))
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
And: {
|
|
91
|
+
Prefix: spec.prefix,
|
|
92
|
+
Tags: spec.tags.map((tag)=>({
|
|
93
|
+
Key: tag.key,
|
|
94
|
+
Value: tag.value
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export { AWS_RULE_LIMITS, STATUS_OPTIONS, buildS3Filter, toFilterSpec };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFeatures(feature: string): boolean | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useDataBrowserContext } from "../components/index.js";
|
|
2
|
+
function useFeatures(feature) {
|
|
3
|
+
const { getS3Config } = useDataBrowserContext();
|
|
4
|
+
const config = getS3Config();
|
|
5
|
+
return config?.credentials?.features?.includes(feature);
|
|
6
|
+
}
|
|
7
|
+
export { useFeatures };
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scality/data-browser-library",
|
|
3
|
+
"version": "1.0.0-preview.11",
|
|
4
|
+
"description": "A modular React component library for browsing S3 buckets and objects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rslib build",
|
|
19
|
+
"dev": "rslib build --watch",
|
|
20
|
+
"type-check": "tsc --noEmit",
|
|
21
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@aws-sdk/client-s3": "^3.478.0",
|
|
27
|
+
"@aws-sdk/protocol-http": "^3.370.0",
|
|
28
|
+
"@aws-sdk/s3-presigned-post": "^3.888.0",
|
|
29
|
+
"@aws-sdk/s3-request-presigner": "^3.478.0",
|
|
30
|
+
"@hookform/resolvers": "^5.2.2",
|
|
31
|
+
"@monaco-editor/react": "^4.7.0",
|
|
32
|
+
"@tanstack/react-query": "^5.8.0",
|
|
33
|
+
"@tanstack/react-query-devtools": "^5.8.0",
|
|
34
|
+
"@testing-library/user-event": "^14.6.1",
|
|
35
|
+
"joi": "^18.0.1",
|
|
36
|
+
"react-dropzone": "^14.2.0",
|
|
37
|
+
"react-hook-form": "^7.48.0",
|
|
38
|
+
"@scality/zenkoclient": "^2.0.0-preview.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@scality/core-ui": "^0.174.0",
|
|
42
|
+
"react": ">=18.0.0",
|
|
43
|
+
"react-dom": ">=18.0.0",
|
|
44
|
+
"react-router-dom": ">=6.0.0",
|
|
45
|
+
"styled-components": "^5.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@rsbuild/plugin-react": "^1.4.1",
|
|
49
|
+
"@rslib/core": "^0.14.0",
|
|
50
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
51
|
+
"@testing-library/react": "^15.0.6",
|
|
52
|
+
"@testing-library/user-event": "^14.6.1",
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"@types/react": "^18.2.0",
|
|
55
|
+
"@types/react-dom": "^18.2.0",
|
|
56
|
+
"@types/styled-components": "^5.1.34",
|
|
57
|
+
"identity-obj-proxy": "^3.0.0",
|
|
58
|
+
"jest": "^30.0.5",
|
|
59
|
+
"jest-environment-jsdom": "^30.0.5",
|
|
60
|
+
"msw": "^0.28.2",
|
|
61
|
+
"ts-jest": "^29.4.1"
|
|
62
|
+
},
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/scality/data-browser.git",
|
|
66
|
+
"directory": "packages/data-browser-library"
|
|
67
|
+
},
|
|
68
|
+
"keywords": [
|
|
69
|
+
"s3",
|
|
70
|
+
"aws",
|
|
71
|
+
"react",
|
|
72
|
+
"browser",
|
|
73
|
+
"data",
|
|
74
|
+
"scality",
|
|
75
|
+
"tanstack",
|
|
76
|
+
"react-query",
|
|
77
|
+
"component-library"
|
|
78
|
+
],
|
|
79
|
+
"author": "Scality",
|
|
80
|
+
"license": "Apache-2.0",
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
83
|
+
}
|
|
84
|
+
}
|