@arkstack/filesystem 0.12.24 → 0.12.26
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
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DriveDirectory, DriveFile, DriveManager } from "flydrive";
|
|
2
2
|
import { Readable } from "node:stream";
|
|
3
3
|
import { DriverContract, ObjectMetaData, ObjectVisibility, SignedURLOptions, WriteOptions } from "flydrive/types";
|
|
4
|
+
import { GCSDriverOptions } from "flydrive/drivers/gcs/types";
|
|
4
5
|
|
|
5
6
|
//#region src/types.d.ts
|
|
6
7
|
interface FileLike {
|
|
@@ -9,6 +10,7 @@ interface FileLike {
|
|
|
9
10
|
mimetype: string;
|
|
10
11
|
}
|
|
11
12
|
interface CustomDiskDriverRegistry {}
|
|
13
|
+
type GcsDiskDriverConfig = GCSDriverOptions;
|
|
12
14
|
interface FtpDriverConfig {
|
|
13
15
|
host: string;
|
|
14
16
|
username: string;
|
|
@@ -38,6 +40,7 @@ interface LocalDriverConfig {
|
|
|
38
40
|
root?: string;
|
|
39
41
|
location?: string | URL;
|
|
40
42
|
visibility: ObjectVisibility;
|
|
43
|
+
url?: string;
|
|
41
44
|
}
|
|
42
45
|
type CustomDiskConfig = keyof CustomDiskDriverRegistry extends never ? {
|
|
43
46
|
driver: string;
|
|
@@ -52,7 +55,7 @@ type DiskConfig = LocalDriverConfig & {
|
|
|
52
55
|
} | S3DriverConfig & {
|
|
53
56
|
driver: 's3';
|
|
54
57
|
} | CustomDiskConfig;
|
|
55
|
-
type DriverConfig<K extends 'ftp' | 'local' | 's3' | (string & {}) = string & {}> = K extends 'ftp' ? FtpDriverConfig : K extends 's3' ? S3DriverConfig : K extends 'local' ? LocalDriverConfig : K extends keyof CustomDiskDriverRegistry ? CustomDiskDriverRegistry[K] : DiskConfig;
|
|
58
|
+
type DriverConfig<K extends 'ftp' | 'local' | 'gcs' | 's3' | (string & {}) = string & {}> = K extends 'ftp' ? FtpDriverConfig : K extends 's3' ? S3DriverConfig : K extends 'gcs' ? GcsDiskDriverConfig : K extends 'local' ? LocalDriverConfig : K extends keyof CustomDiskDriverRegistry ? CustomDiskDriverRegistry[K] : DiskConfig;
|
|
56
59
|
type KnownDisks = {
|
|
57
60
|
local: LocalDriverConfig & {
|
|
58
61
|
driver: 'local';
|
|
@@ -63,12 +66,15 @@ type KnownDisks = {
|
|
|
63
66
|
ftp: FtpDriverConfig & {
|
|
64
67
|
driver: 'ftp';
|
|
65
68
|
};
|
|
69
|
+
gcs: GcsDiskDriverConfig & {
|
|
70
|
+
driver: 'gcs';
|
|
71
|
+
};
|
|
66
72
|
s3: S3DriverConfig & {
|
|
67
73
|
driver: 's3';
|
|
68
74
|
};
|
|
69
75
|
};
|
|
70
76
|
interface FilesystemConfig {
|
|
71
|
-
default: 'local' | 'ftp' | 's3' | keyof CustomDiskDriverRegistry | (string & {});
|
|
77
|
+
default: 'local' | 'ftp' | 'gcs' | 's3' | keyof CustomDiskDriverRegistry | (string & {});
|
|
72
78
|
disks: KnownDisks & CustomDiskDriverRegistry;
|
|
73
79
|
links: Record<string, string>;
|
|
74
80
|
custom_drivers?: Record<keyof CustomDiskDriverRegistry | (string & {}), DriverContract | (new (config?: CustomDiskConfig) => DriverContract)>;
|
|
@@ -434,4 +440,4 @@ declare class FtpDriver implements DriverContract {
|
|
|
434
440
|
}>;
|
|
435
441
|
}
|
|
436
442
|
//#endregion
|
|
437
|
-
export { CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, FileLike, FilesystemConfig, FtpDriver, FtpDriverConfig, KnownDisks, LocalDriverConfig, S3DriverConfig, Storage };
|
|
443
|
+
export { CustomDiskConfig, CustomDiskDriverRegistry, DiskConfig, DriverConfig, FileLike, FilesystemConfig, FtpDriver, FtpDriverConfig, GcsDiskDriverConfig, KnownDisks, LocalDriverConfig, S3DriverConfig, Storage };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as FtpDriver, t as Storage } from "./src-
|
|
1
|
+
import { n as FtpDriver, t as Storage } from "./src-DNh_3BpA.js";
|
|
2
2
|
export { FtpDriver, Storage };
|
|
@@ -5,6 +5,7 @@ import { FSDriver } from "flydrive/drivers/fs";
|
|
|
5
5
|
import Client from "ssh2-sftp-client";
|
|
6
6
|
import { Readable } from "node:stream";
|
|
7
7
|
import path from "node:path";
|
|
8
|
+
import { GCSDriver } from "flydrive/drivers/gcs";
|
|
8
9
|
import { S3Driver } from "flydrive/drivers/s3";
|
|
9
10
|
import { appUrl, config } from "@arkstack/common";
|
|
10
11
|
import { Logger } from "@h3ravel/shared";
|
|
@@ -248,7 +249,8 @@ var Driver = class Driver {
|
|
|
248
249
|
if (![
|
|
249
250
|
"local",
|
|
250
251
|
"ftp",
|
|
251
|
-
"s3"
|
|
252
|
+
"s3",
|
|
253
|
+
"gcs"
|
|
252
254
|
].includes(name) && !this.customDrivers.has(name)) throw new Error(`Unsupported driver: ${name}`);
|
|
253
255
|
const driver = new Driver(config);
|
|
254
256
|
if (this.customDrivers.has(name)) return driver.custom(name);
|
|
@@ -261,9 +263,11 @@ var Driver = class Driver {
|
|
|
261
263
|
visibility: config.visibility ?? "public",
|
|
262
264
|
urlBuilder: {
|
|
263
265
|
async generateURL(key, _path) {
|
|
266
|
+
if (config.url) return `${config.url}/key`.replace(/^(https?:\/)\/+/, "$1/").replace(/([^:]\/)\/+/g, "$1");
|
|
264
267
|
return appUrl(key);
|
|
265
268
|
},
|
|
266
269
|
async generateSignedURL(key, _path, _opts) {
|
|
270
|
+
if (config.url) return `${config.url}/key`.replace(/^(https?:\/)\/+/, "$1/").replace(/([^:]\/)\/+/g, "$1");
|
|
267
271
|
return appUrl(key);
|
|
268
272
|
}
|
|
269
273
|
}
|
|
@@ -283,6 +287,10 @@ var Driver = class Driver {
|
|
|
283
287
|
cdnUrl: config.cdnUrl ?? config.url
|
|
284
288
|
});
|
|
285
289
|
}
|
|
290
|
+
gcs() {
|
|
291
|
+
const { driver: _driver, ...options } = this.config;
|
|
292
|
+
return new GCSDriver(options);
|
|
293
|
+
}
|
|
286
294
|
ftp() {
|
|
287
295
|
const config = this.config;
|
|
288
296
|
return new FtpDriver({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/filesystem",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.26",
|
|
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",
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@h3ravel/shared": "^2.1.3",
|
|
38
|
+
"@google-cloud/storage": "^7.21.0",
|
|
38
39
|
"@aws-sdk/client-s3": "^3.1011.0",
|
|
39
40
|
"@aws-sdk/s3-request-presigner": "^3.1011.0",
|
|
40
41
|
"flydrive": "^2.0.0",
|
|
41
42
|
"ssh2-sftp-client": "^12.1.0",
|
|
42
|
-
"@arkstack/common": "^0.12.
|
|
43
|
-
"@arkstack/contract": "^0.12.
|
|
43
|
+
"@arkstack/common": "^0.12.26",
|
|
44
|
+
"@arkstack/contract": "^0.12.26"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@types/ssh2-sftp-client": "^9.0.6"
|