@makolabs/ripple 2.5.0 → 2.5.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.
|
@@ -5,7 +5,13 @@ import { BaseAdapter } from './BaseAdapter.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class S3Adapter extends BaseAdapter {
|
|
7
7
|
private basePath;
|
|
8
|
-
|
|
8
|
+
private bucket;
|
|
9
|
+
private fileExtensions;
|
|
10
|
+
constructor(basePathOrOptions?: string | {
|
|
11
|
+
basePath?: string;
|
|
12
|
+
bucket?: string;
|
|
13
|
+
fileExtensions?: string[];
|
|
14
|
+
}, publicS3BasePath?: string);
|
|
9
15
|
getName(): string;
|
|
10
16
|
isConfigured(): Promise<boolean>;
|
|
11
17
|
authenticate(): Promise<boolean>;
|
|
@@ -4,9 +4,18 @@ import { BaseAdapter } from './BaseAdapter.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export class S3Adapter extends BaseAdapter {
|
|
6
6
|
basePath;
|
|
7
|
-
|
|
7
|
+
bucket;
|
|
8
|
+
fileExtensions;
|
|
9
|
+
constructor(basePathOrOptions, publicS3BasePath) {
|
|
8
10
|
super();
|
|
9
|
-
|
|
11
|
+
if (typeof basePathOrOptions === 'object' && basePathOrOptions !== null) {
|
|
12
|
+
this.basePath = basePathOrOptions.basePath || '/';
|
|
13
|
+
this.bucket = basePathOrOptions.bucket;
|
|
14
|
+
this.fileExtensions = basePathOrOptions.fileExtensions;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.basePath = basePathOrOptions || publicS3BasePath || '/';
|
|
18
|
+
}
|
|
10
19
|
}
|
|
11
20
|
getName() {
|
|
12
21
|
return 'S3';
|
|
@@ -42,11 +51,14 @@ export class S3Adapter extends BaseAdapter {
|
|
|
42
51
|
try {
|
|
43
52
|
// Ensure path ends with a forward slash
|
|
44
53
|
const normalizedPath = path.endsWith('/') ? path : path + '/';
|
|
45
|
-
// Build API URL including search term if provided
|
|
54
|
+
// Build API URL including search term and bucket if provided
|
|
46
55
|
let apiUrl = `/api/s3/list?prefix=${encodeURIComponent(normalizedPath)}`;
|
|
47
56
|
if (searchQuery) {
|
|
48
57
|
apiUrl += `&search=${encodeURIComponent(searchQuery)}`;
|
|
49
58
|
}
|
|
59
|
+
if (this.bucket) {
|
|
60
|
+
apiUrl += `&bucket=${encodeURIComponent(this.bucket)}`;
|
|
61
|
+
}
|
|
50
62
|
// Use the API endpoint for listing S3 files
|
|
51
63
|
const response = await fetch(apiUrl);
|
|
52
64
|
if (!response.ok) {
|
|
@@ -77,7 +89,14 @@ export class S3Adapter extends BaseAdapter {
|
|
|
77
89
|
const relativePath = file.key.slice(normalizedPath.length);
|
|
78
90
|
// Only include files that don't have additional path separators
|
|
79
91
|
// (indicating they're directly in this directory)
|
|
80
|
-
|
|
92
|
+
if (relativePath.includes('/'))
|
|
93
|
+
return false;
|
|
94
|
+
// Filter by file extension if configured
|
|
95
|
+
if (this.fileExtensions) {
|
|
96
|
+
const lowerKey = file.key.toLowerCase();
|
|
97
|
+
return this.fileExtensions.some((ext) => lowerKey.endsWith(ext.toLowerCase()));
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
81
100
|
})
|
|
82
101
|
.map((file) => ({
|
|
83
102
|
key: file.key,
|