alepha 0.14.3 → 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 +2 -5
- package/dist/api/audits/index.d.ts +620 -811
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +185 -377
- 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 -435
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.d.ts +238 -429
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +236 -427
- 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 +1010 -1196
- 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 +17 -17
- 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 +384 -285
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1113 -623
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +299 -300
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +13 -9
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +445 -103
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +733 -625
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +446 -103
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +445 -103
- 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/logger/index.js +12 -2
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts +197 -197
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.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 +1228 -1216
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +2041 -1967
- 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 +110 -110
- 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 +62 -47
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +56 -3
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +6 -0
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +36 -1
- package/dist/server/compress/index.js.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.browser.js +2 -2
- package/dist/server/core/index.browser.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 +294 -125
- 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 +123 -124
- 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/static/index.js +4 -0
- package/dist/server/static/index.js.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 +3 -5
- 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 +5805 -249
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +599 -513
- 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/AlephaCli.ts +0 -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/atoms/buildOptions.ts +88 -0
- package/src/cli/commands/build.ts +70 -87
- package/src/cli/commands/db.ts +21 -22
- package/src/cli/commands/deploy.ts +17 -5
- package/src/cli/commands/dev.ts +22 -14
- package/src/cli/commands/format.ts +8 -2
- package/src/cli/commands/gen/env.ts +53 -0
- package/src/cli/commands/gen/openapi.ts +1 -1
- package/src/cli/commands/gen/resource.ts +15 -0
- package/src/cli/commands/gen.ts +7 -1
- package/src/cli/commands/init.ts +74 -30
- package/src/cli/commands/lint.ts +8 -2
- package/src/cli/commands/test.ts +8 -3
- package/src/cli/commands/typecheck.ts +5 -1
- package/src/cli/commands/verify.ts +5 -3
- package/src/cli/defineConfig.ts +49 -7
- package/src/cli/index.ts +0 -1
- package/src/cli/services/AlephaCliUtils.ts +39 -589
- package/src/cli/services/PackageManagerUtils.ts +301 -0
- package/src/cli/services/ProjectScaffolder.ts +306 -0
- package/src/command/helpers/Runner.spec.ts +2 -2
- package/src/command/helpers/Runner.ts +16 -4
- package/src/command/primitives/$command.ts +0 -6
- package/src/command/providers/CliProvider.ts +1 -3
- package/src/core/Alepha.ts +42 -0
- 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/logger/index.ts +15 -3
- package/src/mcp/transports/StdioMcpTransport.ts +1 -1
- 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 +13 -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/queue/core/providers/WorkerProvider.spec.ts +48 -32
- 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.spec.ts +183 -0
- package/src/server/cache/providers/ServerCacheProvider.ts +95 -10
- package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
- package/src/server/cookies/providers/ServerCookiesProvider.ts +3 -3
- package/src/server/core/helpers/ServerReply.ts +2 -2
- 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 +155 -22
- 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/static/providers/ServerStaticProvider.ts +10 -0
- package/src/server/swagger/index.ts +1 -1
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
- 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/helpers/importViteReact.ts +13 -0
- package/src/vite/index.ts +1 -21
- package/src/vite/plugins/viteAlephaDev.ts +16 -1
- package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
- package/src/vite/tasks/buildClient.ts +11 -0
- package/src/vite/tasks/buildServer.ts +59 -4
- package/src/vite/tasks/devServer.ts +71 -0
- package/src/vite/tasks/generateCloudflare.ts +7 -0
- package/src/vite/tasks/index.ts +2 -1
- 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/cli/assets/viteConfigTs.ts +0 -14
- package/src/cli/commands/run.ts +0 -24
- package/src/server/security/index.browser.ts +0 -10
- package/src/server/security/index.ts +0 -94
- package/src/vite/plugins/viteAlepha.ts +0 -37
- package/src/vite/plugins/viteAlephaBuild.ts +0 -281
- /package/src/{server/security → security}/primitives/$basicAuth.ts +0 -0
- /package/src/{server/security → security}/providers/ServerBasicAuthProvider.ts +0 -0
|
@@ -9,16 +9,12 @@ import { AuditService } from "alepha/api/audits";
|
|
|
9
9
|
import * as alepha_logger5 from "alepha/logger";
|
|
10
10
|
import * as alepha_bucket0 from "alepha/bucket";
|
|
11
11
|
import * as alepha_server_links0 from "alepha/server/links";
|
|
12
|
+
import { OAuth2Profile, ServerAuthProvider, WithLinkFn, WithLoginFn } from "alepha/server/auth";
|
|
12
13
|
import * as alepha_cache0 from "alepha/cache";
|
|
13
14
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
14
|
-
import { CryptoProvider,
|
|
15
|
-
import { OAuth2Profile, ServerAuthProvider, WithLinkFn, WithLoginFn } from "alepha/server/auth";
|
|
15
|
+
import { CryptoProvider, IssuerPrimitive, IssuerPrimitiveOptions, UserAccount } from "alepha/security";
|
|
16
16
|
import { FileSystemProvider } from "alepha/file";
|
|
17
17
|
import { FileController } from "alepha/api/files";
|
|
18
|
-
import "bun";
|
|
19
|
-
import "bun:sqlite";
|
|
20
|
-
import "drizzle-orm/bun-sql";
|
|
21
|
-
import "drizzle-orm/bun-sqlite";
|
|
22
18
|
import "drizzle-orm/d1";
|
|
23
19
|
import * as drizzle_orm0 from "drizzle-orm";
|
|
24
20
|
import { BuildExtraConfigColumns, SQL, SQLWrapper } from "drizzle-orm";
|
|
@@ -27,10 +23,7 @@ import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, Pg
|
|
|
27
23
|
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
28
24
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
29
25
|
import "alepha/retry";
|
|
30
|
-
import "alepha/lock";
|
|
31
26
|
import "drizzle-orm/sqlite-core";
|
|
32
|
-
import "drizzle-orm/postgres-js";
|
|
33
|
-
import "postgres";
|
|
34
27
|
|
|
35
28
|
//#region ../../src/api/users/atoms/realmAuthSettingsAtom.d.ts
|
|
36
29
|
declare const realmAuthSettingsAtom: alepha23.Atom<alepha23.TObject<{
|
|
@@ -42,6 +35,7 @@ declare const realmAuthSettingsAtom: alepha23.Atom<alepha23.TObject<{
|
|
|
42
35
|
emailRequired: alepha23.TBoolean;
|
|
43
36
|
usernameEnabled: alepha23.TBoolean;
|
|
44
37
|
usernameRequired: alepha23.TBoolean;
|
|
38
|
+
usernameRegExp: alepha23.TString;
|
|
45
39
|
phoneEnabled: alepha23.TBoolean;
|
|
46
40
|
phoneRequired: alepha23.TBoolean;
|
|
47
41
|
verifyEmailRequired: alepha23.TBoolean;
|
|
@@ -89,114 +83,114 @@ type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]:
|
|
|
89
83
|
//#region ../../src/orm/primitives/$entity.d.ts
|
|
90
84
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
91
85
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
* The database table name that will be created for this entity.
|
|
87
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
88
|
+
*/
|
|
95
89
|
name: string;
|
|
96
90
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
* TypeBox schema defining the table structure and column types.
|
|
92
|
+
*/
|
|
99
93
|
schema: T;
|
|
100
94
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
* Database indexes to create for query optimization.
|
|
96
|
+
*/
|
|
103
97
|
indexes?: (Keys | {
|
|
104
98
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
* Single column to index.
|
|
100
|
+
*/
|
|
107
101
|
column: Keys;
|
|
108
102
|
/**
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
104
|
+
*/
|
|
111
105
|
unique?: boolean;
|
|
112
106
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
108
|
+
*/
|
|
115
109
|
name?: string;
|
|
116
110
|
} | {
|
|
117
111
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
113
|
+
*/
|
|
120
114
|
columns: Keys[];
|
|
121
115
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
117
|
+
*/
|
|
124
118
|
unique?: boolean;
|
|
125
119
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
121
|
+
*/
|
|
128
122
|
name?: string;
|
|
129
123
|
})[];
|
|
130
124
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
* Foreign key constraints to maintain referential integrity.
|
|
126
|
+
*/
|
|
133
127
|
foreignKeys?: Array<{
|
|
134
128
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
* Optional name for the foreign key constraint.
|
|
130
|
+
*/
|
|
137
131
|
name?: string;
|
|
138
132
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
133
|
+
* Local columns that reference the foreign table.
|
|
134
|
+
*/
|
|
141
135
|
columns: Array<keyof Static<T>>;
|
|
142
136
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
* Referenced columns in the foreign table.
|
|
138
|
+
* Must be EntityColumn references from other entities.
|
|
139
|
+
*/
|
|
146
140
|
foreignColumns: Array<() => EntityColumn<any>>;
|
|
147
141
|
}>;
|
|
148
142
|
/**
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
143
|
+
* Additional table constraints for data validation.
|
|
144
|
+
*
|
|
145
|
+
* Constraints enforce business rules at the database level, providing
|
|
146
|
+
* an additional layer of data integrity beyond application validation.
|
|
147
|
+
*
|
|
148
|
+
* **Constraint Types**:
|
|
149
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
150
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* constraints: [
|
|
155
|
+
* {
|
|
156
|
+
* name: "unique_user_email",
|
|
157
|
+
* columns: ["email"],
|
|
158
|
+
* unique: true
|
|
159
|
+
* },
|
|
160
|
+
* {
|
|
161
|
+
* name: "valid_age_range",
|
|
162
|
+
* columns: ["age"],
|
|
163
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
164
|
+
* },
|
|
165
|
+
* {
|
|
166
|
+
* name: "unique_user_username_per_tenant",
|
|
167
|
+
* columns: ["tenantId", "username"],
|
|
168
|
+
* unique: true
|
|
169
|
+
* }
|
|
170
|
+
* ]
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
179
173
|
constraints?: Array<{
|
|
180
174
|
/**
|
|
181
|
-
|
|
182
|
-
|
|
175
|
+
* Columns involved in this constraint.
|
|
176
|
+
*/
|
|
183
177
|
columns: Array<keyof Static<T>>;
|
|
184
178
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
* Optional name for the constraint.
|
|
180
|
+
*/
|
|
187
181
|
name?: string;
|
|
188
182
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
* Whether this is a unique constraint.
|
|
184
|
+
*/
|
|
191
185
|
unique?: boolean | {};
|
|
192
186
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
* SQL expression for check constraint validation.
|
|
188
|
+
*/
|
|
195
189
|
check?: SQL;
|
|
196
190
|
}>;
|
|
197
191
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
192
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
193
|
+
*/
|
|
200
194
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
201
195
|
}
|
|
202
196
|
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
@@ -250,8 +244,8 @@ type PgSymbols = {
|
|
|
250
244
|
[PG_REF]: PgRefOptions;
|
|
251
245
|
[PG_ENUM]: PgEnumOptions;
|
|
252
246
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
247
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
248
|
+
*/
|
|
255
249
|
[PG_SERIAL]: {};
|
|
256
250
|
};
|
|
257
251
|
type PgSymbolKeys = keyof PgSymbols;
|
|
@@ -284,416 +278,416 @@ declare class DbError extends AlephaError {
|
|
|
284
278
|
//#region ../../src/orm/interfaces/FilterOperators.d.ts
|
|
285
279
|
interface FilterOperators<TValue> {
|
|
286
280
|
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
281
|
+
* Test that two values are equal.
|
|
282
|
+
*
|
|
283
|
+
* Remember that the SQL standard dictates that
|
|
284
|
+
* two NULL values are not equal, so if you want to test
|
|
285
|
+
* whether a value is null, you may want to use
|
|
286
|
+
* `isNull` instead.
|
|
287
|
+
*
|
|
288
|
+
* ## Examples
|
|
289
|
+
*
|
|
290
|
+
* ```ts
|
|
291
|
+
* // Select cars made by Ford
|
|
292
|
+
* db.select().from(cars)
|
|
293
|
+
* .where(eq(cars.make, 'Ford'))
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @see isNull for a way to test equality to NULL.
|
|
297
|
+
*/
|
|
304
298
|
eq?: TValue;
|
|
305
299
|
/**
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
300
|
+
* Test that two values are not equal.
|
|
301
|
+
*
|
|
302
|
+
* Remember that the SQL standard dictates that
|
|
303
|
+
* two NULL values are not equal, so if you want to test
|
|
304
|
+
* whether a value is not null, you may want to use
|
|
305
|
+
* `isNotNull` instead.
|
|
306
|
+
*
|
|
307
|
+
* ## Examples
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Select cars not made by Ford
|
|
311
|
+
* db.select().from(cars)
|
|
312
|
+
* .where(ne(cars.make, 'Ford'))
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @see isNotNull for a way to test whether a value is not null.
|
|
316
|
+
*/
|
|
323
317
|
ne?: TValue;
|
|
324
318
|
/**
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
319
|
+
* Test that the first expression passed is greater than
|
|
320
|
+
* the second expression.
|
|
321
|
+
*
|
|
322
|
+
* ## Examples
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* // Select cars made after 2000.
|
|
326
|
+
* db.select().from(cars)
|
|
327
|
+
* .where(gt(cars.year, 2000))
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @see gte for greater-than-or-equal
|
|
331
|
+
*/
|
|
338
332
|
gt?: TValue;
|
|
339
333
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
334
|
+
* Test that the first expression passed is greater than
|
|
335
|
+
* or equal to the second expression. Use `gt` to
|
|
336
|
+
* test whether an expression is strictly greater
|
|
337
|
+
* than another.
|
|
338
|
+
*
|
|
339
|
+
* ## Examples
|
|
340
|
+
*
|
|
341
|
+
* ```ts
|
|
342
|
+
* // Select cars made on or after 2000.
|
|
343
|
+
* db.select().from(cars)
|
|
344
|
+
* .where(gte(cars.year, 2000))
|
|
345
|
+
* ```
|
|
346
|
+
*
|
|
347
|
+
* @see gt for a strictly greater-than condition
|
|
348
|
+
*/
|
|
355
349
|
gte?: TValue;
|
|
356
350
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
351
|
+
* Test that the first expression passed is less than
|
|
352
|
+
* the second expression.
|
|
353
|
+
*
|
|
354
|
+
* ## Examples
|
|
355
|
+
*
|
|
356
|
+
* ```ts
|
|
357
|
+
* // Select cars made before 2000.
|
|
358
|
+
* db.select().from(cars)
|
|
359
|
+
* .where(lt(cars.year, 2000))
|
|
360
|
+
* ```
|
|
361
|
+
*
|
|
362
|
+
* @see lte for greater-than-or-equal
|
|
363
|
+
*/
|
|
370
364
|
lt?: TValue;
|
|
371
365
|
/**
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
366
|
+
* Test that the first expression passed is less than
|
|
367
|
+
* or equal to the second expression.
|
|
368
|
+
*
|
|
369
|
+
* ## Examples
|
|
370
|
+
*
|
|
371
|
+
* ```ts
|
|
372
|
+
* // Select cars made before 2000.
|
|
373
|
+
* db.select().from(cars)
|
|
374
|
+
* .where(lte(cars.year, 2000))
|
|
375
|
+
* ```
|
|
376
|
+
*
|
|
377
|
+
* @see lt for a strictly less-than condition
|
|
378
|
+
*/
|
|
385
379
|
lte?: TValue;
|
|
386
380
|
/**
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
381
|
+
* Test whether the first parameter, a column or expression,
|
|
382
|
+
* has a value from a list passed as the second argument.
|
|
383
|
+
*
|
|
384
|
+
* ## Throws
|
|
385
|
+
*
|
|
386
|
+
* The argument passed in the second array can't be empty:
|
|
387
|
+
* if an empty is provided, this method will throw.
|
|
388
|
+
*
|
|
389
|
+
* ## Examples
|
|
390
|
+
*
|
|
391
|
+
* ```ts
|
|
392
|
+
* // Select cars made by Ford or GM.
|
|
393
|
+
* db.select().from(cars)
|
|
394
|
+
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @see notInArray for the inverse of this test
|
|
398
|
+
*/
|
|
405
399
|
inArray?: TValue[];
|
|
406
400
|
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
401
|
+
* Test whether the first parameter, a column or expression,
|
|
402
|
+
* has a value that is not present in a list passed as the
|
|
403
|
+
* second argument.
|
|
404
|
+
*
|
|
405
|
+
* ## Throws
|
|
406
|
+
*
|
|
407
|
+
* The argument passed in the second array can't be empty:
|
|
408
|
+
* if an empty is provided, this method will throw.
|
|
409
|
+
*
|
|
410
|
+
* ## Examples
|
|
411
|
+
*
|
|
412
|
+
* ```ts
|
|
413
|
+
* // Select cars made by any company except Ford or GM.
|
|
414
|
+
* db.select().from(cars)
|
|
415
|
+
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @see inArray for the inverse of this test
|
|
419
|
+
*/
|
|
426
420
|
notInArray?: TValue[];
|
|
427
421
|
/**
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
422
|
+
* Test whether an expression is not NULL. By the SQL standard,
|
|
423
|
+
* NULL is neither equal nor not equal to itself, so
|
|
424
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
425
|
+
* comparisons to NULL.
|
|
426
|
+
*
|
|
427
|
+
* ## Examples
|
|
428
|
+
*
|
|
429
|
+
* ```ts
|
|
430
|
+
* // Select cars that have been discontinued.
|
|
431
|
+
* db.select().from(cars)
|
|
432
|
+
* .where(isNotNull(cars.discontinuedAt))
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
435
|
+
* @see isNull for the inverse of this test
|
|
436
|
+
*/
|
|
443
437
|
isNotNull?: true;
|
|
444
438
|
/**
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
439
|
+
* Test whether an expression is NULL. By the SQL standard,
|
|
440
|
+
* NULL is neither equal nor not equal to itself, so
|
|
441
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
442
|
+
* comparisons to NULL.
|
|
443
|
+
*
|
|
444
|
+
* ## Examples
|
|
445
|
+
*
|
|
446
|
+
* ```ts
|
|
447
|
+
* // Select cars that have no discontinuedAt date.
|
|
448
|
+
* db.select().from(cars)
|
|
449
|
+
* .where(isNull(cars.discontinuedAt))
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* @see isNotNull for the inverse of this test
|
|
453
|
+
*/
|
|
460
454
|
isNull?: true;
|
|
461
455
|
/**
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
456
|
+
* Test whether an expression is between two values. This
|
|
457
|
+
* is an easier way to express range tests, which would be
|
|
458
|
+
* expressed mathematically as `x <= a <= y` but in SQL
|
|
459
|
+
* would have to be like `a >= x AND a <= y`.
|
|
460
|
+
*
|
|
461
|
+
* Between is inclusive of the endpoints: if `column`
|
|
462
|
+
* is equal to `min` or `max`, it will be TRUE.
|
|
463
|
+
*
|
|
464
|
+
* ## Examples
|
|
465
|
+
*
|
|
466
|
+
* ```ts
|
|
467
|
+
* // Select cars made between 1990 and 2000
|
|
468
|
+
* db.select().from(cars)
|
|
469
|
+
* .where(between(cars.year, 1990, 2000))
|
|
470
|
+
* ```
|
|
471
|
+
*
|
|
472
|
+
* @see notBetween for the inverse of this test
|
|
473
|
+
*/
|
|
480
474
|
between?: [number, number];
|
|
481
475
|
/**
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
476
|
+
* Test whether an expression is not between two values.
|
|
477
|
+
*
|
|
478
|
+
* This, like `between`, includes its endpoints, so if
|
|
479
|
+
* the `column` is equal to `min` or `max`, in this case
|
|
480
|
+
* it will evaluate to FALSE.
|
|
481
|
+
*
|
|
482
|
+
* ## Examples
|
|
483
|
+
*
|
|
484
|
+
* ```ts
|
|
485
|
+
* // Exclude cars made in the 1970s
|
|
486
|
+
* db.select().from(cars)
|
|
487
|
+
* .where(notBetween(cars.year, 1970, 1979))
|
|
488
|
+
* ```
|
|
489
|
+
*
|
|
490
|
+
* @see between for the inverse of this test
|
|
491
|
+
*/
|
|
498
492
|
notBetween?: [number, number];
|
|
499
493
|
/**
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
494
|
+
* Compare a column to a pattern, which can include `%` and `_`
|
|
495
|
+
* characters to match multiple variations. Including `%`
|
|
496
|
+
* in the pattern matches zero or more characters, and including
|
|
497
|
+
* `_` will match a single character.
|
|
498
|
+
*
|
|
499
|
+
* ## Examples
|
|
500
|
+
*
|
|
501
|
+
* ```ts
|
|
502
|
+
* // Select all cars with 'Turbo' in their names.
|
|
503
|
+
* db.select().from(cars)
|
|
504
|
+
* .where(like(cars.name, '%Turbo%'))
|
|
505
|
+
* ```
|
|
506
|
+
*
|
|
507
|
+
* @see ilike for a case-insensitive version of this condition
|
|
508
|
+
*/
|
|
515
509
|
like?: string;
|
|
516
510
|
/**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
511
|
+
* The inverse of like - this tests that a given column
|
|
512
|
+
* does not match a pattern, which can include `%` and `_`
|
|
513
|
+
* characters to match multiple variations. Including `%`
|
|
514
|
+
* in the pattern matches zero or more characters, and including
|
|
515
|
+
* `_` will match a single character.
|
|
516
|
+
*
|
|
517
|
+
* ## Examples
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* // Select all cars that don't have "ROver" in their name.
|
|
521
|
+
* db.select().from(cars)
|
|
522
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
523
|
+
* ```
|
|
524
|
+
*
|
|
525
|
+
* @see like for the inverse condition
|
|
526
|
+
* @see notIlike for a case-insensitive version of this condition
|
|
527
|
+
*/
|
|
534
528
|
notLike?: string;
|
|
535
529
|
/**
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
530
|
+
* Case-insensitively compare a column to a pattern,
|
|
531
|
+
* which can include `%` and `_`
|
|
532
|
+
* characters to match multiple variations. Including `%`
|
|
533
|
+
* in the pattern matches zero or more characters, and including
|
|
534
|
+
* `_` will match a single character.
|
|
535
|
+
*
|
|
536
|
+
* Unlike like, this performs a case-insensitive comparison.
|
|
537
|
+
*
|
|
538
|
+
* ## Examples
|
|
539
|
+
*
|
|
540
|
+
* ```ts
|
|
541
|
+
* // Select all cars with 'Turbo' in their names.
|
|
542
|
+
* db.select().from(cars)
|
|
543
|
+
* .where(ilike(cars.name, '%Turbo%'))
|
|
544
|
+
* ```
|
|
545
|
+
*
|
|
546
|
+
* @see like for a case-sensitive version of this condition
|
|
547
|
+
*/
|
|
554
548
|
ilike?: string;
|
|
555
549
|
/**
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
550
|
+
* The inverse of ilike - this case-insensitively tests that a given column
|
|
551
|
+
* does not match a pattern, which can include `%` and `_`
|
|
552
|
+
* characters to match multiple variations. Including `%`
|
|
553
|
+
* in the pattern matches zero or more characters, and including
|
|
554
|
+
* `_` will match a single character.
|
|
555
|
+
*
|
|
556
|
+
* ## Examples
|
|
557
|
+
*
|
|
558
|
+
* ```ts
|
|
559
|
+
* // Select all cars that don't have "Rover" in their name.
|
|
560
|
+
* db.select().from(cars)
|
|
561
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @see ilike for the inverse condition
|
|
565
|
+
* @see notLike for a case-sensitive version of this condition
|
|
566
|
+
*/
|
|
573
567
|
notIlike?: string;
|
|
574
568
|
/**
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
569
|
+
* Syntactic sugar for case-insensitive substring matching.
|
|
570
|
+
* Automatically wraps the value with `%` wildcards on both sides.
|
|
571
|
+
*
|
|
572
|
+
* Equivalent to: `ilike: '%value%'`
|
|
573
|
+
*
|
|
574
|
+
* ## Examples
|
|
575
|
+
*
|
|
576
|
+
* ```ts
|
|
577
|
+
* // Select all cars with "Turbo" anywhere in their name.
|
|
578
|
+
* db.select().from(cars)
|
|
579
|
+
* .where({ name: { contains: 'Turbo' } })
|
|
580
|
+
* // Same as: .where(ilike(cars.name, '%Turbo%'))
|
|
581
|
+
* ```
|
|
582
|
+
*
|
|
583
|
+
* @see ilike for manual pattern matching
|
|
584
|
+
* @see startsWith for prefix matching
|
|
585
|
+
* @see endsWith for suffix matching
|
|
586
|
+
*/
|
|
593
587
|
contains?: string;
|
|
594
588
|
/**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
589
|
+
* Syntactic sugar for case-insensitive prefix matching.
|
|
590
|
+
* Automatically appends a `%` wildcard to the end of the value.
|
|
591
|
+
*
|
|
592
|
+
* Equivalent to: `ilike: 'value%'`
|
|
593
|
+
*
|
|
594
|
+
* ## Examples
|
|
595
|
+
*
|
|
596
|
+
* ```ts
|
|
597
|
+
* // Select all cars whose names start with "Ford".
|
|
598
|
+
* db.select().from(cars)
|
|
599
|
+
* .where({ name: { startsWith: 'Ford' } })
|
|
600
|
+
* // Same as: .where(ilike(cars.name, 'Ford%'))
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @see ilike for manual pattern matching
|
|
604
|
+
* @see contains for substring matching
|
|
605
|
+
* @see endsWith for suffix matching
|
|
606
|
+
*/
|
|
613
607
|
startsWith?: string;
|
|
614
608
|
/**
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
609
|
+
* Syntactic sugar for case-insensitive suffix matching.
|
|
610
|
+
* Automatically prepends a `%` wildcard to the beginning of the value.
|
|
611
|
+
*
|
|
612
|
+
* Equivalent to: `ilike: '%value'`
|
|
613
|
+
*
|
|
614
|
+
* ## Examples
|
|
615
|
+
*
|
|
616
|
+
* ```ts
|
|
617
|
+
* // Select all cars whose names end with "Turbo".
|
|
618
|
+
* db.select().from(cars)
|
|
619
|
+
* .where({ name: { endsWith: 'Turbo' } })
|
|
620
|
+
* // Same as: .where(ilike(cars.name, '%Turbo'))
|
|
621
|
+
* ```
|
|
622
|
+
*
|
|
623
|
+
* @see ilike for manual pattern matching
|
|
624
|
+
* @see contains for substring matching
|
|
625
|
+
* @see startsWith for prefix matching
|
|
626
|
+
*/
|
|
633
627
|
endsWith?: string;
|
|
634
628
|
/**
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
629
|
+
* Test that a column or expression contains all elements of
|
|
630
|
+
* the list passed as the second argument.
|
|
631
|
+
*
|
|
632
|
+
* ## Throws
|
|
633
|
+
*
|
|
634
|
+
* The argument passed in the second array can't be empty:
|
|
635
|
+
* if an empty is provided, this method will throw.
|
|
636
|
+
*
|
|
637
|
+
* ## Examples
|
|
638
|
+
*
|
|
639
|
+
* ```ts
|
|
640
|
+
* // Select posts where its tags contain "Typescript" and "ORM".
|
|
641
|
+
* db.select().from(posts)
|
|
642
|
+
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
|
643
|
+
* ```
|
|
644
|
+
*
|
|
645
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
646
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
647
|
+
*/
|
|
654
648
|
arrayContains?: TValue;
|
|
655
649
|
/**
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
650
|
+
* Test that the list passed as the second argument contains
|
|
651
|
+
* all elements of a column or expression.
|
|
652
|
+
*
|
|
653
|
+
* ## Throws
|
|
654
|
+
*
|
|
655
|
+
* The argument passed in the second array can't be empty:
|
|
656
|
+
* if an empty is provided, this method will throw.
|
|
657
|
+
*
|
|
658
|
+
* ## Examples
|
|
659
|
+
*
|
|
660
|
+
* ```ts
|
|
661
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
|
662
|
+
* // but filtering posts that have additional tags.
|
|
663
|
+
* db.select().from(posts)
|
|
664
|
+
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
|
665
|
+
* ```
|
|
666
|
+
*
|
|
667
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
668
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
669
|
+
*/
|
|
676
670
|
arrayContained?: TValue;
|
|
677
671
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
672
|
+
* Test that a column or expression contains any elements of
|
|
673
|
+
* the list passed as the second argument.
|
|
674
|
+
*
|
|
675
|
+
* ## Throws
|
|
676
|
+
*
|
|
677
|
+
* The argument passed in the second array can't be empty:
|
|
678
|
+
* if an empty is provided, this method will throw.
|
|
679
|
+
*
|
|
680
|
+
* ## Examples
|
|
681
|
+
*
|
|
682
|
+
* ```ts
|
|
683
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
|
684
|
+
* db.select().from(posts)
|
|
685
|
+
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
689
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
690
|
+
*/
|
|
697
691
|
arrayOverlaps?: TValue;
|
|
698
692
|
}
|
|
699
693
|
//#endregion
|
|
@@ -752,71 +746,71 @@ type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObjec
|
|
|
752
746
|
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
|
|
753
747
|
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
754
748
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
749
|
+
* Combine a list of conditions with the `and` operator. Conditions
|
|
750
|
+
* that are equal `undefined` are automatically ignored.
|
|
751
|
+
*
|
|
752
|
+
* ## Examples
|
|
753
|
+
*
|
|
754
|
+
* ```ts
|
|
755
|
+
* db.select().from(cars)
|
|
756
|
+
* .where(
|
|
757
|
+
* and(
|
|
758
|
+
* eq(cars.make, 'Volvo'),
|
|
759
|
+
* eq(cars.year, 1950),
|
|
760
|
+
* )
|
|
761
|
+
* )
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
770
764
|
and?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
771
765
|
/**
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
766
|
+
* Combine a list of conditions with the `or` operator. Conditions
|
|
767
|
+
* that are equal `undefined` are automatically ignored.
|
|
768
|
+
*
|
|
769
|
+
* ## Examples
|
|
770
|
+
*
|
|
771
|
+
* ```ts
|
|
772
|
+
* db.select().from(cars)
|
|
773
|
+
* .where(
|
|
774
|
+
* or(
|
|
775
|
+
* eq(cars.make, 'GM'),
|
|
776
|
+
* eq(cars.make, 'Ford'),
|
|
777
|
+
* )
|
|
778
|
+
* )
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
787
781
|
or?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
788
782
|
/**
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
783
|
+
* Negate the meaning of an expression using the `not` keyword.
|
|
784
|
+
*
|
|
785
|
+
* ## Examples
|
|
786
|
+
*
|
|
787
|
+
* ```ts
|
|
788
|
+
* // Select cars _not_ made by GM or Ford.
|
|
789
|
+
* db.select().from(cars)
|
|
790
|
+
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
799
793
|
not?: PgQueryWhereOrSQL<T, Relations>;
|
|
800
794
|
/**
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
795
|
+
* Test whether a subquery evaluates to have any rows.
|
|
796
|
+
*
|
|
797
|
+
* ## Examples
|
|
798
|
+
*
|
|
799
|
+
* ```ts
|
|
800
|
+
* // Users whose `homeCity` column has a match in a cities
|
|
801
|
+
* // table.
|
|
802
|
+
* db
|
|
803
|
+
* .select()
|
|
804
|
+
* .from(users)
|
|
805
|
+
* .where(
|
|
806
|
+
* exists(db.select()
|
|
807
|
+
* .from(cities)
|
|
808
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
809
|
+
* );
|
|
810
|
+
* ```
|
|
811
|
+
*
|
|
812
|
+
* @see notExists for the inverse of this test
|
|
813
|
+
*/
|
|
820
814
|
exists?: SQLWrapper;
|
|
821
815
|
};
|
|
822
816
|
type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
|
|
@@ -837,8 +831,8 @@ interface PgAttrField {
|
|
|
837
831
|
//#region ../../src/orm/primitives/$sequence.d.ts
|
|
838
832
|
interface SequencePrimitiveOptions extends PgSequenceOptions {
|
|
839
833
|
/**
|
|
840
|
-
|
|
841
|
-
|
|
834
|
+
* The name of the sequence. If not provided, the property key will be used.
|
|
835
|
+
*/
|
|
842
836
|
name?: string;
|
|
843
837
|
provider?: DatabaseProvider;
|
|
844
838
|
}
|
|
@@ -878,33 +872,33 @@ interface TableConfigBuilders<TConfig> {
|
|
|
878
872
|
*/
|
|
879
873
|
declare abstract class ModelBuilder {
|
|
880
874
|
/**
|
|
881
|
-
|
|
882
|
-
|
|
875
|
+
* Build a table from an entity primitive.
|
|
876
|
+
*/
|
|
883
877
|
abstract buildTable(entity: EntityPrimitive, options: {
|
|
884
878
|
tables: Map<string, unknown>;
|
|
885
879
|
enums: Map<string, unknown>;
|
|
886
880
|
schema: string;
|
|
887
881
|
}): void;
|
|
888
882
|
/**
|
|
889
|
-
|
|
890
|
-
|
|
883
|
+
* Build a sequence from a sequence primitive.
|
|
884
|
+
*/
|
|
891
885
|
abstract buildSequence(sequence: SequencePrimitive, options: {
|
|
892
886
|
sequences: Map<string, unknown>;
|
|
893
887
|
schema: string;
|
|
894
888
|
}): void;
|
|
895
889
|
/**
|
|
896
|
-
|
|
897
|
-
|
|
890
|
+
* Convert camelCase to snake_case for column names.
|
|
891
|
+
*/
|
|
898
892
|
protected toColumnName(str: string): string;
|
|
899
893
|
/**
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
894
|
+
* Build the table configuration function for any database.
|
|
895
|
+
* This includes indexes, foreign keys, constraints, and custom config.
|
|
896
|
+
*
|
|
897
|
+
* @param entity - The entity primitive
|
|
898
|
+
* @param builders - Database-specific builder functions
|
|
899
|
+
* @param tableResolver - Function to resolve entity references to table columns
|
|
900
|
+
* @param customConfigHandler - Optional handler for custom config
|
|
901
|
+
*/
|
|
908
902
|
protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
909
903
|
}
|
|
910
904
|
//#endregion
|
|
@@ -913,37 +907,37 @@ declare class DrizzleKitProvider {
|
|
|
913
907
|
protected readonly log: alepha_logger5.Logger;
|
|
914
908
|
protected readonly alepha: Alepha;
|
|
915
909
|
/**
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
910
|
+
* Synchronize database with current schema definitions.
|
|
911
|
+
*
|
|
912
|
+
* In development mode, it will generate and execute migrations based on the current state.
|
|
913
|
+
* In testing mode, it will generate migrations from scratch without applying them.
|
|
914
|
+
*
|
|
915
|
+
* Does nothing in production mode, you must handle migrations manually.
|
|
916
|
+
*/
|
|
923
917
|
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
924
918
|
/**
|
|
925
|
-
|
|
926
|
-
|
|
919
|
+
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
920
|
+
*/
|
|
927
921
|
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
928
922
|
statements: string[];
|
|
929
923
|
models: Record<string, unknown>;
|
|
930
924
|
snapshot?: any;
|
|
931
925
|
}>;
|
|
932
926
|
/**
|
|
933
|
-
|
|
934
|
-
|
|
927
|
+
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
928
|
+
*/
|
|
935
929
|
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
936
930
|
/**
|
|
937
|
-
|
|
938
|
-
|
|
931
|
+
* Load the migration snapshot from the database.
|
|
932
|
+
*/
|
|
939
933
|
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
940
934
|
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
941
935
|
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
942
936
|
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
943
937
|
/**
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
938
|
+
* Try to load the official Drizzle Kit API.
|
|
939
|
+
* If not available, fallback to the local kit import.
|
|
940
|
+
*/
|
|
947
941
|
importDrizzleKit(): typeof DrizzleKit;
|
|
948
942
|
}
|
|
949
943
|
declare const devMigrationsSchema: alepha23.TObject<{
|
|
@@ -968,6 +962,7 @@ declare abstract class DatabaseProvider {
|
|
|
968
962
|
readonly tables: Map<string, unknown>;
|
|
969
963
|
readonly sequences: Map<string, unknown>;
|
|
970
964
|
get name(): string;
|
|
965
|
+
get driver(): string;
|
|
971
966
|
get schema(): string;
|
|
972
967
|
table<T extends TObject>(entity: EntityPrimitive<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
973
968
|
registerEntity(entity: EntityPrimitive): void;
|
|
@@ -975,39 +970,39 @@ declare abstract class DatabaseProvider {
|
|
|
975
970
|
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
976
971
|
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
977
972
|
/**
|
|
978
|
-
|
|
979
|
-
|
|
973
|
+
* Get migrations folder path - can be overridden
|
|
974
|
+
*/
|
|
980
975
|
protected getMigrationsFolder(): string;
|
|
981
976
|
/**
|
|
982
|
-
|
|
983
|
-
|
|
977
|
+
* Base migration orchestration - handles environment logic
|
|
978
|
+
*/
|
|
984
979
|
migrate(): Promise<void>;
|
|
985
980
|
/**
|
|
986
|
-
|
|
987
|
-
|
|
981
|
+
* Production: run migrations from folder
|
|
982
|
+
*/
|
|
988
983
|
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
989
984
|
/**
|
|
990
|
-
|
|
991
|
-
|
|
985
|
+
* Test: always synchronize
|
|
986
|
+
*/
|
|
992
987
|
protected runTestMigration(): Promise<void>;
|
|
993
988
|
/**
|
|
994
|
-
|
|
995
|
-
|
|
989
|
+
* Development: default to synchronize (can be overridden)
|
|
990
|
+
*/
|
|
996
991
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
997
992
|
/**
|
|
998
|
-
|
|
999
|
-
|
|
993
|
+
* Common synchronization with error handling
|
|
994
|
+
*/
|
|
1000
995
|
protected synchronizeSchema(): Promise<void>;
|
|
1001
996
|
/**
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
997
|
+
* Provider-specific migration execution
|
|
998
|
+
* MUST be implemented by each provider
|
|
999
|
+
*/
|
|
1005
1000
|
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1006
1001
|
/**
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1002
|
+
* For testing purposes, generate a unique schema name.
|
|
1003
|
+
* The schema name will be generated based on the current date and time.
|
|
1004
|
+
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
1005
|
+
*/
|
|
1011
1006
|
protected generateTestSchemaName(): string;
|
|
1012
1007
|
}
|
|
1013
1008
|
//#endregion
|
|
@@ -1015,8 +1010,8 @@ declare abstract class DatabaseProvider {
|
|
|
1015
1010
|
declare class QueryManager {
|
|
1016
1011
|
protected readonly alepha: Alepha;
|
|
1017
1012
|
/**
|
|
1018
|
-
|
|
1019
|
-
|
|
1013
|
+
* Convert a query object to a SQL query.
|
|
1014
|
+
*/
|
|
1020
1015
|
toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
|
|
1021
1016
|
schema: TObject;
|
|
1022
1017
|
col: (key: string) => PgColumn;
|
|
@@ -1024,22 +1019,22 @@ declare class QueryManager {
|
|
|
1024
1019
|
dialect: "postgresql" | "sqlite";
|
|
1025
1020
|
}): SQL | undefined;
|
|
1026
1021
|
/**
|
|
1027
|
-
|
|
1028
|
-
|
|
1022
|
+
* Check if an object has any filter operator properties.
|
|
1023
|
+
*/
|
|
1029
1024
|
protected hasFilterOperatorProperties(obj: any): boolean;
|
|
1030
1025
|
/**
|
|
1031
|
-
|
|
1032
|
-
|
|
1026
|
+
* Map a filter operator to a SQL query.
|
|
1027
|
+
*/
|
|
1033
1028
|
mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
|
|
1034
1029
|
/**
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1030
|
+
* Parse pagination sort string to orderBy format.
|
|
1031
|
+
* Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
|
|
1032
|
+
* - Columns separated by comma
|
|
1033
|
+
* - Prefix with '-' for DESC direction
|
|
1034
|
+
*
|
|
1035
|
+
* @param sort Pagination sort string
|
|
1036
|
+
* @returns OrderBy array or single object
|
|
1037
|
+
*/
|
|
1043
1038
|
parsePaginationSort(sort: string): Array<{
|
|
1044
1039
|
column: string;
|
|
1045
1040
|
direction: "asc" | "desc";
|
|
@@ -1048,30 +1043,30 @@ declare class QueryManager {
|
|
|
1048
1043
|
direction: "asc" | "desc";
|
|
1049
1044
|
};
|
|
1050
1045
|
/**
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1046
|
+
* Normalize orderBy parameter to array format.
|
|
1047
|
+
* Supports 3 modes:
|
|
1048
|
+
* 1. String: "name" -> [{ column: "name", direction: "asc" }]
|
|
1049
|
+
* 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
|
|
1050
|
+
* 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
|
|
1051
|
+
*
|
|
1052
|
+
* @param orderBy The orderBy parameter
|
|
1053
|
+
* @returns Normalized array of order by clauses
|
|
1054
|
+
*/
|
|
1060
1055
|
normalizeOrderBy(orderBy: any): Array<{
|
|
1061
1056
|
column: string;
|
|
1062
1057
|
direction: "asc" | "desc";
|
|
1063
1058
|
}>;
|
|
1064
1059
|
/**
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1060
|
+
* Create a pagination object.
|
|
1061
|
+
*
|
|
1062
|
+
* @deprecated Use `createPagination` from alepha instead.
|
|
1063
|
+
* This method now delegates to the framework-level helper.
|
|
1064
|
+
*
|
|
1065
|
+
* @param entities The entities to paginate.
|
|
1066
|
+
* @param limit The limit of the pagination.
|
|
1067
|
+
* @param offset The offset of the pagination.
|
|
1068
|
+
* @param sort Optional sort metadata to include in response.
|
|
1069
|
+
*/
|
|
1075
1070
|
createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
|
|
1076
1071
|
column: string;
|
|
1077
1072
|
direction: "asc" | "desc";
|
|
@@ -1088,20 +1083,20 @@ interface PgJoin {
|
|
|
1088
1083
|
//#region ../../src/orm/services/PgRelationManager.d.ts
|
|
1089
1084
|
declare class PgRelationManager {
|
|
1090
1085
|
/**
|
|
1091
|
-
|
|
1092
|
-
|
|
1086
|
+
* Recursively build joins for the query builder based on the relations map
|
|
1087
|
+
*/
|
|
1093
1088
|
buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
|
|
1094
1089
|
/**
|
|
1095
|
-
|
|
1096
|
-
|
|
1090
|
+
* Map a row with its joined relations based on the joins definition
|
|
1091
|
+
*/
|
|
1097
1092
|
mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
|
|
1098
1093
|
/**
|
|
1099
|
-
|
|
1100
|
-
|
|
1094
|
+
* Check if all values in an object are null (indicates a left join with no match)
|
|
1095
|
+
*/
|
|
1101
1096
|
private isAllNull;
|
|
1102
1097
|
/**
|
|
1103
|
-
|
|
1104
|
-
|
|
1098
|
+
* Build a schema that includes all join properties recursively
|
|
1099
|
+
*/
|
|
1105
1100
|
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1106
1101
|
}
|
|
1107
1102
|
//#endregion
|
|
@@ -1109,216 +1104,217 @@ declare class PgRelationManager {
|
|
|
1109
1104
|
declare abstract class Repository$1<T extends TObject> {
|
|
1110
1105
|
readonly entity: EntityPrimitive<T>;
|
|
1111
1106
|
readonly provider: DatabaseProvider;
|
|
1107
|
+
protected readonly log: alepha_logger5.Logger;
|
|
1112
1108
|
protected readonly relationManager: PgRelationManager;
|
|
1113
1109
|
protected readonly queryManager: QueryManager;
|
|
1114
1110
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1115
1111
|
protected readonly alepha: Alepha;
|
|
1116
1112
|
constructor(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider);
|
|
1117
1113
|
/**
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1114
|
+
* Represents the primary key of the table.
|
|
1115
|
+
* - Key is the name of the primary key column.
|
|
1116
|
+
* - Type is the type (TypeBox) of the primary key column.
|
|
1117
|
+
*
|
|
1118
|
+
* ID is mandatory. If the table does not have a primary key, it will throw an error.
|
|
1119
|
+
*/
|
|
1124
1120
|
get id(): {
|
|
1125
1121
|
type: TSchema;
|
|
1126
1122
|
key: keyof T["properties"];
|
|
1127
1123
|
col: PgColumn;
|
|
1128
1124
|
};
|
|
1129
1125
|
/**
|
|
1130
|
-
|
|
1131
|
-
|
|
1126
|
+
* Get Drizzle table object.
|
|
1127
|
+
*/
|
|
1132
1128
|
get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1133
1129
|
/**
|
|
1134
|
-
|
|
1135
|
-
|
|
1130
|
+
* Get SQL table name. (from Drizzle table object)
|
|
1131
|
+
*/
|
|
1136
1132
|
get tableName(): string;
|
|
1137
1133
|
/**
|
|
1138
|
-
|
|
1139
|
-
|
|
1134
|
+
* Getter for the database connection from the database provider.
|
|
1135
|
+
*/
|
|
1140
1136
|
protected get db(): PgDatabase<any>;
|
|
1141
1137
|
/**
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1138
|
+
* Execute a SQL query.
|
|
1139
|
+
*
|
|
1140
|
+
* This method allows executing raw SQL queries against the database.
|
|
1141
|
+
* This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
|
|
1142
|
+
*
|
|
1143
|
+
* You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* ```ts
|
|
1147
|
+
* class App {
|
|
1148
|
+
* repository = $repository({ ... });
|
|
1149
|
+
* async getAdults() {
|
|
1150
|
+
* const users = repository.table; // Drizzle table object
|
|
1151
|
+
* await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1152
|
+
* // or better
|
|
1153
|
+
* await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1154
|
+
* }
|
|
1155
|
+
* }
|
|
1156
|
+
* ```
|
|
1157
|
+
*/
|
|
1162
1158
|
query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
|
|
1163
1159
|
/**
|
|
1164
|
-
|
|
1165
|
-
|
|
1160
|
+
* Map raw database fields to entity fields. (handles column name differences)
|
|
1161
|
+
*/
|
|
1166
1162
|
protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
|
|
1167
1163
|
/**
|
|
1168
|
-
|
|
1169
|
-
|
|
1164
|
+
* Get a Drizzle column from the table by his name.
|
|
1165
|
+
*/
|
|
1170
1166
|
protected col(name: keyof StaticEncode<T>): PgColumn;
|
|
1171
1167
|
/**
|
|
1172
|
-
|
|
1173
|
-
|
|
1168
|
+
* Run a transaction.
|
|
1169
|
+
*/
|
|
1174
1170
|
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
1175
1171
|
/**
|
|
1176
|
-
|
|
1177
|
-
|
|
1172
|
+
* Start a SELECT query on the table.
|
|
1173
|
+
*/
|
|
1178
1174
|
protected rawSelect(opts?: StatementOptions): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>>, "single", Record<string, "not-null">, false, never, {
|
|
1179
1175
|
[x: string]: unknown;
|
|
1180
1176
|
}[], {
|
|
1181
1177
|
[x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
1182
1178
|
}>;
|
|
1183
1179
|
/**
|
|
1184
|
-
|
|
1185
|
-
|
|
1180
|
+
* Start a SELECT DISTINCT query on the table.
|
|
1181
|
+
*/
|
|
1186
1182
|
protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
|
|
1187
1183
|
[x: string]: any;
|
|
1188
1184
|
}[], {
|
|
1189
1185
|
[x: string]: any;
|
|
1190
1186
|
}>;
|
|
1191
1187
|
/**
|
|
1192
|
-
|
|
1193
|
-
|
|
1188
|
+
* Start an INSERT query on the table.
|
|
1189
|
+
*/
|
|
1194
1190
|
protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
|
|
1195
1191
|
/**
|
|
1196
|
-
|
|
1197
|
-
|
|
1192
|
+
* Start an UPDATE query on the table.
|
|
1193
|
+
*/
|
|
1198
1194
|
protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
|
|
1199
1195
|
/**
|
|
1200
|
-
|
|
1201
|
-
|
|
1196
|
+
* Start a DELETE query on the table.
|
|
1197
|
+
*/
|
|
1202
1198
|
protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
|
|
1203
1199
|
/**
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1200
|
+
* Create a Drizzle `select` query based on a JSON query object.
|
|
1201
|
+
*
|
|
1202
|
+
* > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
|
|
1203
|
+
*/
|
|
1208
1204
|
findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
|
|
1209
1205
|
/**
|
|
1210
|
-
|
|
1211
|
-
|
|
1206
|
+
* Find a single entity.
|
|
1207
|
+
*/
|
|
1212
1208
|
findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
|
|
1213
1209
|
/**
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1210
|
+
* Find entities with pagination.
|
|
1211
|
+
*
|
|
1212
|
+
* It uses the same parameters as `find()`, but adds pagination metadata to the response.
|
|
1213
|
+
*
|
|
1214
|
+
* > Pagination CAN also do a count query to get the total number of elements.
|
|
1215
|
+
*/
|
|
1220
1216
|
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1221
1217
|
count?: boolean;
|
|
1222
1218
|
}): Promise<Page<PgStatic<T, R>>>;
|
|
1223
1219
|
/**
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1220
|
+
* Find an entity by ID.
|
|
1221
|
+
*
|
|
1222
|
+
* This is a convenience method for `findOne` with a where clause on the primary key.
|
|
1223
|
+
* If you need more complex queries, use `findOne` instead.
|
|
1224
|
+
*/
|
|
1229
1225
|
findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
|
|
1230
1226
|
/**
|
|
1231
|
-
|
|
1232
|
-
|
|
1227
|
+
* Helper to create a type-safe query object.
|
|
1228
|
+
*/
|
|
1233
1229
|
createQuery(): PgQuery<T>;
|
|
1234
1230
|
/**
|
|
1235
|
-
|
|
1236
|
-
|
|
1231
|
+
* Helper to create a type-safe where clause.
|
|
1232
|
+
*/
|
|
1237
1233
|
createQueryWhere(): PgQueryWhere<T>;
|
|
1238
1234
|
/**
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1235
|
+
* Create an entity.
|
|
1236
|
+
*
|
|
1237
|
+
* @param data The entity to create.
|
|
1238
|
+
* @param opts The options for creating the entity.
|
|
1239
|
+
* @returns The ID of the created entity.
|
|
1240
|
+
*/
|
|
1245
1241
|
create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1246
1242
|
/**
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1243
|
+
* Create many entities.
|
|
1244
|
+
*
|
|
1245
|
+
* Inserts are batched in chunks of 1000 to avoid hitting database limits.
|
|
1246
|
+
*
|
|
1247
|
+
* @param values The entities to create.
|
|
1248
|
+
* @param opts The statement options.
|
|
1249
|
+
* @returns The created entities.
|
|
1250
|
+
*/
|
|
1255
1251
|
createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions & {
|
|
1256
1252
|
batchSize?: number;
|
|
1257
1253
|
}): Promise<Static<T>[]>;
|
|
1258
1254
|
/**
|
|
1259
|
-
|
|
1260
|
-
|
|
1255
|
+
* Find an entity and update it.
|
|
1256
|
+
*/
|
|
1261
1257
|
updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1262
1258
|
/**
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1259
|
+
* Save a given entity.
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```ts
|
|
1263
|
+
* const entity = await repository.findById(1);
|
|
1264
|
+
* entity.name = "New Name"; // update a field
|
|
1265
|
+
* delete entity.description; // delete a field
|
|
1266
|
+
* await repository.save(entity);
|
|
1267
|
+
* ```
|
|
1268
|
+
*
|
|
1269
|
+
* Difference with `updateById/updateOne`:
|
|
1270
|
+
*
|
|
1271
|
+
* - requires the entity to be fetched first (whole object is expected)
|
|
1272
|
+
* - check pg.version() if present -> optimistic locking
|
|
1273
|
+
* - validate entity against schema
|
|
1274
|
+
* - undefined values will be set to null, not ignored!
|
|
1275
|
+
*
|
|
1276
|
+
* @see {@link DbVersionMismatchError}
|
|
1277
|
+
*/
|
|
1282
1278
|
save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
|
|
1283
1279
|
/**
|
|
1284
|
-
|
|
1285
|
-
|
|
1280
|
+
* Find an entity by ID and update it.
|
|
1281
|
+
*/
|
|
1286
1282
|
updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1287
1283
|
/**
|
|
1288
|
-
|
|
1289
|
-
|
|
1284
|
+
* Find many entities and update all of them.
|
|
1285
|
+
*/
|
|
1290
1286
|
updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1291
1287
|
/**
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1288
|
+
* Find many and delete all of them.
|
|
1289
|
+
* @returns Array of deleted entity IDs
|
|
1290
|
+
*/
|
|
1295
1291
|
deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1296
1292
|
/**
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1293
|
+
* Delete all entities.
|
|
1294
|
+
* @returns Array of deleted entity IDs
|
|
1295
|
+
*/
|
|
1300
1296
|
clear(opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1301
1297
|
/**
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1298
|
+
* Delete the given entity.
|
|
1299
|
+
*
|
|
1300
|
+
* You must fetch the entity first in order to delete it.
|
|
1301
|
+
* @returns Array containing the deleted entity ID
|
|
1302
|
+
*/
|
|
1307
1303
|
destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1308
1304
|
/**
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1305
|
+
* Find an entity and delete it.
|
|
1306
|
+
* @returns Array of deleted entity IDs (should contain at most one ID)
|
|
1307
|
+
*/
|
|
1312
1308
|
deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1313
1309
|
/**
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1310
|
+
* Find an entity by ID and delete it.
|
|
1311
|
+
* @returns Array containing the deleted entity ID
|
|
1312
|
+
* @throws DbEntityNotFoundError if the entity is not found
|
|
1313
|
+
*/
|
|
1318
1314
|
deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1319
1315
|
/**
|
|
1320
|
-
|
|
1321
|
-
|
|
1316
|
+
* Count entities.
|
|
1317
|
+
*/
|
|
1322
1318
|
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
1323
1319
|
protected conflictMessagePattern: string;
|
|
1324
1320
|
protected handleError(error: unknown, message: string): DbError;
|
|
@@ -1327,31 +1323,31 @@ declare abstract class Repository$1<T extends TObject> {
|
|
|
1327
1323
|
}): PgQueryWhereOrSQL<T>;
|
|
1328
1324
|
protected deletedAt(): PgAttrField | undefined;
|
|
1329
1325
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1326
|
+
* Convert something to valid Pg Insert Value.
|
|
1327
|
+
*/
|
|
1332
1328
|
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
|
|
1333
1329
|
/**
|
|
1334
|
-
|
|
1335
|
-
|
|
1330
|
+
* Transform a row from the database into a clean entity.
|
|
1331
|
+
*/
|
|
1336
1332
|
protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
|
|
1337
1333
|
/**
|
|
1338
|
-
|
|
1339
|
-
|
|
1334
|
+
* Clean a row with joins recursively
|
|
1335
|
+
*/
|
|
1340
1336
|
protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
|
|
1341
1337
|
/**
|
|
1342
|
-
|
|
1343
|
-
|
|
1338
|
+
* Convert a where clause to SQL.
|
|
1339
|
+
*/
|
|
1344
1340
|
protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
|
|
1345
1341
|
/**
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1342
|
+
* Get the where clause for an ID.
|
|
1343
|
+
*
|
|
1344
|
+
* @param id The ID to get the where clause for.
|
|
1345
|
+
* @returns The where clause for the ID.
|
|
1346
|
+
*/
|
|
1351
1347
|
protected getWhereId(id: string | number): PgQueryWhere<T>;
|
|
1352
1348
|
/**
|
|
1353
|
-
|
|
1354
|
-
|
|
1349
|
+
* Find a primary key in the schema.
|
|
1350
|
+
*/
|
|
1355
1351
|
protected getPrimaryKey(schema: TObject): {
|
|
1356
1352
|
key: string;
|
|
1357
1353
|
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
@@ -1363,210 +1359,26 @@ declare abstract class Repository$1<T extends TObject> {
|
|
|
1363
1359
|
*/
|
|
1364
1360
|
interface StatementOptions {
|
|
1365
1361
|
/**
|
|
1366
|
-
|
|
1367
|
-
|
|
1362
|
+
* Transaction to use.
|
|
1363
|
+
*/
|
|
1368
1364
|
tx?: PgTransaction<any, Record<string, any>>;
|
|
1369
1365
|
/**
|
|
1370
|
-
|
|
1371
|
-
|
|
1366
|
+
* Lock strength.
|
|
1367
|
+
*/
|
|
1372
1368
|
for?: LockStrength | {
|
|
1373
1369
|
config: LockConfig;
|
|
1374
1370
|
strength: LockStrength;
|
|
1375
1371
|
};
|
|
1376
1372
|
/**
|
|
1377
|
-
|
|
1378
|
-
|
|
1373
|
+
* If true, ignore soft delete.
|
|
1374
|
+
*/
|
|
1379
1375
|
force?: boolean;
|
|
1380
1376
|
/**
|
|
1381
|
-
|
|
1382
|
-
|
|
1377
|
+
* Force the current time.
|
|
1378
|
+
*/
|
|
1383
1379
|
now?: DateTime | string;
|
|
1384
1380
|
}
|
|
1385
1381
|
//#endregion
|
|
1386
|
-
//#region ../../src/orm/providers/drivers/BunPostgresProvider.d.ts
|
|
1387
|
-
declare module "alepha" {
|
|
1388
|
-
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
1389
|
-
}
|
|
1390
|
-
declare const envSchema$1: alepha23.TObject<{
|
|
1391
|
-
/**
|
|
1392
|
-
* Main configuration for database connection.
|
|
1393
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
1394
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
1395
|
-
* or
|
|
1396
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
1397
|
-
*/
|
|
1398
|
-
DATABASE_URL: alepha23.TOptional<alepha23.TString>;
|
|
1399
|
-
/**
|
|
1400
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1401
|
-
*/
|
|
1402
|
-
POSTGRES_SCHEMA: alepha23.TOptional<alepha23.TString>;
|
|
1403
|
-
}>;
|
|
1404
|
-
/**
|
|
1405
|
-
* Bun PostgreSQL provider using Drizzle ORM with Bun's native SQL client.
|
|
1406
|
-
*
|
|
1407
|
-
* This provider uses Bun's built-in SQL class for PostgreSQL connections,
|
|
1408
|
-
* which provides excellent performance on the Bun runtime.
|
|
1409
|
-
*
|
|
1410
|
-
* @example
|
|
1411
|
-
* ```ts
|
|
1412
|
-
* // Set DATABASE_URL environment variable
|
|
1413
|
-
* // DATABASE_URL=postgres://user:password@localhost:5432/database
|
|
1414
|
-
*
|
|
1415
|
-
* // Or configure programmatically
|
|
1416
|
-
* alepha.with({
|
|
1417
|
-
* provide: DatabaseProvider,
|
|
1418
|
-
* use: BunPostgresProvider,
|
|
1419
|
-
* });
|
|
1420
|
-
* ```
|
|
1421
|
-
*/
|
|
1422
|
-
//#endregion
|
|
1423
|
-
//#region ../../src/orm/providers/drivers/BunSqliteProvider.d.ts
|
|
1424
|
-
/**
|
|
1425
|
-
* Configuration options for the Bun SQLite database provider.
|
|
1426
|
-
*/
|
|
1427
|
-
declare const bunSqliteOptions: alepha23.Atom<alepha23.TObject<{
|
|
1428
|
-
path: alepha23.TOptional<alepha23.TString>;
|
|
1429
|
-
}>, "alepha.postgres.bun-sqlite.options">;
|
|
1430
|
-
type BunSqliteProviderOptions = Static<typeof bunSqliteOptions.schema>;
|
|
1431
|
-
declare module "alepha" {
|
|
1432
|
-
interface State {
|
|
1433
|
-
[bunSqliteOptions.key]: BunSqliteProviderOptions;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
/**
|
|
1437
|
-
* Bun SQLite provider using Drizzle ORM with Bun's native SQLite client.
|
|
1438
|
-
*
|
|
1439
|
-
* This provider uses Bun's built-in `bun:sqlite` for SQLite connections,
|
|
1440
|
-
* which provides excellent performance on the Bun runtime.
|
|
1441
|
-
*
|
|
1442
|
-
* @example
|
|
1443
|
-
* ```ts
|
|
1444
|
-
* // Set DATABASE_URL environment variable
|
|
1445
|
-
* // DATABASE_URL=sqlite://./my-database.db
|
|
1446
|
-
*
|
|
1447
|
-
* // Or configure programmatically
|
|
1448
|
-
* alepha.with({
|
|
1449
|
-
* provide: DatabaseProvider,
|
|
1450
|
-
* use: BunSqliteProvider,
|
|
1451
|
-
* });
|
|
1452
|
-
*
|
|
1453
|
-
* // Or use options atom
|
|
1454
|
-
* alepha.store.mut(bunSqliteOptions, (old) => ({
|
|
1455
|
-
* ...old,
|
|
1456
|
-
* path: ":memory:",
|
|
1457
|
-
* }));
|
|
1458
|
-
* ```
|
|
1459
|
-
*/
|
|
1460
|
-
//#endregion
|
|
1461
|
-
//#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
1462
|
-
declare module "alepha" {
|
|
1463
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1464
|
-
}
|
|
1465
|
-
declare const envSchema: alepha23.TObject<{
|
|
1466
|
-
/**
|
|
1467
|
-
* Main configuration for database connection.
|
|
1468
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
1469
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
1470
|
-
* or
|
|
1471
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
1472
|
-
*/
|
|
1473
|
-
DATABASE_URL: alepha23.TOptional<alepha23.TString>;
|
|
1474
|
-
/**
|
|
1475
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1476
|
-
*
|
|
1477
|
-
* It will monkey patch drizzle tables.
|
|
1478
|
-
*/
|
|
1479
|
-
POSTGRES_SCHEMA: alepha23.TOptional<alepha23.TString>;
|
|
1480
|
-
}>;
|
|
1481
|
-
//#endregion
|
|
1482
|
-
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
1483
|
-
/**
|
|
1484
|
-
* Configuration options for the Node.js SQLite database provider.
|
|
1485
|
-
*/
|
|
1486
|
-
declare const nodeSqliteOptions: alepha23.Atom<alepha23.TObject<{
|
|
1487
|
-
path: alepha23.TOptional<alepha23.TString>;
|
|
1488
|
-
}>, "alepha.postgres.node-sqlite.options">;
|
|
1489
|
-
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
1490
|
-
declare module "alepha" {
|
|
1491
|
-
interface State {
|
|
1492
|
-
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
/**
|
|
1496
|
-
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
1497
|
-
*
|
|
1498
|
-
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
1499
|
-
* This is NOT recommended for production use.
|
|
1500
|
-
*/
|
|
1501
|
-
//#endregion
|
|
1502
|
-
//#region ../../src/orm/index.d.ts
|
|
1503
|
-
declare module "alepha" {
|
|
1504
|
-
interface Hooks {
|
|
1505
|
-
/**
|
|
1506
|
-
* Fires before creating an entity in the repository.
|
|
1507
|
-
*/
|
|
1508
|
-
"repository:create:before": {
|
|
1509
|
-
tableName: string;
|
|
1510
|
-
data: any;
|
|
1511
|
-
};
|
|
1512
|
-
/**
|
|
1513
|
-
* Fires after creating an entity in the repository.
|
|
1514
|
-
*/
|
|
1515
|
-
"repository:create:after": {
|
|
1516
|
-
tableName: string;
|
|
1517
|
-
data: any;
|
|
1518
|
-
entity: any;
|
|
1519
|
-
};
|
|
1520
|
-
/**
|
|
1521
|
-
* Fires before updating entities in the repository.
|
|
1522
|
-
*/
|
|
1523
|
-
"repository:update:before": {
|
|
1524
|
-
tableName: string;
|
|
1525
|
-
where: any;
|
|
1526
|
-
data: any;
|
|
1527
|
-
};
|
|
1528
|
-
/**
|
|
1529
|
-
* Fires after updating entities in the repository.
|
|
1530
|
-
*/
|
|
1531
|
-
"repository:update:after": {
|
|
1532
|
-
tableName: string;
|
|
1533
|
-
where: any;
|
|
1534
|
-
data: any;
|
|
1535
|
-
entities: any[];
|
|
1536
|
-
};
|
|
1537
|
-
/**
|
|
1538
|
-
* Fires before deleting entities from the repository.
|
|
1539
|
-
*/
|
|
1540
|
-
"repository:delete:before": {
|
|
1541
|
-
tableName: string;
|
|
1542
|
-
where: any;
|
|
1543
|
-
};
|
|
1544
|
-
/**
|
|
1545
|
-
* Fires after deleting entities from the repository.
|
|
1546
|
-
*/
|
|
1547
|
-
"repository:delete:after": {
|
|
1548
|
-
tableName: string;
|
|
1549
|
-
where: any;
|
|
1550
|
-
ids: Array<string | number>;
|
|
1551
|
-
};
|
|
1552
|
-
/**
|
|
1553
|
-
* Fires before reading entities from the repository.
|
|
1554
|
-
*/
|
|
1555
|
-
"repository:read:before": {
|
|
1556
|
-
tableName: string;
|
|
1557
|
-
query: any;
|
|
1558
|
-
};
|
|
1559
|
-
/**
|
|
1560
|
-
* Fires after reading entities from the repository.
|
|
1561
|
-
*/
|
|
1562
|
-
"repository:read:after": {
|
|
1563
|
-
tableName: string;
|
|
1564
|
-
query: any;
|
|
1565
|
-
entities: any[];
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
//#endregion
|
|
1570
1382
|
//#region ../../src/api/users/entities/identities.d.ts
|
|
1571
1383
|
declare const identities: alepha_orm24.EntityPrimitive<alepha23.TObject<{
|
|
1572
1384
|
id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
|
|
@@ -1619,8 +1431,8 @@ declare const users: alepha_orm24.EntityPrimitive<alepha23.TObject<{
|
|
|
1619
1431
|
}>>;
|
|
1620
1432
|
type UserEntity = Static<typeof users.schema>;
|
|
1621
1433
|
//#endregion
|
|
1622
|
-
//#region ../../src/api/users/primitives/$
|
|
1623
|
-
type
|
|
1434
|
+
//#region ../../src/api/users/primitives/$realm.d.ts
|
|
1435
|
+
type RealmPrimitive = IssuerPrimitive & WithLinkFn & WithLoginFn;
|
|
1624
1436
|
/**
|
|
1625
1437
|
* Already configured realm for user management.
|
|
1626
1438
|
*
|
|
@@ -1634,23 +1446,23 @@ type UserRealmPrimitive = RealmPrimitive & WithLinkFn & WithLoginFn;
|
|
|
1634
1446
|
* Environment Variables:
|
|
1635
1447
|
* - `APP_SECRET`: Secret key for signing tokens (if not provided in options).
|
|
1636
1448
|
*/
|
|
1637
|
-
declare const $
|
|
1638
|
-
interface
|
|
1449
|
+
declare const $realm: (options?: RealmOptions) => RealmPrimitive;
|
|
1450
|
+
interface RealmOptions {
|
|
1639
1451
|
/**
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1452
|
+
* Secret key for signing tokens.
|
|
1453
|
+
*
|
|
1454
|
+
* If not provided, the secret from the SecurityProvider will be used (usually from the APP_SECRET environment variable).
|
|
1455
|
+
*/
|
|
1644
1456
|
secret?: string;
|
|
1645
1457
|
/**
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1458
|
+
* Issuer configuration options.
|
|
1459
|
+
*
|
|
1460
|
+
* It's already pre-configured for user management with admin and user roles.
|
|
1461
|
+
*/
|
|
1462
|
+
issuer?: Partial<IssuerPrimitiveOptions>;
|
|
1651
1463
|
/**
|
|
1652
|
-
|
|
1653
|
-
|
|
1464
|
+
* Override entities.
|
|
1465
|
+
*/
|
|
1654
1466
|
entities?: {
|
|
1655
1467
|
users?: Repository<typeof users.schema>;
|
|
1656
1468
|
identities?: Repository<typeof identities.schema>;
|
|
@@ -1669,18 +1481,18 @@ interface UserRealmOptions {
|
|
|
1669
1481
|
};
|
|
1670
1482
|
}
|
|
1671
1483
|
//#endregion
|
|
1672
|
-
//#region ../../src/api/users/providers/
|
|
1673
|
-
interface
|
|
1484
|
+
//#region ../../src/api/users/providers/RealmProvider.d.ts
|
|
1485
|
+
interface RealmRepositories {
|
|
1674
1486
|
identities: Repository<typeof identities.schema>;
|
|
1675
1487
|
sessions: Repository<typeof sessions.schema>;
|
|
1676
1488
|
users: Repository<typeof users.schema>;
|
|
1677
1489
|
}
|
|
1678
|
-
interface
|
|
1490
|
+
interface Realm {
|
|
1679
1491
|
name: string;
|
|
1680
|
-
repositories:
|
|
1492
|
+
repositories: RealmRepositories;
|
|
1681
1493
|
settings: RealmAuthSettings;
|
|
1682
1494
|
}
|
|
1683
|
-
declare class
|
|
1495
|
+
declare class RealmProvider {
|
|
1684
1496
|
protected readonly alepha: Alepha;
|
|
1685
1497
|
protected readonly defaultIdentities: Repository<alepha23.TObject<{
|
|
1686
1498
|
id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
|
|
@@ -1724,17 +1536,17 @@ declare class UserRealmProvider {
|
|
|
1724
1536
|
enabled: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
|
|
1725
1537
|
emailVerified: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
|
|
1726
1538
|
}>>;
|
|
1727
|
-
protected realms: Map<string,
|
|
1539
|
+
protected realms: Map<string, Realm>;
|
|
1728
1540
|
avatars: alepha_bucket0.BucketPrimitive;
|
|
1729
1541
|
protected readonly onConfigure: alepha23.HookPrimitive<"configure">;
|
|
1730
|
-
register(
|
|
1731
|
-
/**
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
getRealm(
|
|
1735
|
-
identityRepository(
|
|
1736
|
-
sessionRepository(
|
|
1737
|
-
userRepository(
|
|
1542
|
+
register(realmName: string, realmOptions?: RealmOptions): Realm;
|
|
1543
|
+
/**
|
|
1544
|
+
* Gets a registered realm by name, auto-creating default if needed.
|
|
1545
|
+
*/
|
|
1546
|
+
getRealm(realmName?: string): Realm;
|
|
1547
|
+
identityRepository(realmName?: string): Repository<typeof identities.schema>;
|
|
1548
|
+
sessionRepository(realmName?: string): Repository<typeof sessions.schema>;
|
|
1549
|
+
userRepository(realmName?: string): Repository<typeof users.schema>;
|
|
1738
1550
|
}
|
|
1739
1551
|
//#endregion
|
|
1740
1552
|
//#region ../../src/api/users/schemas/identityQuerySchema.d.ts
|
|
@@ -1750,7 +1562,7 @@ type IdentityQuery = Static<typeof identityQuerySchema>;
|
|
|
1750
1562
|
//#region ../../src/api/users/services/IdentityService.d.ts
|
|
1751
1563
|
declare class IdentityService {
|
|
1752
1564
|
protected readonly log: alepha_logger5.Logger;
|
|
1753
|
-
protected readonly
|
|
1565
|
+
protected readonly realmProvider: RealmProvider;
|
|
1754
1566
|
protected readonly auditService: AuditService;
|
|
1755
1567
|
identities(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
|
|
1756
1568
|
id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
|
|
@@ -1764,16 +1576,16 @@ declare class IdentityService {
|
|
|
1764
1576
|
providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
|
|
1765
1577
|
}>>;
|
|
1766
1578
|
/**
|
|
1767
|
-
|
|
1768
|
-
|
|
1579
|
+
* Find identities with pagination and filtering.
|
|
1580
|
+
*/
|
|
1769
1581
|
findIdentities(q?: IdentityQuery, userRealmName?: string): Promise<Page$1<IdentityEntity>>;
|
|
1770
1582
|
/**
|
|
1771
|
-
|
|
1772
|
-
|
|
1583
|
+
* Get an identity by ID.
|
|
1584
|
+
*/
|
|
1773
1585
|
getIdentityById(id: string, userRealmName?: string): Promise<IdentityEntity>;
|
|
1774
1586
|
/**
|
|
1775
|
-
|
|
1776
|
-
|
|
1587
|
+
* Delete an identity by ID.
|
|
1588
|
+
*/
|
|
1777
1589
|
deleteIdentity(id: string, userRealmName?: string): Promise<void>;
|
|
1778
1590
|
}
|
|
1779
1591
|
//#endregion
|
|
@@ -1783,8 +1595,8 @@ declare class AdminIdentityController {
|
|
|
1783
1595
|
protected readonly group = "admin:identities";
|
|
1784
1596
|
protected readonly identityService: IdentityService;
|
|
1785
1597
|
/**
|
|
1786
|
-
|
|
1787
|
-
|
|
1598
|
+
* Find identities with pagination and filtering.
|
|
1599
|
+
*/
|
|
1788
1600
|
readonly findIdentities: alepha_server0.ActionPrimitiveFn<{
|
|
1789
1601
|
query: alepha23.TObject<{
|
|
1790
1602
|
page: alepha23.TOptional<alepha23.TInteger>;
|
|
@@ -1806,8 +1618,8 @@ declare class AdminIdentityController {
|
|
|
1806
1618
|
}>>;
|
|
1807
1619
|
}>;
|
|
1808
1620
|
/**
|
|
1809
|
-
|
|
1810
|
-
|
|
1621
|
+
* Get an identity by ID.
|
|
1622
|
+
*/
|
|
1811
1623
|
readonly getIdentity: alepha_server0.ActionPrimitiveFn<{
|
|
1812
1624
|
params: alepha23.TObject<{
|
|
1813
1625
|
id: alepha23.TString;
|
|
@@ -1827,8 +1639,8 @@ declare class AdminIdentityController {
|
|
|
1827
1639
|
}>;
|
|
1828
1640
|
}>;
|
|
1829
1641
|
/**
|
|
1830
|
-
|
|
1831
|
-
|
|
1642
|
+
* Delete an identity.
|
|
1643
|
+
*/
|
|
1832
1644
|
readonly deleteIdentity: alepha_server0.ActionPrimitiveFn<{
|
|
1833
1645
|
params: alepha23.TObject<{
|
|
1834
1646
|
id: alepha23.TString;
|
|
@@ -1856,7 +1668,7 @@ type SessionQuery = Static<typeof sessionQuerySchema>;
|
|
|
1856
1668
|
//#region ../../src/api/users/services/SessionCrudService.d.ts
|
|
1857
1669
|
declare class SessionCrudService {
|
|
1858
1670
|
protected readonly log: alepha_logger5.Logger;
|
|
1859
|
-
protected readonly
|
|
1671
|
+
protected readonly realmProvider: RealmProvider;
|
|
1860
1672
|
sessions(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
|
|
1861
1673
|
id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
|
|
1862
1674
|
version: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TInteger, typeof alepha_orm24.PG_VERSION>, typeof alepha_orm24.PG_DEFAULT>;
|
|
@@ -1873,16 +1685,16 @@ declare class SessionCrudService {
|
|
|
1873
1685
|
}>>;
|
|
1874
1686
|
}>>;
|
|
1875
1687
|
/**
|
|
1876
|
-
|
|
1877
|
-
|
|
1688
|
+
* Find sessions with pagination and filtering.
|
|
1689
|
+
*/
|
|
1878
1690
|
findSessions(q?: SessionQuery, userRealmName?: string): Promise<Page$1<SessionEntity>>;
|
|
1879
1691
|
/**
|
|
1880
|
-
|
|
1881
|
-
|
|
1692
|
+
* Get a session by ID.
|
|
1693
|
+
*/
|
|
1882
1694
|
getSessionById(id: string, userRealmName?: string): Promise<SessionEntity>;
|
|
1883
1695
|
/**
|
|
1884
|
-
|
|
1885
|
-
|
|
1696
|
+
* Delete a session by ID.
|
|
1697
|
+
*/
|
|
1886
1698
|
deleteSession(id: string, userRealmName?: string): Promise<void>;
|
|
1887
1699
|
}
|
|
1888
1700
|
//#endregion
|
|
@@ -1892,8 +1704,8 @@ declare class AdminSessionController {
|
|
|
1892
1704
|
protected readonly group = "admin:sessions";
|
|
1893
1705
|
protected readonly sessionService: SessionCrudService;
|
|
1894
1706
|
/**
|
|
1895
|
-
|
|
1896
|
-
|
|
1707
|
+
* Find sessions with pagination and filtering.
|
|
1708
|
+
*/
|
|
1897
1709
|
readonly findSessions: alepha_server0.ActionPrimitiveFn<{
|
|
1898
1710
|
query: alepha23.TObject<{
|
|
1899
1711
|
page: alepha23.TOptional<alepha23.TInteger>;
|
|
@@ -1919,8 +1731,8 @@ declare class AdminSessionController {
|
|
|
1919
1731
|
}>>;
|
|
1920
1732
|
}>;
|
|
1921
1733
|
/**
|
|
1922
|
-
|
|
1923
|
-
|
|
1734
|
+
* Get a session by ID.
|
|
1735
|
+
*/
|
|
1924
1736
|
readonly getSession: alepha_server0.ActionPrimitiveFn<{
|
|
1925
1737
|
params: alepha23.TObject<{
|
|
1926
1738
|
id: alepha23.TString;
|
|
@@ -1945,8 +1757,8 @@ declare class AdminSessionController {
|
|
|
1945
1757
|
}>;
|
|
1946
1758
|
}>;
|
|
1947
1759
|
/**
|
|
1948
|
-
|
|
1949
|
-
|
|
1760
|
+
* Delete a session.
|
|
1761
|
+
*/
|
|
1950
1762
|
readonly deleteSession: alepha_server0.ActionPrimitiveFn<{
|
|
1951
1763
|
params: alepha23.TObject<{
|
|
1952
1764
|
id: alepha23.TString;
|
|
@@ -2040,7 +1852,7 @@ declare class UserService {
|
|
|
2040
1852
|
protected readonly log: alepha_logger5.Logger;
|
|
2041
1853
|
protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
|
|
2042
1854
|
protected readonly userNotifications: UserNotifications;
|
|
2043
|
-
protected readonly
|
|
1855
|
+
protected readonly realmProvider: RealmProvider;
|
|
2044
1856
|
protected readonly auditService: AuditService;
|
|
2045
1857
|
users(userRealmName?: string): alepha_orm24.Repository<alepha23.TObject<{
|
|
2046
1858
|
id: alepha_orm24.PgAttr<alepha_orm24.PgAttr<alepha23.TString, typeof alepha_orm24.PG_PRIMARY_KEY>, typeof alepha_orm24.PG_DEFAULT>;
|
|
@@ -2059,41 +1871,41 @@ declare class UserService {
|
|
|
2059
1871
|
emailVerified: alepha_orm24.PgAttr<alepha23.TBoolean, typeof alepha_orm24.PG_DEFAULT>;
|
|
2060
1872
|
}>>;
|
|
2061
1873
|
/**
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1874
|
+
* Request email verification for a user.
|
|
1875
|
+
* @param email - The email address to verify.
|
|
1876
|
+
* @param userRealmName - Optional realm name.
|
|
1877
|
+
* @param method - The verification method: "code" (default) or "link".
|
|
1878
|
+
* @param verifyUrl - Base URL for verification link (required when method is "link").
|
|
1879
|
+
*/
|
|
2068
1880
|
requestEmailVerification(email: string, userRealmName?: string, method?: "code" | "link", verifyUrl?: string): Promise<boolean>;
|
|
2069
1881
|
/**
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1882
|
+
* Verify a user's email using a valid verification token.
|
|
1883
|
+
* Supports both code (6-digit) and link (UUID) verification tokens.
|
|
1884
|
+
*/
|
|
2073
1885
|
verifyEmail(email: string, token: string, userRealmName?: string): Promise<void>;
|
|
2074
1886
|
/**
|
|
2075
|
-
|
|
2076
|
-
|
|
1887
|
+
* Check if an email is verified.
|
|
1888
|
+
*/
|
|
2077
1889
|
isEmailVerified(email: string, userRealmName?: string): Promise<boolean>;
|
|
2078
1890
|
/**
|
|
2079
|
-
|
|
2080
|
-
|
|
1891
|
+
* Find users with pagination and filtering.
|
|
1892
|
+
*/
|
|
2081
1893
|
findUsers(q?: UserQuery, userRealmName?: string): Promise<Page$1<UserEntity>>;
|
|
2082
1894
|
/**
|
|
2083
|
-
|
|
2084
|
-
|
|
1895
|
+
* Get a user by ID.
|
|
1896
|
+
*/
|
|
2085
1897
|
getUserById(id: string, userRealmName?: string): Promise<UserEntity>;
|
|
2086
1898
|
/**
|
|
2087
|
-
|
|
2088
|
-
|
|
1899
|
+
* Create a new user.
|
|
1900
|
+
*/
|
|
2089
1901
|
createUser(data: CreateUser, userRealmName?: string): Promise<UserEntity>;
|
|
2090
1902
|
/**
|
|
2091
|
-
|
|
2092
|
-
|
|
1903
|
+
* Update an existing user.
|
|
1904
|
+
*/
|
|
2093
1905
|
updateUser(id: string, data: UpdateUser, userRealmName?: string): Promise<UserEntity>;
|
|
2094
1906
|
/**
|
|
2095
|
-
|
|
2096
|
-
|
|
1907
|
+
* Delete a user by ID.
|
|
1908
|
+
*/
|
|
2097
1909
|
deleteUser(id: string, userRealmName?: string): Promise<void>;
|
|
2098
1910
|
}
|
|
2099
1911
|
//#endregion
|
|
@@ -2103,8 +1915,8 @@ declare class AdminUserController {
|
|
|
2103
1915
|
protected readonly group = "admin:users";
|
|
2104
1916
|
protected readonly userService: UserService;
|
|
2105
1917
|
/**
|
|
2106
|
-
|
|
2107
|
-
|
|
1918
|
+
* Find users with pagination and filtering.
|
|
1919
|
+
*/
|
|
2108
1920
|
readonly findUsers: alepha_server0.ActionPrimitiveFn<{
|
|
2109
1921
|
query: alepha23.TObject<{
|
|
2110
1922
|
page: alepha23.TOptional<alepha23.TInteger>;
|
|
@@ -2135,8 +1947,8 @@ declare class AdminUserController {
|
|
|
2135
1947
|
}>>;
|
|
2136
1948
|
}>;
|
|
2137
1949
|
/**
|
|
2138
|
-
|
|
2139
|
-
|
|
1950
|
+
* Get a user by ID.
|
|
1951
|
+
*/
|
|
2140
1952
|
readonly getUser: alepha_server0.ActionPrimitiveFn<{
|
|
2141
1953
|
params: alepha23.TObject<{
|
|
2142
1954
|
id: alepha23.TString;
|
|
@@ -2162,8 +1974,8 @@ declare class AdminUserController {
|
|
|
2162
1974
|
}>;
|
|
2163
1975
|
}>;
|
|
2164
1976
|
/**
|
|
2165
|
-
|
|
2166
|
-
|
|
1977
|
+
* Create a new user.
|
|
1978
|
+
*/
|
|
2167
1979
|
readonly createUser: alepha_server0.ActionPrimitiveFn<{
|
|
2168
1980
|
query: alepha23.TObject<{
|
|
2169
1981
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2201,8 +2013,8 @@ declare class AdminUserController {
|
|
|
2201
2013
|
}>;
|
|
2202
2014
|
}>;
|
|
2203
2015
|
/**
|
|
2204
|
-
|
|
2205
|
-
|
|
2016
|
+
* Update a user.
|
|
2017
|
+
*/
|
|
2206
2018
|
readonly updateUser: alepha_server0.ActionPrimitiveFn<{
|
|
2207
2019
|
params: alepha23.TObject<{
|
|
2208
2020
|
id: alepha23.TString;
|
|
@@ -2238,8 +2050,8 @@ declare class AdminUserController {
|
|
|
2238
2050
|
}>;
|
|
2239
2051
|
}>;
|
|
2240
2052
|
/**
|
|
2241
|
-
|
|
2242
|
-
|
|
2053
|
+
* Delete a user.
|
|
2054
|
+
*/
|
|
2243
2055
|
readonly deleteUser: alepha_server0.ActionPrimitiveFn<{
|
|
2244
2056
|
params: alepha23.TObject<{
|
|
2245
2057
|
id: alepha23.TString;
|
|
@@ -2255,6 +2067,70 @@ declare class AdminUserController {
|
|
|
2255
2067
|
}>;
|
|
2256
2068
|
}
|
|
2257
2069
|
//#endregion
|
|
2070
|
+
//#region ../../src/api/users/controllers/RealmController.d.ts
|
|
2071
|
+
/**
|
|
2072
|
+
* Controller for exposing realm configuration.
|
|
2073
|
+
* Uses $route instead of $action to keep endpoints hidden from API documentation.
|
|
2074
|
+
*/
|
|
2075
|
+
declare class RealmController {
|
|
2076
|
+
protected readonly url = "/realms";
|
|
2077
|
+
protected readonly group = "realms";
|
|
2078
|
+
protected readonly realmProvider: RealmProvider;
|
|
2079
|
+
protected readonly serverAuthProvider: ServerAuthProvider;
|
|
2080
|
+
/**
|
|
2081
|
+
* Get realm configuration settings.
|
|
2082
|
+
* This endpoint is not exposed in the API documentation.
|
|
2083
|
+
*/
|
|
2084
|
+
readonly getRealmConfig: alepha_server0.ActionPrimitiveFn<{
|
|
2085
|
+
query: alepha23.TObject<{
|
|
2086
|
+
realmName: alepha23.TOptional<alepha23.TString>;
|
|
2087
|
+
}>;
|
|
2088
|
+
response: alepha23.TObject<{
|
|
2089
|
+
settings: alepha23.TObject<{
|
|
2090
|
+
displayName: alepha23.TOptional<alepha23.TString>;
|
|
2091
|
+
description: alepha23.TOptional<alepha23.TString>;
|
|
2092
|
+
logoUrl: alepha23.TOptional<alepha23.TString>;
|
|
2093
|
+
registrationAllowed: alepha23.TBoolean;
|
|
2094
|
+
emailEnabled: alepha23.TBoolean;
|
|
2095
|
+
emailRequired: alepha23.TBoolean;
|
|
2096
|
+
usernameEnabled: alepha23.TBoolean;
|
|
2097
|
+
usernameRequired: alepha23.TBoolean;
|
|
2098
|
+
usernameRegExp: alepha23.TString;
|
|
2099
|
+
phoneEnabled: alepha23.TBoolean;
|
|
2100
|
+
phoneRequired: alepha23.TBoolean;
|
|
2101
|
+
verifyEmailRequired: alepha23.TBoolean;
|
|
2102
|
+
verifyPhoneRequired: alepha23.TBoolean;
|
|
2103
|
+
firstNameLastNameEnabled: alepha23.TBoolean;
|
|
2104
|
+
firstNameLastNameRequired: alepha23.TBoolean;
|
|
2105
|
+
resetPasswordAllowed: alepha23.TBoolean;
|
|
2106
|
+
passwordPolicy: alepha23.TObject<{
|
|
2107
|
+
minLength: alepha23.TInteger;
|
|
2108
|
+
requireUppercase: alepha23.TBoolean;
|
|
2109
|
+
requireLowercase: alepha23.TBoolean;
|
|
2110
|
+
requireNumbers: alepha23.TBoolean;
|
|
2111
|
+
requireSpecialCharacters: alepha23.TBoolean;
|
|
2112
|
+
}>;
|
|
2113
|
+
}>;
|
|
2114
|
+
realmName: alepha23.TString;
|
|
2115
|
+
authenticationMethods: alepha23.TArray<alepha23.TObject<{
|
|
2116
|
+
name: alepha23.TString;
|
|
2117
|
+
type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
2118
|
+
}>>;
|
|
2119
|
+
}>;
|
|
2120
|
+
}>;
|
|
2121
|
+
readonly checkUsernameAvailability: alepha_server0.ActionPrimitiveFn<{
|
|
2122
|
+
query: alepha23.TObject<{
|
|
2123
|
+
realmName: alepha23.TOptional<alepha23.TString>;
|
|
2124
|
+
}>;
|
|
2125
|
+
body: alepha23.TObject<{
|
|
2126
|
+
username: alepha23.TString;
|
|
2127
|
+
}>;
|
|
2128
|
+
response: alepha23.TObject<{
|
|
2129
|
+
available: alepha23.TBoolean;
|
|
2130
|
+
}>;
|
|
2131
|
+
}>;
|
|
2132
|
+
}
|
|
2133
|
+
//#endregion
|
|
2258
2134
|
//#region ../../src/api/users/schemas/completePasswordResetRequestSchema.d.ts
|
|
2259
2135
|
/**
|
|
2260
2136
|
* Request schema for completing a password reset.
|
|
@@ -2299,7 +2175,7 @@ declare class CredentialService {
|
|
|
2299
2175
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2300
2176
|
protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
|
|
2301
2177
|
protected readonly userNotifications: UserNotifications;
|
|
2302
|
-
protected readonly
|
|
2178
|
+
protected readonly realmProvider: RealmProvider;
|
|
2303
2179
|
protected readonly auditService: AuditService;
|
|
2304
2180
|
protected readonly intentCache: alepha_cache0.CachePrimitiveFn<PasswordResetIntent, any[]>;
|
|
2305
2181
|
users(userRealmName?: string): Repository$1<alepha23.TObject<{
|
|
@@ -2345,36 +2221,36 @@ declare class CredentialService {
|
|
|
2345
2221
|
providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
|
|
2346
2222
|
}>>;
|
|
2347
2223
|
/**
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2224
|
+
* Phase 1: Create a password reset intent.
|
|
2225
|
+
*
|
|
2226
|
+
* Validates the email, checks for existing user with credentials,
|
|
2227
|
+
* sends verification code, and stores the intent in cache.
|
|
2228
|
+
*
|
|
2229
|
+
* @param email - User's email address
|
|
2230
|
+
* @param userRealmName - Optional realm name
|
|
2231
|
+
* @returns Intent response with intentId and expiration (always returns for security)
|
|
2232
|
+
*/
|
|
2357
2233
|
createPasswordResetIntent(email: string, userRealmName?: string): Promise<PasswordResetIntentResponse>;
|
|
2358
2234
|
/**
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2235
|
+
* Phase 2: Complete password reset using an intent.
|
|
2236
|
+
*
|
|
2237
|
+
* Validates the verification code, updates the password,
|
|
2238
|
+
* and invalidates all existing sessions.
|
|
2239
|
+
*
|
|
2240
|
+
* @param body - Request body with intentId, code, and newPassword
|
|
2241
|
+
*/
|
|
2366
2242
|
completePasswordReset(body: CompletePasswordResetRequest): Promise<void>;
|
|
2367
2243
|
/**
|
|
2368
|
-
|
|
2369
|
-
|
|
2244
|
+
* @deprecated Use createPasswordResetIntent instead
|
|
2245
|
+
*/
|
|
2370
2246
|
requestPasswordReset(email: string, userRealmName?: string): Promise<boolean>;
|
|
2371
2247
|
/**
|
|
2372
|
-
|
|
2373
|
-
|
|
2248
|
+
* @deprecated Use completePasswordReset instead
|
|
2249
|
+
*/
|
|
2374
2250
|
validateResetToken(email: string, token: string, _userRealmName?: string): Promise<string>;
|
|
2375
2251
|
/**
|
|
2376
|
-
|
|
2377
|
-
|
|
2252
|
+
* @deprecated Use completePasswordReset instead
|
|
2253
|
+
*/
|
|
2378
2254
|
resetPassword(email: string, token: string, newPassword: string, userRealmName?: string): Promise<void>;
|
|
2379
2255
|
}
|
|
2380
2256
|
//#endregion
|
|
@@ -2441,42 +2317,42 @@ declare class RegistrationService {
|
|
|
2441
2317
|
protected readonly cryptoProvider: CryptoProvider;
|
|
2442
2318
|
protected readonly verificationController: alepha_server_links0.HttpVirtualClient<VerificationController>;
|
|
2443
2319
|
protected readonly userNotifications: UserNotifications;
|
|
2444
|
-
protected readonly
|
|
2320
|
+
protected readonly realmProvider: RealmProvider;
|
|
2445
2321
|
protected readonly auditService: AuditService;
|
|
2446
2322
|
protected readonly intentCache: alepha_cache0.CachePrimitiveFn<RegistrationIntent, any[]>;
|
|
2447
2323
|
/**
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2324
|
+
* Phase 1: Create a registration intent.
|
|
2325
|
+
*
|
|
2326
|
+
* Validates the registration data, checks for existing users,
|
|
2327
|
+
* creates verification sessions, and stores the intent in cache.
|
|
2328
|
+
*/
|
|
2453
2329
|
createRegistrationIntent(body: RegisterRequest, userRealmName?: string): Promise<RegistrationIntentResponse>;
|
|
2454
2330
|
/**
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2331
|
+
* Phase 2: Complete registration using an intent.
|
|
2332
|
+
*
|
|
2333
|
+
* Validates all requirements (verification codes, captcha),
|
|
2334
|
+
* creates the user and credentials, and returns the user.
|
|
2335
|
+
*/
|
|
2460
2336
|
completeRegistration(body: CompleteRegistrationRequest): Promise<UserEntity>;
|
|
2461
2337
|
/**
|
|
2462
|
-
|
|
2463
|
-
|
|
2338
|
+
* Check if username, email, and phone are available.
|
|
2339
|
+
*/
|
|
2464
2340
|
protected checkUserAvailability(body: Pick<RegisterRequest, "username" | "email" | "phoneNumber">, userRealmName?: string): Promise<void>;
|
|
2465
2341
|
/**
|
|
2466
|
-
|
|
2467
|
-
|
|
2342
|
+
* Send email verification code.
|
|
2343
|
+
*/
|
|
2468
2344
|
protected sendEmailVerification(email: string): Promise<void>;
|
|
2469
2345
|
/**
|
|
2470
|
-
|
|
2471
|
-
|
|
2346
|
+
* Send phone verification code.
|
|
2347
|
+
*/
|
|
2472
2348
|
protected sendPhoneVerification(phoneNumber: string): Promise<void>;
|
|
2473
2349
|
/**
|
|
2474
|
-
|
|
2475
|
-
|
|
2350
|
+
* Verify email code using verification service.
|
|
2351
|
+
*/
|
|
2476
2352
|
protected verifyEmailCode(email: string, code: string): Promise<void>;
|
|
2477
2353
|
/**
|
|
2478
|
-
|
|
2479
|
-
|
|
2354
|
+
* Verify phone code using verification service.
|
|
2355
|
+
*/
|
|
2480
2356
|
protected verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
|
|
2481
2357
|
}
|
|
2482
2358
|
//#endregion
|
|
@@ -2488,9 +2364,9 @@ declare class UserController {
|
|
|
2488
2364
|
protected readonly userService: UserService;
|
|
2489
2365
|
protected readonly registrationService: RegistrationService;
|
|
2490
2366
|
/**
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2367
|
+
* Phase 1: Create a registration intent.
|
|
2368
|
+
* Validates data, creates verification sessions, and stores intent in cache.
|
|
2369
|
+
*/
|
|
2494
2370
|
readonly createRegistrationIntent: alepha_server0.ActionPrimitiveFn<{
|
|
2495
2371
|
body: alepha23.TObject<{
|
|
2496
2372
|
password: alepha23.TString;
|
|
@@ -2513,9 +2389,9 @@ declare class UserController {
|
|
|
2513
2389
|
}>;
|
|
2514
2390
|
}>;
|
|
2515
2391
|
/**
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2392
|
+
* Phase 2: Complete registration using an intent.
|
|
2393
|
+
* Validates verification codes and creates the user.
|
|
2394
|
+
*/
|
|
2519
2395
|
readonly createUserFromIntent: alepha_server0.ActionPrimitiveFn<{
|
|
2520
2396
|
body: alepha23.TObject<{
|
|
2521
2397
|
intentId: alepha23.TString;
|
|
@@ -2541,9 +2417,9 @@ declare class UserController {
|
|
|
2541
2417
|
}>;
|
|
2542
2418
|
}>;
|
|
2543
2419
|
/**
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2420
|
+
* Phase 1: Create a password reset intent.
|
|
2421
|
+
* Validates email, sends verification code, and stores intent in cache.
|
|
2422
|
+
*/
|
|
2547
2423
|
readonly createPasswordResetIntent: alepha_server0.ActionPrimitiveFn<{
|
|
2548
2424
|
query: alepha23.TObject<{
|
|
2549
2425
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2557,9 +2433,9 @@ declare class UserController {
|
|
|
2557
2433
|
}>;
|
|
2558
2434
|
}>;
|
|
2559
2435
|
/**
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2436
|
+
* Phase 2: Complete password reset using an intent.
|
|
2437
|
+
* Validates verification code, updates password, and invalidates sessions.
|
|
2438
|
+
*/
|
|
2563
2439
|
readonly completePasswordReset: alepha_server0.ActionPrimitiveFn<{
|
|
2564
2440
|
body: alepha23.TObject<{
|
|
2565
2441
|
intentId: alepha23.TString;
|
|
@@ -2573,8 +2449,8 @@ declare class UserController {
|
|
|
2573
2449
|
}>;
|
|
2574
2450
|
}>;
|
|
2575
2451
|
/**
|
|
2576
|
-
|
|
2577
|
-
|
|
2452
|
+
* @deprecated Use createPasswordResetIntent instead
|
|
2453
|
+
*/
|
|
2578
2454
|
requestPasswordReset: alepha_server0.ActionPrimitiveFn<{
|
|
2579
2455
|
query: alepha23.TObject<{
|
|
2580
2456
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2588,8 +2464,8 @@ declare class UserController {
|
|
|
2588
2464
|
}>;
|
|
2589
2465
|
}>;
|
|
2590
2466
|
/**
|
|
2591
|
-
|
|
2592
|
-
|
|
2467
|
+
* @deprecated Use completePasswordReset instead
|
|
2468
|
+
*/
|
|
2593
2469
|
validateResetToken: alepha_server0.ActionPrimitiveFn<{
|
|
2594
2470
|
query: alepha23.TObject<{
|
|
2595
2471
|
email: alepha23.TString;
|
|
@@ -2602,8 +2478,8 @@ declare class UserController {
|
|
|
2602
2478
|
}>;
|
|
2603
2479
|
}>;
|
|
2604
2480
|
/**
|
|
2605
|
-
|
|
2606
|
-
|
|
2481
|
+
* @deprecated Use completePasswordReset instead
|
|
2482
|
+
*/
|
|
2607
2483
|
resetPassword: alepha_server0.ActionPrimitiveFn<{
|
|
2608
2484
|
query: alepha23.TObject<{
|
|
2609
2485
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2619,11 +2495,11 @@ declare class UserController {
|
|
|
2619
2495
|
}>;
|
|
2620
2496
|
}>;
|
|
2621
2497
|
/**
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2498
|
+
* Request email verification.
|
|
2499
|
+
* Generates a verification token using verification service and sends an email to the user.
|
|
2500
|
+
* @param method - The verification method: "code" (default) sends a 6-digit code, "link" sends a clickable verification link.
|
|
2501
|
+
* @param verifyUrl - Required when method is "link". The base URL for the verification link. Token and email will be appended as query params.
|
|
2502
|
+
*/
|
|
2627
2503
|
requestEmailVerification: alepha_server0.ActionPrimitiveFn<{
|
|
2628
2504
|
query: alepha23.TObject<{
|
|
2629
2505
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2639,9 +2515,9 @@ declare class UserController {
|
|
|
2639
2515
|
}>;
|
|
2640
2516
|
}>;
|
|
2641
2517
|
/**
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2518
|
+
* Verify email with a valid token.
|
|
2519
|
+
* Updates the user's emailVerified status.
|
|
2520
|
+
*/
|
|
2645
2521
|
verifyEmail: alepha_server0.ActionPrimitiveFn<{
|
|
2646
2522
|
query: alepha23.TObject<{
|
|
2647
2523
|
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
@@ -2656,8 +2532,8 @@ declare class UserController {
|
|
|
2656
2532
|
}>;
|
|
2657
2533
|
}>;
|
|
2658
2534
|
/**
|
|
2659
|
-
|
|
2660
|
-
|
|
2535
|
+
* Check if an email is verified.
|
|
2536
|
+
*/
|
|
2661
2537
|
checkEmailVerification: alepha_server0.ActionPrimitiveFn<{
|
|
2662
2538
|
query: alepha23.TObject<{
|
|
2663
2539
|
email: alepha23.TString;
|
|
@@ -2669,69 +2545,6 @@ declare class UserController {
|
|
|
2669
2545
|
}>;
|
|
2670
2546
|
}
|
|
2671
2547
|
//#endregion
|
|
2672
|
-
//#region ../../src/api/users/controllers/UserRealmController.d.ts
|
|
2673
|
-
/**
|
|
2674
|
-
* Controller for exposing realm configuration.
|
|
2675
|
-
* Uses $route instead of $action to keep endpoints hidden from API documentation.
|
|
2676
|
-
*/
|
|
2677
|
-
declare class UserRealmController {
|
|
2678
|
-
protected readonly url = "/realms";
|
|
2679
|
-
protected readonly group = "realms";
|
|
2680
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
2681
|
-
protected readonly serverAuthProvider: ServerAuthProvider;
|
|
2682
|
-
/**
|
|
2683
|
-
* Get realm configuration settings.
|
|
2684
|
-
* This endpoint is not exposed in the API documentation.
|
|
2685
|
-
*/
|
|
2686
|
-
readonly getRealmConfig: alepha_server0.ActionPrimitiveFn<{
|
|
2687
|
-
query: alepha23.TObject<{
|
|
2688
|
-
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
2689
|
-
}>;
|
|
2690
|
-
response: alepha23.TObject<{
|
|
2691
|
-
settings: alepha23.TObject<{
|
|
2692
|
-
displayName: alepha23.TOptional<alepha23.TString>;
|
|
2693
|
-
description: alepha23.TOptional<alepha23.TString>;
|
|
2694
|
-
logoUrl: alepha23.TOptional<alepha23.TString>;
|
|
2695
|
-
registrationAllowed: alepha23.TBoolean;
|
|
2696
|
-
emailEnabled: alepha23.TBoolean;
|
|
2697
|
-
emailRequired: alepha23.TBoolean;
|
|
2698
|
-
usernameEnabled: alepha23.TBoolean;
|
|
2699
|
-
usernameRequired: alepha23.TBoolean;
|
|
2700
|
-
phoneEnabled: alepha23.TBoolean;
|
|
2701
|
-
phoneRequired: alepha23.TBoolean;
|
|
2702
|
-
verifyEmailRequired: alepha23.TBoolean;
|
|
2703
|
-
verifyPhoneRequired: alepha23.TBoolean;
|
|
2704
|
-
firstNameLastNameEnabled: alepha23.TBoolean;
|
|
2705
|
-
firstNameLastNameRequired: alepha23.TBoolean;
|
|
2706
|
-
resetPasswordAllowed: alepha23.TBoolean;
|
|
2707
|
-
passwordPolicy: alepha23.TObject<{
|
|
2708
|
-
minLength: alepha23.TInteger;
|
|
2709
|
-
requireUppercase: alepha23.TBoolean;
|
|
2710
|
-
requireLowercase: alepha23.TBoolean;
|
|
2711
|
-
requireNumbers: alepha23.TBoolean;
|
|
2712
|
-
requireSpecialCharacters: alepha23.TBoolean;
|
|
2713
|
-
}>;
|
|
2714
|
-
}>;
|
|
2715
|
-
realmName: alepha23.TString;
|
|
2716
|
-
authenticationMethods: alepha23.TArray<alepha23.TObject<{
|
|
2717
|
-
name: alepha23.TString;
|
|
2718
|
-
type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
2719
|
-
}>>;
|
|
2720
|
-
}>;
|
|
2721
|
-
}>;
|
|
2722
|
-
readonly checkUsernameAvailability: alepha_server0.ActionPrimitiveFn<{
|
|
2723
|
-
query: alepha23.TObject<{
|
|
2724
|
-
userRealmName: alepha23.TOptional<alepha23.TString>;
|
|
2725
|
-
}>;
|
|
2726
|
-
body: alepha23.TObject<{
|
|
2727
|
-
username: alepha23.TString;
|
|
2728
|
-
}>;
|
|
2729
|
-
response: alepha23.TObject<{
|
|
2730
|
-
available: alepha23.TBoolean;
|
|
2731
|
-
}>;
|
|
2732
|
-
}>;
|
|
2733
|
-
}
|
|
2734
|
-
//#endregion
|
|
2735
2548
|
//#region ../../src/api/users/schemas/identityResourceSchema.d.ts
|
|
2736
2549
|
declare const identityResourceSchema: alepha23.TObject<{
|
|
2737
2550
|
id: PgAttr<PgAttr<alepha23.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
@@ -2752,6 +2565,41 @@ declare const loginSchema: alepha23.TObject<{
|
|
|
2752
2565
|
}>;
|
|
2753
2566
|
type LoginInput = Static<typeof loginSchema>;
|
|
2754
2567
|
//#endregion
|
|
2568
|
+
//#region ../../src/api/users/schemas/realmConfigSchema.d.ts
|
|
2569
|
+
declare const realmConfigSchema: alepha23.TObject<{
|
|
2570
|
+
settings: alepha23.TObject<{
|
|
2571
|
+
displayName: alepha23.TOptional<alepha23.TString>;
|
|
2572
|
+
description: alepha23.TOptional<alepha23.TString>;
|
|
2573
|
+
logoUrl: alepha23.TOptional<alepha23.TString>;
|
|
2574
|
+
registrationAllowed: alepha23.TBoolean;
|
|
2575
|
+
emailEnabled: alepha23.TBoolean;
|
|
2576
|
+
emailRequired: alepha23.TBoolean;
|
|
2577
|
+
usernameEnabled: alepha23.TBoolean;
|
|
2578
|
+
usernameRequired: alepha23.TBoolean;
|
|
2579
|
+
usernameRegExp: alepha23.TString;
|
|
2580
|
+
phoneEnabled: alepha23.TBoolean;
|
|
2581
|
+
phoneRequired: alepha23.TBoolean;
|
|
2582
|
+
verifyEmailRequired: alepha23.TBoolean;
|
|
2583
|
+
verifyPhoneRequired: alepha23.TBoolean;
|
|
2584
|
+
firstNameLastNameEnabled: alepha23.TBoolean;
|
|
2585
|
+
firstNameLastNameRequired: alepha23.TBoolean;
|
|
2586
|
+
resetPasswordAllowed: alepha23.TBoolean;
|
|
2587
|
+
passwordPolicy: alepha23.TObject<{
|
|
2588
|
+
minLength: alepha23.TInteger;
|
|
2589
|
+
requireUppercase: alepha23.TBoolean;
|
|
2590
|
+
requireLowercase: alepha23.TBoolean;
|
|
2591
|
+
requireNumbers: alepha23.TBoolean;
|
|
2592
|
+
requireSpecialCharacters: alepha23.TBoolean;
|
|
2593
|
+
}>;
|
|
2594
|
+
}>;
|
|
2595
|
+
realmName: alepha23.TString;
|
|
2596
|
+
authenticationMethods: alepha23.TArray<alepha23.TObject<{
|
|
2597
|
+
name: alepha23.TString;
|
|
2598
|
+
type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
2599
|
+
}>>;
|
|
2600
|
+
}>;
|
|
2601
|
+
type RealmConfig = Static<typeof realmConfigSchema>;
|
|
2602
|
+
//#endregion
|
|
2755
2603
|
//#region ../../src/api/users/schemas/registerSchema.d.ts
|
|
2756
2604
|
declare const registerSchema: alepha23.TObject<{
|
|
2757
2605
|
username: alepha23.TString;
|
|
@@ -2793,40 +2641,6 @@ declare const sessionResourceSchema: alepha23.TObject<{
|
|
|
2793
2641
|
}>;
|
|
2794
2642
|
type SessionResource = Static<typeof sessionResourceSchema>;
|
|
2795
2643
|
//#endregion
|
|
2796
|
-
//#region ../../src/api/users/schemas/userRealmConfigSchema.d.ts
|
|
2797
|
-
declare const userRealmConfigSchema: alepha23.TObject<{
|
|
2798
|
-
settings: alepha23.TObject<{
|
|
2799
|
-
displayName: alepha23.TOptional<alepha23.TString>;
|
|
2800
|
-
description: alepha23.TOptional<alepha23.TString>;
|
|
2801
|
-
logoUrl: alepha23.TOptional<alepha23.TString>;
|
|
2802
|
-
registrationAllowed: alepha23.TBoolean;
|
|
2803
|
-
emailEnabled: alepha23.TBoolean;
|
|
2804
|
-
emailRequired: alepha23.TBoolean;
|
|
2805
|
-
usernameEnabled: alepha23.TBoolean;
|
|
2806
|
-
usernameRequired: alepha23.TBoolean;
|
|
2807
|
-
phoneEnabled: alepha23.TBoolean;
|
|
2808
|
-
phoneRequired: alepha23.TBoolean;
|
|
2809
|
-
verifyEmailRequired: alepha23.TBoolean;
|
|
2810
|
-
verifyPhoneRequired: alepha23.TBoolean;
|
|
2811
|
-
firstNameLastNameEnabled: alepha23.TBoolean;
|
|
2812
|
-
firstNameLastNameRequired: alepha23.TBoolean;
|
|
2813
|
-
resetPasswordAllowed: alepha23.TBoolean;
|
|
2814
|
-
passwordPolicy: alepha23.TObject<{
|
|
2815
|
-
minLength: alepha23.TInteger;
|
|
2816
|
-
requireUppercase: alepha23.TBoolean;
|
|
2817
|
-
requireLowercase: alepha23.TBoolean;
|
|
2818
|
-
requireNumbers: alepha23.TBoolean;
|
|
2819
|
-
requireSpecialCharacters: alepha23.TBoolean;
|
|
2820
|
-
}>;
|
|
2821
|
-
}>;
|
|
2822
|
-
realmName: alepha23.TString;
|
|
2823
|
-
authenticationMethods: alepha23.TArray<alepha23.TObject<{
|
|
2824
|
-
name: alepha23.TString;
|
|
2825
|
-
type: alepha23.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
2826
|
-
}>>;
|
|
2827
|
-
}>;
|
|
2828
|
-
type UserRealmConfig = Static<typeof userRealmConfigSchema>;
|
|
2829
|
-
//#endregion
|
|
2830
2644
|
//#region ../../src/api/users/schemas/userResourceSchema.d.ts
|
|
2831
2645
|
declare const userResourceSchema: alepha23.TObject<{
|
|
2832
2646
|
id: PgAttr<PgAttr<alepha23.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
@@ -2853,7 +2667,7 @@ declare class SessionService {
|
|
|
2853
2667
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2854
2668
|
protected readonly cryptoProvider: CryptoProvider;
|
|
2855
2669
|
protected readonly log: alepha_logger5.Logger;
|
|
2856
|
-
protected readonly
|
|
2670
|
+
protected readonly realmProvider: RealmProvider;
|
|
2857
2671
|
protected readonly fileController: alepha_server_links0.HttpVirtualClient<FileController>;
|
|
2858
2672
|
protected readonly auditService: AuditService;
|
|
2859
2673
|
users(userRealmName?: string): Repository$1<alepha23.TObject<{
|
|
@@ -2899,13 +2713,13 @@ declare class SessionService {
|
|
|
2899
2713
|
providerData: alepha23.TOptional<alepha23.TRecord<string, alepha23.TAny>>;
|
|
2900
2714
|
}>>;
|
|
2901
2715
|
/**
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2716
|
+
* Random delay to prevent timing attacks (50-200ms)
|
|
2717
|
+
* Uses cryptographically secure random number generation
|
|
2718
|
+
*/
|
|
2905
2719
|
protected randomDelay(): Promise<void>;
|
|
2906
2720
|
/**
|
|
2907
|
-
|
|
2908
|
-
|
|
2721
|
+
* Validate user credentials and return the user if valid.
|
|
2722
|
+
*/
|
|
2909
2723
|
login(provider: string, username: string, password: string, userRealmName?: string): Promise<UserEntity>;
|
|
2910
2724
|
createSession(user: UserAccount, expiresIn: number, userRealmName?: string): Promise<{
|
|
2911
2725
|
refreshToken: string;
|
|
@@ -3005,5 +2819,5 @@ declare class SessionService {
|
|
|
3005
2819
|
*/
|
|
3006
2820
|
declare const AlephaApiUsers: alepha23.Service<alepha23.Module>;
|
|
3007
2821
|
//#endregion
|
|
3008
|
-
export { $
|
|
2822
|
+
export { $realm, AdminIdentityController, AdminSessionController, AdminUserController, AlephaApiUsers, CompletePasswordResetRequest, CompleteRegistrationRequest, CreateUser, CredentialService, DEFAULT_USER_REALM_NAME, IdentityEntity, IdentityQuery, IdentityResource, IdentityService, LoginInput, PasswordResetIntentResponse, Realm, RealmAuthSettings, RealmConfig, RealmController, RealmOptions, RealmPrimitive, RealmProvider, RealmRepositories, RegisterInput, RegistrationIntentResponse, RegistrationService, ResetPasswordInput, ResetPasswordRequest, SessionCrudService, SessionEntity, SessionQuery, SessionResource, SessionService, UpdateUser, UserController, UserEntity, UserQuery, UserResource, UserService, completePasswordResetRequestSchema, completeRegistrationRequestSchema, createUserSchema, identities, identityQuerySchema, identityResourceSchema, loginSchema, passwordResetIntentResponseSchema, realmAuthSettingsAtom, realmConfigSchema, registerSchema, registrationIntentResponseSchema, resetPasswordRequestSchema, resetPasswordSchema, sessionQuerySchema, sessionResourceSchema, sessions, updateUserSchema, userQuerySchema, userResourceSchema, users };
|
|
3009
2823
|
//# sourceMappingURL=index.d.ts.map
|