alepha 0.14.4 → 0.15.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/README.md +1 -4
- package/dist/api/audits/index.d.ts +619 -731
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +185 -298
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js +0 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +245 -356
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.d.ts +238 -350
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +499 -611
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.browser.js +1 -2
- package/dist/api/users/index.browser.js.map +1 -1
- package/dist/api/users/index.d.ts +1697 -1804
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +178 -151
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +132 -132
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.d.ts +122 -122
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +1 -2
- package/dist/batch/index.js.map +1 -1
- package/dist/bucket/index.d.ts +163 -163
- package/dist/bucket/index.d.ts.map +1 -1
- package/dist/cache/core/index.d.ts +46 -46
- package/dist/cache/core/index.d.ts.map +1 -1
- package/dist/cache/redis/index.d.ts.map +1 -1
- package/dist/cli/index.d.ts +302 -299
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +966 -564
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +303 -299
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +11 -7
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +419 -99
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +718 -625
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +420 -99
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +419 -99
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.d.ts +44 -44
- package/dist/datetime/index.d.ts.map +1 -1
- package/dist/datetime/index.js +4 -4
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/index.d.ts +97 -50
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +129 -33
- package/dist/email/index.js.map +1 -1
- package/dist/fake/index.d.ts +7981 -14
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/file/index.d.ts +523 -390
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js +253 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/core/index.d.ts +208 -208
- package/dist/lock/core/index.d.ts.map +1 -1
- package/dist/lock/redis/index.d.ts.map +1 -1
- package/dist/logger/index.d.ts +25 -26
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/mcp/index.d.ts +197 -197
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/orm/chunk-DtkW-qnP.js +38 -0
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.bun.js +2814 -0
- package/dist/orm/index.bun.js.map +1 -0
- package/dist/orm/index.d.ts +1205 -1057
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +2056 -1753
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/core/index.d.ts +248 -248
- package/dist/queue/core/index.d.ts.map +1 -1
- package/dist/queue/redis/index.d.ts.map +1 -1
- package/dist/redis/index.bun.js +285 -0
- package/dist/redis/index.bun.js.map +1 -0
- package/dist/redis/index.d.ts +118 -136
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +18 -38
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.d.ts +69 -69
- package/dist/retry/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +6 -6
- package/dist/router/index.d.ts.map +1 -1
- package/dist/scheduler/index.d.ts +25 -25
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/security/index.browser.js +5 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +417 -254
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +386 -86
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +277 -277
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +20 -20
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.d.ts +60 -57
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +1 -1
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +3 -3
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/cookies/index.d.ts +6 -6
- package/dist/server/cookies/index.d.ts.map +1 -1
- package/dist/server/cookies/index.js +3 -3
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.d.ts +242 -150
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +288 -122
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/cors/index.d.ts +11 -12
- package/dist/server/cors/index.d.ts.map +1 -1
- package/dist/server/health/index.d.ts +0 -1
- package/dist/server/health/index.d.ts.map +1 -1
- package/dist/server/helmet/index.d.ts +2 -2
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.d.ts +84 -85
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/links/index.js +1 -2
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/multipart/index.d.ts +6 -6
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/proxy/index.d.ts +102 -103
- package/dist/server/proxy/index.d.ts.map +1 -1
- package/dist/server/rate-limit/index.d.ts +16 -16
- package/dist/server/rate-limit/index.d.ts.map +1 -1
- package/dist/server/static/index.d.ts +44 -44
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/swagger/index.d.ts +48 -49
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +1 -2
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.d.ts +13 -11
- package/dist/sms/index.d.ts.map +1 -1
- package/dist/sms/index.js +7 -7
- package/dist/sms/index.js.map +1 -1
- package/dist/thread/index.d.ts +71 -72
- package/dist/thread/index.d.ts.map +1 -1
- package/dist/topic/core/index.d.ts +318 -318
- package/dist/topic/core/index.d.ts.map +1 -1
- package/dist/topic/redis/index.d.ts +6 -6
- package/dist/topic/redis/index.d.ts.map +1 -1
- package/dist/vite/index.d.ts +5720 -159
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +41 -18
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +6 -6
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +247 -247
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +6 -6
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -14
- package/src/api/files/controllers/AdminFileStatsController.ts +0 -1
- package/src/api/users/atoms/realmAuthSettingsAtom.ts +5 -0
- package/src/api/users/controllers/{UserRealmController.ts → RealmController.ts} +11 -11
- package/src/api/users/entities/users.ts +1 -1
- package/src/api/users/index.ts +8 -8
- package/src/api/users/primitives/{$userRealm.ts → $realm.ts} +17 -19
- package/src/api/users/providers/{UserRealmProvider.ts → RealmProvider.ts} +26 -30
- package/src/api/users/schemas/{userRealmConfigSchema.ts → realmConfigSchema.ts} +2 -2
- package/src/api/users/services/CredentialService.ts +7 -7
- package/src/api/users/services/IdentityService.ts +4 -4
- package/src/api/users/services/RegistrationService.spec.ts +25 -27
- package/src/api/users/services/RegistrationService.ts +38 -27
- package/src/api/users/services/SessionCrudService.ts +3 -3
- package/src/api/users/services/SessionService.spec.ts +3 -3
- package/src/api/users/services/SessionService.ts +28 -9
- package/src/api/users/services/UserService.ts +7 -7
- package/src/batch/providers/BatchProvider.ts +1 -2
- package/src/cli/apps/AlephaPackageBuilderCli.ts +38 -19
- package/src/cli/assets/apiHelloControllerTs.ts +18 -0
- package/src/cli/assets/apiIndexTs.ts +16 -0
- package/src/cli/assets/claudeMd.ts +303 -0
- package/src/cli/assets/mainBrowserTs.ts +2 -2
- package/src/cli/assets/mainServerTs.ts +24 -0
- package/src/cli/assets/webAppRouterTs.ts +15 -0
- package/src/cli/assets/webHelloComponentTsx.ts +16 -0
- package/src/cli/assets/webIndexTs.ts +16 -0
- package/src/cli/commands/build.ts +41 -21
- package/src/cli/commands/db.ts +21 -18
- package/src/cli/commands/deploy.ts +17 -5
- package/src/cli/commands/dev.ts +13 -17
- package/src/cli/commands/format.ts +8 -2
- package/src/cli/commands/init.ts +74 -29
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/test.ts +8 -2
- package/src/cli/commands/typecheck.ts +5 -1
- package/src/cli/commands/verify.ts +4 -2
- package/src/cli/services/AlephaCliUtils.ts +39 -600
- package/src/cli/services/PackageManagerUtils.ts +301 -0
- package/src/cli/services/ProjectScaffolder.ts +306 -0
- package/src/command/helpers/Runner.ts +15 -3
- package/src/core/__tests__/Alepha-graph.spec.ts +4 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +2 -0
- package/src/core/primitives/$hook.ts +6 -2
- package/src/core/primitives/$module.spec.ts +4 -0
- package/src/core/providers/AlsProvider.ts +1 -1
- package/src/core/providers/CodecManager.spec.ts +12 -6
- package/src/core/providers/CodecManager.ts +26 -6
- package/src/core/providers/EventManager.ts +169 -13
- package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +621 -0
- package/src/core/providers/KeylessJsonSchemaCodec.ts +407 -0
- package/src/core/providers/StateManager.spec.ts +27 -16
- package/src/email/providers/LocalEmailProvider.spec.ts +111 -87
- package/src/email/providers/LocalEmailProvider.ts +52 -15
- package/src/email/providers/NodemailerEmailProvider.ts +167 -56
- package/src/file/errors/FileError.ts +7 -0
- package/src/file/index.ts +9 -1
- package/src/file/providers/MemoryFileSystemProvider.ts +393 -0
- package/src/orm/index.browser.ts +1 -19
- package/src/orm/index.bun.ts +77 -0
- package/src/orm/index.shared-server.ts +22 -0
- package/src/orm/index.shared.ts +15 -0
- package/src/orm/index.ts +19 -39
- package/src/orm/providers/drivers/BunPostgresProvider.ts +3 -5
- package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -1
- package/src/orm/providers/drivers/CloudflareD1Provider.ts +4 -0
- package/src/orm/providers/drivers/DatabaseProvider.ts +4 -0
- package/src/orm/providers/drivers/PglitePostgresProvider.ts +4 -0
- package/src/orm/services/Repository.ts +8 -0
- package/src/redis/index.bun.ts +35 -0
- package/src/redis/providers/BunRedisProvider.ts +12 -43
- package/src/redis/providers/BunRedisSubscriberProvider.ts +2 -3
- package/src/redis/providers/NodeRedisProvider.ts +16 -34
- package/src/{server/security → security}/__tests__/BasicAuth.spec.ts +11 -11
- package/src/{server/security → security}/__tests__/ServerSecurityProvider-realm.spec.ts +21 -16
- package/src/{server/security/providers → security/__tests__}/ServerSecurityProvider.spec.ts +5 -5
- package/src/security/index.browser.ts +5 -0
- package/src/security/index.ts +90 -7
- package/src/security/primitives/{$realm.spec.ts → $issuer.spec.ts} +11 -11
- package/src/security/primitives/{$realm.ts → $issuer.ts} +20 -17
- package/src/security/primitives/$role.ts +5 -5
- package/src/security/primitives/$serviceAccount.spec.ts +5 -5
- package/src/security/primitives/$serviceAccount.ts +3 -3
- package/src/{server/security → security}/providers/ServerSecurityProvider.ts +5 -7
- package/src/server/auth/primitives/$auth.ts +10 -10
- package/src/server/auth/primitives/$authCredentials.ts +3 -3
- package/src/server/auth/primitives/$authGithub.ts +3 -3
- package/src/server/auth/primitives/$authGoogle.ts +3 -3
- package/src/server/auth/providers/ServerAuthProvider.ts +13 -13
- package/src/server/cache/providers/ServerCacheProvider.ts +1 -1
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
- package/src/server/core/providers/NodeHttpServerProvider.ts +25 -6
- package/src/server/core/providers/ServerBodyParserProvider.ts +19 -23
- package/src/server/core/providers/ServerLoggerProvider.ts +23 -19
- package/src/server/core/providers/ServerProvider.ts +144 -21
- package/src/server/core/providers/ServerRouterProvider.ts +259 -115
- package/src/server/core/providers/ServerTimingProvider.ts +2 -2
- package/src/server/links/index.ts +1 -1
- package/src/server/links/providers/LinkProvider.ts +1 -1
- package/src/server/swagger/index.ts +1 -1
- package/src/sms/providers/LocalSmsProvider.spec.ts +153 -111
- package/src/sms/providers/LocalSmsProvider.ts +8 -7
- package/src/vite/helpers/boot.ts +28 -17
- package/src/vite/tasks/buildServer.ts +12 -1
- package/src/vite/tasks/devServer.ts +3 -1
- package/src/vite/tasks/generateCloudflare.ts +7 -0
- package/dist/server/security/index.browser.js +0 -13
- package/dist/server/security/index.browser.js.map +0 -1
- package/dist/server/security/index.d.ts +0 -173
- package/dist/server/security/index.d.ts.map +0 -1
- package/dist/server/security/index.js +0 -311
- package/dist/server/security/index.js.map +0 -1
- package/src/cli/assets/appRouterTs.ts +0 -9
- package/src/cli/assets/mainTs.ts +0 -13
- package/src/server/security/index.browser.ts +0 -10
- package/src/server/security/index.ts +0 -94
- /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
- /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as alepha160 from "alepha";
|
|
2
2
|
import { Alepha, FileLike, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
|
|
3
3
|
import { BucketPrimitive } from "alepha/bucket";
|
|
4
|
-
import "alepha/server/security";
|
|
5
4
|
import * as alepha_server0 from "alepha/server";
|
|
6
5
|
import { Ok } from "alepha/server";
|
|
7
6
|
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
@@ -15,9 +14,6 @@ import { BuildExtraConfigColumns, SQL } from "drizzle-orm";
|
|
|
15
14
|
import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
16
15
|
import "alepha/retry";
|
|
17
16
|
import "drizzle-orm/sqlite-core";
|
|
18
|
-
import "alepha/lock";
|
|
19
|
-
import "drizzle-orm/postgres-js";
|
|
20
|
-
import "postgres";
|
|
21
17
|
|
|
22
18
|
//#region ../../src/api/files/entities/files.d.ts
|
|
23
19
|
declare const files: alepha_orm16.EntityPrimitive<alepha160.TObject<{
|
|
@@ -84,114 +80,114 @@ type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]:
|
|
|
84
80
|
//#region ../../src/orm/primitives/$entity.d.ts
|
|
85
81
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
86
82
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
* The database table name that will be created for this entity.
|
|
84
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
85
|
+
*/
|
|
90
86
|
name: string;
|
|
91
87
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
* TypeBox schema defining the table structure and column types.
|
|
89
|
+
*/
|
|
94
90
|
schema: T;
|
|
95
91
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
* Database indexes to create for query optimization.
|
|
93
|
+
*/
|
|
98
94
|
indexes?: (Keys | {
|
|
99
95
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
* Single column to index.
|
|
97
|
+
*/
|
|
102
98
|
column: Keys;
|
|
103
99
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
101
|
+
*/
|
|
106
102
|
unique?: boolean;
|
|
107
103
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
105
|
+
*/
|
|
110
106
|
name?: string;
|
|
111
107
|
} | {
|
|
112
108
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
110
|
+
*/
|
|
115
111
|
columns: Keys[];
|
|
116
112
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
114
|
+
*/
|
|
119
115
|
unique?: boolean;
|
|
120
116
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
118
|
+
*/
|
|
123
119
|
name?: string;
|
|
124
120
|
})[];
|
|
125
121
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
* Foreign key constraints to maintain referential integrity.
|
|
123
|
+
*/
|
|
128
124
|
foreignKeys?: Array<{
|
|
129
125
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
* Optional name for the foreign key constraint.
|
|
127
|
+
*/
|
|
132
128
|
name?: string;
|
|
133
129
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
* Local columns that reference the foreign table.
|
|
131
|
+
*/
|
|
136
132
|
columns: Array<keyof Static<T>>;
|
|
137
133
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
* Referenced columns in the foreign table.
|
|
135
|
+
* Must be EntityColumn references from other entities.
|
|
136
|
+
*/
|
|
141
137
|
foreignColumns: Array<() => EntityColumn<any>>;
|
|
142
138
|
}>;
|
|
143
139
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
140
|
+
* Additional table constraints for data validation.
|
|
141
|
+
*
|
|
142
|
+
* Constraints enforce business rules at the database level, providing
|
|
143
|
+
* an additional layer of data integrity beyond application validation.
|
|
144
|
+
*
|
|
145
|
+
* **Constraint Types**:
|
|
146
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
147
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* constraints: [
|
|
152
|
+
* {
|
|
153
|
+
* name: "unique_user_email",
|
|
154
|
+
* columns: ["email"],
|
|
155
|
+
* unique: true
|
|
156
|
+
* },
|
|
157
|
+
* {
|
|
158
|
+
* name: "valid_age_range",
|
|
159
|
+
* columns: ["age"],
|
|
160
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
161
|
+
* },
|
|
162
|
+
* {
|
|
163
|
+
* name: "unique_user_username_per_tenant",
|
|
164
|
+
* columns: ["tenantId", "username"],
|
|
165
|
+
* unique: true
|
|
166
|
+
* }
|
|
167
|
+
* ]
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
174
170
|
constraints?: Array<{
|
|
175
171
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
172
|
+
* Columns involved in this constraint.
|
|
173
|
+
*/
|
|
178
174
|
columns: Array<keyof Static<T>>;
|
|
179
175
|
/**
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
* Optional name for the constraint.
|
|
177
|
+
*/
|
|
182
178
|
name?: string;
|
|
183
179
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
* Whether this is a unique constraint.
|
|
181
|
+
*/
|
|
186
182
|
unique?: boolean | {};
|
|
187
183
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
* SQL expression for check constraint validation.
|
|
185
|
+
*/
|
|
190
186
|
check?: SQL;
|
|
191
187
|
}>;
|
|
192
188
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
190
|
+
*/
|
|
195
191
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
196
192
|
}
|
|
197
193
|
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
@@ -239,8 +235,8 @@ type PgSymbols = {
|
|
|
239
235
|
[PG_REF]: PgRefOptions;
|
|
240
236
|
[PG_ENUM]: PgEnumOptions;
|
|
241
237
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
239
|
+
*/
|
|
244
240
|
[PG_SERIAL]: {};
|
|
245
241
|
};
|
|
246
242
|
type PgSymbolKeys = keyof PgSymbols;
|
|
@@ -270,115 +266,6 @@ interface PgRefOptions {
|
|
|
270
266
|
*/
|
|
271
267
|
type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
272
268
|
//#endregion
|
|
273
|
-
//#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
274
|
-
declare module "alepha" {
|
|
275
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
276
|
-
}
|
|
277
|
-
declare const envSchema: alepha160.TObject<{
|
|
278
|
-
/**
|
|
279
|
-
* Main configuration for database connection.
|
|
280
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
281
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
282
|
-
* or
|
|
283
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
284
|
-
*/
|
|
285
|
-
DATABASE_URL: alepha160.TOptional<alepha160.TString>;
|
|
286
|
-
/**
|
|
287
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
288
|
-
*
|
|
289
|
-
* It will monkey patch drizzle tables.
|
|
290
|
-
*/
|
|
291
|
-
POSTGRES_SCHEMA: alepha160.TOptional<alepha160.TString>;
|
|
292
|
-
}>;
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
295
|
-
/**
|
|
296
|
-
* Configuration options for the Node.js SQLite database provider.
|
|
297
|
-
*/
|
|
298
|
-
declare const nodeSqliteOptions: alepha160.Atom<alepha160.TObject<{
|
|
299
|
-
path: alepha160.TOptional<alepha160.TString>;
|
|
300
|
-
}>, "alepha.postgres.node-sqlite.options">;
|
|
301
|
-
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
302
|
-
declare module "alepha" {
|
|
303
|
-
interface State {
|
|
304
|
-
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
309
|
-
*
|
|
310
|
-
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
311
|
-
* This is NOT recommended for production use.
|
|
312
|
-
*/
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region ../../src/orm/index.d.ts
|
|
315
|
-
declare module "alepha" {
|
|
316
|
-
interface Hooks {
|
|
317
|
-
/**
|
|
318
|
-
* Fires before creating an entity in the repository.
|
|
319
|
-
*/
|
|
320
|
-
"repository:create:before": {
|
|
321
|
-
tableName: string;
|
|
322
|
-
data: any;
|
|
323
|
-
};
|
|
324
|
-
/**
|
|
325
|
-
* Fires after creating an entity in the repository.
|
|
326
|
-
*/
|
|
327
|
-
"repository:create:after": {
|
|
328
|
-
tableName: string;
|
|
329
|
-
data: any;
|
|
330
|
-
entity: any;
|
|
331
|
-
};
|
|
332
|
-
/**
|
|
333
|
-
* Fires before updating entities in the repository.
|
|
334
|
-
*/
|
|
335
|
-
"repository:update:before": {
|
|
336
|
-
tableName: string;
|
|
337
|
-
where: any;
|
|
338
|
-
data: any;
|
|
339
|
-
};
|
|
340
|
-
/**
|
|
341
|
-
* Fires after updating entities in the repository.
|
|
342
|
-
*/
|
|
343
|
-
"repository:update:after": {
|
|
344
|
-
tableName: string;
|
|
345
|
-
where: any;
|
|
346
|
-
data: any;
|
|
347
|
-
entities: any[];
|
|
348
|
-
};
|
|
349
|
-
/**
|
|
350
|
-
* Fires before deleting entities from the repository.
|
|
351
|
-
*/
|
|
352
|
-
"repository:delete:before": {
|
|
353
|
-
tableName: string;
|
|
354
|
-
where: any;
|
|
355
|
-
};
|
|
356
|
-
/**
|
|
357
|
-
* Fires after deleting entities from the repository.
|
|
358
|
-
*/
|
|
359
|
-
"repository:delete:after": {
|
|
360
|
-
tableName: string;
|
|
361
|
-
where: any;
|
|
362
|
-
ids: Array<string | number>;
|
|
363
|
-
};
|
|
364
|
-
/**
|
|
365
|
-
* Fires before reading entities from the repository.
|
|
366
|
-
*/
|
|
367
|
-
"repository:read:before": {
|
|
368
|
-
tableName: string;
|
|
369
|
-
query: any;
|
|
370
|
-
};
|
|
371
|
-
/**
|
|
372
|
-
* Fires after reading entities from the repository.
|
|
373
|
-
*/
|
|
374
|
-
"repository:read:after": {
|
|
375
|
-
tableName: string;
|
|
376
|
-
query: any;
|
|
377
|
-
entities: any[];
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
//#endregion
|
|
382
269
|
//#region ../../src/api/files/schemas/fileResourceSchema.d.ts
|
|
383
270
|
declare const fileResourceSchema: alepha160.TObject<{
|
|
384
271
|
id: PgAttr<PgAttr<alepha160.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
@@ -452,57 +339,57 @@ declare class FileService {
|
|
|
452
339
|
protected onUploadFile: alepha160.HookPrimitive<"bucket:file:uploaded">;
|
|
453
340
|
protected onDeleteBucketFile: alepha160.HookPrimitive<"bucket:file:deleted">;
|
|
454
341
|
/**
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
342
|
+
* Calculates SHA-256 checksum of a file.
|
|
343
|
+
*
|
|
344
|
+
* @param file - The file to calculate checksum for
|
|
345
|
+
* @returns Hexadecimal string representation of the SHA-256 hash
|
|
346
|
+
* @protected
|
|
347
|
+
*/
|
|
461
348
|
protected calculateChecksum(file: FileLike): Promise<string>;
|
|
462
349
|
/**
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
350
|
+
* Gets a bucket primitive by name.
|
|
351
|
+
*
|
|
352
|
+
* @param bucketName - The name of the bucket to retrieve (defaults to "default")
|
|
353
|
+
* @returns The bucket primitive
|
|
354
|
+
* @throws {NotFoundError} If the bucket is not found
|
|
355
|
+
*/
|
|
469
356
|
bucket(bucketName?: string): BucketPrimitive;
|
|
470
357
|
/**
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
358
|
+
* Finds files matching the given query criteria with pagination support.
|
|
359
|
+
* Supports filtering by bucket, tags, name, mimeType, creator, and date range.
|
|
360
|
+
*
|
|
361
|
+
* @param q - Query parameters including bucket, tags, name, mimeType, creator, date range, pagination, and sorting
|
|
362
|
+
* @returns Paginated list of file entities
|
|
363
|
+
*/
|
|
477
364
|
findFiles(q?: FileQuery): Promise<Page<FileEntity>>;
|
|
478
365
|
/**
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
366
|
+
* Finds files that have expired based on their expiration date.
|
|
367
|
+
* Limited to 1000 files per call to prevent memory issues.
|
|
368
|
+
*
|
|
369
|
+
* @returns Array of expired file entities
|
|
370
|
+
*/
|
|
484
371
|
findExpiredFiles(): Promise<FileEntity[]>;
|
|
485
372
|
/**
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
373
|
+
* Calculates an expiration date based on a TTL (time to live) duration.
|
|
374
|
+
*
|
|
375
|
+
* @param ttl - Duration like "1 day", "2 hours", etc.
|
|
376
|
+
* @returns DateTime representation of the expiration date, or undefined if no TTL provided
|
|
377
|
+
* @protected
|
|
378
|
+
*/
|
|
492
379
|
protected getExpirationDate(ttl?: DurationLike): string | undefined;
|
|
493
380
|
/**
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
381
|
+
* Uploads a file to a bucket and creates a database record with metadata.
|
|
382
|
+
* Automatically calculates and stores the file checksum (SHA-256).
|
|
383
|
+
*
|
|
384
|
+
* @param file - The file to upload
|
|
385
|
+
* @param options - Upload options including bucket, expiration, user, and tags
|
|
386
|
+
* @param options.bucket - Target bucket name (defaults to "default")
|
|
387
|
+
* @param options.expirationDate - When the file should expire
|
|
388
|
+
* @param options.user - User performing the upload (for audit trail)
|
|
389
|
+
* @param options.tags - Tags to associate with the file
|
|
390
|
+
* @returns The created file entity with all metadata
|
|
391
|
+
* @throws {NotFoundError} If the specified bucket doesn't exist
|
|
392
|
+
*/
|
|
506
393
|
uploadFile(file: FileLike, options?: {
|
|
507
394
|
expirationDate?: string | DateTime;
|
|
508
395
|
bucket?: string;
|
|
@@ -510,63 +397,63 @@ declare class FileService {
|
|
|
510
397
|
tags?: string[];
|
|
511
398
|
}): Promise<FileEntity>;
|
|
512
399
|
/**
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
400
|
+
* Streams a file from storage by its database ID.
|
|
401
|
+
*
|
|
402
|
+
* @param id - The database ID (UUID) of the file to stream
|
|
403
|
+
* @returns The file object ready for streaming/downloading
|
|
404
|
+
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
405
|
+
* @throws {FileNotFoundError} If the file exists in database but not in storage
|
|
406
|
+
*/
|
|
520
407
|
streamFile(id: string): Promise<FileLike>;
|
|
521
408
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
409
|
+
* Updates file metadata (name, tags, expiration date).
|
|
410
|
+
* Does not modify the actual file content in storage.
|
|
411
|
+
*
|
|
412
|
+
* @param id - The database ID (UUID) of the file to update
|
|
413
|
+
* @param data - Partial file data to update
|
|
414
|
+
* @param data.name - New file name
|
|
415
|
+
* @param data.tags - New tags array
|
|
416
|
+
* @param data.expirationDate - New expiration date
|
|
417
|
+
* @returns The updated file entity
|
|
418
|
+
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
419
|
+
*/
|
|
533
420
|
updateFile(id: string, data: {
|
|
534
421
|
name?: string;
|
|
535
422
|
tags?: string[];
|
|
536
423
|
expirationDate?: DateTime | string;
|
|
537
424
|
}): Promise<FileEntity>;
|
|
538
425
|
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
426
|
+
* Deletes a file from both storage and database.
|
|
427
|
+
* Handles cases where file is already deleted from storage gracefully.
|
|
428
|
+
* Always ensures database record is removed even if storage deletion fails.
|
|
429
|
+
*
|
|
430
|
+
* @param id - The database ID (UUID) of the file to delete
|
|
431
|
+
* @returns Success response with the deleted file ID
|
|
432
|
+
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
433
|
+
*/
|
|
547
434
|
deleteFile(id: string): Promise<Ok>;
|
|
548
435
|
/**
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
436
|
+
* Retrieves a file entity by its ID.
|
|
437
|
+
* If already an entity object, returns it as-is (convenience method).
|
|
438
|
+
*
|
|
439
|
+
* @param id - Either a UUID string or an existing FileEntity object
|
|
440
|
+
* @returns The file entity
|
|
441
|
+
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
442
|
+
*/
|
|
556
443
|
getFileById(id: string | FileEntity): Promise<FileEntity>;
|
|
557
444
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
445
|
+
* Gets storage statistics including total size, file count, and breakdowns by bucket and MIME type.
|
|
446
|
+
*
|
|
447
|
+
* @returns Storage statistics with aggregated data
|
|
448
|
+
*/
|
|
562
449
|
getStorageStats(): Promise<StorageStats>;
|
|
563
450
|
/**
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
451
|
+
* Converts a file entity to a file resource (API response format).
|
|
452
|
+
* Currently a pass-through, but allows for future transformation logic.
|
|
453
|
+
*
|
|
454
|
+
* @param entity - The file entity to convert
|
|
455
|
+
* @returns The file resource for API responses
|
|
456
|
+
*/
|
|
570
457
|
entityToResource(entity: FileEntity): FileResource;
|
|
571
458
|
}
|
|
572
459
|
//#endregion
|
|
@@ -580,10 +467,10 @@ declare class AdminFileStatsController {
|
|
|
580
467
|
protected readonly group = "admin:files";
|
|
581
468
|
protected readonly fileService: FileService;
|
|
582
469
|
/**
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
470
|
+
* GET /files/stats - Gets storage statistics.
|
|
471
|
+
* Returns aggregated data including total size, file count,
|
|
472
|
+
* and breakdowns by bucket and MIME type.
|
|
473
|
+
*/
|
|
587
474
|
readonly getStats: alepha_server0.ActionPrimitiveFn<{
|
|
588
475
|
response: alepha160.TObject<{
|
|
589
476
|
totalSize: alepha160.TNumber;
|
|
@@ -611,9 +498,9 @@ declare class FileController {
|
|
|
611
498
|
protected readonly group = "files";
|
|
612
499
|
protected readonly fileService: FileService;
|
|
613
500
|
/**
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
501
|
+
* GET /files - Lists files with optional filtering and pagination.
|
|
502
|
+
* Supports filtering by bucket and tags.
|
|
503
|
+
*/
|
|
617
504
|
readonly findFiles: alepha_server0.ActionPrimitiveFn<{
|
|
618
505
|
query: alepha160.TObject<{
|
|
619
506
|
page: alepha160.TOptional<alepha160.TInteger>;
|
|
@@ -646,9 +533,9 @@ declare class FileController {
|
|
|
646
533
|
}>>;
|
|
647
534
|
}>;
|
|
648
535
|
/**
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
536
|
+
* DELETE /files/:id - Deletes a file from both storage and database.
|
|
537
|
+
* Removes the file from the bucket and cleans up the database record.
|
|
538
|
+
*/
|
|
652
539
|
readonly deleteFile: alepha_server0.ActionPrimitiveFn<{
|
|
653
540
|
params: alepha160.TObject<{
|
|
654
541
|
id: alepha160.TString;
|
|
@@ -660,10 +547,10 @@ declare class FileController {
|
|
|
660
547
|
}>;
|
|
661
548
|
}>;
|
|
662
549
|
/**
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
550
|
+
* POST /files - Uploads a new file to storage.
|
|
551
|
+
* Creates a database record with metadata and calculates checksum.
|
|
552
|
+
* Optionally specify bucket and expiration date.
|
|
553
|
+
*/
|
|
667
554
|
readonly uploadFile: alepha_server0.ActionPrimitiveFn<{
|
|
668
555
|
body: alepha160.TObject<{
|
|
669
556
|
file: alepha160.TFile;
|
|
@@ -691,9 +578,9 @@ declare class FileController {
|
|
|
691
578
|
}>;
|
|
692
579
|
}>;
|
|
693
580
|
/**
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
581
|
+
* PATCH /files/:id - Updates file metadata.
|
|
582
|
+
* Allows updating name, tags, and expiration date without modifying file content.
|
|
583
|
+
*/
|
|
697
584
|
readonly updateFile: alepha_server0.ActionPrimitiveFn<{
|
|
698
585
|
params: alepha160.TObject<{
|
|
699
586
|
id: alepha160.TString;
|
|
@@ -722,10 +609,10 @@ declare class FileController {
|
|
|
722
609
|
}>;
|
|
723
610
|
}>;
|
|
724
611
|
/**
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
612
|
+
* GET /files/:id - Streams/downloads a file by its ID.
|
|
613
|
+
* Returns the file content with appropriate Content-Type header.
|
|
614
|
+
* Cached with ETag support for 1 year (immutable).
|
|
615
|
+
*/
|
|
729
616
|
readonly streamFile: alepha_server0.ActionPrimitiveFn<{
|
|
730
617
|
params: alepha160.TObject<{
|
|
731
618
|
id: alepha160.TString;
|
|
@@ -744,22 +631,22 @@ declare class FileJobs {
|
|
|
744
631
|
declare module "alepha/bucket" {
|
|
745
632
|
interface BucketFileOptions {
|
|
746
633
|
/**
|
|
747
|
-
|
|
748
|
-
|
|
634
|
+
* Time to live for the files in the bucket.
|
|
635
|
+
*/
|
|
749
636
|
ttl?: DurationLike;
|
|
750
637
|
/**
|
|
751
|
-
|
|
752
|
-
|
|
638
|
+
* Tags for the bucket.
|
|
639
|
+
*/
|
|
753
640
|
tags?: string[];
|
|
754
641
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
642
|
+
* User performing the operation.
|
|
643
|
+
*/
|
|
757
644
|
user?: UserAccountToken;
|
|
758
645
|
/**
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
646
|
+
* Whether to persist the file metadata in the database.
|
|
647
|
+
*
|
|
648
|
+
* @default true
|
|
649
|
+
*/
|
|
763
650
|
persist?: boolean;
|
|
764
651
|
}
|
|
765
652
|
}
|