effect-cloudflare-r2-layer 1.0.16 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/cjs/layer/file-storage.layer.js +1 -1
- package/cjs/layer/file-storage.layer.js.map +1 -1
- package/cjs/r2/implementations/bucket-infos.effect.js +2 -2
- package/cjs/r2/implementations/bucket-infos.effect.js.map +1 -1
- package/cjs/r2/implementations/create-bucket.effect.js +2 -2
- package/cjs/r2/implementations/create-bucket.effect.js.map +1 -1
- package/cjs/r2/implementations/get-file-url.effect.js +1 -1
- package/cjs/r2/implementations/get-file-url.effect.js.map +1 -1
- package/cjs/r2/implementations/internal/fetch-file.effect.js +1 -1
- package/cjs/r2/implementations/internal/fetch-file.effect.js.map +1 -1
- package/cjs/r2/implementations/internal/get-url.effect.js +1 -1
- package/cjs/r2/implementations/internal/get-url.effect.js.map +1 -1
- package/cjs/r2/implementations/upload-file.effect.js +2 -2
- package/cjs/r2/implementations/upload-file.effect.js.map +1 -1
- package/cjs/r2/r2-file-storage.layer.js +1 -1
- package/cjs/r2/r2-file-storage.layer.js.map +1 -1
- package/dts/{cjs/layer → layer}/file-storage.layer.d.ts +9 -9
- package/dts/{cjs/r2 → r2}/implementations/bucket-infos.effect.d.ts +1 -1
- package/dts/{esm/r2 → r2}/implementations/create-bucket.effect.d.ts +1 -1
- package/dts/{esm/r2 → r2}/implementations/internal/fetch-file.effect.d.ts +1 -1
- package/dts/{cjs/r2 → r2}/implementations/internal/get-url.effect.d.ts +1 -1
- package/dts/{cjs/r2 → r2}/implementations/read-as-json.effect.d.ts +1 -1
- package/dts/{cjs/r2 → r2}/implementations/read-as-raw-binary.effect.d.ts +1 -1
- package/dts/{cjs/r2 → r2}/implementations/read-as-text.effect.d.ts +1 -1
- package/dts/{cjs/r2 → r2}/implementations/upload-file.effect.d.ts +1 -1
- package/esm/layer/file-storage.layer.js +1 -1
- package/esm/layer/file-storage.layer.js.map +1 -1
- package/esm/r2/implementations/bucket-infos.effect.js +2 -2
- package/esm/r2/implementations/bucket-infos.effect.js.map +1 -1
- package/esm/r2/implementations/create-bucket.effect.js +2 -2
- package/esm/r2/implementations/create-bucket.effect.js.map +1 -1
- package/esm/r2/implementations/get-file-url.effect.js +1 -1
- package/esm/r2/implementations/get-file-url.effect.js.map +1 -1
- package/esm/r2/implementations/internal/fetch-file.effect.js +1 -1
- package/esm/r2/implementations/internal/fetch-file.effect.js.map +1 -1
- package/esm/r2/implementations/internal/get-url.effect.js +1 -1
- package/esm/r2/implementations/internal/get-url.effect.js.map +1 -1
- package/esm/r2/implementations/upload-file.effect.js +2 -2
- package/esm/r2/implementations/upload-file.effect.js.map +1 -1
- package/esm/r2/r2-file-storage.layer.js +1 -1
- package/esm/r2/r2-file-storage.layer.js.map +1 -1
- package/package.json +22 -13
- package/dts/cjs/r2/implementations/create-bucket.effect.d.ts +0 -4
- package/dts/cjs/r2/implementations/internal/fetch-file.effect.d.ts +0 -3
- package/dts/esm/effects/index.d.ts +0 -1
- package/dts/esm/effects/tapLayer.effect.d.ts +0 -3
- package/dts/esm/errors/bucket-not-found.d.ts +0 -9
- package/dts/esm/errors/file-storage.error.d.ts +0 -9
- package/dts/esm/errors/index.d.ts +0 -2
- package/dts/esm/index.d.ts +0 -7
- package/dts/esm/layer/file-storage.layer.d.ts +0 -27
- package/dts/esm/r2/implementations/bucket-infos.effect.d.ts +0 -12
- package/dts/esm/r2/implementations/get-file-url.effect.d.ts +0 -2
- package/dts/esm/r2/implementations/index.d.ts +0 -7
- package/dts/esm/r2/implementations/internal/get-url.effect.d.ts +0 -4
- package/dts/esm/r2/implementations/internal/index.d.ts +0 -2
- package/dts/esm/r2/implementations/read-as-json.effect.d.ts +0 -2
- package/dts/esm/r2/implementations/read-as-raw-binary.effect.d.ts +0 -2
- package/dts/esm/r2/implementations/read-as-text.effect.d.ts +0 -2
- package/dts/esm/r2/implementations/upload-file.effect.d.ts +0 -9
- package/dts/esm/r2/providers/r2-file-storage.provider.d.ts +0 -3
- package/dts/esm/r2/r2-file-storage.layer.d.ts +0 -2
- /package/dts/{cjs/effects → effects}/index.d.ts +0 -0
- /package/dts/{cjs/effects → effects}/tapLayer.effect.d.ts +0 -0
- /package/dts/{cjs/errors → errors}/bucket-not-found.d.ts +0 -0
- /package/dts/{cjs/errors → errors}/file-storage.error.d.ts +0 -0
- /package/dts/{cjs/errors → errors}/index.d.ts +0 -0
- /package/dts/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dts/{cjs/r2 → r2}/implementations/get-file-url.effect.d.ts +0 -0
- /package/dts/{cjs/r2 → r2}/implementations/index.d.ts +0 -0
- /package/dts/{cjs/r2 → r2}/implementations/internal/index.d.ts +0 -0
- /package/dts/{cjs/r2 → r2}/providers/r2-file-storage.provider.d.ts +0 -0
- /package/dts/{cjs/r2 → r2}/r2-file-storage.layer.d.ts +0 -0
package/README.md
CHANGED
@@ -4,7 +4,7 @@ An effect layer to interact with Cloudware R2 storage service.
|
|
4
4
|
|
5
5
|
<!-- readme-package-icons start -->
|
6
6
|
|
7
|
-
<p align="left"><a href="https://docs.github.com/en/actions" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg" /></a> <a href="https://www.typescriptlang.org/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg" /></a> <a href="https://nodejs.org/en/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg" /></a> <a href="https://bun.sh/docs" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Bun-Dark.svg" /></a> <a href="https://aws.amazon.com/developer/language/javascript/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/AWS-Dark.svg" /></a> <a href="https://biomejs.dev/guides/getting-started/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Biome-Dark.svg" /></a> <a href="https://github.com/motdotla/dotenv#readme" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Dotenv-Dark.svg" /></a> <a href="https://www.effect.website/docs/quickstart" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Effect-Dark.svg" /></a></p>
|
7
|
+
<p align="left"><a href="https://docs.github.com/en/actions" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg" /></a> <a href="https://www.typescriptlang.org/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg" /></a> <a href="https://nodejs.org/en/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg" /></a> <a href="https://bun.sh/docs" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Bun-Dark.svg" /></a> <a href="https://aws.amazon.com/developer/language/javascript/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/AWS-Dark.svg" /></a> <a href="https://biomejs.dev/guides/getting-started/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Biome-Dark.svg" /></a> <a href="https://github.com/motdotla/dotenv#readme" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Dotenv-Dark.svg" /></a> <a href="https://vitest.dev/guide/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Vitest-Dark.svg" /></a> <a href="https://www.effect.website/docs/quickstart" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Effect-Dark.svg" /></a></p>
|
8
8
|
|
9
9
|
<!-- readme-package-icons end -->
|
10
10
|
|
@@ -259,7 +259,7 @@ type readAsJson = <
|
|
259
259
|
) => Effect.Effect<
|
260
260
|
TShape,
|
261
261
|
HttpClientError | FileStorageError | ConfigError.ConfigError,
|
262
|
-
Scope | HttpClient
|
262
|
+
FileStorage | Scope | HttpClient<HttpClientError, Scope>
|
263
263
|
>;
|
264
264
|
```
|
265
265
|
|
@@ -310,7 +310,7 @@ readAsText: <TBucket extends string>(
|
|
310
310
|
Effect.Effect<
|
311
311
|
string,
|
312
312
|
ConfigError | HttpClientError | FileStorageError,
|
313
|
-
Scope | HttpClient
|
313
|
+
FileStorage | Scope | HttpClient<HttpClientError, Scope>
|
314
314
|
>;
|
315
315
|
```
|
316
316
|
|
@@ -356,7 +356,7 @@ readAsRawBinary: <TBucket extends string>(
|
|
356
356
|
Effect.Effect<
|
357
357
|
ArrayBuffer,
|
358
358
|
ConfigError | HttpClientError | FileStorageError,
|
359
|
-
Scope | HttpClient
|
359
|
+
FileStorage | Scope | HttpClient<HttpClientError, Scope>
|
360
360
|
>;
|
361
361
|
```
|
362
362
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.FileStorageLayer = exports.FileStorageLayerContext = void 0;
|
4
4
|
const effect_1 = require("effect");
|
5
|
-
const _effects_1 = require("
|
5
|
+
const _effects_1 = require("./../effects/index.js");
|
6
6
|
exports.FileStorageLayerContext = effect_1.Context.GenericTag('file-storage');
|
7
7
|
exports.FileStorageLayer = {
|
8
8
|
createBucket: (input) => (0, _effects_1.tapLayer)(exports.FileStorageLayerContext, ({ createBucket }) => createBucket(input)),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":";;;AAEA,mCAAiC;AAUjC,
|
1
|
+
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":";;;AAEA,mCAAiC;AAUjC,uCAAoC;AAkEvB,QAAA,uBAAuB,GAClC,gBAAO,CAAC,UAAU,CAAc,cAAc,CAAC,CAAC;AAErC,QAAA,gBAAgB,GAAG;IAC9B,YAAY,EAAE,CAAC,KAA+B,EAAE,EAAE,CAChD,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CACrD,YAAY,CAAC,KAAK,CAAC,CACpB;IACH,WAAW,EAAE,CAAyB,KAAgC,EAAE,EAAE,CACxE,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5E,UAAU,EAAE,CAAyB,MAAe,EAAE,QAAgB,EAAE,EAAE,CACxE,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC7B;IACH,eAAe,EAAE,CACf,MAAe,EACf,QAAgB,EAChB,EAAE,CACF,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CACxD,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAClC;IACH,UAAU,EAAE,CACV,MAAe,EACf,QAAgB,EAChB,EAAE,CACF,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAkB,MAAM,EAAE,QAAQ,CAAC,CAC9C;IACH,UAAU,EAAE,CAAyB,MAAe,EAAE,QAAgB,EAAE,EAAE,CACxE,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC7B;IACH,UAAU,EAAE,CAAyB,KAA+B,EAAE,EAAE,CACtE,IAAA,mBAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;CAC3E,CAAC"}
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bucketInfos = void 0;
|
4
4
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
5
5
|
const effect_1 = require("effect");
|
6
|
-
const _errors_1 = require("
|
7
|
-
const _provider_1 = require("
|
6
|
+
const _errors_1 = require("./../../errors/index.js");
|
7
|
+
const _provider_1 = require("./../providers/r2-file-storage.provider.js");
|
8
8
|
const hasName = (error) => {
|
9
9
|
return error?.name !== undefined;
|
10
10
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bucket-infos.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/bucket-infos.effect.ts"],"names":[],"mappings":";;;AAAA,kDAAuD;AACvD,mCAAsC;AAEtC,
|
1
|
+
{"version":3,"file":"bucket-infos.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/bucket-infos.effect.ts"],"names":[],"mappings":";;;AAAA,kDAAuD;AACvD,mCAAsC;AAEtC,qCAAgE;AAChE,yCAAwD;AAIxD,MAAM,OAAO,GAAG,CAAC,KAAc,EAAoC,EAAE;IACnE,OAAQ,KAAuB,EAAE,IAAI,KAAK,SAAS,CAAC;AACtD,CAAC,CAAC;AAWK,MAAM,WAAW,GAAG,CACzB,KAAgC,EAChC,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAC3D,IAAA,aAAI,EACF,uCAA2B,EAC3B,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,eAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,6BAAiB,CAAC,KAAK,CAAC,CAAC;IACtD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;QACX,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACxC,OAAO,IAAI,6BAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,0BAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF,CAAC,CACH,EACD,eAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC,YAAY;CAC9B,CAAC,CAAC,CACJ,CACF,CAAC;AAtBS,QAAA,WAAW,eAsBpB"}
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBucket = void 0;
|
4
4
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
5
5
|
const effect_1 = require("effect");
|
6
|
-
const _errors_1 = require("
|
7
|
-
const _provider_1 = require("
|
6
|
+
const _errors_1 = require("./../../errors/index.js");
|
7
|
+
const _provider_1 = require("./../providers/r2-file-storage.provider.js");
|
8
8
|
const createBucket = (input) => effect_1.Effect.withSpan('create-bucket', { attributes: { ...input } })((0, effect_1.pipe)(_provider_1.cloudflareR2StorageProvider, effect_1.Effect.flatMap((provider) => effect_1.Effect.tryPromise({
|
9
9
|
try: () => provider.send(new client_s3_1.CreateBucketCommand(input)),
|
10
10
|
catch: (e) => new _errors_1.FileStorageError({ cause: e }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-bucket.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/create-bucket.effect.ts"],"names":[],"mappings":";;;AAAA,kDAG4B;AAC5B,mCAAsC;AAEtC,
|
1
|
+
{"version":3,"file":"create-bucket.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/create-bucket.effect.ts"],"names":[],"mappings":";;;AAAA,kDAG4B;AAC5B,mCAAsC;AAEtC,qCAA2C;AAC3C,yCAAwD;AAEjD,MAAM,YAAY,GAAG,CAAC,KAA+B,EAAE,EAAE,CAC9D,eAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAC5D,IAAA,aAAI,EACF,uCAA2B,EAC3B,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,eAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,+BAAmB,CAAC,KAAK,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,0BAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CACF,CACF,CAAC;AAXS,QAAA,YAAY,gBAWrB"}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getFileUrl = void 0;
|
4
4
|
const effect_1 = require("effect");
|
5
|
-
const _provider_1 = require("
|
5
|
+
const _provider_1 = require("./../providers/r2-file-storage.provider.js");
|
6
6
|
const index_js_1 = require("./internal/index.js");
|
7
7
|
const getFileUrl = (bucketName, documentKey) => effect_1.Effect.withSpan('get-file-url', { attributes: { bucketName, documentKey } })((0, effect_1.pipe)(_provider_1.cloudflareR2StorageProvider, effect_1.Effect.flatMap((provider) => (0, index_js_1.getUrl)(provider, bucketName, documentKey))));
|
8
8
|
exports.getFileUrl = getFileUrl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-file-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-file-url.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,
|
1
|
+
{"version":3,"file":"get-file-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-file-url.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,yCAAwD;AAExD,kDAA6C;AAEtC,MAAM,UAAU,GAAG,CACxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CAC1E,IAAA,aAAI,EACF,uCAA2B,EAC3B,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,iBAAM,EAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CACxE,CACF,CAAC;AATS,QAAA,UAAU,cASnB"}
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchFile = void 0;
|
4
4
|
const platform_1 = require("@effect/platform");
|
5
5
|
const effect_1 = require("effect");
|
6
|
-
const _provider_1 = require("
|
6
|
+
const _provider_1 = require("./../../providers/r2-file-storage.provider.js");
|
7
7
|
const get_url_effect_js_1 = require("./get-url.effect.js");
|
8
8
|
const fetchFile = (bucketName, documentKey) => effect_1.Effect.gen(function* () {
|
9
9
|
const provider = yield* _provider_1.cloudflareR2StorageProvider;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch-file.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/fetch-file.effect.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAC9C,mCAAgC;AAEhC,
|
1
|
+
{"version":3,"file":"fetch-file.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/fetch-file.effect.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAC9C,mCAAgC;AAEhC,yCAAwD;AAExD,2DAA6C;AAEtC,MAAM,SAAS,GAAG,CAAC,UAAkB,EAAE,WAAmB,EAAE,EAAE,CACnE,eAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,uCAA2B,CAAC;IACpD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,IAAA,0BAAM,EAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAE7D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,qBAAU,CAAC,UAAU,CAAC;IAC5C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC;AAPQ,QAAA,SAAS,aAOjB"}
|
@@ -4,7 +4,7 @@ exports.getUrl = void 0;
|
|
4
4
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
5
5
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
6
6
|
const effect_1 = require("effect");
|
7
|
-
const _errors_1 = require("
|
7
|
+
const _errors_1 = require("./../../../errors/index.js");
|
8
8
|
const oneHourDuration = 60 * 60;
|
9
9
|
const getUrl = (provider, bucketName, documentKey) => effect_1.Effect.withSpan('get-url', { attributes: { bucketName, documentKey } })(effect_1.Effect.tryPromise({
|
10
10
|
try: () => (0, s3_request_presigner_1.getSignedUrl)(provider, new client_s3_1.GetObjectCommand({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/get-url.effect.ts"],"names":[],"mappings":";;;AACA,kDAAsD;AACtD,wEAAgF;AAChF,mCAAgC;AAEhC,
|
1
|
+
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/get-url.effect.ts"],"names":[],"mappings":";;;AACA,kDAAsD;AACtD,wEAAgF;AAChF,mCAAgC;AAEhC,qCAA2C;AAE3C,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,GAAG,CACpB,QAAkB,EAClB,UAAmB,EACnB,WAAoB,EACpB,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CACrE,eAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CACR,IAAA,mCAAe,EACb,QAAQ,EACR,IAAI,4BAAgB,CAAC;QACnB,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,WAAW;KACjB,CAAC,EACF;QACE,SAAS,EAAE,eAAe;KAC3B,CACF;IACH,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,0BAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CAAC;AApBS,QAAA,MAAM,UAoBf"}
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uploadFile = void 0;
|
4
4
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
5
5
|
const effect_1 = require("effect");
|
6
|
-
const _errors_1 = require("
|
7
|
-
const _provider_1 = require("
|
6
|
+
const _errors_1 = require("./../../errors/index.js");
|
7
|
+
const _provider_1 = require("./../providers/r2-file-storage.provider.js");
|
8
8
|
const uploadFile = ({ bucketName, documentKey, data, contentType, }) => effect_1.Effect.withSpan('upload-file', {
|
9
9
|
attributes: { bucketName, documentKey, contentType },
|
10
10
|
})((0, effect_1.pipe)(_provider_1.cloudflareR2StorageProvider, effect_1.Effect.flatMap((provider) => effect_1.Effect.tryPromise({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"upload-file.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/upload-file.effect.ts"],"names":[],"mappings":";;;AAAA,kDAAsD;AACtD,mCAAsC;AAEtC,
|
1
|
+
{"version":3,"file":"upload-file.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/upload-file.effect.ts"],"names":[],"mappings":";;;AAAA,kDAAsD;AACtD,mCAAsC;AAEtC,qCAA2C;AAC3C,yCAAwD;AASjD,MAAM,UAAU,GAAG,CAAyB,EACjD,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,GACc,EAAE,EAAE,CAC7B,eAAM,CAAC,QAAQ,CAAC,aAAa,EAAE;IAC7B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE;CACrD,CAAC,CACA,IAAA,aAAI,EACF,uCAA2B,EAC3B,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,eAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CACR,QAAQ,CAAC,IAAI,CACX,IAAI,4BAAgB,CAAC;QACnB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,WAAqB;QAClC,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,UAAU;KACnB,CAAC,CACH;IACH,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,0BAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CACF,CACF,CAAC;AA1BS,QAAA,UAAU,cA0BnB"}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.CloudflareR2StorageLayerLive = void 0;
|
4
4
|
const effect_1 = require("effect");
|
5
|
-
const _implementation_1 = require("./implementations");
|
5
|
+
const _implementation_1 = require("./implementations/index.js");
|
6
6
|
const file_storage_layer_js_1 = require("../layer/file-storage.layer.js");
|
7
7
|
exports.CloudflareR2StorageLayerLive = effect_1.Layer.succeed(file_storage_layer_js_1.FileStorageLayerContext, file_storage_layer_js_1.FileStorageLayerContext.of({
|
8
8
|
createBucket: _implementation_1.createBucket,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"r2-file-storage.layer.js","sourceRoot":"","sources":["../../../src/r2/r2-file-storage.layer.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,
|
1
|
+
{"version":3,"file":"r2-file-storage.layer.js","sourceRoot":"","sources":["../../../src/r2/r2-file-storage.layer.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,qDAQyB;AAEzB,0EAAyE;AAE5D,QAAA,4BAA4B,GAAG,cAAK,CAAC,OAAO,CACvD,+CAAuB,EACvB,+CAAuB,CAAC,EAAE,CAAC;IACzB,YAAY,EAAZ,8BAAY;IACZ,WAAW,EAAX,6BAAW;IACX,UAAU,EAAV,4BAAU;IACV,UAAU,EAAV,4BAAU;IACV,UAAU,EAAV,4BAAU;IACV,UAAU,EAAV,4BAAU;IACV,eAAe,EAAf,iCAAe;CAChB,CAAC,CACH,CAAC"}
|
@@ -2,17 +2,17 @@ import { HttpClientError } from '@effect/platform/HttpClientError';
|
|
2
2
|
import type { ConfigError, Effect } from 'effect';
|
3
3
|
import { Context } from 'effect';
|
4
4
|
import { CreateBucketCommandInput, CreateBucketCommandOutput, PutObjectCommandOutput } from '@aws-sdk/client-s3';
|
5
|
-
import { HttpClient } from '@effect/platform';
|
5
|
+
import { HttpClient } from '@effect/platform/HttpClient';
|
6
6
|
import { Scope } from 'effect/Scope';
|
7
|
-
import type { BucketNotFoundError, FileStorageError } from
|
8
|
-
import type { BucketInfosInput, BucketInfosResult, UploadFileInput } from
|
7
|
+
import type { BucketNotFoundError, FileStorageError } from './../errors/index.js';
|
8
|
+
import type { BucketInfosInput, BucketInfosResult, UploadFileInput } from './../r2/implementations/index.js';
|
9
9
|
export interface FileStorage {
|
10
10
|
readonly createBucket: (input: CreateBucketCommandInput) => Effect.Effect<CreateBucketCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
11
11
|
readonly bucketInfos: <TBucket extends string>(input: BucketInfosInput<TBucket>) => Effect.Effect<BucketInfosResult, ConfigError.ConfigError | FileStorageError | BucketNotFoundError, never>;
|
12
12
|
readonly getFileUrl: <TBucket extends string>(fileName: string, bucket: TBucket) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError>;
|
13
|
-
readonly readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope |
|
14
|
-
readonly readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope |
|
15
|
-
readonly readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope |
|
13
|
+
readonly readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, ConfigError.ConfigError | HttpClientError | FileStorageError, HttpClient<HttpClientError, Scope> | Scope>;
|
14
|
+
readonly readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, ConfigError.ConfigError | HttpClientError | FileStorageError, HttpClient<HttpClientError, Scope> | Scope>;
|
15
|
+
readonly readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, ConfigError.ConfigError | HttpClientError | FileStorageError, HttpClient<HttpClientError, Scope> | Scope>;
|
16
16
|
readonly uploadFile: <TBucket extends string>({ bucketName, documentKey, data, contentType, }: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
17
17
|
}
|
18
18
|
export declare const FileStorageLayerContext: Context.Tag<FileStorage, FileStorage>;
|
@@ -20,8 +20,8 @@ export declare const FileStorageLayer: {
|
|
20
20
|
createBucket: (input: CreateBucketCommandInput) => Effect.Effect<CreateBucketCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
21
21
|
bucketInfos: <TBucket extends string>(input: BucketInfosInput<TBucket>) => Effect.Effect<BucketInfosResult, BucketNotFoundError | FileStorageError | ConfigError.ConfigError, FileStorage>;
|
22
22
|
getFileUrl: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
23
|
-
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient
|
24
|
-
readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucket: TBucket, fileName: string) => Effect.Effect<TShape, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient
|
25
|
-
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient
|
23
|
+
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient<HttpClientError, Scope> | FileStorage>;
|
24
|
+
readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucket: TBucket, fileName: string) => Effect.Effect<TShape, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient<HttpClientError, Scope> | FileStorage>;
|
25
|
+
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient<HttpClientError, Scope> | FileStorage>;
|
26
26
|
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
27
27
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Effect } from 'effect';
|
2
|
-
import { BucketNotFoundError, FileStorageError } from
|
2
|
+
import { BucketNotFoundError, FileStorageError } from './../../errors/index.js';
|
3
3
|
export type BucketInfosInput<TBucket extends string> = {
|
4
4
|
Bucket: TBucket;
|
5
5
|
ExpectedBucketOwner?: string;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { CreateBucketCommandInput } from '@aws-sdk/client-s3';
|
2
2
|
import { Effect } from 'effect';
|
3
|
-
import { FileStorageError } from
|
3
|
+
import { FileStorageError } from './../../errors/index.js';
|
4
4
|
export declare const createBucket: (input: CreateBucketCommandInput) => Effect.Effect<import("@aws-sdk/client-s3").CreateBucketCommandOutput, FileStorageError | import("effect/ConfigError").ConfigError, never>;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { HttpClient } from '@effect/platform';
|
2
2
|
import { Effect } from 'effect';
|
3
|
-
export declare const fetchFile: (bucketName: string, documentKey: string) => Effect.Effect<import("@effect/platform/HttpClientResponse").HttpClientResponse, import("../../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | HttpClient.HttpClient.
|
3
|
+
export declare const fetchFile: (bucketName: string, documentKey: string) => Effect.Effect<import("@effect/platform/HttpClientResponse").HttpClientResponse, import("../../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | HttpClient.HttpClient<import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope>>;
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { S3Client } from '@aws-sdk/client-s3';
|
2
2
|
import { Effect } from 'effect';
|
3
|
-
import { FileStorageError } from
|
3
|
+
import { FileStorageError } from './../../../errors/index.js';
|
4
4
|
export declare const getUrl: <TBucket extends string>(provider: S3Client, bucketName: TBucket, documentKey: TBucket) => Effect.Effect<string, FileStorageError, never>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Effect } from 'effect';
|
2
|
-
export declare const readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.
|
2
|
+
export declare const readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient<import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope>>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Effect } from 'effect';
|
2
|
-
export declare const readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.
|
2
|
+
export declare const readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient<import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope>>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Effect } from 'effect';
|
2
|
-
export declare const readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.
|
2
|
+
export declare const readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient<import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope>>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Context } from 'effect';
|
2
|
-
import { tapLayer } from
|
2
|
+
import { tapLayer } from './../effects/index.js';
|
3
3
|
export const FileStorageLayerContext = Context.GenericTag('file-storage');
|
4
4
|
export const FileStorageLayer = {
|
5
5
|
createBucket: (input) => tapLayer(FileStorageLayerContext, ({ createBucket }) => createBucket(input)),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAUjC,OAAO,EAAE,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAUjC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAkEpC,MAAM,CAAC,MAAM,uBAAuB,GAClC,OAAO,CAAC,UAAU,CAAc,cAAc,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY,EAAE,CAAC,KAA+B,EAAE,EAAE,CAChD,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CACrD,YAAY,CAAC,KAAK,CAAC,CACpB;IACH,WAAW,EAAE,CAAyB,KAAgC,EAAE,EAAE,CACxE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5E,UAAU,EAAE,CAAyB,MAAe,EAAE,QAAgB,EAAE,EAAE,CACxE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC7B;IACH,eAAe,EAAE,CACf,MAAe,EACf,QAAgB,EAChB,EAAE,CACF,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CACxD,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAClC;IACH,UAAU,EAAE,CACV,MAAe,EACf,QAAgB,EAChB,EAAE,CACF,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAkB,MAAM,EAAE,QAAQ,CAAC,CAC9C;IACH,UAAU,EAAE,CAAyB,MAAe,EAAE,QAAgB,EAAE,EAAE,CACxE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAC7B;IACH,UAAU,EAAE,CAAyB,KAA+B,EAAE,EAAE,CACtE,QAAQ,CAAC,uBAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;CAC3E,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { HeadBucketCommand } from '@aws-sdk/client-s3';
|
2
2
|
import { Effect, pipe } from 'effect';
|
3
|
-
import { BucketNotFoundError, FileStorageError } from
|
4
|
-
import { cloudflareR2StorageProvider } from
|
3
|
+
import { BucketNotFoundError, FileStorageError } from './../../errors/index.js';
|
4
|
+
import { cloudflareR2StorageProvider } from './../providers/r2-file-storage.provider.js';
|
5
5
|
const hasName = (error) => {
|
6
6
|
return error?.name !== undefined;
|
7
7
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bucket-infos.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/bucket-infos.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,
|
1
|
+
{"version":3,"file":"bucket-infos.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/bucket-infos.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAIxD,MAAM,OAAO,GAAG,CAAC,KAAc,EAAoC,EAAE;IACnE,OAAQ,KAAuB,EAAE,IAAI,KAAK,SAAS,CAAC;AACtD,CAAC,CAAC;AAWF,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAgC,EAChC,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAC3D,IAAI,CACF,2BAA2B,EAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACtD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;QACX,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACxC,OAAO,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF,CAAC,CACH,EACD,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC,YAAY;CAC9B,CAAC,CAAC,CACJ,CACF,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CreateBucketCommand, } from '@aws-sdk/client-s3';
|
2
2
|
import { Effect, pipe } from 'effect';
|
3
|
-
import { FileStorageError } from
|
4
|
-
import { cloudflareR2StorageProvider } from
|
3
|
+
import { FileStorageError } from './../../errors/index.js';
|
4
|
+
import { cloudflareR2StorageProvider } from './../providers/r2-file-storage.provider.js';
|
5
5
|
export const createBucket = (input) => Effect.withSpan('create-bucket', { attributes: { ...input } })(pipe(cloudflareR2StorageProvider, Effect.flatMap((provider) => Effect.tryPromise({
|
6
6
|
try: () => provider.send(new CreateBucketCommand(input)),
|
7
7
|
catch: (e) => new FileStorageError({ cause: e }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-bucket.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/create-bucket.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,
|
1
|
+
{"version":3,"file":"create-bucket.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/create-bucket.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA+B,EAAE,EAAE,CAC9D,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,CAAC,CAC5D,IAAI,CACF,2BAA2B,EAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CACF,CACF,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Effect, pipe } from 'effect';
|
2
|
-
import { cloudflareR2StorageProvider } from
|
2
|
+
import { cloudflareR2StorageProvider } from './../providers/r2-file-storage.provider.js';
|
3
3
|
import { getUrl } from './internal/index.js';
|
4
4
|
export const getFileUrl = (bucketName, documentKey) => Effect.withSpan('get-file-url', { attributes: { bucketName, documentKey } })(pipe(cloudflareR2StorageProvider, Effect.flatMap((provider) => getUrl(provider, bucketName, documentKey))));
|
5
5
|
//# sourceMappingURL=get-file-url.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-file-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-file-url.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,2BAA2B,EAAE,
|
1
|
+
{"version":3,"file":"get-file-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-file-url.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CAC1E,IAAI,CACF,2BAA2B,EAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CACxE,CACF,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { HttpClient } from '@effect/platform';
|
2
2
|
import { Effect } from 'effect';
|
3
|
-
import { cloudflareR2StorageProvider } from
|
3
|
+
import { cloudflareR2StorageProvider } from './../../providers/r2-file-storage.provider.js';
|
4
4
|
import { getUrl } from './get-url.effect.js';
|
5
5
|
export const fetchFile = (bucketName, documentKey) => Effect.gen(function* () {
|
6
6
|
const provider = yield* cloudflareR2StorageProvider;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetch-file.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/fetch-file.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,
|
1
|
+
{"version":3,"file":"fetch-file.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/fetch-file.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAkB,EAAE,WAAmB,EAAE,EAAE,CACnE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,2BAA2B,CAAC;IACpD,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;IAE7D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;IAC5C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { GetObjectCommand } from '@aws-sdk/client-s3';
|
2
2
|
import { getSignedUrl as awsGetSignedUrl } from '@aws-sdk/s3-request-presigner';
|
3
3
|
import { Effect } from 'effect';
|
4
|
-
import { FileStorageError } from
|
4
|
+
import { FileStorageError } from './../../../errors/index.js';
|
5
5
|
const oneHourDuration = 60 * 60;
|
6
6
|
export const getUrl = (provider, bucketName, documentKey) => Effect.withSpan('get-url', { attributes: { bucketName, documentKey } })(Effect.tryPromise({
|
7
7
|
try: () => awsGetSignedUrl(provider, new GetObjectCommand({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/get-url.effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,
|
1
|
+
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/get-url.effect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAC;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,QAAkB,EAClB,UAAmB,EACnB,WAAoB,EACpB,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CACrE,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CACR,eAAe,CACb,QAAQ,EACR,IAAI,gBAAgB,CAAC;QACnB,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,WAAW;KACjB,CAAC,EACF;QACE,SAAS,EAAE,eAAe;KAC3B,CACF;IACH,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { PutObjectCommand } from '@aws-sdk/client-s3';
|
2
2
|
import { Effect, pipe } from 'effect';
|
3
|
-
import { FileStorageError } from
|
4
|
-
import { cloudflareR2StorageProvider } from
|
3
|
+
import { FileStorageError } from './../../errors/index.js';
|
4
|
+
import { cloudflareR2StorageProvider } from './../providers/r2-file-storage.provider.js';
|
5
5
|
export const uploadFile = ({ bucketName, documentKey, data, contentType, }) => Effect.withSpan('upload-file', {
|
6
6
|
attributes: { bucketName, documentKey, contentType },
|
7
7
|
})(pipe(cloudflareR2StorageProvider, Effect.flatMap((provider) => Effect.tryPromise({
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"upload-file.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/upload-file.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,
|
1
|
+
{"version":3,"file":"upload-file.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/upload-file.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AASxD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAyB,EACjD,UAAU,EACV,WAAW,EACX,IAAI,EACJ,WAAW,GACc,EAAE,EAAE,CAC7B,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE;IAC7B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE;CACrD,CAAC,CACA,IAAI,CACF,2BAA2B,EAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1B,MAAM,CAAC,UAAU,CAAC;IAChB,GAAG,EAAE,GAAG,EAAE,CACR,QAAQ,CAAC,IAAI,CACX,IAAI,gBAAgB,CAAC;QACnB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,WAAqB;QAClC,GAAG,EAAE,WAAW;QAChB,MAAM,EAAE,UAAU;KACnB,CAAC,CACH;IACH,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CACF,CACF,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Layer } from 'effect';
|
2
|
-
import { bucketInfos, createBucket, getFileUrl, readAsJson, readAsRawBinary, readAsText, uploadFile, } from
|
2
|
+
import { bucketInfos, createBucket, getFileUrl, readAsJson, readAsRawBinary, readAsText, uploadFile, } from './implementations/index.js';
|
3
3
|
import { FileStorageLayerContext } from '../layer/file-storage.layer.js';
|
4
4
|
export const CloudflareR2StorageLayerLive = Layer.succeed(FileStorageLayerContext, FileStorageLayerContext.of({
|
5
5
|
createBucket,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"r2-file-storage.layer.js","sourceRoot":"","sources":["../../../src/r2/r2-file-storage.layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,GACX,
|
1
|
+
{"version":3,"file":"r2-file-storage.layer.js","sourceRoot":"","sources":["../../../src/r2/r2-file-storage.layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC,OAAO,CACvD,uBAAuB,EACvB,uBAAuB,CAAC,EAAE,CAAC;IACzB,YAAY;IACZ,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,eAAe;CAChB,CAAC,CACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "effect-cloudflare-r2-layer",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.18",
|
4
4
|
"author": "jpb06 <jp.bois.06@outlook.fr>",
|
5
5
|
"description": "An effect layer to interact with Cloudware R2 storage service",
|
6
6
|
"keywords": [
|
@@ -8,16 +8,17 @@
|
|
8
8
|
],
|
9
9
|
"main": "./cjs/index.js",
|
10
10
|
"module": "./esm/index.js",
|
11
|
+
"types": "./dts/index.d.ts",
|
11
12
|
"type": "module",
|
12
13
|
"exports": {
|
13
14
|
".": {
|
14
15
|
"require": {
|
15
16
|
"default": "./cjs/index.js",
|
16
|
-
"types": "./dts/
|
17
|
+
"types": "./dts/index.d.ts"
|
17
18
|
},
|
18
19
|
"import": {
|
19
20
|
"default": "./esm/index.js",
|
20
|
-
"types": "./dts/
|
21
|
+
"types": "./dts/index.d.ts"
|
21
22
|
}
|
22
23
|
}
|
23
24
|
},
|
@@ -25,7 +26,6 @@
|
|
25
26
|
"node": "20.x"
|
26
27
|
},
|
27
28
|
"scripts": {
|
28
|
-
"prepare": "ts-patch install -s",
|
29
29
|
"update-deps": "bunx npm-check-updates --root --format group -i",
|
30
30
|
"copy-package": "copyfiles package.json ./dist/",
|
31
31
|
"copy-readme": "copyfiles README.md ./dist/",
|
@@ -34,34 +34,43 @@
|
|
34
34
|
"build-cjs": "tsc --project tsconfig.cjs.json",
|
35
35
|
"postbuild-cjs": "echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
36
36
|
"postbuild-esm": "echo '{\"type\": \"module\"}' > dist/esm/package.json",
|
37
|
-
"postbuild": "bun run copy-package && bun run copy-readme",
|
37
|
+
"postbuild": "bun run copy-package && bun run copy-readme && bun resolve-ts-paths-esm",
|
38
38
|
"format": "biome format --write ./src",
|
39
39
|
"format-ci": "biome format ./src",
|
40
40
|
"lint": "biome lint ./src",
|
41
41
|
"type-check": "tsc --noEmit",
|
42
|
+
"test": "vitest",
|
43
|
+
"test-ci": "vitest --coverage --run",
|
44
|
+
"test-dev": "vitest --coverage",
|
45
|
+
"test-coverage": "vitest run --coverage",
|
42
46
|
"sync-icons": "bun generateReadmeIcons -h 50"
|
43
47
|
},
|
44
48
|
"dependencies": {
|
45
|
-
"@aws-sdk/client-s3": "^3.
|
46
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
47
|
-
"@effect/platform": "^0.
|
49
|
+
"@aws-sdk/client-s3": "^3.670.0",
|
50
|
+
"@aws-sdk/s3-request-presigner": "^3.670.0",
|
51
|
+
"@effect/platform": "^0.68.5",
|
48
52
|
"dotenv": "^16.4.5",
|
49
|
-
"effect": "^3.
|
53
|
+
"effect": "^3.9.2"
|
50
54
|
},
|
51
55
|
"peerDependencies": {
|
52
56
|
"typescript": "5.6.3"
|
53
57
|
},
|
54
58
|
"devDependencies": {
|
55
|
-
"@biomejs/biome": "^1.9.
|
59
|
+
"@biomejs/biome": "^1.9.3",
|
56
60
|
"@types/bun": "latest",
|
57
61
|
"@types/fs-extra": "^11.0.4",
|
62
|
+
"@vitest/coverage-v8": "^2.1.3",
|
63
|
+
"comment-json": "^4.2.5",
|
58
64
|
"copyfiles": "^2.4.1",
|
59
65
|
"del-cli": "^6.0.0",
|
60
|
-
"effect-errors": "^1.7.
|
66
|
+
"effect-errors": "^1.7.17",
|
61
67
|
"fs-extra": "^11.2.0",
|
62
|
-
"
|
68
|
+
"glob": "^11.0.0",
|
69
|
+
"readme-package-icons": "^1.1.16",
|
63
70
|
"ts-patch": "^3.2.1",
|
71
|
+
"ts-paths-resolver": "1.1.5",
|
64
72
|
"tsx": "^4.19.1",
|
65
|
-
"
|
73
|
+
"vitest": "^2.1.3",
|
74
|
+
"vitest-mock-extended": "^2.0.2"
|
66
75
|
}
|
67
76
|
}
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import { CreateBucketCommandInput } from '@aws-sdk/client-s3';
|
2
|
-
import { Effect } from 'effect';
|
3
|
-
import { FileStorageError } from "../../errors";
|
4
|
-
export declare const createBucket: (input: CreateBucketCommandInput) => Effect.Effect<import("@aws-sdk/client-s3").CreateBucketCommandOutput, FileStorageError | import("effect/ConfigError").ConfigError, never>;
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
|
-
import { Effect } from 'effect';
|
3
|
-
export declare const fetchFile: (bucketName: string, documentKey: string) => Effect.Effect<import("@effect/platform/HttpClientResponse").HttpClientResponse, import("../../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | HttpClient.HttpClient.Service>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './tapLayer.effect.js';
|
@@ -1,9 +0,0 @@
|
|
1
|
-
declare const BucketNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
2
|
-
readonly _tag: "bucket-not-found-error";
|
3
|
-
} & Readonly<A>;
|
4
|
-
export declare class BucketNotFoundError extends BucketNotFoundError_base<{
|
5
|
-
cause?: unknown;
|
6
|
-
message?: string;
|
7
|
-
}> {
|
8
|
-
}
|
9
|
-
export {};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
declare const FileStorageError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
2
|
-
readonly _tag: "file-storage-error";
|
3
|
-
} & Readonly<A>;
|
4
|
-
export declare class FileStorageError extends FileStorageError_base<{
|
5
|
-
cause?: unknown;
|
6
|
-
message?: string;
|
7
|
-
}> {
|
8
|
-
}
|
9
|
-
export {};
|
package/dts/esm/index.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { FileStorage } from './layer/file-storage.layer.js';
|
2
|
-
import { FileStorageLayer } from './layer/file-storage.layer.js';
|
3
|
-
export { FileStorageLayer };
|
4
|
-
export type { FileStorage };
|
5
|
-
export * from './r2/r2-file-storage.layer.js';
|
6
|
-
export type { PutObjectCommandOutput, CreateBucketCommandInput, CreateBucketCommandOutput, } from '@aws-sdk/client-s3';
|
7
|
-
export type { BucketInfosInput, BucketInfosResult, } from './r2/implementations/bucket-infos.effect.js';
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { HttpClientError } from '@effect/platform/HttpClientError';
|
2
|
-
import type { ConfigError, Effect } from 'effect';
|
3
|
-
import { Context } from 'effect';
|
4
|
-
import { CreateBucketCommandInput, CreateBucketCommandOutput, PutObjectCommandOutput } from '@aws-sdk/client-s3';
|
5
|
-
import { HttpClient } from '@effect/platform';
|
6
|
-
import { Scope } from 'effect/Scope';
|
7
|
-
import type { BucketNotFoundError, FileStorageError } from "../errors";
|
8
|
-
import type { BucketInfosInput, BucketInfosResult, UploadFileInput } from "../r2/implementations";
|
9
|
-
export interface FileStorage {
|
10
|
-
readonly createBucket: (input: CreateBucketCommandInput) => Effect.Effect<CreateBucketCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
11
|
-
readonly bucketInfos: <TBucket extends string>(input: BucketInfosInput<TBucket>) => Effect.Effect<BucketInfosResult, ConfigError.ConfigError | FileStorageError | BucketNotFoundError, never>;
|
12
|
-
readonly getFileUrl: <TBucket extends string>(fileName: string, bucket: TBucket) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError>;
|
13
|
-
readonly readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
14
|
-
readonly readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
15
|
-
readonly readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
16
|
-
readonly uploadFile: <TBucket extends string>({ bucketName, documentKey, data, contentType, }: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
17
|
-
}
|
18
|
-
export declare const FileStorageLayerContext: Context.Tag<FileStorage, FileStorage>;
|
19
|
-
export declare const FileStorageLayer: {
|
20
|
-
createBucket: (input: CreateBucketCommandInput) => Effect.Effect<CreateBucketCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
21
|
-
bucketInfos: <TBucket extends string>(input: BucketInfosInput<TBucket>) => Effect.Effect<BucketInfosResult, BucketNotFoundError | FileStorageError | ConfigError.ConfigError, FileStorage>;
|
22
|
-
getFileUrl: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
23
|
-
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
24
|
-
readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucket: TBucket, fileName: string) => Effect.Effect<TShape, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
25
|
-
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
26
|
-
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
27
|
-
};
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { Effect } from 'effect';
|
2
|
-
import { BucketNotFoundError, FileStorageError } from "../../errors";
|
3
|
-
export type BucketInfosInput<TBucket extends string> = {
|
4
|
-
Bucket: TBucket;
|
5
|
-
ExpectedBucketOwner?: string;
|
6
|
-
};
|
7
|
-
export type BucketInfosResult = {
|
8
|
-
region: string | undefined;
|
9
|
-
};
|
10
|
-
export declare const bucketInfos: <TBucket extends string>(input: BucketInfosInput<TBucket>) => Effect.Effect<{
|
11
|
-
region: string | undefined;
|
12
|
-
}, BucketNotFoundError | FileStorageError | import("effect/ConfigError").ConfigError, never>;
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export * from './create-bucket.effect.js';
|
2
|
-
export * from './bucket-infos.effect.js';
|
3
|
-
export * from './get-file-url.effect.js';
|
4
|
-
export * from './upload-file.effect.js';
|
5
|
-
export * from './read-as-json.effect.js';
|
6
|
-
export * from './read-as-raw-binary.effect.js';
|
7
|
-
export * from './read-as-text.effect.js';
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import type { S3Client } from '@aws-sdk/client-s3';
|
2
|
-
import { Effect } from 'effect';
|
3
|
-
import { FileStorageError } from "../../../errors";
|
4
|
-
export declare const getUrl: <TBucket extends string>(provider: S3Client, bucketName: TBucket, documentKey: TBucket) => Effect.Effect<string, FileStorageError, never>;
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import { Effect } from 'effect';
|
2
|
-
export declare const readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucketName: TBucket, documentKey: string) => Effect.Effect<TShape, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.Service>;
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import { Effect } from 'effect';
|
2
|
-
export declare const readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.Service>;
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import { Effect } from 'effect';
|
2
|
-
export declare const readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, import("../../errors/file-storage.error.js").FileStorageError | import("effect/ConfigError").ConfigError | import("@effect/platform/HttpClientError").HttpClientError, import("effect/Scope").Scope | import("@effect/platform/HttpClient").HttpClient.Service>;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Effect } from 'effect';
|
2
|
-
import { FileStorageError } from "../../errors";
|
3
|
-
export interface UploadFileInput<TBucket extends string> {
|
4
|
-
bucketName: TBucket;
|
5
|
-
documentKey: string;
|
6
|
-
data: Buffer;
|
7
|
-
contentType: string | undefined;
|
8
|
-
}
|
9
|
-
export declare const uploadFile: <TBucket extends string>({ bucketName, documentKey, data, contentType, }: UploadFileInput<TBucket>) => Effect.Effect<import("@aws-sdk/client-s3").PutObjectCommandOutput, FileStorageError | import("effect/ConfigError").ConfigError, never>;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|