@bejibun/storage 0.1.0 → 0.1.1
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/.prettierignore +45 -0
- package/.prettierrc.json +14 -0
- package/CHANGELOG.md +29 -0
- package/README.md +24 -0
- package/builders/StorageBuilder.js +10 -4
- package/builders/storage/StorageLocalBuilder.js +10 -4
- package/builders/storage/StorageS3Builder.js +10 -4
- package/configure.js +1 -2
- package/eslint.config.js +61 -0
- package/facades/Storage.js +1 -1
- package/package.json +22 -12
- package/tsconfig.json +0 -1
- package/types/index.d.ts +1 -1
- package/types/storage.d.ts +138 -138
package/.prettierignore
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# dependencies (bun install)
|
|
2
|
+
node_modules
|
|
3
|
+
|
|
4
|
+
# output
|
|
5
|
+
out
|
|
6
|
+
dist
|
|
7
|
+
*.tgz
|
|
8
|
+
|
|
9
|
+
# code coverage
|
|
10
|
+
coverage
|
|
11
|
+
*.lcov
|
|
12
|
+
|
|
13
|
+
# logs
|
|
14
|
+
logs
|
|
15
|
+
_.log
|
|
16
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
17
|
+
|
|
18
|
+
# dotenv environment variable files
|
|
19
|
+
.env
|
|
20
|
+
.env.development.local
|
|
21
|
+
.env.test.local
|
|
22
|
+
.env.production.local
|
|
23
|
+
.env.local
|
|
24
|
+
|
|
25
|
+
# caches
|
|
26
|
+
.eslintcache
|
|
27
|
+
.cache
|
|
28
|
+
*.tsbuildinfo
|
|
29
|
+
|
|
30
|
+
# storage (runtime/framework generated content)
|
|
31
|
+
storage/app
|
|
32
|
+
storage/cache
|
|
33
|
+
storage/framework
|
|
34
|
+
|
|
35
|
+
# public
|
|
36
|
+
public
|
|
37
|
+
|
|
38
|
+
# bun
|
|
39
|
+
bun.lock
|
|
40
|
+
|
|
41
|
+
# IntelliJ based IDEs
|
|
42
|
+
.idea
|
|
43
|
+
|
|
44
|
+
# Finder (MacOS) folder config
|
|
45
|
+
.DS_Store
|
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tabWidth": 4,
|
|
3
|
+
"useTabs": false,
|
|
4
|
+
"semi": true,
|
|
5
|
+
"singleQuote": false,
|
|
6
|
+
"quoteProps": "as-needed",
|
|
7
|
+
"trailingComma": "none",
|
|
8
|
+
"bracketSpacing": false,
|
|
9
|
+
"bracketSameLine": false,
|
|
10
|
+
"arrowParens": "always",
|
|
11
|
+
"printWidth": 100,
|
|
12
|
+
"endOfLine": "lf",
|
|
13
|
+
"jsxSingleQuote": false
|
|
14
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
## [v0.1.1](https://github.com/Bejibun-Framework/bejibun-storage/compare/v0.1.0...v0.1.1) - 2026-08-20
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
- Fix missing `options` in `Storage.put()`
|
|
10
|
+
|
|
11
|
+
### 📖 Changes
|
|
12
|
+
#### Tooling
|
|
13
|
+
- Added `prettier` + `.prettierrc.json` / `.prettierignore` and an `eslint.config.js` (flat config, `typescript-eslint`) for consistent formatting/linting across `src`
|
|
14
|
+
- Added `bun run format`, `bun run eslint`, and `bun run lint` scripts; `bun run build` now runs `lint` before compiling
|
|
15
|
+
- `alias` script now runs `tsc-alias` directly instead of via `bunx`
|
|
16
|
+
|
|
17
|
+
### 📦 Dependencies
|
|
18
|
+
|
|
19
|
+
- Bumped `tsc-alias` (devDependency) from `^1.8.16` to `^1.9.2`
|
|
20
|
+
- Added `@eslint/js` (devDependency) `^10.0.1`
|
|
21
|
+
- Added `eslint` (devDependency) `^10.8.1`
|
|
22
|
+
- Added `eslint-config-prettier` (devDependency) `^10.1.8`
|
|
23
|
+
- Added `globals` (devDependency) `^17.11.0`
|
|
24
|
+
- Added `prettier` (devDependency) `^3.9.6`
|
|
25
|
+
- Added `typescript` (devDependency) `^6.0.3`
|
|
26
|
+
- Added `typescript-eslint` (devDependency) `^8.67.0`
|
|
27
|
+
|
|
28
|
+
### ❤️Contributors
|
|
29
|
+
- Havea Crenata ([@crenata](https://github.com/crenata))
|
|
30
|
+
|
|
31
|
+
**Full Changelog**: https://github.com/Bejibun-Framework/bejibun-storage/blob/master/CHANGELOG.md
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
6
35
|
## [v0.1.0](https://github.com/Bejibun-Framework/bejibun-storage/compare/v0.1.0...v0.1.0) - 2026-08-03
|
|
7
36
|
|
|
8
37
|
### 🩹 Fixes
|
package/README.md
CHANGED
|
@@ -87,6 +87,10 @@ await Storage.put("path/to/your/file.ext", "content"); // Store content to file
|
|
|
87
87
|
await Storage.copy("source/file.ext", "destination/file.ext"); // Copy file
|
|
88
88
|
await Storage.move("source/file.ext", "destination/file.ext"); // Move file
|
|
89
89
|
await Storage.delete("path/to/your/file.ext"); // Delete file
|
|
90
|
+
await Storage.metadata("path/to/your/file.ext"); // Retrieve complete file metadata and statistics
|
|
91
|
+
await Storage.size("path/to/your/file.ext"); // Get the file size in bytes
|
|
92
|
+
await Storage.mimeType("path/to/your/file.ext"); // Get the file MIME type
|
|
93
|
+
await Storage.lastModified("path/to/your/file.ext"); // Get the file's last modification date
|
|
90
94
|
```
|
|
91
95
|
|
|
92
96
|
#### With Specified Disk
|
|
@@ -100,6 +104,10 @@ await Storage.disk("public").put("path/to/your/file.ext", "content");
|
|
|
100
104
|
await Storage.disk("public").copy("source/file.ext", "destination/file.ext");
|
|
101
105
|
await Storage.disk("public").move("source/file.ext", "destination/file.ext");
|
|
102
106
|
await Storage.disk("public").delete("path/to/your/file.ext");
|
|
107
|
+
await Storage.disk("public").metadata("path/to/your/file.ext");
|
|
108
|
+
await Storage.disk("public").size("path/to/your/file.ext");
|
|
109
|
+
await Storage.disk("public").mimeType("path/to/your/file.ext");
|
|
110
|
+
await Storage.disk("public").lastModified("path/to/your/file.ext");
|
|
103
111
|
```
|
|
104
112
|
|
|
105
113
|
#### New Disk at Runtime
|
|
@@ -134,6 +142,22 @@ await Storage.build({
|
|
|
134
142
|
driver: "local",
|
|
135
143
|
root: App.Path.storagePath("custom")
|
|
136
144
|
}).delete("path/to/your/file.ext");
|
|
145
|
+
await Storage.build({
|
|
146
|
+
driver: "local",
|
|
147
|
+
root: App.Path.storagePath("custom")
|
|
148
|
+
}).metadata("path/to/your/file.ext");
|
|
149
|
+
await Storage.build({
|
|
150
|
+
driver: "local",
|
|
151
|
+
root: App.Path.storagePath("custom")
|
|
152
|
+
}).size("path/to/your/file.ext");
|
|
153
|
+
await Storage.build({
|
|
154
|
+
driver: "local",
|
|
155
|
+
root: App.Path.storagePath("custom")
|
|
156
|
+
}).mimeType("path/to/your/file.ext");
|
|
157
|
+
await Storage.build({
|
|
158
|
+
driver: "local",
|
|
159
|
+
root: App.Path.storagePath("custom")
|
|
160
|
+
}).lastModified("path/to/your/file.ext");
|
|
137
161
|
```
|
|
138
162
|
|
|
139
163
|
## ☕ Support / Donate
|
|
@@ -60,7 +60,7 @@ export default class StorageBuilder {
|
|
|
60
60
|
async missing(filepath) {
|
|
61
61
|
if (isEmpty(filepath))
|
|
62
62
|
throw new StorageException("The file path is required.");
|
|
63
|
-
return !await this.driver.missing(filepath);
|
|
63
|
+
return !(await this.driver.missing(filepath));
|
|
64
64
|
}
|
|
65
65
|
async metadata(filepath) {
|
|
66
66
|
if (isEmpty(filepath))
|
|
@@ -96,7 +96,9 @@ export default class StorageBuilder {
|
|
|
96
96
|
await this.driver.put(filepath, content, options);
|
|
97
97
|
}
|
|
98
98
|
catch (error) {
|
|
99
|
-
Logger.setContext("Storage")
|
|
99
|
+
Logger.setContext("Storage")
|
|
100
|
+
.error("Something went wrong when saving file.")
|
|
101
|
+
.trace(error);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
async copy(source, destination, options) {
|
|
@@ -108,7 +110,9 @@ export default class StorageBuilder {
|
|
|
108
110
|
await this.driver.copy(source, destination, options);
|
|
109
111
|
}
|
|
110
112
|
catch (error) {
|
|
111
|
-
Logger.setContext("Storage")
|
|
113
|
+
Logger.setContext("Storage")
|
|
114
|
+
.error("Something went wrong when copying file.")
|
|
115
|
+
.trace(error);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
async move(source, destination, options) {
|
|
@@ -120,7 +124,9 @@ export default class StorageBuilder {
|
|
|
120
124
|
await this.driver.move(source, destination, options);
|
|
121
125
|
}
|
|
122
126
|
catch (error) {
|
|
123
|
-
Logger.setContext("Storage")
|
|
127
|
+
Logger.setContext("Storage")
|
|
128
|
+
.error("Something went wrong when moving file.")
|
|
129
|
+
.trace(error);
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
async delete(filepath) {
|
|
@@ -20,7 +20,7 @@ export default class StorageLocalBuilder {
|
|
|
20
20
|
async missing(filepath) {
|
|
21
21
|
if (isEmpty(filepath))
|
|
22
22
|
throw new StorageException("The file path is required.");
|
|
23
|
-
return !await this.exists(filepath);
|
|
23
|
+
return !(await this.exists(filepath));
|
|
24
24
|
}
|
|
25
25
|
async metadata(filepath) {
|
|
26
26
|
if (isEmpty(filepath))
|
|
@@ -56,7 +56,9 @@ export default class StorageLocalBuilder {
|
|
|
56
56
|
await Bun.write(path.resolve(this.config.root, filepath), content, options);
|
|
57
57
|
}
|
|
58
58
|
catch (error) {
|
|
59
|
-
Logger.setContext("Storage")
|
|
59
|
+
Logger.setContext("Storage")
|
|
60
|
+
.error("Something went wrong when saving file.")
|
|
61
|
+
.trace(error);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
async copy(source, destination, options) {
|
|
@@ -68,7 +70,9 @@ export default class StorageLocalBuilder {
|
|
|
68
70
|
await this.put(destination, await this.get(source), options);
|
|
69
71
|
}
|
|
70
72
|
catch (error) {
|
|
71
|
-
Logger.setContext("Storage")
|
|
73
|
+
Logger.setContext("Storage")
|
|
74
|
+
.error("Something went wrong when copying file.")
|
|
75
|
+
.trace(error);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
async move(source, destination, options) {
|
|
@@ -81,7 +85,9 @@ export default class StorageLocalBuilder {
|
|
|
81
85
|
await this.delete(source);
|
|
82
86
|
}
|
|
83
87
|
catch (error) {
|
|
84
|
-
Logger.setContext("Storage")
|
|
88
|
+
Logger.setContext("Storage")
|
|
89
|
+
.error("Something went wrong when moving file.")
|
|
90
|
+
.trace(error);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
async delete(filepath) {
|
|
@@ -31,7 +31,7 @@ export default class StorageS3Builder {
|
|
|
31
31
|
async missing(filepath) {
|
|
32
32
|
if (isEmpty(filepath))
|
|
33
33
|
throw new StorageException("The file path is required.");
|
|
34
|
-
return !await this.exists(filepath);
|
|
34
|
+
return !(await this.exists(filepath));
|
|
35
35
|
}
|
|
36
36
|
async metadata(filepath) {
|
|
37
37
|
if (isEmpty(filepath))
|
|
@@ -67,7 +67,9 @@ export default class StorageS3Builder {
|
|
|
67
67
|
await this.client.write(filepath, content, options);
|
|
68
68
|
}
|
|
69
69
|
catch (error) {
|
|
70
|
-
Logger.setContext("Storage")
|
|
70
|
+
Logger.setContext("Storage")
|
|
71
|
+
.error("Something went wrong when saving file.")
|
|
72
|
+
.trace(error);
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
async copy(source, destination, options) {
|
|
@@ -79,7 +81,9 @@ export default class StorageS3Builder {
|
|
|
79
81
|
await this.put(destination, await this.get(source), options);
|
|
80
82
|
}
|
|
81
83
|
catch (error) {
|
|
82
|
-
Logger.setContext("Storage")
|
|
84
|
+
Logger.setContext("Storage")
|
|
85
|
+
.error("Something went wrong when copying file.")
|
|
86
|
+
.trace(error);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
async move(source, destination, options) {
|
|
@@ -92,7 +96,9 @@ export default class StorageS3Builder {
|
|
|
92
96
|
await this.delete(source);
|
|
93
97
|
}
|
|
94
98
|
catch (error) {
|
|
95
|
-
Logger.setContext("Storage")
|
|
99
|
+
Logger.setContext("Storage")
|
|
100
|
+
.error("Something went wrong when moving file.")
|
|
101
|
+
.trace(error);
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
async delete(filepath) {
|
package/configure.js
CHANGED
|
@@ -5,8 +5,7 @@ const configPath = path.resolve(__dirname, "config");
|
|
|
5
5
|
const regex = /\.(m?js|ts)$/;
|
|
6
6
|
const configs = Array.from(new Bun.Glob("**/*").scanSync({
|
|
7
7
|
cwd: configPath
|
|
8
|
-
})).filter(value =>
|
|
9
|
-
!value.endsWith(".d.ts")));
|
|
8
|
+
})).filter((value) => regex.test(value) && !value.endsWith(".d.ts"));
|
|
10
9
|
for (const config of configs) {
|
|
11
10
|
const destination = config.replace(regex, ".ts");
|
|
12
11
|
await Bun.write(App.Path.configPath(destination), await Bun.file(path.resolve(configPath, config)).text());
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
|
|
6
|
+
export default tseslint.config(
|
|
7
|
+
{
|
|
8
|
+
ignores: [
|
|
9
|
+
"node_modules/**",
|
|
10
|
+
"dist/**",
|
|
11
|
+
"out/**",
|
|
12
|
+
"coverage/**",
|
|
13
|
+
"public/**",
|
|
14
|
+
"storage/app/**",
|
|
15
|
+
"storage/cache/**",
|
|
16
|
+
"storage/framework/**",
|
|
17
|
+
"bun.lock",
|
|
18
|
+
"*.tsbuildinfo"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
js.configs.recommended,
|
|
23
|
+
...tseslint.configs.recommended,
|
|
24
|
+
|
|
25
|
+
// All TypeScript (server code + resources/views), no React-specific rules
|
|
26
|
+
{
|
|
27
|
+
files: ["**/*.{ts,tsx}"],
|
|
28
|
+
languageOptions: {
|
|
29
|
+
ecmaVersion: "latest",
|
|
30
|
+
sourceType: "module",
|
|
31
|
+
parserOptions: {
|
|
32
|
+
ecmaFeatures: {
|
|
33
|
+
experimentalDecorators: true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
globals: {
|
|
37
|
+
...globals.node,
|
|
38
|
+
...globals.browser,
|
|
39
|
+
Bun: "readonly"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
"no-unused-vars": "off",
|
|
44
|
+
"@typescript-eslint/no-unused-vars": [
|
|
45
|
+
"warn",
|
|
46
|
+
{
|
|
47
|
+
argsIgnorePattern: "^_",
|
|
48
|
+
varsIgnorePattern: "^_"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
52
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
53
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
54
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
55
|
+
"no-console": "off"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// Prettier must be last: turns off stylistic rules that conflict with formatting
|
|
60
|
+
eslintConfigPrettier
|
|
61
|
+
);
|
package/facades/Storage.js
CHANGED
|
@@ -28,7 +28,7 @@ export default class Storage {
|
|
|
28
28
|
return await new StorageBuilder().get(path);
|
|
29
29
|
}
|
|
30
30
|
static async put(path, content, options) {
|
|
31
|
-
return await new StorageBuilder().put(path, content);
|
|
31
|
+
return await new StorageBuilder().put(path, content, options);
|
|
32
32
|
}
|
|
33
33
|
static async copy(source, destination, options) {
|
|
34
34
|
return await new StorageBuilder().copy(source, destination, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bejibun/storage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "Havea Crenata <havea.crenata@gmail.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"module": "index.js",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@bejibun/app": "^0.1.24",
|
|
13
|
-
"@bejibun/logger": "^0.1.22",
|
|
14
|
-
"@bejibun/utils": "^0.1.28"
|
|
15
|
-
},
|
|
16
11
|
"devDependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"
|
|
12
|
+
"@eslint/js": "^10.0.1",
|
|
13
|
+
"@types/bun": "^1.3.14",
|
|
14
|
+
"eslint": "^10.8.1",
|
|
15
|
+
"eslint-config-prettier": "^10.1.8",
|
|
16
|
+
"globals": "^17.11.0",
|
|
17
|
+
"prettier": "^3.9.6",
|
|
18
|
+
"tsc-alias": "^1.9.2",
|
|
19
|
+
"typescript": "^6.0.3",
|
|
20
|
+
"typescript-eslint": "^8.67.0"
|
|
19
21
|
},
|
|
20
22
|
"bugs": {
|
|
21
23
|
"url": "https://github.com/Bejibun-Framework/bejibun-storage/issues"
|
|
@@ -31,13 +33,21 @@
|
|
|
31
33
|
],
|
|
32
34
|
"license": "MIT",
|
|
33
35
|
"scripts": {
|
|
34
|
-
"alias": "
|
|
36
|
+
"alias": "tsc-alias -p tsconfig.json",
|
|
35
37
|
"types": "cp -rf src/types dist",
|
|
36
38
|
"rsync": "rsync -a dist/ ./",
|
|
37
39
|
"clean": "rm -rf dist",
|
|
38
|
-
"
|
|
40
|
+
"format": "prettier --write src --log-level=silent",
|
|
41
|
+
"eslint": "eslint src",
|
|
42
|
+
"lint": "bun run format && bun run eslint",
|
|
43
|
+
"build": "bun run lint && tsc -p tsconfig.json && bun run types && bun run alias && bun run rsync && bun run clean",
|
|
39
44
|
"deploy": "bun run build && bun publish --access public"
|
|
40
45
|
},
|
|
41
46
|
"type": "module",
|
|
42
|
-
"types": "index.d.ts"
|
|
43
|
-
|
|
47
|
+
"types": "index.d.ts",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@bejibun/app": "^0.1.25",
|
|
50
|
+
"@bejibun/logger": "^0.1.23",
|
|
51
|
+
"@bejibun/utils": "^0.1.29"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/tsconfig.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "../types/storage";
|
|
1
|
+
export * from "../types/storage";
|
package/types/storage.d.ts
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
import type {Stats} from "fs";
|
|
2
|
-
|
|
3
|
-
export type StorageDisk = {
|
|
4
|
-
driver: string;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type StorageOptions = {
|
|
9
|
-
mode?: number;
|
|
10
|
-
createPath?: boolean;
|
|
11
|
-
acl?:
|
|
12
|
-
| "private"
|
|
13
|
-
| "public-read"
|
|
14
|
-
| "public-read-write"
|
|
15
|
-
| "aws-exec-read"
|
|
16
|
-
| "authenticated-read"
|
|
17
|
-
| "bucket-owner-read"
|
|
18
|
-
| "bucket-owner-full-control"
|
|
19
|
-
| "log-delivery-write";
|
|
20
|
-
bucket?: string;
|
|
21
|
-
region?: string;
|
|
22
|
-
accessKeyId?: string;
|
|
23
|
-
secretAccessKey?: string;
|
|
24
|
-
sessionToken?: string;
|
|
25
|
-
endpoint?: string;
|
|
26
|
-
virtualHostedStyle?: boolean;
|
|
27
|
-
partSize?: number;
|
|
28
|
-
queueSize?: number;
|
|
29
|
-
retry?: number;
|
|
30
|
-
type?: string;
|
|
31
|
-
contentDisposition?: string | undefined;
|
|
32
|
-
storageClass?:
|
|
33
|
-
| "STANDARD"
|
|
34
|
-
| "DEEP_ARCHIVE"
|
|
35
|
-
| "EXPRESS_ONEZONE"
|
|
36
|
-
| "GLACIER"
|
|
37
|
-
| "GLACIER_IR"
|
|
38
|
-
| "INTELLIGENT_TIERING"
|
|
39
|
-
| "ONEZONE_IA"
|
|
40
|
-
| "OUTPOSTS"
|
|
41
|
-
| "REDUCED_REDUNDANCY"
|
|
42
|
-
| "SNOW"
|
|
43
|
-
| "STANDARD_IA";
|
|
44
|
-
requestPayer?: boolean;
|
|
45
|
-
highWaterMark?: number;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export interface StorageDriver {
|
|
49
|
-
/**
|
|
50
|
-
* Determine whether a file exists.
|
|
51
|
-
*
|
|
52
|
-
* @param filepath The path to the file.
|
|
53
|
-
* @returns True if the file exists; otherwise false.
|
|
54
|
-
*/
|
|
55
|
-
exists(filepath: string): Promise<boolean>;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Determine whether a file is missing.
|
|
59
|
-
*
|
|
60
|
-
* @param filepath The path to the file.
|
|
61
|
-
* @returns True if the file does not exist; otherwise false.
|
|
62
|
-
*/
|
|
63
|
-
missing(filepath: string): Promise<boolean>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Retrieve metadata for a file.
|
|
67
|
-
*
|
|
68
|
-
* @param filepath The path to the file.
|
|
69
|
-
* @returns File metadata and statistics.
|
|
70
|
-
*/
|
|
71
|
-
metadata(filepath: string): Promise<Stats | Bun.S3Stats>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get the file size in bytes.
|
|
75
|
-
*
|
|
76
|
-
* @param filepath The path to the file.
|
|
77
|
-
* @returns The file size in bytes.
|
|
78
|
-
*/
|
|
79
|
-
size(filepath: string): Promise<number>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Get the file MIME type.
|
|
83
|
-
*
|
|
84
|
-
* @param filepath The path to the file.
|
|
85
|
-
* @returns The detected MIME type.
|
|
86
|
-
*/
|
|
87
|
-
mimeType(filepath: string): Promise<string>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get the file's last modification date.
|
|
91
|
-
*
|
|
92
|
-
* @param filepath The path to the file.
|
|
93
|
-
* @returns The last modified timestamp.
|
|
94
|
-
*/
|
|
95
|
-
lastModified(filepath: string): Promise<Date>;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Retrieve a file from storage.
|
|
99
|
-
*
|
|
100
|
-
* @param filepath The path to the file.
|
|
101
|
-
* @returns The storage file instance.
|
|
102
|
-
*/
|
|
103
|
-
get(filepath: string): Promise<Bun.BunFile | Bun.S3File>;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Store content at the given path.
|
|
107
|
-
*
|
|
108
|
-
* @param filepath The destination file path.
|
|
109
|
-
* @param content The content to store.
|
|
110
|
-
* @param options Additional storage options.
|
|
111
|
-
*/
|
|
112
|
-
put(filepath: string, content: any, options?: StorageOptions): Promise<void>;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Copy a file to a new location.
|
|
116
|
-
*
|
|
117
|
-
* @param source The source file path.
|
|
118
|
-
* @param destination The destination file path.
|
|
119
|
-
* @param options Additional storage options.
|
|
120
|
-
*/
|
|
121
|
-
copy(source: string, destination: string, options?: StorageOptions): Promise<void>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Move a file to a new location.
|
|
125
|
-
*
|
|
126
|
-
* @param source The source file path.
|
|
127
|
-
* @param destination The destination file path.
|
|
128
|
-
* @param options Additional storage options.
|
|
129
|
-
*/
|
|
130
|
-
move(source: string, destination: string, options?: StorageOptions): Promise<void>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Delete a file from storage.
|
|
134
|
-
*
|
|
135
|
-
* @param filepath The path to the file.
|
|
136
|
-
*/
|
|
137
|
-
delete(filepath: string): Promise<void>;
|
|
138
|
-
}
|
|
1
|
+
import type {Stats} from "fs";
|
|
2
|
+
|
|
3
|
+
export type StorageDisk = {
|
|
4
|
+
driver: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type StorageOptions = {
|
|
9
|
+
mode?: number;
|
|
10
|
+
createPath?: boolean;
|
|
11
|
+
acl?:
|
|
12
|
+
| "private"
|
|
13
|
+
| "public-read"
|
|
14
|
+
| "public-read-write"
|
|
15
|
+
| "aws-exec-read"
|
|
16
|
+
| "authenticated-read"
|
|
17
|
+
| "bucket-owner-read"
|
|
18
|
+
| "bucket-owner-full-control"
|
|
19
|
+
| "log-delivery-write";
|
|
20
|
+
bucket?: string;
|
|
21
|
+
region?: string;
|
|
22
|
+
accessKeyId?: string;
|
|
23
|
+
secretAccessKey?: string;
|
|
24
|
+
sessionToken?: string;
|
|
25
|
+
endpoint?: string;
|
|
26
|
+
virtualHostedStyle?: boolean;
|
|
27
|
+
partSize?: number;
|
|
28
|
+
queueSize?: number;
|
|
29
|
+
retry?: number;
|
|
30
|
+
type?: string;
|
|
31
|
+
contentDisposition?: string | undefined;
|
|
32
|
+
storageClass?:
|
|
33
|
+
| "STANDARD"
|
|
34
|
+
| "DEEP_ARCHIVE"
|
|
35
|
+
| "EXPRESS_ONEZONE"
|
|
36
|
+
| "GLACIER"
|
|
37
|
+
| "GLACIER_IR"
|
|
38
|
+
| "INTELLIGENT_TIERING"
|
|
39
|
+
| "ONEZONE_IA"
|
|
40
|
+
| "OUTPOSTS"
|
|
41
|
+
| "REDUCED_REDUNDANCY"
|
|
42
|
+
| "SNOW"
|
|
43
|
+
| "STANDARD_IA";
|
|
44
|
+
requestPayer?: boolean;
|
|
45
|
+
highWaterMark?: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface StorageDriver {
|
|
49
|
+
/**
|
|
50
|
+
* Determine whether a file exists.
|
|
51
|
+
*
|
|
52
|
+
* @param filepath The path to the file.
|
|
53
|
+
* @returns True if the file exists; otherwise false.
|
|
54
|
+
*/
|
|
55
|
+
exists(filepath: string): Promise<boolean>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Determine whether a file is missing.
|
|
59
|
+
*
|
|
60
|
+
* @param filepath The path to the file.
|
|
61
|
+
* @returns True if the file does not exist; otherwise false.
|
|
62
|
+
*/
|
|
63
|
+
missing(filepath: string): Promise<boolean>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Retrieve metadata for a file.
|
|
67
|
+
*
|
|
68
|
+
* @param filepath The path to the file.
|
|
69
|
+
* @returns File metadata and statistics.
|
|
70
|
+
*/
|
|
71
|
+
metadata(filepath: string): Promise<Stats | Bun.S3Stats>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get the file size in bytes.
|
|
75
|
+
*
|
|
76
|
+
* @param filepath The path to the file.
|
|
77
|
+
* @returns The file size in bytes.
|
|
78
|
+
*/
|
|
79
|
+
size(filepath: string): Promise<number>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the file MIME type.
|
|
83
|
+
*
|
|
84
|
+
* @param filepath The path to the file.
|
|
85
|
+
* @returns The detected MIME type.
|
|
86
|
+
*/
|
|
87
|
+
mimeType(filepath: string): Promise<string>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the file's last modification date.
|
|
91
|
+
*
|
|
92
|
+
* @param filepath The path to the file.
|
|
93
|
+
* @returns The last modified timestamp.
|
|
94
|
+
*/
|
|
95
|
+
lastModified(filepath: string): Promise<Date>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve a file from storage.
|
|
99
|
+
*
|
|
100
|
+
* @param filepath The path to the file.
|
|
101
|
+
* @returns The storage file instance.
|
|
102
|
+
*/
|
|
103
|
+
get(filepath: string): Promise<Bun.BunFile | Bun.S3File>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Store content at the given path.
|
|
107
|
+
*
|
|
108
|
+
* @param filepath The destination file path.
|
|
109
|
+
* @param content The content to store.
|
|
110
|
+
* @param options Additional storage options.
|
|
111
|
+
*/
|
|
112
|
+
put(filepath: string, content: any, options?: StorageOptions): Promise<void>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Copy a file to a new location.
|
|
116
|
+
*
|
|
117
|
+
* @param source The source file path.
|
|
118
|
+
* @param destination The destination file path.
|
|
119
|
+
* @param options Additional storage options.
|
|
120
|
+
*/
|
|
121
|
+
copy(source: string, destination: string, options?: StorageOptions): Promise<void>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Move a file to a new location.
|
|
125
|
+
*
|
|
126
|
+
* @param source The source file path.
|
|
127
|
+
* @param destination The destination file path.
|
|
128
|
+
* @param options Additional storage options.
|
|
129
|
+
*/
|
|
130
|
+
move(source: string, destination: string, options?: StorageOptions): Promise<void>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Delete a file from storage.
|
|
134
|
+
*
|
|
135
|
+
* @param filepath The path to the file.
|
|
136
|
+
*/
|
|
137
|
+
delete(filepath: string): Promise<void>;
|
|
138
|
+
}
|