@scality/data-browser-library 1.0.0-preview.9 → 1.0.3

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 (287) hide show
  1. package/dist/components/DataBrowserUI.d.ts +12 -0
  2. package/dist/components/DataBrowserUI.js +99 -0
  3. package/dist/components/Editor.d.ts +1 -1
  4. package/dist/components/Editor.js +3 -3
  5. package/dist/components/__tests__/BucketAccessor.test.js +214 -0
  6. package/dist/components/__tests__/BucketCorsPage.test.d.ts +1 -0
  7. package/dist/components/__tests__/BucketCorsPage.test.js +263 -0
  8. package/dist/components/__tests__/BucketCreate.test.js +271 -105
  9. package/dist/components/__tests__/BucketDetails.test.d.ts +1 -0
  10. package/dist/components/__tests__/BucketDetails.test.js +421 -0
  11. package/dist/components/__tests__/BucketLifecycleFormPage.test.d.ts +13 -0
  12. package/dist/components/__tests__/BucketLifecycleFormPage.test.js +178 -178
  13. package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
  14. package/dist/components/__tests__/BucketList.test.js +463 -239
  15. package/dist/components/__tests__/BucketNotificationFormPage.test.d.ts +1 -0
  16. package/dist/components/__tests__/BucketNotificationFormPage.test.js +348 -0
  17. package/dist/components/__tests__/BucketNotificationList.test.d.ts +1 -0
  18. package/dist/components/__tests__/BucketNotificationList.test.js +379 -0
  19. package/dist/components/__tests__/BucketOverview.test.js +281 -266
  20. package/dist/components/__tests__/BucketPolicyPage.test.js +151 -99
  21. package/dist/components/__tests__/BucketReplicationFormPage.test.d.ts +15 -0
  22. package/dist/components/__tests__/BucketReplicationFormPage.test.js +544 -544
  23. package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
  24. package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
  25. package/dist/components/__tests__/DeleteBucketButton.test.js +64 -64
  26. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
  27. package/dist/components/__tests__/DeleteObjectButton.test.js +64 -64
  28. package/dist/components/__tests__/EmptyBucketButton.test.js +59 -59
  29. package/dist/components/__tests__/MetadataSearch.test.js +65 -65
  30. package/dist/components/__tests__/ObjectList.test.js +741 -240
  31. package/dist/components/__tests__/UploadButton.test.js +45 -45
  32. package/dist/components/breadcrumb/Breadcrumb.d.ts +6 -0
  33. package/dist/components/breadcrumb/Breadcrumb.js +37 -0
  34. package/dist/components/breadcrumb/DataBrowserBreadcrumb.d.ts +1 -0
  35. package/dist/components/breadcrumb/DataBrowserBreadcrumb.js +10 -0
  36. package/dist/components/breadcrumb/__tests__/Breadcrumb.test.d.ts +1 -0
  37. package/dist/components/breadcrumb/__tests__/Breadcrumb.test.js +196 -0
  38. package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.d.ts +1 -0
  39. package/dist/components/breadcrumb/__tests__/DataBrowserBreadcrumb.test.js +153 -0
  40. package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.d.ts +1 -0
  41. package/dist/components/breadcrumb/__tests__/useBreadcrumbPaths.test.js +134 -0
  42. package/dist/components/breadcrumb/index.d.ts +8 -0
  43. package/dist/components/breadcrumb/index.js +4 -0
  44. package/dist/components/breadcrumb/useBreadcrumbPaths.d.ts +2 -0
  45. package/dist/components/breadcrumb/useBreadcrumbPaths.js +82 -0
  46. package/dist/components/buckets/BucketAccessor.d.ts +2 -0
  47. package/dist/components/buckets/BucketAccessor.js +125 -0
  48. package/dist/components/buckets/BucketConfigEditButton.d.ts +8 -0
  49. package/dist/components/buckets/{BucketPolicyButton.js → BucketConfigEditButton.js} +9 -5
  50. package/dist/components/buckets/BucketCorsPage.d.ts +1 -0
  51. package/dist/components/buckets/BucketCorsPage.js +234 -0
  52. package/dist/components/buckets/BucketCreate.d.ts +3 -2
  53. package/dist/components/buckets/BucketCreate.js +93 -47
  54. package/dist/components/buckets/BucketDetails.d.ts +42 -0
  55. package/dist/components/buckets/BucketDetails.js +249 -85
  56. package/dist/components/buckets/BucketLifecycleFormPage.js +225 -191
  57. package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
  58. package/dist/components/buckets/BucketLifecycleList.js +59 -61
  59. package/dist/components/buckets/BucketList.d.ts +7 -8
  60. package/dist/components/buckets/BucketList.js +158 -101
  61. package/dist/components/buckets/BucketLocation.js +4 -4
  62. package/dist/components/buckets/BucketOverview.d.ts +22 -2
  63. package/dist/components/buckets/BucketOverview.js +394 -187
  64. package/dist/components/buckets/BucketPage.js +43 -21
  65. package/dist/components/buckets/BucketPolicyPage.js +155 -127
  66. package/dist/components/buckets/BucketReplicationFormPage.js +134 -133
  67. package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
  68. package/dist/components/buckets/BucketReplicationList.js +48 -45
  69. package/dist/components/buckets/BucketVersioning.d.ts +4 -0
  70. package/dist/components/buckets/BucketVersioning.js +76 -0
  71. package/dist/components/buckets/DeleteBucketButton.js +8 -8
  72. package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
  73. package/dist/components/buckets/DeleteBucketConfigRuleButton.js +2 -2
  74. package/dist/components/buckets/EmptyBucketButton.js +24 -24
  75. package/dist/components/buckets/EmptyBucketSummary.d.ts +2 -2
  76. package/dist/components/buckets/EmptyBucketSummary.js +1 -1
  77. package/dist/components/buckets/EmptyBucketSummaryList.d.ts +1 -1
  78. package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
  79. package/dist/components/buckets/__tests__/BucketVersioning.test.d.ts +1 -0
  80. package/dist/components/buckets/__tests__/BucketVersioning.test.js +163 -0
  81. package/dist/components/buckets/notifications/BucketNotificationFormPage.d.ts +1 -0
  82. package/dist/components/buckets/notifications/BucketNotificationFormPage.js +316 -0
  83. package/dist/components/buckets/notifications/BucketNotificationList.d.ts +10 -0
  84. package/dist/components/buckets/notifications/BucketNotificationList.js +267 -0
  85. package/dist/components/buckets/notifications/EventsSection.js +145 -29
  86. package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
  87. package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
  88. package/dist/components/buckets/notifications/events.d.ts +71 -7
  89. package/dist/components/buckets/notifications/events.js +98 -16
  90. package/dist/components/index.d.ts +27 -20
  91. package/dist/components/index.js +17 -10
  92. package/dist/components/layouts/ArrowNavigation.d.ts +3 -0
  93. package/dist/components/layouts/ArrowNavigation.js +28 -0
  94. package/dist/components/layouts/BrowserPageLayout.d.ts +5 -1
  95. package/dist/components/layouts/BrowserPageLayout.js +10 -5
  96. package/dist/components/objects/CreateFolderButton.d.ts +2 -2
  97. package/dist/components/objects/CreateFolderButton.js +12 -12
  98. package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
  99. package/dist/components/objects/DeleteObjectButton.js +19 -21
  100. package/dist/components/objects/GetPresignedUrlButton.d.ts +7 -0
  101. package/dist/components/objects/GetPresignedUrlButton.js +255 -0
  102. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -2
  103. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +289 -230
  104. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +2 -2
  105. package/dist/components/objects/ObjectDetails/ObjectSummary.js +540 -138
  106. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +2 -2
  107. package/dist/components/objects/ObjectDetails/ObjectTags.js +103 -123
  108. package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.d.ts +1 -0
  109. package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +516 -0
  110. package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.d.ts +1 -0
  111. package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +1064 -0
  112. package/dist/components/objects/ObjectDetails/formUtils.d.ts +15 -0
  113. package/dist/components/objects/ObjectDetails/formUtils.js +7 -0
  114. package/dist/components/objects/ObjectDetails/index.d.ts +18 -2
  115. package/dist/components/objects/ObjectDetails/index.js +152 -40
  116. package/dist/components/objects/ObjectList.d.ts +12 -10
  117. package/dist/components/objects/ObjectList.js +590 -263
  118. package/dist/components/objects/ObjectLock/EditRetentionButton.js +4 -4
  119. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +15 -15
  120. package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
  121. package/dist/components/objects/ObjectLock/ObjectLockSettings.js +32 -31
  122. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
  123. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
  124. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +51 -51
  125. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +78 -78
  126. package/dist/components/objects/ObjectPage.js +12 -8
  127. package/dist/components/objects/UploadButton.d.ts +3 -3
  128. package/dist/components/objects/UploadButton.js +10 -10
  129. package/dist/components/objects/__tests__/GetPresignedUrlButton.test.d.ts +1 -0
  130. package/dist/components/objects/__tests__/GetPresignedUrlButton.test.js +531 -0
  131. package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
  132. package/dist/components/providers/DataBrowserProvider.js +60 -38
  133. package/dist/components/providers/QueryProvider.d.ts +9 -0
  134. package/dist/components/providers/QueryProvider.js +21 -0
  135. package/dist/components/search/MetadataSearch.js +29 -28
  136. package/dist/components/search/SearchHints.js +1 -1
  137. package/dist/components/ui/ArrayFieldActions.js +12 -7
  138. package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +2 -2
  139. package/dist/components/ui/ConfirmDeleteRuleModal.js +6 -1
  140. package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
  141. package/dist/components/ui/DeleteObjectModalContent.js +12 -12
  142. package/dist/components/ui/FilterFormSection.d.ts +2 -2
  143. package/dist/components/ui/FilterFormSection.js +29 -29
  144. package/dist/components/ui/Search.elements.d.ts +2 -2
  145. package/dist/components/ui/Search.elements.js +7 -7
  146. package/dist/components/ui/Table.elements.d.ts +2 -1
  147. package/dist/components/ui/Table.elements.js +18 -12
  148. package/dist/config/__tests__/factory.test.d.ts +1 -0
  149. package/dist/config/__tests__/factory.test.js +311 -0
  150. package/dist/config/factory.d.ts +10 -56
  151. package/dist/config/factory.js +23 -71
  152. package/dist/config/types.d.ts +212 -34
  153. package/dist/contexts/DataBrowserUICustomizationContext.d.ts +27 -0
  154. package/dist/contexts/DataBrowserUICustomizationContext.js +13 -0
  155. package/dist/hooks/__tests__/useAccessibleBuckets.test.d.ts +1 -0
  156. package/dist/hooks/__tests__/useAccessibleBuckets.test.js +145 -0
  157. package/dist/hooks/__tests__/useISVBucketDetection.test.js +45 -45
  158. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +27 -27
  159. package/dist/hooks/__tests__/useLoginMutation.test.d.ts +1 -0
  160. package/dist/hooks/__tests__/useLoginMutation.test.js +194 -0
  161. package/dist/hooks/bucketConfiguration.d.ts +8 -1
  162. package/dist/hooks/bucketConfiguration.js +52 -51
  163. package/dist/hooks/bucketOperations.d.ts +10 -1
  164. package/dist/hooks/bucketOperations.js +10 -9
  165. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +80 -80
  166. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +80 -80
  167. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +44 -44
  168. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +63 -63
  169. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +65 -65
  170. package/dist/hooks/factories/index.d.ts +4 -4
  171. package/dist/hooks/factories/index.js +2 -2
  172. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
  173. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +16 -13
  174. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
  175. package/dist/hooks/factories/useCreateS3LoginHook.js +1 -1
  176. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
  177. package/dist/hooks/factories/useCreateS3MutationHook.js +7 -2
  178. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
  179. package/dist/hooks/factories/useCreateS3QueryHook.js +11 -6
  180. package/dist/hooks/index.d.ts +19 -12
  181. package/dist/hooks/index.js +16 -9
  182. package/dist/hooks/loginOperations.d.ts +1 -1
  183. package/dist/hooks/loginOperations.js +1 -1
  184. package/dist/hooks/objectOperations.d.ts +2 -2
  185. package/dist/hooks/objectOperations.js +50 -49
  186. package/dist/hooks/presignedOperations.d.ts +4 -4
  187. package/dist/hooks/presignedOperations.js +5 -5
  188. package/dist/hooks/useAccessibleBuckets.d.ts +11 -0
  189. package/dist/hooks/useAccessibleBuckets.js +115 -0
  190. package/dist/hooks/useBatchObjectLegalHold.d.ts +11 -0
  191. package/dist/hooks/useBatchObjectLegalHold.js +48 -0
  192. package/dist/hooks/useBucketConfigEditor.d.ts +31 -0
  193. package/dist/hooks/useBucketConfigEditor.js +82 -0
  194. package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
  195. package/dist/hooks/useDataBrowserNavigate.js +24 -0
  196. package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
  197. package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
  198. package/dist/hooks/useEmptyBucket.js +11 -11
  199. package/dist/hooks/useFeatures.d.ts +7 -0
  200. package/dist/hooks/useFeatures.js +8 -0
  201. package/dist/hooks/useISVBucketDetection.js +6 -6
  202. package/dist/hooks/useIsBucketEmpty.js +4 -4
  203. package/dist/hooks/useLimitedAccessFlow.d.ts +48 -0
  204. package/dist/hooks/useLimitedAccessFlow.js +23 -0
  205. package/dist/hooks/useS3Client.d.ts +6 -0
  206. package/dist/hooks/useS3Client.js +3 -2
  207. package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
  208. package/dist/hooks/useS3ConfigSwitch.js +37 -0
  209. package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
  210. package/dist/hooks/useSupportedNotificationEvents.js +8 -0
  211. package/dist/index.d.ts +6 -6
  212. package/dist/index.js +2 -2
  213. package/dist/schemas/bucketPolicySchema.json +3 -13
  214. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
  215. package/dist/test/msw/handlers/deleteBucket.js +20 -10
  216. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
  217. package/dist/test/msw/handlers/getBucketAcl.js +29 -17
  218. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
  219. package/dist/test/msw/handlers/getBucketLocation.js +29 -15
  220. package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
  221. package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
  222. package/dist/test/msw/handlers/headObject.d.ts +1 -1
  223. package/dist/test/msw/handlers/headObject.js +31 -13
  224. package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
  225. package/dist/test/msw/handlers/listBuckets.js +5 -3
  226. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
  227. package/dist/test/msw/handlers/listObjectVersions.js +38 -26
  228. package/dist/test/msw/handlers/listObjects.d.ts +1 -1
  229. package/dist/test/msw/handlers/listObjects.js +35 -23
  230. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
  231. package/dist/test/msw/handlers/objectLegalHold.js +32 -17
  232. package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
  233. package/dist/test/msw/handlers/objectRetention.js +31 -17
  234. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
  235. package/dist/test/msw/handlers/putBucketAcl.js +29 -14
  236. package/dist/test/msw/handlers/putObject.d.ts +1 -1
  237. package/dist/test/msw/handlers/putObject.js +27 -12
  238. package/dist/test/msw/handlers.d.ts +3 -3
  239. package/dist/test/msw/handlers.js +77 -54
  240. package/dist/test/msw/index.d.ts +2 -2
  241. package/dist/test/msw/index.js +1 -1
  242. package/dist/test/msw/server.d.ts +1 -1
  243. package/dist/test/msw/server.js +1 -1
  244. package/dist/test/msw/utils.js +2 -2
  245. package/dist/test/setup.d.ts +1 -1
  246. package/dist/test/setup.js +13 -30
  247. package/dist/test/testUtils.d.ts +85 -33
  248. package/dist/test/testUtils.js +176 -111
  249. package/dist/test/utils/errorHandling.test.js +119 -119
  250. package/dist/types/index.d.ts +50 -37
  251. package/dist/types/monaco.d.ts +13 -0
  252. package/dist/types/monaco.js +0 -0
  253. package/dist/utils/__tests__/proxyMiddleware.test.d.ts +1 -0
  254. package/dist/utils/__tests__/proxyMiddleware.test.js +579 -0
  255. package/dist/utils/__tests__/s3Client.test.d.ts +1 -0
  256. package/dist/utils/__tests__/s3Client.test.js +340 -0
  257. package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
  258. package/dist/utils/__tests__/s3ConfigIdentifier.test.js +437 -0
  259. package/dist/utils/constants.d.ts +10 -0
  260. package/dist/utils/constants.js +19 -9
  261. package/dist/utils/deletion/index.d.ts +2 -2
  262. package/dist/utils/deletion/index.js +1 -1
  263. package/dist/utils/deletion/messages.d.ts +1 -1
  264. package/dist/utils/deletion/messages.js +4 -4
  265. package/dist/utils/errorHandling.d.ts +3 -3
  266. package/dist/utils/errorHandling.js +6 -6
  267. package/dist/utils/hooks.js +8 -8
  268. package/dist/utils/index.d.ts +5 -4
  269. package/dist/utils/index.js +4 -2
  270. package/dist/utils/proxyMiddleware.d.ts +32 -13
  271. package/dist/utils/proxyMiddleware.js +90 -36
  272. package/dist/utils/s3Client.d.ts +14 -4
  273. package/dist/utils/s3Client.js +5 -26
  274. package/dist/utils/s3ConfigIdentifier.d.ts +79 -0
  275. package/dist/utils/s3ConfigIdentifier.js +57 -0
  276. package/dist/utils/s3RuleUtils.d.ts +5 -5
  277. package/dist/utils/s3RuleUtils.js +17 -17
  278. package/package.json +10 -8
  279. package/dist/components/__tests__/BucketNotificationCreatePage.test.js +0 -316
  280. package/dist/components/buckets/BucketPolicyButton.d.ts +0 -7
  281. package/dist/components/buckets/notifications/BucketNotificationCreatePage.d.ts +0 -1
  282. package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +0 -234
  283. package/dist/hooks/useLoginMutation.d.ts +0 -21
  284. package/dist/hooks/useLoginMutation.js +0 -9
  285. package/dist/utils/useFeatures.d.ts +0 -1
  286. package/dist/utils/useFeatures.js +0 -7
  287. /package/dist/components/__tests__/{BucketNotificationCreatePage.test.d.ts → BucketAccessor.test.d.ts} +0 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook to check if a feature is enabled in the S3 configuration.
