@scality/data-browser-library 1.0.0-preview.13 → 1.0.0-preview.16

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 (212) hide show
  1. package/dist/components/DataBrowserUI.d.ts +6 -14
  2. package/dist/components/DataBrowserUI.js +79 -55
  3. package/dist/components/Editor.d.ts +1 -1
  4. package/dist/components/Editor.js +3 -3
  5. package/dist/components/__tests__/BucketCreate.test.js +102 -102
  6. package/dist/components/__tests__/BucketDetails.test.js +122 -123
  7. package/dist/components/__tests__/BucketLifecycleFormPage.test.js +177 -177
  8. package/dist/components/__tests__/BucketLifecycleList.test.js +85 -85
  9. package/dist/components/__tests__/BucketList.test.js +175 -176
  10. package/dist/components/__tests__/BucketNotificationCreatePage.test.js +84 -84
  11. package/dist/components/__tests__/BucketOverview.test.js +257 -201
  12. package/dist/components/__tests__/BucketPolicyPage.test.js +62 -62
  13. package/dist/components/__tests__/BucketReplicationFormPage.test.js +542 -542
  14. package/dist/components/__tests__/BucketReplicationList.test.js +106 -106
  15. package/dist/components/__tests__/CreateFolderButton.test.js +56 -56
  16. package/dist/components/__tests__/DeleteBucketButton.test.js +62 -62
  17. package/dist/components/__tests__/DeleteBucketConfigRuleButton.test.js +47 -47
  18. package/dist/components/__tests__/DeleteObjectButton.test.js +63 -63
  19. package/dist/components/__tests__/EmptyBucketButton.test.js +56 -56
  20. package/dist/components/__tests__/MetadataSearch.test.js +65 -65
  21. package/dist/components/__tests__/ObjectList.test.js +252 -251
  22. package/dist/components/__tests__/UploadButton.test.js +45 -45
  23. package/dist/components/buckets/BucketCreate.d.ts +2 -2
  24. package/dist/components/buckets/BucketCreate.js +41 -41
  25. package/dist/components/buckets/BucketDetails.d.ts +2 -2
  26. package/dist/components/buckets/BucketDetails.js +48 -36
  27. package/dist/components/buckets/BucketLifecycleFormPage.js +161 -160
  28. package/dist/components/buckets/BucketLifecycleList.d.ts +2 -2
  29. package/dist/components/buckets/BucketLifecycleList.js +46 -46
  30. package/dist/components/buckets/BucketList.d.ts +2 -2
  31. package/dist/components/buckets/BucketList.js +28 -27
  32. package/dist/components/buckets/BucketLocation.js +3 -3
  33. package/dist/components/buckets/BucketOverview.d.ts +1 -1
  34. package/dist/components/buckets/BucketOverview.js +64 -65
  35. package/dist/components/buckets/BucketPage.js +19 -11
  36. package/dist/components/buckets/BucketPolicyButton.js +2 -2
  37. package/dist/components/buckets/BucketPolicyPage.js +27 -25
  38. package/dist/components/buckets/BucketReplicationFormPage.js +133 -132
  39. package/dist/components/buckets/BucketReplicationList.d.ts +2 -2
  40. package/dist/components/buckets/BucketReplicationList.js +41 -41
  41. package/dist/components/buckets/BucketVersioning.js +11 -11
  42. package/dist/components/buckets/DeleteBucketButton.js +5 -5
  43. package/dist/components/buckets/DeleteBucketConfigRuleButton.d.ts +2 -2
  44. package/dist/components/buckets/DeleteBucketConfigRuleButton.js +1 -1
  45. package/dist/components/buckets/EmptyBucketButton.js +19 -19
  46. package/dist/components/buckets/EmptyBucketSummary.d.ts +1 -1
  47. package/dist/components/buckets/EmptyBucketSummary.js +1 -1
  48. package/dist/components/buckets/EmptyBucketSummaryList.js +22 -22
  49. package/dist/components/buckets/__tests__/BucketVersioning.test.js +45 -45
  50. package/dist/components/buckets/notifications/BucketNotificationCreatePage.js +34 -33
  51. package/dist/components/buckets/notifications/EventsSection.js +144 -28
  52. package/dist/components/buckets/notifications/__tests__/events.test.d.ts +1 -0
  53. package/dist/components/buckets/notifications/__tests__/events.test.js +56 -0
  54. package/dist/components/buckets/notifications/events.d.ts +71 -7
  55. package/dist/components/buckets/notifications/events.js +98 -16
  56. package/dist/components/index.d.ts +24 -22
  57. package/dist/components/index.js +5 -3
  58. package/dist/components/layouts/ArrowNavigation.d.ts +1 -2
  59. package/dist/components/layouts/ArrowNavigation.js +3 -3
  60. package/dist/components/layouts/BrowserPageLayout.d.ts +2 -3
  61. package/dist/components/layouts/BrowserPageLayout.js +1 -1
  62. package/dist/components/objects/CreateFolderButton.d.ts +2 -2
  63. package/dist/components/objects/CreateFolderButton.js +9 -9
  64. package/dist/components/objects/DeleteObjectButton.d.ts +1 -1
  65. package/dist/components/objects/DeleteObjectButton.js +20 -20
  66. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +1 -1
  67. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +56 -56
  68. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +1 -1
  69. package/dist/components/objects/ObjectDetails/ObjectSummary.js +39 -39
  70. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +1 -1
  71. package/dist/components/objects/ObjectDetails/ObjectTags.js +25 -25
  72. package/dist/components/objects/ObjectDetails/__tests__/ObjectDetails.test.js +119 -119
  73. package/dist/components/objects/ObjectDetails/__tests__/ObjectSummary.test.js +211 -211
  74. package/dist/components/objects/ObjectDetails/index.d.ts +1 -1
  75. package/dist/components/objects/ObjectDetails/index.js +30 -30
  76. package/dist/components/objects/ObjectList.d.ts +5 -5
  77. package/dist/components/objects/ObjectList.js +113 -112
  78. package/dist/components/objects/ObjectLock/EditRetentionButton.js +3 -3
  79. package/dist/components/objects/ObjectLock/ObjectLockRetentionSettings.js +14 -14
  80. package/dist/components/objects/ObjectLock/ObjectLockSettings.d.ts +1 -1
  81. package/dist/components/objects/ObjectLock/ObjectLockSettings.js +29 -28
  82. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.d.ts +1 -1
  83. package/dist/components/objects/ObjectLock/ObjectLockSettingsUtils.js +6 -6
  84. package/dist/components/objects/ObjectLock/__tests__/EditRetentionButton.test.js +50 -50
  85. package/dist/components/objects/ObjectLock/__tests__/ObjectLockSettings.test.js +77 -77
  86. package/dist/components/objects/ObjectPage.js +5 -4
  87. package/dist/components/objects/UploadButton.d.ts +3 -3
  88. package/dist/components/objects/UploadButton.js +5 -5
  89. package/dist/components/providers/DataBrowserProvider.d.ts +23 -12
  90. package/dist/components/providers/DataBrowserProvider.js +60 -38
  91. package/dist/components/providers/QueryProvider.d.ts +9 -0
  92. package/dist/components/providers/QueryProvider.js +22 -0
  93. package/dist/components/search/MetadataSearch.js +26 -25
  94. package/dist/components/search/SearchHints.js +1 -1
  95. package/dist/components/ui/ArrayFieldActions.js +4 -4
  96. package/dist/components/ui/ConfirmDeleteRuleModal.d.ts +1 -1
  97. package/dist/components/ui/ConfirmDeleteRuleModal.js +1 -1
  98. package/dist/components/ui/DeleteObjectModalContent.d.ts +1 -1
  99. package/dist/components/ui/DeleteObjectModalContent.js +12 -12
  100. package/dist/components/ui/FilterFormSection.d.ts +2 -2
  101. package/dist/components/ui/FilterFormSection.js +29 -29
  102. package/dist/components/ui/Search.elements.d.ts +1 -1
  103. package/dist/components/ui/Search.elements.js +7 -7
  104. package/dist/components/ui/Table.elements.js +5 -5
  105. package/dist/config/factory.d.ts +23 -10
  106. package/dist/config/factory.js +22 -7
  107. package/dist/config/types.d.ts +20 -3
  108. package/dist/contexts/DataBrowserUICustomizationContext.d.ts +2 -2
  109. package/dist/hooks/__tests__/useISVBucketDetection.test.js +42 -42
  110. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +25 -25
  111. package/dist/hooks/bucketConfiguration.d.ts +1 -1
  112. package/dist/hooks/bucketConfiguration.js +48 -48
  113. package/dist/hooks/bucketOperations.d.ts +1 -1
  114. package/dist/hooks/bucketOperations.js +6 -6
  115. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +78 -78
  116. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +78 -78
  117. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +42 -42
  118. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +61 -61
  119. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +63 -63
  120. package/dist/hooks/factories/index.d.ts +4 -4
  121. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +2 -2
  122. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +15 -12
  123. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +2 -2
  124. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +3 -3
  125. package/dist/hooks/factories/useCreateS3MutationHook.js +6 -1
  126. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +2 -2
  127. package/dist/hooks/factories/useCreateS3QueryHook.js +8 -5
  128. package/dist/hooks/index.d.ts +16 -13
  129. package/dist/hooks/index.js +4 -1
  130. package/dist/hooks/loginOperations.d.ts +1 -1
  131. package/dist/hooks/loginOperations.js +1 -1
  132. package/dist/hooks/objectOperations.d.ts +2 -2
  133. package/dist/hooks/objectOperations.js +49 -49
  134. package/dist/hooks/presignedOperations.d.ts +2 -2
  135. package/dist/hooks/presignedOperations.js +3 -3
  136. package/dist/hooks/useBatchObjectLegalHold.js +7 -4
  137. package/dist/hooks/useDataBrowserNavigate.d.ts +28 -0
  138. package/dist/hooks/useDataBrowserNavigate.js +24 -0
  139. package/dist/hooks/useDeleteBucketConfigRule.d.ts +2 -2
  140. package/dist/hooks/useDeleteBucketConfigRule.js +4 -4
  141. package/dist/hooks/useEmptyBucket.js +10 -10
  142. package/dist/hooks/useFeatures.d.ts +7 -0
  143. package/dist/hooks/useFeatures.js +8 -0
  144. package/dist/hooks/useISVBucketDetection.js +5 -5
  145. package/dist/hooks/useIsBucketEmpty.js +4 -4
  146. package/dist/hooks/useLoginMutation.d.ts +1 -1
  147. package/dist/hooks/useLoginMutation.js +1 -1
  148. package/dist/hooks/useS3Client.d.ts +6 -0
  149. package/dist/hooks/useS3Client.js +3 -2
  150. package/dist/hooks/useS3ConfigSwitch.d.ts +11 -0
  151. package/dist/hooks/useS3ConfigSwitch.js +37 -0
  152. package/dist/hooks/useSupportedNotificationEvents.d.ts +6 -0
  153. package/dist/hooks/useSupportedNotificationEvents.js +8 -0
  154. package/dist/index.d.ts +6 -6
  155. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -1
  156. package/dist/test/msw/handlers/deleteBucket.js +20 -10
  157. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -1
  158. package/dist/test/msw/handlers/getBucketAcl.js +29 -17
  159. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -1
  160. package/dist/test/msw/handlers/getBucketLocation.js +29 -15
  161. package/dist/test/msw/handlers/getBucketPolicy.d.ts +1 -1
  162. package/dist/test/msw/handlers/getBucketPolicy.js +52 -32
  163. package/dist/test/msw/handlers/headObject.d.ts +1 -1
  164. package/dist/test/msw/handlers/headObject.js +31 -13
  165. package/dist/test/msw/handlers/listBuckets.d.ts +1 -1
  166. package/dist/test/msw/handlers/listBuckets.js +5 -3
  167. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -1
  168. package/dist/test/msw/handlers/listObjectVersions.js +38 -26
  169. package/dist/test/msw/handlers/listObjects.d.ts +1 -1
  170. package/dist/test/msw/handlers/listObjects.js +35 -23
  171. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -1
  172. package/dist/test/msw/handlers/objectLegalHold.js +31 -16
  173. package/dist/test/msw/handlers/objectRetention.d.ts +1 -1
  174. package/dist/test/msw/handlers/objectRetention.js +31 -17
  175. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -1
  176. package/dist/test/msw/handlers/putBucketAcl.js +29 -14
  177. package/dist/test/msw/handlers/putObject.d.ts +1 -1
  178. package/dist/test/msw/handlers/putObject.js +27 -12
  179. package/dist/test/msw/handlers.d.ts +3 -3
  180. package/dist/test/msw/handlers.js +72 -49
  181. package/dist/test/msw/index.d.ts +2 -2
  182. package/dist/test/msw/server.d.ts +1 -1
  183. package/dist/test/msw/server.js +1 -1
  184. package/dist/test/msw/utils.js +2 -2
  185. package/dist/test/setup.d.ts +1 -1
  186. package/dist/test/setup.js +19 -19
  187. package/dist/test/testUtils.d.ts +9 -15
  188. package/dist/test/testUtils.js +73 -91
  189. package/dist/test/utils/errorHandling.test.js +119 -119
  190. package/dist/types/index.d.ts +6 -31
  191. package/dist/utils/__tests__/s3ConfigIdentifier.test.d.ts +1 -0
  192. package/dist/utils/__tests__/s3ConfigIdentifier.test.js +429 -0
  193. package/dist/utils/constants.js +8 -8
  194. package/dist/utils/deletion/index.d.ts +2 -2
  195. package/dist/utils/deletion/messages.d.ts +1 -1
  196. package/dist/utils/deletion/messages.js +4 -4
  197. package/dist/utils/errorHandling.d.ts +3 -3
  198. package/dist/utils/errorHandling.js +6 -6
  199. package/dist/utils/hooks.js +8 -8
  200. package/dist/utils/index.d.ts +5 -4
  201. package/dist/utils/index.js +2 -0
  202. package/dist/utils/proxyMiddleware.d.ts +1 -1
  203. package/dist/utils/proxyMiddleware.js +6 -11
  204. package/dist/utils/s3Client.d.ts +2 -2
  205. package/dist/utils/s3Client.js +1 -1
  206. package/dist/utils/s3ConfigIdentifier.d.ts +68 -0
  207. package/dist/utils/s3ConfigIdentifier.js +55 -0
  208. package/dist/utils/s3RuleUtils.d.ts +5 -5
  209. package/dist/utils/s3RuleUtils.js +17 -17
  210. package/package.json +2 -2
  211. package/dist/utils/useFeatures.d.ts +0 -1
  212. package/dist/utils/useFeatures.js +0 -7
