@tc-libs/storage 3.6.0 → 3.8.0

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.
Files changed (2) hide show
  1. package/README.md +91 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,11 +1,96 @@
1
- # storage
1
+ # @tc-libs/storage
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Astrazione storage file con implementazione principale AWS S3.
4
4
 
5
- ## Building
5
+ Il package espone:
6
6
 
7
- Run `nx build storage` to build the library.
7
+ - `StorageModule`
8
+ - `StorageAwsS3Service`
9
+ - tipi e serializzazioni per upload/download/listing
10
+ - enum ACL
8
11
 
9
- ## Running unit tests
12
+ ## Registrazione
10
13
 
11
- Run `nx test storage` to execute the unit tests via [Jest](https://jestjs.io).
14
+ ```ts
15
+ StorageModule.register(
16
+ {
17
+ aws: {
18
+ credential: {
19
+ key: process.env.AWS_ACCESS_KEY_ID!,
20
+ secret: process.env.AWS_SECRET_ACCESS_KEY!,
21
+ },
22
+ s3: {
23
+ region: process.env.AWS_REGION!,
24
+ bucket: process.env.AWS_S3_BUCKET!,
25
+ baseUrl: process.env.AWS_S3_BASE_URL!,
26
+ },
27
+ },
28
+ },
29
+ true,
30
+ );
31
+ ```
32
+
33
+ ## Operazioni principali
34
+
35
+ `StorageAwsS3Service` implementa `IStorageService` e copre:
36
+
37
+ - health check bucket
38
+ - lista bucket
39
+ - lista file con prefisso
40
+ - download file e signed URL
41
+ - upload singolo
42
+ - multipart upload
43
+ - delete singolo/multiplo/cartella
44
+
45
+ Esempi:
46
+
47
+ ```ts
48
+ const uploaded = await this.storage.uploadItem('avatar.png', buffer, {
49
+ path: 'users/42',
50
+ mime: 'image/png',
51
+ acl: ACL.public_read,
52
+ });
53
+
54
+ const signedUrl = await this.storage.getSignedUrl('avatar.png', 'users/42');
55
+ ```
56
+
57
+ Multipart:
58
+
59
+ ```ts
60
+ const init = await this.storage.createMultiPart('video.mp4', {
61
+ path: 'uploads',
62
+ mime: 'video/mp4',
63
+ });
64
+ ```
65
+
66
+ ## Serializzazioni utili
67
+
68
+ - `StorageFileSerialization`
69
+ - `StorageFileResponseSerialization`
70
+ - `StorageMultipartSerialization`
71
+ - `StorageMultipartPartsSerialization`
72
+
73
+ Sono utili come tipi di ritorno e per documentazione Swagger.
74
+
75
+ ## Note operative
76
+
77
+ - L'implementazione exportata e AWS S3; il file Azure esiste ma non e esportato dall'entrypoint.
78
+ - Il service esegue retry interni sul client S3.
79
+ - `getTextFromFile` forza `text/plain` ed e utile per leggere file testuali.
80
+
81
+ ## Export pubblici
82
+
83
+ ```ts
84
+ import {
85
+ ACL,
86
+ StorageAwsS3Service,
87
+ StorageModule,
88
+ } from '@tc-libs/storage';
89
+ ```
90
+
91
+ ## Sviluppo
92
+
93
+ ```bash
94
+ nx build storage
95
+ nx test storage
96
+ ```
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tc-libs/storage",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
- "@tc-libs/constant": "3.6.0",
5
+ "@tc-libs/constant": "3.8.0",
6
6
  "jsonc-eslint-parser": "2.4.0",
7
7
  "@aws-sdk/client-s3": "^3.779.0",
8
8
  "@faker-js/faker": "^9.6.0",