@arkstack/filesystem 0.16.3 → 0.16.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/filesystem",
3
- "version": "0.16.3",
3
+ "version": "0.16.5",
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",
@@ -20,7 +20,8 @@
20
20
  "flydrive"
21
21
  ],
22
22
  "files": [
23
- "dist"
23
+ "dist",
24
+ "stubs"
24
25
  ],
25
26
  "publishConfig": {
26
27
  "access": "public"
@@ -40,8 +41,8 @@
40
41
  "@aws-sdk/s3-request-presigner": "^3.1011.0",
41
42
  "flydrive": "^2.0.0",
42
43
  "ssh2-sftp-client": "^12.1.0",
43
- "@arkstack/contract": "^0.16.3",
44
- "@arkstack/common": "^0.16.3"
44
+ "@arkstack/common": "^0.16.5",
45
+ "@arkstack/contract": "^0.16.5"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/ssh2-sftp-client": "^9.0.6"
@@ -0,0 +1,86 @@
1
+ import { Arkstack } from '@arkstack/contract'
2
+ import { FilesystemConfig } from '@arkstack/filesystem'
3
+ import path from 'node:path'
4
+
5
+ export default (): FilesystemConfig => {
6
+ return {
7
+ /**
8
+ * Default filesystem disk to be used by the framework.
9
+ */
10
+ default: env('FILESYSTEM_DISK', 'local'),
11
+
12
+ /**
13
+ * Available disks and their configurations.
14
+ *
15
+ * You can configure as many disks as you want, and even have multiple disks
16
+ * using the same driver.
17
+ *
18
+ * Supported drivers: local, ftp, s3
19
+ */
20
+ disks: {
21
+ local: {
22
+ driver: 'local',
23
+ root: path.join(Arkstack.rootDir(), './storage/app'),
24
+ visibility: 'public',
25
+ },
26
+ public: {
27
+ driver: 'local',
28
+ root: path.join(Arkstack.rootDir(), './storage/app/public'),
29
+ visibility: 'public'
30
+ },
31
+ ftp: {
32
+ driver: 'ftp',
33
+ host: env('FTP_HOST'),
34
+ username: env('FTP_USERNAME'),
35
+ password: env('FTP_PASSWORD'),
36
+ port: env('FTP_PORT', 21),
37
+ verbose: env('FTP_VERBOSE', false),
38
+ privateKey: env('FTP_PRIVATE_KEY'),
39
+ },
40
+ s3: {
41
+ driver: 's3',
42
+ key: env('AWS_ACCESS_KEY_ID'),
43
+ secret: env('AWS_SECRET_ACCESS_KEY'),
44
+ region: env('AWS_DEFAULT_REGION'),
45
+ bucket: env('AWS_BUCKET'),
46
+ url: env('AWS_URL'),
47
+ endpoint: env('AWS_ENDPOINT'),
48
+ visibility: 'public',
49
+ },
50
+ gcs: {
51
+ driver: 'gcs',
52
+ projectId: env('GOOGLE_CLOUD_PROJECT'),
53
+ keyFilename: env('GOOGLE_APPLICATION_CREDENTIALS'),
54
+ bucket: env('GOOGLE_CLOUD_STORAGE_BUCKET'),
55
+ visibility: 'private',
56
+ usingUniformAcl: true,
57
+ }
58
+ },
59
+
60
+ /**
61
+ * Optional symbolic links to create when the `storage:link` command is executed.
62
+ * The key of the object represents the link location, while the value represents the target location.
63
+ */
64
+ links: {
65
+ [path.join(Arkstack.rootDir(), './public/storage')]: path.join(Arkstack.rootDir(), './storage/app/public'),
66
+ },
67
+
68
+ /**
69
+ * Optional file name generator function.
70
+ * If provided, this function will be used to generate unique file names
71
+ * for uploaded files when using the `saveFile` method of the Storage class.
72
+ *
73
+ * @param originalName The original name of the file
74
+ * @returns A unique file name
75
+ *
76
+ * fileNameGenerator: (originalName: string) => {
77
+ * const timestamp = Date.now()
78
+ * const randomString = Math.random().toString(36).substring(2, 8)
79
+ * const extension = path.extname(originalName)
80
+ * const baseName = path.basename(originalName, extension)
81
+ *
82
+ * return `${baseName}-${timestamp}-${randomString}${extension}`
83
+ * },
84
+ */
85
+ }
86
+ }