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