ag-common 0.0.735 → 0.0.737
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/api/helpers/s3.d.ts +7 -4
- package/dist/api/helpers/s3.js +13 -5
- package/package.json +3 -3
package/dist/api/helpers/s3.d.ts
CHANGED
|
@@ -2,12 +2,15 @@ import { S3Client } from '@aws-sdk/client-s3';
|
|
|
2
2
|
import type { StreamingBlobPayloadOutputTypes } from '@smithy/types';
|
|
3
3
|
import type { Buffer } from 'buffer';
|
|
4
4
|
export type StorageProvider = 's3' | 'r2';
|
|
5
|
-
export
|
|
6
|
-
provider:
|
|
7
|
-
region
|
|
5
|
+
export type StorageConfig = {
|
|
6
|
+
provider: 's3';
|
|
7
|
+
region?: string;
|
|
8
8
|
endpoint?: string;
|
|
9
9
|
accountId?: string;
|
|
10
|
-
}
|
|
10
|
+
} | {
|
|
11
|
+
provider: 'r2';
|
|
12
|
+
accountId: string;
|
|
13
|
+
};
|
|
11
14
|
export declare const createStorageClient: (config: StorageConfig) => S3Client;
|
|
12
15
|
export declare const setS3: (config: StorageConfig) => S3Client;
|
|
13
16
|
export declare const s3: S3Client;
|
package/dist/api/helpers/s3.js
CHANGED
|
@@ -34,6 +34,12 @@ const object_1 = require("../../common/helpers/object");
|
|
|
34
34
|
// Cache for memoization
|
|
35
35
|
const clientCache = new Map();
|
|
36
36
|
const getCacheKey = (config) => {
|
|
37
|
+
if (config.provider === 'r2') {
|
|
38
|
+
return JSON.stringify({
|
|
39
|
+
provider: config.provider,
|
|
40
|
+
accountId: config.accountId,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
37
43
|
return JSON.stringify({
|
|
38
44
|
provider: config.provider,
|
|
39
45
|
region: config.region,
|
|
@@ -47,19 +53,21 @@ const createStorageClient = (config) => {
|
|
|
47
53
|
if (cachedClient) {
|
|
48
54
|
return cachedClient;
|
|
49
55
|
}
|
|
50
|
-
const baseConfig = {
|
|
51
|
-
region: config.region,
|
|
52
|
-
};
|
|
53
56
|
let client;
|
|
54
57
|
if (config.provider === 'r2') {
|
|
55
58
|
const accountId = config.accountId || process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
56
59
|
if (!accountId) {
|
|
57
60
|
throw new Error('Account ID is required for R2. Set CLOUDFLARE_ACCOUNT_ID env var or provide accountId in config');
|
|
58
61
|
}
|
|
59
|
-
client = new client_s3_1.S3Client(
|
|
62
|
+
client = new client_s3_1.S3Client({
|
|
63
|
+
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
|
|
64
|
+
forcePathStyle: true,
|
|
65
|
+
});
|
|
60
66
|
}
|
|
61
67
|
else {
|
|
62
|
-
client = new client_s3_1.S3Client(
|
|
68
|
+
client = new client_s3_1.S3Client({
|
|
69
|
+
region: config.region,
|
|
70
|
+
});
|
|
63
71
|
}
|
|
64
72
|
clientCache.set(cacheKey, client);
|
|
65
73
|
return client;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.737",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@emotion/styled": "^11.14.0",
|
|
47
47
|
"@smithy/types": "^4.2.0",
|
|
48
48
|
"@storybook/addon-actions": "^8.6.12",
|
|
49
|
-
"@storybook/addon-docs": "8.
|
|
49
|
+
"@storybook/addon-docs": "8.6.12",
|
|
50
50
|
"@storybook/addon-essentials": "^8.6.12",
|
|
51
51
|
"@storybook/addon-interactions": "^8.6.12",
|
|
52
52
|
"@storybook/addon-links": "^8.6.12",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"tsx": "^4.19.3"
|
|
71
71
|
},
|
|
72
72
|
"resolutions": {
|
|
73
|
-
"globals": "15.
|
|
73
|
+
"globals": "15.15.0"
|
|
74
74
|
},
|
|
75
75
|
"files": [
|
|
76
76
|
"dist/**/*",
|