@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,45 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useS3Client } from "./useS3Client.js";
|
|
3
|
+
import { GetObjectLegalHoldCommand } from "@aws-sdk/client-s3";
|
|
4
|
+
const useBatchObjectLegalHold = (bucketName, objects, enabled = true)=>{
|
|
5
|
+
const s3Client = useS3Client();
|
|
6
|
+
return useQuery({
|
|
7
|
+
queryKey: [
|
|
8
|
+
"BatchObjectLegalHold",
|
|
9
|
+
bucketName,
|
|
10
|
+
...objects.map((obj)=>`${obj.Key}:${obj.VersionId || "null"}`)
|
|
11
|
+
],
|
|
12
|
+
queryFn: async ()=>{
|
|
13
|
+
const results = {};
|
|
14
|
+
await Promise.allSettled(objects.map(async (obj)=>{
|
|
15
|
+
const key = `${obj.Key}:${obj.VersionId || "null"}`;
|
|
16
|
+
try {
|
|
17
|
+
const command = new GetObjectLegalHoldCommand({
|
|
18
|
+
Bucket: bucketName,
|
|
19
|
+
Key: obj.Key,
|
|
20
|
+
...obj.VersionId && {
|
|
21
|
+
VersionId: obj.VersionId
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const response = await s3Client.send(command);
|
|
25
|
+
results[key] = {
|
|
26
|
+
key: obj.Key,
|
|
27
|
+
versionId: obj.VersionId,
|
|
28
|
+
isLegalHoldEnabled: response.LegalHold?.Status === "ON"
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
results[key] = {
|
|
32
|
+
key: obj.Key,
|
|
33
|
+
versionId: obj.VersionId,
|
|
34
|
+
isLegalHoldEnabled: false
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
return results;
|
|
39
|
+
},
|
|
40
|
+
enabled: enabled && objects.length > 0,
|
|
41
|
+
staleTime: 30000,
|
|
42
|
+
refetchOnWindowFocus: false
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export { useBatchObjectLegalHold };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
interface BucketCommandInput {
|
|
3
|
+
Bucket: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface UseDeleteBucketConfigRuleOptions<TRule extends {
|
|
6
|
+
ID?: string;
|
|
7
|
+
}, TUpdateInput extends BucketCommandInput, TUpdateOutput, TDeleteInput extends BucketCommandInput, TDeleteOutput, TError = unknown> {
|
|
8
|
+
bucketName: string;
|
|
9
|
+
ruleId: string;
|
|
10
|
+
rules: TRule[];
|
|
11
|
+
updateMutation: UseMutationResult<TUpdateOutput, TError, TUpdateInput, unknown>;
|
|
12
|
+
deleteMutation: UseMutationResult<TDeleteOutput, TError, TDeleteInput, unknown>;
|
|
13
|
+
buildUpdateInput: (remainingRules: TRule[]) => Omit<TUpdateInput, "Bucket">;
|
|
14
|
+
successMessage?: string;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
onSuccess?: () => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseDeleteBucketConfigRuleReturn {
|
|
20
|
+
isDeleting: boolean;
|
|
21
|
+
deleteRule: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function useDeleteBucketConfigRule<TRule extends {
|
|
24
|
+
ID?: string;
|
|
25
|
+
}, TUpdateInput extends BucketCommandInput = BucketCommandInput, TUpdateOutput = unknown, TDeleteInput extends BucketCommandInput = BucketCommandInput, TDeleteOutput = unknown, TError = unknown>({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage, errorMessage, onSuccess, onError, }: UseDeleteBucketConfigRuleOptions<TRule, TUpdateInput, TUpdateOutput, TDeleteInput, TDeleteOutput, TError>): UseDeleteBucketConfigRuleReturn;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useToast } from "@scality/core-ui";
|
|
2
|
+
function useDeleteBucketConfigRule({ bucketName, ruleId, rules, updateMutation, deleteMutation, buildUpdateInput, successMessage = "Rule deleted successfully", errorMessage = "Failed to delete rule", onSuccess, onError }) {
|
|
3
|
+
const { showToast } = useToast();
|
|
4
|
+
const { mutate: updateConfig, status: updateStatus } = updateMutation;
|
|
5
|
+
const { mutate: deleteConfig, status: deleteStatus } = deleteMutation;
|
|
6
|
+
const isDeleting = "pending" === updateStatus || "pending" === deleteStatus;
|
|
7
|
+
const deleteRule = ()=>{
|
|
8
|
+
const remainingRules = rules.filter((rule)=>rule.ID !== ruleId);
|
|
9
|
+
const handleSuccess = ()=>{
|
|
10
|
+
showToast({
|
|
11
|
+
open: true,
|
|
12
|
+
message: successMessage,
|
|
13
|
+
status: "success"
|
|
14
|
+
});
|
|
15
|
+
onSuccess?.();
|
|
16
|
+
};
|
|
17
|
+
const handleError = (error)=>{
|
|
18
|
+
const displayMessage = error instanceof Error && error.message ? error.message : errorMessage;
|
|
19
|
+
const errorToReport = error instanceof Error ? error : new Error(displayMessage);
|
|
20
|
+
showToast({
|
|
21
|
+
open: true,
|
|
22
|
+
message: displayMessage,
|
|
23
|
+
status: "error"
|
|
24
|
+
});
|
|
25
|
+
onError?.(errorToReport);
|
|
26
|
+
};
|
|
27
|
+
if (0 === remainingRules.length) deleteConfig({
|
|
28
|
+
Bucket: bucketName
|
|
29
|
+
}, {
|
|
30
|
+
onSuccess: handleSuccess,
|
|
31
|
+
onError: handleError
|
|
32
|
+
});
|
|
33
|
+
else updateConfig({
|
|
34
|
+
Bucket: bucketName,
|
|
35
|
+
...buildUpdateInput(remainingRules)
|
|
36
|
+
}, {
|
|
37
|
+
onSuccess: handleSuccess,
|
|
38
|
+
onError: handleError
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
isDeleting,
|
|
43
|
+
deleteRule
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export { useDeleteBucketConfigRule };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface EmptyBucketResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
deletedCount: number;
|
|
4
|
+
errors: Array<{
|
|
5
|
+
key: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}>;
|
|
9
|
+
limitReached: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface UseEmptyBucketOptions {
|
|
12
|
+
maxObjects?: number;
|
|
13
|
+
maxKeysPerList?: number;
|
|
14
|
+
bypassGovernanceRetention?: boolean;
|
|
15
|
+
onProgress?: (deletedCount: number, totalAttempted: number) => void;
|
|
16
|
+
onSuccess?: (result: EmptyBucketResult) => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseEmptyBucketReturn {
|
|
20
|
+
emptyBucket: (bucketName: string) => Promise<EmptyBucketResult | null>;
|
|
21
|
+
isEmptying: boolean;
|
|
22
|
+
error: Error | null;
|
|
23
|
+
result: EmptyBucketResult | null;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const useEmptyBucket: (options?: UseEmptyBucketOptions) => UseEmptyBucketReturn;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useS3Client } from "./useS3Client.js";
|
|
4
|
+
import { DeleteObjectsCommand, ListObjectVersionsCommand } from "@aws-sdk/client-s3";
|
|
5
|
+
const useEmptyBucket = (options = {})=>{
|
|
6
|
+
const { maxObjects = 20000, maxKeysPerList = 1000, bypassGovernanceRetention = true, onProgress, onSuccess, onError } = options;
|
|
7
|
+
const [isEmptying, setIsEmptying] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const [result, setResult] = useState(null);
|
|
10
|
+
const s3Client = useS3Client();
|
|
11
|
+
const queryClient = useQueryClient();
|
|
12
|
+
const emptyBucket = useCallback(async (bucketName)=>{
|
|
13
|
+
setIsEmptying(true);
|
|
14
|
+
setError(null);
|
|
15
|
+
setResult(null);
|
|
16
|
+
try {
|
|
17
|
+
let deletedCount = 0;
|
|
18
|
+
let totalAttempted = 0;
|
|
19
|
+
let keyMarker;
|
|
20
|
+
let versionIdMarker;
|
|
21
|
+
const allErrors = [];
|
|
22
|
+
let limitReached = false;
|
|
23
|
+
while(totalAttempted < maxObjects){
|
|
24
|
+
const listCommand = new ListObjectVersionsCommand({
|
|
25
|
+
Bucket: bucketName,
|
|
26
|
+
MaxKeys: maxKeysPerList,
|
|
27
|
+
KeyMarker: keyMarker,
|
|
28
|
+
VersionIdMarker: versionIdMarker
|
|
29
|
+
});
|
|
30
|
+
const listResponse = await s3Client.send(listCommand);
|
|
31
|
+
const objectsToDelete = [];
|
|
32
|
+
if (listResponse.Versions) objectsToDelete.push(...listResponse.Versions.filter((v)=>v.Key).map((v)=>({
|
|
33
|
+
Key: v.Key,
|
|
34
|
+
VersionId: v.VersionId
|
|
35
|
+
})));
|
|
36
|
+
if (listResponse.DeleteMarkers) objectsToDelete.push(...listResponse.DeleteMarkers.filter((dm)=>dm.Key).map((dm)=>({
|
|
37
|
+
Key: dm.Key,
|
|
38
|
+
VersionId: dm.VersionId
|
|
39
|
+
})));
|
|
40
|
+
if (0 === objectsToDelete.length) break;
|
|
41
|
+
const deleteCommand = new DeleteObjectsCommand({
|
|
42
|
+
Bucket: bucketName,
|
|
43
|
+
Delete: {
|
|
44
|
+
Objects: objectsToDelete
|
|
45
|
+
},
|
|
46
|
+
BypassGovernanceRetention: bypassGovernanceRetention
|
|
47
|
+
});
|
|
48
|
+
const deleteResponse = await s3Client.send(deleteCommand);
|
|
49
|
+
const successCount = deleteResponse.Deleted?.length || 0;
|
|
50
|
+
deletedCount += successCount;
|
|
51
|
+
totalAttempted += objectsToDelete.length;
|
|
52
|
+
if (deleteResponse.Errors) allErrors.push(...deleteResponse.Errors.map((error)=>({
|
|
53
|
+
key: error.Key || "unknown",
|
|
54
|
+
code: error.Code,
|
|
55
|
+
message: error.Message
|
|
56
|
+
})));
|
|
57
|
+
onProgress?.(deletedCount, totalAttempted);
|
|
58
|
+
if (!listResponse.IsTruncated) break;
|
|
59
|
+
if (totalAttempted >= maxObjects) {
|
|
60
|
+
limitReached = true;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
keyMarker = listResponse.NextKeyMarker;
|
|
64
|
+
versionIdMarker = listResponse.NextVersionIdMarker;
|
|
65
|
+
}
|
|
66
|
+
const bucketResult = {
|
|
67
|
+
success: 0 === allErrors.length,
|
|
68
|
+
deletedCount,
|
|
69
|
+
errors: allErrors,
|
|
70
|
+
limitReached
|
|
71
|
+
};
|
|
72
|
+
setResult(bucketResult);
|
|
73
|
+
queryClient.invalidateQueries({
|
|
74
|
+
queryKey: [
|
|
75
|
+
"ListObjects"
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
queryClient.invalidateQueries({
|
|
79
|
+
queryKey: [
|
|
80
|
+
"ListObjectVersions"
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
onSuccess?.(bucketResult);
|
|
84
|
+
return bucketResult;
|
|
85
|
+
} catch (err) {
|
|
86
|
+
const errorObj = err instanceof Error ? err : new Error("Failed to empty bucket");
|
|
87
|
+
setError(errorObj);
|
|
88
|
+
onError?.(errorObj);
|
|
89
|
+
return null;
|
|
90
|
+
} finally{
|
|
91
|
+
setIsEmptying(false);
|
|
92
|
+
}
|
|
93
|
+
}, [
|
|
94
|
+
s3Client,
|
|
95
|
+
maxObjects,
|
|
96
|
+
maxKeysPerList,
|
|
97
|
+
bypassGovernanceRetention,
|
|
98
|
+
onProgress,
|
|
99
|
+
onSuccess,
|
|
100
|
+
onError,
|
|
101
|
+
queryClient
|
|
102
|
+
]);
|
|
103
|
+
const reset = useCallback(()=>{
|
|
104
|
+
setIsEmptying(false);
|
|
105
|
+
setError(null);
|
|
106
|
+
setResult(null);
|
|
107
|
+
}, []);
|
|
108
|
+
return {
|
|
109
|
+
emptyBucket,
|
|
110
|
+
isEmptying,
|
|
111
|
+
error,
|
|
112
|
+
result,
|
|
113
|
+
reset
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export { useEmptyBucket };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to detect if a bucket is managed by any ISV (Veeam or Commvault)
|
|
3
|
+
* Returns comprehensive information about ISV bucket status
|
|
4
|
+
*
|
|
5
|
+
* This hook fetches bucket tags once and derives all ISV-related states from it,
|
|
6
|
+
* avoiding multiple API calls for the same data.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useISVBucketStatus: (bucketName: string) => {
|
|
9
|
+
isVeeamBucket: boolean;
|
|
10
|
+
isCommvaultBucket: boolean;
|
|
11
|
+
isISVManaged: boolean;
|
|
12
|
+
isvApplication: string | undefined;
|
|
13
|
+
isLoading: boolean | undefined;
|
|
14
|
+
bucketTagsStatus: "error" | "success" | "pending";
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useGetBucketTagging } from "./bucketConfiguration.js";
|
|
2
|
+
import { useFeatures } from "../utils/useFeatures.js";
|
|
3
|
+
import { BUCKET_TAG_APPLICATION, BUCKET_TAG_VEEAM_APPLICATION, COMMVAULT_APPLICATION, VEEAM_BACKUP_REPLICATION, VEEAM_OFFICE_365, VEEAM_OFFICE_365_V8, VEEAM_VBO_APPLICATION } from "../utils/constants.js";
|
|
4
|
+
const useISVBucketStatus = (bucketName)=>{
|
|
5
|
+
const isISVFeatureEnabled = useFeatures("ISV");
|
|
6
|
+
const { data: bucketTags, status: bucketTagsStatus } = useGetBucketTagging({
|
|
7
|
+
Bucket: bucketName
|
|
8
|
+
}, {
|
|
9
|
+
enabled: isISVFeatureEnabled
|
|
10
|
+
});
|
|
11
|
+
const veeamTagApplication = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_VEEAM_APPLICATION)?.Value;
|
|
12
|
+
const ISVApplicationTag = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_APPLICATION)?.Value;
|
|
13
|
+
const isVeeamBucket = veeamTagApplication === VEEAM_BACKUP_REPLICATION || veeamTagApplication === VEEAM_OFFICE_365 || veeamTagApplication === VEEAM_OFFICE_365_V8;
|
|
14
|
+
const isISVBucketTagAsVeeam = ISVApplicationTag === VEEAM_BACKUP_REPLICATION || ISVApplicationTag === VEEAM_VBO_APPLICATION;
|
|
15
|
+
const isCommvaultBucket = ISVApplicationTag === COMMVAULT_APPLICATION;
|
|
16
|
+
const isVeeam = isVeeamBucket || isISVBucketTagAsVeeam;
|
|
17
|
+
const isISVManaged = isVeeam || isCommvaultBucket;
|
|
18
|
+
return {
|
|
19
|
+
isVeeamBucket: isVeeam,
|
|
20
|
+
isCommvaultBucket,
|
|
21
|
+
isISVManaged,
|
|
22
|
+
isvApplication: isCommvaultBucket ? "Commvault" : isVeeam ? "Veeam" : void 0,
|
|
23
|
+
isLoading: isISVFeatureEnabled && "pending" === bucketTagsStatus,
|
|
24
|
+
bucketTagsStatus
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export { useISVBucketStatus };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useListObjects } from "./objectOperations.js";
|
|
3
|
+
const isInfiniteData = (data)=>null != data && "object" == typeof data && "pages" in data && Array.isArray(data.pages);
|
|
4
|
+
const useIsBucketEmpty = (bucketName)=>{
|
|
5
|
+
const { data, status, error } = useListObjects({
|
|
6
|
+
Bucket: bucketName,
|
|
7
|
+
MaxKeys: 1,
|
|
8
|
+
Delimiter: "/"
|
|
9
|
+
}, {
|
|
10
|
+
enabled: !!bucketName
|
|
11
|
+
});
|
|
12
|
+
const isEmpty = useMemo(()=>{
|
|
13
|
+
if ("pending" === status || !data) return null;
|
|
14
|
+
if (!isInfiniteData(data)) return null;
|
|
15
|
+
for (const page of data.pages){
|
|
16
|
+
if (page?.Contents && page.Contents.length > 0) {
|
|
17
|
+
const validObjects = page.Contents.filter((obj)=>obj?.Key);
|
|
18
|
+
if (validObjects.length > 0) return false;
|
|
19
|
+
}
|
|
20
|
+
if (page?.CommonPrefixes && page.CommonPrefixes.length > 0) {
|
|
21
|
+
const validPrefixes = page.CommonPrefixes.filter((cp)=>cp?.Prefix);
|
|
22
|
+
if (validPrefixes.length > 0) return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}, [
|
|
27
|
+
data,
|
|
28
|
+
status
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
isEmpty,
|
|
32
|
+
isLoading: "pending" === status,
|
|
33
|
+
error: error instanceof Error ? error : null
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export { useIsBucketEmpty };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3 Login Authentication Hook
|
|
3
|
+
*
|
|
4
|
+
* This file contains the login authentication hook using the factory pattern
|
|
5
|
+
* for consistency with other S3 operations.
|
|
6
|
+
*/
|
|
7
|
+
import { S3BrowserConfig, S3Credentials } from "../types";
|
|
8
|
+
export type LoginConfig = S3BrowserConfig & {
|
|
9
|
+
credentials: S3Credentials;
|
|
10
|
+
};
|
|
11
|
+
export interface LoginMutationResult {
|
|
12
|
+
config: LoginConfig;
|
|
13
|
+
authenticated: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Hook for S3 authentication using react-query mutation.
|
|
17
|
+
* Validates credentials and establishes S3 session.
|
|
18
|
+
*
|
|
19
|
+
* Uses the specialized login factory pattern for consistency with other S3 operations.
|
|
20
|
+
*/
|
|
21
|
+
export declare const useLoginMutation: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<LoginMutationResult, import("..").EnhancedS3Error, LoginConfig, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<LoginMutationResult, import("..").EnhancedS3Error, LoginConfig>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useCreateS3LoginHook } from "./factories/index.js";
|
|
2
|
+
class LoginAuthenticationCommand {
|
|
3
|
+
input;
|
|
4
|
+
constructor(input){
|
|
5
|
+
this.input = input;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const useLoginMutation = useCreateS3LoginHook(LoginAuthenticationCommand, "S3 Authentication");
|
|
9
|
+
export { useLoginMutation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useS3Client: () => import("@aws-sdk/client-s3").S3Client;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
|
|
3
|
+
import { createS3Client } from "../utils/s3Client.js";
|
|
4
|
+
const useS3Client = ()=>{
|
|
5
|
+
const { getS3Config } = useDataBrowserContext();
|
|
6
|
+
return useMemo(()=>{
|
|
7
|
+
const config = getS3Config();
|
|
8
|
+
return createS3Client(config);
|
|
9
|
+
}, [
|
|
10
|
+
getS3Config
|
|
11
|
+
]);
|
|
12
|
+
};
|
|
13
|
+
export { useS3Client };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
function useTableRowSelection(tableData, autoSelectFirst = true) {
|
|
3
|
+
const [selectedRuleId, setSelectedRuleId] = useState(null);
|
|
4
|
+
useEffect(()=>{
|
|
5
|
+
if (0 === tableData.length) {
|
|
6
|
+
if (null !== selectedRuleId) setSelectedRuleId(null);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (!autoSelectFirst) {
|
|
10
|
+
if (null !== selectedRuleId) {
|
|
11
|
+
const stillExists = tableData.some((row)=>row.ID === selectedRuleId);
|
|
12
|
+
if (!stillExists) setSelectedRuleId(null);
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (null === selectedRuleId) {
|
|
17
|
+
const firstRowId = tableData[0]?.ID;
|
|
18
|
+
if (firstRowId) setSelectedRuleId(firstRowId);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const stillExists = tableData.some((row)=>row.ID === selectedRuleId);
|
|
22
|
+
if (!stillExists) {
|
|
23
|
+
const firstRowId = tableData[0]?.ID;
|
|
24
|
+
firstRowId ? setSelectedRuleId(firstRowId) : setSelectedRuleId(null);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
autoSelectFirst,
|
|
28
|
+
tableData,
|
|
29
|
+
selectedRuleId
|
|
30
|
+
]);
|
|
31
|
+
const onRowSelected = useCallback((row)=>{
|
|
32
|
+
if (row.original.ID && row.original.ID !== selectedRuleId) setSelectedRuleId(row.original.ID);
|
|
33
|
+
}, [
|
|
34
|
+
selectedRuleId
|
|
35
|
+
]);
|
|
36
|
+
const clearSelection = useCallback(()=>{
|
|
37
|
+
setSelectedRuleId(null);
|
|
38
|
+
}, []);
|
|
39
|
+
return {
|
|
40
|
+
selectedId: selectedRuleId,
|
|
41
|
+
onRowSelected,
|
|
42
|
+
clearSelection
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export { useTableRowSelection };
|
package/dist/index.d.ts
ADDED