3
+ *
4
+ * @param feature - The feature name to check
5
+ * @returns true if enabled, false if disabled, undefined if config not available
6
+ */
7
+ export declare function useFeatures(feature: string): boolean | undefined;
@@ -0,0 +1,8 @@
1
+ import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
2
+ function useFeatures(feature) {
3
+ const { getS3Config } = useDataBrowserContext();
4
+ if (!getS3Config) return;
5
+ const config = getS3Config();
6
+ return config.features?.includes(feature) ?? false;
7
+ }
8
+ export { useFeatures };
@@ -1,12 +1,12 @@
1
- import { useGetBucketTagging } from "./bucketConfiguration.js";
2
- import { useFeatures } from "../utils/useFeatures.js";
3
1
  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";
2
+ import { useGetBucketTagging } from "./bucketConfiguration.js";
3
+ import { useFeatures } from "./useFeatures.js";
4
4
  const useISVBucketStatus = (bucketName)=>{
5
- const isISVFeatureEnabled = useFeatures("ISV");
5
+ const isISVFeatureEnabled = useFeatures('ISV');
6
6
  const { data: bucketTags, status: bucketTagsStatus } = useGetBucketTagging({
7
7
  Bucket: bucketName
8
8
  }, {
9
- enabled: isISVFeatureEnabled
9
+ enabled: true === isISVFeatureEnabled
10
10
  });
11
11
  const veeamTagApplication = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_VEEAM_APPLICATION)?.Value;
