@scality/data-browser-library 1.0.0-preview.2

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 (176) hide show
  1. package/dist/components/Editor.d.ts +12 -0
  2. package/dist/components/Editor.js +28 -0
  3. package/dist/components/__tests__/BucketList.test.d.ts +1 -0
  4. package/dist/components/__tests__/BucketList.test.js +225 -0
  5. package/dist/components/__tests__/BucketOverview.test.d.ts +1 -0
  6. package/dist/components/__tests__/BucketOverview.test.js +479 -0
  7. package/dist/components/__tests__/BucketPolicyPage.test.d.ts +1 -0
  8. package/dist/components/__tests__/BucketPolicyPage.test.js +213 -0
  9. package/dist/components/__tests__/CreateFolderButton.test.d.ts +1 -0
  10. package/dist/components/__tests__/CreateFolderButton.test.js +147 -0
  11. package/dist/components/__tests__/DeleteBucketButton.test.d.ts +1 -0
  12. package/dist/components/__tests__/DeleteBucketButton.test.js +272 -0
  13. package/dist/components/__tests__/DeleteObjectButton.test.d.ts +1 -0
  14. package/dist/components/__tests__/DeleteObjectButton.test.js +302 -0
  15. package/dist/components/__tests__/MetadataSearch.test.d.ts +1 -0
  16. package/dist/components/__tests__/MetadataSearch.test.js +201 -0
  17. package/dist/components/__tests__/ObjectList.test.d.ts +1 -0
  18. package/dist/components/__tests__/ObjectList.test.js +283 -0
  19. package/dist/components/__tests__/UploadButton.test.d.ts +1 -0
  20. package/dist/components/__tests__/UploadButton.test.js +144 -0
  21. package/dist/components/buckets/BucketDetails.d.ts +1 -0
  22. package/dist/components/buckets/BucketDetails.js +51 -0
  23. package/dist/components/buckets/BucketList.d.ts +12 -0
  24. package/dist/components/buckets/BucketList.js +136 -0
  25. package/dist/components/buckets/BucketLocation.d.ts +3 -0
  26. package/dist/components/buckets/BucketLocation.js +16 -0
  27. package/dist/components/buckets/BucketOverview.d.ts +14 -0
  28. package/dist/components/buckets/BucketOverview.js +209 -0
  29. package/dist/components/buckets/BucketPage.d.ts +2 -0
  30. package/dist/components/buckets/BucketPage.js +47 -0
  31. package/dist/components/buckets/BucketPolicyButton.d.ts +7 -0
  32. package/dist/components/buckets/BucketPolicyButton.js +18 -0
  33. package/dist/components/buckets/BucketPolicyPage.d.ts +1 -0
  34. package/dist/components/buckets/BucketPolicyPage.js +205 -0
  35. package/dist/components/buckets/DeleteBucketButton.d.ts +8 -0
  36. package/dist/components/buckets/DeleteBucketButton.js +78 -0
  37. package/dist/components/index.d.ts +12 -0
  38. package/dist/components/index.js +13 -0
  39. package/dist/components/layouts/BrowserPageLayout.d.ts +9 -0
  40. package/dist/components/layouts/BrowserPageLayout.js +46 -0
  41. package/dist/components/objects/CreateFolderButton.d.ts +29 -0
  42. package/dist/components/objects/CreateFolderButton.js +118 -0
  43. package/dist/components/objects/DeleteObjectButton.d.ts +8 -0
  44. package/dist/components/objects/DeleteObjectButton.js +191 -0
  45. package/dist/components/objects/ObjectDetails/ObjectMetadata.d.ts +2 -0
  46. package/dist/components/objects/ObjectDetails/ObjectMetadata.js +323 -0
  47. package/dist/components/objects/ObjectDetails/ObjectSummary.d.ts +3 -0
  48. package/dist/components/objects/ObjectDetails/ObjectSummary.js +193 -0
  49. package/dist/components/objects/ObjectDetails/ObjectTags.d.ts +3 -0
  50. package/dist/components/objects/ObjectDetails/ObjectTags.js +300 -0
  51. package/dist/components/objects/ObjectDetails/index.d.ts +9 -0
  52. package/dist/components/objects/ObjectDetails/index.js +49 -0
  53. package/dist/components/objects/ObjectList.d.ts +40 -0
  54. package/dist/components/objects/ObjectList.js +407 -0
  55. package/dist/components/objects/ObjectPage.d.ts +1 -0
  56. package/dist/components/objects/ObjectPage.js +43 -0
  57. package/dist/components/objects/UploadButton.d.ts +34 -0
  58. package/dist/components/objects/UploadButton.js +229 -0
  59. package/dist/components/providers/DataBrowserProvider.d.ts +20 -0
  60. package/dist/components/providers/DataBrowserProvider.js +42 -0
  61. package/dist/components/search/MetadataSearch.d.ts +5 -0
  62. package/dist/components/search/MetadataSearch.js +162 -0
  63. package/dist/components/search/SearchHints.d.ts +8 -0
  64. package/dist/components/search/SearchHints.js +21 -0
  65. package/dist/components/ui/DeleteObjectModalContent.d.ts +5 -0
  66. package/dist/components/ui/DeleteObjectModalContent.js +71 -0
  67. package/dist/components/ui/Search.elements.d.ts +17 -0
  68. package/dist/components/ui/Search.elements.js +59 -0
  69. package/dist/components/ui/Table.elements.d.ts +36 -0
  70. package/dist/components/ui/Table.elements.js +87 -0
  71. package/dist/config/factory.d.ts +52 -0
  72. package/dist/config/factory.js +70 -0
  73. package/dist/config/types.d.ts +46 -0
  74. package/dist/config/types.js +0 -0
  75. package/dist/hooks/__tests__/useIsBucketEmpty.test.d.ts +1 -0
  76. package/dist/hooks/__tests__/useIsBucketEmpty.test.js +122 -0
  77. package/dist/hooks/bucketConfiguration.d.ts +147 -0
  78. package/dist/hooks/bucketConfiguration.js +59 -0
  79. package/dist/hooks/bucketOperations.d.ts +36 -0
  80. package/dist/hooks/bucketOperations.js +12 -0
  81. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.d.ts +1 -0
  82. package/dist/hooks/factories/__tests__/useCreateS3FunctionMutationHook.test.js +276 -0
  83. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.d.ts +1 -0
  84. package/dist/hooks/factories/__tests__/useCreateS3InfiniteQueryHook.test.js +259 -0
  85. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.d.ts +1 -0
  86. package/dist/hooks/factories/__tests__/useCreateS3LoginHook.test.js +166 -0
  87. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.d.ts +1 -0
  88. package/dist/hooks/factories/__tests__/useCreateS3MutationHook.test.js +200 -0
  89. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.d.ts +1 -0
  90. package/dist/hooks/factories/__tests__/useCreateS3QueryHook.test.js +136 -0
  91. package/dist/hooks/factories/index.d.ts +18 -0
  92. package/dist/hooks/factories/index.js +5 -0
  93. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.d.ts +13 -0
  94. package/dist/hooks/factories/useCreateS3InfiniteQueryHook.js +76 -0
  95. package/dist/hooks/factories/useCreateS3LoginHook.d.ts +8 -0
  96. package/dist/hooks/factories/useCreateS3LoginHook.js +22 -0
  97. package/dist/hooks/factories/useCreateS3MutationHook.d.ts +5 -0
  98. package/dist/hooks/factories/useCreateS3MutationHook.js +50 -0
  99. package/dist/hooks/factories/useCreateS3QueryHook.d.ts +3 -0
  100. package/dist/hooks/factories/useCreateS3QueryHook.js +30 -0
  101. package/dist/hooks/index.d.ts +8 -0
  102. package/dist/hooks/index.js +8 -0
  103. package/dist/hooks/loginOperations.d.ts +21 -0
  104. package/dist/hooks/loginOperations.js +9 -0
  105. package/dist/hooks/objectOperations.d.ts +190 -0
  106. package/dist/hooks/objectOperations.js +66 -0
  107. package/dist/hooks/presignedOperations.d.ts +73 -0
  108. package/dist/hooks/presignedOperations.js +72 -0
  109. package/dist/hooks/useIsBucketEmpty.d.ts +7 -0
  110. package/dist/hooks/useIsBucketEmpty.js +36 -0
  111. package/dist/hooks/useLoginMutation.d.ts +21 -0
  112. package/dist/hooks/useLoginMutation.js +9 -0
  113. package/dist/hooks/useS3Client.d.ts +1 -0
  114. package/dist/hooks/useS3Client.js +13 -0
  115. package/dist/index.d.ts +6 -0
  116. package/dist/index.js +6 -0
  117. package/dist/schemas/bucketPolicySchema.json +321 -0
  118. package/dist/test/msw/handlers/deleteBucket.d.ts +1 -0
  119. package/dist/test/msw/handlers/deleteBucket.js +14 -0
  120. package/dist/test/msw/handlers/getBucketAcl.d.ts +1 -0
  121. package/dist/test/msw/handlers/getBucketAcl.js +96 -0
  122. package/dist/test/msw/handlers/getBucketLocation.d.ts +1 -0
  123. package/dist/test/msw/handlers/getBucketLocation.js +23 -0
  124. package/dist/test/msw/handlers/getBucketPolicy.d.ts +11 -0
  125. package/dist/test/msw/handlers/getBucketPolicy.js +72 -0
  126. package/dist/test/msw/handlers/headObject.d.ts +1 -0
  127. package/dist/test/msw/handlers/headObject.js +17 -0
  128. package/dist/test/msw/handlers/listBuckets.d.ts +1 -0
  129. package/dist/test/msw/handlers/listBuckets.js +24 -0
  130. package/dist/test/msw/handlers/listObjectVersions.d.ts +1 -0
  131. package/dist/test/msw/handlers/listObjectVersions.js +83 -0
  132. package/dist/test/msw/handlers/listObjects.d.ts +1 -0
  133. package/dist/test/msw/handlers/listObjects.js +66 -0
  134. package/dist/test/msw/handlers/objectLegalHold.d.ts +1 -0
  135. package/dist/test/msw/handlers/objectLegalHold.js +24 -0
  136. package/dist/test/msw/handlers/objectRetention.d.ts +1 -0
  137. package/dist/test/msw/handlers/objectRetention.js +27 -0
  138. package/dist/test/msw/handlers/putBucketAcl.d.ts +1 -0
  139. package/dist/test/msw/handlers/putBucketAcl.js +18 -0
  140. package/dist/test/msw/handlers/putObject.d.ts +1 -0
  141. package/dist/test/msw/handlers/putObject.js +16 -0
  142. package/dist/test/msw/handlers.d.ts +4 -0
  143. package/dist/test/msw/handlers.js +109 -0
  144. package/dist/test/msw/index.d.ts +2 -0
  145. package/dist/test/msw/index.js +3 -0
  146. package/dist/test/msw/server.d.ts +4 -0
  147. package/dist/test/msw/server.js +20 -0
  148. package/dist/test/msw/utils.d.ts +2 -0
  149. package/dist/test/msw/utils.js +13 -0
  150. package/dist/test/setup.d.ts +1 -0
  151. package/dist/test/setup.js +82 -0
  152. package/dist/test/testUtils.d.ts +82 -0
  153. package/dist/test/testUtils.js +236 -0
  154. package/dist/test/utils/errorHandling.test.d.ts +1 -0
  155. package/dist/test/utils/errorHandling.test.js +385 -0
  156. package/dist/types/index.d.ts +48 -0
  157. package/dist/types/index.js +0 -0
  158. package/dist/utils/deletion/index.d.ts +2 -0
  159. package/dist/utils/deletion/index.js +2 -0
  160. package/dist/utils/deletion/messages.d.ts +5 -0
  161. package/dist/utils/deletion/messages.js +29 -0
  162. package/dist/utils/deletion/types.d.ts +11 -0
  163. package/dist/utils/deletion/types.js +0 -0
  164. package/dist/utils/errorHandling.d.ts +54 -0
  165. package/dist/utils/errorHandling.js +79 -0
  166. package/dist/utils/hooks.d.ts +2 -0
  167. package/dist/utils/hooks.js +26 -0
  168. package/dist/utils/index.d.ts +2 -0
  169. package/dist/utils/index.js +2 -0
  170. package/dist/utils/proxyMiddleware.d.ts +18 -0
  171. package/dist/utils/proxyMiddleware.js +56 -0
  172. package/dist/utils/s3Client.d.ts +5 -0
  173. package/dist/utils/s3Client.js +35 -0
  174. package/dist/utils/useFeatures.d.ts +1 -0
  175. package/dist/utils/useFeatures.js +7 -0
  176. package/package.json +79 -0
