@superfunctions/storage-r2 0.1.0

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.
@@ -0,0 +1,10 @@
1
+ import type { StorageAdapter } from '@superfunctions/storage';
2
+ export interface R2StorageConfig {
3
+ accountId: string;
4
+ bucket: string;
5
+ accessKeyId: string;
6
+ secretAccessKey: string;
7
+ jurisdiction?: 'eu' | 'fedramp';
8
+ }
9
+ export declare function createR2StorageAdapter(config: R2StorageConfig): StorageAdapter;
10
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAuB9E"}
@@ -0,0 +1,24 @@
1
+ import { S3Client } from '@aws-sdk/client-s3';
2
+ import { createS3CompatibleStorageAdapter } from '@superfunctions/storage/internal/s3-compatible';
3
+ export function createR2StorageAdapter(config) {
4
+ const { accountId, bucket, accessKeyId, secretAccessKey, jurisdiction } = config;
5
+ const endpoint = jurisdiction
6
+ ? `https://${accountId}.${jurisdiction}.r2.cloudflarestorage.com`
7
+ : `https://${accountId}.r2.cloudflarestorage.com`;
8
+ const client = new S3Client({
9
+ region: 'auto',
10
+ endpoint,
11
+ credentials: {
12
+ accessKeyId,
13
+ secretAccessKey,
14
+ },
15
+ });
16
+ return createS3CompatibleStorageAdapter({
17
+ name: 'r2',
18
+ bucket,
19
+ client,
20
+ statNotFoundErrorNames: ['NotFound'],
21
+ downloadNotFoundErrorNames: ['NoSuchKey'],
22
+ });
23
+ }
24
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAWlG,MAAM,UAAU,sBAAsB,CAAC,MAAuB;IAC5D,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAEjF,MAAM,QAAQ,GAAG,YAAY;QAC3B,CAAC,CAAC,WAAW,SAAS,IAAI,YAAY,2BAA2B;QACjE,CAAC,CAAC,WAAW,SAAS,2BAA2B,CAAC;IAEpD,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC;QAC1B,MAAM,EAAE,MAAM;QACd,QAAQ;QACR,WAAW,EAAE;YACX,WAAW;YACX,eAAe;SAChB;KACF,CAAC,CAAC;IAEH,OAAO,gCAAgC,CAAC;QACtC,IAAI,EAAE,IAAI;QACV,MAAM;QACN,MAAM;QACN,sBAAsB,EAAE,CAAC,UAAU,CAAC;QACpC,0BAA0B,EAAE,CAAC,WAAW,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { createR2StorageAdapter, type R2StorageConfig } from './adapter.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createR2StorageAdapter } from './adapter.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAwB,MAAM,cAAc,CAAC"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@superfunctions/storage-r2",
3
+ "version": "0.1.0",
4
+ "description": "Cloudflare R2 storage adapter for @superfunctions/storage",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "test": "vitest",
18
+ "typecheck": "tsc --noEmit",
19
+ "clean": "rm -rf dist"
20
+ },
21
+ "keywords": ["storage", "r2", "cloudflare", "superfunctions"],
22
+ "author": "21n",
23
+ "license": "MIT",
24
+ "bugs": { "url": "https://github.com/21nCo/super-functions/issues" },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/21nCo/super-functions.git",
28
+ "directory": "packages/storage-r2"
29
+ },
30
+ "publishConfig": { "access": "public" },
31
+ "dependencies": {
32
+ "@aws-sdk/client-s3": "^3.600.0",
33
+ "@aws-sdk/s3-request-presigner": "^3.600.0",
34
+ "@superfunctions/storage": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.0.0",
38
+ "typescript": "^5.6.0",
39
+ "vitest": "^3.2.4"
40
+ }
41
+ }