@scality/data-browser-library 1.0.0-preview.8 → 1.0.1
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/DataBrowserUI.d.ts +12 -0
- package/dist/components/DataBrowserUI.js +99 -0
- package/dist/components/Editor.d.ts +1 -1
- package/dist/components/Editor.js +3 -3
- package/dist/components/__tests__/BucketAccessor.test.js +214 -0
- package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
- package/dist/components/__tests__/BucketCreate.test.d.ts +1 -0
- package/dist/components/__tests__/BucketCreate.test.js +574 -0
- package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
- package/dist/components/__tests__/BucketDetails.test.js +421 -0
- package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +14 -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.js +495 -81
- package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
- package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
- package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
- package/dist/components/__tests__/BucketOverview.test.js +484 -179
- package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
- package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +16 -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.js +56 -56
- package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
- 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.js +64 -64
- 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.js +65 -65
- package/dist/components/__tests__/ObjectList.test.js +741 -240
- package/dist/components/__tests__/UploadButton.test.js +45 -45
- package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/components/breadcrumb/Breadcrumb.js +37 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
- package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
- package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
- package/dist/components/breadcrumb/index.d.ts +8 -0
- package/dist/components/breadcrumb/index.js +4 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
- package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
- package/dist/components/buckets/BucketAccessor.d.ts +2 -0
- package/dist/components/buckets/BucketAccessor.js +125 -0
- package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
- package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
- package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
- package/dist/components/buckets/BucketCorsPage.js +234 -0
- package/dist/components/buckets/BucketCreate.d.ts +50 -0
- package/dist/components/buckets/BucketCreate.js +279 -0
- package/dist/components/buckets/BucketDetails.d.ts +42 -0
- package/dist/components/buckets/BucketDetails.js +256 -40
- package/dist/components/buckets/BucketLifecycleFormPage.d.ts +15 -0
- package/dist/components/buckets/BucketLifecycleFormPage.js +1086 -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 +6 -4
- package/dist/components/buckets/BucketList.js +161 -94
- package/dist/components/buckets/BucketLocation.js +4 -4
- package/dist/components/buckets/BucketOverview.d.ts +86 -5
- package/dist/components/buckets/BucketOverview.js +481 -192
- package/dist/components/buckets/BucketPage.js +44 -22
- package/dist/components/buckets/BucketPolicyPage.js +155 -127
- package/dist/components/buckets/BucketReplicationFormPage.d.ts +1 -0
- package/dist/components/buckets/BucketReplicationFormPage.js +835 -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 +76 -0
- package/dist/components/buckets/DeleteBucketButton.js +8 -8
- 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/BucketNotificationFormPage.d.ts +1 -0
- package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
- package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
- package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
- package/dist/components/buckets/notifications/EventsSection.js +145 -29
- package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
- package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
- package/dist/components/buckets/notifications/events.d.ts +71 -7
- package/dist/components/buckets/notifications/events.js +98 -16
- package/dist/components/index.d.ts +27 -13
- package/dist/components/index.js +20 -6
- package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
- package/dist/components/layouts/ArrowNavigation.js +28 -0
- package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
- package/dist/components/layouts/BrowserPageLayout.js +10 -5
- package/dist/components/objects/CreateFolderButton.d.ts +2 -2
- package/dist/components/objects/CreateFolderButton.js +12 -12
- package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
- package/dist/components/objects/DeleteObjectButton.js +19 -21
- package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
- package/dist/components/objects/GetPresignedUrlButton.js +255 -0
- package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectMetadata.js +263 -230
- package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
- package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
- package/dist/components/objects/ObjectDetails/ObjectTags.js +95 -123
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
- package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
- package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
- package/dist/components/objects/ObjectDetails/index.js +152 -40
- package/dist/components/objects/ObjectList.d.ts +12 -10
- package/dist/components/objects/ObjectList.js +590 -263
- 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 +159 -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.js +12 -8
- package/dist/components/objects/UploadButton.d.ts +3 -3
- package/dist/components/objects/UploadButton.js +10 -10
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
- package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
- package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
- package/dist/components/providers/DataBrowserProvider.js +60 -38
- package/dist/components/providers/QueryProvider.d.ts +9 -0
- package/dist/components/providers/QueryProvider.js +21 -0
- package/dist/components/search/MetadataSearch.js +29 -28
- package/dist/components/search/SearchHints.js +1 -1
- 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 +48 -0
- package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
- package/dist/components/ui/DeleteObjectModalContent.js +12 -12
- 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 +2 -2
- package/dist/components/ui/Search.elements.js +7 -7
- package/dist/components/ui/Table.elements.d.ts +2 -1
- package/dist/components/ui/Table.elements.js +18 -12
- package/dist/config/__tests__/factory.test.d.ts +1 -0
- package/dist/config/__tests__/factory.test.js +311 -0
- package/dist/config/factory.d.ts +14 -49
- package/dist/config/factory.js +23 -68
- package/dist/config/types.d.ts +212 -34
- package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
- package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
- package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -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.js +27 -27
- package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
- package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
- package/dist/hooks/bucketConfiguration.d.ts +8 -1
- package/dist/hooks/bucketConfiguration.js +52 -51
- package/dist/hooks/bucketOperations.d.ts +10 -1
- package/dist/hooks/bucketOperations.js +10 -9
- package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
- package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
- package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
- package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +95 -52
- package/dist/hooks/factories/index.d.ts +4 -4
- package/dist/hooks/factories/index.js +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
- package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
- package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
- package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
- package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
- package/dist/hooks/factories/useCreateS3QueryHook.js +29 -3
- package/dist/hooks/index.d.ts +19 -8
- package/dist/hooks/index.js +16 -5
- package/dist/hooks/loginOperations.d.ts +1 -1
- package/dist/hooks/loginOperations.js +1 -1
- package/dist/hooks/objectOperations.d.ts +2 -2
- package/dist/hooks/objectOperations.js +50 -49
- package/dist/hooks/presignedOperations.d.ts +4 -4
- package/dist/hooks/presignedOperations.js +5 -5
- package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
- package/dist/hooks/useAccessibleBuckets.js +115 -0
- package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
- package/dist/hooks/useBatchObjectLegalHold.js +48 -0
- package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
- package/dist/hooks/useBucketConfigEditor.js +82 -0
- package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
- package/dist/hooks/useDataBrowserNavigate.js +24 -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/useFeatures.d.ts +7 -0
- package/dist/hooks/useFeatures.js +8 -0
- package/dist/hooks/useISVBucketDetection.d.ts +15 -0
- package/dist/hooks/useISVBucketDetection.js +27 -0
- package/dist/hooks/useIsBucketEmpty.js +4 -4
- package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
- package/dist/hooks/useLimitedAccessFlow.js +23 -0
- package/dist/hooks/useS3Client.d.ts +6 -0
- package/dist/hooks/useS3Client.js +3 -2
- package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
- package/dist/hooks/useS3ConfigSwitch.js +37 -0
- package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
- package/dist/hooks/useSupportedNotificationEvents.js +8 -0
- package/dist/hooks/useTableRowSelection.d.ts +9 -0
- package/dist/hooks/useTableRowSelection.js +45 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/schemas/bucketPolicySchema.json +3 -13
- package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
- package/dist/test/msw/handlers/deleteBucket.js +20 -10
- package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketAcl.js +29 -17
- package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketLocation.js +29 -15
- package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
- package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
- package/dist/test/msw/handlers/headObject.d.ts +1 -1
- package/dist/test/msw/handlers/headObject.js +31 -13
- package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
- package/dist/test/msw/handlers/listBuckets.js +5 -3
- package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
- package/dist/test/msw/handlers/listObjectVersions.js +38 -26
- package/dist/test/msw/handlers/listObjects.d.ts +1 -1
- package/dist/test/msw/handlers/listObjects.js +35 -23
- package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
- package/dist/test/msw/handlers/objectLegalHold.js +32 -17
- package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
- package/dist/test/msw/handlers/objectRetention.js +31 -17
- package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
- package/dist/test/msw/handlers/putBucketAcl.js +29 -14
- package/dist/test/msw/handlers/putObject.d.ts +1 -1
- package/dist/test/msw/handlers/putObject.js +27 -12
- package/dist/test/msw/handlers.d.ts +3 -3
- package/dist/test/msw/handlers.js +77 -54
- package/dist/test/msw/index.d.ts +2 -2
- package/dist/test/msw/index.js +1 -1
- package/dist/test/msw/server.d.ts +1 -1
- package/dist/test/msw/server.js +1 -1
- package/dist/test/msw/utils.js +2 -2
- package/dist/test/setup.d.ts +1 -1
- package/dist/test/setup.js +13 -30
- package/dist/test/testUtils.d.ts +170 -36
- package/dist/test/testUtils.js +229 -116
- package/dist/test/utils/errorHandling.test.js +146 -108
- package/dist/types/index.d.ts +49 -36
- package/dist/types/monaco.d.ts +13 -0
- package/dist/types/monaco.js +0 -0
- package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
- package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
- package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
- package/dist/utils/__tests__/s3Client.test.js +340 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
- package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
- package/dist/utils/constants.d.ts +22 -0
- package/dist/utils/constants.js +19 -0
- package/dist/utils/deletion/index.d.ts +2 -2
- package/dist/utils/deletion/index.js +1 -1
- package/dist/utils/deletion/messages.d.ts +1 -1
- package/dist/utils/deletion/messages.js +4 -4
- package/dist/utils/errorHandling.d.ts +12 -3
- package/dist/utils/errorHandling.js +12 -7
- package/dist/utils/hooks.js +8 -8
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.js +5 -1
- package/dist/utils/proxyMiddleware.d.ts +32 -13
- package/dist/utils/proxyMiddleware.js +90 -36
- package/dist/utils/s3Client.d.ts +14 -4
- package/dist/utils/s3Client.js +5 -26
- package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
- package/dist/utils/s3ConfigIdentifier.js +57 -0
- package/dist/utils/s3RuleUtils.d.ts +53 -0
- package/dist/utils/s3RuleUtils.js +101 -0
- package/package.json +10 -8
- package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
- package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
- package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
- package/dist/hooks/useLoginMutation.d.ts +0 -21
- package/dist/hooks/useLoginMutation.js +0 -9
- package/dist/utils/useFeatures.d.ts +0 -1
- package/dist/utils/useFeatures.js +0 -7
- /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
|
@@ -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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './config/factory';
|
|
3
|
+
export * from './config/types';
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./components/index.js";
|
|
2
|
+
export * from "./config/factory.js";
|
|
3
|
+
export * from "./config/types.js";
|
|
2
4
|
export * from "./hooks/index.js";
|
|
3
5
|
export * from "./types/index.js";
|
|
4
6
|
export * from "./utils/index.js";
|
|
5
|
-
export * from "./config/factory.js";
|
|
6
|
-
export * from "./config/types.js";
|
|
@@ -20,10 +20,7 @@
|
|
|
20
20
|
"items": {
|
|
21
21
|
"type": "object",
|
|
22
22
|
"required": ["Effect"],
|
|
23
|
-
"oneOf": [
|
|
24
|
-
{ "required": ["Principal"] },
|
|
25
|
-
{ "required": ["NotPrincipal"] }
|
|
26
|
-
],
|
|
23
|
+
"oneOf": [{ "required": ["Principal"] }, { "required": ["NotPrincipal"] }],
|
|
27
24
|
"properties": {
|
|
28
25
|
"Sid": {
|
|
29
26
|
"type": "string",
|
|
@@ -276,10 +273,7 @@
|
|
|
276
273
|
"oneOf": [{ "required": ["Action"] }, { "required": ["NotAction"] }]
|
|
277
274
|
},
|
|
278
275
|
{
|
|
279
|
-
"oneOf": [
|
|
280
|
-
{ "required": ["Resource"] },
|
|
281
|
-
{ "required": ["NotResource"] }
|
|
282
|
-
]
|
|
276
|
+
"oneOf": [{ "required": ["Resource"] }, { "required": ["NotResource"] }]
|
|
283
277
|
}
|
|
284
278
|
]
|
|
285
279
|
}
|
|
@@ -306,11 +300,7 @@
|
|
|
306
300
|
{
|
|
307
301
|
"type": "array",
|
|
308
302
|
"items": {
|
|
309
|
-
"oneOf": [
|
|
310
|
-
{ "type": "string" },
|
|
311
|
-
{ "type": "number" },
|
|
312
|
-
{ "type": "boolean" }
|
|
313
|
-
]
|
|
303
|
+
"oneOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }]
|
|
314
304
|
},
|
|
315
305
|
"description": "Multiple condition values"
|
|
316
306
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const deleteBucketHandler: import("msw").
|
|
1
|
+
export declare const deleteBucketHandler: import("msw").HttpHandler;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const deleteBucketHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
if (
|
|
6
|
-
if (bucketName.includes(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (bucketName.includes(
|
|
10
|
-
|
|
3
|
+
const deleteBucketHandler = http["delete"](`${getS3BaseUrl()}/:bucketName`, async ({ params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
if ('string' == typeof bucketName) {
|
|
6
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
7
|
+
status: 404
|
|
8
|
+
});
|
|
9
|
+
if (bucketName.includes('bucket-not-empty')) return HttpResponse.xml(createS3ErrorXml('BucketNotEmpty', 'The bucket you tried to delete is not empty', bucketName), {
|
|
10
|
+
status: 409
|
|
11
|
+
});
|
|
12
|
+
if (bucketName.includes('restricted-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
13
|
+
status: 403
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
16
|
+
if (bucketName.includes('error-callback-bucket')) return HttpResponse.xml(createS3ErrorXml('InternalError', 'We encountered an internal error. Please try again.'), {
|
|
17
|
+
status: 500
|
|
18
|
+
});
|
|
11
19
|
}
|
|
12
|
-
return
|
|
20
|
+
return new Response(null, {
|
|
21
|
+
status: 204
|
|
22
|
+
});
|
|
13
23
|
});
|
|
14
24
|
export { deleteBucketHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getBucketAclHandler: import("msw").
|
|
1
|
+
export declare const getBucketAclHandler: import("msw").HttpHandler;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketAclHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (bucketName.includes(
|
|
3
|
+
const getBucketAclHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('acl')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
15
|
+
if (bucketName.includes('private-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
12
16
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
13
17
|
<Owner>
|
|
14
18
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -23,8 +27,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
23
27
|
<Permission>FULL_CONTROL</Permission>
|
|
24
28
|
</Grant>
|
|
25
29
|
</AccessControlList>
|
|
26
|
-
</AccessControlPolicy
|
|
27
|
-
|
|
30
|
+
</AccessControlPolicy>`, {
|
|
31
|
+
status: 200
|
|
32
|
+
});
|
|
33
|
+
if (bucketName.includes('public-read-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
34
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
29
35
|
<Owner>
|
|
30
36
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -45,8 +51,10 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
45
51
|
<Permission>READ</Permission>
|
|
46
52
|
</Grant>
|
|
47
53
|
</AccessControlList>
|
|
48
|
-
</AccessControlPolicy
|
|
49
|
-
|
|
54
|
+
</AccessControlPolicy>`, {
|
|
55
|
+
status: 200
|
|
56
|
+
});
|
|
57
|
+
if (bucketName.includes('shared-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
50
58
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
51
59
|
<Owner>
|
|
52
60
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -74,9 +82,11 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
74
82
|
<Permission>READ</Permission>
|
|
75
83
|
</Grant>
|
|
76
84
|
</AccessControlList>
|
|
77
|
-
</AccessControlPolicy
|
|
85
|
+
</AccessControlPolicy>`, {
|
|
86
|
+
status: 200
|
|
87
|
+
});
|
|
78
88
|
}
|
|
79
|
-
return
|
|
89
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
80
90
|
<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
81
91
|
<Owner>
|
|
82
92
|
<ID>owner-canonical-id-123</ID>
|
|
@@ -91,6 +101,8 @@ const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
|
|
|
91
101
|
<Permission>FULL_CONTROL</Permission>
|
|
92
102
|
</Grant>
|
|
93
103
|
</AccessControlList>
|
|
94
|
-
</AccessControlPolicy
|
|
104
|
+
</AccessControlPolicy>`, {
|
|
105
|
+
status: 200
|
|
106
|
+
});
|
|
95
107
|
});
|
|
96
108
|
export { getBucketAclHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getBucketLocationHandler: import("msw").
|
|
1
|
+
export declare const getBucketLocationHandler: import("msw").HttpHandler;
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketLocationHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
if (bucketName.includes(
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const getBucketLocationHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('location')) return;
|
|
7
|
+
if ('string' == typeof bucketName) {
|
|
8
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
9
|
+
status: 404
|
|
10
|
+
});
|
|
11
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
12
|
+
status: 403
|
|
13
|
+
});
|
|
14
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
11
15
|
let locationConstraint = null;
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
else if (bucketName.includes(
|
|
14
|
-
else if (bucketName.includes(
|
|
16
|
+
if (bucketName.includes('eu-west-1')) locationConstraint = 'eu-west-1';
|
|
17
|
+
else if (bucketName.includes('ap-southeast-1')) locationConstraint = 'ap-southeast-1';
|
|
18
|
+
else if (bucketName.includes('us-west-2')) locationConstraint = 'us-west-2';
|
|
15
19
|
const response = locationConstraint ? `<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">${locationConstraint}</LocationConstraint>` : `<?xml version="1.0" encoding="UTF-8"?>
|
|
17
21
|
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`;
|
|
18
|
-
return
|
|
22
|
+
return HttpResponse.xml(response, {
|
|
23
|
+
status: 200,
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/xml'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
19
28
|
}
|
|
20
|
-
return
|
|
21
|
-
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint
|
|
29
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
30
|
+
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/"></LocationConstraint>`, {
|
|
31
|
+
status: 200,
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/xml'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
22
36
|
});
|
|
23
37
|
export { getBucketLocationHandler };
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* - "invalid-json-bucket" returns malformed JSON for testing
|
|
9
9
|
* - Other buckets return a default allow-all policy
|
|
10
10
|
*/
|
|
11
|
-
export declare const getBucketPolicyHandler: import("msw").
|
|
11
|
+
export declare const getBucketPolicyHandler: import("msw").HttpHandler;
|
|
@@ -1,65 +1,80 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const getBucketPolicyHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const getBucketPolicyHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('policy')) return;
|
|
7
|
+
if ('no-policy-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('NoSuchBucketPolicy', 'The bucket policy does not exist', bucketName), {
|
|
8
|
+
status: 404,
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/xml'
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if ('access-denied-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied', bucketName), {
|
|
14
|
+
status: 403,
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/xml'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if ('invalid-json-bucket' === bucketName) return HttpResponse.text('{"Version": "2012-10-17", "Statement": [invalid json}', {
|
|
20
|
+
status: 200,
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
10
25
|
let policy;
|
|
11
|
-
policy =
|
|
12
|
-
Version:
|
|
26
|
+
policy = 'string' == typeof bucketName && bucketName.startsWith('policy-readonly-') ? {
|
|
27
|
+
Version: '2012-10-17',
|
|
13
28
|
Statement: [
|
|
14
29
|
{
|
|
15
|
-
Sid:
|
|
16
|
-
Effect:
|
|
17
|
-
Principal:
|
|
18
|
-
Action:
|
|
30
|
+
Sid: 'PublicReadGetObject',
|
|
31
|
+
Effect: 'Allow',
|
|
32
|
+
Principal: '*',
|
|
33
|
+
Action: 's3:GetObject',
|
|
19
34
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
20
35
|
}
|
|
21
36
|
]
|
|
22
|
-
} :
|
|
23
|
-
Version:
|
|
37
|
+
} : 'string' == typeof bucketName && bucketName.startsWith('policy-complex-') ? {
|
|
38
|
+
Version: '2012-10-17',
|
|
24
39
|
Statement: [
|
|
25
40
|
{
|
|
26
|
-
Sid:
|
|
27
|
-
Effect:
|
|
41
|
+
Sid: 'AllowSpecificUser',
|
|
42
|
+
Effect: 'Allow',
|
|
28
43
|
Principal: {
|
|
29
|
-
AWS:
|
|
44
|
+
AWS: 'arn:aws:iam::123456789012:user/ExampleUser'
|
|
30
45
|
},
|
|
31
46
|
Action: [
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
's3:GetObject',
|
|
48
|
+
's3:PutObject'
|
|
34
49
|
],
|
|
35
50
|
Resource: `arn:aws:s3:::${bucketName}/*`
|
|
36
51
|
},
|
|
37
52
|
{
|
|
38
|
-
Sid:
|
|
39
|
-
Effect:
|
|
40
|
-
Principal:
|
|
41
|
-
Action:
|
|
53
|
+
Sid: 'DenyInsecureConnections',
|
|
54
|
+
Effect: 'Deny',
|
|
55
|
+
Principal: '*',
|
|
56
|
+
Action: 's3:*',
|
|
42
57
|
Resource: [
|
|
43
58
|
`arn:aws:s3:::${bucketName}`,
|
|
44
59
|
`arn:aws:s3:::${bucketName}/*`
|
|
45
60
|
],
|
|
46
61
|
Condition: {
|
|
47
62
|
Bool: {
|
|
48
|
-
|
|
63
|
+
'aws:SecureTransport': 'false'
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
66
|
}
|
|
52
67
|
]
|
|
53
68
|
} : {
|
|
54
|
-
Version:
|
|
69
|
+
Version: '2012-10-17',
|
|
55
70
|
Statement: [
|
|
56
71
|
{
|
|
57
|
-
Sid:
|
|
58
|
-
Effect:
|
|
72
|
+
Sid: 'DefaultStatement',
|
|
73
|
+
Effect: 'Allow',
|
|
59
74
|
Principal: {
|
|
60
|
-
AWS:
|
|
75
|
+
AWS: 'arn:aws:iam::123456789012:root'
|
|
61
76
|
},
|
|
62
|
-
Action:
|
|
77
|
+
Action: 's3:*',
|
|
63
78
|
Resource: [
|
|
64
79
|
`arn:aws:s3:::${bucketName}`,
|
|
65
80
|
`arn:aws:s3:::${bucketName}/*`
|
|
@@ -67,6 +82,11 @@ const getBucketPolicyHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, r
|
|
|
67
82
|
}
|
|
68
83
|
]
|
|
69
84
|
};
|
|
70
|
-
return
|
|
85
|
+
return HttpResponse.json(policy, {
|
|
86
|
+
status: 200,
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/json'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
71
91
|
});
|
|
72
92
|
export { getBucketPolicyHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const headObjectHandler: import("msw").
|
|
1
|
+
export declare const headObjectHandler: import("msw").HttpHandler;
|
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const headObjectHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
const objectKey = url.pathname.substring(url.pathname.indexOf(
|
|
7
|
-
const versionId = url.searchParams.get(
|
|
8
|
-
if (
|
|
9
|
-
if (bucketName.includes(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
3
|
+
const headObjectHandler = http.head(`${getS3BaseUrl()}/:bucketName/*`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
const objectKey = url.pathname.substring(url.pathname.indexOf('/', 1) + 1);
|
|
7
|
+
const versionId = url.searchParams.get('versionId');
|
|
8
|
+
if ('string' == typeof bucketName) {
|
|
9
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
10
|
+
status: 404
|
|
11
|
+
});
|
|
12
|
+
if (objectKey.includes('non-existent-object')) return HttpResponse.xml(createS3ErrorXml('NotFound', 'The specified key does not exist.', bucketName, objectKey), {
|
|
13
|
+
status: 404
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('restricted-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
16
|
+
status: 403
|
|
17
|
+
});
|
|
18
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
19
|
+
return new Response(null, {
|
|
20
|
+
status: 200,
|
|
21
|
+
headers: {
|
|
22
|
+
'x-amz-meta-custom-key': 'custom-value',
|
|
23
|
+
'Content-Length': '12345',
|
|
24
|
+
'Content-Type': 'application/octet-stream',
|
|
25
|
+
ETag: '"some-etag"',
|
|
26
|
+
'Last-Modified': new Date().toUTCString(),
|
|
27
|
+
'x-amz-version-id': versionId || 'some-version-id'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
14
30
|
}
|
|
15
|
-
return
|
|
31
|
+
return HttpResponse.xml(createS3ErrorXml('InvalidArgument', 'Invalid request parameters'), {
|
|
32
|
+
status: 400
|
|
33
|
+
});
|
|
16
34
|
});
|
|
17
35
|
export { headObjectHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listBucketsHandler: import("msw").
|
|
1
|
+
export declare const listBucketsHandler: import("msw").HttpHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const listBucketsHandler =
|
|
3
|
+
const listBucketsHandler = http.get(`${getS3BaseUrl()}/`, async ()=>HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
4
|
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
5
5
|
<Owner>
|
|
6
6
|
<ID>owner-id-123</ID>
|
|
@@ -20,5 +20,7 @@ const listBucketsHandler = rest.get(`${getS3BaseUrl()}/`, (_req, res, ctx)=>res(
|
|
|
20
20
|
<CreationDate>2023-10-10T17:50:00.000Z</CreationDate>
|
|
21
21
|
</Bucket>
|
|
22
22
|
</Buckets>
|
|
23
|
-
</ListAllMyBucketsResult
|
|
23
|
+
</ListAllMyBucketsResult>`, {
|
|
24
|
+
status: 200
|
|
25
|
+
}));
|
|
24
26
|
export { listBucketsHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listObjectVersionsHandler: import("msw").
|
|
1
|
+
export declare const listObjectVersionsHandler: import("msw").HttpHandler;
|
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpResponse, http } from "msw";
|
|
2
2
|
import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
|
|
3
|
-
const listObjectVersionsHandler =
|
|
4
|
-
const { bucketName } =
|
|
5
|
-
const url = new URL(
|
|
6
|
-
if (!url.searchParams.has(
|
|
7
|
-
const prefix = url.searchParams.get(
|
|
8
|
-
const delimiter = url.searchParams.get(
|
|
9
|
-
const maxKeys = parseInt(url.searchParams.get(
|
|
10
|
-
const keyMarker = url.searchParams.get(
|
|
11
|
-
if (
|
|
12
|
-
if (bucketName.includes(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (bucketName.includes(
|
|
3
|
+
const listObjectVersionsHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
|
|
4
|
+
const { bucketName } = params;
|
|
5
|
+
const url = new URL(request.url);
|
|
6
|
+
if (!url.searchParams.has('versions')) return;
|
|
7
|
+
const prefix = url.searchParams.get('prefix') || '';
|
|
8
|
+
const delimiter = url.searchParams.get('delimiter') || '';
|
|
9
|
+
const maxKeys = parseInt(url.searchParams.get('max-keys') || '1000', 10);
|
|
10
|
+
const keyMarker = url.searchParams.get('key-marker');
|
|
11
|
+
if ('string' == typeof bucketName) {
|
|
12
|
+
if (bucketName.includes('non-existent-bucket')) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
|
|
13
|
+
status: 404
|
|
14
|
+
});
|
|
15
|
+
if (bucketName.includes('access-denied-bucket')) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied'), {
|
|
16
|
+
status: 403
|
|
17
|
+
});
|
|
18
|
+
if (bucketName.includes('network-error-bucket')) return HttpResponse.error();
|
|
19
|
+
if (bucketName.includes('empty-bucket')) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
16
20
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
17
21
|
<Name>${bucketName}</Name>
|
|
18
22
|
<Prefix>${prefix}</Prefix>
|
|
19
23
|
<Delimiter>${delimiter}</Delimiter>
|
|
20
24
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
21
25
|
<IsTruncated>false</IsTruncated>
|
|
22
|
-
</ListVersionsResult
|
|
26
|
+
</ListVersionsResult>`, {
|
|
27
|
+
status: 200
|
|
28
|
+
});
|
|
23
29
|
if (keyMarker) {
|
|
24
|
-
const pageKey = prefix &&
|
|
25
|
-
return
|
|
30
|
+
const pageKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-v3.txt` : 'file-v3.txt';
|
|
31
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
26
32
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
27
33
|
<Name>${bucketName}</Name>
|
|
28
34
|
<Prefix>${prefix}</Prefix>
|
|
@@ -38,20 +44,22 @@ const listObjectVersionsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req
|
|
|
38
44
|
<Size>1024</Size>
|
|
39
45
|
<StorageClass>STANDARD</StorageClass>
|
|
40
46
|
</Version>
|
|
41
|
-
</ListVersionsResult
|
|
47
|
+
</ListVersionsResult>`, {
|
|
48
|
+
status: 200
|
|
49
|
+
});
|
|
42
50
|
}
|
|
43
|
-
const hasMorePages = bucketName.includes(
|
|
44
|
-
const baseKey = prefix &&
|
|
45
|
-
const deletedKey = prefix &&
|
|
46
|
-
const nextKey = prefix &&
|
|
47
|
-
return
|
|
51
|
+
const hasMorePages = bucketName.includes('paginated-bucket');
|
|
52
|
+
const baseKey = prefix && 'file.txt' !== prefix ? prefix : 'file.txt';
|
|
53
|
+
const deletedKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-deleted.txt` : 'deleted-file.txt';
|
|
54
|
+
const nextKey = prefix && 'file.txt' !== prefix ? `${prefix.replace(/\/$/, '')}-v2.txt` : 'file-v2.txt';
|
|
55
|
+
return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
|
|
48
56
|
<ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
49
57
|
<Name>${bucketName}</Name>
|
|
50
58
|
<Prefix>${prefix}</Prefix>
|
|
51
59
|
<Delimiter>${delimiter}</Delimiter>
|
|
52
60
|
<MaxKeys>${maxKeys}</MaxKeys>
|
|
53
61
|
<IsTruncated>${hasMorePages}</IsTruncated>
|
|
54
|
-
${hasMorePages ? `<NextKeyMarker>${nextKey}</NextKeyMarker><NextVersionIdMarker>version-id-2</NextVersionIdMarker>` :
|
|
62
|
+
${hasMorePages ? `<NextKeyMarker>${nextKey}</NextKeyMarker><NextVersionIdMarker>version-id-2</NextVersionIdMarker>` : ''}
|
|
55
63
|
<Version>
|
|
56
64
|
<Key>${baseKey}</Key>
|
|
57
65
|
<VersionId>version-id-1</VersionId>
|
|
@@ -76,8 +84,12 @@ const listObjectVersionsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req
|
|
|
76
84
|
<IsLatest>true</IsLatest>
|
|
77
85
|
<LastModified>2023-10-10T17:50:00.000Z</LastModified>
|
|
78
86
|
</DeleteMarker>
|
|
79
|
-
</ListVersionsResult
|
|
87
|
+
</ListVersionsResult>`, {
|
|
88
|
+
status: 200
|
|
89
|
+
});
|
|
80
90
|
}
|
|
81
|
-
return
|
|
91
|
+
return new Response(null, {
|
|
92
|
+
status: 200
|
|
93
|
+
});
|
|
82
94
|
});
|
|
83
95
|
export { listObjectVersionsHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const listObjectsHandler: import("msw").
|
|
1
|
+
export declare const listObjectsHandler: import("msw").HttpHandler;
|