@stacksjs/storage 0.70.327 → 0.70.328
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/drivers/aws.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createS3Storage}from"../adapters/s3";let _adapterPromise=null;async function loadConfig(){try{const{filesystems}=await import("@stacksjs/config"),s3Config=filesystems.s3;return createS3Storage(null,{bucket:s3Config?.bucket||"stacks",prefix:s3Config?.prefix||"stx",region:s3Config?.region||"us-east-1"})}catch{const{env}=await import("@stacksjs/env");return createS3Storage(null,{bucket:env.AWS_S3_BUCKET||"stacks",prefix:env.AWS_S3_PREFIX||"stx",region:env.AWS_REGION||"us-east-1"})}}async function getAdapter(){if(!_adapterPromise)_adapterPromise=loadConfig();return _adapterPromise}export async function getAwsStorage(){return getAdapter()}export const aws={async write(path,contents){await(await getAdapter()).write(path,contents)},async deleteFile(path){await(await getAdapter()).deleteFile(path)},async createDirectory(path){await(await getAdapter()).createDirectory(path)},async moveFile(from,to){await(await getAdapter()).moveFile(from,to)},async copyFile(from,to){await(await getAdapter()).copyFile(from,to)},async stat(path){return await(await getAdapter()).stat(path)},list(path,options={deep:!1}){return async function*(){yield*(await getAdapter()).list(path,options)}()},async changeVisibility(path,visibility){await(await getAdapter()).changeVisibility(path,visibility)},async visibility(path){return await(await getAdapter()).visibility(path)},async fileExists(path){return await(await getAdapter()).fileExists(path)},async directoryExists(path){return await(await getAdapter()).directoryExists(path)},async publicUrl(path,options){return await(await getAdapter()).publicUrl(path,options)},async temporaryUrl(path,options){return await(await getAdapter()).temporaryUrl(path,options)},async checksum(path,options){return await(await getAdapter()).checksum(path,options)},async mimeType(path,options){return await(await getAdapter()).mimeType(path,options)},async lastModified(path){return await(await getAdapter()).lastModified(path)},async fileSize(path){return await(await getAdapter()).fileSize(path)},async read(path){return await(await getAdapter()).read(path)},async readToString(path){return await(await getAdapter()).readToString(path)},async readToBuffer(path){return await(await getAdapter()).readToBuffer(path)},async readToUint8Array(path){return await(await getAdapter()).readToUint8Array(path)}};
|
|
1
|
+
import{createS3Storage}from"../adapters/s3";let _adapterPromise=null;async function loadConfig(){try{const{filesystems}=await import("@stacksjs/config"),s3Config=filesystems.s3;return createS3Storage(null,{bucket:s3Config?.bucket||"stacks",prefix:s3Config?.prefix||"stx",region:s3Config?.region||"us-east-1",endpoint:s3Config?.endpoint,usePathStyleEndpoint:s3Config?.usePathStyleEndpoint,credentials:s3Config?.credentials})}catch{const{env}=await import("@stacksjs/env");return createS3Storage(null,{bucket:env.AWS_S3_BUCKET||"stacks",prefix:env.AWS_S3_PREFIX||"stx",region:env.AWS_REGION||"us-east-1",endpoint:env.AWS_ENDPOINT?String(env.AWS_ENDPOINT):void 0,usePathStyleEndpoint:env.AWS_USE_PATH_STYLE_ENDPOINT===!0,credentials:env.AWS_ACCESS_KEY_ID&&env.AWS_SECRET_ACCESS_KEY?{accessKeyId:env.AWS_ACCESS_KEY_ID,secretAccessKey:env.AWS_SECRET_ACCESS_KEY}:void 0})}}async function getAdapter(){if(!_adapterPromise)_adapterPromise=loadConfig();return _adapterPromise}export async function getAwsStorage(){return getAdapter()}export const aws={async write(path,contents){await(await getAdapter()).write(path,contents)},async deleteFile(path){await(await getAdapter()).deleteFile(path)},async createDirectory(path){await(await getAdapter()).createDirectory(path)},async moveFile(from,to){await(await getAdapter()).moveFile(from,to)},async copyFile(from,to){await(await getAdapter()).copyFile(from,to)},async stat(path){return await(await getAdapter()).stat(path)},list(path,options={deep:!1}){return async function*(){yield*(await getAdapter()).list(path,options)}()},async changeVisibility(path,visibility){await(await getAdapter()).changeVisibility(path,visibility)},async visibility(path){return await(await getAdapter()).visibility(path)},async fileExists(path){return await(await getAdapter()).fileExists(path)},async directoryExists(path){return await(await getAdapter()).directoryExists(path)},async publicUrl(path,options){return await(await getAdapter()).publicUrl(path,options)},async temporaryUrl(path,options){return await(await getAdapter()).temporaryUrl(path,options)},async checksum(path,options){return await(await getAdapter()).checksum(path,options)},async mimeType(path,options){return await(await getAdapter()).mimeType(path,options)},async lastModified(path){return await(await getAdapter()).lastModified(path)},async fileSize(path){return await(await getAdapter()).fileSize(path)},async read(path){return await(await getAdapter()).read(path)},async readToString(path){return await(await getAdapter()).readToString(path)},async readToBuffer(path){return await(await getAdapter()).readToBuffer(path)},async readToUint8Array(path){return await(await getAdapter()).readToUint8Array(path)}};
|
|
@@ -39,11 +39,16 @@ export declare function r2Disk(bucket: string, accountId: string, options?: Part
|
|
|
39
39
|
* Helper to create a Hetzner Object Storage disk config (stacksjs/stacks#1897).
|
|
40
40
|
*
|
|
41
41
|
* Hetzner Object Storage exposes an S3-compatible API, so it reuses the `s3`
|
|
42
|
-
* adapter. `location` is the datacenter
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* adapter. `location` is the datacenter, used as both the region and the
|
|
43
|
+
* endpoint host `https://<location>.your-objectstorage.com`. Supply Hetzner S3
|
|
44
|
+
* credentials via `options.credentials` or the AWS_* env vars.
|
|
45
|
+
*
|
|
46
|
+
* Path-style addressing is on by default. Virtual-hosted-style puts the bucket
|
|
47
|
+
* in the hostname, and Hetzner's wildcard certificate covers only one label, so
|
|
48
|
+
* a bucket name containing a dot fails TLS verification. Pass
|
|
49
|
+
* `usePathStyleEndpoint: false` to opt out.
|
|
45
50
|
*/
|
|
46
|
-
export declare function hetznerDisk(bucket: string, location
|
|
51
|
+
export declare function hetznerDisk(bucket: string, location?: HetznerLocation, options?: Partial<Omit<S3DiskConfig, 'driver' | 'bucket'>>): S3DiskConfig;
|
|
47
52
|
/**
|
|
48
53
|
* Create filesystem config from environment variables
|
|
49
54
|
*/
|
|
@@ -167,3 +172,9 @@ export type DiskConfig = LocalDiskConfig | S3DiskConfig;
|
|
|
167
172
|
*/
|
|
168
173
|
// eslint-disable-next-line ts/no-empty-object-type
|
|
169
174
|
export type DiskName = (keyof KnownDisks & string) | (string & {});
|
|
175
|
+
/**
|
|
176
|
+
* Hetzner's object-storage locations, which double as the S3 region name.
|
|
177
|
+
* Kept a union rather than `string` so a typo is a compile error instead of a
|
|
178
|
+
* request to a host that does not resolve.
|
|
179
|
+
*/
|
|
180
|
+
export type HetznerLocation = 'fsn1' | 'nbg1' | 'hel1';
|
package/dist/types/filesystem.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function localDisk(root,options){return{driver:"local",root,visibility:"private",...options}}export function s3Disk(bucket,options){return{driver:"s3",bucket,region:process.env.AWS_DEFAULT_REGION||"us-east-1",visibility:"private",...options}}export function filebaseDisk(bucket,options){return{driver:"s3",bucket,region:"us-east-1",endpoint:"https://s3.filebase.com",visibility:"private",...options}}export function backblazeDisk(bucket,region,options){return{driver:"s3",bucket,region,endpoint:`https://s3.${region}.backblazeb2.com`,visibility:"private",...options}}export function r2Disk(bucket,accountId,options){return{driver:"s3",bucket,region:"auto",endpoint:`https://${accountId}.r2.cloudflarestorage.com`,visibility:"private",...options}}export function hetznerDisk(bucket,location,options){return{driver:"s3",bucket,region:location,endpoint:`https://${location}.your-objectstorage.com`,visibility:"private",...options}}export function configFromEnv(base={}){const env=process.env;return{default:env.FILESYSTEM_DISK||base.default||"local",disks:{...base.disks,...env.AWS_ACCESS_KEY_ID&&env.AWS_BUCKET?{s3:{driver:"s3",bucket:env.AWS_BUCKET,region:env.AWS_DEFAULT_REGION||"us-east-1",endpoint:env.AWS_ENDPOINT,url:env.AWS_URL,usePathStyleEndpoint:env.AWS_USE_PATH_STYLE_ENDPOINT==="true",credentials:{key:env.AWS_ACCESS_KEY_ID,secret:env.AWS_SECRET_ACCESS_KEY||""}}}:{}}}}
|
|
1
|
+
export function localDisk(root,options){return{driver:"local",root,visibility:"private",...options}}export function s3Disk(bucket,options){return{driver:"s3",bucket,region:process.env.AWS_DEFAULT_REGION||"us-east-1",visibility:"private",...options}}export function filebaseDisk(bucket,options){return{driver:"s3",bucket,region:"us-east-1",endpoint:"https://s3.filebase.com",visibility:"private",...options}}export function backblazeDisk(bucket,region,options){return{driver:"s3",bucket,region,endpoint:`https://s3.${region}.backblazeb2.com`,visibility:"private",...options}}export function r2Disk(bucket,accountId,options){return{driver:"s3",bucket,region:"auto",endpoint:`https://${accountId}.r2.cloudflarestorage.com`,visibility:"private",...options}}export function hetznerDisk(bucket,location="fsn1",options){return{driver:"s3",bucket,region:location,endpoint:`https://${location}.your-objectstorage.com`,usePathStyleEndpoint:!0,visibility:"private",...options}}export function configFromEnv(base={}){const env=process.env;return{default:env.FILESYSTEM_DISK||base.default||"local",disks:{...base.disks,...env.AWS_ACCESS_KEY_ID&&env.AWS_BUCKET?{s3:{driver:"s3",bucket:env.AWS_BUCKET,region:env.AWS_DEFAULT_REGION||"us-east-1",endpoint:env.AWS_ENDPOINT,url:env.AWS_URL,usePathStyleEndpoint:env.AWS_USE_PATH_STYLE_ENDPOINT==="true",credentials:{key:env.AWS_ACCESS_KEY_ID,secret:env.AWS_SECRET_ACCESS_KEY||""}}}:{}}}}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/storage",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.328",
|
|
6
6
|
"description": "The Stacks file system.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"ts-images": "^0.2.8"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@stacksjs/arrays": "0.70.
|
|
68
|
+
"@stacksjs/arrays": "0.70.328",
|
|
69
69
|
"better-dx": "^0.2.17",
|
|
70
|
-
"@stacksjs/error-handling": "0.70.
|
|
71
|
-
"@stacksjs/path": "0.70.
|
|
72
|
-
"@stacksjs/strings": "0.70.
|
|
73
|
-
"@stacksjs/types": "0.70.
|
|
70
|
+
"@stacksjs/error-handling": "0.70.328",
|
|
71
|
+
"@stacksjs/path": "0.70.328",
|
|
72
|
+
"@stacksjs/strings": "0.70.328",
|
|
73
|
+
"@stacksjs/types": "0.70.328"
|
|
74
74
|
}
|
|
75
75
|
}
|