@computesdk/s3 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 computesdk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # @computesdk/s3
2
+
3
+ AWS S3 storage provider for ComputeSDK - object storage with S3-compatible API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @computesdk/s3
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { s3 } from '@computesdk/s3';
15
+
16
+ // Create storage instance
17
+ const storage = s3({
18
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID,
19
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
20
+ region: 'us-east-1'
21
+ });
22
+
23
+ // Upload a file
24
+ await storage.upload('my-bucket', 'path/to/file.txt', 'Hello, World!');
25
+
26
+ // Upload with options
27
+ await storage.upload('my-bucket', 'image.png', buffer, {
28
+ contentType: 'image/png',
29
+ metadata: { author: 'user-123' }
30
+ });
31
+
32
+ // Download a file
33
+ const result = await storage.download('my-bucket', 'path/to/file.txt');
34
+ console.log(Buffer.from(result.data).toString());
35
+
36
+ // Delete a file
37
+ await storage.delete('my-bucket', 'path/to/file.txt');
38
+
39
+ // List objects
40
+ const list = await storage.list('my-bucket', { prefix: 'path/to/' });
41
+ for (const obj of list.objects) {
42
+ console.log(`${obj.key}: ${obj.size} bytes`);
43
+ }
44
+ ```
45
+
46
+ ## Configuration
47
+
48
+ | Option | Type | Required | Default | Description |
49
+ |--------|------|----------|---------|-------------|
50
+ | `accessKeyId` | string | No* | `AWS_ACCESS_KEY_ID` env | AWS access key |
51
+ | `secretAccessKey` | string | No* | `AWS_SECRET_ACCESS_KEY` env | AWS secret key |
52
+ | `region` | string | No | `us-east-1` | AWS region |
53
+ | `endpoint` | string | No | - | Custom endpoint for S3-compatible services |
54
+ | `forcePathStyle` | boolean | No | false | Use path-style URLs |
55
+
56
+ *Either provide in config or set environment variables.
57
+
58
+ ## API
59
+
60
+ ### `upload(bucket, key, data, options?)`
61
+
62
+ Upload data to S3.
63
+
64
+ - **bucket**: Bucket name
65
+ - **key**: Object key/path
66
+ - **data**: `Uint8Array` or `string` to upload (Node `Buffer` also works as it's a Uint8Array subclass)
67
+ - **options**: Optional upload configuration
68
+ - `contentType`: MIME type (default: `application/octet-stream`)
69
+ - `metadata`: Custom metadata object
70
+
71
+ Returns `Promise<StorageObject>` with metadata about the uploaded object.
72
+
73
+ ### `download(bucket, key)`
74
+
75
+ Download data from S3.
76
+
77
+ - **bucket**: Bucket name
78
+ - **key**: Object key/path
79
+
80
+ Returns `Promise<DownloadResult>` containing:
81
+ - `data`: `Uint8Array` with object contents (Node `Buffer` can be created with `Buffer.from(data)`)
82
+ - `size`: Object size in bytes
83
+ - `contentType`: MIME type
84
+ - `etag`: Entity tag
85
+ - `lastModified`: Last modification date
86
+ - `metadata`: Custom metadata
87
+
88
+ ### `delete(bucket, key)`
89
+
90
+ Delete object from S3.
91
+
92
+ - **bucket**: Bucket name
93
+ - **key**: Object key/path
94
+
95
+ Returns `Promise<void>`.
96
+
97
+ ### `list(bucket, options?)`
98
+
99
+ List objects in bucket.
100
+
101
+ - **bucket**: Bucket name
102
+ - **options**: Optional list configuration
103
+ - `prefix`: Filter by prefix
104
+ - `maxKeys`: Maximum results (default: 1000)
105
+ - `continuationToken`: Pagination token
106
+
107
+ Returns `Promise<ListResult>` containing:
108
+ - `objects`: Array of `StorageObject`
109
+ - `truncated`: Whether there are more results
110
+ - `continuationToken`: Token for next page
111
+
112
+ ### `getClient()`
113
+
114
+ Get the underlying AWS S3 client for advanced operations.
115
+
116
+ Returns `S3Client` from `@aws-sdk/client-s3`.
117
+
118
+ ## Environment Variables
119
+
120
+ ```bash
121
+ export AWS_ACCESS_KEY_ID=your-access-key
122
+ export AWS_SECRET_ACCESS_KEY=your-secret-key
123
+ export AWS_REGION=us-east-1 # optional, defaults to us-east-1
124
+ ```
125
+
126
+ ## License
127
+
128
+ MIT
@@ -0,0 +1,69 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { StorageProvider, UploadOptions, StorageObject, DownloadResult, ListOptions, ListResult } from '@computesdk/provider';
3
+
4
+ /**
5
+ * AWS S3 Storage Provider
6
+ *
7
+ * Object storage using AWS S3 with the ComputeSDK storage interface.
8
+ */
9
+
10
+ /**
11
+ * AWS S3-specific configuration options
12
+ */
13
+ interface S3Config {
14
+ /** AWS Access Key ID - if not provided, will use AWS_ACCESS_KEY_ID environment variable */
15
+ accessKeyId?: string;
16
+ /** AWS Secret Access Key - if not provided, will use AWS_SECRET_ACCESS_KEY environment variable */
17
+ secretAccessKey?: string;
18
+ /** AWS region - defaults to us-east-1 */
19
+ region?: string;
20
+ /** Optional custom endpoint for S3-compatible services */
21
+ endpoint?: string;
22
+ /** Optional force path style (needed for some S3-compatible services) */
23
+ forcePathStyle?: boolean;
24
+ }
25
+ /**
26
+ * AWS S3 Storage instance
27
+ */
28
+ interface S3 extends StorageProvider {
29
+ /** Upload data to S3 */
30
+ upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject>;
31
+ /** Download data from S3 */
32
+ download(bucket: string, key: string): Promise<DownloadResult>;
33
+ /** Delete object from S3 */
34
+ delete(bucket: string, key: string): Promise<void>;
35
+ /** List objects in S3 bucket */
36
+ list(bucket: string, options?: ListOptions): Promise<ListResult>;
37
+ /** Get the underlying S3 client for advanced operations */
38
+ getClient(): S3Client;
39
+ }
40
+ /**
41
+ * Create an AWS S3 storage provider instance
42
+ *
43
+ * @param config - S3 configuration options
44
+ * @returns S3 instance
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { s3 } from '@computesdk/s3';
49
+ *
50
+ * const storage = s3({
51
+ * accessKeyId: process.env.AWS_ACCESS_KEY_ID,
52
+ * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
53
+ * region: 'us-east-1'
54
+ * });
55
+ *
56
+ * // Upload a file
57
+ * await storage.upload('my-bucket', 'path/to/file.txt', 'Hello, World!');
58
+ *
59
+ * // Download a file
60
+ * const result = await storage.download('my-bucket', 'path/to/file.txt');
61
+ * console.log(result.data.toString());
62
+ *
63
+ * // Delete a file
64
+ * await storage.delete('my-bucket', 'path/to/file.txt');
65
+ * ```
66
+ */
67
+ declare function s3(config: S3Config): S3;
68
+
69
+ export { type S3, type S3Config, s3 };
@@ -0,0 +1,69 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { StorageProvider, UploadOptions, StorageObject, DownloadResult, ListOptions, ListResult } from '@computesdk/provider';
3
+
4
+ /**
5
+ * AWS S3 Storage Provider
6
+ *
7
+ * Object storage using AWS S3 with the ComputeSDK storage interface.
8
+ */
9
+
10
+ /**
11
+ * AWS S3-specific configuration options
12
+ */
13
+ interface S3Config {
14
+ /** AWS Access Key ID - if not provided, will use AWS_ACCESS_KEY_ID environment variable */
15
+ accessKeyId?: string;
16
+ /** AWS Secret Access Key - if not provided, will use AWS_SECRET_ACCESS_KEY environment variable */
17
+ secretAccessKey?: string;
18
+ /** AWS region - defaults to us-east-1 */
19
+ region?: string;
20
+ /** Optional custom endpoint for S3-compatible services */
21
+ endpoint?: string;
22
+ /** Optional force path style (needed for some S3-compatible services) */
23
+ forcePathStyle?: boolean;
24
+ }
25
+ /**
26
+ * AWS S3 Storage instance
27
+ */
28
+ interface S3 extends StorageProvider {
29
+ /** Upload data to S3 */
30
+ upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject>;
31
+ /** Download data from S3 */
32
+ download(bucket: string, key: string): Promise<DownloadResult>;
33
+ /** Delete object from S3 */
34
+ delete(bucket: string, key: string): Promise<void>;
35
+ /** List objects in S3 bucket */
36
+ list(bucket: string, options?: ListOptions): Promise<ListResult>;
37
+ /** Get the underlying S3 client for advanced operations */
38
+ getClient(): S3Client;
39
+ }
40
+ /**
41
+ * Create an AWS S3 storage provider instance
42
+ *
43
+ * @param config - S3 configuration options
44
+ * @returns S3 instance
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { s3 } from '@computesdk/s3';
49
+ *
50
+ * const storage = s3({
51
+ * accessKeyId: process.env.AWS_ACCESS_KEY_ID,
52
+ * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
53
+ * region: 'us-east-1'
54
+ * });
55
+ *
56
+ * // Upload a file
57
+ * await storage.upload('my-bucket', 'path/to/file.txt', 'Hello, World!');
58
+ *
59
+ * // Download a file
60
+ * const result = await storage.download('my-bucket', 'path/to/file.txt');
61
+ * console.log(result.data.toString());
62
+ *
63
+ * // Delete a file
64
+ * await storage.delete('my-bucket', 'path/to/file.txt');
65
+ * ```
66
+ */
67
+ declare function s3(config: S3Config): S3;
68
+
69
+ export { type S3, type S3Config, s3 };
package/dist/index.js ADDED
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ s3: () => s3
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_client_s3 = require("@aws-sdk/client-s3");
27
+ var import_lib_storage = require("@aws-sdk/lib-storage");
28
+ function s3(config) {
29
+ const accessKeyId = config.accessKeyId || process.env.AWS_ACCESS_KEY_ID;
30
+ const secretAccessKey = config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;
31
+ const region = config.region || process.env.AWS_REGION || "us-east-1";
32
+ if (!accessKeyId) {
33
+ throw new Error(
34
+ `Missing AWS Access Key ID. Provide 'accessKeyId' in config or set AWS_ACCESS_KEY_ID environment variable.`
35
+ );
36
+ }
37
+ if (!secretAccessKey) {
38
+ throw new Error(
39
+ `Missing AWS Secret Access Key. Provide 'secretAccessKey' in config or set AWS_SECRET_ACCESS_KEY environment variable.`
40
+ );
41
+ }
42
+ const client = new import_client_s3.S3Client({
43
+ region,
44
+ credentials: {
45
+ accessKeyId,
46
+ secretAccessKey
47
+ },
48
+ ...config.endpoint && { endpoint: config.endpoint },
49
+ ...config.forcePathStyle && { forcePathStyle: config.forcePathStyle }
50
+ });
51
+ return {
52
+ async upload(bucket, key, data, options) {
53
+ try {
54
+ const body = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);
55
+ const contentType = options?.contentType || "application/octet-stream";
56
+ const upload = new import_lib_storage.Upload({
57
+ client,
58
+ params: {
59
+ Bucket: bucket,
60
+ Key: key,
61
+ Body: body,
62
+ ContentType: contentType,
63
+ ...options?.metadata && { Metadata: options.metadata }
64
+ },
65
+ queueSize: 4,
66
+ partSize: 5 * 1024 * 1024
67
+ // 5MB
68
+ });
69
+ await upload.done();
70
+ return {
71
+ bucket,
72
+ key,
73
+ size: body.length,
74
+ etag: void 0,
75
+ // Upload doesn't return ETag directly
76
+ lastModified: /* @__PURE__ */ new Date()
77
+ };
78
+ } catch (error) {
79
+ throw new Error(
80
+ `Failed to upload to S3: ${error instanceof Error ? error.message : String(error)}`
81
+ );
82
+ }
83
+ },
84
+ async download(bucket, key) {
85
+ try {
86
+ const command = new import_client_s3.GetObjectCommand({
87
+ Bucket: bucket,
88
+ Key: key
89
+ });
90
+ const response = await client.send(command);
91
+ const chunks = [];
92
+ if (response.Body) {
93
+ for await (const chunk of response.Body) {
94
+ chunks.push(new Uint8Array(chunk));
95
+ }
96
+ }
97
+ let totalLength = 0;
98
+ for (const chunk of chunks) {
99
+ totalLength += chunk.length;
100
+ }
101
+ const data = new Uint8Array(totalLength);
102
+ let offset = 0;
103
+ for (const chunk of chunks) {
104
+ data.set(chunk, offset);
105
+ offset += chunk.length;
106
+ }
107
+ return {
108
+ data,
109
+ size: data.length,
110
+ contentType: response.ContentType,
111
+ etag: response.ETag,
112
+ lastModified: response.LastModified,
113
+ metadata: response.Metadata
114
+ };
115
+ } catch (error) {
116
+ if (error instanceof Error && error.name === "NoSuchKey") {
117
+ throw new Error(`Object not found: s3://${bucket}/${key}`);
118
+ }
119
+ throw new Error(
120
+ `Failed to download from S3: ${error instanceof Error ? error.message : String(error)}`
121
+ );
122
+ }
123
+ },
124
+ async delete(bucket, key) {
125
+ try {
126
+ const command = new import_client_s3.DeleteObjectCommand({
127
+ Bucket: bucket,
128
+ Key: key
129
+ });
130
+ await client.send(command);
131
+ } catch (error) {
132
+ throw new Error(
133
+ `Failed to delete from S3: ${error instanceof Error ? error.message : String(error)}`
134
+ );
135
+ }
136
+ },
137
+ async list(bucket, options) {
138
+ try {
139
+ const command = new import_client_s3.ListObjectsV2Command({
140
+ Bucket: bucket,
141
+ Prefix: options?.prefix,
142
+ MaxKeys: options?.maxKeys ?? 1e3,
143
+ ContinuationToken: options?.continuationToken
144
+ });
145
+ const response = await client.send(command);
146
+ return {
147
+ objects: (response.Contents || []).map((obj) => ({
148
+ bucket,
149
+ key: obj.Key || "",
150
+ size: obj.Size || 0,
151
+ etag: obj.ETag,
152
+ lastModified: obj.LastModified
153
+ })),
154
+ truncated: response.IsTruncated || false,
155
+ continuationToken: response.NextContinuationToken
156
+ };
157
+ } catch (error) {
158
+ throw new Error(
159
+ `Failed to list objects in S3: ${error instanceof Error ? error.message : String(error)}`
160
+ );
161
+ }
162
+ },
163
+ getClient() {
164
+ return client;
165
+ }
166
+ };
167
+ }
168
+ // Annotate the CommonJS export names for ESM import in node:
169
+ 0 && (module.exports = {
170
+ s3
171
+ });
172
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * AWS S3 Storage Provider\n * \n * Object storage using AWS S3 with the ComputeSDK storage interface.\n */\n\nimport { S3Client, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';\nimport { Upload } from '@aws-sdk/lib-storage';\nimport type { StorageProvider, StorageObject, UploadOptions, DownloadResult, ListOptions, ListResult } from '@computesdk/provider';\n\n/**\n * AWS S3-specific configuration options\n */\nexport interface S3Config {\n /** AWS Access Key ID - if not provided, will use AWS_ACCESS_KEY_ID environment variable */\n accessKeyId?: string;\n /** AWS Secret Access Key - if not provided, will use AWS_SECRET_ACCESS_KEY environment variable */\n secretAccessKey?: string;\n /** AWS region - defaults to us-east-1 */\n region?: string;\n /** Optional custom endpoint for S3-compatible services */\n endpoint?: string;\n /** Optional force path style (needed for some S3-compatible services) */\n forcePathStyle?: boolean;\n}\n\n/**\n * AWS S3 Storage instance\n */\nexport interface S3 extends StorageProvider {\n /** Upload data to S3 */\n upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject>;\n /** Download data from S3 */\n download(bucket: string, key: string): Promise<DownloadResult>;\n /** Delete object from S3 */\n delete(bucket: string, key: string): Promise<void>;\n /** List objects in S3 bucket */\n list(bucket: string, options?: ListOptions): Promise<ListResult>;\n /** Get the underlying S3 client for advanced operations */\n getClient(): S3Client;\n}\n\n/**\n * Create an AWS S3 storage provider instance\n * \n * @param config - S3 configuration options\n * @returns S3 instance\n * \n * @example\n * ```typescript\n * import { s3 } from '@computesdk/s3';\n * \n * const storage = s3({\n * accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n * region: 'us-east-1'\n * });\n * \n * // Upload a file\n * await storage.upload('my-bucket', 'path/to/file.txt', 'Hello, World!');\n * \n * // Download a file\n * const result = await storage.download('my-bucket', 'path/to/file.txt');\n * console.log(result.data.toString());\n * \n * // Delete a file\n * await storage.delete('my-bucket', 'path/to/file.txt');\n * ```\n */\nexport function s3(config: S3Config): S3 {\n // Resolve configuration from parameters or environment\n const accessKeyId = config.accessKeyId || process.env.AWS_ACCESS_KEY_ID;\n const secretAccessKey = config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;\n const region = config.region || process.env.AWS_REGION || 'us-east-1';\n\n if (!accessKeyId) {\n throw new Error(\n `Missing AWS Access Key ID. Provide 'accessKeyId' in config or set AWS_ACCESS_KEY_ID environment variable.`\n );\n }\n\n if (!secretAccessKey) {\n throw new Error(\n `Missing AWS Secret Access Key. Provide 'secretAccessKey' in config or set AWS_SECRET_ACCESS_KEY environment variable.`\n );\n }\n\n // Create S3 client\n const client = new S3Client({\n region,\n credentials: {\n accessKeyId,\n secretAccessKey,\n },\n ...(config.endpoint && { endpoint: config.endpoint }),\n ...(config.forcePathStyle && { forcePathStyle: config.forcePathStyle }),\n });\n\n return {\n async upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject> {\n try {\n const body = typeof data === 'string' ? Buffer.from(data) : Buffer.from(data);\n const contentType = options?.contentType || 'application/octet-stream';\n\n // Use multipart upload for files larger than 5MB\n const upload = new Upload({\n client,\n params: {\n Bucket: bucket,\n Key: key,\n Body: body,\n ContentType: contentType,\n ...(options?.metadata && { Metadata: options.metadata }),\n },\n queueSize: 4,\n partSize: 5 * 1024 * 1024, // 5MB\n });\n\n await upload.done();\n\n return {\n bucket,\n key,\n size: body.length,\n etag: undefined, // Upload doesn't return ETag directly\n lastModified: new Date(),\n };\n } catch (error) {\n throw new Error(\n `Failed to upload to S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async download(bucket: string, key: string): Promise<DownloadResult> {\n try {\n const command = new GetObjectCommand({\n Bucket: bucket,\n Key: key,\n });\n\n const response = await client.send(command);\n \n // Convert stream to Uint8Array\n const chunks: Uint8Array[] = [];\n if (response.Body) {\n for await (const chunk of response.Body as any) {\n chunks.push(new Uint8Array(chunk));\n }\n }\n \n // Concatenate all chunks\n let totalLength = 0;\n for (const chunk of chunks) {\n totalLength += chunk.length;\n }\n const data = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n data.set(chunk, offset);\n offset += chunk.length;\n }\n\n return {\n data,\n size: data.length,\n contentType: response.ContentType,\n etag: response.ETag,\n lastModified: response.LastModified,\n metadata: response.Metadata,\n };\n } catch (error) {\n if (error instanceof Error && error.name === 'NoSuchKey') {\n throw new Error(`Object not found: s3://${bucket}/${key}`);\n }\n throw new Error(\n `Failed to download from S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async delete(bucket: string, key: string): Promise<void> {\n try {\n const command = new DeleteObjectCommand({\n Bucket: bucket,\n Key: key,\n });\n\n await client.send(command);\n } catch (error) {\n throw new Error(\n `Failed to delete from S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async list(bucket: string, options?: ListOptions): Promise<ListResult> {\n try {\n const command = new ListObjectsV2Command({\n Bucket: bucket,\n Prefix: options?.prefix,\n MaxKeys: options?.maxKeys ?? 1000,\n ContinuationToken: options?.continuationToken,\n });\n\n const response = await client.send(command);\n\n return {\n objects: (response.Contents || []).map(obj => ({\n bucket,\n key: obj.Key || '',\n size: obj.Size || 0,\n etag: obj.ETag,\n lastModified: obj.LastModified,\n })),\n truncated: response.IsTruncated || false,\n continuationToken: response.NextContinuationToken,\n };\n } catch (error) {\n throw new Error(\n `Failed to list objects in S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getClient(): S3Client {\n return client;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,uBAAsF;AACtF,yBAAuB;AA8DhB,SAAS,GAAG,QAAsB;AAEvC,QAAM,cAAc,OAAO,eAAe,QAAQ,IAAI;AACtD,QAAM,kBAAkB,OAAO,mBAAmB,QAAQ,IAAI;AAC9D,QAAM,SAAS,OAAO,UAAU,QAAQ,IAAI,cAAc;AAE1D,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,QAAM,SAAS,IAAI,0BAAS;AAAA,IAC1B;AAAA,IACA,aAAa;AAAA,MACX;AAAA,MACA;AAAA,IACF;AAAA,IACA,GAAI,OAAO,YAAY,EAAE,UAAU,OAAO,SAAS;AAAA,IACnD,GAAI,OAAO,kBAAkB,EAAE,gBAAgB,OAAO,eAAe;AAAA,EACvE,CAAC;AAED,SAAO;AAAA,IACL,MAAM,OAAO,QAAgB,KAAa,MAA2B,SA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AAO;AACd,cAAM,IAAI;AAAA,UACR,iCAAiC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACzF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,YAAsB;AACpB,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,147 @@
1
+ // src/index.ts
2
+ import { S3Client, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command } from "@aws-sdk/client-s3";
3
+ import { Upload } from "@aws-sdk/lib-storage";
4
+ function s3(config) {
5
+ const accessKeyId = config.accessKeyId || process.env.AWS_ACCESS_KEY_ID;
6
+ const secretAccessKey = config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;
7
+ const region = config.region || process.env.AWS_REGION || "us-east-1";
8
+ if (!accessKeyId) {
9
+ throw new Error(
10
+ `Missing AWS Access Key ID. Provide 'accessKeyId' in config or set AWS_ACCESS_KEY_ID environment variable.`
11
+ );
12
+ }
13
+ if (!secretAccessKey) {
14
+ throw new Error(
15
+ `Missing AWS Secret Access Key. Provide 'secretAccessKey' in config or set AWS_SECRET_ACCESS_KEY environment variable.`
16
+ );
17
+ }
18
+ const client = new S3Client({
19
+ region,
20
+ credentials: {
21
+ accessKeyId,
22
+ secretAccessKey
23
+ },
24
+ ...config.endpoint && { endpoint: config.endpoint },
25
+ ...config.forcePathStyle && { forcePathStyle: config.forcePathStyle }
26
+ });
27
+ return {
28
+ async upload(bucket, key, data, options) {
29
+ try {
30
+ const body = typeof data === "string" ? Buffer.from(data) : Buffer.from(data);
31
+ const contentType = options?.contentType || "application/octet-stream";
32
+ const upload = new Upload({
33
+ client,
34
+ params: {
35
+ Bucket: bucket,
36
+ Key: key,
37
+ Body: body,
38
+ ContentType: contentType,
39
+ ...options?.metadata && { Metadata: options.metadata }
40
+ },
41
+ queueSize: 4,
42
+ partSize: 5 * 1024 * 1024
43
+ // 5MB
44
+ });
45
+ await upload.done();
46
+ return {
47
+ bucket,
48
+ key,
49
+ size: body.length,
50
+ etag: void 0,
51
+ // Upload doesn't return ETag directly
52
+ lastModified: /* @__PURE__ */ new Date()
53
+ };
54
+ } catch (error) {
55
+ throw new Error(
56
+ `Failed to upload to S3: ${error instanceof Error ? error.message : String(error)}`
57
+ );
58
+ }
59
+ },
60
+ async download(bucket, key) {
61
+ try {
62
+ const command = new GetObjectCommand({
63
+ Bucket: bucket,
64
+ Key: key
65
+ });
66
+ const response = await client.send(command);
67
+ const chunks = [];
68
+ if (response.Body) {
69
+ for await (const chunk of response.Body) {
70
+ chunks.push(new Uint8Array(chunk));
71
+ }
72
+ }
73
+ let totalLength = 0;
74
+ for (const chunk of chunks) {
75
+ totalLength += chunk.length;
76
+ }
77
+ const data = new Uint8Array(totalLength);
78
+ let offset = 0;
79
+ for (const chunk of chunks) {
80
+ data.set(chunk, offset);
81
+ offset += chunk.length;
82
+ }
83
+ return {
84
+ data,
85
+ size: data.length,
86
+ contentType: response.ContentType,
87
+ etag: response.ETag,
88
+ lastModified: response.LastModified,
89
+ metadata: response.Metadata
90
+ };
91
+ } catch (error) {
92
+ if (error instanceof Error && error.name === "NoSuchKey") {
93
+ throw new Error(`Object not found: s3://${bucket}/${key}`);
94
+ }
95
+ throw new Error(
96
+ `Failed to download from S3: ${error instanceof Error ? error.message : String(error)}`
97
+ );
98
+ }
99
+ },
100
+ async delete(bucket, key) {
101
+ try {
102
+ const command = new DeleteObjectCommand({
103
+ Bucket: bucket,
104
+ Key: key
105
+ });
106
+ await client.send(command);
107
+ } catch (error) {
108
+ throw new Error(
109
+ `Failed to delete from S3: ${error instanceof Error ? error.message : String(error)}`
110
+ );
111
+ }
112
+ },
113
+ async list(bucket, options) {
114
+ try {
115
+ const command = new ListObjectsV2Command({
116
+ Bucket: bucket,
117
+ Prefix: options?.prefix,
118
+ MaxKeys: options?.maxKeys ?? 1e3,
119
+ ContinuationToken: options?.continuationToken
120
+ });
121
+ const response = await client.send(command);
122
+ return {
123
+ objects: (response.Contents || []).map((obj) => ({
124
+ bucket,
125
+ key: obj.Key || "",
126
+ size: obj.Size || 0,
127
+ etag: obj.ETag,
128
+ lastModified: obj.LastModified
129
+ })),
130
+ truncated: response.IsTruncated || false,
131
+ continuationToken: response.NextContinuationToken
132
+ };
133
+ } catch (error) {
134
+ throw new Error(
135
+ `Failed to list objects in S3: ${error instanceof Error ? error.message : String(error)}`
136
+ );
137
+ }
138
+ },
139
+ getClient() {
140
+ return client;
141
+ }
142
+ };
143
+ }
144
+ export {
145
+ s3
146
+ };
147
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * AWS S3 Storage Provider\n * \n * Object storage using AWS S3 with the ComputeSDK storage interface.\n */\n\nimport { S3Client, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';\nimport { Upload } from '@aws-sdk/lib-storage';\nimport type { StorageProvider, StorageObject, UploadOptions, DownloadResult, ListOptions, ListResult } from '@computesdk/provider';\n\n/**\n * AWS S3-specific configuration options\n */\nexport interface S3Config {\n /** AWS Access Key ID - if not provided, will use AWS_ACCESS_KEY_ID environment variable */\n accessKeyId?: string;\n /** AWS Secret Access Key - if not provided, will use AWS_SECRET_ACCESS_KEY environment variable */\n secretAccessKey?: string;\n /** AWS region - defaults to us-east-1 */\n region?: string;\n /** Optional custom endpoint for S3-compatible services */\n endpoint?: string;\n /** Optional force path style (needed for some S3-compatible services) */\n forcePathStyle?: boolean;\n}\n\n/**\n * AWS S3 Storage instance\n */\nexport interface S3 extends StorageProvider {\n /** Upload data to S3 */\n upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject>;\n /** Download data from S3 */\n download(bucket: string, key: string): Promise<DownloadResult>;\n /** Delete object from S3 */\n delete(bucket: string, key: string): Promise<void>;\n /** List objects in S3 bucket */\n list(bucket: string, options?: ListOptions): Promise<ListResult>;\n /** Get the underlying S3 client for advanced operations */\n getClient(): S3Client;\n}\n\n/**\n * Create an AWS S3 storage provider instance\n * \n * @param config - S3 configuration options\n * @returns S3 instance\n * \n * @example\n * ```typescript\n * import { s3 } from '@computesdk/s3';\n * \n * const storage = s3({\n * accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n * secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n * region: 'us-east-1'\n * });\n * \n * // Upload a file\n * await storage.upload('my-bucket', 'path/to/file.txt', 'Hello, World!');\n * \n * // Download a file\n * const result = await storage.download('my-bucket', 'path/to/file.txt');\n * console.log(result.data.toString());\n * \n * // Delete a file\n * await storage.delete('my-bucket', 'path/to/file.txt');\n * ```\n */\nexport function s3(config: S3Config): S3 {\n // Resolve configuration from parameters or environment\n const accessKeyId = config.accessKeyId || process.env.AWS_ACCESS_KEY_ID;\n const secretAccessKey = config.secretAccessKey || process.env.AWS_SECRET_ACCESS_KEY;\n const region = config.region || process.env.AWS_REGION || 'us-east-1';\n\n if (!accessKeyId) {\n throw new Error(\n `Missing AWS Access Key ID. Provide 'accessKeyId' in config or set AWS_ACCESS_KEY_ID environment variable.`\n );\n }\n\n if (!secretAccessKey) {\n throw new Error(\n `Missing AWS Secret Access Key. Provide 'secretAccessKey' in config or set AWS_SECRET_ACCESS_KEY environment variable.`\n );\n }\n\n // Create S3 client\n const client = new S3Client({\n region,\n credentials: {\n accessKeyId,\n secretAccessKey,\n },\n ...(config.endpoint && { endpoint: config.endpoint }),\n ...(config.forcePathStyle && { forcePathStyle: config.forcePathStyle }),\n });\n\n return {\n async upload(bucket: string, key: string, data: Uint8Array | string, options?: UploadOptions): Promise<StorageObject> {\n try {\n const body = typeof data === 'string' ? Buffer.from(data) : Buffer.from(data);\n const contentType = options?.contentType || 'application/octet-stream';\n\n // Use multipart upload for files larger than 5MB\n const upload = new Upload({\n client,\n params: {\n Bucket: bucket,\n Key: key,\n Body: body,\n ContentType: contentType,\n ...(options?.metadata && { Metadata: options.metadata }),\n },\n queueSize: 4,\n partSize: 5 * 1024 * 1024, // 5MB\n });\n\n await upload.done();\n\n return {\n bucket,\n key,\n size: body.length,\n etag: undefined, // Upload doesn't return ETag directly\n lastModified: new Date(),\n };\n } catch (error) {\n throw new Error(\n `Failed to upload to S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async download(bucket: string, key: string): Promise<DownloadResult> {\n try {\n const command = new GetObjectCommand({\n Bucket: bucket,\n Key: key,\n });\n\n const response = await client.send(command);\n \n // Convert stream to Uint8Array\n const chunks: Uint8Array[] = [];\n if (response.Body) {\n for await (const chunk of response.Body as any) {\n chunks.push(new Uint8Array(chunk));\n }\n }\n \n // Concatenate all chunks\n let totalLength = 0;\n for (const chunk of chunks) {\n totalLength += chunk.length;\n }\n const data = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n data.set(chunk, offset);\n offset += chunk.length;\n }\n\n return {\n data,\n size: data.length,\n contentType: response.ContentType,\n etag: response.ETag,\n lastModified: response.LastModified,\n metadata: response.Metadata,\n };\n } catch (error) {\n if (error instanceof Error && error.name === 'NoSuchKey') {\n throw new Error(`Object not found: s3://${bucket}/${key}`);\n }\n throw new Error(\n `Failed to download from S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async delete(bucket: string, key: string): Promise<void> {\n try {\n const command = new DeleteObjectCommand({\n Bucket: bucket,\n Key: key,\n });\n\n await client.send(command);\n } catch (error) {\n throw new Error(\n `Failed to delete from S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n async list(bucket: string, options?: ListOptions): Promise<ListResult> {\n try {\n const command = new ListObjectsV2Command({\n Bucket: bucket,\n Prefix: options?.prefix,\n MaxKeys: options?.maxKeys ?? 1000,\n ContinuationToken: options?.continuationToken,\n });\n\n const response = await client.send(command);\n\n return {\n objects: (response.Contents || []).map(obj => ({\n bucket,\n key: obj.Key || '',\n size: obj.Size || 0,\n etag: obj.ETag,\n lastModified: obj.LastModified,\n })),\n truncated: response.IsTruncated || false,\n continuationToken: response.NextContinuationToken,\n };\n } catch (error) {\n throw new Error(\n `Failed to list objects in S3: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getClient(): S3Client {\n return client;\n },\n };\n}\n"],"mappings":";AAMA,SAAS,UAAU,kBAAkB,qBAAqB,4BAA4B;AACtF,SAAS,cAAc;AA8DhB,SAAS,GAAG,QAAsB;AAEvC,QAAM,cAAc,OAAO,eAAe,QAAQ,IAAI;AACtD,QAAM,kBAAkB,OAAO,mBAAmB,QAAQ,IAAI;AAC9D,QAAM,SAAS,OAAO,UAAU,QAAQ,IAAI,cAAc;AAE1D,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,QAAM,SAAS,IAAI,SAAS;AAAA,IAC1B;AAAA,IACA,aAAa;AAAA,MACX;AAAA,MACA;AAAA,IACF;AAAA,IACA,GAAI,OAAO,YAAY,EAAE,UAAU,OAAO,SAAS;AAAA,IACnD,GAAI,OAAO,kBAAkB,EAAE,gBAAgB,OAAO,eAAe;AAAA,EACvE,CAAC;AAED,SAAO;AAAA,IACL,MAAM,OAAO,QAAgB,KAAa,MAA2B,SAAiD;AACpH,UAAI;AACF,cAAM,OAAO,OAAO,SAAS,WAAW,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI;AAC5E,cAAM,cAAc,SAAS,eAAe;AAG5C,cAAM,SAAS,IAAI,OAAO;AAAA,UACxB;AAAA,UACA,QAAQ;AAAA,YACN,QAAQ;AAAA,YACR,KAAK;AAAA,YACL,MAAM;AAAA,YACN,aAAa;AAAA,YACb,GAAI,SAAS,YAAY,EAAE,UAAU,QAAQ,SAAS;AAAA,UACxD;AAAA,UACA,WAAW;AAAA,UACX,UAAU,IAAI,OAAO;AAAA;AAAA,QACvB,CAAC;AAED,cAAM,OAAO,KAAK;AAElB,eAAO;AAAA,UACL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UAAI;AACF,cAAM,UAAU,IAAI,oBAAoB;AAAA,UACtC,QAAQ;AAAA,UACR,KAAK;AAAA,QACP,CAAC;AAED,cAAM,OAAO,KAAK,OAAO;AAAA,MAC3B,SAAS,OAAO;AACd,cAAM,IAAI;AAAA,UACR,6BAA6B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACrF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,KAAK,QAAgB,SAA4C;AACrE,UAAI;AACF,cAAM,UAAU,IAAI,qBAAqB;AAAA,UACvC,QAAQ;AAAA,UACR,QAAQ,SAAS;AAAA,UACjB,SAAS,SAAS,WAAW;AAAA,UAC7B,mBAAmB,SAAS;AAAA,QAC9B,CAAC;AAED,cAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,eAAO;AAAA,UACL,UAAU,SAAS,YAAY,CAAC,GAAG,IAAI,UAAQ;AAAA,YAC7C;AAAA,YACA,KAAK,IAAI,OAAO;AAAA,YAChB,MAAM,IAAI,QAAQ;AAAA,YAClB,MAAM,IAAI;AAAA,YACV,cAAc,IAAI;AAAA,UACpB,EAAE;AAAA,UACF,WAAW,SAAS,eAAe;AAAA,UACnC,mBAAmB,SAAS;AAAA,QAC9B;AAAA,MACF,SAAS,OAAO;AACd,cAAM,IAAI;AAAA,UACR,iCAAiC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,QACzF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,YAAsB;AACpB,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@computesdk/s3",
3
+ "version": "1.1.0",
4
+ "description": "AWS S3 storage provider for ComputeSDK - object storage with S3-compatible API",
5
+ "author": "Garrison",
6
+ "license": "MIT",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.mjs",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "@aws-sdk/client-s3": "^3.450.0",
22
+ "@aws-sdk/lib-storage": "^3.450.0",
23
+ "@computesdk/provider": "1.0.32"
24
+ },
25
+ "keywords": [
26
+ "computesdk",
27
+ "aws",
28
+ "s3",
29
+ "storage",
30
+ "object-storage",
31
+ "cloud",
32
+ "provider"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/computesdk/computesdk.git",
37
+ "directory": "packages/aws-storage"
38
+ },
39
+ "homepage": "https://www.computesdk.com",
40
+ "bugs": {
41
+ "url": "https://github.com/computesdk/computesdk/issues"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^20.0.0",
45
+ "@vitest/coverage-v8": "^1.0.0",
46
+ "eslint": "^8.37.0",
47
+ "rimraf": "^5.0.0",
48
+ "tsup": "^8.0.0",
49
+ "typescript": "^5.0.0",
50
+ "vitest": "^1.0.0",
51
+ "@computesdk/test-utils": "1.6.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsup",
55
+ "clean": "rimraf dist",
56
+ "dev": "tsup --watch",
57
+ "test": "vitest run",
58
+ "test:watch": "vitest watch",
59
+ "test:coverage": "vitest run --coverage",
60
+ "typecheck": "tsc --noEmit",
61
+ "lint": "eslint"
62
+ }
63
+ }