@cat-factory/provider-s3 0.2.5 → 0.2.7
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/LICENSE +21 -21
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Igor Savin
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Savin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BinaryBlobBackend } from '@cat-factory/kernel';
|
|
2
|
+
export interface S3BinaryBlobBackendConfig {
|
|
3
|
+
region: string;
|
|
4
|
+
bucket: string;
|
|
5
|
+
/** Optional key prefix, e.g. `artifacts/`. Joined to the artifact's storage key. */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
/** Optional custom endpoint (S3-compatible stores: MinIO, etc.). */
|
|
8
|
+
endpoint?: string;
|
|
9
|
+
/** Force path-style addressing (needed by most S3-compatible stores). */
|
|
10
|
+
forcePathStyle?: boolean;
|
|
11
|
+
/** Explicit credentials; omit to use the default AWS credential chain. */
|
|
12
|
+
credentials?: {
|
|
13
|
+
accessKeyId: string;
|
|
14
|
+
secretAccessKey: string;
|
|
15
|
+
sessionToken?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* AWS S3 (or S3-compatible) blob backend for binary artifacts. Implements the kernel
|
|
20
|
+
* {@link BinaryBlobBackend} port; the metadata still lives in the runtime's DB. Opt-in:
|
|
21
|
+
* a deployment selects it via `BINARY_STORAGE_BACKEND=s3`.
|
|
22
|
+
*
|
|
23
|
+
* The (heavy) `@aws-sdk/client-s3` is imported LAZILY on first use, not at module load:
|
|
24
|
+
* a facade statically imports this class to wire its container, but a deployment that
|
|
25
|
+
* runs the `db` (or no) blob backend then never pays the SDK's load cost — the SDK is
|
|
26
|
+
* only pulled in when an S3 operation actually executes.
|
|
27
|
+
*/
|
|
28
|
+
export declare class S3BinaryBlobBackend implements BinaryBlobBackend {
|
|
29
|
+
private readonly config;
|
|
30
|
+
readonly kind: 's3';
|
|
31
|
+
private readonly bucket;
|
|
32
|
+
private readonly prefix;
|
|
33
|
+
/** Cached, lazily-built `{ sdk, client }` so the AWS SDK loads at most once on first I/O. */
|
|
34
|
+
private clientPromise;
|
|
35
|
+
constructor(config: S3BinaryBlobBackendConfig);
|
|
36
|
+
/** Dynamically import the AWS SDK and build the client (memoised). */
|
|
37
|
+
private resolveClient;
|
|
38
|
+
private fullKey;
|
|
39
|
+
put(key: string, bytes: Uint8Array, contentType: string): Promise<void>;
|
|
40
|
+
get(key: string): Promise<Uint8Array | null>;
|
|
41
|
+
delete(key: string): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,0EAA0E;IAC1E,WAAW,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACtF;AAUD;;;;;;;;;GASG;AACH,qBAAa,mBAAoB,YAAW,iBAAiB;IAO/C,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,QAAQ,CAAC,IAAI,EAAG,IAAI,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,6FAA6F;IAC7F,OAAO,CAAC,aAAa,CAAuD;IAE5E,YAA6B,MAAM,EAAE,yBAAyB,EAG7D;IAED,sEAAsE;YACxD,aAAa;IAc3B,OAAO,CAAC,OAAO;IAIT,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5E;IAEK,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAYjD;IAEK,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvC;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS S3 (or S3-compatible) blob backend for binary artifacts. Implements the kernel
|
|
3
|
+
* {@link BinaryBlobBackend} port; the metadata still lives in the runtime's DB. Opt-in:
|
|
4
|
+
* a deployment selects it via `BINARY_STORAGE_BACKEND=s3`.
|
|
5
|
+
*
|
|
6
|
+
* The (heavy) `@aws-sdk/client-s3` is imported LAZILY on first use, not at module load:
|
|
7
|
+
* a facade statically imports this class to wire its container, but a deployment that
|
|
8
|
+
* runs the `db` (or no) blob backend then never pays the SDK's load cost — the SDK is
|
|
9
|
+
* only pulled in when an S3 operation actually executes.
|
|
10
|
+
*/
|
|
11
|
+
export class S3BinaryBlobBackend {
|
|
12
|
+
config;
|
|
13
|
+
kind = 's3';
|
|
14
|
+
bucket;
|
|
15
|
+
prefix;
|
|
16
|
+
/** Cached, lazily-built `{ sdk, client }` so the AWS SDK loads at most once on first I/O. */
|
|
17
|
+
clientPromise;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.bucket = config.bucket;
|
|
21
|
+
this.prefix = config.prefix ? config.prefix.replace(/\/+$/, '') + '/' : '';
|
|
22
|
+
}
|
|
23
|
+
/** Dynamically import the AWS SDK and build the client (memoised). */
|
|
24
|
+
async resolveClient() {
|
|
25
|
+
if (!this.clientPromise) {
|
|
26
|
+
this.clientPromise = (async () => {
|
|
27
|
+
const sdk = (await import('@aws-sdk/client-s3'));
|
|
28
|
+
const clientConfig = { region: this.config.region };
|
|
29
|
+
if (this.config.endpoint)
|
|
30
|
+
clientConfig.endpoint = this.config.endpoint;
|
|
31
|
+
if (this.config.forcePathStyle)
|
|
32
|
+
clientConfig.forcePathStyle = this.config.forcePathStyle;
|
|
33
|
+
if (this.config.credentials)
|
|
34
|
+
clientConfig.credentials = this.config.credentials;
|
|
35
|
+
return { sdk, client: new sdk.S3Client(clientConfig) };
|
|
36
|
+
})();
|
|
37
|
+
}
|
|
38
|
+
return this.clientPromise;
|
|
39
|
+
}
|
|
40
|
+
fullKey(key) {
|
|
41
|
+
return `${this.prefix}${key}`;
|
|
42
|
+
}
|
|
43
|
+
async put(key, bytes, contentType) {
|
|
44
|
+
const { sdk, client } = await this.resolveClient();
|
|
45
|
+
await client.send(new sdk.PutObjectCommand({
|
|
46
|
+
Bucket: this.bucket,
|
|
47
|
+
Key: this.fullKey(key),
|
|
48
|
+
Body: bytes,
|
|
49
|
+
ContentType: contentType,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
async get(key) {
|
|
53
|
+
const { sdk, client } = await this.resolveClient();
|
|
54
|
+
try {
|
|
55
|
+
const out = await client.send(new sdk.GetObjectCommand({ Bucket: this.bucket, Key: this.fullKey(key) }));
|
|
56
|
+
if (!out.Body)
|
|
57
|
+
return null;
|
|
58
|
+
return new Uint8Array(await out.Body.transformToByteArray());
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error.name === 'NoSuchKey')
|
|
62
|
+
return null;
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async delete(key) {
|
|
67
|
+
const { sdk, client } = await this.resolveClient();
|
|
68
|
+
await client.send(new sdk.DeleteObjectCommand({ Bucket: this.bucket, Key: this.fullKey(key) }));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAmB;IAOD,MAAM;IAN1B,IAAI,GAAG,IAAa,CAAA;IACZ,MAAM,CAAQ;IACd,MAAM,CAAQ;IAC/B,6FAA6F;IACrF,aAAa,CAAuD;IAE5E,YAA6B,MAAiC;sBAAjC,MAAM;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5E,CAAC;IAED,sEAAsE;IAC9D,KAAK,CAAC,aAAa;QACzB,IAAI,CAAC,IAAI,CAAC,aAAa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,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;QAClD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAC3B,IAAI,GAAG,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAC1E,CAAA;YACD,IAAI,CAAC,GAAG,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAA;YAC1B,OAAO,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAA;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAK,KAA2B,CAAC,IAAI,KAAK,WAAW;gBAAE,OAAO,IAAI,CAAA;YAClE,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;QAClD,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IACjG,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/provider-s3",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Opt-in AWS S3 blob backend for the Agent Architecture Board's binary-artifact storage abstraction. Implements the kernel BinaryBlobBackend port over an S3 bucket.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@aws-sdk/client-s3": "^3.700.0",
|
|
28
|
-
"@cat-factory/kernel": "0.45.
|
|
28
|
+
"@cat-factory/kernel": "0.45.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "7.0.1-rc"
|