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
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-DtkW-qnP.js";
|
|
2
|
+
import * as alepha34 from "alepha";
|
|
2
3
|
import { Alepha, AlephaError, KIND, Page, Page as Page$1, PageQuery, PageQuery as PageQuery$1, Primitive, Service, Static, StaticEncode, TBigInt, TInteger, TNull, TNumber, TNumberOptions, TObject, TObjectOptions, TOptional, TPage, TSchema, TString, TStringOptions, TUnion, TUnsafe, pageQuerySchema, pageSchema } from "alepha";
|
|
3
4
|
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
4
|
-
import * as drizzle_orm0 from "drizzle-orm";
|
|
5
|
-
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
6
5
|
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
7
6
|
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
8
|
-
import * as
|
|
7
|
+
import * as drizzle_orm0 from "drizzle-orm";
|
|
8
|
+
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "drizzle-orm";
|
|
9
|
+
import * as alepha_logger3 from "alepha/logger";
|
|
9
10
|
import * as alepha_lock0 from "alepha/lock";
|
|
10
11
|
import * as pg$1 from "drizzle-orm/sqlite-core";
|
|
11
12
|
import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
|
|
12
13
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
13
14
|
import postgres from "postgres";
|
|
14
15
|
import * as alepha_retry0 from "alepha/retry";
|
|
15
|
-
import { SQL as SQL$1 } from "bun";
|
|
16
16
|
import { Database } from "bun:sqlite";
|
|
17
17
|
import { BunSQLDatabase } from "drizzle-orm/bun-sql";
|
|
18
18
|
import { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
|
|
19
19
|
import { DrizzleD1Database } from "drizzle-orm/d1";
|
|
20
20
|
import { DatabaseSync } from "node:sqlite";
|
|
21
|
+
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
|
|
21
22
|
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
22
23
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
23
|
-
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
|
|
24
24
|
import * as typebox1 from "typebox";
|
|
25
25
|
export * from "drizzle-orm/pg-core";
|
|
26
26
|
|
|
@@ -78,114 +78,114 @@ declare const $entity: {
|
|
|
78
78
|
};
|
|
79
79
|
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
* The database table name that will be created for this entity.
|
|
82
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
83
|
+
*/
|
|
84
84
|
name: string;
|
|
85
85
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
* TypeBox schema defining the table structure and column types.
|
|
87
|
+
*/
|
|
88
88
|
schema: T;
|
|
89
89
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
* Database indexes to create for query optimization.
|
|
91
|
+
*/
|
|
92
92
|
indexes?: (Keys | {
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
* Single column to index.
|
|
95
|
+
*/
|
|
96
96
|
column: Keys;
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
99
|
+
*/
|
|
100
100
|
unique?: boolean;
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
103
|
+
*/
|
|
104
104
|
name?: string;
|
|
105
105
|
} | {
|
|
106
106
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
108
|
+
*/
|
|
109
109
|
columns: Keys[];
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
112
|
+
*/
|
|
113
113
|
unique?: boolean;
|
|
114
114
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
116
|
+
*/
|
|
117
117
|
name?: string;
|
|
118
118
|
})[];
|
|
119
119
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
* Foreign key constraints to maintain referential integrity.
|
|
121
|
+
*/
|
|
122
122
|
foreignKeys?: Array<{
|
|
123
123
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
* Optional name for the foreign key constraint.
|
|
125
|
+
*/
|
|
126
126
|
name?: string;
|
|
127
127
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
* Local columns that reference the foreign table.
|
|
129
|
+
*/
|
|
130
130
|
columns: Array<keyof Static<T>>;
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
* Referenced columns in the foreign table.
|
|
133
|
+
* Must be EntityColumn references from other entities.
|
|
134
|
+
*/
|
|
135
135
|
foreignColumns: Array<() => EntityColumn<any>>;
|
|
136
136
|
}>;
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
138
|
+
* Additional table constraints for data validation.
|
|
139
|
+
*
|
|
140
|
+
* Constraints enforce business rules at the database level, providing
|
|
141
|
+
* an additional layer of data integrity beyond application validation.
|
|
142
|
+
*
|
|
143
|
+
* **Constraint Types**:
|
|
144
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
145
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* constraints: [
|
|
150
|
+
* {
|
|
151
|
+
* name: "unique_user_email",
|
|
152
|
+
* columns: ["email"],
|
|
153
|
+
* unique: true
|
|
154
|
+
* },
|
|
155
|
+
* {
|
|
156
|
+
* name: "valid_age_range",
|
|
157
|
+
* columns: ["age"],
|
|
158
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
159
|
+
* },
|
|
160
|
+
* {
|
|
161
|
+
* name: "unique_user_username_per_tenant",
|
|
162
|
+
* columns: ["tenantId", "username"],
|
|
163
|
+
* unique: true
|
|
164
|
+
* }
|
|
165
|
+
* ]
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
168
|
constraints?: Array<{
|
|
169
169
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
* Columns involved in this constraint.
|
|
171
|
+
*/
|
|
172
172
|
columns: Array<keyof Static<T>>;
|
|
173
173
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
* Optional name for the constraint.
|
|
175
|
+
*/
|
|
176
176
|
name?: string;
|
|
177
177
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
* Whether this is a unique constraint.
|
|
179
|
+
*/
|
|
180
180
|
unique?: boolean | {};
|
|
181
181
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
* SQL expression for check constraint validation.
|
|
183
|
+
*/
|
|
184
184
|
check?: SQL;
|
|
185
185
|
}>;
|
|
186
186
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
188
|
+
*/
|
|
189
189
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
190
190
|
}
|
|
191
191
|
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
@@ -242,8 +242,8 @@ type PgSymbols = {
|
|
|
242
242
|
[PG_REF]: PgRefOptions;
|
|
243
243
|
[PG_ENUM]: PgEnumOptions;
|
|
244
244
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
246
|
+
*/
|
|
247
247
|
[PG_SERIAL]: {};
|
|
248
248
|
};
|
|
249
249
|
type PgSymbolKeys = keyof PgSymbols;
|
|
@@ -279,13 +279,6 @@ declare class DbConflictError extends DbError {
|
|
|
279
279
|
readonly status = 409;
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
|
-
//#region ../../src/orm/errors/DbEntityNotFoundError.d.ts
|
|
283
|
-
declare class DbEntityNotFoundError extends DbError {
|
|
284
|
-
readonly name = "DbEntityNotFoundError";
|
|
285
|
-
readonly status = 404;
|
|
286
|
-
constructor(entityName: string);
|
|
287
|
-
}
|
|
288
|
-
//#endregion
|
|
289
282
|
//#region ../../src/orm/errors/DbMigrationError.d.ts
|
|
290
283
|
declare class DbMigrationError extends DbError {
|
|
291
284
|
readonly name = "DbMigrationError";
|
|
@@ -303,419 +296,426 @@ declare class DbVersionMismatchError extends DbError {
|
|
|
303
296
|
constructor(table: string, id: any);
|
|
304
297
|
}
|
|
305
298
|
//#endregion
|
|
299
|
+
//#region ../../src/orm/errors/DbEntityNotFoundError.d.ts
|
|
300
|
+
declare class DbEntityNotFoundError extends DbError {
|
|
301
|
+
readonly name = "DbEntityNotFoundError";
|
|
302
|
+
readonly status = 404;
|
|
303
|
+
constructor(entityName: string);
|
|
304
|
+
}
|
|
305
|
+
//#endregion
|
|
306
306
|
//#region ../../src/orm/interfaces/FilterOperators.d.ts
|
|
307
307
|
interface FilterOperators<TValue> {
|
|
308
308
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
309
|
+
* Test that two values are equal.
|
|
310
|
+
*
|
|
311
|
+
* Remember that the SQL standard dictates that
|
|
312
|
+
* two NULL values are not equal, so if you want to test
|
|
313
|
+
* whether a value is null, you may want to use
|
|
314
|
+
* `isNull` instead.
|
|
315
|
+
*
|
|
316
|
+
* ## Examples
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* // Select cars made by Ford
|
|
320
|
+
* db.select().from(cars)
|
|
321
|
+
* .where(eq(cars.make, 'Ford'))
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @see isNull for a way to test equality to NULL.
|
|
325
|
+
*/
|
|
326
326
|
eq?: TValue;
|
|
327
327
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
328
|
+
* Test that two values are not equal.
|
|
329
|
+
*
|
|
330
|
+
* Remember that the SQL standard dictates that
|
|
331
|
+
* two NULL values are not equal, so if you want to test
|
|
332
|
+
* whether a value is not null, you may want to use
|
|
333
|
+
* `isNotNull` instead.
|
|
334
|
+
*
|
|
335
|
+
* ## Examples
|
|
336
|
+
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* // Select cars not made by Ford
|
|
339
|
+
* db.select().from(cars)
|
|
340
|
+
* .where(ne(cars.make, 'Ford'))
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @see isNotNull for a way to test whether a value is not null.
|
|
344
|
+
*/
|
|
345
345
|
ne?: TValue;
|
|
346
346
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
347
|
+
* Test that the first expression passed is greater than
|
|
348
|
+
* the second expression.
|
|
349
|
+
*
|
|
350
|
+
* ## Examples
|
|
351
|
+
*
|
|
352
|
+
* ```ts
|
|
353
|
+
* // Select cars made after 2000.
|
|
354
|
+
* db.select().from(cars)
|
|
355
|
+
* .where(gt(cars.year, 2000))
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @see gte for greater-than-or-equal
|
|
359
|
+
*/
|
|
360
360
|
gt?: TValue;
|
|
361
361
|
/**
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
362
|
+
* Test that the first expression passed is greater than
|
|
363
|
+
* or equal to the second expression. Use `gt` to
|
|
364
|
+
* test whether an expression is strictly greater
|
|
365
|
+
* than another.
|
|
366
|
+
*
|
|
367
|
+
* ## Examples
|
|
368
|
+
*
|
|
369
|
+
* ```ts
|
|
370
|
+
* // Select cars made on or after 2000.
|
|
371
|
+
* db.select().from(cars)
|
|
372
|
+
* .where(gte(cars.year, 2000))
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @see gt for a strictly greater-than condition
|
|
376
|
+
*/
|
|
377
377
|
gte?: TValue;
|
|
378
378
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
379
|
+
* Test that the first expression passed is less than
|
|
380
|
+
* the second expression.
|
|
381
|
+
*
|
|
382
|
+
* ## Examples
|
|
383
|
+
*
|
|
384
|
+
* ```ts
|
|
385
|
+
* // Select cars made before 2000.
|
|
386
|
+
* db.select().from(cars)
|
|
387
|
+
* .where(lt(cars.year, 2000))
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @see lte for greater-than-or-equal
|
|
391
|
+
*/
|
|
392
392
|
lt?: TValue;
|
|
393
393
|
/**
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
394
|
+
* Test that the first expression passed is less than
|
|
395
|
+
* or equal to the second expression.
|
|
396
|
+
*
|
|
397
|
+
* ## Examples
|
|
398
|
+
*
|
|
399
|
+
* ```ts
|
|
400
|
+
* // Select cars made before 2000.
|
|
401
|
+
* db.select().from(cars)
|
|
402
|
+
* .where(lte(cars.year, 2000))
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* @see lt for a strictly less-than condition
|
|
406
|
+
*/
|
|
407
407
|
lte?: TValue;
|
|
408
408
|
/**
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
409
|
+
* Test whether the first parameter, a column or expression,
|
|
410
|
+
* has a value from a list passed as the second argument.
|
|
411
|
+
*
|
|
412
|
+
* ## Throws
|
|
413
|
+
*
|
|
414
|
+
* The argument passed in the second array can't be empty:
|
|
415
|
+
* if an empty is provided, this method will throw.
|
|
416
|
+
*
|
|
417
|
+
* ## Examples
|
|
418
|
+
*
|
|
419
|
+
* ```ts
|
|
420
|
+
* // Select cars made by Ford or GM.
|
|
421
|
+
* db.select().from(cars)
|
|
422
|
+
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
* @see notInArray for the inverse of this test
|
|
426
|
+
*/
|
|
427
427
|
inArray?: TValue[];
|
|
428
428
|
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
429
|
+
* Test whether the first parameter, a column or expression,
|
|
430
|
+
* has a value that is not present in a list passed as the
|
|
431
|
+
* second argument.
|
|
432
|
+
*
|
|
433
|
+
* ## Throws
|
|
434
|
+
*
|
|
435
|
+
* The argument passed in the second array can't be empty:
|
|
436
|
+
* if an empty is provided, this method will throw.
|
|
437
|
+
*
|
|
438
|
+
* ## Examples
|
|
439
|
+
*
|
|
440
|
+
* ```ts
|
|
441
|
+
* // Select cars made by any company except Ford or GM.
|
|
442
|
+
* db.select().from(cars)
|
|
443
|
+
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @see inArray for the inverse of this test
|
|
447
|
+
*/
|
|
448
448
|
notInArray?: TValue[];
|
|
449
449
|
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
450
|
+
* Test whether an expression is not NULL. By the SQL standard,
|
|
451
|
+
* NULL is neither equal nor not equal to itself, so
|
|
452
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
453
|
+
* comparisons to NULL.
|
|
454
|
+
*
|
|
455
|
+
* ## Examples
|
|
456
|
+
*
|
|
457
|
+
* ```ts
|
|
458
|
+
* // Select cars that have been discontinued.
|
|
459
|
+
* db.select().from(cars)
|
|
460
|
+
* .where(isNotNull(cars.discontinuedAt))
|
|
461
|
+
* ```
|
|
462
|
+
*
|
|
463
|
+
* @see isNull for the inverse of this test
|
|
464
|
+
*/
|
|
465
465
|
isNotNull?: true;
|
|
466
466
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
467
|
+
* Test whether an expression is NULL. By the SQL standard,
|
|
468
|
+
* NULL is neither equal nor not equal to itself, so
|
|
469
|
+
* it's recommended to use `isNull` and `notIsNull` for
|
|
470
|
+
* comparisons to NULL.
|
|
471
|
+
*
|
|
472
|
+
* ## Examples
|
|
473
|
+
*
|
|
474
|
+
* ```ts
|
|
475
|
+
* // Select cars that have no discontinuedAt date.
|
|
476
|
+
* db.select().from(cars)
|
|
477
|
+
* .where(isNull(cars.discontinuedAt))
|
|
478
|
+
* ```
|
|
479
|
+
*
|
|
480
|
+
* @see isNotNull for the inverse of this test
|
|
481
|
+
*/
|
|
482
482
|
isNull?: true;
|
|
483
483
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
484
|
+
* Test whether an expression is between two values. This
|
|
485
|
+
* is an easier way to express range tests, which would be
|
|
486
|
+
* expressed mathematically as `x <= a <= y` but in SQL
|
|
487
|
+
* would have to be like `a >= x AND a <= y`.
|
|
488
|
+
*
|
|
489
|
+
* Between is inclusive of the endpoints: if `column`
|
|
490
|
+
* is equal to `min` or `max`, it will be TRUE.
|
|
491
|
+
*
|
|
492
|
+
* ## Examples
|
|
493
|
+
*
|
|
494
|
+
* ```ts
|
|
495
|
+
* // Select cars made between 1990 and 2000
|
|
496
|
+
* db.select().from(cars)
|
|
497
|
+
* .where(between(cars.year, 1990, 2000))
|
|
498
|
+
* ```
|
|
499
|
+
*
|
|
500
|
+
* @see notBetween for the inverse of this test
|
|
501
|
+
*/
|
|
502
502
|
between?: [number, number];
|
|
503
503
|
/**
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
504
|
+
* Test whether an expression is not between two values.
|
|
505
|
+
*
|
|
506
|
+
* This, like `between`, includes its endpoints, so if
|
|
507
|
+
* the `column` is equal to `min` or `max`, in this case
|
|
508
|
+
* it will evaluate to FALSE.
|
|
509
|
+
*
|
|
510
|
+
* ## Examples
|
|
511
|
+
*
|
|
512
|
+
* ```ts
|
|
513
|
+
* // Exclude cars made in the 1970s
|
|
514
|
+
* db.select().from(cars)
|
|
515
|
+
* .where(notBetween(cars.year, 1970, 1979))
|
|
516
|
+
* ```
|
|
517
|
+
*
|
|
518
|
+
* @see between for the inverse of this test
|
|
519
|
+
*/
|
|
520
520
|
notBetween?: [number, number];
|
|
521
521
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
522
|
+
* Compare a column to a pattern, which can include `%` and `_`
|
|
523
|
+
* characters to match multiple variations. Including `%`
|
|
524
|
+
* in the pattern matches zero or more characters, and including
|
|
525
|
+
* `_` will match a single character.
|
|
526
|
+
*
|
|
527
|
+
* ## Examples
|
|
528
|
+
*
|
|
529
|
+
* ```ts
|
|
530
|
+
* // Select all cars with 'Turbo' in their names.
|
|
531
|
+
* db.select().from(cars)
|
|
532
|
+
* .where(like(cars.name, '%Turbo%'))
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @see ilike for a case-insensitive version of this condition
|
|
536
|
+
*/
|
|
537
537
|
like?: string;
|
|
538
538
|
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
539
|
+
* The inverse of like - this tests that a given column
|
|
540
|
+
* does not match a pattern, which can include `%` and `_`
|
|
541
|
+
* characters to match multiple variations. Including `%`
|
|
542
|
+
* in the pattern matches zero or more characters, and including
|
|
543
|
+
* `_` will match a single character.
|
|
544
|
+
*
|
|
545
|
+
* ## Examples
|
|
546
|
+
*
|
|
547
|
+
* ```ts
|
|
548
|
+
* // Select all cars that don't have "ROver" in their name.
|
|
549
|
+
* db.select().from(cars)
|
|
550
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* @see like for the inverse condition
|
|
554
|
+
* @see notIlike for a case-insensitive version of this condition
|
|
555
|
+
*/
|
|
556
556
|
notLike?: string;
|
|
557
557
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
558
|
+
* Case-insensitively compare a column to a pattern,
|
|
559
|
+
* which can include `%` and `_`
|
|
560
|
+
* characters to match multiple variations. Including `%`
|
|
561
|
+
* in the pattern matches zero or more characters, and including
|
|
562
|
+
* `_` will match a single character.
|
|
563
|
+
*
|
|
564
|
+
* Unlike like, this performs a case-insensitive comparison.
|
|
565
|
+
*
|
|
566
|
+
* ## Examples
|
|
567
|
+
*
|
|
568
|
+
* ```ts
|
|
569
|
+
* // Select all cars with 'Turbo' in their names.
|
|
570
|
+
* db.select().from(cars)
|
|
571
|
+
* .where(ilike(cars.name, '%Turbo%'))
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @see like for a case-sensitive version of this condition
|
|
575
|
+
*/
|
|
576
576
|
ilike?: string;
|
|
577
577
|
/**
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
578
|
+
* The inverse of ilike - this case-insensitively tests that a given column
|
|
579
|
+
* does not match a pattern, which can include `%` and `_`
|
|
580
|
+
* characters to match multiple variations. Including `%`
|
|
581
|
+
* in the pattern matches zero or more characters, and including
|
|
582
|
+
* `_` will match a single character.
|
|
583
|
+
*
|
|
584
|
+
* ## Examples
|
|
585
|
+
*
|
|
586
|
+
* ```ts
|
|
587
|
+
* // Select all cars that don't have "Rover" in their name.
|
|
588
|
+
* db.select().from(cars)
|
|
589
|
+
* .where(notLike(cars.name, '%Rover%'))
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @see ilike for the inverse condition
|
|
593
|
+
* @see notLike for a case-sensitive version of this condition
|
|
594
|
+
*/
|
|
595
595
|
notIlike?: string;
|
|
596
596
|
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
597
|
+
* Syntactic sugar for case-insensitive substring matching.
|
|
598
|
+
* Automatically wraps the value with `%` wildcards on both sides.
|
|
599
|
+
*
|
|
600
|
+
* Equivalent to: `ilike: '%value%'`
|
|
601
|
+
*
|
|
602
|
+
* ## Examples
|
|
603
|
+
*
|
|
604
|
+
* ```ts
|
|
605
|
+
* // Select all cars with "Turbo" anywhere in their name.
|
|
606
|
+
* db.select().from(cars)
|
|
607
|
+
* .where({ name: { contains: 'Turbo' } })
|
|
608
|
+
* // Same as: .where(ilike(cars.name, '%Turbo%'))
|
|
609
|
+
* ```
|
|
610
|
+
*
|
|
611
|
+
* @see ilike for manual pattern matching
|
|
612
|
+
* @see startsWith for prefix matching
|
|
613
|
+
* @see endsWith for suffix matching
|
|
614
|
+
*/
|
|
615
615
|
contains?: string;
|
|
616
616
|
/**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
617
|
+
* Syntactic sugar for case-insensitive prefix matching.
|
|
618
|
+
* Automatically appends a `%` wildcard to the end of the value.
|
|
619
|
+
*
|
|
620
|
+
* Equivalent to: `ilike: 'value%'`
|
|
621
|
+
*
|
|
622
|
+
* ## Examples
|
|
623
|
+
*
|
|
624
|
+
* ```ts
|
|
625
|
+
* // Select all cars whose names start with "Ford".
|
|
626
|
+
* db.select().from(cars)
|
|
627
|
+
* .where({ name: { startsWith: 'Ford' } })
|
|
628
|
+
* // Same as: .where(ilike(cars.name, 'Ford%'))
|
|
629
|
+
* ```
|
|
630
|
+
*
|
|
631
|
+
* @see ilike for manual pattern matching
|
|
632
|
+
* @see contains for substring matching
|
|
633
|
+
* @see endsWith for suffix matching
|
|
634
|
+
*/
|
|
635
635
|
startsWith?: string;
|
|
636
636
|
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
637
|
+
* Syntactic sugar for case-insensitive suffix matching.
|
|
638
|
+
* Automatically prepends a `%` wildcard to the beginning of the value.
|
|
639
|
+
*
|
|
640
|
+
* Equivalent to: `ilike: '%value'`
|
|
641
|
+
*
|
|
642
|
+
* ## Examples
|
|
643
|
+
*
|
|
644
|
+
* ```ts
|
|
645
|
+
* // Select all cars whose names end with "Turbo".
|
|
646
|
+
* db.select().from(cars)
|
|
647
|
+
* .where({ name: { endsWith: 'Turbo' } })
|
|
648
|
+
* // Same as: .where(ilike(cars.name, '%Turbo'))
|
|
649
|
+
* ```
|
|
650
|
+
*
|
|
651
|
+
* @see ilike for manual pattern matching
|
|
652
|
+
* @see contains for substring matching
|
|
653
|
+
* @see startsWith for prefix matching
|
|
654
|
+
*/
|
|
655
655
|
endsWith?: string;
|
|
656
656
|
/**
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
657
|
+
* Test that a column or expression contains all elements of
|
|
658
|
+
* the list passed as the second argument.
|
|
659
|
+
*
|
|
660
|
+
* ## Throws
|
|
661
|
+
*
|
|
662
|
+
* The argument passed in the second array can't be empty:
|
|
663
|
+
* if an empty is provided, this method will throw.
|
|
664
|
+
*
|
|
665
|
+
* ## Examples
|
|
666
|
+
*
|
|
667
|
+
* ```ts
|
|
668
|
+
* // Select posts where its tags contain "Typescript" and "ORM".
|
|
669
|
+
* db.select().from(posts)
|
|
670
|
+
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
674
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
675
|
+
*/
|
|
676
676
|
arrayContains?: TValue;
|
|
677
677
|
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
678
|
+
* Test that the list passed as the second argument contains
|
|
679
|
+
* all elements of a column or expression.
|
|
680
|
+
*
|
|
681
|
+
* ## Throws
|
|
682
|
+
*
|
|
683
|
+
* The argument passed in the second array can't be empty:
|
|
684
|
+
* if an empty is provided, this method will throw.
|
|
685
|
+
*
|
|
686
|
+
* ## Examples
|
|
687
|
+
*
|
|
688
|
+
* ```ts
|
|
689
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
|
690
|
+
* // but filtering posts that have additional tags.
|
|
691
|
+
* db.select().from(posts)
|
|
692
|
+
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
|
693
|
+
* ```
|
|
694
|
+
*
|
|
695
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
696
|
+
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
697
|
+
*/
|
|
698
698
|
arrayContained?: TValue;
|
|
699
699
|
/**
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
700
|
+
* Test that a column or expression contains any elements of
|
|
701
|
+
* the list passed as the second argument.
|
|
702
|
+
*
|
|
703
|
+
* ## Throws
|
|
704
|
+
*
|
|
705
|
+
* The argument passed in the second array can't be empty:
|
|
706
|
+
* if an empty is provided, this method will throw.
|
|
707
|
+
*
|
|
708
|
+
* ## Examples
|
|
709
|
+
*
|
|
710
|
+
* ```ts
|
|
711
|
+
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
|
712
|
+
* db.select().from(posts)
|
|
713
|
+
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
|
714
|
+
* ```
|
|
715
|
+
*
|
|
716
|
+
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
717
|
+
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
718
|
+
*/
|
|
719
719
|
arrayOverlaps?: TValue;
|
|
720
720
|
}
|
|
721
721
|
//#endregion
|
|
@@ -774,71 +774,71 @@ type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObjec
|
|
|
774
774
|
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
|
|
775
775
|
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
776
776
|
/**
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
777
|
+
* Combine a list of conditions with the `and` operator. Conditions
|
|
778
|
+
* that are equal `undefined` are automatically ignored.
|
|
779
|
+
*
|
|
780
|
+
* ## Examples
|
|
781
|
+
*
|
|
782
|
+
* ```ts
|
|
783
|
+
* db.select().from(cars)
|
|
784
|
+
* .where(
|
|
785
|
+
* and(
|
|
786
|
+
* eq(cars.make, 'Volvo'),
|
|
787
|
+
* eq(cars.year, 1950),
|
|
788
|
+
* )
|
|
789
|
+
* )
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
792
792
|
and?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
793
793
|
/**
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
794
|
+
* Combine a list of conditions with the `or` operator. Conditions
|
|
795
|
+
* that are equal `undefined` are automatically ignored.
|
|
796
|
+
*
|
|
797
|
+
* ## Examples
|
|
798
|
+
*
|
|
799
|
+
* ```ts
|
|
800
|
+
* db.select().from(cars)
|
|
801
|
+
* .where(
|
|
802
|
+
* or(
|
|
803
|
+
* eq(cars.make, 'GM'),
|
|
804
|
+
* eq(cars.make, 'Ford'),
|
|
805
|
+
* )
|
|
806
|
+
* )
|
|
807
|
+
* ```
|
|
808
|
+
*/
|
|
809
809
|
or?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
810
810
|
/**
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
811
|
+
* Negate the meaning of an expression using the `not` keyword.
|
|
812
|
+
*
|
|
813
|
+
* ## Examples
|
|
814
|
+
*
|
|
815
|
+
* ```ts
|
|
816
|
+
* // Select cars _not_ made by GM or Ford.
|
|
817
|
+
* db.select().from(cars)
|
|
818
|
+
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
821
|
not?: PgQueryWhereOrSQL<T, Relations>;
|
|
822
822
|
/**
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
823
|
+
* Test whether a subquery evaluates to have any rows.
|
|
824
|
+
*
|
|
825
|
+
* ## Examples
|
|
826
|
+
*
|
|
827
|
+
* ```ts
|
|
828
|
+
* // Users whose `homeCity` column has a match in a cities
|
|
829
|
+
* // table.
|
|
830
|
+
* db
|
|
831
|
+
* .select()
|
|
832
|
+
* .from(users)
|
|
833
|
+
* .where(
|
|
834
|
+
* exists(db.select()
|
|
835
|
+
* .from(cities)
|
|
836
|
+
* .where(eq(users.homeCity, cities.id))),
|
|
837
|
+
* );
|
|
838
|
+
* ```
|
|
839
|
+
*
|
|
840
|
+
* @see notExists for the inverse of this test
|
|
841
|
+
*/
|
|
842
842
|
exists?: SQLWrapper;
|
|
843
843
|
};
|
|
844
844
|
type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
|
|
@@ -943,6 +943,116 @@ interface PgAttrField {
|
|
|
943
943
|
one?: boolean;
|
|
944
944
|
}
|
|
945
945
|
//#endregion
|
|
946
|
+
//#region ../../src/orm/providers/DatabaseTypeProvider.d.ts
|
|
947
|
+
declare class DatabaseTypeProvider {
|
|
948
|
+
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
949
|
+
/**
|
|
950
|
+
* Creates a primary key with an identity column.
|
|
951
|
+
*/
|
|
952
|
+
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
953
|
+
/**
|
|
954
|
+
* Creates a primary key with a big identity column. (default)
|
|
955
|
+
*/
|
|
956
|
+
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
957
|
+
/**
|
|
958
|
+
* Creates a primary key with a UUID column.
|
|
959
|
+
*/
|
|
960
|
+
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
961
|
+
/**
|
|
962
|
+
* Creates a primary key for a given type. Supports:
|
|
963
|
+
* - `t.integer()` -> PG INT (default)
|
|
964
|
+
* - `t.bigint()` -> PG BIGINT
|
|
965
|
+
* - `t.uuid()` -> PG UUID
|
|
966
|
+
*/
|
|
967
|
+
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
968
|
+
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
969
|
+
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
970
|
+
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
971
|
+
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
972
|
+
/**
|
|
973
|
+
* Wrap a schema with "default" attribute.
|
|
974
|
+
* This is used to set a default value for a column in the database.
|
|
975
|
+
*/
|
|
976
|
+
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
977
|
+
/**
|
|
978
|
+
* Creates a column 'version'.
|
|
979
|
+
*
|
|
980
|
+
* This is used to track the version of a row in the database.
|
|
981
|
+
*
|
|
982
|
+
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
983
|
+
*
|
|
984
|
+
* @see {@link RepositoryPrimitive#save}
|
|
985
|
+
* @see {@link PgVersionMismatchError}
|
|
986
|
+
*/
|
|
987
|
+
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
988
|
+
/**
|
|
989
|
+
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
990
|
+
*/
|
|
991
|
+
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
992
|
+
/**
|
|
993
|
+
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
994
|
+
*/
|
|
995
|
+
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
996
|
+
/**
|
|
997
|
+
* Creates a column Deleted At for soft delete functionality.
|
|
998
|
+
* This is used to mark rows as deleted without actually removing them from the database.
|
|
999
|
+
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1000
|
+
*/
|
|
1001
|
+
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha34.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Creates a Postgres ENUM type.
|
|
1004
|
+
*
|
|
1005
|
+
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
1006
|
+
* > Using this method, you can create a real ENUM type in the database.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
1014
|
+
/**
|
|
1015
|
+
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1016
|
+
*/
|
|
1017
|
+
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
1018
|
+
onUpdate?: UpdateDeleteAction$1;
|
|
1019
|
+
onDelete?: UpdateDeleteAction$1;
|
|
1020
|
+
}) => PgAttr<T, PgRef>;
|
|
1021
|
+
/**
|
|
1022
|
+
* Creates a page schema for a given object schema.
|
|
1023
|
+
* It's used by {@link Repository#paginate} method.
|
|
1024
|
+
*/
|
|
1025
|
+
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Wrapper of TypeProvider (`t`) for database types.
|
|
1029
|
+
*
|
|
1030
|
+
* Use `db` for improve TypeBox schema definitions with database-specific attributes.
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```ts
|
|
1034
|
+
* import { t } from "alepha";
|
|
1035
|
+
* import { db } from "alepha/orm";
|
|
1036
|
+
*
|
|
1037
|
+
* const userSchema = t.object({
|
|
1038
|
+
* id: db.primaryKey(t.uuid()),
|
|
1039
|
+
* email: t.email(),
|
|
1040
|
+
* createdAt: db.createdAt(),
|
|
1041
|
+
* });
|
|
1042
|
+
* ```
|
|
1043
|
+
*/
|
|
1044
|
+
declare const db: DatabaseTypeProvider;
|
|
1045
|
+
/**
|
|
1046
|
+
* @deprecated Use `db` instead.
|
|
1047
|
+
*/
|
|
1048
|
+
declare const pg: DatabaseTypeProvider;
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region ../../src/orm/schemas/legacyIdSchema.d.ts
|
|
1051
|
+
/**
|
|
1052
|
+
* @deprecated Use `pg.primaryKey()` instead.
|
|
1053
|
+
*/
|
|
1054
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<alepha34.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1055
|
+
//#endregion
|
|
946
1056
|
//#region ../../src/orm/primitives/$sequence.d.ts
|
|
947
1057
|
/**
|
|
948
1058
|
* Creates a PostgreSQL sequence primitive for generating unique numeric values.
|
|
@@ -953,8 +1063,8 @@ declare const $sequence: {
|
|
|
953
1063
|
};
|
|
954
1064
|
interface SequencePrimitiveOptions extends PgSequenceOptions {
|
|
955
1065
|
/**
|
|
956
|
-
|
|
957
|
-
|
|
1066
|
+
* The name of the sequence. If not provided, the property key will be used.
|
|
1067
|
+
*/
|
|
958
1068
|
name?: string;
|
|
959
1069
|
provider?: DatabaseProvider;
|
|
960
1070
|
}
|
|
@@ -994,79 +1104,79 @@ interface TableConfigBuilders<TConfig> {
|
|
|
994
1104
|
*/
|
|
995
1105
|
declare abstract class ModelBuilder {
|
|
996
1106
|
/**
|
|
997
|
-
|
|
998
|
-
|
|
1107
|
+
* Build a table from an entity primitive.
|
|
1108
|
+
*/
|
|
999
1109
|
abstract buildTable(entity: EntityPrimitive, options: {
|
|
1000
1110
|
tables: Map<string, unknown>;
|
|
1001
1111
|
enums: Map<string, unknown>;
|
|
1002
1112
|
schema: string;
|
|
1003
1113
|
}): void;
|
|
1004
1114
|
/**
|
|
1005
|
-
|
|
1006
|
-
|
|
1115
|
+
* Build a sequence from a sequence primitive.
|
|
1116
|
+
*/
|
|
1007
1117
|
abstract buildSequence(sequence: SequencePrimitive, options: {
|
|
1008
1118
|
sequences: Map<string, unknown>;
|
|
1009
1119
|
schema: string;
|
|
1010
1120
|
}): void;
|
|
1011
1121
|
/**
|
|
1012
|
-
|
|
1013
|
-
|
|
1122
|
+
* Convert camelCase to snake_case for column names.
|
|
1123
|
+
*/
|
|
1014
1124
|
protected toColumnName(str: string): string;
|
|
1015
1125
|
/**
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1126
|
+
* Build the table configuration function for any database.
|
|
1127
|
+
* This includes indexes, foreign keys, constraints, and custom config.
|
|
1128
|
+
*
|
|
1129
|
+
* @param entity - The entity primitive
|
|
1130
|
+
* @param builders - Database-specific builder functions
|
|
1131
|
+
* @param tableResolver - Function to resolve entity references to table columns
|
|
1132
|
+
* @param customConfigHandler - Optional handler for custom config
|
|
1133
|
+
*/
|
|
1024
1134
|
protected buildTableConfig<TConfig, TSelf>(entity: EntityPrimitive, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
1025
1135
|
}
|
|
1026
1136
|
//#endregion
|
|
1027
1137
|
//#region ../../src/orm/providers/DrizzleKitProvider.d.ts
|
|
1028
1138
|
declare class DrizzleKitProvider {
|
|
1029
|
-
protected readonly log:
|
|
1139
|
+
protected readonly log: alepha_logger3.Logger;
|
|
1030
1140
|
protected readonly alepha: Alepha;
|
|
1031
1141
|
/**
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1142
|
+
* Synchronize database with current schema definitions.
|
|
1143
|
+
*
|
|
1144
|
+
* In development mode, it will generate and execute migrations based on the current state.
|
|
1145
|
+
* In testing mode, it will generate migrations from scratch without applying them.
|
|
1146
|
+
*
|
|
1147
|
+
* Does nothing in production mode, you must handle migrations manually.
|
|
1148
|
+
*/
|
|
1039
1149
|
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
1040
1150
|
/**
|
|
1041
|
-
|
|
1042
|
-
|
|
1151
|
+
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
1152
|
+
*/
|
|
1043
1153
|
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
1044
1154
|
statements: string[];
|
|
1045
1155
|
models: Record<string, unknown>;
|
|
1046
1156
|
snapshot?: any;
|
|
1047
1157
|
}>;
|
|
1048
1158
|
/**
|
|
1049
|
-
|
|
1050
|
-
|
|
1159
|
+
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
1160
|
+
*/
|
|
1051
1161
|
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
1052
1162
|
/**
|
|
1053
|
-
|
|
1054
|
-
|
|
1163
|
+
* Load the migration snapshot from the database.
|
|
1164
|
+
*/
|
|
1055
1165
|
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
1056
1166
|
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
1057
1167
|
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
1058
1168
|
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
1059
1169
|
/**
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1170
|
+
* Try to load the official Drizzle Kit API.
|
|
1171
|
+
* If not available, fallback to the local kit import.
|
|
1172
|
+
*/
|
|
1063
1173
|
importDrizzleKit(): typeof DrizzleKit;
|
|
1064
1174
|
}
|
|
1065
|
-
declare const devMigrationsSchema:
|
|
1066
|
-
id:
|
|
1067
|
-
name:
|
|
1068
|
-
snapshot:
|
|
1069
|
-
created_at:
|
|
1175
|
+
declare const devMigrationsSchema: alepha34.TObject<{
|
|
1176
|
+
id: alepha34.TNumber;
|
|
1177
|
+
name: alepha34.TString;
|
|
1178
|
+
snapshot: alepha34.TString;
|
|
1179
|
+
created_at: alepha34.TString;
|
|
1070
1180
|
}>;
|
|
1071
1181
|
type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
1072
1182
|
//#endregion
|
|
@@ -1074,7 +1184,7 @@ type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
|
1074
1184
|
type SQLLike = SQLWrapper | string;
|
|
1075
1185
|
declare abstract class DatabaseProvider {
|
|
1076
1186
|
protected readonly alepha: Alepha;
|
|
1077
|
-
protected readonly log:
|
|
1187
|
+
protected readonly log: alepha_logger3.Logger;
|
|
1078
1188
|
protected abstract readonly builder: ModelBuilder;
|
|
1079
1189
|
protected abstract readonly kit: DrizzleKitProvider;
|
|
1080
1190
|
abstract readonly db: PgDatabase<any>;
|
|
@@ -1084,6 +1194,7 @@ declare abstract class DatabaseProvider {
|
|
|
1084
1194
|
readonly tables: Map<string, unknown>;
|
|
1085
1195
|
readonly sequences: Map<string, unknown>;
|
|
1086
1196
|
get name(): string;
|
|
1197
|
+
get driver(): string;
|
|
1087
1198
|
get schema(): string;
|
|
1088
1199
|
table<T extends TObject>(entity: EntityPrimitive<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1089
1200
|
registerEntity(entity: EntityPrimitive): void;
|
|
@@ -1091,39 +1202,39 @@ declare abstract class DatabaseProvider {
|
|
|
1091
1202
|
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
1092
1203
|
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
1093
1204
|
/**
|
|
1094
|
-
|
|
1095
|
-
|
|
1205
|
+
* Get migrations folder path - can be overridden
|
|
1206
|
+
*/
|
|
1096
1207
|
protected getMigrationsFolder(): string;
|
|
1097
1208
|
/**
|
|
1098
|
-
|
|
1099
|
-
|
|
1209
|
+
* Base migration orchestration - handles environment logic
|
|
1210
|
+
*/
|
|
1100
1211
|
migrate(): Promise<void>;
|
|
1101
1212
|
/**
|
|
1102
|
-
|
|
1103
|
-
|
|
1213
|
+
* Production: run migrations from folder
|
|
1214
|
+
*/
|
|
1104
1215
|
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
1105
1216
|
/**
|
|
1106
|
-
|
|
1107
|
-
|
|
1217
|
+
* Test: always synchronize
|
|
1218
|
+
*/
|
|
1108
1219
|
protected runTestMigration(): Promise<void>;
|
|
1109
1220
|
/**
|
|
1110
|
-
|
|
1111
|
-
|
|
1221
|
+
* Development: default to synchronize (can be overridden)
|
|
1222
|
+
*/
|
|
1112
1223
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
1113
1224
|
/**
|
|
1114
|
-
|
|
1115
|
-
|
|
1225
|
+
* Common synchronization with error handling
|
|
1226
|
+
*/
|
|
1116
1227
|
protected synchronizeSchema(): Promise<void>;
|
|
1117
1228
|
/**
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1229
|
+
* Provider-specific migration execution
|
|
1230
|
+
* MUST be implemented by each provider
|
|
1231
|
+
*/
|
|
1121
1232
|
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1122
1233
|
/**
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1234
|
+
* For testing purposes, generate a unique schema name.
|
|
1235
|
+
* The schema name will be generated based on the current date and time.
|
|
1236
|
+
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
1237
|
+
*/
|
|
1127
1238
|
protected generateTestSchemaName(): string;
|
|
1128
1239
|
}
|
|
1129
1240
|
//#endregion
|
|
@@ -1131,8 +1242,8 @@ declare abstract class DatabaseProvider {
|
|
|
1131
1242
|
declare class QueryManager {
|
|
1132
1243
|
protected readonly alepha: Alepha;
|
|
1133
1244
|
/**
|
|
1134
|
-
|
|
1135
|
-
|
|
1245
|
+
* Convert a query object to a SQL query.
|
|
1246
|
+
*/
|
|
1136
1247
|
toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
|
|
1137
1248
|
schema: TObject;
|
|
1138
1249
|
col: (key: string) => PgColumn;
|
|
@@ -1140,22 +1251,22 @@ declare class QueryManager {
|
|
|
1140
1251
|
dialect: "postgresql" | "sqlite";
|
|
1141
1252
|
}): SQL | undefined;
|
|
1142
1253
|
/**
|
|
1143
|
-
|
|
1144
|
-
|
|
1254
|
+
* Check if an object has any filter operator properties.
|
|
1255
|
+
*/
|
|
1145
1256
|
protected hasFilterOperatorProperties(obj: any): boolean;
|
|
1146
1257
|
/**
|
|
1147
|
-
|
|
1148
|
-
|
|
1258
|
+
* Map a filter operator to a SQL query.
|
|
1259
|
+
*/
|
|
1149
1260
|
mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
|
|
1150
1261
|
/**
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1262
|
+
* Parse pagination sort string to orderBy format.
|
|
1263
|
+
* Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
|
|
1264
|
+
* - Columns separated by comma
|
|
1265
|
+
* - Prefix with '-' for DESC direction
|
|
1266
|
+
*
|
|
1267
|
+
* @param sort Pagination sort string
|
|
1268
|
+
* @returns OrderBy array or single object
|
|
1269
|
+
*/
|
|
1159
1270
|
parsePaginationSort(sort: string): Array<{
|
|
1160
1271
|
column: string;
|
|
1161
1272
|
direction: "asc" | "desc";
|
|
@@ -1164,34 +1275,34 @@ declare class QueryManager {
|
|
|
1164
1275
|
direction: "asc" | "desc";
|
|
1165
1276
|
};
|
|
1166
1277
|
/**
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1278
|
+
* Normalize orderBy parameter to array format.
|
|
1279
|
+
* Supports 3 modes:
|
|
1280
|
+
* 1. String: "name" -> [{ column: "name", direction: "asc" }]
|
|
1281
|
+
* 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
|
|
1282
|
+
* 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
|
|
1283
|
+
*
|
|
1284
|
+
* @param orderBy The orderBy parameter
|
|
1285
|
+
* @returns Normalized array of order by clauses
|
|
1286
|
+
*/
|
|
1176
1287
|
normalizeOrderBy(orderBy: any): Array<{
|
|
1177
1288
|
column: string;
|
|
1178
1289
|
direction: "asc" | "desc";
|
|
1179
1290
|
}>;
|
|
1180
1291
|
/**
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1292
|
+
* Create a pagination object.
|
|
1293
|
+
*
|
|
1294
|
+
* @deprecated Use `createPagination` from alepha instead.
|
|
1295
|
+
* This method now delegates to the framework-level helper.
|
|
1296
|
+
*
|
|
1297
|
+
* @param entities The entities to paginate.
|
|
1298
|
+
* @param limit The limit of the pagination.
|
|
1299
|
+
* @param offset The offset of the pagination.
|
|
1300
|
+
* @param sort Optional sort metadata to include in response.
|
|
1301
|
+
*/
|
|
1191
1302
|
createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
|
|
1192
1303
|
column: string;
|
|
1193
1304
|
direction: "asc" | "desc";
|
|
1194
|
-
}>):
|
|
1305
|
+
}>): alepha34.Page<T>;
|
|
1195
1306
|
}
|
|
1196
1307
|
interface PgJoin {
|
|
1197
1308
|
table: string;
|
|
@@ -1204,20 +1315,20 @@ interface PgJoin {
|
|
|
1204
1315
|
//#region ../../src/orm/services/PgRelationManager.d.ts
|
|
1205
1316
|
declare class PgRelationManager {
|
|
1206
1317
|
/**
|
|
1207
|
-
|
|
1208
|
-
|
|
1318
|
+
* Recursively build joins for the query builder based on the relations map
|
|
1319
|
+
*/
|
|
1209
1320
|
buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
|
|
1210
1321
|
/**
|
|
1211
|
-
|
|
1212
|
-
|
|
1322
|
+
* Map a row with its joined relations based on the joins definition
|
|
1323
|
+
*/
|
|
1213
1324
|
mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
|
|
1214
1325
|
/**
|
|
1215
|
-
|
|
1216
|
-
|
|
1326
|
+
* Check if all values in an object are null (indicates a left join with no match)
|
|
1327
|
+
*/
|
|
1217
1328
|
private isAllNull;
|
|
1218
1329
|
/**
|
|
1219
|
-
|
|
1220
|
-
|
|
1330
|
+
* Build a schema that includes all join properties recursively
|
|
1331
|
+
*/
|
|
1221
1332
|
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1222
1333
|
}
|
|
1223
1334
|
//#endregion
|
|
@@ -1225,216 +1336,217 @@ declare class PgRelationManager {
|
|
|
1225
1336
|
declare abstract class Repository<T extends TObject> {
|
|
1226
1337
|
readonly entity: EntityPrimitive<T>;
|
|
1227
1338
|
readonly provider: DatabaseProvider;
|
|
1339
|
+
protected readonly log: alepha_logger3.Logger;
|
|
1228
1340
|
protected readonly relationManager: PgRelationManager;
|
|
1229
1341
|
protected readonly queryManager: QueryManager;
|
|
1230
1342
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1231
1343
|
protected readonly alepha: Alepha;
|
|
1232
1344
|
constructor(entity: EntityPrimitive<T>, provider?: typeof DatabaseProvider);
|
|
1233
1345
|
/**
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1346
|
+
* Represents the primary key of the table.
|
|
1347
|
+
* - Key is the name of the primary key column.
|
|
1348
|
+
* - Type is the type (TypeBox) of the primary key column.
|
|
1349
|
+
*
|
|
1350
|
+
* ID is mandatory. If the table does not have a primary key, it will throw an error.
|
|
1351
|
+
*/
|
|
1240
1352
|
get id(): {
|
|
1241
1353
|
type: TSchema;
|
|
1242
1354
|
key: keyof T["properties"];
|
|
1243
1355
|
col: PgColumn;
|
|
1244
1356
|
};
|
|
1245
1357
|
/**
|
|
1246
|
-
|
|
1247
|
-
|
|
1358
|
+
* Get Drizzle table object.
|
|
1359
|
+
*/
|
|
1248
1360
|
get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1249
1361
|
/**
|
|
1250
|
-
|
|
1251
|
-
|
|
1362
|
+
* Get SQL table name. (from Drizzle table object)
|
|
1363
|
+
*/
|
|
1252
1364
|
get tableName(): string;
|
|
1253
1365
|
/**
|
|
1254
|
-
|
|
1255
|
-
|
|
1366
|
+
* Getter for the database connection from the database provider.
|
|
1367
|
+
*/
|
|
1256
1368
|
protected get db(): PgDatabase<any>;
|
|
1257
1369
|
/**
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1370
|
+
* Execute a SQL query.
|
|
1371
|
+
*
|
|
1372
|
+
* This method allows executing raw SQL queries against the database.
|
|
1373
|
+
* This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
|
|
1374
|
+
*
|
|
1375
|
+
* You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
* ```ts
|
|
1379
|
+
* class App {
|
|
1380
|
+
* repository = $repository({ ... });
|
|
1381
|
+
* async getAdults() {
|
|
1382
|
+
* const users = repository.table; // Drizzle table object
|
|
1383
|
+
* await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1384
|
+
* // or better
|
|
1385
|
+
* await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
1386
|
+
* }
|
|
1387
|
+
* }
|
|
1388
|
+
* ```
|
|
1389
|
+
*/
|
|
1278
1390
|
query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
|
|
1279
1391
|
/**
|
|
1280
|
-
|
|
1281
|
-
|
|
1392
|
+
* Map raw database fields to entity fields. (handles column name differences)
|
|
1393
|
+
*/
|
|
1282
1394
|
protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
|
|
1283
1395
|
/**
|
|
1284
|
-
|
|
1285
|
-
|
|
1396
|
+
* Get a Drizzle column from the table by his name.
|
|
1397
|
+
*/
|
|
1286
1398
|
protected col(name: keyof StaticEncode<T>): PgColumn;
|
|
1287
1399
|
/**
|
|
1288
|
-
|
|
1289
|
-
|
|
1400
|
+
* Run a transaction.
|
|
1401
|
+
*/
|
|
1290
1402
|
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
1291
1403
|
/**
|
|
1292
|
-
|
|
1293
|
-
|
|
1404
|
+
* Start a SELECT query on the table.
|
|
1405
|
+
*/
|
|
1294
1406
|
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, {
|
|
1295
1407
|
[x: string]: unknown;
|
|
1296
1408
|
}[], {
|
|
1297
1409
|
[x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
1298
1410
|
}>;
|
|
1299
1411
|
/**
|
|
1300
|
-
|
|
1301
|
-
|
|
1412
|
+
* Start a SELECT DISTINCT query on the table.
|
|
1413
|
+
*/
|
|
1302
1414
|
protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
|
|
1303
1415
|
[x: string]: any;
|
|
1304
1416
|
}[], {
|
|
1305
1417
|
[x: string]: any;
|
|
1306
1418
|
}>;
|
|
1307
1419
|
/**
|
|
1308
|
-
|
|
1309
|
-
|
|
1420
|
+
* Start an INSERT query on the table.
|
|
1421
|
+
*/
|
|
1310
1422
|
protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
|
|
1311
1423
|
/**
|
|
1312
|
-
|
|
1313
|
-
|
|
1424
|
+
* Start an UPDATE query on the table.
|
|
1425
|
+
*/
|
|
1314
1426
|
protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
|
|
1315
1427
|
/**
|
|
1316
|
-
|
|
1317
|
-
|
|
1428
|
+
* Start a DELETE query on the table.
|
|
1429
|
+
*/
|
|
1318
1430
|
protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
|
|
1319
1431
|
/**
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1432
|
+
* Create a Drizzle `select` query based on a JSON query object.
|
|
1433
|
+
*
|
|
1434
|
+
* > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
|
|
1435
|
+
*/
|
|
1324
1436
|
findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
|
|
1325
1437
|
/**
|
|
1326
|
-
|
|
1327
|
-
|
|
1438
|
+
* Find a single entity.
|
|
1439
|
+
*/
|
|
1328
1440
|
findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
|
|
1329
1441
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1442
|
+
* Find entities with pagination.
|
|
1443
|
+
*
|
|
1444
|
+
* It uses the same parameters as `find()`, but adds pagination metadata to the response.
|
|
1445
|
+
*
|
|
1446
|
+
* > Pagination CAN also do a count query to get the total number of elements.
|
|
1447
|
+
*/
|
|
1336
1448
|
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery$1, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
1337
1449
|
count?: boolean;
|
|
1338
1450
|
}): Promise<Page$1<PgStatic<T, R>>>;
|
|
1339
1451
|
/**
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1452
|
+
* Find an entity by ID.
|
|
1453
|
+
*
|
|
1454
|
+
* This is a convenience method for `findOne` with a where clause on the primary key.
|
|
1455
|
+
* If you need more complex queries, use `findOne` instead.
|
|
1456
|
+
*/
|
|
1345
1457
|
findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
|
|
1346
1458
|
/**
|
|
1347
|
-
|
|
1348
|
-
|
|
1459
|
+
* Helper to create a type-safe query object.
|
|
1460
|
+
*/
|
|
1349
1461
|
createQuery(): PgQuery<T>;
|
|
1350
1462
|
/**
|
|
1351
|
-
|
|
1352
|
-
|
|
1463
|
+
* Helper to create a type-safe where clause.
|
|
1464
|
+
*/
|
|
1353
1465
|
createQueryWhere(): PgQueryWhere<T>;
|
|
1354
1466
|
/**
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1467
|
+
* Create an entity.
|
|
1468
|
+
*
|
|
1469
|
+
* @param data The entity to create.
|
|
1470
|
+
* @param opts The options for creating the entity.
|
|
1471
|
+
* @returns The ID of the created entity.
|
|
1472
|
+
*/
|
|
1361
1473
|
create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1362
1474
|
/**
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1475
|
+
* Create many entities.
|
|
1476
|
+
*
|
|
1477
|
+
* Inserts are batched in chunks of 1000 to avoid hitting database limits.
|
|
1478
|
+
*
|
|
1479
|
+
* @param values The entities to create.
|
|
1480
|
+
* @param opts The statement options.
|
|
1481
|
+
* @returns The created entities.
|
|
1482
|
+
*/
|
|
1371
1483
|
createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions & {
|
|
1372
1484
|
batchSize?: number;
|
|
1373
1485
|
}): Promise<Static<T>[]>;
|
|
1374
1486
|
/**
|
|
1375
|
-
|
|
1376
|
-
|
|
1487
|
+
* Find an entity and update it.
|
|
1488
|
+
*/
|
|
1377
1489
|
updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1378
1490
|
/**
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1491
|
+
* Save a given entity.
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```ts
|
|
1495
|
+
* const entity = await repository.findById(1);
|
|
1496
|
+
* entity.name = "New Name"; // update a field
|
|
1497
|
+
* delete entity.description; // delete a field
|
|
1498
|
+
* await repository.save(entity);
|
|
1499
|
+
* ```
|
|
1500
|
+
*
|
|
1501
|
+
* Difference with `updateById/updateOne`:
|
|
1502
|
+
*
|
|
1503
|
+
* - requires the entity to be fetched first (whole object is expected)
|
|
1504
|
+
* - check pg.version() if present -> optimistic locking
|
|
1505
|
+
* - validate entity against schema
|
|
1506
|
+
* - undefined values will be set to null, not ignored!
|
|
1507
|
+
*
|
|
1508
|
+
* @see {@link DbVersionMismatchError}
|
|
1509
|
+
*/
|
|
1398
1510
|
save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
|
|
1399
1511
|
/**
|
|
1400
|
-
|
|
1401
|
-
|
|
1512
|
+
* Find an entity by ID and update it.
|
|
1513
|
+
*/
|
|
1402
1514
|
updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
1403
1515
|
/**
|
|
1404
|
-
|
|
1405
|
-
|
|
1516
|
+
* Find many entities and update all of them.
|
|
1517
|
+
*/
|
|
1406
1518
|
updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1407
1519
|
/**
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1520
|
+
* Find many and delete all of them.
|
|
1521
|
+
* @returns Array of deleted entity IDs
|
|
1522
|
+
*/
|
|
1411
1523
|
deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1412
1524
|
/**
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1525
|
+
* Delete all entities.
|
|
1526
|
+
* @returns Array of deleted entity IDs
|
|
1527
|
+
*/
|
|
1416
1528
|
clear(opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1417
1529
|
/**
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1530
|
+
* Delete the given entity.
|
|
1531
|
+
*
|
|
1532
|
+
* You must fetch the entity first in order to delete it.
|
|
1533
|
+
* @returns Array containing the deleted entity ID
|
|
1534
|
+
*/
|
|
1423
1535
|
destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1424
1536
|
/**
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1537
|
+
* Find an entity and delete it.
|
|
1538
|
+
* @returns Array of deleted entity IDs (should contain at most one ID)
|
|
1539
|
+
*/
|
|
1428
1540
|
deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1429
1541
|
/**
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1542
|
+
* Find an entity by ID and delete it.
|
|
1543
|
+
* @returns Array containing the deleted entity ID
|
|
1544
|
+
* @throws DbEntityNotFoundError if the entity is not found
|
|
1545
|
+
*/
|
|
1434
1546
|
deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
1435
1547
|
/**
|
|
1436
|
-
|
|
1437
|
-
|
|
1548
|
+
* Count entities.
|
|
1549
|
+
*/
|
|
1438
1550
|
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
1439
1551
|
protected conflictMessagePattern: string;
|
|
1440
1552
|
protected handleError(error: unknown, message: string): DbError;
|
|
@@ -1443,31 +1555,31 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1443
1555
|
}): PgQueryWhereOrSQL<T>;
|
|
1444
1556
|
protected deletedAt(): PgAttrField | undefined;
|
|
1445
1557
|
/**
|
|
1446
|
-
|
|
1447
|
-
|
|
1558
|
+
* Convert something to valid Pg Insert Value.
|
|
1559
|
+
*/
|
|
1448
1560
|
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
|
|
1449
1561
|
/**
|
|
1450
|
-
|
|
1451
|
-
|
|
1562
|
+
* Transform a row from the database into a clean entity.
|
|
1563
|
+
*/
|
|
1452
1564
|
protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
|
|
1453
1565
|
/**
|
|
1454
|
-
|
|
1455
|
-
|
|
1566
|
+
* Clean a row with joins recursively
|
|
1567
|
+
*/
|
|
1456
1568
|
protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
|
|
1457
1569
|
/**
|
|
1458
|
-
|
|
1459
|
-
|
|
1570
|
+
* Convert a where clause to SQL.
|
|
1571
|
+
*/
|
|
1460
1572
|
protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
|
|
1461
1573
|
/**
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1574
|
+
* Get the where clause for an ID.
|
|
1575
|
+
*
|
|
1576
|
+
* @param id The ID to get the where clause for.
|
|
1577
|
+
* @returns The where clause for the ID.
|
|
1578
|
+
*/
|
|
1467
1579
|
protected getWhereId(id: string | number): PgQueryWhere<T>;
|
|
1468
1580
|
/**
|
|
1469
|
-
|
|
1470
|
-
|
|
1581
|
+
* Find a primary key in the schema.
|
|
1582
|
+
*/
|
|
1471
1583
|
protected getPrimaryKey(schema: TObject): {
|
|
1472
1584
|
key: string;
|
|
1473
1585
|
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
@@ -1479,23 +1591,23 @@ declare abstract class Repository<T extends TObject> {
|
|
|
1479
1591
|
*/
|
|
1480
1592
|
interface StatementOptions {
|
|
1481
1593
|
/**
|
|
1482
|
-
|
|
1483
|
-
|
|
1594
|
+
* Transaction to use.
|
|
1595
|
+
*/
|
|
1484
1596
|
tx?: PgTransaction<any, Record<string, any>>;
|
|
1485
1597
|
/**
|
|
1486
|
-
|
|
1487
|
-
|
|
1598
|
+
* Lock strength.
|
|
1599
|
+
*/
|
|
1488
1600
|
for?: LockStrength | {
|
|
1489
1601
|
config: LockConfig;
|
|
1490
1602
|
strength: LockStrength;
|
|
1491
1603
|
};
|
|
1492
1604
|
/**
|
|
1493
|
-
|
|
1494
|
-
|
|
1605
|
+
* If true, ignore soft delete.
|
|
1606
|
+
*/
|
|
1495
1607
|
force?: boolean;
|
|
1496
1608
|
/**
|
|
1497
|
-
|
|
1498
|
-
|
|
1609
|
+
* Force the current time.
|
|
1610
|
+
*/
|
|
1499
1611
|
now?: DateTime | string;
|
|
1500
1612
|
}
|
|
1501
1613
|
//#endregion
|
|
@@ -1524,320 +1636,108 @@ declare const $repository: <T extends TObject>(entity: EntityPrimitive<T>) => Re
|
|
|
1524
1636
|
declare const $transaction: <T extends any[], R>(opts: TransactionPrimitiveOptions<T, R>) => alepha_retry0.RetryPrimitiveFn<(...args: T) => Promise<R>>;
|
|
1525
1637
|
interface TransactionPrimitiveOptions<T extends any[], R> {
|
|
1526
1638
|
/**
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1639
|
+
* Transaction handler function that contains all database operations to be executed atomically.
|
|
1640
|
+
*
|
|
1641
|
+
* This function:
|
|
1642
|
+
* - Receives a transaction object as the first parameter
|
|
1643
|
+
* - Should pass the transaction to all repository operations via `{ tx }` option
|
|
1644
|
+
* - All operations within are automatically rolled back if any error occurs
|
|
1645
|
+
* - Has access to the full Alepha dependency injection container
|
|
1646
|
+
* - Will be automatically retried if a `PgVersionMismatchError` occurs
|
|
1647
|
+
*
|
|
1648
|
+
* **Transaction Guidelines**:
|
|
1649
|
+
* - Keep transactions as short as possible to minimize lock contention
|
|
1650
|
+
* - Always pass the `tx` parameter to repository operations
|
|
1651
|
+
* - Handle expected business errors gracefully
|
|
1652
|
+
* - Log important operations for debugging and audit trails
|
|
1653
|
+
* - Consider the impact of long-running transactions on performance
|
|
1654
|
+
*
|
|
1655
|
+
* **Error Handling**:
|
|
1656
|
+
* - Throwing any error will automatically roll back the transaction
|
|
1657
|
+
* - `PgVersionMismatchError` triggers automatic retry logic
|
|
1658
|
+
* - Other database errors will be propagated after rollback
|
|
1659
|
+
* - Use try-catch within the handler for business-specific error handling
|
|
1660
|
+
*
|
|
1661
|
+
* @param tx - The PostgreSQL transaction object to use for all database operations
|
|
1662
|
+
* @param ...args - Additional arguments passed to the transaction function
|
|
1663
|
+
* @returns Promise resolving to the transaction result
|
|
1664
|
+
*
|
|
1665
|
+
* @example
|
|
1666
|
+
* ```ts
|
|
1667
|
+
* handler: async (tx, orderId: string, newStatus: string) => {
|
|
1668
|
+
* // Get the current order (with transaction)
|
|
1669
|
+
* const order = await this.orders.findById(orderId, { tx });
|
|
1670
|
+
*
|
|
1671
|
+
* // Validate business rules
|
|
1672
|
+
* if (!this.isValidStatusTransition(order.status, newStatus)) {
|
|
1673
|
+
* throw new Error(`Invalid status transition: ${order.status} -> ${newStatus}`);
|
|
1674
|
+
* }
|
|
1675
|
+
*
|
|
1676
|
+
* // Update order status (with transaction)
|
|
1677
|
+
* const updatedOrder = await this.orders.updateById(
|
|
1678
|
+
* orderId,
|
|
1679
|
+
* { status: newStatus },
|
|
1680
|
+
* { tx }
|
|
1681
|
+
* );
|
|
1682
|
+
*
|
|
1683
|
+
* // Create audit log (with transaction)
|
|
1684
|
+
* await this.auditLogs.create({
|
|
1685
|
+
* id: generateUUID(),
|
|
1686
|
+
* entityId: orderId,
|
|
1687
|
+
* action: 'status_change',
|
|
1688
|
+
* oldValue: order.status,
|
|
1689
|
+
* newValue: newStatus,
|
|
1690
|
+
* timestamp: new Date().toISOString()
|
|
1691
|
+
* }, { tx });
|
|
1692
|
+
*
|
|
1693
|
+
* return updatedOrder;
|
|
1694
|
+
* }
|
|
1695
|
+
* ```
|
|
1696
|
+
*/
|
|
1585
1697
|
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
|
|
1586
1698
|
/**
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1699
|
+
* PostgreSQL transaction configuration options.
|
|
1700
|
+
*
|
|
1701
|
+
* This allows you to customize transaction behavior including:
|
|
1702
|
+
* - **Isolation Level**: Controls visibility of concurrent transaction changes
|
|
1703
|
+
* - **Access Mode**: Whether the transaction is read-only or read-write
|
|
1704
|
+
* - **Deferrable**: For serializable transactions, allows deferring to avoid conflicts
|
|
1705
|
+
*
|
|
1706
|
+
* **Isolation Levels**:
|
|
1707
|
+
* - **read_uncommitted**: Lowest isolation, allows dirty reads (rarely used)
|
|
1708
|
+
* - **read_committed**: Default level, prevents dirty reads
|
|
1709
|
+
* - **repeatable_read**: Prevents dirty and non-repeatable reads
|
|
1710
|
+
* - **serializable**: Highest isolation, full ACID compliance
|
|
1711
|
+
*
|
|
1712
|
+
* **Access Modes**:
|
|
1713
|
+
* - **read_write**: Default, allows both read and write operations
|
|
1714
|
+
* - **read_only**: Only allows read operations, can provide performance benefits
|
|
1715
|
+
*
|
|
1716
|
+
* **When to Use Different Isolation Levels**:
|
|
1717
|
+
* - **read_committed**: Most common operations, good balance of consistency and performance
|
|
1718
|
+
* - **repeatable_read**: When you need consistent reads throughout the transaction
|
|
1719
|
+
* - **serializable**: Critical financial operations, when absolute consistency is required
|
|
1720
|
+
*
|
|
1721
|
+
* @example
|
|
1722
|
+
* ```ts
|
|
1723
|
+
* config: {
|
|
1724
|
+
* isolationLevel: 'serializable', // Highest consistency for financial operations
|
|
1725
|
+
* accessMode: 'read_write'
|
|
1726
|
+
* }
|
|
1727
|
+
* ```
|
|
1728
|
+
*
|
|
1729
|
+
* @example
|
|
1730
|
+
* ```ts
|
|
1731
|
+
* config: {
|
|
1732
|
+
* isolationLevel: 'read_committed', // Default level for most operations
|
|
1733
|
+
* accessMode: 'read_only' // Performance optimization for read-only operations
|
|
1734
|
+
* }
|
|
1735
|
+
* ```
|
|
1736
|
+
*/
|
|
1625
1737
|
config?: PgTransactionConfig;
|
|
1626
1738
|
}
|
|
1627
1739
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1628
1740
|
//#endregion
|
|
1629
|
-
//#region ../../src/orm/providers/DatabaseTypeProvider.d.ts
|
|
1630
|
-
declare class DatabaseTypeProvider {
|
|
1631
|
-
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
1632
|
-
/**
|
|
1633
|
-
* Creates a primary key with an identity column.
|
|
1634
|
-
*/
|
|
1635
|
-
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1636
|
-
/**
|
|
1637
|
-
* Creates a primary key with a big identity column. (default)
|
|
1638
|
-
*/
|
|
1639
|
-
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1640
|
-
/**
|
|
1641
|
-
* Creates a primary key with a UUID column.
|
|
1642
|
-
*/
|
|
1643
|
-
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1644
|
-
/**
|
|
1645
|
-
* Creates a primary key for a given type. Supports:
|
|
1646
|
-
* - `t.integer()` -> PG INT (default)
|
|
1647
|
-
* - `t.bigint()` -> PG BIGINT
|
|
1648
|
-
* - `t.uuid()` -> PG UUID
|
|
1649
|
-
*/
|
|
1650
|
-
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1651
|
-
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
1652
|
-
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
1653
|
-
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
1654
|
-
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
1655
|
-
/**
|
|
1656
|
-
* Wrap a schema with "default" attribute.
|
|
1657
|
-
* This is used to set a default value for a column in the database.
|
|
1658
|
-
*/
|
|
1659
|
-
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
1660
|
-
/**
|
|
1661
|
-
* Creates a column 'version'.
|
|
1662
|
-
*
|
|
1663
|
-
* This is used to track the version of a row in the database.
|
|
1664
|
-
*
|
|
1665
|
-
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
1666
|
-
*
|
|
1667
|
-
* @see {@link RepositoryPrimitive#save}
|
|
1668
|
-
* @see {@link PgVersionMismatchError}
|
|
1669
|
-
*/
|
|
1670
|
-
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
1671
|
-
/**
|
|
1672
|
-
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
1673
|
-
*/
|
|
1674
|
-
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1675
|
-
/**
|
|
1676
|
-
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
1677
|
-
*/
|
|
1678
|
-
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1679
|
-
/**
|
|
1680
|
-
* Creates a column Deleted At for soft delete functionality.
|
|
1681
|
-
* This is used to mark rows as deleted without actually removing them from the database.
|
|
1682
|
-
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
1683
|
-
*/
|
|
1684
|
-
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha2.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
1685
|
-
/**
|
|
1686
|
-
* Creates a Postgres ENUM type.
|
|
1687
|
-
*
|
|
1688
|
-
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
1689
|
-
* > Using this method, you can create a real ENUM type in the database.
|
|
1690
|
-
*
|
|
1691
|
-
* @example
|
|
1692
|
-
* ```ts
|
|
1693
|
-
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
1694
|
-
* ```
|
|
1695
|
-
*/
|
|
1696
|
-
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
1697
|
-
/**
|
|
1698
|
-
* Creates a reference to another table or schema. Basically a foreign key.
|
|
1699
|
-
*/
|
|
1700
|
-
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
1701
|
-
onUpdate?: UpdateDeleteAction$1;
|
|
1702
|
-
onDelete?: UpdateDeleteAction$1;
|
|
1703
|
-
}) => PgAttr<T, PgRef>;
|
|
1704
|
-
/**
|
|
1705
|
-
* Creates a page schema for a given object schema.
|
|
1706
|
-
* It's used by {@link Repository#paginate} method.
|
|
1707
|
-
*/
|
|
1708
|
-
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
1709
|
-
}
|
|
1710
|
-
/**
|
|
1711
|
-
* Wrapper of TypeProvider (`t`) for database types.
|
|
1712
|
-
*
|
|
1713
|
-
* Use `db` for improve TypeBox schema definitions with database-specific attributes.
|
|
1714
|
-
*
|
|
1715
|
-
* @example
|
|
1716
|
-
* ```ts
|
|
1717
|
-
* import { t } from "alepha";
|
|
1718
|
-
* import { db } from "alepha/orm";
|
|
1719
|
-
*
|
|
1720
|
-
* const userSchema = t.object({
|
|
1721
|
-
* id: db.primaryKey(t.uuid()),
|
|
1722
|
-
* email: t.email(),
|
|
1723
|
-
* createdAt: db.createdAt(),
|
|
1724
|
-
* });
|
|
1725
|
-
* ```
|
|
1726
|
-
*/
|
|
1727
|
-
declare const db: DatabaseTypeProvider;
|
|
1728
|
-
/**
|
|
1729
|
-
* @deprecated Use `db` instead.
|
|
1730
|
-
*/
|
|
1731
|
-
declare const pg: DatabaseTypeProvider;
|
|
1732
|
-
//#endregion
|
|
1733
|
-
//#region ../../src/orm/services/PostgresModelBuilder.d.ts
|
|
1734
|
-
declare class PostgresModelBuilder extends ModelBuilder {
|
|
1735
|
-
protected schemas: Map<string, drizzle_orm_pg_core0.PgSchema<string>>;
|
|
1736
|
-
protected getPgSchema(name: string): any;
|
|
1737
|
-
buildTable(entity: EntityPrimitive<any>, options: {
|
|
1738
|
-
tables: Map<string, unknown>;
|
|
1739
|
-
enums: Map<string, unknown>;
|
|
1740
|
-
schema: string;
|
|
1741
|
-
}): void;
|
|
1742
|
-
buildSequence(sequence: SequencePrimitive, options: {
|
|
1743
|
-
sequences: Map<string, unknown>;
|
|
1744
|
-
schema: string;
|
|
1745
|
-
}): void;
|
|
1746
|
-
/**
|
|
1747
|
-
* Get PostgreSQL-specific config builder for the table.
|
|
1748
|
-
*/
|
|
1749
|
-
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
|
|
1750
|
-
schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
|
|
1751
|
-
mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
|
|
1752
|
-
/**
|
|
1753
|
-
* Map a string to a PG column.
|
|
1754
|
-
*
|
|
1755
|
-
* @param key The key of the field.
|
|
1756
|
-
* @param value The value of the field.
|
|
1757
|
-
*/
|
|
1758
|
-
mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
1759
|
-
name: string;
|
|
1760
|
-
dataType: "custom";
|
|
1761
|
-
columnType: "PgCustomColumn";
|
|
1762
|
-
data: Buffer<ArrayBufferLike>;
|
|
1763
|
-
driverParam: unknown;
|
|
1764
|
-
enumValues: undefined;
|
|
1765
|
-
}> | drizzle_orm_pg_core0.PgTimestampStringBuilderInitial<string> | drizzle_orm_pg_core0.PgDateStringBuilderInitial<string> | drizzle_orm_pg_core0.PgTextBuilderInitial<string, [string, ...string[]]>;
|
|
1766
|
-
}
|
|
1767
|
-
//#endregion
|
|
1768
|
-
//#region ../../src/orm/providers/drivers/BunPostgresProvider.d.ts
|
|
1769
|
-
declare module "alepha" {
|
|
1770
|
-
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
1771
|
-
}
|
|
1772
|
-
declare const envSchema$1: alepha2.TObject<{
|
|
1773
|
-
/**
|
|
1774
|
-
* Main configuration for database connection.
|
|
1775
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
1776
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
1777
|
-
* or
|
|
1778
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
1779
|
-
*/
|
|
1780
|
-
DATABASE_URL: alepha2.TOptional<alepha2.TString>;
|
|
1781
|
-
/**
|
|
1782
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1783
|
-
*/
|
|
1784
|
-
POSTGRES_SCHEMA: alepha2.TOptional<alepha2.TString>;
|
|
1785
|
-
}>;
|
|
1786
|
-
/**
|
|
1787
|
-
* Bun PostgreSQL provider using Drizzle ORM with Bun's native SQL client.
|
|
1788
|
-
*
|
|
1789
|
-
* This provider uses Bun's built-in SQL class for PostgreSQL connections,
|
|
1790
|
-
* which provides excellent performance on the Bun runtime.
|
|
1791
|
-
*
|
|
1792
|
-
* @example
|
|
1793
|
-
* ```ts
|
|
1794
|
-
* // Set DATABASE_URL environment variable
|
|
1795
|
-
* // DATABASE_URL=postgres://user:password@localhost:5432/database
|
|
1796
|
-
*
|
|
1797
|
-
* // Or configure programmatically
|
|
1798
|
-
* alepha.with({
|
|
1799
|
-
* provide: DatabaseProvider,
|
|
1800
|
-
* use: BunPostgresProvider,
|
|
1801
|
-
* });
|
|
1802
|
-
* ```
|
|
1803
|
-
*/
|
|
1804
|
-
declare class BunPostgresProvider extends DatabaseProvider {
|
|
1805
|
-
protected readonly log: alepha_logger0.Logger;
|
|
1806
|
-
protected readonly env: {
|
|
1807
|
-
DATABASE_URL?: string | undefined;
|
|
1808
|
-
POSTGRES_SCHEMA?: string | undefined;
|
|
1809
|
-
};
|
|
1810
|
-
protected readonly kit: DrizzleKitProvider;
|
|
1811
|
-
protected readonly builder: PostgresModelBuilder;
|
|
1812
|
-
protected client?: SQL$1;
|
|
1813
|
-
protected bunDb?: BunSQLDatabase;
|
|
1814
|
-
readonly dialect = "postgresql";
|
|
1815
|
-
get name(): string;
|
|
1816
|
-
/**
|
|
1817
|
-
* In testing mode, the schema name will be generated and deleted after the test.
|
|
1818
|
-
*/
|
|
1819
|
-
protected schemaForTesting: string | undefined;
|
|
1820
|
-
get url(): string;
|
|
1821
|
-
/**
|
|
1822
|
-
* Execute a SQL statement.
|
|
1823
|
-
*/
|
|
1824
|
-
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
1825
|
-
/**
|
|
1826
|
-
* Get Postgres schema used by this provider.
|
|
1827
|
-
*/
|
|
1828
|
-
get schema(): string;
|
|
1829
|
-
/**
|
|
1830
|
-
* Get the Drizzle Postgres database instance.
|
|
1831
|
-
*/
|
|
1832
|
-
get db(): PgDatabase<any>;
|
|
1833
|
-
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1834
|
-
protected readonly onStart: alepha2.HookPrimitive<"start">;
|
|
1835
|
-
protected readonly onStop: alepha2.HookPrimitive<"stop">;
|
|
1836
|
-
connect(): Promise<void>;
|
|
1837
|
-
close(): Promise<void>;
|
|
1838
|
-
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
1839
|
-
}
|
|
1840
|
-
//#endregion
|
|
1841
1741
|
//#region ../../src/orm/services/SqliteModelBuilder.d.ts
|
|
1842
1742
|
declare class SqliteModelBuilder extends ModelBuilder {
|
|
1843
1743
|
buildTable(entity: EntityPrimitive<any>, options: {
|
|
@@ -1850,8 +1750,8 @@ declare class SqliteModelBuilder extends ModelBuilder {
|
|
|
1850
1750
|
schema: string;
|
|
1851
1751
|
}): void;
|
|
1852
1752
|
/**
|
|
1853
|
-
|
|
1854
|
-
|
|
1753
|
+
* Get SQLite-specific config builder for the table.
|
|
1754
|
+
*/
|
|
1855
1755
|
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildColumns<string, any, "sqlite">) => any) | undefined;
|
|
1856
1756
|
schemaToSqliteColumns: <T extends TObject>(tableName: string, schema: T, enums: Map<string, unknown>, tables: Map<string, unknown>) => SchemaToSqliteBuilder<T>;
|
|
1857
1757
|
mapFieldToSqliteColumn: (tableName: string, fieldName: string, value: TSchema, enums: Map<string, any>) => pg$1.SQLiteIntegerBuilderInitial<string> | pg$1.SQLiteNumericBuilderInitial<string> | pg$1.SQLiteTextBuilderInitial<string, [string, ...string[]], number | undefined> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
@@ -1992,65 +1892,6 @@ declare class SqliteModelBuilder extends ModelBuilder {
|
|
|
1992
1892
|
}
|
|
1993
1893
|
type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
|
|
1994
1894
|
//#endregion
|
|
1995
|
-
//#region ../../src/orm/providers/drivers/BunSqliteProvider.d.ts
|
|
1996
|
-
/**
|
|
1997
|
-
* Configuration options for the Bun SQLite database provider.
|
|
1998
|
-
*/
|
|
1999
|
-
declare const bunSqliteOptions: alepha2.Atom<alepha2.TObject<{
|
|
2000
|
-
path: alepha2.TOptional<alepha2.TString>;
|
|
2001
|
-
}>, "alepha.postgres.bun-sqlite.options">;
|
|
2002
|
-
type BunSqliteProviderOptions = Static<typeof bunSqliteOptions.schema>;
|
|
2003
|
-
declare module "alepha" {
|
|
2004
|
-
interface State {
|
|
2005
|
-
[bunSqliteOptions.key]: BunSqliteProviderOptions;
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Bun SQLite provider using Drizzle ORM with Bun's native SQLite client.
|
|
2010
|
-
*
|
|
2011
|
-
* This provider uses Bun's built-in `bun:sqlite` for SQLite connections,
|
|
2012
|
-
* which provides excellent performance on the Bun runtime.
|
|
2013
|
-
*
|
|
2014
|
-
* @example
|
|
2015
|
-
* ```ts
|
|
2016
|
-
* // Set DATABASE_URL environment variable
|
|
2017
|
-
* // DATABASE_URL=sqlite://./my-database.db
|
|
2018
|
-
*
|
|
2019
|
-
* // Or configure programmatically
|
|
2020
|
-
* alepha.with({
|
|
2021
|
-
* provide: DatabaseProvider,
|
|
2022
|
-
* use: BunSqliteProvider,
|
|
2023
|
-
* });
|
|
2024
|
-
*
|
|
2025
|
-
* // Or use options atom
|
|
2026
|
-
* alepha.store.mut(bunSqliteOptions, (old) => ({
|
|
2027
|
-
* ...old,
|
|
2028
|
-
* path: ":memory:",
|
|
2029
|
-
* }));
|
|
2030
|
-
* ```
|
|
2031
|
-
*/
|
|
2032
|
-
declare class BunSqliteProvider extends DatabaseProvider {
|
|
2033
|
-
protected readonly kit: DrizzleKitProvider;
|
|
2034
|
-
protected readonly log: alepha_logger0.Logger;
|
|
2035
|
-
protected readonly env: {
|
|
2036
|
-
DATABASE_URL?: string | undefined;
|
|
2037
|
-
};
|
|
2038
|
-
protected readonly builder: SqliteModelBuilder;
|
|
2039
|
-
protected readonly options: Readonly<{
|
|
2040
|
-
path?: string | undefined;
|
|
2041
|
-
}>;
|
|
2042
|
-
protected sqlite?: Database;
|
|
2043
|
-
protected bunDb?: BunSQLiteDatabase;
|
|
2044
|
-
get name(): string;
|
|
2045
|
-
readonly dialect = "sqlite";
|
|
2046
|
-
get url(): string;
|
|
2047
|
-
get db(): PgDatabase<any>;
|
|
2048
|
-
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2049
|
-
protected readonly onStart: alepha2.HookPrimitive<"start">;
|
|
2050
|
-
protected readonly onStop: alepha2.HookPrimitive<"stop">;
|
|
2051
|
-
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2052
|
-
}
|
|
2053
|
-
//#endregion
|
|
2054
1895
|
//#region ../../src/orm/providers/drivers/CloudflareD1Provider.d.ts
|
|
2055
1896
|
/**
|
|
2056
1897
|
* D1Database interface matching Cloudflare's D1 API.
|
|
@@ -2097,7 +1938,7 @@ interface D1ExecResult {
|
|
|
2097
1938
|
*/
|
|
2098
1939
|
declare class CloudflareD1Provider extends DatabaseProvider {
|
|
2099
1940
|
protected readonly kit: DrizzleKitProvider;
|
|
2100
|
-
protected readonly log:
|
|
1941
|
+
protected readonly log: alepha_logger3.Logger;
|
|
2101
1942
|
protected readonly builder: SqliteModelBuilder;
|
|
2102
1943
|
protected readonly env: {
|
|
2103
1944
|
DATABASE_URL: string;
|
|
@@ -2105,47 +1946,237 @@ declare class CloudflareD1Provider extends DatabaseProvider {
|
|
|
2105
1946
|
protected d1?: D1Database;
|
|
2106
1947
|
protected drizzleDb?: DrizzleD1Database;
|
|
2107
1948
|
get name(): string;
|
|
1949
|
+
get driver(): string;
|
|
2108
1950
|
readonly dialect = "sqlite";
|
|
2109
1951
|
get url(): string;
|
|
2110
1952
|
get db(): PgDatabase<any>;
|
|
2111
1953
|
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2112
|
-
protected readonly onStart:
|
|
1954
|
+
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2113
1955
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2114
1956
|
/**
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
1957
|
+
* Override development migration to skip sync (not supported on D1).
|
|
1958
|
+
* D1 requires proper migrations to be applied.
|
|
1959
|
+
*/
|
|
2118
1960
|
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
2119
1961
|
/**
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
1962
|
+
* Override test migration to run migrations instead of sync.
|
|
1963
|
+
* D1 doesn't support schema synchronization.
|
|
1964
|
+
*/
|
|
2123
1965
|
protected runTestMigration(): Promise<void>;
|
|
2124
1966
|
}
|
|
2125
1967
|
//#endregion
|
|
1968
|
+
//#region ../../src/orm/providers/RepositoryProvider.d.ts
|
|
1969
|
+
declare class RepositoryProvider {
|
|
1970
|
+
protected readonly alepha: Alepha;
|
|
1971
|
+
protected readonly registry: Map<EntityPrimitive<any>, Service<Repository<any>>>;
|
|
1972
|
+
getRepositories(provider?: DatabaseProvider): Repository<TObject<alepha34.TProperties>>[];
|
|
1973
|
+
getRepository<T extends TObject>(entity: EntityPrimitive<T>): Repository<T>;
|
|
1974
|
+
createClassRepository<T extends TObject>(entity: EntityPrimitive<T>): Service<Repository<T>>;
|
|
1975
|
+
}
|
|
1976
|
+
//#endregion
|
|
1977
|
+
//#region ../../src/orm/types/schema.d.ts
|
|
1978
|
+
/**
|
|
1979
|
+
* Postgres schema type.
|
|
1980
|
+
*/
|
|
1981
|
+
declare const schema: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
1982
|
+
name: string;
|
|
1983
|
+
dataType: "custom";
|
|
1984
|
+
columnType: "PgCustomColumn";
|
|
1985
|
+
data: typebox1.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
1986
|
+
driverParam: string;
|
|
1987
|
+
enumValues: undefined;
|
|
1988
|
+
}>, typebox1.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
1989
|
+
//#endregion
|
|
1990
|
+
//#region ../../src/orm/services/PostgresModelBuilder.d.ts
|
|
1991
|
+
declare class PostgresModelBuilder extends ModelBuilder {
|
|
1992
|
+
protected schemas: Map<string, drizzle_orm_pg_core0.PgSchema<string>>;
|
|
1993
|
+
protected getPgSchema(name: string): any;
|
|
1994
|
+
buildTable(entity: EntityPrimitive<any>, options: {
|
|
1995
|
+
tables: Map<string, unknown>;
|
|
1996
|
+
enums: Map<string, unknown>;
|
|
1997
|
+
schema: string;
|
|
1998
|
+
}): void;
|
|
1999
|
+
buildSequence(sequence: SequencePrimitive, options: {
|
|
2000
|
+
sequences: Map<string, unknown>;
|
|
2001
|
+
schema: string;
|
|
2002
|
+
}): void;
|
|
2003
|
+
/**
|
|
2004
|
+
* Get PostgreSQL-specific config builder for the table.
|
|
2005
|
+
*/
|
|
2006
|
+
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
|
|
2007
|
+
schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
|
|
2008
|
+
mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
|
|
2009
|
+
/**
|
|
2010
|
+
* Map a string to a PG column.
|
|
2011
|
+
*
|
|
2012
|
+
* @param key The key of the field.
|
|
2013
|
+
* @param value The value of the field.
|
|
2014
|
+
*/
|
|
2015
|
+
mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
2016
|
+
name: string;
|
|
2017
|
+
dataType: "custom";
|
|
2018
|
+
columnType: "PgCustomColumn";
|
|
2019
|
+
data: Buffer<ArrayBufferLike>;
|
|
2020
|
+
driverParam: unknown;
|
|
2021
|
+
enumValues: undefined;
|
|
2022
|
+
}> | drizzle_orm_pg_core0.PgTimestampStringBuilderInitial<string> | drizzle_orm_pg_core0.PgDateStringBuilderInitial<string> | drizzle_orm_pg_core0.PgTextBuilderInitial<string, [string, ...string[]]>;
|
|
2023
|
+
}
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region ../../src/orm/providers/drivers/BunPostgresProvider.d.ts
|
|
2026
|
+
declare module "alepha" {
|
|
2027
|
+
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
2028
|
+
}
|
|
2029
|
+
declare const envSchema$1: alepha34.TObject<{
|
|
2030
|
+
/**
|
|
2031
|
+
* Main configuration for database connection.
|
|
2032
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2033
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2034
|
+
* or
|
|
2035
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2036
|
+
*/
|
|
2037
|
+
DATABASE_URL: alepha34.TOptional<alepha34.TString>;
|
|
2038
|
+
/**
|
|
2039
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2040
|
+
*/
|
|
2041
|
+
POSTGRES_SCHEMA: alepha34.TOptional<alepha34.TString>;
|
|
2042
|
+
}>;
|
|
2043
|
+
/**
|
|
2044
|
+
* Bun PostgreSQL provider using Drizzle ORM with Bun's native SQL client.
|
|
2045
|
+
*
|
|
2046
|
+
* This provider uses Bun's built-in SQL class for PostgreSQL connections,
|
|
2047
|
+
* which provides excellent performance on the Bun runtime.
|
|
2048
|
+
*
|
|
2049
|
+
* @example
|
|
2050
|
+
* ```ts
|
|
2051
|
+
* // Set DATABASE_URL environment variable
|
|
2052
|
+
* // DATABASE_URL=postgres://user:password@localhost:5432/database
|
|
2053
|
+
*
|
|
2054
|
+
* // Or configure programmatically
|
|
2055
|
+
* alepha.with({
|
|
2056
|
+
* provide: DatabaseProvider,
|
|
2057
|
+
* use: BunPostgresProvider,
|
|
2058
|
+
* });
|
|
2059
|
+
* ```
|
|
2060
|
+
*/
|
|
2061
|
+
declare class BunPostgresProvider extends DatabaseProvider {
|
|
2062
|
+
protected readonly log: alepha_logger3.Logger;
|
|
2063
|
+
protected readonly env: {
|
|
2064
|
+
DATABASE_URL?: string | undefined;
|
|
2065
|
+
POSTGRES_SCHEMA?: string | undefined;
|
|
2066
|
+
};
|
|
2067
|
+
protected readonly kit: DrizzleKitProvider;
|
|
2068
|
+
protected readonly builder: PostgresModelBuilder;
|
|
2069
|
+
protected client?: Bun.SQL;
|
|
2070
|
+
protected bunDb?: BunSQLDatabase;
|
|
2071
|
+
readonly dialect = "postgresql";
|
|
2072
|
+
get name(): string;
|
|
2073
|
+
/**
|
|
2074
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2075
|
+
*/
|
|
2076
|
+
protected schemaForTesting: string | undefined;
|
|
2077
|
+
get url(): string;
|
|
2078
|
+
/**
|
|
2079
|
+
* Execute a SQL statement.
|
|
2080
|
+
*/
|
|
2081
|
+
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Get Postgres schema used by this provider.
|
|
2084
|
+
*/
|
|
2085
|
+
get schema(): string;
|
|
2086
|
+
/**
|
|
2087
|
+
* Get the Drizzle Postgres database instance.
|
|
2088
|
+
*/
|
|
2089
|
+
get db(): PgDatabase<any>;
|
|
2090
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2091
|
+
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2092
|
+
protected readonly onStop: alepha34.HookPrimitive<"stop">;
|
|
2093
|
+
connect(): Promise<void>;
|
|
2094
|
+
close(): Promise<void>;
|
|
2095
|
+
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
2096
|
+
}
|
|
2097
|
+
//#endregion
|
|
2098
|
+
//#region ../../src/orm/providers/drivers/BunSqliteProvider.d.ts
|
|
2099
|
+
/**
|
|
2100
|
+
* Configuration options for the Bun SQLite database provider.
|
|
2101
|
+
*/
|
|
2102
|
+
declare const bunSqliteOptions: alepha34.Atom<alepha34.TObject<{
|
|
2103
|
+
path: alepha34.TOptional<alepha34.TString>;
|
|
2104
|
+
}>, "alepha.postgres.bun-sqlite.options">;
|
|
2105
|
+
type BunSqliteProviderOptions = Static<typeof bunSqliteOptions.schema>;
|
|
2106
|
+
declare module "alepha" {
|
|
2107
|
+
interface State {
|
|
2108
|
+
[bunSqliteOptions.key]: BunSqliteProviderOptions;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Bun SQLite provider using Drizzle ORM with Bun's native SQLite client.
|
|
2113
|
+
*
|
|
2114
|
+
* This provider uses Bun's built-in `bun:sqlite` for SQLite connections,
|
|
2115
|
+
* which provides excellent performance on the Bun runtime.
|
|
2116
|
+
*
|
|
2117
|
+
* @example
|
|
2118
|
+
* ```ts
|
|
2119
|
+
* // Set DATABASE_URL environment variable
|
|
2120
|
+
* // DATABASE_URL=sqlite://./my-database.db
|
|
2121
|
+
*
|
|
2122
|
+
* // Or configure programmatically
|
|
2123
|
+
* alepha.with({
|
|
2124
|
+
* provide: DatabaseProvider,
|
|
2125
|
+
* use: BunSqliteProvider,
|
|
2126
|
+
* });
|
|
2127
|
+
*
|
|
2128
|
+
* // Or use options atom
|
|
2129
|
+
* alepha.store.mut(bunSqliteOptions, (old) => ({
|
|
2130
|
+
* ...old,
|
|
2131
|
+
* path: ":memory:",
|
|
2132
|
+
* }));
|
|
2133
|
+
* ```
|
|
2134
|
+
*/
|
|
2135
|
+
declare class BunSqliteProvider extends DatabaseProvider {
|
|
2136
|
+
protected readonly kit: DrizzleKitProvider;
|
|
2137
|
+
protected readonly log: alepha_logger3.Logger;
|
|
2138
|
+
protected readonly env: {
|
|
2139
|
+
DATABASE_URL?: string | undefined;
|
|
2140
|
+
};
|
|
2141
|
+
protected readonly builder: SqliteModelBuilder;
|
|
2142
|
+
protected readonly options: Readonly<{
|
|
2143
|
+
path?: string | undefined;
|
|
2144
|
+
}>;
|
|
2145
|
+
protected sqlite?: Database;
|
|
2146
|
+
protected bunDb?: BunSQLiteDatabase;
|
|
2147
|
+
get name(): string;
|
|
2148
|
+
readonly dialect = "sqlite";
|
|
2149
|
+
get url(): string;
|
|
2150
|
+
get db(): PgDatabase<any>;
|
|
2151
|
+
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2152
|
+
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2153
|
+
protected readonly onStop: alepha34.HookPrimitive<"stop">;
|
|
2154
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2155
|
+
}
|
|
2156
|
+
//#endregion
|
|
2126
2157
|
//#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
2127
2158
|
declare module "alepha" {
|
|
2128
2159
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
2129
2160
|
}
|
|
2130
|
-
declare const envSchema:
|
|
2131
|
-
/**
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
DATABASE_URL:
|
|
2139
|
-
/**
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
POSTGRES_SCHEMA:
|
|
2161
|
+
declare const envSchema: alepha34.TObject<{
|
|
2162
|
+
/**
|
|
2163
|
+
* Main configuration for database connection.
|
|
2164
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
2165
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
2166
|
+
* or
|
|
2167
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2168
|
+
*/
|
|
2169
|
+
DATABASE_URL: alepha34.TOptional<alepha34.TString>;
|
|
2170
|
+
/**
|
|
2171
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2172
|
+
*
|
|
2173
|
+
* It will monkey patch drizzle tables.
|
|
2174
|
+
*/
|
|
2175
|
+
POSTGRES_SCHEMA: alepha34.TOptional<alepha34.TString>;
|
|
2145
2176
|
}>;
|
|
2146
2177
|
declare class NodePostgresProvider extends DatabaseProvider {
|
|
2147
2178
|
static readonly SSL_MODES: readonly ["require", "allow", "prefer", "verify-full"];
|
|
2148
|
-
protected readonly log:
|
|
2179
|
+
protected readonly log: alepha_logger3.Logger;
|
|
2149
2180
|
protected readonly env: {
|
|
2150
2181
|
DATABASE_URL?: string | undefined;
|
|
2151
2182
|
POSTGRES_SCHEMA?: string | undefined;
|
|
@@ -2157,31 +2188,31 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2157
2188
|
readonly dialect = "postgresql";
|
|
2158
2189
|
get name(): string;
|
|
2159
2190
|
/**
|
|
2160
|
-
|
|
2161
|
-
|
|
2191
|
+
* In testing mode, the schema name will be generated and deleted after the test.
|
|
2192
|
+
*/
|
|
2162
2193
|
protected schemaForTesting: string | undefined;
|
|
2163
2194
|
get url(): string;
|
|
2164
2195
|
/**
|
|
2165
|
-
|
|
2166
|
-
|
|
2196
|
+
* Execute a SQL statement.
|
|
2197
|
+
*/
|
|
2167
2198
|
execute(statement: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2168
2199
|
/**
|
|
2169
|
-
|
|
2170
|
-
|
|
2200
|
+
* Get Postgres schema used by this provider.
|
|
2201
|
+
*/
|
|
2171
2202
|
get schema(): string;
|
|
2172
2203
|
/**
|
|
2173
|
-
|
|
2174
|
-
|
|
2204
|
+
* Get the Drizzle Postgres database instance.
|
|
2205
|
+
*/
|
|
2175
2206
|
get db(): PostgresJsDatabase;
|
|
2176
2207
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2177
|
-
protected readonly onStart:
|
|
2178
|
-
protected readonly onStop:
|
|
2208
|
+
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2209
|
+
protected readonly onStop: alepha34.HookPrimitive<"stop">;
|
|
2179
2210
|
connect(): Promise<void>;
|
|
2180
2211
|
close(): Promise<void>;
|
|
2181
2212
|
protected migrateLock: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
2182
2213
|
/**
|
|
2183
|
-
|
|
2184
|
-
|
|
2214
|
+
* Map the DATABASE_URL to postgres client options.
|
|
2215
|
+
*/
|
|
2185
2216
|
protected getClientOptions(): postgres.Options<any>;
|
|
2186
2217
|
protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
|
|
2187
2218
|
}
|
|
@@ -2190,8 +2221,8 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2190
2221
|
/**
|
|
2191
2222
|
* Configuration options for the Node.js SQLite database provider.
|
|
2192
2223
|
*/
|
|
2193
|
-
declare const nodeSqliteOptions:
|
|
2194
|
-
path:
|
|
2224
|
+
declare const nodeSqliteOptions: alepha34.Atom<alepha34.TObject<{
|
|
2225
|
+
path: alepha34.TOptional<alepha34.TString>;
|
|
2195
2226
|
}>, "alepha.postgres.node-sqlite.options">;
|
|
2196
2227
|
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
2197
2228
|
declare module "alepha" {
|
|
@@ -2207,7 +2238,7 @@ declare module "alepha" {
|
|
|
2207
2238
|
*/
|
|
2208
2239
|
declare class NodeSqliteProvider extends DatabaseProvider {
|
|
2209
2240
|
protected readonly kit: DrizzleKitProvider;
|
|
2210
|
-
protected readonly log:
|
|
2241
|
+
protected readonly log: alepha_logger3.Logger;
|
|
2211
2242
|
protected readonly env: {
|
|
2212
2243
|
DATABASE_URL?: string | undefined;
|
|
2213
2244
|
};
|
|
@@ -2221,67 +2252,40 @@ declare class NodeSqliteProvider extends DatabaseProvider {
|
|
|
2221
2252
|
get url(): string;
|
|
2222
2253
|
execute(query: SQLLike): Promise<Array<Record<string, unknown>>>;
|
|
2223
2254
|
readonly db: PgDatabase<any>;
|
|
2224
|
-
protected readonly onStart:
|
|
2255
|
+
protected readonly onStart: alepha34.HookPrimitive<"start">;
|
|
2225
2256
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2226
2257
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
declare class RepositoryProvider {
|
|
2230
|
-
protected readonly alepha: Alepha;
|
|
2231
|
-
protected readonly registry: Map<EntityPrimitive<any>, Service<Repository<any>>>;
|
|
2232
|
-
getRepositories(provider?: DatabaseProvider): Repository<TObject<alepha2.TProperties>>[];
|
|
2233
|
-
getRepository<T extends TObject>(entity: EntityPrimitive<T>): Repository<T>;
|
|
2234
|
-
createClassRepository<T extends TObject>(entity: EntityPrimitive<T>): Service<Repository<T>>;
|
|
2258
|
+
declare namespace index_d_exports {
|
|
2259
|
+
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, BunPostgresProvider, BunSqliteProvider, BunSqliteProviderOptions, CloudflareD1Provider, D1Database, D1ExecResult, D1PreparedStatement, D1Result, DatabaseProvider, DatabaseTypeProvider, DbConflictError, DbEntityNotFoundError, DbError, DbMigrationError, DbVersionMismatchError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityPrimitive, EntityPrimitiveOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, Page, PageQuery, PgAttr, PgAttrField, PgDefault, PgEnumOptions, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequencePrimitive, SequencePrimitiveOptions, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionPrimitiveOptions, buildQueryString, bunSqliteOptions, db, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
|
|
2235
2260
|
}
|
|
2236
|
-
//#endregion
|
|
2237
|
-
//#region ../../src/orm/schemas/legacyIdSchema.d.ts
|
|
2238
|
-
/**
|
|
2239
|
-
* @deprecated Use `pg.primaryKey()` instead.
|
|
2240
|
-
*/
|
|
2241
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<alepha2.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
2242
|
-
//#endregion
|
|
2243
|
-
//#region ../../src/orm/types/schema.d.ts
|
|
2244
|
-
/**
|
|
2245
|
-
* Postgres schema type.
|
|
2246
|
-
*/
|
|
2247
|
-
declare const schema: <TDocument extends TSchema>(name: string, document: TDocument) => drizzle_orm0.$Type<drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
2248
|
-
name: string;
|
|
2249
|
-
dataType: "custom";
|
|
2250
|
-
columnType: "PgCustomColumn";
|
|
2251
|
-
data: typebox1.StaticType<[], "Decode", {}, {}, TDocument>;
|
|
2252
|
-
driverParam: string;
|
|
2253
|
-
enumValues: undefined;
|
|
2254
|
-
}>, typebox1.StaticType<[], "Decode", {}, {}, TDocument>>;
|
|
2255
|
-
//#endregion
|
|
2256
|
-
//#region ../../src/orm/index.d.ts
|
|
2257
2261
|
declare module "alepha" {
|
|
2258
2262
|
interface Hooks {
|
|
2259
2263
|
/**
|
|
2260
|
-
|
|
2261
|
-
|
|
2264
|
+
* Fires before creating an entity in the repository.
|
|
2265
|
+
*/
|
|
2262
2266
|
"repository:create:before": {
|
|
2263
2267
|
tableName: string;
|
|
2264
2268
|
data: any;
|
|
2265
2269
|
};
|
|
2266
2270
|
/**
|
|
2267
|
-
|
|
2268
|
-
|
|
2271
|
+
* Fires after creating an entity in the repository.
|
|
2272
|
+
*/
|
|
2269
2273
|
"repository:create:after": {
|
|
2270
2274
|
tableName: string;
|
|
2271
2275
|
data: any;
|
|
2272
2276
|
entity: any;
|
|
2273
2277
|
};
|
|
2274
2278
|
/**
|
|
2275
|
-
|
|
2276
|
-
|
|
2279
|
+
* Fires before updating entities in the repository.
|
|
2280
|
+
*/
|
|
2277
2281
|
"repository:update:before": {
|
|
2278
2282
|
tableName: string;
|
|
2279
2283
|
where: any;
|
|
2280
2284
|
data: any;
|
|
2281
2285
|
};
|
|
2282
2286
|
/**
|
|
2283
|
-
|
|
2284
|
-
|
|
2287
|
+
* Fires after updating entities in the repository.
|
|
2288
|
+
*/
|
|
2285
2289
|
"repository:update:after": {
|
|
2286
2290
|
tableName: string;
|
|
2287
2291
|
where: any;
|
|
@@ -2289,30 +2293,30 @@ declare module "alepha" {
|
|
|
2289
2293
|
entities: any[];
|
|
2290
2294
|
};
|
|
2291
2295
|
/**
|
|
2292
|
-
|
|
2293
|
-
|
|
2296
|
+
* Fires before deleting entities from the repository.
|
|
2297
|
+
*/
|
|
2294
2298
|
"repository:delete:before": {
|
|
2295
2299
|
tableName: string;
|
|
2296
2300
|
where: any;
|
|
2297
2301
|
};
|
|
2298
2302
|
/**
|
|
2299
|
-
|
|
2300
|
-
|
|
2303
|
+
* Fires after deleting entities from the repository.
|
|
2304
|
+
*/
|
|
2301
2305
|
"repository:delete:after": {
|
|
2302
2306
|
tableName: string;
|
|
2303
2307
|
where: any;
|
|
2304
2308
|
ids: Array<string | number>;
|
|
2305
2309
|
};
|
|
2306
2310
|
/**
|
|
2307
|
-
|
|
2308
|
-
|
|
2311
|
+
* Fires before reading entities from the repository.
|
|
2312
|
+
*/
|
|
2309
2313
|
"repository:read:before": {
|
|
2310
2314
|
tableName: string;
|
|
2311
2315
|
query: any;
|
|
2312
2316
|
};
|
|
2313
2317
|
/**
|
|
2314
|
-
|
|
2315
|
-
|
|
2318
|
+
* Fires after reading entities from the repository.
|
|
2319
|
+
*/
|
|
2316
2320
|
"repository:read:after": {
|
|
2317
2321
|
tableName: string;
|
|
2318
2322
|
query: any;
|
|
@@ -2323,6 +2327,10 @@ declare module "alepha" {
|
|
|
2323
2327
|
/**
|
|
2324
2328
|
* Postgres client based on Drizzle ORM, Alepha type-safe friendly.
|
|
2325
2329
|
*
|
|
2330
|
+
* Automatically selects the appropriate provider based on runtime:
|
|
2331
|
+
* - Bun: Uses `BunPostgresProvider` or `BunSqliteProvider`
|
|
2332
|
+
* - Node.js: Uses `NodePostgresProvider` or `NodeSqliteProvider`
|
|
2333
|
+
*
|
|
2326
2334
|
* ```ts
|
|
2327
2335
|
* import { t } from "alepha";
|
|
2328
2336
|
* import { $entity, $repository, db } from "alepha/postgres";
|
|
@@ -2361,9 +2369,13 @@ declare module "alepha" {
|
|
|
2361
2369
|
* @see {@link $sequence}
|
|
2362
2370
|
* @see {@link $repository}
|
|
2363
2371
|
* @see {@link $transaction}
|
|
2372
|
+
* @see {@link NodePostgresProvider} - Node.js Postgres implementation
|
|
2373
|
+
* @see {@link NodeSqliteProvider} - Node.js SQLite implementation
|
|
2374
|
+
* @see {@link BunPostgresProvider} - Bun Postgres implementation
|
|
2375
|
+
* @see {@link BunSqliteProvider} - Bun SQLite implementation
|
|
2364
2376
|
* @module alepha.postgres
|
|
2365
2377
|
*/
|
|
2366
|
-
declare const AlephaPostgres:
|
|
2378
|
+
declare const AlephaPostgres: alepha34.Service<alepha34.Module>;
|
|
2367
2379
|
//#endregion
|
|
2368
2380
|
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, BunPostgresProvider, BunSqliteProvider, BunSqliteProviderOptions, CloudflareD1Provider, D1Database, D1ExecResult, D1PreparedStatement, D1Result, DatabaseProvider, DatabaseTypeProvider, DbConflictError, DbEntityNotFoundError, DbError, DbMigrationError, DbVersionMismatchError, DrizzleKitProvider, EntityColumn, EntityColumns, EntityPrimitive, EntityPrimitiveOptions, FilterOperators, FromSchema, NodePostgresProvider, NodeSqliteProvider, NodeSqliteProviderOptions, OrderBy, OrderByClause, OrderDirection, PG_CREATED_AT, PG_DEFAULT, PG_DELETED_AT, PG_ENUM, PG_IDENTITY, PG_PRIMARY_KEY, PG_REF, PG_SERIAL, PG_UPDATED_AT, PG_VERSION, type Page, type PageQuery, PgAttr, PgAttrField, PgDefault, PgEnumOptions, PgIdentityOptions, PgPrimaryKey, PgQuery, PgQueryRelations, PgQueryWhere, PgQueryWhereOrSQL, PgRef, PgRefOptions, PgRelation, PgRelationMap, PgStatic, PgSymbolKeys, PgSymbols, Repository, RepositoryProvider, SQLLike, SchemaToTableConfig, SequencePrimitive, SequencePrimitiveOptions, StatementOptions, TObjectInsert, TObjectUpdate, TransactionContext, TransactionPrimitiveOptions, buildQueryString, bunSqliteOptions, db, drizzle_orm0 as drizzle, getAttrFields, insertSchema, legacyIdSchema, nodeSqliteOptions, pageQuerySchema, pageSchema, parseQueryString, pg, pgAttr, schema, sql, updateSchema };
|
|
2369
2381
|
//# sourceMappingURL=index.d.ts.map
|