@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.
Files changed (256) hide show
  1. package/dist/components/Editor.d.ts +12 -0
  2. package/dist/components/Editor.js +28 -0
  3. package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
  4. package/dist/components/__tests__/BucketCreate.test.js +408 -0
  5. package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +1 -0
  6. package/dist/components/__tests__/BucketLifecycleFormPage.test.js +618 -0
  7. package/dist/components/__tests__/BucketLifecycleList.test.d.ts +1 -0
  8. package/dist/components/__tests__/BucketLifecycleList.test.js +325 -0
  9. package/dist/components/__tests__/BucketList.test.d.ts +1 -0
  10. package/dist/components/__tests__/BucketList.test.js +415 -0
  11. package/dist/components/__tests__/BucketNotificationCreatePage.test.d.ts +1 -0
  12. package/dist/components/__tests__/BucketNotificationCreatePage.test.js +316 -0
  13. package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
  14. package/dist/components/__tests__/BucketOverview.test.js +769 -0
  15. package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
  16. package/dist/components/__tests__/BucketPolicyPage.test.js +268 -0
  17. package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +1 -0
  18. package/dist/components/__tests__/BucketReplicationFormPage.test.js +1757 -0
  19. package/dist/components/__tests__/BucketReplicationList.test.d.ts +1 -0
  20. package/dist/components/__tests__/BucketReplicationList.test.js +344 -0
  21. package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
  22. package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
  23. package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
  24. package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
  25. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.d.ts +1 -0
  26. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +196 -0
  27. package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
  28. package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
  29. package/dist/components/__tests__/EmptyBucketButton.test.d.ts +1 -0
  30. package/dist/components/__tests__/EmptyBucketButton.test.js +302 -0
  31. package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
  32. package/dist/components/__tests__/MetadataSearch.test.js +201 -0
  33. package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
  34. package/dist/components/__tests__/ObjectList.test.js +283 -0
  35. package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
  36. package/dist/components/__tests__/UploadButton.test.js +144 -0
  37. package/dist/components/buckets/BucketCreate.d.ts +49 -0
  38. package/dist/components/buckets/BucketCreate.js +237 -0
  39. package/dist/components/buckets/BucketDetails.d.ts +1 -0
  40. package/dist/components/buckets/BucketDetails.js +106 -0
  41. package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
  42. package/dist/components/buckets/BucketLifecycleFormPage.js +1085 -0
  43. package/dist/components/buckets/BucketLifecycleList.d.ts +10 -0
  44. package/dist/components/buckets/BucketLifecycleList.js +270 -0
  45. package/dist/components/buckets/BucketList.d.ts +15 -0
  46. package/dist/components/buckets/BucketList.js +146 -0
  47. package/dist/components/buckets/BucketLocation.d.ts +3 -0
  48. package/dist/components/buckets/BucketLocation.js +16 -0
  49. package/dist/components/buckets/BucketOverview.d.ts +88 -0
  50. package/dist/components/buckets/BucketOverview.js +291 -0
  51. package/dist/components/buckets/BucketPage.d.ts +2 -0
  52. package/dist/components/buckets/BucketPage.js +47 -0
  53. package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
  54. package/dist/components/buckets/BucketPolicyButton.js +18 -0
  55. package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
  56. package/dist/components/buckets/BucketPolicyPage.js +236 -0
  57. package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
  58. package/dist/components/buckets/BucketReplicationFormPage.js +834 -0
  59. package/dist/components/buckets/BucketReplicationList.d.ts +11 -0
  60. package/dist/components/buckets/BucketReplicationList.js +189 -0
  61. package/dist/components/buckets/BucketVersioning.d.ts +4 -0
  62. package/dist/components/buckets/BucketVersioning.js +73 -0
  63. package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
  64. package/dist/components/buckets/DeleteBucketButton.js +78 -0
  65. package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +18 -0
  66. package/dist/components/buckets/DeleteBucketConfigRuleButton.js +53 -0
  67. package/dist/components/buckets/EmptyBucketButton.d.ts +5 -0
  68. package/dist/components/buckets/EmptyBucketButton.js +232 -0
  69. package/dist/components/buckets/EmptyBucketSummary.d.ts +9 -0
  70. package/dist/components/buckets/EmptyBucketSummary.js +60 -0
  71. package/dist/components/buckets/EmptyBucketSummaryList.d.ts +13 -0
  72. package/dist/components/buckets/EmptyBucketSummaryList.js +140 -0
  73. package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
  74. package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
  75. package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +1 -0
  76. package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +234 -0
  77. package/dist/components/buckets/notifications/EventsSection.d.ts +1 -0
  78. package/dist/components/buckets/notifications/EventsSection.js +123 -0
  79. package/dist/components/buckets/notifications/events.d.ts +12 -0
  80. package/dist/components/buckets/notifications/events.js +27 -0
  81. package/dist/components/index.d.ts +21 -0
  82. package/dist/components/index.js +22 -0
  83. package/dist/components/layouts/ArrowNavigation.d.ts +4 -0
  84. package/dist/components/layouts/ArrowNavigation.js +16 -0
  85. package/dist/components/layouts/BrowserPageLayout.d.ts +12 -0
  86. package/dist/components/layouts/BrowserPageLayout.js +51 -0
  87. package/dist/components/objects/CreateFolderButton.d.ts +29 -0
  88. package/dist/components/objects/CreateFolderButton.js +118 -0
  89. package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
  90. package/dist/components/objects/DeleteObjectButton.js +191 -0
  91. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
  92. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +356 -0
  93. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
  94. package/dist/components/objects/ObjectDetails/ObjectSummary.js +241 -0
  95. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
  96. package/dist/components/objects/ObjectDetails/ObjectTags.js +272 -0
  97. package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
  98. package/dist/components/objects/ObjectDetails/index.js +75 -0
  99. package/dist/components/objects/ObjectList.d.ts +40 -0
  100. package/dist/components/objects/ObjectList.js +453 -0
  101. package/dist/components/objects/ObjectLock/EditRetentionButton.d.ts +4 -0
  102. package/dist/components/objects/ObjectLock/EditRetentionButton.js +32 -0
  103. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.d.ts +3 -0
  104. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +211 -0
  105. package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +9 -0
  106. package/dist/components/objects/ObjectLock/ObjectLockSettings.js +158 -0
  107. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +8 -0
  108. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +39 -0
  109. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.d.ts +1 -0
  110. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +204 -0
  111. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.d.ts +1 -0
  112. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +374 -0
  113. package/dist/components/objects/ObjectPage.d.ts +1 -0
  114. package/dist/components/objects/ObjectPage.js +45 -0
  115. package/dist/components/objects/UploadButton.d.ts +34 -0
  116. package/dist/components/objects/UploadButton.js +229 -0
  117. package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
  118. package/dist/components/providers/DataBrowserProvider.js +42 -0
  119. package/dist/components/search/MetadataSearch.d.ts +5 -0
  120. package/dist/components/search/MetadataSearch.js +162 -0
  121. package/dist/components/search/SearchHints.d.ts +8 -0
  122. package/dist/components/search/SearchHints.js +21 -0
  123. package/dist/components/ui/ArrayFieldActions.d.ts +36 -0
  124. package/dist/components/ui/ArrayFieldActions.js +43 -0
  125. package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +16 -0
  126. package/dist/components/ui/ConfirmDeleteRuleModal.js +43 -0
  127. package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
  128. package/dist/components/ui/DeleteObjectModalContent.js +71 -0
  129. package/dist/components/ui/FilterFormSection.d.ts +44 -0
  130. package/dist/components/ui/FilterFormSection.js +159 -0
  131. package/dist/components/ui/Search.elements.d.ts +17 -0
  132. package/dist/components/ui/Search.elements.js +59 -0
  133. package/dist/components/ui/Table.elements.d.ts +36 -0
  134. package/dist/components/ui/Table.elements.js +87 -0
  135. package/dist/config/factory.d.ts +63 -0
  136. package/dist/config/factory.js +74 -0
  137. package/dist/config/types.d.ts +46 -0
  138. package/dist/config/types.js +0 -0
  139. package/dist/hooks/__tests__/useISVBucketDetection.test.d.ts +1 -0
  140. package/dist/hooks/__tests__/useISVBucketDetection.test.js +188 -0
  141. package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
  142. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
  143. package/dist/hooks/bucketConfiguration.d.ts +168 -0
  144. package/dist/hooks/bucketConfiguration.js +67 -0
  145. package/dist/hooks/bucketOperations.d.ts +36 -0
  146. package/dist/hooks/bucketOperations.js +12 -0
  147. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
  148. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
  149. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
  150. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
  151. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
  152. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
  153. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
  154. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
  155. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
  156. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +179 -0
  157. package/dist/hooks/factories/index.d.ts +18 -0
  158. package/dist/hooks/factories/index.js +5 -0
  159. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
  160. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
  161. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
  162. package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
  163. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
  164. package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
  165. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
  166. package/dist/hooks/factories/useCreateS3QueryHook.js +51 -0
  167. package/dist/hooks/index.d.ts +13 -0
  168. package/dist/hooks/index.js +13 -0
  169. package/dist/hooks/loginOperations.d.ts +21 -0
  170. package/dist/hooks/loginOperations.js +9 -0
  171. package/dist/hooks/objectOperations.d.ts +190 -0
  172. package/dist/hooks/objectOperations.js +67 -0
  173. package/dist/hooks/presignedOperations.d.ts +73 -0
  174. package/dist/hooks/presignedOperations.js +72 -0
  175. package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
  176. package/dist/hooks/useBatchObjectLegalHold.js +45 -0
  177. package/dist/hooks/useDeleteBucketConfigRule.d.ts +26 -0
  178. package/dist/hooks/useDeleteBucketConfigRule.js +46 -0
  179. package/dist/hooks/useEmptyBucket.d.ts +27 -0
  180. package/dist/hooks/useEmptyBucket.js +116 -0
  181. package/dist/hooks/useISVBucketDetection.d.ts +15 -0
  182. package/dist/hooks/useISVBucketDetection.js +27 -0
  183. package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
  184. package/dist/hooks/useIsBucketEmpty.js +36 -0
  185. package/dist/hooks/useLoginMutation.d.ts +21 -0
  186. package/dist/hooks/useLoginMutation.js +9 -0
  187. package/dist/hooks/useS3Client.d.ts +1 -0
  188. package/dist/hooks/useS3Client.js +13 -0
  189. package/dist/hooks/useTableRowSelection.d.ts +9 -0
  190. package/dist/hooks/useTableRowSelection.js +45 -0
  191. package/dist/index.d.ts +6 -0
  192. package/dist/index.js +6 -0
  193. package/dist/schemas/bucketPolicySchema.json +321 -0
  194. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
  195. package/dist/test/msw/handlers/deleteBucket.js +14 -0
  196. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
  197. package/dist/test/msw/handlers/getBucketAcl.js +96 -0
  198. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
  199. package/dist/test/msw/handlers/getBucketLocation.js +23 -0
  200. package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
  201. package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
  202. package/dist/test/msw/handlers/headObject.d.ts +1 -0
  203. package/dist/test/msw/handlers/headObject.js +17 -0
  204. package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
  205. package/dist/test/msw/handlers/listBuckets.js +24 -0
  206. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
  207. package/dist/test/msw/handlers/listObjectVersions.js +83 -0
  208. package/dist/test/msw/handlers/listObjects.d.ts +1 -0
  209. package/dist/test/msw/handlers/listObjects.js +66 -0
  210. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
  211. package/dist/test/msw/handlers/objectLegalHold.js +24 -0
  212. package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
  213. package/dist/test/msw/handlers/objectRetention.js +27 -0
  214. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
  215. package/dist/test/msw/handlers/putBucketAcl.js +18 -0
  216. package/dist/test/msw/handlers/putObject.d.ts +1 -0
  217. package/dist/test/msw/handlers/putObject.js +16 -0
  218. package/dist/test/msw/handlers.d.ts +4 -0
  219. package/dist/test/msw/handlers.js +109 -0
  220. package/dist/test/msw/index.d.ts +2 -0
  221. package/dist/test/msw/index.js +3 -0
  222. package/dist/test/msw/server.d.ts +4 -0
  223. package/dist/test/msw/server.js +20 -0
  224. package/dist/test/msw/utils.d.ts +2 -0
  225. package/dist/test/msw/utils.js +13 -0
  226. package/dist/test/setup.d.ts +1 -0
  227. package/dist/test/setup.js +90 -0
  228. package/dist/test/testUtils.d.ts +181 -0
  229. package/dist/test/testUtils.js +310 -0
  230. package/dist/test/utils/errorHandling.test.d.ts +1 -0
  231. package/dist/test/utils/errorHandling.test.js +423 -0
  232. package/dist/types/index.d.ts +51 -0
  233. package/dist/types/index.js +0 -0
  234. package/dist/utils/constants.d.ts +12 -0
  235. package/dist/utils/constants.js +9 -0
  236. package/dist/utils/deletion/index.d.ts +2 -0
  237. package/dist/utils/deletion/index.js +2 -0
  238. package/dist/utils/deletion/messages.d.ts +5 -0
  239. package/dist/utils/deletion/messages.js +29 -0
  240. package/dist/utils/deletion/types.d.ts +11 -0
  241. package/dist/utils/deletion/types.js +0 -0
  242. package/dist/utils/errorHandling.d.ts +63 -0
  243. package/dist/utils/errorHandling.js +84 -0
  244. package/dist/utils/hooks.d.ts +2 -0
  245. package/dist/utils/hooks.js +26 -0
  246. package/dist/utils/index.d.ts +4 -0
  247. package/dist/utils/index.js +4 -0
  248. package/dist/utils/proxyMiddleware.d.ts +18 -0
  249. package/dist/utils/proxyMiddleware.js +56 -0
  250. package/dist/utils/s3Client.d.ts +5 -0
  251. package/dist/utils/s3Client.js +36 -0
  252. package/dist/utils/s3RuleUtils.d.ts +53 -0
  253. package/dist/utils/s3RuleUtils.js +101 -0
  254. package/dist/utils/useFeatures.d.ts +1 -0
  255. package/dist/utils/useFeatures.js +7 -0
  256. 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,7 @@
1
+ interface UseIsBucketEmptyResult {
2
+ isEmpty: boolean | null;
3
+ isLoading: boolean;
4
+ error: Error | null;
5
+ }
6
+ export declare const useIsBucketEmpty: (bucketName: string) => UseIsBucketEmptyResult;
7
+ export {};
@@ -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,9 @@
1
+ export declare function useTableRowSelection<TRow extends {
2
+ ID?: string;
3
+ }>(tableData: TRow[], autoSelectFirst?: boolean): {
4
+ selectedId: string | null;
5
+ onRowSelected: (row: {
6
+ original: TRow;
7
+ }) => void;
8
+ clearSelection: () => void;
9
+ };
@@ -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 };
@@ -0,0 +1,6 @@
1
+ export * from "./components";
2
+ export * from "./hooks";
3
+ export * from "./types";
4
+ export * from "./utils";
5
+ export * from "./config/factory";
6
+ export * from "./config/types";
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./components/index.js";
2
+ export * from "./hooks/index.js";
3
+ export * from "./types/index.js";
4
+ export * from "./utils/index.js";
5
+ export * from "./config/factory.js";
6
+ export * from "./config/types.js";