effect-cloudflare-r2-layer 1.1.43 → 1.1.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -27
- package/cjs/index.js +3 -3
- package/cjs/index.js.map +1 -1
- package/cjs/r2/implementations/index.js +4 -4
- package/cjs/r2/implementations/index.js.map +1 -1
- package/dts/index.d.ts +3 -3
- package/dts/r2/implementations/index.d.ts +4 -4
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/r2/implementations/index.js +4 -4
- package/esm/r2/implementations/index.js.map +1 -1
- package/package.json +11 -14
package/README.md
CHANGED
@@ -184,12 +184,13 @@ type uploadFile = <TBucket extends string>(
|
|
184
184
|
#### 🧿 Example
|
185
185
|
|
186
186
|
```typescript
|
187
|
-
import {
|
187
|
+
import { FileSystem } from '@effect/platform/FileSystem';
|
188
|
+
import { NodeFileSystem } from '@effect/platform-node';
|
189
|
+
import { Effect, Layer, pipe } from 'effect';
|
188
190
|
import {
|
189
191
|
CloudflareR2StorageLayerLive,
|
190
192
|
FileStorageLayer,
|
191
193
|
} from 'effect-cloudflare-r2-layer';
|
192
|
-
import { readFile } from 'fs-extra';
|
193
194
|
|
194
195
|
type Buckets = 'assets' | 'config';
|
195
196
|
const fileName = 'yolo.jpg';
|
@@ -197,21 +198,21 @@ const filePath = './assets/yolo.jpg';
|
|
197
198
|
|
198
199
|
const task = pipe(
|
199
200
|
Effect.gen(function* () {
|
200
|
-
const
|
201
|
-
|
202
|
-
catch: (e) => new FsError({ cause: e }),
|
203
|
-
});
|
201
|
+
const fs = yield* FileSystem;
|
202
|
+
const fileData = yield* fs.readFile(filePath);
|
204
203
|
|
205
204
|
yield* FileStorageLayer.uploadFile<Buckets>({
|
206
205
|
bucketName: 'assets',
|
207
206
|
documentKey: fileName,
|
208
|
-
data: fileData,
|
207
|
+
data: Buffer.from(fileData),
|
209
208
|
contentType: 'image/jpeg',
|
210
209
|
});
|
211
210
|
|
212
211
|
// ...
|
213
212
|
}),
|
214
|
-
Effect.provide(
|
213
|
+
Effect.provide(
|
214
|
+
Layer.mergeAll(CloudflareR2StorageLayerLive, NodeFileSystem.layer)
|
215
|
+
)
|
215
216
|
);
|
216
217
|
```
|
217
218
|
|
@@ -242,7 +243,6 @@ import {
|
|
242
243
|
CloudflareR2StorageLayerLive,
|
243
244
|
FileStorageLayer,
|
244
245
|
} from 'effect-cloudflare-r2-layer';
|
245
|
-
import { readFile } from 'fs-extra';
|
246
246
|
|
247
247
|
type Buckets = 'assets' | 'config';
|
248
248
|
const fileName = 'yolo.jpg';
|
@@ -250,11 +250,6 @@ const filePath = './assets/yolo.jpg';
|
|
250
250
|
|
251
251
|
const task = pipe(
|
252
252
|
Effect.gen(function* () {
|
253
|
-
const fileData = yield* Effect.tryPromise({
|
254
|
-
try: () => readFile(filePath),
|
255
|
-
catch: (e) => new FsError({ cause: e }),
|
256
|
-
});
|
257
|
-
|
258
253
|
yield* FileStorageLayer.deleteFile<Buckets>({
|
259
254
|
bucketName: 'assets',
|
260
255
|
documentKey: fileName,
|
@@ -422,17 +417,12 @@ readAsRawBinary: <TBucket extends string>(
|
|
422
417
|
|
423
418
|
```typescript
|
424
419
|
import { FetchHttpClient } from '@effect/platform';
|
420
|
+
import { FileSystem } from '@effect/platform/FileSystem';
|
425
421
|
import { Effect, Layer, pipe } from 'effect';
|
426
422
|
import {
|
427
423
|
CloudflareR2StorageLayerLive,
|
428
424
|
FileStorageLayer,
|
429
425
|
} from 'effect-cloudflare-r2-layer';
|
430
|
-
import fs from 'fs-extra';
|
431
|
-
import { TaggedError } from 'effect/Data';
|
432
|
-
|
433
|
-
export class FsError extends TaggedError('FsError')<{
|
434
|
-
cause?: unknown;
|
435
|
-
}> {}
|
436
426
|
|
437
427
|
type Buckets = 'assets' | 'config';
|
438
428
|
|
@@ -444,13 +434,9 @@ const task = pipe(
|
|
444
434
|
'yolo.jpg'
|
445
435
|
);
|
446
436
|
|
447
|
-
yield*
|
448
|
-
|
449
|
-
|
450
|
-
encoding: 'utf-8',
|
451
|
-
}),
|
452
|
-
catch: (e) => new FsError({ cause: e }),
|
453
|
-
});
|
437
|
+
const fs = yield* FileSystem;
|
438
|
+
const buffer = Buffer.from(data);
|
439
|
+
yield* fs.writeFile('./file.jpg', buffer);
|
454
440
|
}),
|
455
441
|
Effect.scoped,
|
456
442
|
Effect.provide(
|
package/cjs/index.js
CHANGED
@@ -17,13 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.
|
20
|
+
exports.FileStorageError = exports.BucketNotFoundError = exports.FileStorageLayer = void 0;
|
21
21
|
const dotenv_1 = __importDefault(require("dotenv"));
|
22
22
|
dotenv_1.default.config();
|
23
23
|
const file_storage_layer_js_1 = require("./layer/file-storage.layer.js");
|
24
24
|
Object.defineProperty(exports, "FileStorageLayer", { enumerable: true, get: function () { return file_storage_layer_js_1.FileStorageLayer; } });
|
25
|
-
__exportStar(require("./r2/r2-file-storage.layer.js"), exports);
|
26
25
|
var index_js_1 = require("./errors/index.js");
|
27
|
-
Object.defineProperty(exports, "FileStorageError", { enumerable: true, get: function () { return index_js_1.FileStorageError; } });
|
28
26
|
Object.defineProperty(exports, "BucketNotFoundError", { enumerable: true, get: function () { return index_js_1.BucketNotFoundError; } });
|
27
|
+
Object.defineProperty(exports, "FileStorageError", { enumerable: true, get: function () { return index_js_1.FileStorageError; } });
|
28
|
+
__exportStar(require("./r2/r2-file-storage.layer.js"), exports);
|
29
29
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAGhB,yEAAiE;AAExD,iGAFA,wCAAgB,OAEA;AASzB,8CAA0E;AAAjE,+GAAA,mBAAmB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAK9C,gEAA8C"}
|
@@ -14,13 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./create-bucket.effect.js"), exports);
|
18
17
|
__exportStar(require("./bucket-infos.effect.js"), exports);
|
18
|
+
__exportStar(require("./create-bucket.effect.js"), exports);
|
19
|
+
__exportStar(require("./delete-file.effect.js"), exports);
|
20
|
+
__exportStar(require("./file-exists.effect.js"), exports);
|
19
21
|
__exportStar(require("./get-file-url.effect.js"), exports);
|
20
|
-
__exportStar(require("./upload-file.effect.js"), exports);
|
21
22
|
__exportStar(require("./read-as-json.effect.js"), exports);
|
22
23
|
__exportStar(require("./read-as-raw-binary.effect.js"), exports);
|
23
24
|
__exportStar(require("./read-as-text.effect.js"), exports);
|
24
|
-
__exportStar(require("./
|
25
|
-
__exportStar(require("./file-exists.effect.js"), exports);
|
25
|
+
__exportStar(require("./upload-file.effect.js"), exports);
|
26
26
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,4DAA0C;AAC1C,0DAAwC;AACxC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,iEAA+C;AAC/C,2DAAyC;AACzC,0DAAwC"}
|
package/dts/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import type { FileStorage } from './layer/file-storage.layer.js';
|
|
2
2
|
import { FileStorageLayer } from './layer/file-storage.layer.js';
|
3
3
|
export { FileStorageLayer };
|
4
4
|
export type { FileStorage };
|
5
|
-
export
|
6
|
-
export
|
5
|
+
export type { CreateBucketCommandInput, CreateBucketCommandOutput, PutObjectCommandOutput, } from '@aws-sdk/client-s3';
|
6
|
+
export { BucketNotFoundError, FileStorageError } from './errors/index.js';
|
7
7
|
export type { BucketInfosInput, BucketInfosResult, } from './r2/implementations/bucket-infos.effect.js';
|
8
|
-
export
|
8
|
+
export * from './r2/r2-file-storage.layer.js';
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export * from './create-bucket.effect.js';
|
2
1
|
export * from './bucket-infos.effect.js';
|
2
|
+
export * from './create-bucket.effect.js';
|
3
|
+
export * from './delete-file.effect.js';
|
4
|
+
export * from './file-exists.effect.js';
|
3
5
|
export * from './get-file-url.effect.js';
|
4
|
-
export * from './upload-file.effect.js';
|
5
6
|
export * from './read-as-json.effect.js';
|
6
7
|
export * from './read-as-raw-binary.effect.js';
|
7
8
|
export * from './read-as-text.effect.js';
|
8
|
-
export * from './
|
9
|
-
export * from './file-exists.effect.js';
|
9
|
+
export * from './upload-file.effect.js';
|
package/esm/index.js
CHANGED
@@ -2,6 +2,6 @@ import dotenv from 'dotenv';
|
|
2
2
|
dotenv.config();
|
3
3
|
import { FileStorageLayer } from './layer/file-storage.layer.js';
|
4
4
|
export { FileStorageLayer };
|
5
|
+
export { BucketNotFoundError, FileStorageError } from './errors/index.js';
|
5
6
|
export * from './r2/r2-file-storage.layer.js';
|
6
|
-
export { FileStorageError, BucketNotFoundError } from './errors/index.js';
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAGhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAS5B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK1E,cAAc,+BAA+B,CAAC"}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
export * from './create-bucket.effect.js';
|
2
1
|
export * from './bucket-infos.effect.js';
|
2
|
+
export * from './create-bucket.effect.js';
|
3
|
+
export * from './delete-file.effect.js';
|
4
|
+
export * from './file-exists.effect.js';
|
3
5
|
export * from './get-file-url.effect.js';
|
4
|
-
export * from './upload-file.effect.js';
|
5
6
|
export * from './read-as-json.effect.js';
|
6
7
|
export * from './read-as-raw-binary.effect.js';
|
7
8
|
export * from './read-as-text.effect.js';
|
8
|
-
export * from './
|
9
|
-
export * from './file-exists.effect.js';
|
9
|
+
export * from './upload-file.effect.js';
|
10
10
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/r2/implementations/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "effect-cloudflare-r2-layer",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.45",
|
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": [
|
@@ -38,7 +38,8 @@
|
|
38
38
|
"build-cjs": "tsc --project tsconfig.cjs.json",
|
39
39
|
"postbuild-cjs": "echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
40
40
|
"postbuild-esm": "echo '{\"type\": \"module\"}' > dist/esm/package.json",
|
41
|
-
"postbuild": "bun run copy-package && bun run copy-readme && bun resolve-ts-paths-esm",
|
41
|
+
"postbuild": "bun run copy-package && bun run copy-readme && bun run resolve-ts-paths-esm --path ./dist --tsconfigPath ./tsconfig.json --debug true",
|
42
|
+
"check": "biome check ./src",
|
42
43
|
"format": "biome format --write ./src",
|
43
44
|
"format-ci": "biome format ./src",
|
44
45
|
"lint": "biome lint ./src",
|
@@ -50,8 +51,8 @@
|
|
50
51
|
"sync-icons": "bun generateReadmeIcons -h 50"
|
51
52
|
},
|
52
53
|
"dependencies": {
|
53
|
-
"@aws-sdk/client-s3": "3.
|
54
|
-
"@aws-sdk/s3-request-presigner": "3.
|
54
|
+
"@aws-sdk/client-s3": "3.883.0",
|
55
|
+
"@aws-sdk/s3-request-presigner": "3.883.0",
|
55
56
|
"dotenv-flow": "4.1.0"
|
56
57
|
},
|
57
58
|
"peerDependencies": {
|
@@ -59,21 +60,17 @@
|
|
59
60
|
"effect": "3.x"
|
60
61
|
},
|
61
62
|
"devDependencies": {
|
62
|
-
"@biomejs/biome": "2.
|
63
|
+
"@biomejs/biome": "2.2.3",
|
63
64
|
"@types/bun": "latest",
|
64
|
-
"@types/fs-extra": "11.0.4",
|
65
65
|
"@vitest/coverage-v8": "3.2.4",
|
66
|
-
"comment-json": "4.2.5",
|
67
66
|
"copyfiles": "2.4.1",
|
68
67
|
"del-cli": "6.0.0",
|
69
|
-
"effect-errors": "1.10.
|
70
|
-
"
|
71
|
-
"glob": "11.0.3",
|
72
|
-
"npm-check-updates": "18.0.1",
|
68
|
+
"effect-errors": "1.10.15",
|
69
|
+
"npm-check-updates": "18.0.3",
|
73
70
|
"readme-package-icons": "1.2.2",
|
74
|
-
"ts-paths-resolver": "1.
|
75
|
-
"tsx": "4.20.
|
76
|
-
"typescript": "5.
|
71
|
+
"ts-paths-resolver": "1.3.1",
|
72
|
+
"tsx": "4.20.5",
|
73
|
+
"typescript": "5.9.2",
|
77
74
|
"vitest": "3.2.4",
|
78
75
|
"vitest-mock-extended": "3.1.0"
|
79
76
|
}
|