@@ -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;
@@ -1,17 +1,35 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const headObjectHandler = rest.head(`${getS3BaseUrl()}/:bucketName/*`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.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 res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
10
- if (objectKey.includes("non-existent-object")) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NotFound", "The specified key does not exist.", bucketName, objectKey)));
11
- if (bucketName.includes("restricted-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
12
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
13
- return res(ctx.status(200), ctx.set("x-amz-meta-custom-key", "custom-value"), ctx.set("Content-Length", "12345"), ctx.set("Content-Type", "application/octet-stream"), ctx.set("ETag", '"some-etag"'), ctx.set("Last-Modified", new Date().toUTCString()), ctx.set("x-amz-version-id", versionId || "some-version-id"));
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 res(ctx.status(400), ctx.xml(createS3ErrorXml("InvalidArgument", "Invalid request parameters")));
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const listBucketsHandler: import("msw").HttpHandler;
@@ -1,6 +1,6 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { getS3BaseUrl } from "../utils.js";
3
- const listBucketsHandler = rest.get(`${getS3BaseUrl()}/`, (_req, res, ctx)=>res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const listObjectVersionsHandler: import("msw").HttpHandler;
@@ -1,28 +1,34 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const listObjectVersionsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.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 res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
13
- if (bucketName.includes("access-denied-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
14
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
15
- if (bucketName.includes("empty-bucket")) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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 && "file.txt" !== prefix ? `${prefix.replace(/\/$/, "")}-v3.txt` : "file-v3.txt";
25
- return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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("paginated-bucket");
44
- const baseKey = prefix && "file.txt" !== prefix ? prefix : "file.txt";
45
- const deletedKey = prefix && "file.txt" !== prefix ? `${prefix.replace(/\/$/, "")}-deleted.txt` : "deleted-file.txt";
46
- const nextKey = prefix && "file.txt" !== prefix ? `${prefix.replace(/\/$/, "")}-v2.txt` : "file-v2.txt";
47
- return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
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 res(ctx.status(200));
91
+ return new Response(null, {
92
+ status: 200
93
+ });
82
94
  });
83
95
  export { listObjectVersionsHandler };
@@ -1 +1 @@
1
- export declare const listObjectsHandler: import("msw").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const listObjectsHandler: import("msw").HttpHandler;
@@ -1,26 +1,32 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
- const listObjectsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res, ctx)=>{
4
- const { bucketName } = req.params;
5
- const url = new URL(req.url);
6
- if ("2" !== url.searchParams.get("list-type")) 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 continuationToken = url.searchParams.get("continuation-token");
11
- if ("string" == typeof bucketName) {
12
- if (bucketName.includes("non-existent-bucket")) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
13
- if (bucketName.includes("access-denied-bucket")) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied")));
14
- if (bucketName.includes("network-error-bucket")) return res.networkError("Failed to connect");
15
- if (bucketName.includes("empty-bucket")) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
3
+ const listObjectsHandler = http.get(`${getS3BaseUrl()}/:bucketName`, async ({ request, params })=>{
4
+ const { bucketName } = params;
5
+ const url = new URL(request.url);
6
+ if ('2' !== url.searchParams.get('list-type')) 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 continuationToken = url.searchParams.get('continuation-token');
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
  <ListBucketResult 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
- </ListBucketResult>`));
23
- if (continuationToken) return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
26
+ </ListBucketResult>`, {
27
+ status: 200
28
+ });
29
+ if (continuationToken) return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
24
30
  <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
25
31
  <Name>${bucketName}</Name>
26
32
  <Prefix>${prefix}</Prefix>
@@ -34,16 +40,18 @@ const listObjectsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
34
40
  <Size>2048</Size>
35
41
  <StorageClass>STANDARD</StorageClass>
36
42
  </Contents>
37
- </ListBucketResult>`));
38
- const hasMorePages = bucketName.includes("paginated-bucket");
39
- return res(ctx.status(200), ctx.xml(`<?xml version="1.0" encoding="UTF-8"?>
43
+ </ListBucketResult>`, {
44
+ status: 200
45
+ });
46
+ const hasMorePages = bucketName.includes('paginated-bucket');
47
+ return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
40
48
  <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
41
49
  <Name>${bucketName}</Name>
42
50
  <Prefix>${prefix}</Prefix>
43
51
  <Delimiter>${delimiter}</Delimiter>
44
52
  <MaxKeys>${maxKeys}</MaxKeys>
45
53
  <IsTruncated>${hasMorePages}</IsTruncated>
46
- ${hasMorePages ? "<NextContinuationToken>token-123</NextContinuationToken>" : ""}
54
+ ${hasMorePages ? '<NextContinuationToken>token-123</NextContinuationToken>' : ''}
47
55
  <Contents>
48
56
  <Key>${prefix}file1.txt</Key>
49
57
  <LastModified>2023-10-12T17:50:00.000Z</LastModified>
@@ -58,9 +66,13 @@ const listObjectsHandler = rest.get(`${getS3BaseUrl()}/:bucketName`, (req, res,
58
66
  <Size>512</Size>
59
67
  <StorageClass>STANDARD</StorageClass>
60
68
  </Contents>
61
- ${delimiter ? `<CommonPrefixes><Prefix>${prefix}folder1/</Prefix></CommonPrefixes>` : ""}
62
- </ListBucketResult>`));
69
+ ${delimiter ? `<CommonPrefixes><Prefix>${prefix}folder1/</Prefix></CommonPrefixes>` : ''}
70
+ </ListBucketResult>`, {
71
+ status: 200
72
+ });
63
73
  }
64
- return res(ctx.status(200));
74
+ return new Response(null, {
75
+ status: 200
76
+ });
65
77
  });
66
78
  export { listObjectsHandler };
@@ -1 +1 @@
1
- export declare const getObjectLegalHoldHandler: import("msw").RestHandler<import("msw").MockedRequest<import("msw").DefaultRequestBody>>;
1
+ export declare const getObjectLegalHoldHandler: import("msw").HttpHandler;
@@ -1,24 +1,39 @@
1
- import { rest } from "msw";
1
+ import { HttpResponse, http } from "msw";
2
2
  import { createS3ErrorXml, getS3BaseUrl } from "../utils.js";
3
3
  import { ObjectLockLegalHoldStatus } from "@aws-sdk/client-s3";
4
- const getObjectLegalHoldHandler = rest.get(`${getS3BaseUrl()}/:bucketName/*`, (req, res, ctx)=>{
5
- const { bucketName } = req.params;
6
- const url = new URL(req.url);
7
- const objectKey = url.pathname.substring(url.pathname.indexOf("/", 1) + 1);
8
- if (!url.searchParams.has("legal-hold")) return;
9
- if ("string" == typeof bucketName) {
10
- if ("no-such-bucket" === bucketName || "non-existent-bucket" === bucketName) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchBucket", "The specified bucket does not exist", bucketName)));
11
- if ("access-denied-bucket" === bucketName || "restricted-bucket" === bucketName) return res(ctx.status(403), ctx.xml(createS3ErrorXml("AccessDenied", "Access Denied", bucketName, objectKey)));
12
- if ("network-error-bucket" === bucketName) return res.networkError("Failed to connect");
13
- if ("non-existent-object.txt" === objectKey) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchKey", "The specified key does not exist.", bucketName, objectKey)));
14
- if ("no-legal-hold-object.txt" === objectKey) return res(ctx.status(404), ctx.xml(createS3ErrorXml("NoSuchObjectLockConfiguration", "The specified object does not have a ObjectLock configuration", bucketName, objectKey)));
4
+ const getObjectLegalHoldHandler = http.get(`${getS3BaseUrl()}/:bucketName/*`, async ({ request, params })=>{
5
+ const { bucketName } = params;
6
+ const url = new URL(request.url);
7
+ const objectKey = url.pathname.substring(url.pathname.indexOf('/', 1) + 1);
8
+ if (!url.searchParams.has('legal-hold')) return;
9
+ if ('string' == typeof bucketName) {
10
+ if ('no-such-bucket' === bucketName || 'non-existent-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('NoSuchBucket', 'The specified bucket does not exist', bucketName), {
11
+ status: 404
12
+ });
13
+ if ('access-denied-bucket' === bucketName || 'restricted-bucket' === bucketName) return HttpResponse.xml(createS3ErrorXml('AccessDenied', 'Access Denied', bucketName, objectKey), {
14
+ status: 403
15
+ });
16
+ if ('network-error-bucket' === bucketName) return HttpResponse.error();
17
+ if ('non-existent-object.txt' === objectKey) return HttpResponse.xml(createS3ErrorXml('NoSuchKey', 'The specified key does not exist.', bucketName, objectKey), {
18
+ status: 404
19
+ });
20
+ if ('no-legal-hold-object.txt' === objectKey) return HttpResponse.xml(createS3ErrorXml('NoSuchObjectLockConfiguration', 'The specified object does not have a ObjectLock configuration', bucketName, objectKey), {
21
+ status: 404
22
+ });
15
23
  let status = ObjectLockLegalHoldStatus.ON;
16
- if ("legal-hold-off-object.txt" === objectKey) status = ObjectLockLegalHoldStatus.OFF;
17
- return res(ctx.status(200), ctx.set("Content-Type", "application/xml"), ctx.body(`<?xml version="1.0" encoding="UTF-8"?>
24
+ if ('legal-hold-off-object.txt' === objectKey) status = ObjectLockLegalHoldStatus.OFF;
25
+ return HttpResponse.xml(`<?xml version="1.0" encoding="UTF-8"?>
18
26
  <LegalHold xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
19
27
  <Status>${status}</Status>
20
- </LegalHold>`));
28
+ </LegalHold>`, {
29
+ status: 200,
30
+ headers: {
31
+ 'Content-Type': 'application/xml'
32
+ }
33
+ });
21
34
  }
22
- return res(ctx.status(400), ctx.xml(createS3ErrorXml("InvalidArgument", "Invalid request parameters")));
35
+ return HttpResponse.xml(createS3ErrorXml('InvalidArgument', 'Invalid request parameters'), {
36
+ status: 400
37
+ });
23
38
  });
24
39
  export { getObjectLegalHoldHandler };