alepha 0.14.0 → 0.14.2
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 +3 -3
- package/dist/api/audits/index.d.ts +80 -1
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts +80 -1
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +236 -157
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/notifications/index.d.ts +21 -1
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +451 -4
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/users/index.d.ts +252 -249
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +4 -0
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts +128 -128
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cli/index.d.ts +304 -115
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +650 -531
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +210 -13
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +306 -69
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +7 -6
- package/dist/core/index.native.js.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/fake/index.js.map +1 -1
- package/dist/file/index.d.ts.map +1 -1
- package/dist/file/index.js.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.browser.js +26 -5
- package/dist/orm/index.browser.js.map +1 -1
- package/dist/orm/index.d.ts +294 -215
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +522 -523
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/redis/index.js +2 -4
- package/dist/queue/redis/index.js.map +1 -1
- package/dist/redis/index.d.ts +400 -29
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +412 -21
- package/dist/redis/index.js.map +1 -1
- package/dist/retry/index.js.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/scheduler/index.js.map +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +155 -155
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/cookies/index.browser.js.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +0 -1
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/helmet/index.d.ts +4 -1
- package/dist/server/helmet/index.d.ts.map +1 -1
- package/dist/server/helmet/index.js.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/multipart/index.d.ts.map +1 -1
- package/dist/server/multipart/index.js.map +1 -1
- package/dist/server/proxy/index.js.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/security/index.d.ts +9 -9
- package/dist/server/security/index.js.map +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/thread/index.js.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/topic/redis/index.js +3 -3
- package/dist/topic/redis/index.js.map +1 -1
- package/dist/vite/index.js +9 -6
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/dist/websocket/index.js.map +1 -1
- package/package.json +3 -3
- package/src/api/users/index.ts +4 -0
- package/src/cli/apps/AlephaCli.ts +36 -14
- package/src/cli/apps/AlephaPackageBuilderCli.ts +5 -1
- package/src/cli/assets/appRouterTs.ts +1 -1
- package/src/cli/atoms/changelogOptions.ts +45 -0
- package/src/cli/commands/{ViteCommands.ts → build.ts} +4 -93
- package/src/cli/commands/changelog.ts +244 -0
- package/src/cli/commands/clean.ts +14 -0
- package/src/cli/commands/{DrizzleCommands.ts → db.ts} +37 -124
- package/src/cli/commands/deploy.ts +118 -0
- package/src/cli/commands/dev.ts +57 -0
- package/src/cli/commands/format.ts +17 -0
- package/src/cli/commands/{CoreCommands.ts → init.ts} +2 -40
- package/src/cli/commands/lint.ts +17 -0
- package/src/cli/commands/root.ts +32 -0
- package/src/cli/commands/run.ts +24 -0
- package/src/cli/commands/test.ts +42 -0
- package/src/cli/commands/typecheck.ts +19 -0
- package/src/cli/commands/{VerifyCommands.ts → verify.ts} +1 -13
- package/src/cli/defineConfig.ts +24 -0
- package/src/cli/index.ts +17 -5
- package/src/cli/services/AlephaCliUtils.ts +4 -21
- package/src/cli/services/GitMessageParser.ts +77 -0
- package/src/command/helpers/EnvUtils.ts +37 -0
- package/src/command/index.ts +3 -1
- package/src/command/primitives/$command.ts +172 -6
- package/src/command/providers/CliProvider.ts +424 -91
- package/src/core/Alepha.ts +8 -5
- package/src/file/providers/NodeFileSystemProvider.ts +3 -1
- package/src/orm/index.browser.ts +1 -1
- package/src/orm/index.ts +18 -10
- package/src/orm/interfaces/PgQueryWhere.ts +1 -26
- package/src/orm/providers/{PostgresTypeProvider.ts → DatabaseTypeProvider.ts} +25 -3
- package/src/orm/providers/drivers/BunPostgresProvider.ts +225 -0
- package/src/orm/providers/drivers/BunSqliteProvider.ts +180 -0
- package/src/orm/providers/drivers/DatabaseProvider.ts +25 -0
- package/src/orm/providers/drivers/NodePostgresProvider.ts +0 -25
- package/src/orm/services/QueryManager.ts +10 -125
- package/src/queue/redis/providers/RedisQueueProvider.ts +2 -7
- package/src/redis/index.ts +65 -3
- package/src/redis/providers/BunRedisProvider.ts +304 -0
- package/src/redis/providers/BunRedisSubscriberProvider.ts +94 -0
- package/src/redis/providers/NodeRedisProvider.ts +280 -0
- package/src/redis/providers/NodeRedisSubscriberProvider.ts +94 -0
- package/src/redis/providers/RedisProvider.ts +134 -140
- package/src/redis/providers/RedisSubscriberProvider.ts +58 -49
- package/src/server/core/providers/BunHttpServerProvider.ts +0 -3
- package/src/server/core/providers/ServerBodyParserProvider.ts +3 -1
- package/src/server/core/providers/ServerProvider.ts +7 -4
- package/src/server/multipart/providers/ServerMultipartProvider.ts +3 -1
- package/src/server/proxy/providers/ServerProxyProvider.ts +1 -1
- package/src/topic/redis/providers/RedisTopicProvider.ts +3 -3
- package/src/vite/tasks/buildServer.ts +1 -0
- package/src/cli/commands/BiomeCommands.ts +0 -29
- package/src/cli/commands/ChangelogCommands.ts +0 -389
- package/src/orm/services/PgJsonQueryManager.ts +0 -511
package/dist/orm/index.d.ts
CHANGED
|
@@ -6,18 +6,22 @@ import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, sql } from "dri
|
|
|
6
6
|
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
7
7
|
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSchema, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
8
8
|
import * as alepha_logger0 from "alepha/logger";
|
|
9
|
+
import * as alepha_lock0 from "alepha/lock";
|
|
9
10
|
import * as pg$1 from "drizzle-orm/sqlite-core";
|
|
10
11
|
import { SQLiteColumnBuilderBase } from "drizzle-orm/sqlite-core";
|
|
11
|
-
import * as alepha_lock0 from "alepha/lock";
|
|
12
12
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
13
13
|
import postgres from "postgres";
|
|
14
14
|
import * as alepha_retry0 from "alepha/retry";
|
|
15
|
+
import { SQL as SQL$1 } from "bun";
|
|
16
|
+
import { Database } from "bun:sqlite";
|
|
17
|
+
import { BunSQLDatabase } from "drizzle-orm/bun-sql";
|
|
18
|
+
import { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
|
|
15
19
|
import { DrizzleD1Database } from "drizzle-orm/d1";
|
|
16
20
|
import { DatabaseSync } from "node:sqlite";
|
|
17
21
|
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
18
22
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
19
|
-
import * as typebox1 from "typebox";
|
|
20
23
|
import { UpdateDeleteAction as UpdateDeleteAction$1 } from "drizzle-orm/pg-core/foreign-keys";
|
|
24
|
+
import * as typebox1 from "typebox";
|
|
21
25
|
export * from "drizzle-orm/pg-core";
|
|
22
26
|
|
|
23
27
|
//#region ../../src/orm/schemas/insertSchema.d.ts
|
|
@@ -767,7 +771,7 @@ type PgRelation<Base extends TObject> = {
|
|
|
767
771
|
//#region ../../src/orm/interfaces/PgQueryWhere.d.ts
|
|
768
772
|
type PgQueryWhere<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = (PgQueryWhereOperators<T> & PgQueryWhereConditions<T>) | (PgQueryWhereRelations<Relations> & PgQueryWhereOperators<T> & PgQueryWhereConditions<T, Relations>);
|
|
769
773
|
type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = SQLWrapper | PgQueryWhere<T, Relations>;
|
|
770
|
-
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key]
|
|
774
|
+
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] };
|
|
771
775
|
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
772
776
|
/**
|
|
773
777
|
* Combine a list of conditions with the `and` operator. Conditions
|
|
@@ -838,10 +842,6 @@ type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<T
|
|
|
838
842
|
exists?: SQLWrapper;
|
|
839
843
|
};
|
|
840
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"]> } : {};
|
|
841
|
-
/**
|
|
842
|
-
* Recursively allow nested queries for JSONB object/array types
|
|
843
|
-
*/
|
|
844
|
-
type NestedJsonbQuery<T> = T extends object ? T extends Array<infer U> ? U extends object ? { [K in keyof U]?: FilterOperators<U[K]> | U[K] } : FilterOperators<U> | U : { [K in keyof T]?: FilterOperators<T[K]> | T[K] | (T[K] extends object ? NestedJsonbQuery<T[K]> : never) } : FilterOperators<T> | T;
|
|
845
845
|
//#endregion
|
|
846
846
|
//#region ../../src/orm/helpers/parseQueryString.d.ts
|
|
847
847
|
/**
|
|
@@ -1119,84 +1119,16 @@ declare abstract class DatabaseProvider {
|
|
|
1119
1119
|
* MUST be implemented by each provider
|
|
1120
1120
|
*/
|
|
1121
1121
|
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1122
|
-
}
|
|
1123
|
-
//#endregion
|
|
1124
|
-
//#region ../../src/orm/services/PgJsonQueryManager.d.ts
|
|
1125
|
-
/**
|
|
1126
|
-
* Manages JSONB query generation for nested object and array queries in PostgreSQL.
|
|
1127
|
-
* This class handles complex nested queries using PostgreSQL's JSONB operators.
|
|
1128
|
-
*/
|
|
1129
|
-
declare class PgJsonQueryManager {
|
|
1130
|
-
/**
|
|
1131
|
-
* Check if a query contains nested JSONB queries.
|
|
1132
|
-
* A nested query is when the value is an object with operator keys.
|
|
1133
|
-
*/
|
|
1134
|
-
hasNestedQuery(where: PgQueryWhere<TObject>): boolean;
|
|
1135
|
-
/**
|
|
1136
|
-
* Build a JSONB query condition for nested object queries.
|
|
1137
|
-
* Supports deep nesting like: { profile: { contact: { email: { eq: "test@example.com" } } } }
|
|
1138
|
-
*
|
|
1139
|
-
* @param column The JSONB column
|
|
1140
|
-
* @param path The path to the nested property (e.g., ['profile', 'contact', 'email'])
|
|
1141
|
-
* @param operator The filter operator (e.g., { eq: "test@example.com" })
|
|
1142
|
-
* @param dialect Database dialect (postgresql or sqlite)
|
|
1143
|
-
* @param columnSchema Optional schema of the JSON column for type inference
|
|
1144
|
-
* @returns SQL condition
|
|
1145
|
-
*/
|
|
1146
|
-
buildJsonbCondition(column: PgColumn, path: string[], operator: FilterOperators<any>, dialect: "postgresql" | "sqlite", columnSchema?: any): SQL | undefined;
|
|
1147
|
-
/**
|
|
1148
|
-
* Build JSONB array query conditions.
|
|
1149
|
-
* Supports queries like: { addresses: { city: { eq: "Wonderland" } } }
|
|
1150
|
-
* which translates to: EXISTS (SELECT 1 FROM jsonb_array_elements(addresses) elem WHERE elem->>'city' = 'Wonderland')
|
|
1151
|
-
*
|
|
1152
|
-
* @param dialect Database dialect (postgresql or sqlite)
|
|
1153
|
-
* Note: SQLite array queries are not yet supported
|
|
1154
|
-
*/
|
|
1155
|
-
buildJsonbArrayCondition(column: PgColumn, path: string[], arrayPath: string, operator: FilterOperators<any>, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
1156
|
-
/**
|
|
1157
|
-
* Apply a filter operator to a JSONB value.
|
|
1158
|
-
* @param dialect Database dialect for appropriate casting syntax
|
|
1159
|
-
* @param fieldType Optional field type from schema for smart casting
|
|
1160
|
-
*/
|
|
1161
|
-
private applyOperatorToJsonValue;
|
|
1162
|
-
/**
|
|
1163
|
-
* Parse a nested query object and extract the path and operator.
|
|
1164
|
-
* For example: { profile: { contact: { email: { eq: "test@example.com" } } } }
|
|
1165
|
-
* Returns: { path: ['profile', 'contact', 'email'], operator: { eq: "test@example.com" } }
|
|
1166
|
-
*/
|
|
1167
|
-
parseNestedQuery(nestedQuery: any, currentPath?: string[]): Array<{
|
|
1168
|
-
path: string[];
|
|
1169
|
-
operator: FilterOperators<any>;
|
|
1170
|
-
}>;
|
|
1171
|
-
/**
|
|
1172
|
-
* Determine if a property is a JSONB column based on the schema.
|
|
1173
|
-
* A column is JSONB if it's defined as an object or array in the TypeBox schema.
|
|
1174
|
-
*/
|
|
1175
|
-
isJsonbColumn(schema: TObject, columnName: string): boolean;
|
|
1176
|
-
/**
|
|
1177
|
-
* Check if an array property contains primitive types (string, number, boolean, etc.)
|
|
1178
|
-
* rather than objects. Primitive arrays should use native Drizzle operators.
|
|
1179
|
-
* @returns true if the array contains primitives, false if it contains objects
|
|
1180
|
-
*/
|
|
1181
|
-
isPrimitiveArray(schema: TObject, columnName: string): boolean;
|
|
1182
|
-
/**
|
|
1183
|
-
* Get the type of a field by navigating through a schema path.
|
|
1184
|
-
* Used for smart type casting in SQL queries.
|
|
1185
|
-
*
|
|
1186
|
-
* @param columnSchema The schema of the JSON column (e.g., t.object({ age: t.integer() }))
|
|
1187
|
-
* @param path The path to navigate (e.g., ['contact', 'email'])
|
|
1188
|
-
* @returns The type string (e.g., 'integer', 'number', 'string') or undefined if not found
|
|
1189
|
-
*/
|
|
1190
|
-
private getFieldType;
|
|
1191
1122
|
/**
|
|
1192
|
-
*
|
|
1123
|
+
* For testing purposes, generate a unique schema name.
|
|
1124
|
+
* The schema name will be generated based on the current date and time.
|
|
1125
|
+
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
1193
1126
|
*/
|
|
1194
|
-
|
|
1127
|
+
protected generateTestSchemaName(): string;
|
|
1195
1128
|
}
|
|
1196
1129
|
//#endregion
|
|
1197
1130
|
//#region ../../src/orm/services/QueryManager.d.ts
|
|
1198
1131
|
declare class QueryManager {
|
|
1199
|
-
protected readonly jsonQueryManager: PgJsonQueryManager;
|
|
1200
1132
|
protected readonly alepha: Alepha;
|
|
1201
1133
|
/**
|
|
1202
1134
|
* Convert a query object to a SQL query.
|
|
@@ -1207,10 +1139,6 @@ declare class QueryManager {
|
|
|
1207
1139
|
joins?: PgJoin[];
|
|
1208
1140
|
dialect: "postgresql" | "sqlite";
|
|
1209
1141
|
}): SQL | undefined;
|
|
1210
|
-
/**
|
|
1211
|
-
* Build a JSONB query for nested object/array queries.
|
|
1212
|
-
*/
|
|
1213
|
-
protected buildJsonbQuery(column: PgColumn, nestedQuery: any, schema: TObject, columnName: string, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
1214
1142
|
/**
|
|
1215
1143
|
* Check if an object has any filter operator properties.
|
|
1216
1144
|
*/
|
|
@@ -1698,6 +1626,218 @@ interface TransactionPrimitiveOptions<T extends any[], R> {
|
|
|
1698
1626
|
}
|
|
1699
1627
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1700
1628
|
//#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<alepha1.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: alepha1.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: alepha1.TOptional<alepha1.TString>;
|
|
1781
|
+
/**
|
|
1782
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1783
|
+
*/
|
|
1784
|
+
POSTGRES_SCHEMA: alepha1.TOptional<alepha1.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: alepha1.HookPrimitive<"start">;
|
|
1835
|
+
protected readonly onStop: alepha1.HookPrimitive<"stop">;
|
|
1836
|
+
connect(): Promise<void>;
|
|
1837
|
+
close(): Promise<void>;
|
|
1838
|
+
protected migrate: alepha_lock0.LockPrimitive<() => Promise<void>>;
|
|
1839
|
+
}
|
|
1840
|
+
//#endregion
|
|
1701
1841
|
//#region ../../src/orm/services/SqliteModelBuilder.d.ts
|
|
1702
1842
|
declare class SqliteModelBuilder extends ModelBuilder {
|
|
1703
1843
|
buildTable(entity: EntityPrimitive<any>, options: {
|
|
@@ -1754,10 +1894,10 @@ declare class SqliteModelBuilder extends ModelBuilder {
|
|
|
1754
1894
|
name: string;
|
|
1755
1895
|
dataType: "custom";
|
|
1756
1896
|
columnType: "SQLiteCustomColumn";
|
|
1757
|
-
data:
|
|
1897
|
+
data: typebox1.StaticRecord<[], "Decode", {}, {}, string, TSchema>;
|
|
1758
1898
|
driverParam: string;
|
|
1759
1899
|
enumValues: undefined;
|
|
1760
|
-
}>,
|
|
1900
|
+
}>, typebox1.StaticRecord<[], "Decode", {}, {}, string, TSchema>> | drizzle_orm0.$Type<pg$1.SQLiteCustomColumnBuilder<{
|
|
1761
1901
|
name: string;
|
|
1762
1902
|
dataType: "custom";
|
|
1763
1903
|
columnType: "SQLiteCustomColumn";
|
|
@@ -1852,6 +1992,65 @@ declare class SqliteModelBuilder extends ModelBuilder {
|
|
|
1852
1992
|
}
|
|
1853
1993
|
type SchemaToSqliteBuilder<T extends TObject> = { [key in keyof T["properties"]]: SQLiteColumnBuilderBase };
|
|
1854
1994
|
//#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: alepha1.Atom<alepha1.TObject<{
|
|
2000
|
+
path: alepha1.TOptional<alepha1.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: alepha1.HookPrimitive<"start">;
|
|
2050
|
+
protected readonly onStop: alepha1.HookPrimitive<"stop">;
|
|
2051
|
+
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2052
|
+
}
|
|
2053
|
+
//#endregion
|
|
1855
2054
|
//#region ../../src/orm/providers/drivers/CloudflareD1Provider.d.ts
|
|
1856
2055
|
/**
|
|
1857
2056
|
* D1Database interface matching Cloudflare's D1 API.
|
|
@@ -1924,41 +2123,6 @@ declare class CloudflareD1Provider extends DatabaseProvider {
|
|
|
1924
2123
|
protected runTestMigration(): Promise<void>;
|
|
1925
2124
|
}
|
|
1926
2125
|
//#endregion
|
|
1927
|
-
//#region ../../src/orm/services/PostgresModelBuilder.d.ts
|
|
1928
|
-
declare class PostgresModelBuilder extends ModelBuilder {
|
|
1929
|
-
protected schemas: Map<string, drizzle_orm_pg_core0.PgSchema<string>>;
|
|
1930
|
-
protected getPgSchema(name: string): any;
|
|
1931
|
-
buildTable(entity: EntityPrimitive<any>, options: {
|
|
1932
|
-
tables: Map<string, unknown>;
|
|
1933
|
-
enums: Map<string, unknown>;
|
|
1934
|
-
schema: string;
|
|
1935
|
-
}): void;
|
|
1936
|
-
buildSequence(sequence: SequencePrimitive, options: {
|
|
1937
|
-
sequences: Map<string, unknown>;
|
|
1938
|
-
schema: string;
|
|
1939
|
-
}): void;
|
|
1940
|
-
/**
|
|
1941
|
-
* Get PostgreSQL-specific config builder for the table.
|
|
1942
|
-
*/
|
|
1943
|
-
protected getTableConfig(entity: EntityPrimitive, tables: Map<string, unknown>): ((self: BuildExtraConfigColumns<string, any, "pg">) => PgTableExtraConfigValue[]) | undefined;
|
|
1944
|
-
schemaToPgColumns: <T extends TObject>(tableName: string, schema: T, nsp: PgSchema, enums: Map<string, unknown>, tables: Map<string, unknown>) => FromSchema<T>;
|
|
1945
|
-
mapFieldToColumn: (tableName: string, fieldName: string, value: TSchema, nsp: PgSchema, enums: Map<string, any>) => any;
|
|
1946
|
-
/**
|
|
1947
|
-
* Map a string to a PG column.
|
|
1948
|
-
*
|
|
1949
|
-
* @param key The key of the field.
|
|
1950
|
-
* @param value The value of the field.
|
|
1951
|
-
*/
|
|
1952
|
-
mapStringToColumn: (key: string, value: TSchema) => drizzle_orm_pg_core0.PgUUIDBuilderInitial<string> | drizzle_orm_pg_core0.PgCustomColumnBuilder<{
|
|
1953
|
-
name: string;
|
|
1954
|
-
dataType: "custom";
|
|
1955
|
-
columnType: "PgCustomColumn";
|
|
1956
|
-
data: Buffer<ArrayBufferLike>;
|
|
1957
|
-
driverParam: unknown;
|
|
1958
|
-
enumValues: undefined;
|
|
1959
|
-
}> | drizzle_orm_pg_core0.PgTimestampStringBuilderInitial<string> | drizzle_orm_pg_core0.PgDateStringBuilderInitial<string> | drizzle_orm_pg_core0.PgTextBuilderInitial<string, [string, ...string[]]>;
|
|
1960
|
-
}
|
|
1961
|
-
//#endregion
|
|
1962
2126
|
//#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
1963
2127
|
declare module "alepha" {
|
|
1964
2128
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -2020,12 +2184,6 @@ declare class NodePostgresProvider extends DatabaseProvider {
|
|
|
2020
2184
|
*/
|
|
2021
2185
|
protected getClientOptions(): postgres.Options<any>;
|
|
2022
2186
|
protected ssl(url: URL): "require" | "allow" | "prefer" | "verify-full" | undefined;
|
|
2023
|
-
/**
|
|
2024
|
-
* For testing purposes, generate a unique schema name.
|
|
2025
|
-
* The schema name will be generated based on the current date and time.
|
|
2026
|
-
* It will be in the format of `test_YYYYMMDD_HHMMSS_randomSuffix`.
|
|
2027
|
-
*/
|
|
2028
|
-
protected generateTestSchemaName(): string;
|
|
2029
2187
|
}
|
|
2030
2188
|
//#endregion
|
|
2031
2189
|
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
@@ -2067,89 +2225,6 @@ declare class NodeSqliteProvider extends DatabaseProvider {
|
|
|
2067
2225
|
protected executeMigrations(migrationsFolder: string): Promise<void>;
|
|
2068
2226
|
}
|
|
2069
2227
|
//#endregion
|
|
2070
|
-
//#region ../../src/orm/providers/PostgresTypeProvider.d.ts
|
|
2071
|
-
declare class PostgresTypeProvider {
|
|
2072
|
-
readonly attr: <T extends TSchema, Attr extends PgSymbolKeys>(type: T, attr: Attr, value?: PgSymbols[Attr]) => PgAttr<T, Attr>;
|
|
2073
|
-
/**
|
|
2074
|
-
* Creates a primary key with an identity column.
|
|
2075
|
-
*/
|
|
2076
|
-
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
2077
|
-
/**
|
|
2078
|
-
* Creates a primary key with a big identity column. (default)
|
|
2079
|
-
*/
|
|
2080
|
-
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: TNumberOptions) => PgAttr<PgAttr<PgAttr<TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
2081
|
-
/**
|
|
2082
|
-
* Creates a primary key with a UUID column.
|
|
2083
|
-
*/
|
|
2084
|
-
readonly uuidPrimaryKey: () => PgAttr<PgAttr<TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
2085
|
-
/**
|
|
2086
|
-
* Creates a primary key for a given type. Supports:
|
|
2087
|
-
* - `t.integer()` -> PG INT (default)
|
|
2088
|
-
* - `t.bigint()` -> PG BIGINT
|
|
2089
|
-
* - `t.uuid()` -> PG UUID
|
|
2090
|
-
*/
|
|
2091
|
-
primaryKey(): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
2092
|
-
primaryKey(type: TString, options?: TStringOptions): PgAttr<PgAttr<TString, PgPrimaryKey>, PgDefault>;
|
|
2093
|
-
primaryKey(type: TInteger, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TInteger, PgPrimaryKey>, PgDefault>;
|
|
2094
|
-
primaryKey(type: TNumber, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TNumber, PgPrimaryKey>, PgDefault>;
|
|
2095
|
-
primaryKey(type: TBigInt, options?: TNumberOptions, identity?: PgIdentityOptions): PgAttr<PgAttr<TBigInt, PgPrimaryKey>, PgDefault>;
|
|
2096
|
-
/**
|
|
2097
|
-
* Wrap a schema with "default" attribute.
|
|
2098
|
-
* This is used to set a default value for a column in the database.
|
|
2099
|
-
*/
|
|
2100
|
-
readonly default: <T extends TSchema>(type: T, value?: Static<T>) => PgAttr<T, PgDefault>;
|
|
2101
|
-
/**
|
|
2102
|
-
* Creates a column 'version'.
|
|
2103
|
-
*
|
|
2104
|
-
* This is used to track the version of a row in the database.
|
|
2105
|
-
*
|
|
2106
|
-
* You can use it for optimistic concurrency control (OCC) with {@link RepositoryPrimitive#save}.
|
|
2107
|
-
*
|
|
2108
|
-
* @see {@link RepositoryPrimitive#save}
|
|
2109
|
-
* @see {@link PgVersionMismatchError}
|
|
2110
|
-
*/
|
|
2111
|
-
readonly version: (options?: TNumberOptions) => PgAttr<PgAttr<TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
2112
|
-
/**
|
|
2113
|
-
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
2114
|
-
*/
|
|
2115
|
-
readonly createdAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
2116
|
-
/**
|
|
2117
|
-
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
2118
|
-
*/
|
|
2119
|
-
readonly updatedAt: (options?: TStringOptions) => PgAttr<PgAttr<TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
2120
|
-
/**
|
|
2121
|
-
* Creates a column Deleted At for soft delete functionality.
|
|
2122
|
-
* This is used to mark rows as deleted without actually removing them from the database.
|
|
2123
|
-
* The column is nullable - NULL means not deleted, timestamp means deleted.
|
|
2124
|
-
*/
|
|
2125
|
-
readonly deletedAt: (options?: TStringOptions) => PgAttr<alepha1.TOptional<TString>, typeof PG_DELETED_AT>;
|
|
2126
|
-
/**
|
|
2127
|
-
* Creates a Postgres ENUM type.
|
|
2128
|
-
*
|
|
2129
|
-
* > By default, `t.enum()` is mapped to a TEXT column in Postgres.
|
|
2130
|
-
* > Using this method, you can create a real ENUM type in the database.
|
|
2131
|
-
*
|
|
2132
|
-
* @example
|
|
2133
|
-
* ```ts
|
|
2134
|
-
* const statusEnum = pg.enum(["pending", "active", "archived"], { name: "status_enum" });
|
|
2135
|
-
* ```
|
|
2136
|
-
*/
|
|
2137
|
-
readonly enum: <T extends string[]>(values: [...T], pgEnumOptions?: PgEnumOptions, typeOptions?: TStringOptions) => PgAttr<TUnsafe<T[number]>, typeof PG_ENUM>;
|
|
2138
|
-
/**
|
|
2139
|
-
* Creates a reference to another table or schema. Basically a foreign key.
|
|
2140
|
-
*/
|
|
2141
|
-
readonly ref: <T extends TSchema>(type: T, ref: () => any, actions?: {
|
|
2142
|
-
onUpdate?: UpdateDeleteAction$1;
|
|
2143
|
-
onDelete?: UpdateDeleteAction$1;
|
|
2144
|
-
}) => PgAttr<T, PgRef>;
|
|
2145
|
-
/**
|
|
2146
|
-
* Creates a page schema for a given object schema.
|
|
2147
|
-
* It's used by {@link RepositoryPrimitive#paginate} method.
|
|
2148
|
-
*/
|
|
2149
|
-
readonly page: <T extends TObject>(resource: T, options?: TObjectOptions) => TPage<T>;
|
|
2150
|
-
}
|
|
2151
|
-
declare const pg: PostgresTypeProvider;
|
|
2152
|
-
//#endregion
|
|
2153
2228
|
//#region ../../src/orm/providers/RepositoryProvider.d.ts
|
|
2154
2229
|
declare class RepositoryProvider {
|
|
2155
2230
|
protected readonly alepha: Alepha;
|
|
@@ -2249,21 +2324,25 @@ declare module "alepha" {
|
|
|
2249
2324
|
* Postgres client based on Drizzle ORM, Alepha type-safe friendly.
|
|
2250
2325
|
*
|
|
2251
2326
|
* ```ts
|
|
2327
|
+
* import { t } from "alepha";
|
|
2328
|
+
* import { $entity, $repository, db } from "alepha/postgres";
|
|
2329
|
+
*
|
|
2252
2330
|
* const users = $entity({
|
|
2253
2331
|
* name: "users",
|
|
2254
2332
|
* schema: t.object({
|
|
2255
|
-
* id:
|
|
2333
|
+
* id: db.primaryKey(),
|
|
2256
2334
|
* name: t.text(),
|
|
2257
2335
|
* email: t.text(),
|
|
2258
2336
|
* }),
|
|
2259
2337
|
* });
|
|
2260
2338
|
*
|
|
2261
|
-
* class
|
|
2339
|
+
* class App {
|
|
2262
2340
|
* users = $repository(users);
|
|
2263
|
-
* }
|
|
2264
2341
|
*
|
|
2265
|
-
*
|
|
2266
|
-
*
|
|
2342
|
+
* getUserByName(name: string) {
|
|
2343
|
+
* return this.users.findOne({ name: { eq: name } });
|
|
2344
|
+
* }
|
|
2345
|
+
* }
|
|
2267
2346
|
* ```
|
|
2268
2347
|
*
|
|
2269
2348
|
* This is not a full ORM, but rather a set of tools to work with Postgres databases in a type-safe way.
|
|
@@ -2286,5 +2365,5 @@ declare module "alepha" {
|
|
|
2286
2365
|
*/
|
|
2287
2366
|
declare const AlephaPostgres: alepha1.Service<alepha1.Module>;
|
|
2288
2367
|
//#endregion
|
|
2289
|
-
export { $entity, $repository, $sequence, $transaction, AlephaPostgres, CloudflareD1Provider, D1Database, D1ExecResult, D1PreparedStatement, D1Result, DatabaseProvider, 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,
|
|
2368
|
+
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 };
|
|
2290
2369
|
//# sourceMappingURL=index.d.ts.map
|