alepha 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +7 -34
- package/batch.d.ts +44 -11
- package/cache/redis.d.ts +0 -2
- package/cache.d.ts +70 -2
- package/command.d.ts +11 -13
- package/core.d.ts +137 -133
- package/datetime.d.ts +4 -4
- package/file.cjs +8 -0
- package/file.d.ts +46 -0
- package/file.js +1 -0
- package/lock/redis.d.ts +0 -2
- package/lock.d.ts +13 -15
- package/package.json +50 -36
- package/postgres.d.ts +194 -62
- package/queue/redis.d.ts +0 -2
- package/queue.d.ts +91 -5
- package/react/auth.d.ts +7 -6
- package/react/head.d.ts +1 -1
- package/react.d.ts +157 -23
- package/redis.d.ts +3 -0
- package/retry.d.ts +2 -1
- package/router.cjs +8 -0
- package/router.d.ts +45 -0
- package/router.js +1 -0
- package/scheduler.d.ts +1 -4
- package/security.d.ts +191 -12
- package/server/cache.d.ts +0 -3
- package/server/cookies.d.ts +187 -10
- package/server/health.d.ts +0 -3
- package/server/helmet.d.ts +0 -2
- package/server/links.d.ts +16 -13
- package/server/metrics.d.ts +0 -2
- package/server/multipart.d.ts +0 -2
- package/server/proxy.d.ts +4 -4
- package/server/static.d.ts +8 -5
- package/server/swagger.d.ts +7 -6
- package/server.d.ts +161 -8
- package/topic/redis.d.ts +0 -2
- package/topic.d.ts +17 -16
- package/vite.d.ts +52 -36
package/postgres.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
1
|
+
import * as _alepha_core55 from "alepha";
|
|
2
|
+
import * as _alepha_core19 from "alepha";
|
|
3
|
+
import * as _alepha_core21 from "alepha";
|
|
4
4
|
import { Alepha, KIND, Module, OPTIONS, Static, TObject, TSchema as TSchema$1 } from "alepha";
|
|
5
5
|
import * as drizzle_orm3 from "drizzle-orm";
|
|
6
6
|
import * as drizzle_orm8 from "drizzle-orm";
|
|
7
7
|
import * as drizzle_orm2 from "drizzle-orm";
|
|
8
8
|
import * as drizzle from "drizzle-orm";
|
|
9
9
|
import { BuildColumns, BuildExtraConfigColumns, SQL, SQLWrapper, TableConfig, sql } from "drizzle-orm";
|
|
10
|
-
import * as
|
|
10
|
+
import * as _alepha_lock44 from "alepha/lock";
|
|
11
11
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
12
12
|
import postgres from "postgres";
|
|
13
13
|
import * as pg$1 from "drizzle-orm/pg-core";
|
|
14
14
|
import * as drizzle_orm_pg_core13 from "drizzle-orm/pg-core";
|
|
15
15
|
import * as drizzle_orm_pg_core1 from "drizzle-orm/pg-core";
|
|
16
16
|
import { AnyPgColumn, AnyPgTable, LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, PgTransactionConfig, TableConfig as TableConfig$1, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
17
|
-
import * as
|
|
18
|
-
import * as
|
|
17
|
+
import * as _alepha_retry81 from "alepha/retry";
|
|
18
|
+
import * as _sinclair_typebox74 from "@sinclair/typebox";
|
|
19
|
+
import * as _sinclair_typebox89 from "@sinclair/typebox";
|
|
19
20
|
import * as _sinclair_typebox85 from "@sinclair/typebox";
|
|
20
|
-
import * as _sinclair_typebox88 from "@sinclair/typebox";
|
|
21
21
|
import * as _sinclair_typebox82 from "@sinclair/typebox";
|
|
22
|
-
import * as
|
|
23
|
-
import * as
|
|
22
|
+
import * as _sinclair_typebox57 from "@sinclair/typebox";
|
|
23
|
+
import * as _sinclair_typebox48 from "@sinclair/typebox";
|
|
24
24
|
import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2 } from "@sinclair/typebox";
|
|
25
25
|
import { PgTransactionConfig as PgTransactionConfig$1 } from "drizzle-orm/pg-core/session";
|
|
26
26
|
import * as DrizzleKit from "drizzle-kit/api";
|
|
@@ -778,10 +778,10 @@ declare abstract class PostgresProvider {
|
|
|
778
778
|
//# sourceMappingURL=PostgresProvider.d.ts.map
|
|
779
779
|
//#endregion
|
|
780
780
|
//#region src/schemas/pageQuerySchema.d.ts
|
|
781
|
-
declare const pageQuerySchema:
|
|
782
|
-
page:
|
|
783
|
-
size:
|
|
784
|
-
sort:
|
|
781
|
+
declare const pageQuerySchema: _sinclair_typebox74.TObject<{
|
|
782
|
+
page: _sinclair_typebox74.TOptional<_sinclair_typebox74.TNumber>;
|
|
783
|
+
size: _sinclair_typebox74.TOptional<_sinclair_typebox74.TNumber>;
|
|
784
|
+
sort: _sinclair_typebox74.TOptional<_sinclair_typebox74.TString>;
|
|
785
785
|
}>;
|
|
786
786
|
type PageQuery = Static<typeof pageQuerySchema>;
|
|
787
787
|
//# sourceMappingURL=pageQuerySchema.d.ts.map
|
|
@@ -1130,6 +1130,12 @@ declare const PG_SCHEMA: unique symbol;
|
|
|
1130
1130
|
|
|
1131
1131
|
//#endregion
|
|
1132
1132
|
//#region src/descriptors/$db.d.ts
|
|
1133
|
+
/**
|
|
1134
|
+
* @experimental
|
|
1135
|
+
*/
|
|
1136
|
+
declare const $db: <T extends {
|
|
1137
|
+
[key: string]: TableLike;
|
|
1138
|
+
}>(options?: DbDescriptorOptions<T>) => DbDescriptor<T>;
|
|
1133
1139
|
type DbDescriptorOptions<T extends {
|
|
1134
1140
|
[key: string]: TableLike;
|
|
1135
1141
|
}> = {
|
|
@@ -1138,12 +1144,13 @@ type DbDescriptorOptions<T extends {
|
|
|
1138
1144
|
type DbDescriptor<T extends {
|
|
1139
1145
|
[key: string]: TableLike;
|
|
1140
1146
|
}> = { [key in keyof T]: Repository<any, T[key]["$schema"]> } & Pick<PostgresProvider, "execute">;
|
|
1141
|
-
declare const $db: <T extends {
|
|
1142
|
-
[key: string]: TableLike;
|
|
1143
|
-
}>(options?: DbDescriptorOptions<T>) => DbDescriptor<T>;
|
|
1144
1147
|
//# sourceMappingURL=$db.d.ts.map
|
|
1145
1148
|
//#endregion
|
|
1146
1149
|
//#region src/descriptors/$entity.d.ts
|
|
1150
|
+
/**
|
|
1151
|
+
* Creates a table descriptor for drizzle-orm.
|
|
1152
|
+
*/
|
|
1153
|
+
declare const $entity: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
|
|
1147
1154
|
interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1, Keys = keyof Static$1<T>> {
|
|
1148
1155
|
/**
|
|
1149
1156
|
* The name of the table. This is the name that will be used in the database.
|
|
@@ -1200,10 +1207,6 @@ interface EntityDescriptorOptions<TTableName extends string, T extends TObject$1
|
|
|
1200
1207
|
*/
|
|
1201
1208
|
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
1202
1209
|
}
|
|
1203
|
-
/**
|
|
1204
|
-
* Creates a table descriptor for drizzle-orm.
|
|
1205
|
-
*/
|
|
1206
|
-
declare const $entity: <TTableName extends string, TSchema extends TObject$1, TColumnsMap extends FromSchema<TSchema>>(options: EntityDescriptorOptions<TTableName, TSchema>) => PgTableWithColumnsAndSchema<PgTableConfig<TTableName, TSchema, TColumnsMap>, TSchema>;
|
|
1207
1210
|
type Entity<T extends TObject$1> = PgTableWithColumnsAndSchema<PgTableConfig<string, T, FromSchema<T>>, T>;
|
|
1208
1211
|
/**
|
|
1209
1212
|
* Create a table with a json schema.
|
|
@@ -1222,6 +1225,13 @@ type PgTableConfig<TTableName extends string, TSchema extends TObject$1, TColumn
|
|
|
1222
1225
|
//# sourceMappingURL=$entity.d.ts.map
|
|
1223
1226
|
//#endregion
|
|
1224
1227
|
//#region src/descriptors/$repository.d.ts
|
|
1228
|
+
/**
|
|
1229
|
+
*
|
|
1230
|
+
*/
|
|
1231
|
+
declare const $repository: {
|
|
1232
|
+
<TEntity extends TableConfig, TSchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<TEntity, TSchema> | PgTableWithColumnsAndSchema<TEntity, TSchema>): Repository<PgTableWithColumnsAndSchema<TEntity, TSchema>, TSchema>;
|
|
1233
|
+
[KIND]: string;
|
|
1234
|
+
};
|
|
1225
1235
|
interface RepositoryDescriptorOptions<TEntity extends TableConfig, TSchema extends TObject> {
|
|
1226
1236
|
/**
|
|
1227
1237
|
* The table to create the repository for.
|
|
@@ -1232,17 +1242,14 @@ interface RepositoryDescriptorOptions<TEntity extends TableConfig, TSchema exten
|
|
|
1232
1242
|
*/
|
|
1233
1243
|
provider?: () => PostgresProvider;
|
|
1234
1244
|
}
|
|
1235
|
-
/**
|
|
1236
|
-
* @param optionsOrTable
|
|
1237
|
-
*/
|
|
1238
|
-
declare const $repository: {
|
|
1239
|
-
<TEntity extends TableConfig, TSchema extends TObject>(optionsOrTable: RepositoryDescriptorOptions<TEntity, TSchema> | PgTableWithColumnsAndSchema<TEntity, TSchema>): Repository<PgTableWithColumnsAndSchema<TEntity, TSchema>, TSchema>;
|
|
1240
|
-
[KIND]: string;
|
|
1241
|
-
};
|
|
1242
1245
|
//# sourceMappingURL=$repository.d.ts.map
|
|
1243
1246
|
//#endregion
|
|
1244
1247
|
//#region src/descriptors/$sequence.d.ts
|
|
1245
1248
|
declare const KEY = "SEQUENCE";
|
|
1249
|
+
declare const $sequence: {
|
|
1250
|
+
(options?: SequenceDescriptorOptions): SequenceDescriptor;
|
|
1251
|
+
[KIND]: string;
|
|
1252
|
+
};
|
|
1246
1253
|
interface SequenceDescriptorOptions {
|
|
1247
1254
|
name?: string;
|
|
1248
1255
|
start?: number;
|
|
@@ -1258,18 +1265,17 @@ interface SequenceDescriptor {
|
|
|
1258
1265
|
next(): Promise<number>;
|
|
1259
1266
|
current(): Promise<number>;
|
|
1260
1267
|
}
|
|
1261
|
-
declare const $sequence: {
|
|
1262
|
-
(options?: SequenceDescriptorOptions): SequenceDescriptor;
|
|
1263
|
-
[KIND]: string;
|
|
1264
|
-
};
|
|
1265
1268
|
//#endregion
|
|
1266
1269
|
//#region src/descriptors/$transaction.d.ts
|
|
1270
|
+
/**
|
|
1271
|
+
*
|
|
1272
|
+
*/
|
|
1273
|
+
declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry81.RetryDescriptor<(...args: T) => Promise<R>>;
|
|
1267
1274
|
interface TransactionDescriptorOptions<T extends any[], R> {
|
|
1268
1275
|
handler: (tx: PgTransaction<any, any, any>, ...args: T) => Promise<R>;
|
|
1269
1276
|
config?: PgTransactionConfig$1;
|
|
1270
1277
|
}
|
|
1271
1278
|
type TransactionContext = PgTransaction<any, any, any>;
|
|
1272
|
-
declare const $transaction: <T extends any[], R>(opts: TransactionDescriptorOptions<T, R>) => _alepha_retry19.RetryDescriptor<(...args: T) => Promise<R>>;
|
|
1273
1279
|
//# sourceMappingURL=$transaction.d.ts.map
|
|
1274
1280
|
//#endregion
|
|
1275
1281
|
//#region src/errors/EntityNotFoundError.d.ts
|
|
@@ -1282,12 +1288,12 @@ declare class EntityNotFoundError extends Error {
|
|
|
1282
1288
|
//#endregion
|
|
1283
1289
|
//#region src/providers/RepositoryDescriptorProvider.d.ts
|
|
1284
1290
|
declare class RepositoryDescriptorProvider {
|
|
1285
|
-
protected readonly log:
|
|
1291
|
+
protected readonly log: _alepha_core55.Logger;
|
|
1286
1292
|
protected readonly alepha: Alepha;
|
|
1287
1293
|
protected readonly repositories: Array<Repository<any, TObject$1>>;
|
|
1288
1294
|
constructor();
|
|
1289
1295
|
clearRepositories(): Promise<void>;
|
|
1290
|
-
protected readonly configure:
|
|
1296
|
+
protected readonly configure: _alepha_core55.HookDescriptor<"configure">;
|
|
1291
1297
|
/**
|
|
1292
1298
|
* Get all repositories.
|
|
1293
1299
|
*
|
|
@@ -1321,7 +1327,7 @@ declare class RepositoryDescriptorProvider {
|
|
|
1321
1327
|
//#endregion
|
|
1322
1328
|
//#region src/providers/DrizzleKitProvider.d.ts
|
|
1323
1329
|
declare class DrizzleKitProvider {
|
|
1324
|
-
protected readonly log:
|
|
1330
|
+
protected readonly log: _alepha_core19.Logger;
|
|
1325
1331
|
protected readonly alepha: Alepha;
|
|
1326
1332
|
protected readonly repositoryProvider: RepositoryDescriptorProvider;
|
|
1327
1333
|
push(provider: PostgresProvider, schema?: string): Promise<void>;
|
|
@@ -1360,37 +1366,37 @@ declare module "alepha" {
|
|
|
1360
1366
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1361
1367
|
}
|
|
1362
1368
|
declare const envSchema: TObject$1<{
|
|
1363
|
-
PG_HOST:
|
|
1364
|
-
PG_USERNAME:
|
|
1365
|
-
PG_DATABASE:
|
|
1366
|
-
PG_PASSWORD:
|
|
1367
|
-
PG_PORT:
|
|
1368
|
-
DATABASE_URL:
|
|
1369
|
-
DATABASE_MIGRATIONS_FOLDER:
|
|
1369
|
+
PG_HOST: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1370
|
+
PG_USERNAME: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1371
|
+
PG_DATABASE: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1372
|
+
PG_PASSWORD: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1373
|
+
PG_PORT: _alepha_core21.TOptional<_alepha_core21.TNumber>;
|
|
1374
|
+
DATABASE_URL: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1375
|
+
DATABASE_MIGRATIONS_FOLDER: _alepha_core21.TString;
|
|
1370
1376
|
/**
|
|
1371
1377
|
* The schema to use.
|
|
1372
1378
|
* Accept a string.
|
|
1373
1379
|
*/
|
|
1374
|
-
POSTGRES_SCHEMA:
|
|
1380
|
+
POSTGRES_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TString>;
|
|
1375
1381
|
/**
|
|
1376
1382
|
* Synchronize the database schema with the models.
|
|
1377
1383
|
* Accept a boolean or a postgres schema name.
|
|
1378
1384
|
*
|
|
1379
1385
|
* @default false
|
|
1380
1386
|
*/
|
|
1381
|
-
POSTGRES_SYNCHRONIZE:
|
|
1387
|
+
POSTGRES_SYNCHRONIZE: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
|
|
1382
1388
|
/**
|
|
1383
1389
|
* Push the schema to the database.
|
|
1384
1390
|
*
|
|
1385
1391
|
* @default false
|
|
1386
1392
|
*/
|
|
1387
|
-
POSTGRES_PUSH_SCHEMA:
|
|
1393
|
+
POSTGRES_PUSH_SCHEMA: _alepha_core21.TOptional<_alepha_core21.TBoolean>;
|
|
1388
1394
|
/**
|
|
1389
1395
|
* Reject unauthorized SSL connections.
|
|
1390
1396
|
*
|
|
1391
1397
|
* @default false
|
|
1392
1398
|
*/
|
|
1393
|
-
POSTGRES_REJECT_UNAUTHORIZED:
|
|
1399
|
+
POSTGRES_REJECT_UNAUTHORIZED: _alepha_core21.TBoolean;
|
|
1394
1400
|
}>;
|
|
1395
1401
|
interface NodePostgresProviderState {
|
|
1396
1402
|
client: postgres.Sql;
|
|
@@ -1398,7 +1404,7 @@ interface NodePostgresProviderState {
|
|
|
1398
1404
|
}
|
|
1399
1405
|
declare class NodePostgresProvider extends PostgresProvider {
|
|
1400
1406
|
readonly dialect = "postgres";
|
|
1401
|
-
protected readonly log:
|
|
1407
|
+
protected readonly log: _alepha_core21.Logger;
|
|
1402
1408
|
protected readonly env: {
|
|
1403
1409
|
DATABASE_URL?: string | undefined;
|
|
1404
1410
|
PG_HOST?: string | undefined;
|
|
@@ -1420,8 +1426,8 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1420
1426
|
*/
|
|
1421
1427
|
protected testingSchemaName?: string;
|
|
1422
1428
|
get db(): PostgresJsDatabase;
|
|
1423
|
-
protected readonly configure:
|
|
1424
|
-
protected readonly stop:
|
|
1429
|
+
protected readonly configure: _alepha_core21.HookDescriptor<"start">;
|
|
1430
|
+
protected readonly stop: _alepha_core21.HookDescriptor<"stop">;
|
|
1425
1431
|
/**
|
|
1426
1432
|
* Get Postgres schema.
|
|
1427
1433
|
*/
|
|
@@ -1429,7 +1435,7 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1429
1435
|
execute<T extends TObject$1 = any>(query: SQLLike, schema?: T): Promise<Array<T extends TObject$1 ? Static<T> : any>>;
|
|
1430
1436
|
connect(): Promise<void>;
|
|
1431
1437
|
close(): Promise<void>;
|
|
1432
|
-
protected migrate:
|
|
1438
|
+
protected migrate: _alepha_lock44.LockDescriptor<() => Promise<void>>;
|
|
1433
1439
|
protected createClient(): NodePostgresProviderState;
|
|
1434
1440
|
protected getMigrationOptions(): MigrationConfig;
|
|
1435
1441
|
protected getClientOptions(): postgres.Options<any>;
|
|
@@ -1444,7 +1450,7 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1444
1450
|
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1445
1451
|
//#endregion
|
|
1446
1452
|
//#region src/schemas/createdAtSchema.d.ts
|
|
1447
|
-
declare const createdAtSchema: PgAttr<PgAttr<
|
|
1453
|
+
declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox89.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1448
1454
|
//# sourceMappingURL=createdAtSchema.d.ts.map
|
|
1449
1455
|
|
|
1450
1456
|
//#endregion
|
|
@@ -1452,7 +1458,7 @@ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox85.TString, typeof
|
|
|
1452
1458
|
/**
|
|
1453
1459
|
* @deprecated Use `pg.primaryKey()` instead.
|
|
1454
1460
|
*/
|
|
1455
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<
|
|
1461
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox85.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1456
1462
|
//# sourceMappingURL=legacyIdSchema.d.ts.map
|
|
1457
1463
|
//#endregion
|
|
1458
1464
|
//#region src/schemas/updatedAtSchema.d.ts
|
|
@@ -1467,9 +1473,9 @@ declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox82.TString, typeof
|
|
|
1467
1473
|
* Add some common SQL properties to an object.
|
|
1468
1474
|
*/
|
|
1469
1475
|
declare const entitySchema: TObject$1<{
|
|
1470
|
-
id: PgAttr<PgAttr<PgAttr<
|
|
1471
|
-
createdAt: PgAttr<PgAttr<
|
|
1472
|
-
updatedAt: PgAttr<PgAttr<
|
|
1476
|
+
id: PgAttr<PgAttr<PgAttr<_sinclair_typebox57.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1477
|
+
createdAt: PgAttr<PgAttr<_sinclair_typebox57.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1478
|
+
updatedAt: PgAttr<PgAttr<_sinclair_typebox57.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1473
1479
|
}>;
|
|
1474
1480
|
/**
|
|
1475
1481
|
* TypeBox Entity Type.
|
|
@@ -1504,19 +1510,19 @@ declare class PostgresTypeProvider {
|
|
|
1504
1510
|
/**
|
|
1505
1511
|
* Creates a primary key with an identity column.
|
|
1506
1512
|
*/
|
|
1507
|
-
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<
|
|
1513
|
+
readonly identityPrimaryKey: (identity?: PgIdentityOptions, options?: IntegerOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1508
1514
|
/**
|
|
1509
1515
|
* Creates a primary key with a big identity column. (default)
|
|
1510
1516
|
*/
|
|
1511
|
-
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<
|
|
1517
|
+
readonly bigIdentityPrimaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1512
1518
|
/**
|
|
1513
1519
|
* Creates a primary key with a UUID column.
|
|
1514
1520
|
*/
|
|
1515
|
-
readonly uuidPrimaryKey: () => PgAttr<PgAttr<
|
|
1521
|
+
readonly uuidPrimaryKey: () => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1516
1522
|
/**
|
|
1517
1523
|
* @alias bigIdentityPrimaryKey
|
|
1518
1524
|
*/
|
|
1519
|
-
readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<
|
|
1525
|
+
readonly primaryKey: (identity?: PgIdentityOptions, options?: NumberOptions) => PgAttr<PgAttr<PgAttr<_sinclair_typebox48.TNumber, typeof PG_PRIMARY_KEY>, typeof PG_IDENTITY>, typeof PG_DEFAULT>;
|
|
1520
1526
|
/**
|
|
1521
1527
|
* Wrap a schema with "default" attribute.
|
|
1522
1528
|
* This is used to set a default value for a column in the database.
|
|
@@ -1527,15 +1533,15 @@ declare class PostgresTypeProvider {
|
|
|
1527
1533
|
* This is used to track the version of a row in the database.
|
|
1528
1534
|
* You can use it for optimistic concurrency control.
|
|
1529
1535
|
*/
|
|
1530
|
-
readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<
|
|
1536
|
+
readonly version: (options?: IntegerOptions) => PgAttr<PgAttr<_sinclair_typebox48.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
1531
1537
|
/**
|
|
1532
1538
|
* Creates a column Created At. So just a datetime column with a default value of the current timestamp.
|
|
1533
1539
|
*/
|
|
1534
|
-
readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<
|
|
1540
|
+
readonly createdAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1535
1541
|
/**
|
|
1536
1542
|
* Creates a column Updated At. Like createdAt, but it is updated on every update of the row.
|
|
1537
1543
|
*/
|
|
1538
|
-
readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<
|
|
1544
|
+
readonly updatedAt: (options?: StringOptions) => PgAttr<PgAttr<_sinclair_typebox48.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1539
1545
|
/**
|
|
1540
1546
|
* @deprecated Build your own entity schema.
|
|
1541
1547
|
*/
|
|
@@ -1600,6 +1606,132 @@ declare const schema: <TDocument extends TSchema$2>(name: string, document: TDoc
|
|
|
1600
1606
|
declare module "alepha" {
|
|
1601
1607
|
function $inject<T extends TableConfig, R extends TObject>(type: PgTableWithColumnsAndSchema<T, R>): Repository<PgTableWithColumnsAndSchema<T, R>, R>;
|
|
1602
1608
|
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Provides PostgreSQL and SQLite database integration with type-safe ORM capabilities through Drizzle.
|
|
1611
|
+
*
|
|
1612
|
+
* The postgres module enables declarative database operations using descriptors like `$entity`, `$repository`,
|
|
1613
|
+
* and `$db` on class properties. It offers automatic schema generation, type-safe queries, transactions,
|
|
1614
|
+
* and database migrations with support for both PostgreSQL and SQLite backends.
|
|
1615
|
+
*
|
|
1616
|
+
* **Key Features:**
|
|
1617
|
+
* - Declarative entity definition with `$entity` descriptor
|
|
1618
|
+
* - Type-safe repository pattern with `$repository` descriptor
|
|
1619
|
+
* - Database connection management with `$db` descriptor
|
|
1620
|
+
* - Automatic schema migrations and type generation
|
|
1621
|
+
* - Transaction support with `$transaction` descriptor
|
|
1622
|
+
* - Sequence management with `$sequence` descriptor
|
|
1623
|
+
* - Full TypeScript integration with compile-time type checking
|
|
1624
|
+
*
|
|
1625
|
+
* **Basic Usage:**
|
|
1626
|
+
* ```ts
|
|
1627
|
+
* import { Alepha, run, t } from "alepha";
|
|
1628
|
+
* import { AlephaPostgres, $entity, $repository, pg } from "alepha/postgres";
|
|
1629
|
+
*
|
|
1630
|
+
* // Define database entities
|
|
1631
|
+
* const user = $entity({
|
|
1632
|
+
* name: "users",
|
|
1633
|
+
* schema: t.object({
|
|
1634
|
+
* id: pg.primaryKey(),
|
|
1635
|
+
* createdAt: pg.createdAt(),
|
|
1636
|
+
* name: t.string(),
|
|
1637
|
+
* email: t.string(),
|
|
1638
|
+
* age: t.optional(t.integer()),
|
|
1639
|
+
* }),
|
|
1640
|
+
* });
|
|
1641
|
+
*
|
|
1642
|
+
* const post = $entity({
|
|
1643
|
+
* name: "posts",
|
|
1644
|
+
* schema: t.object({
|
|
1645
|
+
* id: pg.primaryKey(),
|
|
1646
|
+
* createdAt: pg.createdAt(),
|
|
1647
|
+
* title: t.string(),
|
|
1648
|
+
* content: t.string(),
|
|
1649
|
+
* authorId: pg.references(t.uint(), () => user.id),
|
|
1650
|
+
* }),
|
|
1651
|
+
* });
|
|
1652
|
+
*
|
|
1653
|
+
* class Database {
|
|
1654
|
+
* users = $repository(user);
|
|
1655
|
+
* posts = $repository(post);
|
|
1656
|
+
* }
|
|
1657
|
+
*
|
|
1658
|
+
* const alepha = Alepha.create()
|
|
1659
|
+
* .with(AlephaPostgres)
|
|
1660
|
+
* .with(Database);
|
|
1661
|
+
*
|
|
1662
|
+
* run(alepha);
|
|
1663
|
+
* ```
|
|
1664
|
+
*
|
|
1665
|
+
* **Repository Operations:**
|
|
1666
|
+
* ```ts
|
|
1667
|
+
* class UserService {
|
|
1668
|
+
* users = $repository(user);
|
|
1669
|
+
*
|
|
1670
|
+
* async createUser(userData: { name: string; email: string }) {
|
|
1671
|
+
* return await this.users.create(userData);
|
|
1672
|
+
* }
|
|
1673
|
+
*
|
|
1674
|
+
* async findUserByEmail(email: string) {
|
|
1675
|
+
* return await this.users.findFirst({
|
|
1676
|
+
* where: { email },
|
|
1677
|
+
* });
|
|
1678
|
+
* }
|
|
1679
|
+
*
|
|
1680
|
+
* async getUsersWithPosts() {
|
|
1681
|
+
* return await this.users.find({
|
|
1682
|
+
* with: { posts: true },
|
|
1683
|
+
* limit: 10,
|
|
1684
|
+
* });
|
|
1685
|
+
* }
|
|
1686
|
+
*
|
|
1687
|
+
* async updateUser(id: number, updates: Partial<{ name: string; age: number }>) {
|
|
1688
|
+
* return await this.users.update(id, updates);
|
|
1689
|
+
* }
|
|
1690
|
+
* }
|
|
1691
|
+
* ```
|
|
1692
|
+
*
|
|
1693
|
+
* **Advanced Database Operations:**
|
|
1694
|
+
* ```ts
|
|
1695
|
+
* import { $db, $transaction } from "alepha/postgres";
|
|
1696
|
+
*
|
|
1697
|
+
* class AdvancedDatabase {
|
|
1698
|
+
* db = $db({
|
|
1699
|
+
* entities: { user, post },
|
|
1700
|
+
* });
|
|
1701
|
+
*
|
|
1702
|
+
* createUserWithPost = $transaction(async () => {
|
|
1703
|
+
* const newUser = await this.db.users.create({
|
|
1704
|
+
* name: "John Doe",
|
|
1705
|
+
* email: "john@example.com",
|
|
1706
|
+
* });
|
|
1707
|
+
*
|
|
1708
|
+
* const newPost = await this.db.posts.create({
|
|
1709
|
+
* title: "My First Post",
|
|
1710
|
+
* content: "Hello world!",
|
|
1711
|
+
* authorId: newUser.id,
|
|
1712
|
+
* });
|
|
1713
|
+
*
|
|
1714
|
+
* return { user: newUser, post: newPost };
|
|
1715
|
+
* });
|
|
1716
|
+
*
|
|
1717
|
+
* async rawQuery() {
|
|
1718
|
+
* // Execute raw SQL queries
|
|
1719
|
+
* return await this.db.execute(sql`
|
|
1720
|
+
* SELECT users.name, COUNT(posts.id) as post_count
|
|
1721
|
+
* FROM users
|
|
1722
|
+
* LEFT JOIN posts ON users.id = posts.author_id
|
|
1723
|
+
* GROUP BY users.id, users.name
|
|
1724
|
+
* `);
|
|
1725
|
+
* }
|
|
1726
|
+
* }
|
|
1727
|
+
* ```
|
|
1728
|
+
*
|
|
1729
|
+
* @see {@link $entity}
|
|
1730
|
+
* @see {@link $repository}
|
|
1731
|
+
* @see {@link $db}
|
|
1732
|
+
* @see {@link $transaction}
|
|
1733
|
+
* @module alepha.postgres
|
|
1734
|
+
*/
|
|
1603
1735
|
declare class AlephaPostgres implements Module {
|
|
1604
1736
|
readonly name = "alepha.postgres";
|
|
1605
1737
|
readonly env: {
|
package/queue/redis.d.ts
CHANGED
|
@@ -17,8 +17,6 @@ declare class RedisQueueProvider implements QueueProvider {
|
|
|
17
17
|
//#region src/index.d.ts
|
|
18
18
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
19
19
|
/**
|
|
20
|
-
* Alepha Queue Redis Module
|
|
21
|
-
*
|
|
22
20
|
* Plugin for Alepha Queue that provides Redis queue capabilities.
|
|
23
21
|
*
|
|
24
22
|
* @see {@link RedisQueueProvider}
|
package/queue.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare abstract class QueueProvider {
|
|
|
31
31
|
//#region src/descriptors/$queue.d.ts
|
|
32
32
|
declare const KEY$1 = "QUEUE";
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Create a new queue.
|
|
35
35
|
*/
|
|
36
36
|
declare const $queue: {
|
|
37
37
|
<T extends QueueMessageSchema>(options: QueueDescriptorOptions<T>): QueueDescriptor<T>;
|
|
@@ -192,11 +192,97 @@ declare class QueueDescriptorProvider {
|
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region src/index.d.ts
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
195
|
+
* Provides asynchronous message queuing and processing capabilities through declarative queue descriptors.
|
|
196
196
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
197
|
+
* The queue module enables reliable background job processing and message passing using the `$queue` descriptor
|
|
198
|
+
* on class properties. It supports schema validation, automatic retries, and multiple queue backends for
|
|
199
|
+
* building scalable, decoupled applications with robust error handling.
|
|
200
|
+
*
|
|
201
|
+
* **Key Features:**
|
|
202
|
+
* - Declarative queue definition with `$queue` descriptor
|
|
203
|
+
* - Schema validation for message payloads and headers
|
|
204
|
+
* - Built-in message handlers with automatic processing
|
|
205
|
+
* - Multiple queue backends (memory, Redis, etc.)
|
|
206
|
+
* - Type-safe message publishing and consumption
|
|
207
|
+
* - Automatic retry mechanisms and error handling
|
|
208
|
+
*
|
|
209
|
+
* **Basic Usage:**
|
|
210
|
+
* ```ts
|
|
211
|
+
* import { Alepha, run, t } from "alepha";
|
|
212
|
+
* import { AlephaQueue, $queue } from "alepha/queue";
|
|
213
|
+
*
|
|
214
|
+
* class EmailService {
|
|
215
|
+
* sendEmail = $queue({
|
|
216
|
+
* name: "emails",
|
|
217
|
+
* schema: {
|
|
218
|
+
* payload: t.object({
|
|
219
|
+
* to: t.string(),
|
|
220
|
+
* subject: t.string(),
|
|
221
|
+
* body: t.string(),
|
|
222
|
+
* }),
|
|
223
|
+
* },
|
|
224
|
+
* handler: async ({ payload }) => {
|
|
225
|
+
* // Process the email
|
|
226
|
+
* await sendEmailViaProvider(payload.to, payload.subject, payload.body);
|
|
227
|
+
* console.log(`Email sent to ${payload.to}`);
|
|
228
|
+
* },
|
|
229
|
+
* });
|
|
230
|
+
* }
|
|
231
|
+
*
|
|
232
|
+
* const alepha = Alepha.create()
|
|
233
|
+
* .with(AlephaQueue)
|
|
234
|
+
* .with(EmailService);
|
|
235
|
+
*
|
|
236
|
+
* run(alepha);
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* **Queue Operations:**
|
|
240
|
+
* ```ts
|
|
241
|
+
* class NotificationService {
|
|
242
|
+
* notifications = $queue({
|
|
243
|
+
* name: "notifications",
|
|
244
|
+
* provider: "memory",
|
|
245
|
+
* schema: {
|
|
246
|
+
* payload: t.object({
|
|
247
|
+
* userId: t.string(),
|
|
248
|
+
* message: t.string(),
|
|
249
|
+
* type: t.union([t.literal("info"), t.literal("warning"), t.literal("error")]),
|
|
250
|
+
* }),
|
|
251
|
+
* },
|
|
252
|
+
* handler: async ({ payload }) => {
|
|
253
|
+
* await sendNotification(payload.userId, payload.message, payload.type);
|
|
254
|
+
* },
|
|
255
|
+
* });
|
|
256
|
+
*
|
|
257
|
+
* async notifyUser(userId: string, message: string, type: "info" | "warning" | "error") {
|
|
258
|
+
* // Push message to queue
|
|
259
|
+
* await this.notifications.push({ userId, message, type });
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* **Batch Processing:**
|
|
265
|
+
* ```ts
|
|
266
|
+
* class BatchProcessor {
|
|
267
|
+
* processTasks = $queue({
|
|
268
|
+
* name: "batch-tasks",
|
|
269
|
+
* schema: {
|
|
270
|
+
* payload: t.object({
|
|
271
|
+
* taskId: t.string(),
|
|
272
|
+
* data: t.any(),
|
|
273
|
+
* }),
|
|
274
|
+
* },
|
|
275
|
+
* handler: async ({ payload }) => {
|
|
276
|
+
* await processTask(payload.taskId, payload.data);
|
|
277
|
+
* },
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* async submitBatch(tasks: Array<{ taskId: string; data: any }>) {
|
|
281
|
+
* // Push multiple messages at once
|
|
282
|
+
* await this.processTasks.push(...tasks);
|
|
283
|
+
* }
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
200
286
|
*
|
|
201
287
|
* @see {@link $queue}
|
|
202
288
|
* @see {@link $consumer}
|
package/react/auth.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ import * as _sinclair_typebox2 from "@sinclair/typebox";
|
|
|
12
12
|
|
|
13
13
|
//#region src/descriptors/$auth.d.ts
|
|
14
14
|
declare const KEY = "AUTH";
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
declare const $auth: {
|
|
19
|
+
(options: AuthDescriptorOptions): AuthDescriptor;
|
|
20
|
+
[KIND]: string;
|
|
21
|
+
};
|
|
15
22
|
type AccessToken = string;
|
|
16
23
|
interface AuthDescriptorOptions {
|
|
17
24
|
name?: string;
|
|
@@ -30,10 +37,6 @@ interface AuthDescriptor {
|
|
|
30
37
|
[OPTIONS]: AuthDescriptorOptions;
|
|
31
38
|
jwks: () => string;
|
|
32
39
|
}
|
|
33
|
-
declare const $auth: {
|
|
34
|
-
(options: AuthDescriptorOptions): AuthDescriptor;
|
|
35
|
-
[KIND]: string;
|
|
36
|
-
};
|
|
37
40
|
//#endregion
|
|
38
41
|
//#region src/providers/ReactAuthProvider.d.ts
|
|
39
42
|
declare class ReactAuthProvider {
|
|
@@ -185,8 +188,6 @@ declare module "alepha/react" {
|
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
/**
|
|
188
|
-
* Alepha React Authentication Module
|
|
189
|
-
*
|
|
190
191
|
* The ReactAuthModule provides authentication services for React applications.
|
|
191
192
|
*
|
|
192
193
|
* @see {@link ReactAuthProvider}
|