effect-cloudflare-r2-layer 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +48 -7
- package/cjs/dts/index.d.ts +1 -0
- package/cjs/dts/layer/file-storage.layer.d.ts +7 -6
- package/cjs/dts/r2/implementations/index.d.ts +3 -0
- package/cjs/dts/r2/implementations/internal/fetch-file.effect.d.ts +3 -0
- package/cjs/dts/r2/implementations/{get-url.effect.d.ts → internal/get-url.effect.d.ts} +1 -1
- package/cjs/dts/r2/implementations/internal/index.d.ts +2 -0
- package/cjs/dts/r2/implementations/read-as-json.effect.d.ts +1 -2
- package/cjs/dts/r2/implementations/read-as-raw-binary.effect.d.ts +1 -2
- package/cjs/dts/r2/implementations/read-as-text.effect.d.ts +1 -2
- package/cjs/dts/r2/implementations/upload-file.effect.d.ts +2 -2
- package/cjs/layer/file-storage.layer.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/index.js +3 -0
- package/cjs/r2/implementations/index.js.map +1 -1
- package/cjs/r2/implementations/internal/fetch-file.effect.js +15 -0
- package/cjs/r2/implementations/internal/fetch-file.effect.js.map +1 -0
- package/cjs/r2/implementations/{get-url.effect.js → internal/get-url.effect.js} +1 -1
- package/cjs/r2/implementations/internal/get-url.effect.js.map +1 -0
- package/cjs/r2/implementations/internal/index.js +19 -0
- package/cjs/r2/implementations/internal/index.js.map +1 -0
- package/cjs/r2/implementations/read-as-json.effect.js +2 -11
- package/cjs/r2/implementations/read-as-json.effect.js.map +1 -1
- package/cjs/r2/implementations/read-as-raw-binary.effect.js +2 -10
- package/cjs/r2/implementations/read-as-raw-binary.effect.js.map +1 -1
- package/cjs/r2/implementations/read-as-text.effect.js +2 -10
- package/cjs/r2/implementations/read-as-text.effect.js.map +1 -1
- package/cjs/r2/implementations/upload-file.effect.js +3 -3
- package/cjs/r2/implementations/upload-file.effect.js.map +1 -1
- package/cjs/r2/r2-file-storage.layer.js +3 -6
- package/cjs/r2/r2-file-storage.layer.js.map +1 -1
- package/esm/dts/index.d.ts +1 -0
- package/esm/dts/layer/file-storage.layer.d.ts +7 -6
- package/esm/dts/r2/implementations/index.d.ts +3 -0
- package/esm/dts/r2/implementations/internal/fetch-file.effect.d.ts +3 -0
- package/esm/dts/r2/implementations/{get-url.effect.d.ts → internal/get-url.effect.d.ts} +1 -1
- package/esm/dts/r2/implementations/internal/index.d.ts +2 -0
- package/esm/dts/r2/implementations/read-as-json.effect.d.ts +1 -2
- package/esm/dts/r2/implementations/read-as-raw-binary.effect.d.ts +1 -2
- package/esm/dts/r2/implementations/read-as-text.effect.d.ts +1 -2
- package/esm/dts/r2/implementations/upload-file.effect.d.ts +2 -2
- package/esm/layer/file-storage.layer.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/index.js +3 -0
- package/esm/r2/implementations/index.js.map +1 -1
- package/esm/r2/implementations/internal/fetch-file.effect.js +11 -0
- package/esm/r2/implementations/internal/fetch-file.effect.js.map +1 -0
- package/esm/r2/implementations/{get-url.effect.js → internal/get-url.effect.js} +1 -1
- package/esm/r2/implementations/internal/get-url.effect.js.map +1 -0
- package/esm/r2/implementations/internal/index.js +3 -0
- package/esm/r2/implementations/internal/index.js.map +1 -0
- package/esm/r2/implementations/read-as-json.effect.js +3 -12
- package/esm/r2/implementations/read-as-json.effect.js.map +1 -1
- package/esm/r2/implementations/read-as-raw-binary.effect.js +3 -11
- package/esm/r2/implementations/read-as-raw-binary.effect.js.map +1 -1
- package/esm/r2/implementations/read-as-text.effect.js +3 -11
- package/esm/r2/implementations/read-as-text.effect.js.map +1 -1
- package/esm/r2/implementations/upload-file.effect.js +3 -3
- package/esm/r2/implementations/upload-file.effect.js.map +1 -1
- package/esm/r2/r2-file-storage.layer.js +1 -4
- package/esm/r2/r2-file-storage.layer.js.map +1 -1
- package/package.json +1 -1
- package/cjs/r2/implementations/get-url.effect.js.map +0 -1
- package/esm/r2/implementations/get-url.effect.js.map +0 -1
package/README.md
CHANGED
@@ -10,6 +10,8 @@ An effect layer to interact with Cloudware R2 storage service.
|
|
10
10
|
|
11
11
|
## ⚡ Quick start
|
12
12
|
|
13
|
+
### 🔶 Install
|
14
|
+
|
13
15
|
```bash
|
14
16
|
npm i effect-cloudflare-r2-layer
|
15
17
|
# or
|
@@ -18,6 +20,34 @@ pnpm i effect-cloudflare-r2-layer
|
|
18
20
|
bun i effect-cloudflare-r2-layer
|
19
21
|
```
|
20
22
|
|
23
|
+
### 🔶 Use the layer
|
24
|
+
|
25
|
+
```typescript
|
26
|
+
import { FetchHttpClient } from '@effect/platform';
|
27
|
+
import { Effect, Layer, pipe } from 'effect';
|
28
|
+
import {
|
29
|
+
CloudflareR2StorageLayerLive,
|
30
|
+
FileStorageLayer,
|
31
|
+
} from 'effect-cloudflare-r2-layer';
|
32
|
+
|
33
|
+
const task = pipe(
|
34
|
+
FileStorageLayer.readAsText('my-bucket', 'some-file.txt'),
|
35
|
+
Effect.scoped,
|
36
|
+
Effect.provide(
|
37
|
+
Layer.mergeAll(CloudflareR2StorageLayerLive, FetchHttpClient.layer)
|
38
|
+
)
|
39
|
+
);
|
40
|
+
|
41
|
+
/* task is of type
|
42
|
+
|
43
|
+
Effect.Effect<
|
44
|
+
string,
|
45
|
+
ConfigError | HttpClientError | FileStorageError,
|
46
|
+
never
|
47
|
+
>
|
48
|
+
*/
|
49
|
+
```
|
50
|
+
|
21
51
|
## ⚡ Env variables
|
22
52
|
|
23
53
|
The layer requires the following env variables:
|
@@ -30,6 +60,14 @@ R2_DOCUMENTS_SECRET_ACCESS_KEY=""
|
|
30
60
|
|
31
61
|
## ⚡ API
|
32
62
|
|
63
|
+
| function | description |
|
64
|
+
| ------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
65
|
+
| [`uploadFile`](./README.md#-uploadfile) | Adds a file to the specified bucket |
|
66
|
+
| [`getFileUrl`](./README.md#-getfileurl) | Gets a pre-signed url to fetch a ressource by its `filename` from the specified `bucket`. |
|
67
|
+
| [`readAsJson`](./README.md#-readasjson) | Fetches a file, expecting a content extending `Record<string, unknown>`. |
|
68
|
+
| [`readAsText`](./README.md#-readastext) | Fetches a file as a string. |
|
69
|
+
| [`readAsRawBinary`](./README.md#-readasrawbinary) | Fetches a file as raw binary (ArrayBuffer). |
|
70
|
+
|
33
71
|
### 🔶 `uploadFile`
|
34
72
|
|
35
73
|
Adds a file to the specified bucket.
|
@@ -42,12 +80,15 @@ interface UploadFileInput<TBucket extends string> {
|
|
42
80
|
contentType: string | undefined;
|
43
81
|
}
|
44
82
|
|
45
|
-
type uploadFile = <TBucket extends string>(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
83
|
+
type uploadFile = <TBucket extends string>({
|
84
|
+
bucketName,
|
85
|
+
documentKey,
|
86
|
+
data,
|
87
|
+
contentType,
|
88
|
+
}: UploadFileInput<TBucket>) => Effect.Effect<
|
89
|
+
PutObjectCommandOutput,
|
90
|
+
FileStorageError | ConfigError,
|
91
|
+
never
|
51
92
|
>;
|
52
93
|
```
|
53
94
|
|
@@ -74,7 +115,7 @@ const task = pipe(
|
|
74
115
|
|
75
116
|
yield* FileStorageLayer.uploadFile<Buckets>({
|
76
117
|
bucketName: 'assets',
|
77
|
-
|
118
|
+
documentKey: fileName,
|
78
119
|
data: fileData,
|
79
120
|
contentType: 'image/jpeg',
|
80
121
|
});
|
package/cjs/dts/index.d.ts
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
import { HttpClientError } from '@effect/platform/HttpClientError';
|
2
2
|
import type { ConfigError, Effect } from 'effect';
|
3
3
|
import { Context } from 'effect';
|
4
|
+
import { PutObjectCommandOutput } from '@aws-sdk/client-s3';
|
4
5
|
import { HttpClient } from '@effect/platform';
|
5
6
|
import { Scope } from 'effect/Scope';
|
6
7
|
import type { FileStorageError } from '../errors/file-storage.error.js';
|
7
|
-
import type { UploadFileInput } from '../r2/implementations/
|
8
|
+
import type { UploadFileInput } from '../r2/implementations/index.js';
|
8
9
|
export interface FileStorage {
|
9
10
|
readonly getFileUrl: <TBucket extends string>(fileName: string, bucket: TBucket) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError>;
|
10
11
|
readonly readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
11
12
|
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>;
|
12
13
|
readonly readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
13
|
-
readonly uploadFile: <TBucket extends string>(
|
14
|
+
readonly uploadFile: <TBucket extends string>({ bucketName, documentKey, data, contentType, }: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
14
15
|
}
|
15
16
|
export declare const FileStorageLayerContext: Context.Tag<FileStorage, FileStorage>;
|
16
17
|
export declare const FileStorageLayer: {
|
17
18
|
getFileUrl: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
18
|
-
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
19
|
-
readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucket: TBucket, fileName: string) => Effect.Effect<TShape, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
20
|
-
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
21
|
-
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<
|
19
|
+
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
20
|
+
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>;
|
21
|
+
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
22
|
+
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
22
23
|
};
|
@@ -0,0 +1,3 @@
|
|
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,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/file-storage.error.js';
|
4
4
|
export declare const getUrl: <TBucket extends string>(provider: S3Client, bucketName: TBucket, documentKey: TBucket) => Effect.Effect<string, FileStorageError, never>;
|
@@ -1,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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>;
|
@@ -2,8 +2,8 @@ import { Effect } from 'effect';
|
|
2
2
|
import { FileStorageError } from '../../errors/file-storage.error.js';
|
3
3
|
export interface UploadFileInput<TBucket extends string> {
|
4
4
|
bucketName: TBucket;
|
5
|
-
|
5
|
+
documentKey: string;
|
6
6
|
data: Buffer;
|
7
7
|
contentType: string | undefined;
|
8
8
|
}
|
9
|
-
export declare const uploadFile: <TBucket extends string>({ bucketName,
|
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>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":";;;AAEA,mCAAiC;
|
1
|
+
{"version":3,"file":"file-storage.layer.js","sourceRoot":"","sources":["../../../src/layer/file-storage.layer.ts"],"names":[],"mappings":";;;AAEA,mCAAiC;AAOjC,wEAA2D;AA8C9C,QAAA,uBAAuB,GAClC,gBAAO,CAAC,UAAU,CAAc,cAAc,CAAC,CAAC;AAErC,QAAA,gBAAgB,GAAG;IAC9B,UAAU,EAAE,CAAyB,MAAe,EAAE,QAAgB,EAAE,EAAE,CACxE,IAAA,6BAAQ,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,6BAAQ,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,6BAAQ,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,6BAAQ,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,6BAAQ,EAAC,+BAAuB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;CAC3E,CAAC"}
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFileUrl = void 0;
|
4
4
|
const effect_1 = require("effect");
|
5
5
|
const r2_file_storage_provider_js_1 = require("../providers/r2-file-storage.provider.js");
|
6
|
-
const get_url_effect_js_1 = require("./get-url.effect.js");
|
6
|
+
const get_url_effect_js_1 = require("./internal/get-url.effect.js");
|
7
7
|
const getFileUrl = (bucketName, documentKey) => effect_1.Effect.withSpan('get-file-url', { attributes: { bucketName, documentKey } })((0, effect_1.pipe)(r2_file_storage_provider_js_1.cloudflareR2StorageProvider, effect_1.Effect.flatMap((provider) => (0, get_url_effect_js_1.getUrl)(provider, bucketName, documentKey))));
|
8
8
|
exports.getFileUrl = getFileUrl;
|
9
9
|
//# 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,mCAAsC;AAEtC,0FAAuF;AACvF,
|
1
|
+
{"version":3,"file":"get-file-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-file-url.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,0FAAuF;AACvF,oEAAsD;AAE/C,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,yDAA2B,EAC3B,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAA,0BAAM,EAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CACxE,CACF,CAAC;AATS,QAAA,UAAU,cASnB"}
|
@@ -16,4 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("./get-file-url.effect.js"), exports);
|
18
18
|
__exportStar(require("./upload-file.effect.js"), exports);
|
19
|
+
__exportStar(require("./read-as-json.effect.js"), exports);
|
20
|
+
__exportStar(require("./read-as-raw-binary.effect.js"), exports);
|
21
|
+
__exportStar(require("./read-as-text.effect.js"), exports);
|
19
22
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,0DAAwC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,0DAAwC;AACxC,2DAAyC;AACzC,iEAA+C;AAC/C,2DAAyC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.fetchFile = void 0;
|
4
|
+
const platform_1 = require("@effect/platform");
|
5
|
+
const effect_1 = require("effect");
|
6
|
+
const r2_file_storage_provider_js_1 = require("../../providers/r2-file-storage.provider.js");
|
7
|
+
const get_url_effect_js_1 = require("./get-url.effect.js");
|
8
|
+
const fetchFile = (bucketName, documentKey) => effect_1.Effect.gen(function* () {
|
9
|
+
const provider = yield* r2_file_storage_provider_js_1.cloudflareR2StorageProvider;
|
10
|
+
const url = yield* (0, get_url_effect_js_1.getUrl)(provider, bucketName, documentKey);
|
11
|
+
const client = yield* platform_1.HttpClient.HttpClient;
|
12
|
+
return yield* client.get(url);
|
13
|
+
});
|
14
|
+
exports.fetchFile = fetchFile;
|
15
|
+
//# sourceMappingURL=fetch-file.effect.js.map
|
@@ -0,0 +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,6FAA0F;AAC1F,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,yDAA2B,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 file_storage_error_js_1 = require("
|
7
|
+
const file_storage_error_js_1 = require("../../../errors/file-storage.error.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({
|
@@ -0,0 +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,iFAAyE;AAEzE,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,wCAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CAAC;AApBS,QAAA,MAAM,UAoBf"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./fetch-file.effect.js"), exports);
|
18
|
+
__exportStar(require("./get-url.effect.js"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,sDAAoC"}
|
@@ -1,19 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readAsJson = void 0;
|
4
|
-
const platform_1 = require("@effect/platform");
|
5
4
|
const effect_1 = require("effect");
|
6
|
-
const
|
7
|
-
const get_url_effect_js_1 = require("./get-url.effect.js");
|
5
|
+
const index_js_1 = require("./internal/index.js");
|
8
6
|
const readAsJson = (bucketName, documentKey) => effect_1.Effect.withSpan('read-as-json', {
|
9
7
|
attributes: { bucketName, documentKey },
|
10
|
-
})(effect_1.Effect.
|
11
|
-
const provider = yield* r2_file_storage_provider_js_1.cloudflareR2StorageProvider;
|
12
|
-
const url = yield* (0, get_url_effect_js_1.getUrl)(provider, bucketName, documentKey);
|
13
|
-
const client = yield* platform_1.HttpClient.HttpClient;
|
14
|
-
const response = yield* client.get(url);
|
15
|
-
const json = yield* response.json;
|
16
|
-
return json;
|
17
|
-
}));
|
8
|
+
})((0, effect_1.pipe)((0, index_js_1.fetchFile)(bucketName, documentKey), effect_1.Effect.flatMap((response) => response.json), effect_1.Effect.map((json) => json)));
|
18
9
|
exports.readAsJson = readAsJson;
|
19
10
|
//# sourceMappingURL=read-as-json.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-json.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-json.effect.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"read-as-json.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-json.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,kDAAgD;AAEzC,MAAM,UAAU,GAAG,CAIxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAA,aAAI,EACF,IAAA,oBAAS,EAAC,UAAU,EAAE,WAAW,CAAC,EAClC,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC3C,eAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAc,CAAC,CACrC,CACF,CAAC;AAfS,QAAA,UAAU,cAenB"}
|
@@ -1,18 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readAsRawBinary = void 0;
|
4
|
-
const platform_1 = require("@effect/platform");
|
5
4
|
const effect_1 = require("effect");
|
6
|
-
const
|
7
|
-
const get_url_effect_js_1 = require("./get-url.effect.js");
|
5
|
+
const index_js_1 = require("./internal/index.js");
|
8
6
|
const readAsRawBinary = (bucketName, documentKey) => effect_1.Effect.withSpan('read-as-raw-binary', {
|
9
7
|
attributes: { bucketName, documentKey },
|
10
|
-
})(effect_1.
|
11
|
-
const provider = yield* r2_file_storage_provider_js_1.cloudflareR2StorageProvider;
|
12
|
-
const url = yield* (0, get_url_effect_js_1.getUrl)(provider, bucketName, documentKey);
|
13
|
-
const client = yield* platform_1.HttpClient.HttpClient;
|
14
|
-
const response = yield* client.get(url);
|
15
|
-
return yield* response.arrayBuffer;
|
16
|
-
}));
|
8
|
+
})((0, effect_1.pipe)((0, index_js_1.fetchFile)(bucketName, documentKey), effect_1.Effect.flatMap((response) => response.arrayBuffer)));
|
17
9
|
exports.readAsRawBinary = readAsRawBinary;
|
18
10
|
//# sourceMappingURL=read-as-raw-binary.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-raw-binary.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-raw-binary.effect.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"read-as-raw-binary.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-raw-binary.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,kDAAgD;AAEzC,MAAM,eAAe,GAAG,CAC7B,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE;IACpC,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAA,aAAI,EACF,IAAA,oBAAS,EAAC,UAAU,EAAE,WAAW,CAAC,EAClC,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CACnD,CACF,CAAC;AAXS,QAAA,eAAe,mBAWxB"}
|
@@ -1,18 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readAsText = void 0;
|
4
|
-
const platform_1 = require("@effect/platform");
|
5
4
|
const effect_1 = require("effect");
|
6
|
-
const
|
7
|
-
const get_url_effect_js_1 = require("./get-url.effect.js");
|
5
|
+
const index_js_1 = require("./internal/index.js");
|
8
6
|
const readAsText = (bucketName, documentKey) => effect_1.Effect.withSpan('read-as-text', {
|
9
7
|
attributes: { bucketName, documentKey },
|
10
|
-
})(effect_1.
|
11
|
-
const provider = yield* r2_file_storage_provider_js_1.cloudflareR2StorageProvider;
|
12
|
-
const url = yield* (0, get_url_effect_js_1.getUrl)(provider, bucketName, documentKey);
|
13
|
-
const client = yield* platform_1.HttpClient.HttpClient;
|
14
|
-
const response = yield* client.get(url);
|
15
|
-
return yield* response.text;
|
16
|
-
}));
|
8
|
+
})((0, effect_1.pipe)((0, index_js_1.fetchFile)(bucketName, documentKey), effect_1.Effect.flatMap((response) => response.text)));
|
17
9
|
exports.readAsText = readAsText;
|
18
10
|
//# sourceMappingURL=read-as-text.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-text.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-text.effect.ts"],"names":[],"mappings":";;;AAAA
|
1
|
+
{"version":3,"file":"read-as-text.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-text.effect.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,kDAAgD;AAEzC,MAAM,UAAU,GAAG,CACxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,eAAM,CAAC,QAAQ,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAA,aAAI,EACF,IAAA,oBAAS,EAAC,UAAU,EAAE,WAAW,CAAC,EAClC,eAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC5C,CACF,CAAC;AAXS,QAAA,UAAU,cAWnB"}
|
@@ -5,13 +5,13 @@ const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
5
|
const effect_1 = require("effect");
|
6
6
|
const file_storage_error_js_1 = require("../../errors/file-storage.error.js");
|
7
7
|
const r2_file_storage_provider_js_1 = require("../providers/r2-file-storage.provider.js");
|
8
|
-
const uploadFile = ({ bucketName,
|
9
|
-
attributes: { bucketName,
|
8
|
+
const uploadFile = ({ bucketName, documentKey, data, contentType, }) => effect_1.Effect.withSpan('upload-file', {
|
9
|
+
attributes: { bucketName, documentKey, contentType },
|
10
10
|
})((0, effect_1.pipe)(r2_file_storage_provider_js_1.cloudflareR2StorageProvider, effect_1.Effect.flatMap((provider) => effect_1.Effect.tryPromise({
|
11
11
|
try: () => provider.send(new client_s3_1.PutObjectCommand({
|
12
12
|
Body: data,
|
13
13
|
ContentType: contentType,
|
14
|
-
Key:
|
14
|
+
Key: documentKey,
|
15
15
|
Bucket: bucketName,
|
16
16
|
})),
|
17
17
|
catch: (e) => new file_storage_error_js_1.FileStorageError({ cause: e }),
|
@@ -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,8EAAsE;AACtE,0FAAuF;AAShF,MAAM,UAAU,GAAG,CAAyB,EACjD,UAAU,EACV,
|
1
|
+
{"version":3,"file":"upload-file.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/upload-file.effect.ts"],"names":[],"mappings":";;;AAAA,kDAAsD;AACtD,mCAAsC;AAEtC,8EAAsE;AACtE,0FAAuF;AAShF,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,yDAA2B,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,wCAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CACF,CACF,CAAC;AA1BS,QAAA,UAAU,cA0BnB"}
|
@@ -4,14 +4,11 @@ exports.CloudflareR2StorageLayerLive = void 0;
|
|
4
4
|
const effect_1 = require("effect");
|
5
5
|
const file_storage_layer_js_1 = require("../layer/file-storage.layer.js");
|
6
6
|
const index_js_1 = require("./implementations/index.js");
|
7
|
-
const read_as_json_effect_js_1 = require("./implementations/read-as-json.effect.js");
|
8
|
-
const read_as_raw_binary_effect_js_1 = require("./implementations/read-as-raw-binary.effect.js");
|
9
|
-
const read_as_text_effect_js_1 = require("./implementations/read-as-text.effect.js");
|
10
7
|
exports.CloudflareR2StorageLayerLive = effect_1.Layer.succeed(file_storage_layer_js_1.FileStorageLayerContext, file_storage_layer_js_1.FileStorageLayerContext.of({
|
11
8
|
getFileUrl: index_js_1.getFileUrl,
|
12
9
|
uploadFile: index_js_1.uploadFile,
|
13
|
-
readAsText:
|
14
|
-
readAsJson:
|
15
|
-
readAsRawBinary:
|
10
|
+
readAsText: index_js_1.readAsText,
|
11
|
+
readAsJson: index_js_1.readAsJson,
|
12
|
+
readAsRawBinary: index_js_1.readAsRawBinary,
|
16
13
|
}));
|
17
14
|
//# sourceMappingURL=r2-file-storage.layer.js.map
|
@@ -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,0EAAyE;AACzE,
|
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,0EAAyE;AACzE,yDAMoC;AAEvB,QAAA,4BAA4B,GAAG,cAAK,CAAC,OAAO,CACvD,+CAAuB,EACvB,+CAAuB,CAAC,EAAE,CAAC;IACzB,UAAU,EAAV,qBAAU;IACV,UAAU,EAAV,qBAAU;IACV,UAAU,EAAV,qBAAU;IACV,UAAU,EAAV,qBAAU;IACV,eAAe,EAAf,0BAAe;CAChB,CAAC,CACH,CAAC"}
|
package/esm/dts/index.d.ts
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
import { HttpClientError } from '@effect/platform/HttpClientError';
|
2
2
|
import type { ConfigError, Effect } from 'effect';
|
3
3
|
import { Context } from 'effect';
|
4
|
+
import { PutObjectCommandOutput } from '@aws-sdk/client-s3';
|
4
5
|
import { HttpClient } from '@effect/platform';
|
5
6
|
import { Scope } from 'effect/Scope';
|
6
7
|
import type { FileStorageError } from '../errors/file-storage.error.js';
|
7
|
-
import type { UploadFileInput } from '../r2/implementations/
|
8
|
+
import type { UploadFileInput } from '../r2/implementations/index.js';
|
8
9
|
export interface FileStorage {
|
9
10
|
readonly getFileUrl: <TBucket extends string>(fileName: string, bucket: TBucket) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError>;
|
10
11
|
readonly readAsRawBinary: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<ArrayBuffer, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
11
12
|
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>;
|
12
13
|
readonly readAsText: <TBucket extends string>(bucketName: TBucket, documentKey: string) => Effect.Effect<string, ConfigError.ConfigError | HttpClientError | FileStorageError, Scope | HttpClient.HttpClient.Service>;
|
13
|
-
readonly uploadFile: <TBucket extends string>(
|
14
|
+
readonly uploadFile: <TBucket extends string>({ bucketName, documentKey, data, contentType, }: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, ConfigError.ConfigError | FileStorageError, never>;
|
14
15
|
}
|
15
16
|
export declare const FileStorageLayerContext: Context.Tag<FileStorage, FileStorage>;
|
16
17
|
export declare const FileStorageLayer: {
|
17
18
|
getFileUrl: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
18
|
-
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
19
|
-
readAsJson: <TBucket extends string, TShape extends Record<string, unknown>>(bucket: TBucket, fileName: string) => Effect.Effect<TShape, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
20
|
-
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError,
|
21
|
-
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<
|
19
|
+
readAsRawBinary: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<ArrayBuffer, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
20
|
+
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>;
|
21
|
+
readAsText: <TBucket extends string>(bucket: TBucket, fileName: string) => Effect.Effect<string, FileStorageError | ConfigError.ConfigError | HttpClientError, Scope | HttpClient.HttpClient.Service | FileStorage>;
|
22
|
+
uploadFile: <TBucket extends string>(input: UploadFileInput<TBucket>) => Effect.Effect<PutObjectCommandOutput, FileStorageError | ConfigError.ConfigError, FileStorage>;
|
22
23
|
};
|
@@ -0,0 +1,3 @@
|
|
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,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/file-storage.error.js';
|
4
4
|
export declare const getUrl: <TBucket extends string>(provider: S3Client, bucketName: TBucket, documentKey: TBucket) => Effect.Effect<string, FileStorageError, never>;
|
@@ -1,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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,3 +1,2 @@
|
|
1
|
-
import { HttpClient } from '@effect/platform';
|
2
1
|
import { Effect } from 'effect';
|
3
|
-
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 | HttpClient.HttpClient.Service>;
|
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>;
|
@@ -2,8 +2,8 @@ import { Effect } from 'effect';
|
|
2
2
|
import { FileStorageError } from '../../errors/file-storage.error.js';
|
3
3
|
export interface UploadFileInput<TBucket extends string> {
|
4
4
|
bucketName: TBucket;
|
5
|
-
|
5
|
+
documentKey: string;
|
6
6
|
data: Buffer;
|
7
7
|
contentType: string | undefined;
|
8
8
|
}
|
9
|
-
export declare const uploadFile: <TBucket extends string>({ bucketName,
|
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>;
|
@@ -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;
|
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;AAOjC,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AA8C3D,MAAM,CAAC,MAAM,uBAAuB,GAClC,OAAO,CAAC,UAAU,CAAc,cAAc,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,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,5 +1,5 @@
|
|
1
1
|
import { Effect, pipe } from 'effect';
|
2
2
|
import { cloudflareR2StorageProvider } from '../providers/r2-file-storage.provider.js';
|
3
|
-
import { getUrl } from './get-url.effect.js';
|
3
|
+
import { getUrl } from './internal/get-url.effect.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,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,
|
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,0CAA0C,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,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 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { HttpClient } from '@effect/platform';
|
2
|
+
import { Effect } from 'effect';
|
3
|
+
import { cloudflareR2StorageProvider } from '../../providers/r2-file-storage.provider.js';
|
4
|
+
import { getUrl } from './get-url.effect.js';
|
5
|
+
export const fetchFile = (bucketName, documentKey) => Effect.gen(function* () {
|
6
|
+
const provider = yield* cloudflareR2StorageProvider;
|
7
|
+
const url = yield* getUrl(provider, bucketName, documentKey);
|
8
|
+
const client = yield* HttpClient.HttpClient;
|
9
|
+
return yield* client.get(url);
|
10
|
+
});
|
11
|
+
//# sourceMappingURL=fetch-file.effect.js.map
|
@@ -0,0 +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,MAAM,6CAA6C,CAAC;AAC1F,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/file-storage.error.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({
|
@@ -0,0 +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,MAAM,uCAAuC,CAAC;AAEzE,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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/r2/implementations/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
@@ -1,15 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { cloudflareR2StorageProvider } from '../providers/r2-file-storage.provider.js';
|
4
|
-
import { getUrl } from './get-url.effect.js';
|
1
|
+
import { Effect, pipe } from 'effect';
|
2
|
+
import { fetchFile } from './internal/index.js';
|
5
3
|
export const readAsJson = (bucketName, documentKey) => Effect.withSpan('read-as-json', {
|
6
4
|
attributes: { bucketName, documentKey },
|
7
|
-
})(Effect.
|
8
|
-
const provider = yield* cloudflareR2StorageProvider;
|
9
|
-
const url = yield* getUrl(provider, bucketName, documentKey);
|
10
|
-
const client = yield* HttpClient.HttpClient;
|
11
|
-
const response = yield* client.get(url);
|
12
|
-
const json = yield* response.json;
|
13
|
-
return json;
|
14
|
-
}));
|
5
|
+
})(pipe(fetchFile(bucketName, documentKey), Effect.flatMap((response) => response.json), Effect.map((json) => json)));
|
15
6
|
//# sourceMappingURL=read-as-json.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-json.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-json.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"read-as-json.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-json.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,CAIxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAI,CACF,SAAS,CAAC,UAAU,EAAE,WAAW,CAAC,EAClC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC3C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAc,CAAC,CACrC,CACF,CAAC"}
|
@@ -1,14 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { cloudflareR2StorageProvider } from '../providers/r2-file-storage.provider.js';
|
4
|
-
import { getUrl } from './get-url.effect.js';
|
1
|
+
import { Effect, pipe } from 'effect';
|
2
|
+
import { fetchFile } from './internal/index.js';
|
5
3
|
export const readAsRawBinary = (bucketName, documentKey) => Effect.withSpan('read-as-raw-binary', {
|
6
4
|
attributes: { bucketName, documentKey },
|
7
|
-
})(Effect.
|
8
|
-
const provider = yield* cloudflareR2StorageProvider;
|
9
|
-
const url = yield* getUrl(provider, bucketName, documentKey);
|
10
|
-
const client = yield* HttpClient.HttpClient;
|
11
|
-
const response = yield* client.get(url);
|
12
|
-
return yield* response.arrayBuffer;
|
13
|
-
}));
|
5
|
+
})(pipe(fetchFile(bucketName, documentKey), Effect.flatMap((response) => response.arrayBuffer)));
|
14
6
|
//# sourceMappingURL=read-as-raw-binary.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-raw-binary.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-raw-binary.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"read-as-raw-binary.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-raw-binary.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,oBAAoB,EAAE;IACpC,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAI,CACF,SAAS,CAAC,UAAU,EAAE,WAAW,CAAC,EAClC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CACnD,CACF,CAAC"}
|
@@ -1,14 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { cloudflareR2StorageProvider } from '../providers/r2-file-storage.provider.js';
|
4
|
-
import { getUrl } from './get-url.effect.js';
|
1
|
+
import { Effect, pipe } from 'effect';
|
2
|
+
import { fetchFile } from './internal/index.js';
|
5
3
|
export const readAsText = (bucketName, documentKey) => Effect.withSpan('read-as-text', {
|
6
4
|
attributes: { bucketName, documentKey },
|
7
|
-
})(Effect.
|
8
|
-
const provider = yield* cloudflareR2StorageProvider;
|
9
|
-
const url = yield* getUrl(provider, bucketName, documentKey);
|
10
|
-
const client = yield* HttpClient.HttpClient;
|
11
|
-
const response = yield* client.get(url);
|
12
|
-
return yield* response.text;
|
13
|
-
}));
|
5
|
+
})(pipe(fetchFile(bucketName, documentKey), Effect.flatMap((response) => response.text)));
|
14
6
|
//# sourceMappingURL=read-as-text.effect.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"read-as-text.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-text.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"read-as-text.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/read-as-text.effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,UAAmB,EACnB,WAAmB,EACnB,EAAE,CACF,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE;IAC9B,UAAU,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE;CACxC,CAAC,CACA,IAAI,CACF,SAAS,CAAC,UAAU,EAAE,WAAW,CAAC,EAClC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC5C,CACF,CAAC"}
|
@@ -2,13 +2,13 @@ import { PutObjectCommand } from '@aws-sdk/client-s3';
|
|
2
2
|
import { Effect, pipe } from 'effect';
|
3
3
|
import { FileStorageError } from '../../errors/file-storage.error.js';
|
4
4
|
import { cloudflareR2StorageProvider } from '../providers/r2-file-storage.provider.js';
|
5
|
-
export const uploadFile = ({ bucketName,
|
6
|
-
attributes: { bucketName,
|
5
|
+
export const uploadFile = ({ bucketName, documentKey, data, contentType, }) => Effect.withSpan('upload-file', {
|
6
|
+
attributes: { bucketName, documentKey, contentType },
|
7
7
|
})(pipe(cloudflareR2StorageProvider, Effect.flatMap((provider) => Effect.tryPromise({
|
8
8
|
try: () => provider.send(new PutObjectCommand({
|
9
9
|
Body: data,
|
10
10
|
ContentType: contentType,
|
11
|
-
Key:
|
11
|
+
Key: documentKey,
|
12
12
|
Bucket: bucketName,
|
13
13
|
})),
|
14
14
|
catch: (e) => new FileStorageError({ cause: e }),
|
@@ -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,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AASvF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAyB,EACjD,UAAU,EACV,
|
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,oCAAoC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AASvF,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,9 +1,6 @@
|
|
1
1
|
import { Layer } from 'effect';
|
2
2
|
import { FileStorageLayerContext } from '../layer/file-storage.layer.js';
|
3
|
-
import { getFileUrl, uploadFile } from './implementations/index.js';
|
4
|
-
import { readAsJson } from './implementations/read-as-json.effect.js';
|
5
|
-
import { readAsRawBinary } from './implementations/read-as-raw-binary.effect.js';
|
6
|
-
import { readAsText } from './implementations/read-as-text.effect.js';
|
3
|
+
import { getFileUrl, readAsJson, readAsRawBinary, readAsText, uploadFile, } from './implementations/index.js';
|
7
4
|
export const CloudflareR2StorageLayerLive = Layer.succeed(FileStorageLayerContext, FileStorageLayerContext.of({
|
8
5
|
getFileUrl,
|
9
6
|
uploadFile,
|
@@ -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,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,
|
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,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,4BAA4B,CAAC;AAEpC,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC,OAAO,CACvD,uBAAuB,EACvB,uBAAuB,CAAC,EAAE,CAAC;IACzB,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,eAAe;CAChB,CAAC,CACH,CAAC"}
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/get-url.effect.ts"],"names":[],"mappings":";;;AACA,kDAAsD;AACtD,wEAAgF;AAChF,mCAAgC;AAEhC,8EAAsE;AAEtE,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,wCAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;CACjD,CAAC,CACH,CAAC;AApBS,QAAA,MAAM,UAoBf"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"get-url.effect.js","sourceRoot":"","sources":["../../../../src/r2/implementations/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,oCAAoC,CAAC;AAEtE,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"}
|