12
12
  const ISVApplicationTag = bucketTags?.TagSet?.find((tag)=>tag.Key === BUCKET_TAG_APPLICATION)?.Value;
@@ -19,8 +19,8 @@ const useISVBucketStatus = (bucketName)=>{
19
19
  isVeeamBucket: isVeeam,
20
20
  isCommvaultBucket,
21
21
  isISVManaged,
22
- isvApplication: isCommvaultBucket ? "Commvault" : isVeeam ? "Veeam" : void 0,
23
- isLoading: isISVFeatureEnabled && "pending" === bucketTagsStatus,
22
+ isvApplication: isCommvaultBucket ? 'Commvault' : isVeeam ? 'Veeam' : void 0,
23
+ isLoading: isISVFeatureEnabled && 'pending' === bucketTagsStatus,
24
24
  bucketTagsStatus
25
25
  };
26
26
  };
@@ -1,16 +1,16 @@
1
1
  import { useMemo } from "react";
2
2
  import { useListObjects } from "./objectOperations.js";
3
- const isInfiniteData = (data)=>null != data && "object" == typeof data && "pages" in data && Array.isArray(data.pages);
3
+ const isInfiniteData = (data)=>null != data && 'object' == typeof data && 'pages' in data && Array.isArray(data.pages);
4
4
  const useIsBucketEmpty = (bucketName)=>{
5
5
  const { data, status, error } = useListObjects({
6
6
  Bucket: bucketName,
7
7
  MaxKeys: 1,
8
- Delimiter: "/"
8
+ Delimiter: '/'
9
9
  }, {
10
10
  enabled: !!bucketName
11
11
  });
12
12
  const isEmpty = useMemo(()=>{
13
- if ("pending" === status || !data) return null;
13
+ if ('pending' === status || !data) return null;
14
14
  if (!isInfiniteData(data)) return null;
15
15
  for (const page of data.pages){
16
16
  if (page?.Contents && page.Contents.length > 0) {
@@ -29,7 +29,7 @@ const useIsBucketEmpty = (bucketName)=>{
29
29
  ]);
30
30
  return {
31
31
  isEmpty,
32
- isLoading: "pending" === status,
32
+ isLoading: 'pending' === status,
33
33
  error: error instanceof Error ? error : null
34
34
  };
35
35
  };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Limited Access Flow Orchestrator
3
+ *
4
+ * This module centralizes all logic related to handling users with limited S3 permissions
5
+ * (specifically users who lack ListBuckets permission but have access to specific buckets).
6
+ *
7
+ * It provides a clean abstraction that:
8
+ * - Encapsulates storage key patterns
9
+ * - Manages the limited access flag
10
+ * - Provides navigation logic
11
+ * - Coordinates between authentication, storage, and routing
12
+ */
13
+ import type { LoginConfig } from './loginOperations';
14
+ export interface UseLimitedAccessFlowOptions {
15
+ /**
16
+ * Callback invoked when a user successfully authenticates with limited access.
17
+ * This should be used to persist the config and transition the app state.
18
+ */
19
+ onLimitedAccessGranted: (config: LoginConfig) => void;
20
+ }
21
+ export interface LimitedAccessFlowHandlers {
22
+ /**
23
+ * Activates the limited access flow for a given S3 configuration.
24
+ * Sets the necessary flags and navigates to the bucket accessor form.
25
+ */
26
+ activateLimitedAccessFlow: (config: LoginConfig) => void;
27
+ }
28
+ /**
29
+ * Hook that orchestrates the limited access flow.
30
+ *
31
+ * This hook provides methods to activate and check the limited access mode
32
+ * for users who lack ListBuckets permission.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const { activateLimitedAccessFlow } = useLimitedAccessFlow({
37
+ * onLimitedAccessGranted: (config) => {
38
+ * setAppConfig(config);
39
+ * }
40
+ * });
41
+ *
42
+ * // In login error handler:
43
+ * if (error.name === 'AccessDenied') {
44
+ * activateLimitedAccessFlow(variables);
45
+ * }
46
+ * ```
47
+ */
48
+ export declare const useLimitedAccessFlow: (options: UseLimitedAccessFlowOptions) => LimitedAccessFlowHandlers;
@@ -0,0 +1,23 @@
1
+ import { useCallback } from "react";
2
+ import { useNavigate } from "react-router";
3
+ import { computeS3ConfigIdentifier } from "../utils/s3ConfigIdentifier.js";
4
+ import { setLimitedAccessFlag } from "./useAccessibleBuckets.js";
5
+ const useLimitedAccessFlow = (options)=>{
6
+ const navigate = useNavigate();
7
+ const { onLimitedAccessGranted } = options;
8
+ const activateLimitedAccessFlow = useCallback((config)=>{
9
+ const s3ConfigIdentifier = computeS3ConfigIdentifier(config);
10
+ setLimitedAccessFlag(s3ConfigIdentifier, true);
11
+ onLimitedAccessGranted(config);
12
+ navigate('/buckets/-/access', {
13
+ replace: true
14
+ });
15
+ }, [
16
+ navigate,
17
+ onLimitedAccessGranted
18
+ ]);
19
+ return {
20
+ activateLimitedAccessFlow
21
+ };
22
+ };
23
+ export { useLimitedAccessFlow };
@@ -1 +1,7 @@
1
+ /**
2
+ * Hook to get the S3 client instance.
3
+ *
4
+ * Recreates client only when s3ConfigIdentifier changes.
5
+ * The client is memoized to avoid unnecessary recreations.
6
+ */
1
7
  export declare const useS3Client: () => import("@aws-sdk/client-s3").S3Client;
@@ -2,12 +2,13 @@ import { useMemo } from "react";
2
2
  import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
3
3
  import { createS3Client } from "../utils/s3Client.js";
4
4
  const useS3Client = ()=>{
5
- const { getS3Config } = useDataBrowserContext();
5
+ const { s3ConfigIdentifier, getS3Config } = useDataBrowserContext();
6
+ if (!getS3Config) throw new Error('useS3Client: S3 config not available. Ensure DataBrowserProvider has getS3Config prop set.');
6
7
  return useMemo(()=>{
7
8
  const config = getS3Config();
8
9
  return createS3Client(config);
9
10
  }, [
10
- getS3Config
11
+ s3ConfigIdentifier
11
12
  ]);
12
13
  };
13
14
  export { useS3Client };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hook that handles navigation and query cleanup when S3 config changes.
3
+ * Must be used inside both DataBrowserProvider and DataBrowserUICustomizationProvider.
4
+ *
5
+ * When the S3 config identifier changes:
6
+ * - Navigates to the buckets page first (to trigger component unmounting)
7
+ * - Clears all queries associated with the previous config (after navigation)
8
+ *
9
+ * @internal This hook is designed for internal use within DataBrowserUI only.
10
+ */
11
+ export declare const useS3ConfigSwitch: () => void;
@@ -0,0 +1,37 @@
1
+ import { useQueryClient } from "@tanstack/react-query";
2
+ import { useEffect, useRef } from "react";
3
+ import { useNavigate } from "react-router";
4
+ import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
5
+ import { useDataBrowserUICustomization } from "../contexts/DataBrowserUICustomizationContext.js";
6
+ import { normalizePath } from "./useDataBrowserNavigate.js";
7
+ const useS3ConfigSwitch = ()=>{
8
+ const { s3ConfigIdentifier } = useDataBrowserContext();
9
+ const { basePath = '' } = useDataBrowserUICustomization();
10
+ const queryClient = useQueryClient();
11
+ const navigate = useNavigate();
12
+ const prevConfigIdRef = useRef();
13
+ useEffect(()=>{
14
+ if (void 0 !== prevConfigIdRef.current && prevConfigIdRef.current !== s3ConfigIdentifier) {
15
+ const previousConfigId = prevConfigIdRef.current;
16
+ const bucketsPath = normalizePath(basePath, '/buckets');
17
+ navigate(bucketsPath, {
18
+ replace: true
19
+ });
20
+ queueMicrotask(()=>{
21
+ queryClient.removeQueries({
22
+ queryKey: [
23
+ previousConfigId
24
+ ],
25
+ exact: false
26
+ });
27
+ });
28
+ }
29
+ prevConfigIdRef.current = s3ConfigIdentifier;
30
+ }, [
31
+ s3ConfigIdentifier,
32
+ navigate,
33
+ basePath,
34
+ queryClient
35
+ ]);
36
+ };
37
+ export { useS3ConfigSwitch };
@@ -0,0 +1,6 @@
1
+ import type { S3EventType } from '../config/types';
2
+ /**
3
+ * Hook to get supported notification events from the DataBrowser configuration
4
+ * If no supported events are configured, returns undefined (meaning all events are supported)
5
+ */
6
+ export declare function useSupportedNotificationEvents(): S3EventType[] | undefined;
@@ -0,0 +1,8 @@
1
+ import { useDataBrowserContext } from "../components/providers/DataBrowserProvider.js";
2
+ function useSupportedNotificationEvents() {
3
+ const { getS3Config } = useDataBrowserContext();
4
+ if (!getS3Config) return;
5
+ const config = getS3Config();
6
+ return config?.s3Capabilities?.supportedNotificationEvents;
7
+ }
8
+ export { useSupportedNotificationEvents };
package/dist/index.d.ts CHANGED
@@ -1,6 +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";
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const deleteBucketHandler: import("msw").HttpHandler;
@@ -1,14 +1,24 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const deleteBucketHandler = rest["delete"](`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- if ("string" == typeof bucketName) {
6
- if (bucketName.includes("non-existent-bucket")) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
7
- if (bucketName.includes("bucket-not-empty")) return res(ctx.status(409), ctx.xml(createS3ErrorXml("BucketNotEmpty", "The bucket you tried to delete is not empty", bucketName)));
8
- if (bucketName.includes("restricted-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
9
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
10
- if (bucketName.includes("error-callback-bucket")) return res(ctx.status(500), ctx.xml(createS3ErrorXml("InternalError", "We encountered an internal error. Please try again.")));
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 res(ctx.status(204));
20
+ return new Response(null, {
21
+ status: 204
22
+ });
13
23
  });
14
24
  export { deleteBucketHandler };
@@ -1 +1 @@
1
- export declare const getBucketAclHandler: import("msw").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const getBucketAclHandler: import("msw").HttpHandler;
@@ -1,14 +1,18 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const getBucketAclHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.url);
6
- if (!url.searchParams.has("acl")) return;
7
- if ("string" == typeof bucketName) {
8
- if (bucketName.includes("non-existent-bucket")) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
9
- if (bucketName.includes("access-denied-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
10
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
11
- if (bucketName.includes("private-bucket")) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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
- if (bucketName.includes("public-read-bucket")) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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
- if (bucketName.includes("shared-bucket")) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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 res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const getBucketLocationHandler: import("msw").HttpHandler;
@@ -1,23 +1,37 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const getBucketLocationHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.url);
6
- if (!url.searchParams.has("location")) return;
7
- if ("string" == typeof bucketName) {
8
- if (bucketName.includes("non-existent-bucket")) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
9
- if (bucketName.includes("access-denied-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
10
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
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("eu-west-1")) locationConstraint = "eu-west-1";
13
- else if (bucketName.includes("ap-southeast-1")) locationConstraint = "ap-southeast-1";
14
- else if (bucketName.includes("us-west-2")) locationConstraint = "us-west-2";
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 res(ctx.status(200), ctx.set("Content-Type", "application/xml"), ctx.body(response));
22
+ return HttpResponse.xml(response, {
23
+ status: 200,
24
+ headers: {
25
+ 'Content-Type': 'application/xml'
26
+ }
27
+ });
19
28
  }
20
- return res(ctx.status(200), ctx.set("Content-Type", "application/xml"), ctx.body(`<?xml version="1.0" encoding="UTF-8"?>
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
11
+ export declare const getBucketPolicyHandler: import("msw").HttpHandler;
@@ -1,65 +1,80 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const getBucketPolicyHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.url);
6
- if (!url.searchParams.has("policy")) return;
7
- if ("no-policy-bucket" === bucketName) return res(ctx.status(404), ctx.set("Content-Type", "application/xml"), ctx.body(createS3ErrorXml("NoSuchBucketPolicy", "The bucket policy does not exist", bucketName)));
8
- if ("access-denied-bucket" === bucketName) return res(ctx.status(403), ctx.set("Content-Type", "application/xml"), ctx.body(createS3ErrorXml("AccessDenied", "Access Denied", bucketName)));
9
- if ("invalid-json-bucket" === bucketName) return res(ctx.status(200), ctx.set("Content-Type", "application/json"), ctx.body('{"Version": "2012-10-17", "Statement": [invalid json}'));
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 = "string" == typeof bucketName && bucketName.startsWith("policy-readonly-") ? {
12
- Version: "2012-10-17",
26
+ policy = 'string' == typeof bucketName && bucketName.startsWith('policy-readonly-') ? {
27
+ Version: '2012-10-17',
13
28
  Statement: [
14
29
  {
15
- Sid: "PublicReadGetObject",
16
- Effect: "Allow",
17
- Principal: "*",
18
- Action: "s3:GetObject",
30
+ Sid: 'PublicReadGetObject',
31
+ Effect: 'Allow',
32
+ Principal: '*',
33
+ Action: 's3:GetObject',
19
34
  Resource: `arn:aws:s3:::${bucketName}/*`
20
35
  }
21
36
  ]
22
- } : "string" == typeof bucketName && bucketName.startsWith("policy-complex-") ? {
23
- Version: "2012-10-17",
37
+ } : 'string' == typeof bucketName && bucketName.startsWith('policy-complex-') ? {
38
+ Version: '2012-10-17',
24
39
  Statement: [
25
40
  {
26
- Sid: "AllowSpecificUser",
27
- Effect: "Allow",
41
+ Sid: 'AllowSpecificUser',
42
+ Effect: 'Allow',
28
43
  Principal: {
29
- AWS: "arn:aws:iam::123456789012:user/ExampleUser"
44
+ AWS: 'arn:aws:iam::123456789012:user/ExampleUser'
30
45
  },
31
46
  Action: [
32
- "s3:GetObject",
33
- "s3:PutObject"
47
+ 's3:GetObject',
48
+ 's3:PutObject'
34
49
  ],
35
50
  Resource: `arn:aws:s3:::${bucketName}/*`
36
51
  },
37
52
  {
38
- Sid: "DenyInsecureConnections",
39
- Effect: "Deny",
40
- Principal: "*",
41
- Action: "s3:*",
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
- "aws:SecureTransport": "false"
63
+ 'aws:SecureTransport': 'false'
49
64
  }
50
65
  }
51
66
  }
52
67
  ]
53
68
  } : {
54
- Version: "2012-10-17",
69
+ Version: '2012-10-17',
55
70
  Statement: [
56
71
  {
57
- Sid: "DefaultStatement",
58
- Effect: "Allow",
72
+ Sid: 'DefaultStatement',
73
+ Effect: 'Allow',
59
74
  Principal: {
60
- AWS: "arn:aws:iam::123456789012:root"
75
+ AWS: 'arn:aws:iam::123456789012:root'
61
76
  },
62
- Action: "s3:*",
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 res(ctx.status(200), ctx.set("Content-Type", "application/json"), ctx.body(JSON.stringify(policy)));
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const headObjectHandler: import("msw").HttpHandler;