@arkstack/filesystem 0.12.6 → 0.12.7
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/dist/index.d.ts +174 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -81,29 +81,123 @@ declare class Storage implements DriverContract {
|
|
|
81
81
|
services: Record<string, () => DriverContract>;
|
|
82
82
|
diskName: string;
|
|
83
83
|
constructor();
|
|
84
|
+
/**
|
|
85
|
+
* Static method to get a disk instance directly from the Storage class without needing to instantiate it first.
|
|
86
|
+
*
|
|
87
|
+
* @param diskName The name of the disk to use. If not provided, the default disk will be used.
|
|
88
|
+
* @returns A Storage instance
|
|
89
|
+
*/
|
|
84
90
|
static disk<K extends string>(diskName?: K): Storage;
|
|
91
|
+
/**
|
|
92
|
+
* Generate a unique name for the file based on random numbers and original extension
|
|
93
|
+
*
|
|
94
|
+
* @param file The file object containing the original name
|
|
95
|
+
* @returns A unique file name
|
|
96
|
+
*/
|
|
85
97
|
static generateName: (file: {
|
|
86
98
|
name?: string;
|
|
87
99
|
originalname?: string;
|
|
88
100
|
}) => string;
|
|
101
|
+
/**
|
|
102
|
+
* Save the file to the storage and return the public URL and the file path
|
|
103
|
+
*
|
|
104
|
+
* @param file The file object containing the file data
|
|
105
|
+
* @param filePath The path where the file should be saved
|
|
106
|
+
* @param fileName The name to save the file as (optional)
|
|
107
|
+
* @returns A tuple containing the public URL and the file path
|
|
108
|
+
*/
|
|
89
109
|
static saveFile: (file: FileLike, filePath?: string, fileName?: string) => Promise<[string, string]>;
|
|
110
|
+
/**
|
|
111
|
+
* Save the file to the storage and return the public URL and the file path
|
|
112
|
+
*
|
|
113
|
+
* @param file The file object containing the file data
|
|
114
|
+
* @param filePath The path where the file should be saved
|
|
115
|
+
* @param fileName The name to save the file as (optional)
|
|
116
|
+
* @returns A tuple containing the public URL and the file path
|
|
117
|
+
*/
|
|
90
118
|
saveFile: (file: FileLike, filePath?: string, fileName?: string) => Promise<[string, string]>;
|
|
119
|
+
/**
|
|
120
|
+
* Return a boolean indicating if the file exists
|
|
121
|
+
*/
|
|
91
122
|
exists(key: string): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Return contents of a object for the given key as a UTF-8 string.
|
|
125
|
+
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
126
|
+
* does not exists.
|
|
127
|
+
*/
|
|
92
128
|
get(key: string): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Return contents of a object for the given key as a Readable stream.
|
|
131
|
+
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
132
|
+
* does not exists.
|
|
133
|
+
*/
|
|
93
134
|
getStream(key: string): Promise<Readable>;
|
|
135
|
+
/**
|
|
136
|
+
* Return contents of an object for the given key as an Uint8Array.
|
|
137
|
+
* Should throw "E_CANNOT_READ_FILE" error when the file
|
|
138
|
+
* does not exists.
|
|
139
|
+
*/
|
|
94
140
|
getBytes(key: string): Promise<Uint8Array>;
|
|
141
|
+
/**
|
|
142
|
+
* Return metadata of an object for the given key.
|
|
143
|
+
*/
|
|
95
144
|
getMetaData(key: string): Promise<ObjectMetaData>;
|
|
145
|
+
/**
|
|
146
|
+
* Return the visibility of the file
|
|
147
|
+
*/
|
|
96
148
|
getVisibility(key: string): Promise<ObjectVisibility>;
|
|
149
|
+
/**
|
|
150
|
+
* Return the public URL to access the file
|
|
151
|
+
*/
|
|
97
152
|
getUrl(key: string): Promise<string>;
|
|
153
|
+
/**
|
|
154
|
+
* Return the signed/temporary URL to access the file
|
|
155
|
+
*/
|
|
98
156
|
getSignedUrl(key: string, options?: SignedURLOptions): Promise<string>;
|
|
157
|
+
/**
|
|
158
|
+
* Return the signed/temporary URL that can be used to directly upload
|
|
159
|
+
* the file contents to the storage.
|
|
160
|
+
*/
|
|
99
161
|
getSignedUploadUrl(key: string, options?: SignedURLOptions): Promise<string>;
|
|
162
|
+
/**
|
|
163
|
+
* Update the visibility of the file
|
|
164
|
+
*/
|
|
100
165
|
setVisibility(key: string, visibility: ObjectVisibility): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Write object to the destination with the provided
|
|
168
|
+
* contents.
|
|
169
|
+
*/
|
|
101
170
|
put(key: string, contents: string | Uint8Array | FileLike, options?: WriteOptions): Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Write object to the destination with the provided
|
|
173
|
+
* contents as a readable stream
|
|
174
|
+
*/
|
|
102
175
|
putStream(key: string, contents: Readable, options?: WriteOptions): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Copy the file from within the disk root location. Both
|
|
178
|
+
* the "source" and "destination" will be the key names
|
|
179
|
+
* and not absolute paths.
|
|
180
|
+
*/
|
|
103
181
|
copy(source: string, destination: string, options?: WriteOptions): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Move the file from within the disk root location. Both
|
|
184
|
+
* the "source" and "destination" will be the key names
|
|
185
|
+
* and not absolute paths.
|
|
186
|
+
*/
|
|
104
187
|
move(source: string, destination: string, options?: WriteOptions): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Delete the file for the given key. Should not throw
|
|
190
|
+
* error when file does not exist in first place
|
|
191
|
+
*/
|
|
105
192
|
delete(key: string): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Delete the files and directories matching the provided prefix.
|
|
195
|
+
*/
|
|
106
196
|
deleteAll(prefix: string): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* The list all method must return an array of objects with
|
|
199
|
+
* the ability to paginate results (if supported).
|
|
200
|
+
*/
|
|
107
201
|
listAll(prefix: string, options?: {
|
|
108
202
|
recursive?: boolean;
|
|
109
203
|
paginationToken?: string;
|
|
@@ -111,7 +205,13 @@ declare class Storage implements DriverContract {
|
|
|
111
205
|
paginationToken?: string;
|
|
112
206
|
objects: Iterable<DriveFile | DriveDirectory>;
|
|
113
207
|
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Switch bucket at runtime if supported.
|
|
210
|
+
*/
|
|
114
211
|
bucket(bucket: string): DriverContract;
|
|
212
|
+
/**
|
|
213
|
+
* Create symbolic links for all configured links in the application configuration.
|
|
214
|
+
*/
|
|
115
215
|
static link({
|
|
116
216
|
force
|
|
117
217
|
}?: {
|
|
@@ -140,22 +240,92 @@ declare class FtpDriver implements DriverContract {
|
|
|
140
240
|
};
|
|
141
241
|
private init;
|
|
142
242
|
private load;
|
|
243
|
+
/**
|
|
244
|
+
* Return a boolean value indicating if the file exists
|
|
245
|
+
* or not.
|
|
246
|
+
*/
|
|
143
247
|
exists(key: string): Promise<boolean>;
|
|
248
|
+
/**
|
|
249
|
+
* Return the file contents as a UTF-8 string. Throw an exception
|
|
250
|
+
* if the file is missing.
|
|
251
|
+
*/
|
|
144
252
|
get(key: string): Promise<string>;
|
|
253
|
+
/**
|
|
254
|
+
* Return the file contents as a Readable stream. Throw an exception
|
|
255
|
+
* if the file is missing.
|
|
256
|
+
*/
|
|
145
257
|
getStream(key: string): Promise<Readable>;
|
|
258
|
+
/**
|
|
259
|
+
* Return the file contents as a Uint8Array. Throw an exception
|
|
260
|
+
* if the file is missing.
|
|
261
|
+
*/
|
|
146
262
|
getBytes(key: string): Promise<Uint8Array>;
|
|
263
|
+
/**
|
|
264
|
+
* Return metadata of the file. Throw an exception
|
|
265
|
+
* if the file is missing.
|
|
266
|
+
*/
|
|
147
267
|
getMetaData(key: string): Promise<ObjectMetaData>;
|
|
268
|
+
/**
|
|
269
|
+
* Return visibility of the file. Infer visibility from the initial
|
|
270
|
+
* config, when the driver does not support the concept of visibility.
|
|
271
|
+
*/
|
|
148
272
|
getVisibility(key: string): Promise<ObjectVisibility>;
|
|
273
|
+
/**
|
|
274
|
+
* Return the public URL of the file. Throw an exception when the driver
|
|
275
|
+
* does not support generating URLs.
|
|
276
|
+
*/
|
|
149
277
|
getUrl(key: string): Promise<string>;
|
|
278
|
+
/**
|
|
279
|
+
* Return the signed URL to serve a private file. Throw exception
|
|
280
|
+
* when the driver does not support generating URLs.
|
|
281
|
+
*/
|
|
150
282
|
getSignedUrl(key: string, options?: SignedURLOptions): Promise<string>;
|
|
283
|
+
/**
|
|
284
|
+
* Return the signed/temporary URL that can be used to directly upload
|
|
285
|
+
* the file contents to the storage.
|
|
286
|
+
*/
|
|
151
287
|
getSignedUploadUrl(key: string, options?: SignedURLOptions): Promise<string>;
|
|
288
|
+
/**
|
|
289
|
+
* Update the visibility of the file. Result in a NOOP
|
|
290
|
+
* when the driver does not support the concept of
|
|
291
|
+
* visibility.
|
|
292
|
+
*/
|
|
152
293
|
setVisibility(key: string, visibility: ObjectVisibility): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Create a new file or update an existing file. The contents
|
|
296
|
+
* will be a UTF-8 string or "Uint8Array".
|
|
297
|
+
*/
|
|
153
298
|
put(key: string, contents: string | Uint8Array, options?: WriteOptions): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Create a new file or update an existing file. The contents
|
|
301
|
+
* will be a Readable stream.
|
|
302
|
+
*/
|
|
154
303
|
putStream(key: string, contents: Readable, options?: WriteOptions): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Copy the existing file to the destination. Make sure the new file
|
|
306
|
+
* has the same visibility as the existing file. It might require
|
|
307
|
+
* manually fetching the visibility of the "source" file.
|
|
308
|
+
*/
|
|
155
309
|
copy(source: string, destination: string, options?: WriteOptions): Promise<void>;
|
|
310
|
+
/**
|
|
311
|
+
* Move the existing file to the destination. Make sure the new file
|
|
312
|
+
* has the same visibility as the existing file. It might require
|
|
313
|
+
* manually fetching the visibility of the "source" file.
|
|
314
|
+
*/
|
|
156
315
|
move(source: string, destination: string, options?: WriteOptions): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Delete an existing file. Do not throw an error if the
|
|
318
|
+
* file is already missing
|
|
319
|
+
*/
|
|
157
320
|
delete(key: string): Promise<void>;
|
|
321
|
+
/**
|
|
322
|
+
* Delete all files inside a folder. Do not throw an error
|
|
323
|
+
* if the folder does not exist or is empty.
|
|
324
|
+
*/
|
|
158
325
|
deleteAll(prefix: string): Promise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Switch bucket at runtime if supported.
|
|
328
|
+
*/
|
|
159
329
|
bucket(config: string | {
|
|
160
330
|
host: string;
|
|
161
331
|
username: string;
|
|
@@ -164,6 +334,10 @@ declare class FtpDriver implements DriverContract {
|
|
|
164
334
|
verbose?: boolean;
|
|
165
335
|
privateKey?: string;
|
|
166
336
|
}): DriverContract;
|
|
337
|
+
/**
|
|
338
|
+
* List all files from a given folder or the root of the storage.
|
|
339
|
+
* Do not throw an error if the request folder does not exist.
|
|
340
|
+
*/
|
|
167
341
|
listAll(prefix: string, options?: {
|
|
168
342
|
recursive?: boolean;
|
|
169
343
|
paginationToken?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/filesystem",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Filesystem module for Arkstack, providing shared file storage and filesystem utitlities for the framework.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@aws-sdk/s3-request-presigner": "^3.1011.0",
|
|
40
40
|
"flydrive": "^2.0.0",
|
|
41
41
|
"ssh2-sftp-client": "^12.1.0",
|
|
42
|
-
"@arkstack/common": "^0.12.
|
|
43
|
-
"@arkstack/contract": "^0.12.
|
|
42
|
+
"@arkstack/common": "^0.12.7",
|
|
43
|
+
"@arkstack/contract": "^0.12.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/ssh2-sftp-client": "^9.0.6"
|