@@ -0,0 +1,87 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Text, spacing } from "@scality/core-ui";
3
+ import { Box } from "@scality/core-ui/dist/next";
4
+ import styled_components from "styled-components";
5
+ const Table = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
6
+ height: "100%",
7
+ overflow: "auto",
8
+ width: "100%",
9
+ ...props,
10
+ children: children
11
+ });
12
+ const Body = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ ...props,
16
+ children: children
17
+ });
18
+ const Group = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
19
+ marginBottom: spacing.r28,
20
+ ...props,
21
+ children: children
22
+ });
23
+ const GroupName = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
24
+ marginBottom: spacing.r10,
25
+ ...props,
26
+ children: /*#__PURE__*/ jsx(Text, {
27
+ isEmphazed: true,
28
+ color: "textPrimary",
29
+ children: children
30
+ })
31
+ });
32
+ const GroupContent = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
33
+ display: "flex",
34
+ flexDirection: "column",
35
+ ...props,
36
+ children: children
37
+ });
38
+ const Row = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
39
+ position: "relative",
40
+ display: "flex",
41
+ flexDirection: "row",
42
+ alignItems: "center",
43
+ marginBottom: spacing.r8,
44
+ minHeight: spacing.r28,
45
+ ...props,
46
+ children: children
47
+ });
48
+ const RawKey = styled_components.div`
49
+ color: ${(props)=>props.principal ? props.theme.textPrimary : props.theme?.textSecondary};
50
+ font-weight: ${(props)=>props.principal ? "bold" : "normal"};
51
+ ${(props)=>props.required ? `
52
+ &:after {
53
+ content: '*';
54
+ }
55
+ ` : ""}
56
+ `;
57
+ const Key = styled_components(RawKey)`
58
+ && {
59
+ flex: ${(props)=>props.size || "0.35"};
60
+ min-width: 0;
61
+ }
62
+ `;
63
+ const Value = styled_components.div`
64
+ flex: 0.65;
65
+ flex-direction: column;
66
+ min-width: 0;
67
+ color: ${(props)=>props.theme?.textPrimary};
68
+ width: ${(props)=>props.width};
69
+ `;
70
+ const TableContainer = ({ children, ...props })=>/*#__PURE__*/ jsx(Box, {
71
+ display: "flex",
72
+ flexDirection: "column",
73
+ height: "100%",
74
+ ...props,
75
+ children: children
76
+ });
77
+ const GroupValues = styled_components.div`
78
+ display: flex;
79
+ flex: ${(props)=>props.size || "0.65"};
80
+ justify-content: space-between;
81
+ align-items: center;
82
+ min-width: 0;
83
+ `;
84
+ const ExtraCell = styled_components.div`
85
+ margin-left: ${(props)=>props.marginLeft || "1.429rem"};
86
+ `;
87
+ export { Body, ExtraCell, Group, GroupContent, GroupName, GroupValues, Key, Row, Table, TableContainer, Value };
@@ -0,0 +1,52 @@
1
+ import type { S3ClientConfiguration } from "./types";
2
+ import type { S3BrowserConfig, S3Credentials } from "../types";
3
+ /**
4
+ * Configuration factory that uses build-time constants
5
+ * No runtime environment detection or hardcoded values
6
+ */
7
+ export declare class S3ConfigurationFactory {
8
+ /**
9
+ * Load runtime configuration from config.json
10
+ * Should be called at app startup
11
+ */
12
+ static loadRuntimeConfig(): Promise<void>;
13
+ private static getBuildTimeConfig;
14
+ /**
15
+ * Create S3 client configuration based on build-time settings
16
+ */
17
+ static createClientConfiguration(credentials: S3Credentials): S3BrowserConfig & {
18
+ credentials: S3Credentials;
19
+ };
20
+ /**
21
+ * Create proxy middleware configuration
22
+ */
23
+ static createProxyConfiguration(): S3ClientConfiguration;
24
+ /**
25
+ * Check if proxy middleware should be enabled
26
+ */
27
+ static shouldUseProxyMiddleware(): boolean;
28
+ /**
29
+ * Get build-time environment info for debugging
30
+ */
31
+ static getBuildInfo(): {
32
+ environment: string;
33
+ useProxy: boolean;
34
+ s3Endpoint: string;
35
+ proxyEndpoint: string | undefined;
36
+ };
37
+ }
38
+ /**
39
+ * Convenience functions for common use cases
40
+ */
41
+ export declare const createS3Config: (credentials: S3Credentials) => S3BrowserConfig & {
42
+ credentials: S3Credentials;
43
+ };
44
+ export declare const shouldUseProxy: () => boolean;
45
+ export declare const getProxyConfig: () => S3ClientConfiguration;
46
+ export declare const getBuildInfo: () => {
47
+ environment: string;
48
+ useProxy: boolean;
49
+ s3Endpoint: string;
50
+ proxyEndpoint: string | undefined;
51
+ };
52
+ export declare const loadRuntimeConfig: () => Promise<void>;
@@ -0,0 +1,70 @@
1
+ let runtimeConfig = null;
2
+ class S3ConfigurationFactory {
3
+ static async loadRuntimeConfig() {
4
+ try {
5
+ const response = await fetch("/_/s3-browser/config.json");
6
+ if (response.ok) {
7
+ const data = await response.json();
8
+ runtimeConfig = data.s3;
9
+ console.log("Loaded runtime S3 configuration:", runtimeConfig);
10
+ }
11
+ } catch (error) {
12
+ console.warn("Could not load runtime config, using build-time config:", error);
13
+ }
14
+ }
15
+ static getBuildTimeConfig() {
16
+ return {
17
+ s3: __S3_CONFIG__,
18
+ dev: __DEV_CONFIG__,
19
+ isDevelopment: __IS_DEVELOPMENT__,
20
+ isProduction: __IS_PRODUCTION__
21
+ };
22
+ }
23
+ static createClientConfiguration(credentials) {
24
+ const buildConfig = this.getBuildTimeConfig();
25
+ const s3Config = buildConfig.isProduction && runtimeConfig ? runtimeConfig : buildConfig.s3;
26
+ const baseConfig = {
27
+ credentials,
28
+ region: s3Config.region,
29
+ forcePathStyle: s3Config.forcePathStyle ?? true,
30
+ endpoint: s3Config.endpoint
31
+ };
32
+ if (buildConfig.isDevelopment && buildConfig.dev.useProxy && buildConfig.dev.proxyEndpoint) baseConfig.endpoint = buildConfig.dev.proxyEndpoint;
33
+ return baseConfig;
34
+ }
35
+ static createProxyConfiguration() {
36
+ const buildConfig = this.getBuildTimeConfig();
37
+ const config = {
38
+ endpoint: buildConfig.s3.endpoint,
39
+ region: buildConfig.s3.region,
40
+ forcePathStyle: buildConfig.s3.forcePathStyle,
41
+ useProxy: buildConfig.isDevelopment && buildConfig.dev.useProxy
42
+ };
43
+ if (config.useProxy) config.proxyConfig = {
44
+ realHost: buildConfig.s3.realHost,
45
+ proxyBasePath: buildConfig.dev.proxyBasePath,
46
+ proxyHost: buildConfig.dev.proxyHost,
47
+ proxyPort: buildConfig.dev.proxyPort
48
+ };
49
+ return config;
50
+ }
51
+ static shouldUseProxyMiddleware() {
52
+ const buildConfig = this.getBuildTimeConfig();
53
+ return buildConfig.isDevelopment && buildConfig.dev.useProxy;
54
+ }
55
+ static getBuildInfo() {
56
+ const buildConfig = this.getBuildTimeConfig();
57
+ return {
58
+ environment: buildConfig.isDevelopment ? "development" : "production",
59
+ useProxy: buildConfig.dev.useProxy,
60
+ s3Endpoint: buildConfig.s3.endpoint,
61
+ proxyEndpoint: buildConfig.dev.proxyEndpoint
62
+ };
63
+ }
64
+ }
65
+ const createS3Config = (credentials)=>S3ConfigurationFactory.createClientConfiguration(credentials);
66
+ const shouldUseProxy = ()=>S3ConfigurationFactory.shouldUseProxyMiddleware();
67
+ const getProxyConfig = ()=>S3ConfigurationFactory.createProxyConfiguration();
68
+ const getBuildInfo = ()=>S3ConfigurationFactory.getBuildInfo();
69
+ const loadRuntimeConfig = ()=>S3ConfigurationFactory.loadRuntimeConfig();
70
+ export { S3ConfigurationFactory, createS3Config, getBuildInfo, getProxyConfig, loadRuntimeConfig, shouldUseProxy };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Build-time configuration types injected by RSBuild
3
+ */
4
+ export interface S3Configuration {
5
+ endpoint: string;
6
+ region: string;
7
+ realHost: string;
8
+ forcePathStyle: boolean;
9
+ }
10
+ export interface DevelopmentConfiguration {
11
+ useProxy: boolean;
12
+ proxyEndpoint?: string;
13
+ proxyBasePath: string;
14
+ proxyHost: string;
15
+ proxyPort: number;
16
+ }
17
+ export interface BuildTimeConfig {
18
+ s3: S3Configuration;
19
+ dev: DevelopmentConfiguration;
20
+ isDevelopment: boolean;
21
+ isProduction: boolean;
22
+ }
23
+ /**
24
+ * Runtime configuration for S3 client
25
+ */
26
+ export interface S3ClientConfiguration {
27
+ endpoint: string;
28
+ region: string;
29
+ forcePathStyle: boolean;
30
+ useProxy: boolean;
31
+ proxyConfig?: {
32
+ realHost: string;
33
+ proxyBasePath: string;
34
+ proxyHost: string;
35
+ proxyPort: number;
36
+ };
37
+ }
38
+ /**
39
+ * Global type declarations for build-time constants
40
+ */
41
+ declare global {
42
+ const __S3_CONFIG__: S3Configuration;
43
+ const __DEV_CONFIG__: DevelopmentConfiguration;
44
+ const __IS_DEVELOPMENT__: boolean;
45
+ const __IS_PRODUCTION__: boolean;
46
+ }
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ import { useIsBucketEmpty } from "../useIsBucketEmpty.js";
2
+ import { useListObjects } from "../objectOperations.js";
3
+ import { renderHookWithWrapper } from "../../test/testUtils.js";
4
+ jest.mock("../objectOperations");
5
+ const mockUseListObjects = jest.mocked(useListObjects);
6
+ describe("useIsBucketEmpty", ()=>{
7
+ beforeEach(()=>{
8
+ jest.clearAllMocks();
9
+ });
10
+ it("returns loading state when checking bucket", ()=>{
11
+ mockUseListObjects.mockReturnValue({
12
+ data: void 0,
13
+ status: "pending",
14
+ error: null
15
+ });
16
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
17
+ expect(result.current.isEmpty).toBe(null);
18
+ expect(result.current.isLoading).toBe(true);
19
+ expect(result.current.error).toBe(null);
20
+ });
21
+ it("returns true when bucket is empty", ()=>{
22
+ mockUseListObjects.mockReturnValue({
23
+ data: {
24
+ pages: [
25
+ {
26
+ objects: [],
27
+ commonPrefixes: []
28
+ }
29
+ ]
30
+ },
31
+ status: "success",
32
+ error: null
33
+ });
34
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
35
+ expect(result.current.isEmpty).toBe(true);
36
+ expect(result.current.isLoading).toBe(false);
37
+ });
38
+ it("returns false when bucket has objects", ()=>{
39
+ mockUseListObjects.mockReturnValue({
40
+ data: {
41
+ pages: [
42
+ {
43
+ objects: [
44
+ {
45
+ Key: "file.txt"
46
+ }
47
+ ],
48
+ commonPrefixes: []
49
+ }
50
+ ]
51
+ },
52
+ status: "success",
53
+ error: null
54
+ });
55
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
56
+ expect(result.current.isEmpty).toBe(false);
57
+ expect(result.current.isLoading).toBe(false);
58
+ });
59
+ it("returns false when bucket has folders", ()=>{
60
+ mockUseListObjects.mockReturnValue({
61
+ data: {
62
+ pages: [
63
+ {
64
+ objects: [],
65
+ commonPrefixes: [
66
+ {
67
+ Prefix: "folder/"
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ },
73
+ status: "success",
74
+ error: null
75
+ });
76
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
77
+ expect(result.current.isEmpty).toBe(false);
78
+ expect(result.current.isLoading).toBe(false);
79
+ });
80
+ it("handles error state", ()=>{
81
+ const testError = new Error("Access denied");
82
+ mockUseListObjects.mockReturnValue({
83
+ data: void 0,
84
+ status: "error",
85
+ error: testError
86
+ });
87
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
88
+ expect(result.current.isEmpty).toBe(null);
89
+ expect(result.current.isLoading).toBe(false);
90
+ expect(result.current.error).toBe(testError);
91
+ });
92
+ it("ignores invalid objects and prefixes", ()=>{
93
+ mockUseListObjects.mockReturnValue({
94
+ data: {
95
+ pages: [
96
+ {
97
+ objects: [
98
+ {
99
+ Key: void 0
100
+ },
101
+ {
102
+ Key: ""
103
+ }
104
+ ],
105
+ commonPrefixes: [
106
+ {
107
+ Prefix: null
108
+ },
109
+ {
110
+ Prefix: ""
111
+ }
112
+ ]
113
+ }
114
+ ]
115
+ },
116
+ status: "success",
117
+ error: null
118
+ });
119
+ const { result } = renderHookWithWrapper(()=>useIsBucketEmpty("test-bucket"));
120
+ expect(result.current.isEmpty).toBe(true);
121
+ });
122
+ });
@@ -0,0 +1,147 @@
1
+ /**
2
+ * S3 Bucket Configuration Operations
3
+ *
4
+ * This file contains hooks for managing bucket configuration settings
5
+ * like ACL, policies, versioning, CORS, lifecycle, etc.
6
+ */
7
+ import { GetBucketAclCommandInput, GetBucketAclCommandOutput, PutBucketAclCommandInput, PutBucketAclCommandOutput, GetBucketPolicyCommandInput, GetBucketPolicyCommandOutput, PutBucketPolicyCommandInput, PutBucketPolicyCommandOutput, DeleteBucketPolicyCommandInput, DeleteBucketPolicyCommandOutput, GetBucketVersioningCommandInput, GetBucketVersioningCommandOutput, PutBucketVersioningCommandInput, PutBucketVersioningCommandOutput, GetBucketCorsCommandInput, GetBucketCorsCommandOutput, PutBucketCorsCommandInput, PutBucketCorsCommandOutput, DeleteBucketCorsCommandInput, DeleteBucketCorsCommandOutput, GetBucketLifecycleConfigurationCommandInput, GetBucketLifecycleConfigurationCommandOutput, PutBucketLifecycleConfigurationCommandInput, PutBucketLifecycleConfigurationCommandOutput, DeleteBucketLifecycleCommandInput, DeleteBucketLifecycleCommandOutput, GetBucketNotificationConfigurationCommandInput, GetBucketNotificationConfigurationCommandOutput, PutBucketNotificationConfigurationCommandInput, PutBucketNotificationConfigurationCommandOutput, GetBucketEncryptionCommandInput, GetBucketEncryptionCommandOutput, PutBucketEncryptionCommandInput, PutBucketEncryptionCommandOutput, GetBucketTaggingCommandInput, GetBucketTaggingCommandOutput, PutBucketTaggingCommandInput, PutBucketTaggingCommandOutput, DeleteBucketTaggingCommandInput, DeleteBucketTaggingCommandOutput, GetObjectLockConfigurationCommandInput, GetObjectLockConfigurationCommandOutput, PutObjectLockConfigurationCommandInput, PutObjectLockConfigurationCommandOutput } from "@aws-sdk/client-s3";
8
+ /**
9
+ * Hook for retrieving S3 bucket access control list (ACL) settings
10
+ *
11
+ * Fetches the access control list of an S3 bucket, which defines permissions
12
+ * for different AWS accounts or predefined groups.
13
+ */
14
+ export declare const useGetBucketAcl: (params?: GetBucketAclCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketAclCommandOutput, import("..").EnhancedS3Error, GetBucketAclCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketAclCommandOutput, import("..").EnhancedS3Error>;
15
+ /**
16
+ * Hook for setting S3 bucket ACL (Access Control List)
17
+ *
18
+ * Updates the access control list for an S3 bucket. The ACL defines which AWS
19
+ * accounts or groups are granted access and the type of access.
20
+ */
21
+ export declare const useSetBucketAcl: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketAclCommandOutput, import("..").EnhancedS3Error, PutBucketAclCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketAclCommandOutput, import("..").EnhancedS3Error, PutBucketAclCommandInput>;
22
+ /**
23
+ * Hook for retrieving S3 bucket policy
24
+ *
25
+ * Fetches the bucket policy for an S3 bucket as a JSON string. The bucket policy
26
+ * defines permissions for accessing the bucket and its objects.
27
+ */
28
+ export declare const useGetBucketPolicy: (params?: GetBucketPolicyCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketPolicyCommandOutput, import("..").EnhancedS3Error, GetBucketPolicyCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketPolicyCommandOutput, import("..").EnhancedS3Error>;
29
+ /**
30
+ * Hook for setting S3 bucket policy
31
+ *
32
+ * Updates the bucket policy for an S3 bucket. The policy must be a valid JSON
33
+ * document that defines access permissions.
34
+ */
35
+ export declare const useSetBucketPolicy: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketPolicyCommandOutput, import("..").EnhancedS3Error, PutBucketPolicyCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketPolicyCommandOutput, import("..").EnhancedS3Error, PutBucketPolicyCommandInput>;
36
+ /**
37
+ * Hook for deleting S3 bucket policy
38
+ *
39
+ * Removes the bucket policy from an S3 bucket, reverting to default access controls.
40
+ */
41
+ export declare const useDeleteBucketPolicy: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<DeleteBucketPolicyCommandOutput, import("..").EnhancedS3Error, DeleteBucketPolicyCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<DeleteBucketPolicyCommandOutput, import("..").EnhancedS3Error, DeleteBucketPolicyCommandInput>;
42
+ /**
43
+ * Hook for retrieving S3 bucket versioning configuration
44
+ *
45
+ * Fetches the versioning state of an S3 bucket. Returns information about
46
+ * whether versioning is enabled, suspended, or never configured.
47
+ */
48
+ export declare const useGetBucketVersioning: (params?: GetBucketVersioningCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketVersioningCommandOutput, import("..").EnhancedS3Error, GetBucketVersioningCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketVersioningCommandOutput, import("..").EnhancedS3Error>;
49
+ /**
50
+ * Hook for setting S3 bucket versioning configuration
51
+ *
52
+ * Enables or suspends versioning on an S3 bucket. Once versioning is enabled,
53
+ * it cannot be disabled, only suspended.
54
+ */
55
+ export declare const useSetBucketVersioning: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketVersioningCommandOutput, import("..").EnhancedS3Error, PutBucketVersioningCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketVersioningCommandOutput, import("..").EnhancedS3Error, PutBucketVersioningCommandInput>;
56
+ /**
57
+ * Hook for retrieving S3 bucket CORS configuration
58
+ *
59
+ * Fetches the Cross-Origin Resource Sharing (CORS) configuration for an S3 bucket.
60
+ * CORS rules define how web applications from different domains can access bucket resources.
61
+ */
62
+ export declare const useGetBucketCors: (params?: GetBucketCorsCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketCorsCommandOutput, import("..").EnhancedS3Error, GetBucketCorsCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketCorsCommandOutput, import("..").EnhancedS3Error>;
63
+ /**
64
+ * Hook for setting S3 bucket CORS configuration
65
+ *
66
+ * Sets the CORS configuration for an S3 bucket. CORS rules specify which domains
67
+ * can access bucket resources and what HTTP methods are allowed.
68
+ */
69
+ export declare const useSetBucketCors: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketCorsCommandOutput, import("..").EnhancedS3Error, PutBucketCorsCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketCorsCommandOutput, import("..").EnhancedS3Error, PutBucketCorsCommandInput>;
70
+ /**
71
+ * Hook for deleting S3 bucket CORS configuration
72
+ *
73
+ * Removes the CORS configuration from an S3 bucket, disabling cross-origin access.
74
+ */
75
+ export declare const useDeleteBucketCors: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<DeleteBucketCorsCommandOutput, import("..").EnhancedS3Error, DeleteBucketCorsCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<DeleteBucketCorsCommandOutput, import("..").EnhancedS3Error, DeleteBucketCorsCommandInput>;
76
+ /**
77
+ * Hook for retrieving S3 bucket lifecycle configuration
78
+ *
79
+ * Fetches the lifecycle configuration for an S3 bucket. Lifecycle rules define
80
+ * automatic actions like transitioning objects to different storage classes or deleting them.
81
+ */
82
+ export declare const useGetBucketLifecycle: (params?: GetBucketLifecycleConfigurationCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketLifecycleConfigurationCommandOutput, import("..").EnhancedS3Error, GetBucketLifecycleConfigurationCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketLifecycleConfigurationCommandOutput, import("..").EnhancedS3Error>;
83
+ /**
84
+ * Hook for setting S3 bucket lifecycle configuration
85
+ *
86
+ * Sets the lifecycle configuration for an S3 bucket. Lifecycle rules can automatically
87
+ * transition objects between storage classes and delete expired objects.
88
+ */
89
+ export declare const useSetBucketLifecycle: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketLifecycleConfigurationCommandOutput, import("..").EnhancedS3Error, PutBucketLifecycleConfigurationCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketLifecycleConfigurationCommandOutput, import("..").EnhancedS3Error, PutBucketLifecycleConfigurationCommandInput>;
90
+ /**
91
+ * Hook for deleting S3 bucket lifecycle configuration
92
+ *
93
+ * Removes the lifecycle configuration from an S3 bucket, disabling automatic
94
+ * object transitions and expiration.
95
+ */
96
+ export declare const useDeleteBucketLifecycle: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<DeleteBucketLifecycleCommandOutput, import("..").EnhancedS3Error, DeleteBucketLifecycleCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<DeleteBucketLifecycleCommandOutput, import("..").EnhancedS3Error, DeleteBucketLifecycleCommandInput>;
97
+ /**
98
+ * Hook for retrieving S3 bucket notification configuration
99
+ *
100
+ * Fetches the notification configuration for an S3 bucket. Notifications can be
101
+ * sent to SNS topics, SQS queues, or Lambda functions when certain events occur.
102
+ */
103
+ export declare const useGetBucketNotification: (params?: GetBucketNotificationConfigurationCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketNotificationConfigurationCommandOutput, import("..").EnhancedS3Error, GetBucketNotificationConfigurationCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketNotificationConfigurationCommandOutput, import("..").EnhancedS3Error>;
104
+ /**
105
+ * Hook for setting S3 bucket notification configuration
106
+ *
107
+ * Sets the notification configuration for an S3 bucket. Configures which events
108
+ * trigger notifications and where those notifications are sent.
109
+ */
110
+ export declare const useSetBucketNotification: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketNotificationConfigurationCommandOutput, import("..").EnhancedS3Error, PutBucketNotificationConfigurationCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketNotificationConfigurationCommandOutput, import("..").EnhancedS3Error, PutBucketNotificationConfigurationCommandInput>;
111
+ /**
112
+ * Hook for retrieving S3 bucket encryption configuration
113
+ *
114
+ * Fetches the default encryption configuration for an S3 bucket. This determines
115
+ * how objects are encrypted when uploaded without explicit encryption settings.
116
+ */
117
+ export declare const useGetBucketEncryption: (params?: GetBucketEncryptionCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketEncryptionCommandOutput, import("..").EnhancedS3Error, GetBucketEncryptionCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketEncryptionCommandOutput, import("..").EnhancedS3Error>;
118
+ /**
119
+ * Hook for setting S3 bucket encryption configuration
120
+ *
121
+ * Sets the default encryption configuration for an S3 bucket. Objects uploaded
122
+ * without explicit encryption will use this configuration.
123
+ */
124
+ export declare const useSetBucketEncryption: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketEncryptionCommandOutput, import("..").EnhancedS3Error, PutBucketEncryptionCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketEncryptionCommandOutput, import("..").EnhancedS3Error, PutBucketEncryptionCommandInput>;
125
+ /**
126
+ * Hook for retrieving S3 bucket tags
127
+ *
128
+ * Fetches the tag set associated with an S3 bucket. Tags are key-value pairs
129
+ * that provide metadata for organizing and managing buckets.
130
+ */
131
+ export declare const useGetBucketTagging: (params?: GetBucketTaggingCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketTaggingCommandOutput, import("..").EnhancedS3Error, GetBucketTaggingCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketTaggingCommandOutput, import("..").EnhancedS3Error>;
132
+ /**
133
+ * Hook for setting S3 bucket tags
134
+ *
135
+ * Sets or updates the tag set for an S3 bucket. Tags help organize and categorize
136
+ * buckets for billing, access control, and management purposes.
137
+ */
138
+ export declare const useSetBucketTagging: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutBucketTaggingCommandOutput, import("..").EnhancedS3Error, PutBucketTaggingCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutBucketTaggingCommandOutput, import("..").EnhancedS3Error, PutBucketTaggingCommandInput>;
139
+ /**
140
+ * Hook for deleting S3 bucket tags
141
+ *
142
+ * Removes all tags from an S3 bucket. This operation cannot be undone,
143
+ * so use with caution.
144
+ */
145
+ export declare const useDeleteBucketTagging: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<DeleteBucketTaggingCommandOutput, import("..").EnhancedS3Error, DeleteBucketTaggingCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<DeleteBucketTaggingCommandOutput, import("..").EnhancedS3Error, DeleteBucketTaggingCommandInput>;
146
+ export declare const useGetBucketObjectLockConfiguration: (params?: GetObjectLockConfigurationCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetObjectLockConfigurationCommandOutput, import("..").EnhancedS3Error, GetObjectLockConfigurationCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetObjectLockConfigurationCommandOutput, import("..").EnhancedS3Error>;
147
+ export declare const useSetBucketObjectLockConfiguration: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<PutObjectLockConfigurationCommandOutput, import("..").EnhancedS3Error, PutObjectLockConfigurationCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<PutObjectLockConfigurationCommandOutput, import("..").EnhancedS3Error, PutObjectLockConfigurationCommandInput>;
@@ -0,0 +1,59 @@
1
+ import { DeleteBucketCorsCommand, DeleteBucketLifecycleCommand, DeleteBucketPolicyCommand, DeleteBucketTaggingCommand, GetBucketAclCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketNotificationConfigurationCommand, GetBucketPolicyCommand, GetBucketTaggingCommand, GetBucketVersioningCommand, GetObjectLockConfigurationCommand, PutBucketAclCommand, PutBucketCorsCommand, PutBucketEncryptionCommand, PutBucketLifecycleConfigurationCommand, PutBucketNotificationConfigurationCommand, PutBucketPolicyCommand, PutBucketTaggingCommand, PutBucketVersioningCommand, PutObjectLockConfigurationCommand } from "@aws-sdk/client-s3";
2
+ import { useCreateS3QueryHook } from "./factories/useCreateS3QueryHook.js";
3
+ import { useCreateS3MutationHook } from "./factories/useCreateS3MutationHook.js";
4
+ const useGetBucketAcl = useCreateS3QueryHook(GetBucketAclCommand, "GetBucketAcl");
5
+ const useSetBucketAcl = useCreateS3MutationHook(PutBucketAclCommand, "PutBucketAcl", [
6
+ "GetBucketAcl",
7
+ "ListBuckets"
8
+ ]);
9
+ const useGetBucketPolicy = useCreateS3QueryHook(GetBucketPolicyCommand, "GetBucketPolicy");
10
+ const useSetBucketPolicy = useCreateS3MutationHook(PutBucketPolicyCommand, "PutBucketPolicy", [
11
+ "GetBucketPolicy",
12
+ "ListBuckets"
13
+ ]);
14
+ const useDeleteBucketPolicy = useCreateS3MutationHook(DeleteBucketPolicyCommand, "DeleteBucketPolicy", [
15
+ "GetBucketPolicy"
16
+ ]);
17
+ const useGetBucketVersioning = useCreateS3QueryHook(GetBucketVersioningCommand, "GetBucketVersioning");
18
+ const useSetBucketVersioning = useCreateS3MutationHook(PutBucketVersioningCommand, "PutBucketVersioning", [
19
+ "GetBucketVersioning"
20
+ ]);
21
+ const useGetBucketCors = useCreateS3QueryHook(GetBucketCorsCommand, "GetBucketCors");
22
+ const useSetBucketCors = useCreateS3MutationHook(PutBucketCorsCommand, "PutBucketCors", [
23
+ "GetBucketCors",
24
+ "ListBuckets"
25
+ ]);
26
+ const useDeleteBucketCors = useCreateS3MutationHook(DeleteBucketCorsCommand, "DeleteBucketCors", [
27
+ "GetBucketCors"
28
+ ]);
29
+ const useGetBucketLifecycle = useCreateS3QueryHook(GetBucketLifecycleConfigurationCommand, "GetBucketLifecycleConfiguration");
30
+ const useSetBucketLifecycle = useCreateS3MutationHook(PutBucketLifecycleConfigurationCommand, "PutBucketLifecycleConfiguration", [
31
+ "GetBucketLifecycleConfiguration",
32
+ "ListBuckets"
33
+ ]);
34
+ const useDeleteBucketLifecycle = useCreateS3MutationHook(DeleteBucketLifecycleCommand, "DeleteBucketLifecycle", [
35
+ "GetBucketLifecycleConfiguration"
36
+ ]);
37
+ const useGetBucketNotification = useCreateS3QueryHook(GetBucketNotificationConfigurationCommand, "GetBucketNotificationConfiguration");
38
+ const useSetBucketNotification = useCreateS3MutationHook(PutBucketNotificationConfigurationCommand, "PutBucketNotificationConfiguration", [
39
+ "GetBucketNotificationConfiguration",
40
+ "ListBuckets"
41
+ ]);
42
+ const useGetBucketEncryption = useCreateS3QueryHook(GetBucketEncryptionCommand, "GetBucketEncryption");
43
+ const useSetBucketEncryption = useCreateS3MutationHook(PutBucketEncryptionCommand, "PutBucketEncryption", [
44
+ "GetBucketEncryption",
45
+ "ListBuckets"
46
+ ]);
47
+ const useGetBucketTagging = useCreateS3QueryHook(GetBucketTaggingCommand, "GetBucketTagging");
48
+ const useSetBucketTagging = useCreateS3MutationHook(PutBucketTaggingCommand, "PutBucketTagging", [
49
+ "GetBucketTagging",
50
+ "ListBuckets"
51
+ ]);
52
+ const useDeleteBucketTagging = useCreateS3MutationHook(DeleteBucketTaggingCommand, "DeleteBucketTagging", [
53
+ "GetBucketTagging"
54
+ ]);
55
+ const useGetBucketObjectLockConfiguration = useCreateS3QueryHook(GetObjectLockConfigurationCommand, "GetObjectLockConfiguration");
56
+ const useSetBucketObjectLockConfiguration = useCreateS3MutationHook(PutObjectLockConfigurationCommand, "PutObjectLockConfiguration", [
57
+ "GetObjectLockConfiguration"
58
+ ]);
59
+ export { useDeleteBucketCors, useDeleteBucketLifecycle, useDeleteBucketPolicy, useDeleteBucketTagging, useGetBucketAcl, useGetBucketCors, useGetBucketEncryption, useGetBucketLifecycle, useGetBucketNotification, useGetBucketObjectLockConfiguration, useGetBucketPolicy, useGetBucketTagging, useGetBucketVersioning, useSetBucketAcl, useSetBucketCors, useSetBucketEncryption, useSetBucketLifecycle, useSetBucketNotification, useSetBucketObjectLockConfiguration, useSetBucketPolicy, useSetBucketTagging, useSetBucketVersioning };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Basic S3 Bucket Operations
3
+ *
4
+ * This file contains hooks for fundamental bucket operations like
5
+ * listing, creating, and deleting buckets.
6
+ */
7
+ import { ListBucketsCommandInput, ListBucketsCommandOutput, CreateBucketCommandInput, CreateBucketCommandOutput, DeleteBucketCommandInput, DeleteBucketCommandOutput, GetBucketLocationCommandInput, GetBucketLocationCommandOutput } from "@aws-sdk/client-s3";
8
+ /**
9
+ * Hook for listing all S3 buckets
10
+ *
11
+ * Lists all S3 buckets accessible to the authenticated user.
12
+ * Note: Unlike objects listing, bucket listing doesn't support pagination
13
+ * as S3 returns all buckets in a single response.
14
+ */
15
+ export declare const useBuckets: (params?: ListBucketsCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<ListBucketsCommandOutput, import("..").EnhancedS3Error, ListBucketsCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<ListBucketsCommandOutput, import("..").EnhancedS3Error>;
16
+ /**
17
+ * Hook for retrieving S3 bucket location constraint information
18
+ *
19
+ * Fetches the AWS region where an S3 bucket is located. This is essential
20
+ * for cross-region operations and understanding bucket placement.
21
+ */
22
+ export declare const useGetBucketLocation: (params?: GetBucketLocationCommandInput | undefined, options?: Omit<import("@tanstack/react-query").UseQueryOptions<GetBucketLocationCommandOutput, import("..").EnhancedS3Error, GetBucketLocationCommandOutput, readonly unknown[]>, "queryKey" | "queryFn"> | undefined) => import("@tanstack/react-query").UseQueryResult<GetBucketLocationCommandOutput, import("..").EnhancedS3Error>;
23
+ /**
24
+ * Hook for creating a new S3 bucket
25
+ *
26
+ * Creates a new S3 bucket with specified configuration options.
27
+ * Automatically invalidates the buckets list after successful creation.
28
+ */
29
+ export declare const useCreateBucket: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<CreateBucketCommandOutput, import("..").EnhancedS3Error, CreateBucketCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<CreateBucketCommandOutput, import("..").EnhancedS3Error, CreateBucketCommandInput>;
30
+ /**
31
+ * Hook for deleting an S3 bucket
32
+ *
33
+ * Deletes an empty S3 bucket. The bucket must be empty before deletion.
34
+ * Automatically invalidates the buckets list after successful deletion.
35
+ */
36
+ export declare const useDeleteBucket: (options?: Omit<import("@tanstack/react-query").UseMutationOptions<DeleteBucketCommandOutput, import("..").EnhancedS3Error, DeleteBucketCommandInput, unknown>, "mutationFn"> | undefined) => import("@tanstack/react-query").UseMutationResult<DeleteBucketCommandOutput, import("..").EnhancedS3Error, DeleteBucketCommandInput>;
@@ -0,0 +1,12 @@
1
+ import { CreateBucketCommand, DeleteBucketCommand, GetBucketLocationCommand, ListBucketsCommand } from "@aws-sdk/client-s3";
2
+ import { useCreateS3QueryHook } from "./factories/useCreateS3QueryHook.js";
3
+ import { useCreateS3MutationHook } from "./factories/useCreateS3MutationHook.js";
4
+ const useBuckets = useCreateS3QueryHook(ListBucketsCommand, "ListBuckets");
5
+ const useGetBucketLocation = useCreateS3QueryHook(GetBucketLocationCommand, "GetBucketLocation");
6
+ const useCreateBucket = useCreateS3MutationHook(CreateBucketCommand, "CreateBucket", [
7
+ "ListBuckets"
8
+ ]);
9
+ const useDeleteBucket = useCreateS3MutationHook(DeleteBucketCommand, "DeleteBucket", [
10
+ "ListBuckets"
11
+ ]);
12
+ export { useBuckets, useCreateBucket, useDeleteBucket, useGetBucketLocation };