alepha 0.13.0 → 0.13.1
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/dist/api-jobs/index.d.ts +26 -26
- package/dist/api-users/index.d.ts +1 -1
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +3 -11
- package/dist/cli/index.js +106 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/email/index.js +71 -73
- package/dist/email/index.js.map +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/retry/index.d.ts +1 -1
- package/dist/retry/index.js +2 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/security/index.d.ts +28 -28
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server-health/index.d.ts +17 -17
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-security/index.d.ts +9 -9
- package/dist/vite/index.js +4 -5
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/package.json +52 -103
- package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +65 -57
- package/src/cli/commands/VerifyCommands.ts +1 -1
- package/src/cli/services/ProjectUtils.ts +44 -38
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/retry/descriptors/$retry.ts +5 -3
- package/src/server/providers/NodeHttpServerProvider.ts +1 -1
- package/src/vite/helpers/boot.ts +3 -3
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs +0 -2264
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
|
@@ -1,829 +0,0 @@
|
|
|
1
|
-
import * as alepha160 from "alepha";
|
|
2
|
-
import { Alepha, FileLike, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
|
|
3
|
-
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
4
|
-
import { UserAccount, UserAccountToken } from "alepha/security";
|
|
5
|
-
import * as alepha_orm64 from "alepha/orm";
|
|
6
|
-
import { Page } from "alepha/orm";
|
|
7
|
-
import * as alepha_server0 from "alepha/server";
|
|
8
|
-
import { FetchOptions, Ok } from "alepha/server";
|
|
9
|
-
import * as alepha_logger0 from "alepha/logger";
|
|
10
|
-
import { BucketDescriptor } from "alepha/bucket";
|
|
11
|
-
import { BuildExtraConfigColumns, SQL } from "drizzle-orm";
|
|
12
|
-
import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
13
|
-
import "alepha/retry";
|
|
14
|
-
import "alepha/lock";
|
|
15
|
-
|
|
16
|
-
//#region src/api-files/entities/files.d.ts
|
|
17
|
-
declare const files: alepha_orm64.EntityDescriptor<alepha160.TObject<{
|
|
18
|
-
id: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_PRIMARY_KEY>, typeof alepha_orm64.PG_DEFAULT>;
|
|
19
|
-
version: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TInteger, typeof alepha_orm64.PG_VERSION>, typeof alepha_orm64.PG_DEFAULT>;
|
|
20
|
-
createdAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_CREATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
21
|
-
updatedAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_UPDATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
22
|
-
blobId: alepha160.TString;
|
|
23
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
24
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
25
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
26
|
-
bucket: alepha160.TString;
|
|
27
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
28
|
-
name: alepha160.TString;
|
|
29
|
-
size: alepha160.TNumber;
|
|
30
|
-
mimeType: alepha160.TString;
|
|
31
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
32
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
33
|
-
}>>;
|
|
34
|
-
type FileEntity = Static<typeof files.schema>;
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/api-files/schemas/fileQuerySchema.d.ts
|
|
37
|
-
declare const fileQuerySchema: alepha160.TObject<{
|
|
38
|
-
page: alepha160.TOptional<alepha160.TInteger>;
|
|
39
|
-
size: alepha160.TOptional<alepha160.TInteger>;
|
|
40
|
-
sort: alepha160.TOptional<alepha160.TString>;
|
|
41
|
-
bucket: alepha160.TOptional<alepha160.TString>;
|
|
42
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
43
|
-
name: alepha160.TOptional<alepha160.TString>;
|
|
44
|
-
mimeType: alepha160.TOptional<alepha160.TString>;
|
|
45
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
46
|
-
createdAfter: alepha160.TOptional<alepha160.TString>;
|
|
47
|
-
createdBefore: alepha160.TOptional<alepha160.TString>;
|
|
48
|
-
}>;
|
|
49
|
-
type FileQuery = Static<typeof fileQuerySchema>;
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/orm/schemas/insertSchema.d.ts
|
|
52
|
-
/**
|
|
53
|
-
* Transforms a TObject schema for insert operations.
|
|
54
|
-
* All default properties at the root level are made optional.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* Before: { name: string; age: number(default=0); }
|
|
58
|
-
* After: { name: string; age?: number; }
|
|
59
|
-
*/
|
|
60
|
-
type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends {
|
|
61
|
-
[PG_DEFAULT]: any;
|
|
62
|
-
} | {
|
|
63
|
-
"~optional": true;
|
|
64
|
-
} ? TOptional<T["properties"][K]> : T["properties"][K] }>;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/orm/schemas/updateSchema.d.ts
|
|
67
|
-
/**
|
|
68
|
-
* Transforms a TObject schema for update operations.
|
|
69
|
-
* All optional properties at the root level are made nullable (i.e., `T | null`).
|
|
70
|
-
* This allows an API endpoint to explicitly accept `null` to clear an optional field in the database.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* Before: { name?: string; age: number; }
|
|
74
|
-
* After: { name?: string | null; age: number; }
|
|
75
|
-
*/
|
|
76
|
-
type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/orm/descriptors/$entity.d.ts
|
|
79
|
-
interface EntityDescriptorOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
80
|
-
/**
|
|
81
|
-
* The database table name that will be created for this entity.
|
|
82
|
-
* If not provided, name will be inferred from the $repository variable name.
|
|
83
|
-
*/
|
|
84
|
-
name: string;
|
|
85
|
-
/**
|
|
86
|
-
* TypeBox schema defining the table structure and column types.
|
|
87
|
-
*/
|
|
88
|
-
schema: T;
|
|
89
|
-
/**
|
|
90
|
-
* Database indexes to create for query optimization.
|
|
91
|
-
*/
|
|
92
|
-
indexes?: (Keys | {
|
|
93
|
-
/**
|
|
94
|
-
* Single column to index.
|
|
95
|
-
*/
|
|
96
|
-
column: Keys;
|
|
97
|
-
/**
|
|
98
|
-
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
99
|
-
*/
|
|
100
|
-
unique?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Custom name for the index. If not provided, generates name automatically.
|
|
103
|
-
*/
|
|
104
|
-
name?: string;
|
|
105
|
-
} | {
|
|
106
|
-
/**
|
|
107
|
-
* Multiple columns for composite index (order matters for query optimization).
|
|
108
|
-
*/
|
|
109
|
-
columns: Keys[];
|
|
110
|
-
/**
|
|
111
|
-
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
112
|
-
*/
|
|
113
|
-
unique?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Custom name for the index. If not provided, generates name automatically.
|
|
116
|
-
*/
|
|
117
|
-
name?: string;
|
|
118
|
-
})[];
|
|
119
|
-
/**
|
|
120
|
-
* Foreign key constraints to maintain referential integrity.
|
|
121
|
-
*/
|
|
122
|
-
foreignKeys?: Array<{
|
|
123
|
-
/**
|
|
124
|
-
* Optional name for the foreign key constraint.
|
|
125
|
-
*/
|
|
126
|
-
name?: string;
|
|
127
|
-
/**
|
|
128
|
-
* Local columns that reference the foreign table.
|
|
129
|
-
*/
|
|
130
|
-
columns: Array<keyof Static<T>>;
|
|
131
|
-
/**
|
|
132
|
-
* Referenced columns in the foreign table.
|
|
133
|
-
* Must be EntityColumn references from other entities.
|
|
134
|
-
*/
|
|
135
|
-
foreignColumns: Array<() => EntityColumn<any>>;
|
|
136
|
-
}>;
|
|
137
|
-
/**
|
|
138
|
-
* Additional table constraints for data validation.
|
|
139
|
-
*
|
|
140
|
-
* Constraints enforce business rules at the database level, providing
|
|
141
|
-
* an additional layer of data integrity beyond application validation.
|
|
142
|
-
*
|
|
143
|
-
* **Constraint Types**:
|
|
144
|
-
* - **Unique constraints**: Prevent duplicate values across columns
|
|
145
|
-
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```ts
|
|
149
|
-
* constraints: [
|
|
150
|
-
* {
|
|
151
|
-
* name: "unique_user_email",
|
|
152
|
-
* columns: ["email"],
|
|
153
|
-
* unique: true
|
|
154
|
-
* },
|
|
155
|
-
* {
|
|
156
|
-
* name: "valid_age_range",
|
|
157
|
-
* columns: ["age"],
|
|
158
|
-
* check: sql`age >= 0 AND age <= 150`
|
|
159
|
-
* },
|
|
160
|
-
* {
|
|
161
|
-
* name: "unique_user_username_per_tenant",
|
|
162
|
-
* columns: ["tenantId", "username"],
|
|
163
|
-
* unique: true
|
|
164
|
-
* }
|
|
165
|
-
* ]
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
constraints?: Array<{
|
|
169
|
-
/**
|
|
170
|
-
* Columns involved in this constraint.
|
|
171
|
-
*/
|
|
172
|
-
columns: Array<keyof Static<T>>;
|
|
173
|
-
/**
|
|
174
|
-
* Optional name for the constraint.
|
|
175
|
-
*/
|
|
176
|
-
name?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Whether this is a unique constraint.
|
|
179
|
-
*/
|
|
180
|
-
unique?: boolean | {};
|
|
181
|
-
/**
|
|
182
|
-
* SQL expression for check constraint validation.
|
|
183
|
-
*/
|
|
184
|
-
check?: SQL;
|
|
185
|
-
}>;
|
|
186
|
-
/**
|
|
187
|
-
* Advanced Drizzle ORM configuration for complex table setups.
|
|
188
|
-
*/
|
|
189
|
-
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
190
|
-
}
|
|
191
|
-
declare class EntityDescriptor<T extends TObject = TObject> {
|
|
192
|
-
readonly options: EntityDescriptorOptions<T>;
|
|
193
|
-
constructor(options: EntityDescriptorOptions<T>);
|
|
194
|
-
alias(alias: string): this;
|
|
195
|
-
get cols(): EntityColumns<T>;
|
|
196
|
-
get name(): string;
|
|
197
|
-
get schema(): T;
|
|
198
|
-
get insertSchema(): TObjectInsert<T>;
|
|
199
|
-
get updateSchema(): TObjectUpdate<T>;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Convert a schema to columns.
|
|
203
|
-
*/
|
|
204
|
-
type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
|
|
205
|
-
type EntityColumn<T extends TObject> = {
|
|
206
|
-
name: string;
|
|
207
|
-
entity: EntityDescriptor<T>;
|
|
208
|
-
};
|
|
209
|
-
type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region src/orm/constants/PG_SYMBOLS.d.ts
|
|
212
|
-
declare const PG_DEFAULT: unique symbol;
|
|
213
|
-
declare const PG_PRIMARY_KEY: unique symbol;
|
|
214
|
-
declare const PG_CREATED_AT: unique symbol;
|
|
215
|
-
declare const PG_UPDATED_AT: unique symbol;
|
|
216
|
-
declare const PG_DELETED_AT: unique symbol;
|
|
217
|
-
declare const PG_VERSION: unique symbol;
|
|
218
|
-
declare const PG_IDENTITY: unique symbol;
|
|
219
|
-
declare const PG_ENUM: unique symbol;
|
|
220
|
-
declare const PG_REF: unique symbol;
|
|
221
|
-
/**
|
|
222
|
-
* @deprecated Use `PG_IDENTITY` instead.
|
|
223
|
-
*/
|
|
224
|
-
declare const PG_SERIAL: unique symbol;
|
|
225
|
-
type PgSymbols = {
|
|
226
|
-
[PG_DEFAULT]: {};
|
|
227
|
-
[PG_PRIMARY_KEY]: {};
|
|
228
|
-
[PG_CREATED_AT]: {};
|
|
229
|
-
[PG_UPDATED_AT]: {};
|
|
230
|
-
[PG_DELETED_AT]: {};
|
|
231
|
-
[PG_VERSION]: {};
|
|
232
|
-
[PG_IDENTITY]: PgIdentityOptions;
|
|
233
|
-
[PG_REF]: PgRefOptions;
|
|
234
|
-
[PG_ENUM]: PgEnumOptions;
|
|
235
|
-
/**
|
|
236
|
-
* @deprecated Use `PG_IDENTITY` instead.
|
|
237
|
-
*/
|
|
238
|
-
[PG_SERIAL]: {};
|
|
239
|
-
};
|
|
240
|
-
type PgSymbolKeys = keyof PgSymbols;
|
|
241
|
-
type PgIdentityOptions = {
|
|
242
|
-
mode: "always" | "byDefault";
|
|
243
|
-
} & PgSequenceOptions & {
|
|
244
|
-
name?: string;
|
|
245
|
-
};
|
|
246
|
-
interface PgEnumOptions {
|
|
247
|
-
name?: string;
|
|
248
|
-
description?: string;
|
|
249
|
-
}
|
|
250
|
-
interface PgRefOptions {
|
|
251
|
-
ref: () => {
|
|
252
|
-
name: string;
|
|
253
|
-
entity: EntityDescriptor;
|
|
254
|
-
};
|
|
255
|
-
actions?: {
|
|
256
|
-
onUpdate?: UpdateDeleteAction;
|
|
257
|
-
onDelete?: UpdateDeleteAction;
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
//#endregion
|
|
261
|
-
//#region src/orm/helpers/pgAttr.d.ts
|
|
262
|
-
/**
|
|
263
|
-
* Type representation.
|
|
264
|
-
*/
|
|
265
|
-
type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
268
|
-
declare module "alepha" {
|
|
269
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
270
|
-
}
|
|
271
|
-
declare const envSchema: alepha160.TObject<{
|
|
272
|
-
/**
|
|
273
|
-
* Main configuration for database connection.
|
|
274
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
275
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
276
|
-
* or
|
|
277
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
278
|
-
*/
|
|
279
|
-
DATABASE_URL: alepha160.TOptional<alepha160.TString>;
|
|
280
|
-
/**
|
|
281
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
282
|
-
*
|
|
283
|
-
* It will monkey patch drizzle tables.
|
|
284
|
-
*/
|
|
285
|
-
POSTGRES_SCHEMA: alepha160.TOptional<alepha160.TString>;
|
|
286
|
-
}>;
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
289
|
-
/**
|
|
290
|
-
* Configuration options for the Node.js SQLite database provider.
|
|
291
|
-
*/
|
|
292
|
-
declare const nodeSqliteOptions: alepha160.Atom<alepha160.TObject<{
|
|
293
|
-
path: alepha160.TOptional<alepha160.TString>;
|
|
294
|
-
}>, "alepha.postgres.node-sqlite.options">;
|
|
295
|
-
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
296
|
-
declare module "alepha" {
|
|
297
|
-
interface State {
|
|
298
|
-
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
303
|
-
*
|
|
304
|
-
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
305
|
-
* This is NOT recommended for production use.
|
|
306
|
-
*/
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/orm/index.d.ts
|
|
309
|
-
declare module "alepha" {
|
|
310
|
-
interface Hooks {
|
|
311
|
-
/**
|
|
312
|
-
* Fires before creating an entity in the repository.
|
|
313
|
-
*/
|
|
314
|
-
"repository:create:before": {
|
|
315
|
-
tableName: string;
|
|
316
|
-
data: any;
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* Fires after creating an entity in the repository.
|
|
320
|
-
*/
|
|
321
|
-
"repository:create:after": {
|
|
322
|
-
tableName: string;
|
|
323
|
-
data: any;
|
|
324
|
-
entity: any;
|
|
325
|
-
};
|
|
326
|
-
/**
|
|
327
|
-
* Fires before updating entities in the repository.
|
|
328
|
-
*/
|
|
329
|
-
"repository:update:before": {
|
|
330
|
-
tableName: string;
|
|
331
|
-
where: any;
|
|
332
|
-
data: any;
|
|
333
|
-
};
|
|
334
|
-
/**
|
|
335
|
-
* Fires after updating entities in the repository.
|
|
336
|
-
*/
|
|
337
|
-
"repository:update:after": {
|
|
338
|
-
tableName: string;
|
|
339
|
-
where: any;
|
|
340
|
-
data: any;
|
|
341
|
-
entities: any[];
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* Fires before deleting entities from the repository.
|
|
345
|
-
*/
|
|
346
|
-
"repository:delete:before": {
|
|
347
|
-
tableName: string;
|
|
348
|
-
where: any;
|
|
349
|
-
};
|
|
350
|
-
/**
|
|
351
|
-
* Fires after deleting entities from the repository.
|
|
352
|
-
*/
|
|
353
|
-
"repository:delete:after": {
|
|
354
|
-
tableName: string;
|
|
355
|
-
where: any;
|
|
356
|
-
ids: Array<string | number>;
|
|
357
|
-
};
|
|
358
|
-
/**
|
|
359
|
-
* Fires before reading entities from the repository.
|
|
360
|
-
*/
|
|
361
|
-
"repository:read:before": {
|
|
362
|
-
tableName: string;
|
|
363
|
-
query: any;
|
|
364
|
-
};
|
|
365
|
-
/**
|
|
366
|
-
* Fires after reading entities from the repository.
|
|
367
|
-
*/
|
|
368
|
-
"repository:read:after": {
|
|
369
|
-
tableName: string;
|
|
370
|
-
query: any;
|
|
371
|
-
entities: any[];
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region src/api-files/schemas/fileResourceSchema.d.ts
|
|
377
|
-
declare const fileResourceSchema: alepha160.TObject<{
|
|
378
|
-
id: PgAttr<PgAttr<alepha160.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
379
|
-
version: PgAttr<PgAttr<alepha160.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
380
|
-
createdAt: PgAttr<PgAttr<alepha160.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
381
|
-
updatedAt: PgAttr<PgAttr<alepha160.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
382
|
-
blobId: alepha160.TString;
|
|
383
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
384
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
385
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
386
|
-
bucket: alepha160.TString;
|
|
387
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
388
|
-
name: alepha160.TString;
|
|
389
|
-
size: alepha160.TNumber;
|
|
390
|
-
mimeType: alepha160.TString;
|
|
391
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
392
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
393
|
-
}>;
|
|
394
|
-
type FileResource = Static<typeof fileResourceSchema>;
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/api-files/schemas/storageStatsSchema.d.ts
|
|
397
|
-
declare const bucketStatsSchema: alepha160.TObject<{
|
|
398
|
-
bucket: alepha160.TString;
|
|
399
|
-
totalSize: alepha160.TNumber;
|
|
400
|
-
fileCount: alepha160.TNumber;
|
|
401
|
-
}>;
|
|
402
|
-
declare const mimeTypeStatsSchema: alepha160.TObject<{
|
|
403
|
-
mimeType: alepha160.TString;
|
|
404
|
-
fileCount: alepha160.TNumber;
|
|
405
|
-
}>;
|
|
406
|
-
declare const storageStatsSchema: alepha160.TObject<{
|
|
407
|
-
totalSize: alepha160.TNumber;
|
|
408
|
-
totalFiles: alepha160.TNumber;
|
|
409
|
-
byBucket: alepha160.TArray<alepha160.TObject<{
|
|
410
|
-
bucket: alepha160.TString;
|
|
411
|
-
totalSize: alepha160.TNumber;
|
|
412
|
-
fileCount: alepha160.TNumber;
|
|
413
|
-
}>>;
|
|
414
|
-
byMimeType: alepha160.TArray<alepha160.TObject<{
|
|
415
|
-
mimeType: alepha160.TString;
|
|
416
|
-
fileCount: alepha160.TNumber;
|
|
417
|
-
}>>;
|
|
418
|
-
}>;
|
|
419
|
-
type BucketStats = Static<typeof bucketStatsSchema>;
|
|
420
|
-
type MimeTypeStats = Static<typeof mimeTypeStatsSchema>;
|
|
421
|
-
type StorageStats = Static<typeof storageStatsSchema>;
|
|
422
|
-
//#endregion
|
|
423
|
-
//#region src/api-files/services/FileService.d.ts
|
|
424
|
-
declare class FileService {
|
|
425
|
-
protected readonly alepha: Alepha;
|
|
426
|
-
protected readonly log: alepha_logger0.Logger;
|
|
427
|
-
protected readonly fileRepository: alepha_orm64.Repository<alepha160.TObject<{
|
|
428
|
-
id: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_PRIMARY_KEY>, typeof alepha_orm64.PG_DEFAULT>;
|
|
429
|
-
version: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TInteger, typeof alepha_orm64.PG_VERSION>, typeof alepha_orm64.PG_DEFAULT>;
|
|
430
|
-
createdAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_CREATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
431
|
-
updatedAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_UPDATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
432
|
-
blobId: alepha160.TString;
|
|
433
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
434
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
435
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
436
|
-
bucket: alepha160.TString;
|
|
437
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
438
|
-
name: alepha160.TString;
|
|
439
|
-
size: alepha160.TNumber;
|
|
440
|
-
mimeType: alepha160.TString;
|
|
441
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
442
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
443
|
-
}>>;
|
|
444
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
445
|
-
protected readonly defaultBucket: BucketDescriptor;
|
|
446
|
-
protected onUploadFile: alepha160.HookDescriptor<"bucket:file:uploaded">;
|
|
447
|
-
protected onDeleteBucketFile: alepha160.HookDescriptor<"bucket:file:deleted">;
|
|
448
|
-
/**
|
|
449
|
-
* Calculates SHA-256 checksum of a file.
|
|
450
|
-
*
|
|
451
|
-
* @param file - The file to calculate checksum for
|
|
452
|
-
* @returns Hexadecimal string representation of the SHA-256 hash
|
|
453
|
-
* @protected
|
|
454
|
-
*/
|
|
455
|
-
protected calculateChecksum(file: FileLike): Promise<string>;
|
|
456
|
-
/**
|
|
457
|
-
* Gets a bucket descriptor by name.
|
|
458
|
-
*
|
|
459
|
-
* @param bucketName - The name of the bucket to retrieve (defaults to "default")
|
|
460
|
-
* @returns The bucket descriptor
|
|
461
|
-
* @throws {NotFoundError} If the bucket is not found
|
|
462
|
-
*/
|
|
463
|
-
bucket(bucketName?: string): BucketDescriptor;
|
|
464
|
-
/**
|
|
465
|
-
* Finds files matching the given query criteria with pagination support.
|
|
466
|
-
* Supports filtering by bucket, tags, name, mimeType, creator, and date range.
|
|
467
|
-
*
|
|
468
|
-
* @param q - Query parameters including bucket, tags, name, mimeType, creator, date range, pagination, and sorting
|
|
469
|
-
* @returns Paginated list of file entities
|
|
470
|
-
*/
|
|
471
|
-
findFiles(q?: FileQuery): Promise<Page<FileEntity>>;
|
|
472
|
-
/**
|
|
473
|
-
* Finds files that have expired based on their expiration date.
|
|
474
|
-
* Limited to 1000 files per call to prevent memory issues.
|
|
475
|
-
*
|
|
476
|
-
* @returns Array of expired file entities
|
|
477
|
-
*/
|
|
478
|
-
findExpiredFiles(): Promise<FileEntity[]>;
|
|
479
|
-
/**
|
|
480
|
-
* Calculates an expiration date based on a TTL (time to live) duration.
|
|
481
|
-
*
|
|
482
|
-
* @param ttl - Duration like "1 day", "2 hours", etc.
|
|
483
|
-
* @returns DateTime representation of the expiration date, or undefined if no TTL provided
|
|
484
|
-
* @protected
|
|
485
|
-
*/
|
|
486
|
-
protected getExpirationDate(ttl?: DurationLike): string | undefined;
|
|
487
|
-
/**
|
|
488
|
-
* Uploads a file to a bucket and creates a database record with metadata.
|
|
489
|
-
* Automatically calculates and stores the file checksum (SHA-256).
|
|
490
|
-
*
|
|
491
|
-
* @param file - The file to upload
|
|
492
|
-
* @param options - Upload options including bucket, expiration, user, and tags
|
|
493
|
-
* @param options.bucket - Target bucket name (defaults to "default")
|
|
494
|
-
* @param options.expirationDate - When the file should expire
|
|
495
|
-
* @param options.user - User performing the upload (for audit trail)
|
|
496
|
-
* @param options.tags - Tags to associate with the file
|
|
497
|
-
* @returns The created file entity with all metadata
|
|
498
|
-
* @throws {NotFoundError} If the specified bucket doesn't exist
|
|
499
|
-
*/
|
|
500
|
-
uploadFile(file: FileLike, options?: {
|
|
501
|
-
expirationDate?: string | DateTime;
|
|
502
|
-
bucket?: string;
|
|
503
|
-
user?: UserAccountToken;
|
|
504
|
-
tags?: string[];
|
|
505
|
-
}): Promise<FileEntity>;
|
|
506
|
-
/**
|
|
507
|
-
* Streams a file from storage by its database ID.
|
|
508
|
-
*
|
|
509
|
-
* @param id - The database ID (UUID) of the file to stream
|
|
510
|
-
* @returns The file object ready for streaming/downloading
|
|
511
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
512
|
-
* @throws {FileNotFoundError} If the file exists in database but not in storage
|
|
513
|
-
*/
|
|
514
|
-
streamFile(id: string): Promise<FileLike>;
|
|
515
|
-
/**
|
|
516
|
-
* Updates file metadata (name, tags, expiration date).
|
|
517
|
-
* Does not modify the actual file content in storage.
|
|
518
|
-
*
|
|
519
|
-
* @param id - The database ID (UUID) of the file to update
|
|
520
|
-
* @param data - Partial file data to update
|
|
521
|
-
* @param data.name - New file name
|
|
522
|
-
* @param data.tags - New tags array
|
|
523
|
-
* @param data.expirationDate - New expiration date
|
|
524
|
-
* @returns The updated file entity
|
|
525
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
526
|
-
*/
|
|
527
|
-
updateFile(id: string, data: {
|
|
528
|
-
name?: string;
|
|
529
|
-
tags?: string[];
|
|
530
|
-
expirationDate?: DateTime | string;
|
|
531
|
-
}): Promise<FileEntity>;
|
|
532
|
-
/**
|
|
533
|
-
* Deletes a file from both storage and database.
|
|
534
|
-
* Handles cases where file is already deleted from storage gracefully.
|
|
535
|
-
* Always ensures database record is removed even if storage deletion fails.
|
|
536
|
-
*
|
|
537
|
-
* @param id - The database ID (UUID) of the file to delete
|
|
538
|
-
* @returns Success response with the deleted file ID
|
|
539
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
540
|
-
*/
|
|
541
|
-
deleteFile(id: string): Promise<Ok>;
|
|
542
|
-
/**
|
|
543
|
-
* Retrieves a file entity by its ID.
|
|
544
|
-
* If already an entity object, returns it as-is (convenience method).
|
|
545
|
-
*
|
|
546
|
-
* @param id - Either a UUID string or an existing FileEntity object
|
|
547
|
-
* @returns The file entity
|
|
548
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
549
|
-
*/
|
|
550
|
-
getFileById(id: string | FileEntity): Promise<FileEntity>;
|
|
551
|
-
/**
|
|
552
|
-
* Gets storage statistics including total size, file count, and breakdowns by bucket and MIME type.
|
|
553
|
-
*
|
|
554
|
-
* @returns Storage statistics with aggregated data
|
|
555
|
-
*/
|
|
556
|
-
getStorageStats(): Promise<StorageStats>;
|
|
557
|
-
/**
|
|
558
|
-
* Converts a file entity to a file resource (API response format).
|
|
559
|
-
* Currently a pass-through, but allows for future transformation logic.
|
|
560
|
-
*
|
|
561
|
-
* @param entity - The file entity to convert
|
|
562
|
-
* @returns The file resource for API responses
|
|
563
|
-
*/
|
|
564
|
-
entityToResource(entity: FileEntity): FileResource;
|
|
565
|
-
}
|
|
566
|
-
//#endregion
|
|
567
|
-
//#region src/api-files/controllers/FileController.d.ts
|
|
568
|
-
/**
|
|
569
|
-
* REST API controller for file management operations.
|
|
570
|
-
* Provides endpoints for uploading, downloading, listing, and deleting files.
|
|
571
|
-
*/
|
|
572
|
-
declare class FileController {
|
|
573
|
-
protected readonly url = "/files";
|
|
574
|
-
protected readonly group = "files";
|
|
575
|
-
protected readonly fileService: FileService;
|
|
576
|
-
/**
|
|
577
|
-
* GET /files - Lists files with optional filtering and pagination.
|
|
578
|
-
* Supports filtering by bucket and tags.
|
|
579
|
-
*/
|
|
580
|
-
readonly findFiles: alepha_server0.ActionDescriptorFn<{
|
|
581
|
-
query: alepha160.TObject<{
|
|
582
|
-
page: alepha160.TOptional<alepha160.TInteger>;
|
|
583
|
-
size: alepha160.TOptional<alepha160.TInteger>;
|
|
584
|
-
sort: alepha160.TOptional<alepha160.TString>;
|
|
585
|
-
bucket: alepha160.TOptional<alepha160.TString>;
|
|
586
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
587
|
-
name: alepha160.TOptional<alepha160.TString>;
|
|
588
|
-
mimeType: alepha160.TOptional<alepha160.TString>;
|
|
589
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
590
|
-
createdAfter: alepha160.TOptional<alepha160.TString>;
|
|
591
|
-
createdBefore: alepha160.TOptional<alepha160.TString>;
|
|
592
|
-
}>;
|
|
593
|
-
response: alepha160.TPage<alepha160.TObject<{
|
|
594
|
-
id: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_PRIMARY_KEY>, typeof alepha_orm64.PG_DEFAULT>;
|
|
595
|
-
version: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TInteger, typeof alepha_orm64.PG_VERSION>, typeof alepha_orm64.PG_DEFAULT>;
|
|
596
|
-
createdAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_CREATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
597
|
-
updatedAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_UPDATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
598
|
-
blobId: alepha160.TString;
|
|
599
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
600
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
601
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
602
|
-
bucket: alepha160.TString;
|
|
603
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
604
|
-
name: alepha160.TString;
|
|
605
|
-
size: alepha160.TNumber;
|
|
606
|
-
mimeType: alepha160.TString;
|
|
607
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
608
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
609
|
-
}>>;
|
|
610
|
-
}>;
|
|
611
|
-
/**
|
|
612
|
-
* DELETE /files/:id - Deletes a file from both storage and database.
|
|
613
|
-
* Removes the file from the bucket and cleans up the database record.
|
|
614
|
-
*/
|
|
615
|
-
readonly deleteFile: alepha_server0.ActionDescriptorFn<{
|
|
616
|
-
params: alepha160.TObject<{
|
|
617
|
-
id: alepha160.TString;
|
|
618
|
-
}>;
|
|
619
|
-
response: alepha160.TObject<{
|
|
620
|
-
ok: alepha160.TBoolean;
|
|
621
|
-
id: alepha160.TOptional<alepha160.TUnion<[alepha160.TString, alepha160.TInteger]>>;
|
|
622
|
-
count: alepha160.TOptional<alepha160.TNumber>;
|
|
623
|
-
}>;
|
|
624
|
-
}>;
|
|
625
|
-
/**
|
|
626
|
-
* POST /files - Uploads a new file to storage.
|
|
627
|
-
* Creates a database record with metadata and calculates checksum.
|
|
628
|
-
* Optionally specify bucket and expiration date.
|
|
629
|
-
*/
|
|
630
|
-
readonly uploadFile: alepha_server0.ActionDescriptorFn<{
|
|
631
|
-
body: alepha160.TObject<{
|
|
632
|
-
file: alepha160.TFile;
|
|
633
|
-
}>;
|
|
634
|
-
query: alepha160.TObject<{
|
|
635
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
636
|
-
bucket: alepha160.TOptional<alepha160.TString>;
|
|
637
|
-
}>;
|
|
638
|
-
response: alepha160.TObject<{
|
|
639
|
-
id: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_PRIMARY_KEY>, typeof alepha_orm64.PG_DEFAULT>;
|
|
640
|
-
version: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TInteger, typeof alepha_orm64.PG_VERSION>, typeof alepha_orm64.PG_DEFAULT>;
|
|
641
|
-
createdAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_CREATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
642
|
-
updatedAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_UPDATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
643
|
-
blobId: alepha160.TString;
|
|
644
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
645
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
646
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
647
|
-
bucket: alepha160.TString;
|
|
648
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
649
|
-
name: alepha160.TString;
|
|
650
|
-
size: alepha160.TNumber;
|
|
651
|
-
mimeType: alepha160.TString;
|
|
652
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
653
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
654
|
-
}>;
|
|
655
|
-
}>;
|
|
656
|
-
/**
|
|
657
|
-
* PATCH /files/:id - Updates file metadata.
|
|
658
|
-
* Allows updating name, tags, and expiration date without modifying file content.
|
|
659
|
-
*/
|
|
660
|
-
readonly updateFile: alepha_server0.ActionDescriptorFn<{
|
|
661
|
-
params: alepha160.TObject<{
|
|
662
|
-
id: alepha160.TString;
|
|
663
|
-
}>;
|
|
664
|
-
body: alepha160.TObject<{
|
|
665
|
-
name: alepha160.TOptional<alepha160.TString>;
|
|
666
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
667
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
668
|
-
}>;
|
|
669
|
-
response: alepha160.TObject<{
|
|
670
|
-
id: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_PRIMARY_KEY>, typeof alepha_orm64.PG_DEFAULT>;
|
|
671
|
-
version: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TInteger, typeof alepha_orm64.PG_VERSION>, typeof alepha_orm64.PG_DEFAULT>;
|
|
672
|
-
createdAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_CREATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
673
|
-
updatedAt: alepha_orm64.PgAttr<alepha_orm64.PgAttr<alepha160.TString, typeof alepha_orm64.PG_UPDATED_AT>, typeof alepha_orm64.PG_DEFAULT>;
|
|
674
|
-
blobId: alepha160.TString;
|
|
675
|
-
creator: alepha160.TOptional<alepha160.TString>;
|
|
676
|
-
creatorRealm: alepha160.TOptional<alepha160.TString>;
|
|
677
|
-
creatorName: alepha160.TOptional<alepha160.TString>;
|
|
678
|
-
bucket: alepha160.TString;
|
|
679
|
-
expirationDate: alepha160.TOptional<alepha160.TString>;
|
|
680
|
-
name: alepha160.TString;
|
|
681
|
-
size: alepha160.TNumber;
|
|
682
|
-
mimeType: alepha160.TString;
|
|
683
|
-
tags: alepha160.TOptional<alepha160.TArray<alepha160.TString>>;
|
|
684
|
-
checksum: alepha160.TOptional<alepha160.TString>;
|
|
685
|
-
}>;
|
|
686
|
-
}>;
|
|
687
|
-
/**
|
|
688
|
-
* GET /files/:id - Streams/downloads a file by its ID.
|
|
689
|
-
* Returns the file content with appropriate Content-Type header.
|
|
690
|
-
* Cached with ETag support for 1 year (immutable).
|
|
691
|
-
*/
|
|
692
|
-
readonly streamFile: alepha_server0.ActionDescriptorFn<{
|
|
693
|
-
params: alepha160.TObject<{
|
|
694
|
-
id: alepha160.TString;
|
|
695
|
-
}>;
|
|
696
|
-
response: alepha160.TFile;
|
|
697
|
-
}>;
|
|
698
|
-
}
|
|
699
|
-
//#endregion
|
|
700
|
-
//#region src/server-security/providers/ServerBasicAuthProvider.d.ts
|
|
701
|
-
interface BasicAuthOptions {
|
|
702
|
-
username: string;
|
|
703
|
-
password: string;
|
|
704
|
-
}
|
|
705
|
-
//#endregion
|
|
706
|
-
//#region src/server-security/providers/ServerSecurityProvider.d.ts
|
|
707
|
-
type ServerRouteSecure = {
|
|
708
|
-
realm?: string;
|
|
709
|
-
basic?: BasicAuthOptions;
|
|
710
|
-
};
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region src/server-security/index.d.ts
|
|
713
|
-
declare module "alepha" {
|
|
714
|
-
interface State {
|
|
715
|
-
/**
|
|
716
|
-
* Real (or fake) user account, used for internal actions.
|
|
717
|
-
*
|
|
718
|
-
* If you define this, you assume that all actions are executed by this user by default.
|
|
719
|
-
* > To force a different user, you need to pass it explicitly in the options.
|
|
720
|
-
*/
|
|
721
|
-
"alepha.server.security.system.user"?: UserAccountToken;
|
|
722
|
-
/**
|
|
723
|
-
* The authenticated user account attached to the server request state.
|
|
724
|
-
*
|
|
725
|
-
* @internal
|
|
726
|
-
*/
|
|
727
|
-
"alepha.server.request.user"?: UserAccount;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
declare module "alepha/server" {
|
|
731
|
-
interface ServerRequest<TConfig> {
|
|
732
|
-
user?: UserAccountToken;
|
|
733
|
-
}
|
|
734
|
-
interface ServerActionRequest<TConfig> {
|
|
735
|
-
user: UserAccountToken;
|
|
736
|
-
}
|
|
737
|
-
interface ServerRoute {
|
|
738
|
-
/**
|
|
739
|
-
* If true, the route will be protected by the security provider.
|
|
740
|
-
* All actions are secure by default, but you can disable it for specific actions.
|
|
741
|
-
*/
|
|
742
|
-
secure?: boolean | ServerRouteSecure;
|
|
743
|
-
}
|
|
744
|
-
interface ClientRequestOptions extends FetchOptions {
|
|
745
|
-
/**
|
|
746
|
-
* Forward user from the previous request.
|
|
747
|
-
* If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
|
|
748
|
-
* If "context", use the user from the current context (e.g. request).
|
|
749
|
-
*
|
|
750
|
-
* @default "system" if provided, else "context" if available.
|
|
751
|
-
*/
|
|
752
|
-
user?: UserAccountToken | "system" | "context";
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
|
|
757
|
-
*
|
|
758
|
-
* By default, all $action will be guarded by a permission check.
|
|
759
|
-
*
|
|
760
|
-
* @see {@link ServerSecurityProvider}
|
|
761
|
-
* @module alepha.server.security
|
|
762
|
-
*/
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region src/api-files/controllers/StorageStatsController.d.ts
|
|
765
|
-
/**
|
|
766
|
-
* REST API controller for storage analytics and statistics.
|
|
767
|
-
* Provides endpoints for viewing storage usage metrics.
|
|
768
|
-
*/
|
|
769
|
-
declare class StorageStatsController {
|
|
770
|
-
protected readonly url = "/files/stats";
|
|
771
|
-
protected readonly group = "files";
|
|
772
|
-
protected readonly fileService: FileService;
|
|
773
|
-
/**
|
|
774
|
-
* GET /files/stats - Gets storage statistics.
|
|
775
|
-
* Returns aggregated data including total size, file count,
|
|
776
|
-
* and breakdowns by bucket and MIME type.
|
|
777
|
-
*/
|
|
778
|
-
readonly getStats: alepha_server0.ActionDescriptorFn<{
|
|
779
|
-
response: alepha160.TObject<{
|
|
780
|
-
totalSize: alepha160.TNumber;
|
|
781
|
-
totalFiles: alepha160.TNumber;
|
|
782
|
-
byBucket: alepha160.TArray<alepha160.TObject<{
|
|
783
|
-
bucket: alepha160.TString;
|
|
784
|
-
totalSize: alepha160.TNumber;
|
|
785
|
-
fileCount: alepha160.TNumber;
|
|
786
|
-
}>>;
|
|
787
|
-
byMimeType: alepha160.TArray<alepha160.TObject<{
|
|
788
|
-
mimeType: alepha160.TString;
|
|
789
|
-
fileCount: alepha160.TNumber;
|
|
790
|
-
}>>;
|
|
791
|
-
}>;
|
|
792
|
-
}>;
|
|
793
|
-
}
|
|
794
|
-
//#endregion
|
|
795
|
-
//#region src/api-files/index.d.ts
|
|
796
|
-
declare module "alepha/bucket" {
|
|
797
|
-
interface BucketFileOptions {
|
|
798
|
-
/**
|
|
799
|
-
* Time to live for the files in the bucket.
|
|
800
|
-
*/
|
|
801
|
-
ttl?: DurationLike;
|
|
802
|
-
/**
|
|
803
|
-
* Tags for the bucket.
|
|
804
|
-
*/
|
|
805
|
-
tags?: string[];
|
|
806
|
-
/**
|
|
807
|
-
* User performing the operation.
|
|
808
|
-
*/
|
|
809
|
-
user?: UserAccountToken;
|
|
810
|
-
/**
|
|
811
|
-
* Whether to persist the file metadata in the database.
|
|
812
|
-
*
|
|
813
|
-
* @default true
|
|
814
|
-
*/
|
|
815
|
-
persist?: boolean;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Provides file management API endpoints for Alepha applications.
|
|
820
|
-
*
|
|
821
|
-
* This module includes file upload, download, storage management,
|
|
822
|
-
* and file metadata operations.
|
|
823
|
-
*
|
|
824
|
-
* @module alepha.api.files
|
|
825
|
-
*/
|
|
826
|
-
declare const AlephaApiFiles: alepha160.Service<alepha160.Module>;
|
|
827
|
-
//#endregion
|
|
828
|
-
export { AlephaApiFiles, BucketStats, FileController, FileEntity, FileService, MimeTypeStats, StorageStats, StorageStatsController, bucketStatsSchema, files, mimeTypeStatsSchema, storageStatsSchema };
|
|
829
|
-
//# sourceMappingURL=index.d.cts.map
|