@opensaas/stack-storage-s3 0.39.2 → 0.40.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +0 -16
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @opensaas/stack-storage-s3
|
|
2
2
|
|
|
3
|
+
## 0.40.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#973](https://github.com/OpenSaasAU/stack/pull/973) [`8f76533`](https://github.com/OpenSaasAU/stack/commit/8f765333e3067c741c69f535927cc82115c60ed1) Thanks [@borisno2](https://github.com/borisno2)! - Comment cleanup only, no behavior change: removed restating/narration comments, kept TSDoc on public config options and field builders, and kept external API/behavior constraint notes (Prisma, S3, Vercel Blob, Keystone parity, Next.js SSR, Zod).
|
|
8
|
+
|
|
3
9
|
## 0.39.2
|
|
4
10
|
|
|
5
11
|
## 0.39.1
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { StorageProvider, UploadOptions, UploadResult } from '@opensaas/stack-storage';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration for S3 storage
|
|
4
|
-
*/
|
|
5
2
|
export interface S3StorageConfig {
|
|
6
3
|
type: 's3';
|
|
7
4
|
/** S3 bucket name */
|
|
@@ -33,13 +30,7 @@ export declare class S3StorageProvider implements StorageProvider {
|
|
|
33
30
|
private client;
|
|
34
31
|
private config;
|
|
35
32
|
constructor(config: S3StorageConfig);
|
|
36
|
-
/**
|
|
37
|
-
* Generates a unique filename if configured
|
|
38
|
-
*/
|
|
39
33
|
private generateFilename;
|
|
40
|
-
/**
|
|
41
|
-
* Gets the full key for an object including path prefix
|
|
42
|
-
*/
|
|
43
34
|
private getFullKey;
|
|
44
35
|
upload(file: Buffer | Uint8Array, filename: string, options?: UploadOptions): Promise<UploadResult>;
|
|
45
36
|
download(filename: string): Promise<Buffer>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3F
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAA;IACV,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,uEAAuE;IACvE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2DAA2D;IAC3D,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,kDAAkD;IAClD,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,mBAAmB,GAAG,oBAAoB,CAAA;IAC5E,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAiB;IAE/B,YAAY,MAAM,EAAE,eAAe,EAelC;IAED,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,UAAU;IAOZ,MAAM,CACV,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAyBvB;IAEK,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBhD;IAEK,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5C;IAED,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY/B;IAEK,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAS9E;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG,eAAe,CAOhF"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export class S3StorageProvider {
|
|
|
10
10
|
config;
|
|
11
11
|
constructor(config) {
|
|
12
12
|
this.config = config;
|
|
13
|
-
// Create S3 client
|
|
14
13
|
this.client = new S3Client({
|
|
15
14
|
region: config.region,
|
|
16
15
|
credentials: config.accessKeyId && config.secretAccessKey
|
|
@@ -23,9 +22,6 @@ export class S3StorageProvider {
|
|
|
23
22
|
forcePathStyle: config.forcePathStyle,
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Generates a unique filename if configured
|
|
28
|
-
*/
|
|
29
25
|
generateFilename(originalFilename) {
|
|
30
26
|
if (this.config.generateUniqueFilenames === false) {
|
|
31
27
|
return originalFilename;
|
|
@@ -35,9 +31,6 @@ export class S3StorageProvider {
|
|
|
35
31
|
const timestamp = Date.now();
|
|
36
32
|
return `${timestamp}-${uniqueId}${ext}`;
|
|
37
33
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Gets the full key for an object including path prefix
|
|
40
|
-
*/
|
|
41
34
|
getFullKey(filename) {
|
|
42
35
|
if (this.config.pathPrefix) {
|
|
43
36
|
return `${this.config.pathPrefix}/${filename}`;
|
|
@@ -47,7 +40,6 @@ export class S3StorageProvider {
|
|
|
47
40
|
async upload(file, filename, options) {
|
|
48
41
|
const generatedFilename = this.generateFilename(filename);
|
|
49
42
|
const key = this.getFullKey(generatedFilename);
|
|
50
|
-
// Upload to S3
|
|
51
43
|
const command = new PutObjectCommand({
|
|
52
44
|
Bucket: this.config.bucket,
|
|
53
45
|
Key: key,
|
|
@@ -58,7 +50,6 @@ export class S3StorageProvider {
|
|
|
58
50
|
CacheControl: options?.cacheControl,
|
|
59
51
|
});
|
|
60
52
|
await this.client.send(command);
|
|
61
|
-
// Generate URL
|
|
62
53
|
const url = this.getUrl(generatedFilename);
|
|
63
54
|
return {
|
|
64
55
|
filename: generatedFilename,
|
|
@@ -96,16 +87,12 @@ export class S3StorageProvider {
|
|
|
96
87
|
}
|
|
97
88
|
getUrl(filename) {
|
|
98
89
|
const key = this.getFullKey(filename);
|
|
99
|
-
// Use custom domain if configured
|
|
100
90
|
if (this.config.customDomain) {
|
|
101
91
|
return `${this.config.customDomain}/${key}`;
|
|
102
92
|
}
|
|
103
|
-
// Use standard S3 URL
|
|
104
93
|
if (this.config.endpoint) {
|
|
105
|
-
// Custom endpoint (S3-compatible services)
|
|
106
94
|
return `${this.config.endpoint}/${this.config.bucket}/${key}`;
|
|
107
95
|
}
|
|
108
|
-
// Standard AWS S3 URL
|
|
109
96
|
return `https://${this.config.bucket}.s3.${this.config.region}.amazonaws.com/${key}`;
|
|
110
97
|
}
|
|
111
98
|
async getSignedUrl(filename, expiresIn = 3600) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"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CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,GAAG,EAAE,CAAA;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,CAAA;QAC/D,CAAC;QAED,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAA;IACtF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,SAAS,GAAW,IAAI;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;QAErC,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;YAC1B,GAAG,EAAE,GAAG;SACT,CAAC,CAAA;QAEF,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;IAChE,CAAC;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CAAC,MAAqC;IAC7D,OAAO;QACL,IAAI,EAAE,IAAI;QACV,uBAAuB,EAAE,IAAI;QAC7B,GAAG,EAAE,SAAS;QACd,GAAG,MAAM;KACV,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensaas/stack-storage-s3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "AWS S3 storage provider for OpenSaas Stack file uploads",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@vitest/coverage-v8": "^4.1.10",
|
|
22
22
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
23
23
|
"vitest": "^4.1.10",
|
|
24
|
-
"@opensaas/stack-storage": "0.
|
|
24
|
+
"@opensaas/stack-storage": "0.40.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@opensaas/stack-storage": "^0"
|
package/src/index.ts
CHANGED
|
@@ -8,9 +8,6 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
|
|
8
8
|
import { randomBytes } from 'node:crypto'
|
|
9
9
|
import type { StorageProvider, UploadOptions, UploadResult } from '@opensaas/stack-storage'
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Configuration for S3 storage
|
|
13
|
-
*/
|
|
14
11
|
export interface S3StorageConfig {
|
|
15
12
|
type: 's3'
|
|
16
13
|
/** S3 bucket name */
|
|
@@ -46,7 +43,6 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
46
43
|
constructor(config: S3StorageConfig) {
|
|
47
44
|
this.config = config
|
|
48
45
|
|
|
49
|
-
// Create S3 client
|
|
50
46
|
this.client = new S3Client({
|
|
51
47
|
region: config.region,
|
|
52
48
|
credentials:
|
|
@@ -61,9 +57,6 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
61
57
|
})
|
|
62
58
|
}
|
|
63
59
|
|
|
64
|
-
/**
|
|
65
|
-
* Generates a unique filename if configured
|
|
66
|
-
*/
|
|
67
60
|
private generateFilename(originalFilename: string): string {
|
|
68
61
|
if (this.config.generateUniqueFilenames === false) {
|
|
69
62
|
return originalFilename
|
|
@@ -75,9 +68,6 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
75
68
|
return `${timestamp}-${uniqueId}${ext}`
|
|
76
69
|
}
|
|
77
70
|
|
|
78
|
-
/**
|
|
79
|
-
* Gets the full key for an object including path prefix
|
|
80
|
-
*/
|
|
81
71
|
private getFullKey(filename: string): string {
|
|
82
72
|
if (this.config.pathPrefix) {
|
|
83
73
|
return `${this.config.pathPrefix}/${filename}`
|
|
@@ -93,7 +83,6 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
93
83
|
const generatedFilename = this.generateFilename(filename)
|
|
94
84
|
const key = this.getFullKey(generatedFilename)
|
|
95
85
|
|
|
96
|
-
// Upload to S3
|
|
97
86
|
const command = new PutObjectCommand({
|
|
98
87
|
Bucket: this.config.bucket,
|
|
99
88
|
Key: key,
|
|
@@ -106,7 +95,6 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
106
95
|
|
|
107
96
|
await this.client.send(command)
|
|
108
97
|
|
|
109
|
-
// Generate URL
|
|
110
98
|
const url = this.getUrl(generatedFilename)
|
|
111
99
|
|
|
112
100
|
return {
|
|
@@ -157,18 +145,14 @@ export class S3StorageProvider implements StorageProvider {
|
|
|
157
145
|
getUrl(filename: string): string {
|
|
158
146
|
const key = this.getFullKey(filename)
|
|
159
147
|
|
|
160
|
-
// Use custom domain if configured
|
|
161
148
|
if (this.config.customDomain) {
|
|
162
149
|
return `${this.config.customDomain}/${key}`
|
|
163
150
|
}
|
|
164
151
|
|
|
165
|
-
// Use standard S3 URL
|
|
166
152
|
if (this.config.endpoint) {
|
|
167
|
-
// Custom endpoint (S3-compatible services)
|
|
168
153
|
return `${this.config.endpoint}/${this.config.bucket}/${key}`
|
|
169
154
|
}
|
|
170
155
|
|
|
171
|
-
// Standard AWS S3 URL
|
|
172
156
|
return `https://${this.config.bucket}.s3.${this.config.region}.amazonaws.com/${key}`
|
|
173
157
|
}
|
|
174
158
|
|