@bejibun/storage 0.1.1 → 0.1.11

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 (40) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/benchmarks/README.md +46 -0
  3. package/benchmarks/package.json +12 -0
  4. package/benchmarks/scripts/coldstart-baseline.mjs +9 -0
  5. package/benchmarks/scripts/coldstart-optimized.mjs +9 -0
  6. package/benchmarks/scripts/coldstart.mjs +93 -0
  7. package/benchmarks/scripts/readme-writer.mjs +35 -0
  8. package/benchmarks/scripts/table-format.mjs +123 -0
  9. package/benchmarks/scripts/throughput-baseline.mjs +68 -0
  10. package/benchmarks/scripts/throughput-optimized.mjs +68 -0
  11. package/benchmarks/scripts/throughput.mjs +83 -0
  12. package/builders/StorageBuilder.d.ts +117 -0
  13. package/builders/StorageBuilder.js +156 -29
  14. package/builders/storage/StorageLocalBuilder.d.ts +89 -0
  15. package/builders/storage/StorageLocalBuilder.js +109 -21
  16. package/builders/storage/StorageS3Builder.d.ts +90 -0
  17. package/builders/storage/StorageS3Builder.js +107 -18
  18. package/config/storage.d.ts +3 -0
  19. package/config/storage.js +8 -0
  20. package/configure.js +5 -0
  21. package/enums/StorageDiskDriverEnum.d.ts +5 -0
  22. package/enums/StorageDiskDriverEnum.js +5 -0
  23. package/enums/index.d.ts +4 -1
  24. package/enums/index.js +4 -1
  25. package/exceptions/StorageException.d.ts +10 -0
  26. package/exceptions/StorageException.js +10 -0
  27. package/exceptions/index.d.ts +4 -1
  28. package/exceptions/index.js +4 -1
  29. package/facades/Storage.d.ts +87 -0
  30. package/facades/Storage.js +87 -0
  31. package/facades/index.d.ts +4 -1
  32. package/facades/index.js +4 -1
  33. package/index.d.ts +4 -0
  34. package/index.js +4 -0
  35. package/package.json +10 -9
  36. package/tests/integration/storage.integration.test.ts +145 -0
  37. package/tests/unit/storage.test.ts +177 -0
  38. package/tsconfig.json +2 -1
  39. package/types/index.d.ts +4 -1
  40. package/types/storage.d.ts +24 -24
@@ -1,59 +1,125 @@
1
1
  import Logger from "@bejibun/logger";
2
- import { isEmpty } from "@bejibun/utils";
3
- import path from "path";
2
+ import { resolve } from "path";
4
3
  import StorageException from "../../exceptions/StorageException";
