@tc-libs/storage 4.0.0 → 4.1.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 +96 -0
  2. package/package.json +10 -8
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @tc-libs/storage
2
+
3
+ Astrazione storage file con implementazione principale AWS S3.
4
+
5
+ Il package espone:
6
+
7
+ - `StorageModule`
8
+ - `StorageAwsS3Service`
9
+ - tipi e serializzazioni per upload/download/listing
10
+ - enum ACL
11
+
12
+ ## Registrazione
13
+
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,19 +1,21 @@
1
1
  {
2
2
  "name": "@tc-libs/storage",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "dependencies": {
5
- "@tc-libs/constant": "4.0.0",
6
- "jsonc-eslint-parser": "2.4.0",
7
5
  "@aws-sdk/client-s3": "^3.779.0",
8
- "@faker-js/faker": "^9.6.0",
9
- "@nestjs/swagger": "^11.1.0",
10
- "class-transformer": "^0.5.1",
11
- "@nestjs/common": "^11.0.12",
12
6
  "@aws-sdk/s3-request-presigner": "^3.779.0",
7
+ "@faker-js/faker": "^9.6.0",
8
+ "@tc-libs/constant": "4.1.0",
9
+ "jsonc-eslint-parser": "2.4.0",
13
10
  "tslib": "^2.8.1"
14
11
  },
15
12
  "type": "commonjs",
16
13
  "main": "./src/index.js",
17
14
  "typings": "./src/index.d.ts",
18
- "types": "./../packages/storage/src/index.d.ts"
15
+ "peerDependencies": {
16
+ "@nestjs/common": "^11.0.12",
17
+ "@nestjs/swagger": "^11.1.0",
18
+ "class-transformer": "^0.5.1"
19
+ },
20
+ "types": "./src/index.d.ts"
19
21
  }