alepha 0.10.6 → 0.10.7

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/api/files.d.ts CHANGED
@@ -2,245 +2,469 @@ import { BucketDescriptor } from "alepha/bucket";
2
2
  import * as _alepha_core1 from "alepha";
3
3
  import { Alepha, FileLike, Static } from "alepha";
4
4
  import "alepha/server/security";
5
- import * as _alepha_postgres83 from "alepha/postgres";
5
+ import * as _alepha_postgres50 from "alepha/postgres";
6
6
  import { Page } from "alepha/postgres";
7
7
  import * as _alepha_server0 from "alepha/server";
8
8
  import { Ok } from "alepha/server";
9
9
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
10
10
  import * as _alepha_logger0 from "alepha/logger";
11
11
  import { UserAccountToken } from "alepha/security";
12
- import * as typebox144 from "typebox";
12
+ import * as typebox68 from "typebox";
13
13
 
14
14
  //#region src/entities/files.d.ts
15
- declare const files: _alepha_postgres83.PgTableWithColumnsAndSchema<_alepha_postgres83.PgTableConfig<"files", typebox144.TObject<{
16
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
17
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
18
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
19
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
20
- blobId: typebox144.TString;
21
- creator: typebox144.TOptional<typebox144.TString>;
22
- creatorRealm: typebox144.TOptional<typebox144.TString>;
23
- creatorName: typebox144.TOptional<typebox144.TString>;
24
- bucket: typebox144.TString;
25
- expirationDate: typebox144.TOptional<typebox144.TString>;
26
- name: typebox144.TString;
27
- size: typebox144.TNumber;
28
- mimeType: typebox144.TString;
29
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
30
- checksum: typebox144.TOptional<typebox144.TString>;
31
- }>, _alepha_postgres83.FromSchema<typebox144.TObject<{
32
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
33
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
34
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
35
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
36
- blobId: typebox144.TString;
37
- creator: typebox144.TOptional<typebox144.TString>;
38
- creatorRealm: typebox144.TOptional<typebox144.TString>;
39
- creatorName: typebox144.TOptional<typebox144.TString>;
40
- bucket: typebox144.TString;
41
- expirationDate: typebox144.TOptional<typebox144.TString>;
42
- name: typebox144.TString;
43
- size: typebox144.TNumber;
44
- mimeType: typebox144.TString;
45
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
46
- checksum: typebox144.TOptional<typebox144.TString>;
47
- }>>>, typebox144.TObject<{
48
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
49
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
50
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
51
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
52
- blobId: typebox144.TString;
53
- creator: typebox144.TOptional<typebox144.TString>;
54
- creatorRealm: typebox144.TOptional<typebox144.TString>;
55
- creatorName: typebox144.TOptional<typebox144.TString>;
56
- bucket: typebox144.TString;
57
- expirationDate: typebox144.TOptional<typebox144.TString>;
58
- name: typebox144.TString;
59
- size: typebox144.TNumber;
60
- mimeType: typebox144.TString;
61
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
62
- checksum: typebox144.TOptional<typebox144.TString>;
15
+ declare const files: _alepha_postgres50.PgTableWithColumnsAndSchema<_alepha_postgres50.PgTableConfig<"files", typebox68.TObject<{
16
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
17
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
18
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
19
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
20
+ blobId: typebox68.TString;
21
+ creator: typebox68.TOptional<typebox68.TString>;
22
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
23
+ creatorName: typebox68.TOptional<typebox68.TString>;
24
+ bucket: typebox68.TString;
25
+ expirationDate: typebox68.TOptional<typebox68.TString>;
26
+ name: typebox68.TString;
27
+ size: typebox68.TNumber;
28
+ mimeType: typebox68.TString;
29
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
30
+ checksum: typebox68.TOptional<typebox68.TString>;
31
+ }>, _alepha_postgres50.FromSchema<typebox68.TObject<{
32
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
33
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
34
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
35
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
36
+ blobId: typebox68.TString;
37
+ creator: typebox68.TOptional<typebox68.TString>;
38
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
39
+ creatorName: typebox68.TOptional<typebox68.TString>;
40
+ bucket: typebox68.TString;
41
+ expirationDate: typebox68.TOptional<typebox68.TString>;
42
+ name: typebox68.TString;
43
+ size: typebox68.TNumber;
44
+ mimeType: typebox68.TString;
45
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
46
+ checksum: typebox68.TOptional<typebox68.TString>;
47
+ }>>>, typebox68.TObject<{
48
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
49
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
50
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
51
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
52
+ blobId: typebox68.TString;
53
+ creator: typebox68.TOptional<typebox68.TString>;
54
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
55
+ creatorName: typebox68.TOptional<typebox68.TString>;
56
+ bucket: typebox68.TString;
57
+ expirationDate: typebox68.TOptional<typebox68.TString>;
58
+ name: typebox68.TString;
59
+ size: typebox68.TNumber;
60
+ mimeType: typebox68.TString;
61
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
62
+ checksum: typebox68.TOptional<typebox68.TString>;
63
63
  }>>;
64
64
  type FileEntity = Static<typeof files.$schema>;
65
65
  //#endregion
66
66
  //#region src/schemas/fileQuerySchema.d.ts
67
- declare const fileQuerySchema: typebox144.TObject<{
68
- page: typebox144.TOptional<typebox144.TInteger>;
69
- size: typebox144.TOptional<typebox144.TInteger>;
70
- sort: typebox144.TOptional<typebox144.TString>;
71
- bucket: typebox144.TOptional<typebox144.TString>;
72
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
67
+ declare const fileQuerySchema: typebox68.TObject<{
68
+ page: typebox68.TOptional<typebox68.TInteger>;
69
+ size: typebox68.TOptional<typebox68.TInteger>;
70
+ sort: typebox68.TOptional<typebox68.TString>;
71
+ bucket: typebox68.TOptional<typebox68.TString>;
72
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
73
+ name: typebox68.TOptional<typebox68.TString>;
74
+ mimeType: typebox68.TOptional<typebox68.TString>;
75
+ creator: typebox68.TOptional<typebox68.TString>;
76
+ createdAfter: typebox68.TOptional<typebox68.TString>;
77
+ createdBefore: typebox68.TOptional<typebox68.TString>;
73
78
  }>;
74
79
  type FileQuery = Static<typeof fileQuerySchema>;
75
80
  //#endregion
76
81
  //#region src/schemas/fileResourceSchema.d.ts
77
- declare const fileResourceSchema: typebox144.TObject<{
78
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
79
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
80
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
81
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
82
- blobId: typebox144.TString;
83
- creator: typebox144.TOptional<typebox144.TString>;
84
- creatorRealm: typebox144.TOptional<typebox144.TString>;
85
- creatorName: typebox144.TOptional<typebox144.TString>;
86
- bucket: typebox144.TString;
87
- expirationDate: typebox144.TOptional<typebox144.TString>;
88
- name: typebox144.TString;
89
- size: typebox144.TNumber;
90
- mimeType: typebox144.TString;
91
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
92
- checksum: typebox144.TOptional<typebox144.TString>;
82
+ declare const fileResourceSchema: typebox68.TObject<{
83
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
84
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
85
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
86
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
87
+ blobId: typebox68.TString;
88
+ creator: typebox68.TOptional<typebox68.TString>;
89
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
90
+ creatorName: typebox68.TOptional<typebox68.TString>;
91
+ bucket: typebox68.TString;
92
+ expirationDate: typebox68.TOptional<typebox68.TString>;
93
+ name: typebox68.TString;
94
+ size: typebox68.TNumber;
95
+ mimeType: typebox68.TString;
96
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
97
+ checksum: typebox68.TOptional<typebox68.TString>;
93
98
  }>;
94
99
  type FileResource = Static<typeof fileResourceSchema>;
95
100
  //#endregion
101
+ //#region src/schemas/storageStatsSchema.d.ts
102
+ declare const bucketStatsSchema: typebox68.TObject<{
103
+ bucket: typebox68.TString;
104
+ totalSize: typebox68.TNumber;
105
+ fileCount: typebox68.TNumber;
106
+ }>;
107
+ declare const mimeTypeStatsSchema: typebox68.TObject<{
108
+ mimeType: typebox68.TString;
109
+ fileCount: typebox68.TNumber;
110
+ }>;
111
+ declare const storageStatsSchema: typebox68.TObject<{
112
+ totalSize: typebox68.TNumber;
113
+ totalFiles: typebox68.TNumber;
114
+ byBucket: typebox68.TArray<typebox68.TObject<{
115
+ bucket: typebox68.TString;
116
+ totalSize: typebox68.TNumber;
117
+ fileCount: typebox68.TNumber;
118
+ }>>;
119
+ byMimeType: typebox68.TArray<typebox68.TObject<{
120
+ mimeType: typebox68.TString;
121
+ fileCount: typebox68.TNumber;
122
+ }>>;
123
+ }>;
124
+ type BucketStats = Static<typeof bucketStatsSchema>;
125
+ type MimeTypeStats = Static<typeof mimeTypeStatsSchema>;
126
+ type StorageStats = Static<typeof storageStatsSchema>;
127
+ //#endregion
96
128
  //#region src/services/FileService.d.ts
97
129
  declare class FileService {
98
130
  protected readonly alepha: Alepha;
99
131
  protected readonly log: _alepha_logger0.Logger;
100
- protected readonly fileRepository: _alepha_postgres83.RepositoryDescriptor<_alepha_postgres83.PgTableConfig<"files", typebox144.TObject<{
101
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
102
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
103
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
104
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
105
- blobId: typebox144.TString;
106
- creator: typebox144.TOptional<typebox144.TString>;
107
- creatorRealm: typebox144.TOptional<typebox144.TString>;
108
- creatorName: typebox144.TOptional<typebox144.TString>;
109
- bucket: typebox144.TString;
110
- expirationDate: typebox144.TOptional<typebox144.TString>;
111
- name: typebox144.TString;
112
- size: typebox144.TNumber;
113
- mimeType: typebox144.TString;
114
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
115
- checksum: typebox144.TOptional<typebox144.TString>;
116
- }>, _alepha_postgres83.FromSchema<typebox144.TObject<{
117
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
118
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
119
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
120
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
121
- blobId: typebox144.TString;
122
- creator: typebox144.TOptional<typebox144.TString>;
123
- creatorRealm: typebox144.TOptional<typebox144.TString>;
124
- creatorName: typebox144.TOptional<typebox144.TString>;
125
- bucket: typebox144.TString;
126
- expirationDate: typebox144.TOptional<typebox144.TString>;
127
- name: typebox144.TString;
128
- size: typebox144.TNumber;
129
- mimeType: typebox144.TString;
130
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
131
- checksum: typebox144.TOptional<typebox144.TString>;
132
- }>>>, typebox144.TObject<{
133
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
134
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
135
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
136
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
137
- blobId: typebox144.TString;
138
- creator: typebox144.TOptional<typebox144.TString>;
139
- creatorRealm: typebox144.TOptional<typebox144.TString>;
140
- creatorName: typebox144.TOptional<typebox144.TString>;
141
- bucket: typebox144.TString;
142
- expirationDate: typebox144.TOptional<typebox144.TString>;
143
- name: typebox144.TString;
144
- size: typebox144.TNumber;
145
- mimeType: typebox144.TString;
146
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
147
- checksum: typebox144.TOptional<typebox144.TString>;
132
+ protected readonly fileRepository: _alepha_postgres50.RepositoryDescriptor<_alepha_postgres50.PgTableConfig<"files", typebox68.TObject<{
133
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
134
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
135
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
136
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
137
+ blobId: typebox68.TString;
138
+ creator: typebox68.TOptional<typebox68.TString>;
139
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
140
+ creatorName: typebox68.TOptional<typebox68.TString>;
141
+ bucket: typebox68.TString;
142
+ expirationDate: typebox68.TOptional<typebox68.TString>;
143
+ name: typebox68.TString;
144
+ size: typebox68.TNumber;
145
+ mimeType: typebox68.TString;
146
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
147
+ checksum: typebox68.TOptional<typebox68.TString>;
148
+ }>, _alepha_postgres50.FromSchema<typebox68.TObject<{
149
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
150
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
151
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
152
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
153
+ blobId: typebox68.TString;
154
+ creator: typebox68.TOptional<typebox68.TString>;
155
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
156
+ creatorName: typebox68.TOptional<typebox68.TString>;
157
+ bucket: typebox68.TString;
158
+ expirationDate: typebox68.TOptional<typebox68.TString>;
159
+ name: typebox68.TString;
160
+ size: typebox68.TNumber;
161
+ mimeType: typebox68.TString;
162
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
163
+ checksum: typebox68.TOptional<typebox68.TString>;
164
+ }>>>, typebox68.TObject<{
165
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
166
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
167
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
168
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
169
+ blobId: typebox68.TString;
170
+ creator: typebox68.TOptional<typebox68.TString>;
171
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
172
+ creatorName: typebox68.TOptional<typebox68.TString>;
173
+ bucket: typebox68.TString;
174
+ expirationDate: typebox68.TOptional<typebox68.TString>;
175
+ name: typebox68.TString;
176
+ size: typebox68.TNumber;
177
+ mimeType: typebox68.TString;
178
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
179
+ checksum: typebox68.TOptional<typebox68.TString>;
148
180
  }>>;
149
181
  protected readonly dateTimeProvider: DateTimeProvider;
150
182
  protected readonly defaultBucket: BucketDescriptor;
151
183
  protected onUploadFile: _alepha_core1.HookDescriptor<"bucket:file:uploaded">;
152
184
  protected onDeleteBucketFile: _alepha_core1.HookDescriptor<"bucket:file:deleted">;
185
+ /**
186
+ * Calculates SHA-256 checksum of a file.
187
+ *
188
+ * @param file - The file to calculate checksum for
189
+ * @returns Hexadecimal string representation of the SHA-256 hash
190
+ * @protected
191
+ */
192
+ protected calculateChecksum(file: FileLike): Promise<string>;
193
+ /**
194
+ * Gets a bucket descriptor by name.
195
+ *
196
+ * @param bucketName - The name of the bucket to retrieve (defaults to "default")
197
+ * @returns The bucket descriptor
198
+ * @throws {NotFoundError} If the bucket is not found
199
+ */
153
200
  bucket(bucketName?: string): BucketDescriptor;
201
+ /**
202
+ * Finds files matching the given query criteria with pagination support.
203
+ * Supports filtering by bucket, tags, name, mimeType, creator, and date range.
204
+ *
205
+ * @param q - Query parameters including bucket, tags, name, mimeType, creator, date range, pagination, and sorting
206
+ * @returns Paginated list of file entities
207
+ */
154
208
  findFiles(q?: FileQuery): Promise<Page<FileEntity>>;
209
+ /**
210
+ * Finds files that have expired based on their expiration date.
211
+ * Limited to 1000 files per call to prevent memory issues.
212
+ *
213
+ * @returns Array of expired file entities
214
+ */
155
215
  findExpiredFiles(): Promise<FileEntity[]>;
216
+ /**
217
+ * Calculates an expiration date based on a TTL (time to live) duration.
218
+ *
219
+ * @param ttl - Duration like "1 day", "2 hours", etc.
220
+ * @returns ISO string representation of the expiration date, or undefined if no TTL provided
221
+ * @protected
222
+ */
156
223
  protected getExpirationDate(ttl?: DurationLike): string | undefined;
224
+ /**
225
+ * Uploads a file to a bucket and creates a database record with metadata.
226
+ * Automatically calculates and stores the file checksum (SHA-256).
227
+ *
228
+ * @param file - The file to upload
229
+ * @param options - Upload options including bucket, expiration, user, and tags
230
+ * @param options.bucket - Target bucket name (defaults to "default")
231
+ * @param options.expirationDate - When the file should expire
232
+ * @param options.user - User performing the upload (for audit trail)
233
+ * @param options.tags - Tags to associate with the file
234
+ * @returns The created file entity with all metadata
235
+ * @throws {NotFoundError} If the specified bucket doesn't exist
236
+ */
157
237
  uploadFile(file: FileLike, options?: {
158
238
  expirationDate?: string | Date;
159
239
  bucket?: string;
160
240
  user?: UserAccountToken;
161
241
  tags?: string[];
162
242
  }): Promise<FileEntity>;
243
+ /**
244
+ * Streams a file from storage by its database ID.
245
+ *
246
+ * @param id - The database ID (UUID) of the file to stream
247
+ * @returns The file object ready for streaming/downloading
248
+ * @throws {NotFoundError} If the file doesn't exist in the database
249
+ * @throws {FileNotFoundError} If the file exists in database but not in storage
250
+ */
163
251
  streamFile(id: string): Promise<FileLike>;
252
+ /**
253
+ * Updates file metadata (name, tags, expiration date).
254
+ * Does not modify the actual file content in storage.
255
+ *
256
+ * @param id - The database ID (UUID) of the file to update
257
+ * @param data - Partial file data to update
258
+ * @param data.name - New file name
259
+ * @param data.tags - New tags array
260
+ * @param data.expirationDate - New expiration date
261
+ * @returns The updated file entity
262
+ * @throws {NotFoundError} If the file doesn't exist in the database
263
+ */
264
+ updateFile(id: string, data: {
265
+ name?: string;
266
+ tags?: string[];
267
+ expirationDate?: string | Date;
268
+ }): Promise<FileEntity>;
269
+ /**
270
+ * Deletes a file from both storage and database.
271
+ * Handles cases where file is already deleted from storage gracefully.
272
+ * Always ensures database record is removed even if storage deletion fails.
273
+ *
274
+ * @param id - The database ID (UUID) of the file to delete
275
+ * @returns Success response with the deleted file ID
276
+ * @throws {NotFoundError} If the file doesn't exist in the database
277
+ */
164
278
  deleteFile(id: string): Promise<Ok>;
279
+ /**
280
+ * Retrieves a file entity by its ID.
281
+ * If already an entity object, returns it as-is (convenience method).
282
+ *
283
+ * @param id - Either a UUID string or an existing FileEntity object
284
+ * @returns The file entity
285
+ * @throws {NotFoundError} If the file doesn't exist in the database
286
+ */
165
287
  getFileById(id: string | FileEntity): Promise<FileEntity>;
288
+ /**
289
+ * Gets storage statistics including total size, file count, and breakdowns by bucket and MIME type.
290
+ *
291
+ * @returns Storage statistics with aggregated data
292
+ */
293
+ getStorageStats(): Promise<StorageStats>;
294
+ /**
295
+ * Converts a file entity to a file resource (API response format).
296
+ * Currently a pass-through, but allows for future transformation logic.
297
+ *
298
+ * @param entity - The file entity to convert
299
+ * @returns The file resource for API responses
300
+ */
166
301
  entityToResource(entity: FileEntity): FileResource;
167
302
  }
168
303
  //#endregion
169
304
  //#region src/controllers/FileController.d.ts
305
+ /**
306
+ * REST API controller for file management operations.
307
+ * Provides endpoints for uploading, downloading, listing, and deleting files.
308
+ */
170
309
  declare class FileController {
171
310
  protected readonly url = "/files";
172
311
  protected readonly group = "files";
173
312
  protected readonly fileService: FileService;
313
+ /**
314
+ * GET /files - Lists files with optional filtering and pagination.
315
+ * Supports filtering by bucket and tags.
316
+ */
174
317
  readonly findFiles: _alepha_server0.ActionDescriptorFn<{
175
- query: typebox144.TObject<{
176
- page: typebox144.TOptional<typebox144.TInteger>;
177
- size: typebox144.TOptional<typebox144.TInteger>;
178
- sort: typebox144.TOptional<typebox144.TString>;
179
- bucket: typebox144.TOptional<typebox144.TString>;
180
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
318
+ query: typebox68.TObject<{
319
+ page: typebox68.TOptional<typebox68.TInteger>;
320
+ size: typebox68.TOptional<typebox68.TInteger>;
321
+ sort: typebox68.TOptional<typebox68.TString>;
322
+ bucket: typebox68.TOptional<typebox68.TString>;
323
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
324
+ name: typebox68.TOptional<typebox68.TString>;
325
+ mimeType: typebox68.TOptional<typebox68.TString>;
326
+ creator: typebox68.TOptional<typebox68.TString>;
327
+ createdAfter: typebox68.TOptional<typebox68.TString>;
328
+ createdBefore: typebox68.TOptional<typebox68.TString>;
181
329
  }>;
182
- response: _alepha_postgres83.TPage<typebox144.TObject<{
183
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
184
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
185
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
186
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
187
- blobId: typebox144.TString;
188
- creator: typebox144.TOptional<typebox144.TString>;
189
- creatorRealm: typebox144.TOptional<typebox144.TString>;
190
- creatorName: typebox144.TOptional<typebox144.TString>;
191
- bucket: typebox144.TString;
192
- expirationDate: typebox144.TOptional<typebox144.TString>;
193
- name: typebox144.TString;
194
- size: typebox144.TNumber;
195
- mimeType: typebox144.TString;
196
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
197
- checksum: typebox144.TOptional<typebox144.TString>;
330
+ response: _alepha_postgres50.TPage<typebox68.TObject<{
331
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
332
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
333
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
334
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
335
+ blobId: typebox68.TString;
336
+ creator: typebox68.TOptional<typebox68.TString>;
337
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
338
+ creatorName: typebox68.TOptional<typebox68.TString>;
339
+ bucket: typebox68.TString;
340
+ expirationDate: typebox68.TOptional<typebox68.TString>;
341
+ name: typebox68.TString;
342
+ size: typebox68.TNumber;
343
+ mimeType: typebox68.TString;
344
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
345
+ checksum: typebox68.TOptional<typebox68.TString>;
198
346
  }>>;
199
347
  }>;
348
+ /**
349
+ * DELETE /files/:id - Deletes a file from both storage and database.
350
+ * Removes the file from the bucket and cleans up the database record.
351
+ */
200
352
  readonly deleteFile: _alepha_server0.ActionDescriptorFn<{
201
- params: typebox144.TObject<{
202
- id: typebox144.TString;
353
+ params: typebox68.TObject<{
354
+ id: typebox68.TString;
203
355
  }>;
204
- response: typebox144.TObject<{
205
- ok: typebox144.TBoolean;
206
- id: typebox144.TOptional<typebox144.TUnion<[typebox144.TString, typebox144.TInteger]>>;
207
- count: typebox144.TOptional<typebox144.TNumber>;
356
+ response: typebox68.TObject<{
357
+ ok: typebox68.TBoolean;
358
+ id: typebox68.TOptional<typebox68.TUnion<[typebox68.TString, typebox68.TInteger]>>;
359
+ count: typebox68.TOptional<typebox68.TNumber>;
208
360
  }>;
209
361
  }>;
362
+ /**
363
+ * POST /files - Uploads a new file to storage.
364
+ * Creates a database record with metadata and calculates checksum.
365
+ * Optionally specify bucket and expiration date.
366
+ */
210
367
  readonly uploadFile: _alepha_server0.ActionDescriptorFn<{
211
- body: typebox144.TObject<{
368
+ body: typebox68.TObject<{
212
369
  file: _alepha_core1.TFile;
213
370
  }>;
214
- query: typebox144.TObject<{
215
- expirationDate: typebox144.TOptional<typebox144.TString>;
216
- bucket: typebox144.TOptional<typebox144.TString>;
371
+ query: typebox68.TObject<{
372
+ expirationDate: typebox68.TOptional<typebox68.TString>;
373
+ bucket: typebox68.TOptional<typebox68.TString>;
217
374
  }>;
218
- response: typebox144.TObject<{
219
- id: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_PRIMARY_KEY>, typeof _alepha_postgres83.PG_DEFAULT>;
220
- version: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TInteger, typeof _alepha_postgres83.PG_VERSION>, typeof _alepha_postgres83.PG_DEFAULT>;
221
- createdAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_CREATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
222
- updatedAt: _alepha_postgres83.PgAttr<_alepha_postgres83.PgAttr<typebox144.TString, typeof _alepha_postgres83.PG_UPDATED_AT>, typeof _alepha_postgres83.PG_DEFAULT>;
223
- blobId: typebox144.TString;
224
- creator: typebox144.TOptional<typebox144.TString>;
225
- creatorRealm: typebox144.TOptional<typebox144.TString>;
226
- creatorName: typebox144.TOptional<typebox144.TString>;
227
- bucket: typebox144.TString;
228
- expirationDate: typebox144.TOptional<typebox144.TString>;
229
- name: typebox144.TString;
230
- size: typebox144.TNumber;
231
- mimeType: typebox144.TString;
232
- tags: typebox144.TOptional<typebox144.TArray<typebox144.TString>>;
233
- checksum: typebox144.TOptional<typebox144.TString>;
375
+ response: typebox68.TObject<{
376
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
377
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
378
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
379
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
380
+ blobId: typebox68.TString;
381
+ creator: typebox68.TOptional<typebox68.TString>;
382
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
383
+ creatorName: typebox68.TOptional<typebox68.TString>;
384
+ bucket: typebox68.TString;
385
+ expirationDate: typebox68.TOptional<typebox68.TString>;
386
+ name: typebox68.TString;
387
+ size: typebox68.TNumber;
388
+ mimeType: typebox68.TString;
389
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
390
+ checksum: typebox68.TOptional<typebox68.TString>;
234
391
  }>;
235
392
  }>;
393
+ /**
394
+ * PATCH /files/:id - Updates file metadata.
395
+ * Allows updating name, tags, and expiration date without modifying file content.
396
+ */
397
+ readonly updateFile: _alepha_server0.ActionDescriptorFn<{
398
+ params: typebox68.TObject<{
399
+ id: typebox68.TString;
400
+ }>;
401
+ body: typebox68.TObject<{
402
+ name: typebox68.TOptional<typebox68.TString>;
403
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
404
+ expirationDate: typebox68.TOptional<typebox68.TString>;
405
+ }>;
406
+ response: typebox68.TObject<{
407
+ id: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_PRIMARY_KEY>, typeof _alepha_postgres50.PG_DEFAULT>;
408
+ version: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TInteger, typeof _alepha_postgres50.PG_VERSION>, typeof _alepha_postgres50.PG_DEFAULT>;
409
+ createdAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_CREATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
410
+ updatedAt: _alepha_postgres50.PgAttr<_alepha_postgres50.PgAttr<typebox68.TString, typeof _alepha_postgres50.PG_UPDATED_AT>, typeof _alepha_postgres50.PG_DEFAULT>;
411
+ blobId: typebox68.TString;
412
+ creator: typebox68.TOptional<typebox68.TString>;
413
+ creatorRealm: typebox68.TOptional<typebox68.TString>;
414
+ creatorName: typebox68.TOptional<typebox68.TString>;
415
+ bucket: typebox68.TString;
416
+ expirationDate: typebox68.TOptional<typebox68.TString>;
417
+ name: typebox68.TString;
418
+ size: typebox68.TNumber;
419
+ mimeType: typebox68.TString;
420
+ tags: typebox68.TOptional<typebox68.TArray<typebox68.TString>>;
421
+ checksum: typebox68.TOptional<typebox68.TString>;
422
+ }>;
423
+ }>;
424
+ /**
425
+ * GET /files/:id - Streams/downloads a file by its ID.
426
+ * Returns the file content with appropriate Content-Type header.
427
+ * Cached with ETag support for 1 year (immutable).
428
+ */
236
429
  readonly streamFile: _alepha_server0.ActionDescriptorFn<{
237
- params: typebox144.TObject<{
238
- id: typebox144.TString;
430
+ params: typebox68.TObject<{
431
+ id: typebox68.TString;
239
432
  }>;
240
433
  response: _alepha_core1.TFile;
241
434
  }>;
242
435
  }
243
436
  //#endregion
437
+ //#region src/controllers/StorageStatsController.d.ts
438
+ /**
439
+ * REST API controller for storage analytics and statistics.
440
+ * Provides endpoints for viewing storage usage metrics.
441
+ */
442
+ declare class StorageStatsController {
443
+ protected readonly url = "/files/stats";
444
+ protected readonly group = "files";
445
+ protected readonly fileService: FileService;
446
+ /**
447
+ * GET /files/stats - Gets storage statistics.
448
+ * Returns aggregated data including total size, file count,
449
+ * and breakdowns by bucket and MIME type.
450
+ */
451
+ readonly getStats: _alepha_server0.ActionDescriptorFn<{
452
+ response: typebox68.TObject<{
453
+ totalSize: typebox68.TNumber;
454
+ totalFiles: typebox68.TNumber;
455
+ byBucket: typebox68.TArray<typebox68.TObject<{
456
+ bucket: typebox68.TString;
457
+ totalSize: typebox68.TNumber;
458
+ fileCount: typebox68.TNumber;
459
+ }>>;
460
+ byMimeType: typebox68.TArray<typebox68.TObject<{
461
+ mimeType: typebox68.TString;
462
+ fileCount: typebox68.TNumber;
463
+ }>>;
464
+ }>;
465
+ }>;
466
+ }
467
+ //#endregion
244
468
  //#region src/index.d.ts
245
469
  declare module "alepha/bucket" {
246
470
  interface BucketFileOptions {
@@ -274,5 +498,5 @@ declare module "alepha/bucket" {
274
498
  */
275
499
  declare const AlephaApiFiles: _alepha_core1.Service<_alepha_core1.Module<{}>>;
276
500
  //#endregion
277
- export { AlephaApiFiles, FileController, FileEntity, FileService, files };
501
+ export { AlephaApiFiles, BucketStats, FileController, FileEntity, FileService, MimeTypeStats, StorageStats, StorageStatsController, bucketStatsSchema, files, mimeTypeStatsSchema, storageStatsSchema };
278
502
  //# sourceMappingURL=index.d.ts.map