4
+ /**
5
+ * Local filesystem storage driver backed by Bun file utilities.
6
+ */
5
7
  export default class StorageLocalBuilder {
8
+ /** The Local disk configuration. */
6
9
  _config;
10
+ /**
11
+ * Create a local storage driver from disk configuration.
12
+ *
13
+ * @param {Record<string, any>} config - The local disk configuration.
14
+ * @throws {StorageException} When the root path is missing.
15
+ */
7
16
  constructor(config) {
8
17
  this._config = config;
9
18
  }
10
19
  get config() {
11
- if (isEmpty(this._config.root))
20
+ if (!this._config.root)
12
21
  throw new StorageException(`Missing "root" for "local" disk configuration.`);
13
22
  return this._config;
14
23
  }
24
+ /**
25
+ * Determine whether a file exists.
26
+ *
27
+ * @param {string} filepath - The path to the file.
28
+ * @returns {Promise<boolean>} True if the file exists; otherwise false.
29
+ * @throws {StorageException} When the file path is empty.
30
+ */
15
31
  async exists(filepath) {
16
- if (isEmpty(filepath))
32
+ if (!filepath)
17
33
  throw new StorageException("The file path is required.");
18
- return await Bun.file(path.resolve(this.config.root, filepath)).exists();
34
+ return await Bun.file(resolve(this.config.root, filepath)).exists();
19
35
  }
36
+ /**
37
+ * Determine whether a file is missing.
38
+ *
39
+ * @param {string} filepath - The path to the file.
40
+ * @returns {Promise<boolean>} True if the file does not exist; otherwise false.
41
+ * @throws {StorageException} When the file path is empty.
42
+ */
20
43
  async missing(filepath) {
21
- if (isEmpty(filepath))
44
+ if (!filepath)
22
45
  throw new StorageException("The file path is required.");
23
46
  return !(await this.exists(filepath));
24
47
  }
48
+ /**
49
+ * Retrieve metadata for a file.
50
+ *
51
+ * @param {string} filepath - The path to the file.
52
+ * @returns {Promise<Stats>} File metadata and statistics.
53
+ * @throws {StorageException} When the file path is empty.
54
+ */
25
55
  async metadata(filepath) {
26
- if (isEmpty(filepath))
56
+ if (!filepath)
27
57
  throw new StorageException("The file path is required.");
28
58
  return await (await this.get(filepath)).stat();
29
59
  }
60
+ /**
61
+ * Get the file size in bytes.
62
+ *
63
+ * @param {string} filepath - The path to the file.
64
+ * @returns {Promise<number>} The file size in bytes.
65
+ * @throws {StorageException} When the file path is empty.
66
+ */
30
67
  async size(filepath) {
31
- if (isEmpty(filepath))
68
+ if (!filepath)
32
69
  throw new StorageException("The file path is required.");
33
70
  return (await this.metadata(filepath)).size;
34
71
  }
72
+ /**
73
+ * Get the file MIME type.
74
+ *
75
+ * @param {string} filepath - The path to the file.
76
+ * @returns {Promise<string>} The detected MIME type.
77
+ * @throws {StorageException} When the file path is empty.
78
+ */
35
79
  async mimeType(filepath) {
36
- if (isEmpty(filepath))
80
+ if (!filepath)
37
81
  throw new StorageException("The file path is required.");
38
82
  return (await this.get(filepath)).type;
39
83
  }
84
+ /**
85
+ * Get the file's last modification date.
86
+ *
87
+ * @param {string} filepath - The path to the file.
88
+ * @returns {Promise<Date>} The last modified timestamp.
89
+ * @throws {StorageException} When the file path is empty.
90
+ */
40
91
  async lastModified(filepath) {
41
- if (isEmpty(filepath))
92
+ if (!filepath)
42
93
  throw new StorageException("The file path is required.");
43
94
  return (await this.metadata(filepath)).mtime;
44
95
  }
96
+ /**
97
+ * Retrieve a file from storage.
98
+ *
99
+ * @param {string} filepath - The path to the file.
100
+ * @returns {Promise<Bun.BunFile>} The local file instance.
101
+ * @throws {StorageException} When the file path is empty.
102
+ */
45
103
  async get(filepath) {
46
- if (isEmpty(filepath))
104
+ if (!filepath)
47
105
  throw new StorageException("The file path is required.");
48
- return Bun.file(path.resolve(this.config.root, filepath));
106
+ return Bun.file(resolve(this.config.root, filepath));
49
107
  }
108
+ /**
109
+ * Store content at the given path.
110
+ *
111
+ * @param {string} filepath - The destination file path.
112
+ * @param {any} content - The content to store.
113
+ * @param {StorageOptions} options - Additional storage options.
114
+ * @throws {StorageException} When the file path or content is empty.
115
+ */
50
116
  async put(filepath, content, options) {
51
- if (isEmpty(filepath))
117
+ if (!filepath)
52
118
  throw new StorageException("The file path is required.");
53
- if (isEmpty(content))
119
+ if (!content)
54
120
  throw new StorageException("The content is required.");
55
121
  try {
56
- await Bun.write(path.resolve(this.config.root, filepath), content, options);
122
+ await Bun.write(resolve(this.config.root, filepath), content, options);
57
123
  }
58
124
  catch (error) {
59
125
  Logger.setContext("Storage")
@@ -61,10 +127,18 @@ export default class StorageLocalBuilder {
61
127
  .trace(error);
62
128
  }
63
129
  }
130
+ /**
131
+ * Copy a file to a new location.
132
+ *
133
+ * @param {string} source - The source file path.
134
+ * @param {string} destination - The destination file path.
135
+ * @param {StorageOptions} options - Additional storage options.
136
+ * @throws {StorageException} When the source or destination path is empty.
137
+ */
64
138
  async copy(source, destination, options) {
65
- if (isEmpty(source))
139
+ if (!source)
66
140
  throw new StorageException("The source file path is required.");
67
- if (isEmpty(destination))
141
+ if (!destination)
68
142
  throw new StorageException("The destination file path is required.");
69
143
  try {
70
144
  await this.put(destination, await this.get(source), options);
@@ -75,10 +149,18 @@ export default class StorageLocalBuilder {
75
149
  .trace(error);
76
150
  }
77
151
  }
152
+ /**
153
+ * Move a file to a new location.
154
+ *
155
+ * @param {string} source - The source file path.
156
+ * @param {string} destination - The destination file path.
157
+ * @param {StorageOptions} options - Additional storage options.
158
+ * @throws {StorageException} When the source or destination path is empty.
159
+ */
78
160
  async move(source, destination, options) {
79
- if (isEmpty(source))
161
+ if (!source)
80
162
  throw new StorageException("The source file path is required.");
81
- if (isEmpty(destination))
163
+ if (!destination)
82
164
  throw new StorageException("The destination file path is required.");
83
165
  try {
84
166
  await this.copy(source, destination, options);
@@ -90,9 +172,15 @@ export default class StorageLocalBuilder {
90
172
  .trace(error);
91
173
  }
92
174
  }
175
+ /**
176
+ * Delete a file from storage.
177
+ *
178
+ * @param {string} filepath - The path to the file.
179
+ * @throws {StorageException} When the file path is empty.
180
+ */
93
181
  async delete(filepath) {
94
- if (isEmpty(filepath))
182
+ if (!filepath)
95
183
  throw new StorageException("The file path is required.");
96
- await Bun.file(path.resolve(this.config.root, filepath)).delete();
184
+ await Bun.file(resolve(this.config.root, filepath)).delete();
97
185
  }
98
186
  }
@@ -1,18 +1,108 @@
1
1
  import type { StorageDriver, StorageOptions } from "../../types/storage";
2
+ /**
3
+ * S3-compatible storage driver backed by a Bun S3 client.
4
+ */
2
5
  export default class StorageS3Builder implements StorageDriver {
6
+ /** The S3 disk configuration. */
3
7
  protected _config: Record<string, any>;
8
+ /** The underlying S3 client. */
4
9
  protected client: Bun.S3Client;
10
+ /**
11
+ * Create an S3 storage driver from disk configuration.
12
+ *
13
+ * @param {Record<string, any>} config - The S3 disk configuration.
14
+ * @throws {StorageException} When the endpoint, access key id, or secret access key is missing.
15
+ */
5
16
  constructor(config: Record<string, any>);
6
17
  private get config();
18
+ /**
19
+ * Determine whether a file exists.
20
+ *
21
+ * @param {string} filepath - The path to the file.
22
+ * @returns {Promise<boolean>} True if the file exists; otherwise false.
23
+ * @throws {StorageException} When the file path is empty.
24
+ */
7
25
  exists(filepath: string): Promise<boolean>;
26
+ /**
27
+ * Determine whether a file is missing.
28
+ *
29
+ * @param {string} filepath - The path to the file.
30
+ * @returns {Promise<boolean>} True if the file does not exist; otherwise false.
31
+ * @throws {StorageException} When the file path is empty.
32
+ */
8
33
  missing(filepath: string): Promise<boolean>;
34
+ /**
35
+ * Retrieve metadata for a file.
36
+ *
37
+ * @param {string} filepath - The path to the file.
38
+ * @returns {Promise<Bun.S3Stats>} File metadata and statistics.
39
+ * @throws {StorageException} When the file path is empty.
40
+ */
9
41
  metadata(filepath: string): Promise<Bun.S3Stats>;
42
+ /**
43
+ * Get the file size in bytes.
44
+ *
45
+ * @param {string} filepath - The path to the file.
46
+ * @returns {Promise<number>} The file size in bytes.
47
+ * @throws {StorageException} When the file path is empty.
48
+ */
10
49
  size(filepath: string): Promise<number>;
50
+ /**
51
+ * Get the file MIME type.
52
+ *
53
+ * @param {string} filepath - The path to the file.
54
+ * @returns {Promise<string>} The detected MIME type.
55
+ * @throws {StorageException} When the file path is empty.
56
+ */
11
57
  mimeType(filepath: string): Promise<string>;
58
+ /**
59
+ * Get the file's last modification date.
60
+ *
61
+ * @param {string} filepath - The path to the file.
62
+ * @returns {Promise<Date>} The last modified timestamp.
63
+ * @throws {StorageException} When the file path is empty.
64
+ */
12
65
  lastModified(filepath: string): Promise<Date>;
66
+ /**
67
+ * Retrieve a file from storage.
68
+ *
69
+ * @param {string} filepath - The path to the file.
70
+ * @returns {Promise<Bun.S3File>} The S3 file instance.
71
+ * @throws {StorageException} When the file path is empty.
72
+ */
13
73
  get(filepath: string): Promise<Bun.S3File>;
74
+ /**
75
+ * Store content at the given path.
76
+ *
77
+ * @param {string} filepath - The destination file path.
78
+ * @param {any} content - The content to store.
79
+ * @param {StorageOptions} options - Additional storage options.
80
+ * @throws {StorageException} When the file path or content is empty.
81
+ */
14
82
  put(filepath: string, content: any, options?: StorageOptions): Promise<void>;
83
+ /**
84
+ * Copy a file to a new location.
85
+ *
86
+ * @param {string} source - The source file path.
87
+ * @param {string} destination - The destination file path.
88
+ * @param {StorageOptions} options - Additional storage options.
89
+ * @throws {StorageException} When the source or destination path is empty.
90
+ */
15
91
  copy(source: string, destination: string, options?: StorageOptions): Promise<void>;
92
+ /**
93
+ * Move a file to a new location.
94
+ *
95
+ * @param {string} source - The source file path.
96
+ * @param {string} destination - The destination file path.
97
+ * @param {StorageOptions} options - Additional storage options.
98
+ * @throws {StorageException} When the source or destination path is empty.
99
+ */
16
100
  move(source: string, destination: string, options?: StorageOptions): Promise<void>;
101
+ /**
102
+ * Delete a file from storage.
103
+ *
104
+ * @param {string} filepath - The path to the file.
105
+ * @throws {StorageException} When the file path is empty.
106
+ */
17
107
  delete(filepath: string): Promise<void>;
18
108
  }
@@ -1,9 +1,19 @@
1
1
  import Logger from "@bejibun/logger";
2
- import { isEmpty } from "@bejibun/utils";
3
2
  import StorageException from "../../exceptions/StorageException";
3
+ /**
4
+ * S3-compatible storage driver backed by a Bun S3 client.
5
+ */
4
6
  export default class StorageS3Builder {
7
+ /** The S3 disk configuration. */
5
8
  _config;
9
+ /** The underlying S3 client. */
6
10
  client;
11
+ /**
12
+ * Create an S3 storage driver from disk configuration.
13
+ *
14
+ * @param {Record<string, any>} config - The S3 disk configuration.
15
+ * @throws {StorageException} When the endpoint, access key id, or secret access key is missing.
16
+ */
7
17
  constructor(config) {
8
18
  this._config = config;
9
19
  this.client = new Bun.S3Client({
@@ -15,53 +25,110 @@ export default class StorageS3Builder {
15
25
  });
16
26
  }
17
27
  get config() {
18
- if (isEmpty(this._config.endpoint))
28
+ if (!this._config.endpoint)
19
29
  throw new StorageException(`Missing "endpoint" for "s3" disk configuration.`);
20
- if (isEmpty(this._config.access_key_id))
30
+ if (!this._config.access_key_id)
21
31
  throw new StorageException(`Missing "access_key_id" for "s3" disk configuration.`);
22
- if (isEmpty(this._config.secret_access_key))
32
+ if (!this._config.secret_access_key)
23
33
  throw new StorageException(`Missing "secret_access_key" for "s3" disk configuration.`);
24
34
  return this._config;
25
35
  }
36
+ /**
37
+ * Determine whether a file exists.
38
+ *
39
+ * @param {string} filepath - The path to the file.
40
+ * @returns {Promise<boolean>} True if the file exists; otherwise false.
41
+ * @throws {StorageException} When the file path is empty.
42
+ */
26
43
  async exists(filepath) {
27
- if (isEmpty(filepath))
44
+ if (!filepath)
28
45
  throw new StorageException("The file path is required.");
29
46
  return await this.client.file(filepath).exists();
30
47
  }
48
+ /**
49
+ * Determine whether a file is missing.
50
+ *
51
+ * @param {string} filepath - The path to the file.
52
+ * @returns {Promise<boolean>} True if the file does not exist; otherwise false.
53
+ * @throws {StorageException} When the file path is empty.
54
+ */
31
55
  async missing(filepath) {
32
- if (isEmpty(filepath))
56
+ if (!filepath)
33
57
  throw new StorageException("The file path is required.");
34
58
  return !(await this.exists(filepath));
35
59
  }
60
+ /**
61
+ * Retrieve metadata for a file.
62
+ *
63
+ * @param {string} filepath - The path to the file.
64
+ * @returns {Promise<Bun.S3Stats>} File metadata and statistics.
65
+ * @throws {StorageException} When the file path is empty.
66
+ */
36
67
  async metadata(filepath) {
37
- if (isEmpty(filepath))
68
+ if (!filepath)
38
69
  throw new StorageException("The file path is required.");
39
70
  return await (await this.get(filepath)).stat();
40
71
  }
72
+ /**
73
+ * Get the file size in bytes.
74
+ *
75
+ * @param {string} filepath - The path to the file.
76
+ * @returns {Promise<number>} The file size in bytes.
77
+ * @throws {StorageException} When the file path is empty.
78
+ */
41
79
  async size(filepath) {
42
- if (isEmpty(filepath))
80
+ if (!filepath)
43
81
  throw new StorageException("The file path is required.");
44
82
  return (await this.metadata(filepath)).size;
45
83
  }
84
+ /**
85
+ * Get the file MIME type.
86
+ *
87
+ * @param {string} filepath - The path to the file.
88
+ * @returns {Promise<string>} The detected MIME type.
89
+ * @throws {StorageException} When the file path is empty.
90
+ */
46
91
  async mimeType(filepath) {
47
- if (isEmpty(filepath))
92
+ if (!filepath)
48
93
  throw new StorageException("The file path is required.");
49
94
  return (await this.metadata(filepath)).type;
50
95
  }
96
+ /**
97
+ * Get the file's last modification date.
98
+ *
99
+ * @param {string} filepath - The path to the file.
100
+ * @returns {Promise<Date>} The last modified timestamp.
101
+ * @throws {StorageException} When the file path is empty.
102
+ */
51
103
  async lastModified(filepath) {
52
- if (isEmpty(filepath))
104
+ if (!filepath)
53
105
  throw new StorageException("The file path is required.");
54
106
  return (await this.metadata(filepath)).lastModified;
55
107
  }
108
+ /**
109
+ * Retrieve a file from storage.
110
+ *
111
+ * @param {string} filepath - The path to the file.
112
+ * @returns {Promise<Bun.S3File>} The S3 file instance.
113
+ * @throws {StorageException} When the file path is empty.
114
+ */
56
115
  async get(filepath) {
57
- if (isEmpty(filepath))
116
+ if (!filepath)
58
117
  throw new StorageException("The file path is required.");
59
118
  return this.client.file(filepath);
60
119
  }
120
+ /**
121
+ * Store content at the given path.
122
+ *
123
+ * @param {string} filepath - The destination file path.
124
+ * @param {any} content - The content to store.
125
+ * @param {StorageOptions} options - Additional storage options.
126
+ * @throws {StorageException} When the file path or content is empty.
127
+ */
61
128
  async put(filepath, content, options) {
62
- if (isEmpty(filepath))
129
+ if (!filepath)
63
130
  throw new StorageException("The file path is required.");
64
- if (isEmpty(content))
131
+ if (!content)
65
132
  throw new StorageException("The content is required.");
66
133
  try {
67
134
  await this.client.write(filepath, content, options);
@@ -72,10 +139,18 @@ export default class StorageS3Builder {
72
139
  .trace(error);
73
140
  }
74
141
  }
142
+ /**
143
+ * Copy a file to a new location.
144
+ *
145
+ * @param {string} source - The source file path.
146
+ * @param {string} destination - The destination file path.
147
+ * @param {StorageOptions} options - Additional storage options.
148
+ * @throws {StorageException} When the source or destination path is empty.
149
+ */
75
150
  async copy(source, destination, options) {
76
- if (isEmpty(source))
151
+ if (!source)
77
152
  throw new StorageException("The source file path is required.");
78
- if (isEmpty(destination))
153
+ if (!destination)
79
154
  throw new StorageException("The destination file path is required.");
80
155
  try {
81
156
  await this.put(destination, await this.get(source), options);
@@ -86,10 +161,18 @@ export default class StorageS3Builder {
86
161
  .trace(error);
87
162
  }
88
163
  }
164
+ /**
165
+ * Move a file to a new location.
166
+ *
167
+ * @param {string} source - The source file path.
168
+ * @param {string} destination - The destination file path.
169
+ * @param {StorageOptions} options - Additional storage options.
170
+ * @throws {StorageException} When the source or destination path is empty.
171
+ */
89
172
  async move(source, destination, options) {
90
- if (isEmpty(source))
173
+ if (!source)
91
174
  throw new StorageException("The source file path is required.");
92
- if (isEmpty(destination))
175
+ if (!destination)
93
176
  throw new StorageException("The destination file path is required.");
94
177
  try {
95
178
  await this.copy(source, destination, options);
@@ -101,8 +184,14 @@ export default class StorageS3Builder {
101
184
  .trace(error);
102
185
  }
103
186
  }
187
+ /**
188
+ * Delete a file from storage.
189
+ *
190
+ * @param {string} filepath - The path to the file.
191
+ * @throws {StorageException} When the file path is empty.
192
+ */
104
193
  async delete(filepath) {
105
- if (isEmpty(filepath))
194
+ if (!filepath)
106
195
  throw new StorageException("The file path is required.");
107
196
  await this.client.file(filepath).delete();
108
197
  }
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Default storage configuration defining the available disk drivers and their settings.
3
+ */
1
4
  declare const config: Record<string, any>;
2
5
  export default config;
package/config/storage.js CHANGED
@@ -1,17 +1,25 @@
1
1
  import App from "@bejibun/app";
2
2
  import StorageDiskDriverEnum from "../enums/StorageDiskDriverEnum";
3
+ /**
4
+ * Default storage configuration defining the available disk drivers and their settings.
5
+ */
3
6
  const config = {
7
+ /** The default disk used when no disk is specified. */
4
8
  default: "local",
9
+ /** The collection of named storage disks. */
5
10
  disks: {
11
+ /** Local disk using the application storage path as its root. */
6
12
  local: {
7
13
  driver: StorageDiskDriverEnum.Local,
8
14
  root: App.Path.storagePath("app")
9
15
  },
16
+ /** Publicly accessible local disk rooted at the public storage path. */
10
17
  public: {
11
18
  driver: StorageDiskDriverEnum.Local,
12
19
  root: App.Path.storagePath("app/public"),
13
20
  url: `${Bun.env.APP_URL}/storage/public`
14
21
  },
22
+ /** S3-compatible disk configured via S3 environment variables. */
15
23
  s3: {
16
24
  driver: StorageDiskDriverEnum.S3,
17
25
  endpoint: Bun.env.S3_ENDPOINT,
package/configure.js CHANGED
@@ -1,8 +1,13 @@
1
1
  import App from "@bejibun/app";
2
2
  import Logger from "@bejibun/logger";
3
3
  import path from "path";
4
+ /**
5
+ * Copy all package config files into the application config directory.
6
+ */
4
7
  const configPath = path.resolve(__dirname, "config");
8
+ /** Match JavaScript and TypeScript config file extensions. */
5
9
  const regex = /\.(m?js|ts)$/;
10
+ /** The list of config files found in the package config directory. */
6
11
  const configs = Array.from(new Bun.Glob("**/*").scanSync({
7
12
  cwd: configPath
8
13
  })).filter((value) => regex.test(value) && !value.endsWith(".d.ts"));
@@ -1,5 +1,10 @@
1
+ /**
2
+ * Supported storage disk drivers.
3
+ */
1
4
  declare enum StorageDiskDriverEnum {
5
+ /** Local filesystem disk driver. */
2
6
  Local = "local",
7
+ /** Amazon S3-compatible disk driver. */
3
8
  S3 = "s3"
4
9
  }
5
10
  export default StorageDiskDriverEnum;
@@ -1,6 +1,11 @@
1
+ /**
2
+ * Supported storage disk drivers.
3
+ */
1
4
  var StorageDiskDriverEnum;
2
5
  (function (StorageDiskDriverEnum) {
6
+ /** Local filesystem disk driver. */
3
7
  StorageDiskDriverEnum["Local"] = "local";
8
+ /** Amazon S3-compatible disk driver. */
4
9
  StorageDiskDriverEnum["S3"] = "s3";
5
10
  })(StorageDiskDriverEnum || (StorageDiskDriverEnum = {}));
6
11
  export default StorageDiskDriverEnum;
package/enums/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export * from "../enums/StorageDiskDriverEnum";
1
+ /**
2
+ * Re-exports the storage enums.
3
+ */
4
+ export { default as StorageDiskDriverEnum } from "./StorageDiskDriverEnum";
package/enums/index.js CHANGED
@@ -1 +1,4 @@
1
- export * from "../enums/StorageDiskDriverEnum";
1
+ /**
2
+ * Re-exports the storage enums.
3
+ */
4
+ export { default as StorageDiskDriverEnum } from "./StorageDiskDriverEnum";
@@ -1,4 +1,14 @@
1
+ /**
2
+ * Exception thrown when a storage operation fails.
3
+ */
1
4
  export default class StorageException extends Error {
5
+ /** The HTTP status code associated with the exception. */
2
6
  code: number;
7
+ /**
8
+ * Create a new storage exception.
9
+ *
10
+ * @param {string} message - The error message.
11
+ * @param {number} code - The HTTP status code, defaults to 503.
12
+ */
3
13
  constructor(message?: string, code?: number);
4
14
  }
@@ -1,7 +1,17 @@
1
1
  import Logger from "@bejibun/logger";
2
2
  import { defineValue } from "@bejibun/utils";
3
+ /**
4
+ * Exception thrown when a storage operation fails.
5
+ */
3
6
  export default class StorageException extends Error {
7
+ /** The HTTP status code associated with the exception. */
4
8
  code;
9
+ /**
10
+ * Create a new storage exception.
11
+ *
12
+ * @param {string} message - The error message.
13
+ * @param {number} code - The HTTP status code, defaults to 503.
14
+ */
5
15
  constructor(message, code) {
6
16
  super(message);
7
17
  this.name = "StorageException";
@@ -1 +1,4 @@
1
- export * from "../exceptions/StorageException";
1
+ /**
2
+ * Re-exports the storage exception classes.
3
+ */
4
+ export { default as StorageException } from "./StorageException";
@@ -1 +1,4 @@
1
- export * from "../exceptions/StorageException";
1
+ /**
2
+ * Re-exports the storage exception classes.
3
+ */
4
+ export { default as StorageException } from "./StorageException";