alepha 0.13.0 → 0.13.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/dist/api-jobs/index.d.ts +26 -26
- package/dist/api-users/index.d.ts +1 -1
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +3 -11
- package/dist/cli/index.js +106 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/email/index.js +71 -73
- package/dist/email/index.js.map +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/retry/index.d.ts +1 -1
- package/dist/retry/index.js +2 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/security/index.d.ts +28 -28
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server-health/index.d.ts +17 -17
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-security/index.d.ts +9 -9
- package/dist/vite/index.js +4 -5
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/package.json +52 -103
- package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +65 -57
- package/src/cli/commands/VerifyCommands.ts +1 -1
- package/src/cli/services/ProjectUtils.ts +44 -38
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/retry/descriptors/$retry.ts +5 -3
- package/src/server/providers/NodeHttpServerProvider.ts +1 -1
- package/src/vite/helpers/boot.ts +3 -3
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs +0 -2264
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
|
@@ -1,4740 +0,0 @@
|
|
|
1
|
-
import * as alepha1 from "alepha";
|
|
2
|
-
import { Alepha, AlephaError, Async, Descriptor, FileLike, Page, PageQuery, Static, StaticEncode, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
|
|
3
|
-
import * as alepha_orm198 from "alepha/orm";
|
|
4
|
-
import { Page as Page$1, Repository } from "alepha/orm";
|
|
5
|
-
import * as alepha_server0 from "alepha/server";
|
|
6
|
-
import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchOptions, FetchResponse, HttpClient, Ok, RequestConfigSchema, ServerHandler, ServerRequest, ServerRequestConfigEntry, ServerResponseBody, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
|
|
7
|
-
import * as alepha_logger1 from "alepha/logger";
|
|
8
|
-
import * as alepha_bucket0 from "alepha/bucket";
|
|
9
|
-
import { BucketDescriptor } from "alepha/bucket";
|
|
10
|
-
import { AccessTokenResponse, CryptoProvider, RealmDescriptor, RealmDescriptorOptions, SecurityProvider, ServiceAccountDescriptor, UserAccount, UserAccountToken } from "alepha/security";
|
|
11
|
-
import * as alepha_retry0 from "alepha/retry";
|
|
12
|
-
import * as alepha_cache0 from "alepha/cache";
|
|
13
|
-
import * as drizzle_orm0 from "drizzle-orm";
|
|
14
|
-
import { BuildExtraConfigColumns, SQL, SQLWrapper } from "drizzle-orm";
|
|
15
|
-
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
16
|
-
import { LockConfig, LockStrength, PgColumn, PgColumnBuilderBase, PgDatabase, PgInsertValue, PgSelectBase, PgSequenceOptions, PgTableExtraConfigValue, PgTableWithColumns, PgTransaction, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
17
|
-
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
18
|
-
import { PgTransactionConfig } from "drizzle-orm/pg-core/session";
|
|
19
|
-
import * as DrizzleKit from "drizzle-kit/api";
|
|
20
|
-
import "alepha/lock";
|
|
21
|
-
import * as alepha_batch0 from "alepha/batch";
|
|
22
|
-
import { EmailProvider } from "alepha/email";
|
|
23
|
-
import "alepha/queue";
|
|
24
|
-
import { Configuration } from "openid-client";
|
|
25
|
-
import { FileSystemProvider } from "alepha/file";
|
|
26
|
-
|
|
27
|
-
//#region src/api-users/atoms/realmAuthSettingsAtom.d.ts
|
|
28
|
-
declare const realmAuthSettingsAtom: alepha1.Atom<alepha1.TObject<{
|
|
29
|
-
registrationAllowed: alepha1.TBoolean;
|
|
30
|
-
emailEnabled: alepha1.TBoolean;
|
|
31
|
-
emailRequired: alepha1.TBoolean;
|
|
32
|
-
usernameEnabled: alepha1.TBoolean;
|
|
33
|
-
usernameRequired: alepha1.TBoolean;
|
|
34
|
-
phoneEnabled: alepha1.TBoolean;
|
|
35
|
-
phoneRequired: alepha1.TBoolean;
|
|
36
|
-
verifyEmailRequired: alepha1.TBoolean;
|
|
37
|
-
verifyPhoneRequired: alepha1.TBoolean;
|
|
38
|
-
firstNameLastNameEnabled: alepha1.TBoolean;
|
|
39
|
-
firstNameLastNameRequired: alepha1.TBoolean;
|
|
40
|
-
resetPasswordAllowed: alepha1.TBoolean;
|
|
41
|
-
passwordPolicy: alepha1.TObject<{
|
|
42
|
-
minLength: alepha1.TInteger;
|
|
43
|
-
requireUppercase: alepha1.TBoolean;
|
|
44
|
-
requireLowercase: alepha1.TBoolean;
|
|
45
|
-
requireNumbers: alepha1.TBoolean;
|
|
46
|
-
requireSpecialCharacters: alepha1.TBoolean;
|
|
47
|
-
}>;
|
|
48
|
-
}>, "alepha.api.users.realmAuthSettings">;
|
|
49
|
-
type RealmAuthSettings = Static<typeof realmAuthSettingsAtom.schema>;
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/api-users/entities/identities.d.ts
|
|
52
|
-
declare const identities: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
53
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
54
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
55
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
56
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
57
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
58
|
-
password: alepha1.TOptional<alepha1.TString>;
|
|
59
|
-
provider: alepha1.TString;
|
|
60
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
61
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
62
|
-
}>>;
|
|
63
|
-
type IdentityEntity = Static<typeof identities.schema>;
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/api-users/entities/sessions.d.ts
|
|
66
|
-
declare const sessions: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
67
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
68
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
69
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
70
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
71
|
-
refreshToken: alepha1.TString;
|
|
72
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
73
|
-
expiresAt: alepha1.TString;
|
|
74
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
75
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
76
|
-
os: alepha1.TString;
|
|
77
|
-
browser: alepha1.TString;
|
|
78
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
79
|
-
}>>;
|
|
80
|
-
}>>;
|
|
81
|
-
type SessionEntity = Static<typeof sessions.schema>;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/api-users/entities/users.d.ts
|
|
84
|
-
declare const DEFAULT_USER_REALM_NAME = "default";
|
|
85
|
-
declare const users: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
86
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
87
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
88
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
89
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
90
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
91
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
92
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
93
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
94
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
95
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
96
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
97
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
98
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
99
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
100
|
-
}>>;
|
|
101
|
-
type UserEntity = Static<typeof users.schema>;
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region src/api-users/providers/UserRealmProvider.d.ts
|
|
104
|
-
interface UserRealmRepositories {
|
|
105
|
-
identities: Repository<typeof identities.schema>;
|
|
106
|
-
sessions: Repository<typeof sessions.schema>;
|
|
107
|
-
users: Repository<typeof users.schema>;
|
|
108
|
-
}
|
|
109
|
-
interface UserRealm {
|
|
110
|
-
name: string;
|
|
111
|
-
repositories: UserRealmRepositories;
|
|
112
|
-
settings: RealmAuthSettings;
|
|
113
|
-
}
|
|
114
|
-
declare class UserRealmProvider {
|
|
115
|
-
protected readonly alepha: Alepha;
|
|
116
|
-
protected readonly defaultIdentities: Repository<alepha1.TObject<{
|
|
117
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
118
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
119
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
120
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
121
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
122
|
-
password: alepha1.TOptional<alepha1.TString>;
|
|
123
|
-
provider: alepha1.TString;
|
|
124
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
125
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
126
|
-
}>>;
|
|
127
|
-
protected readonly defaultSessions: Repository<alepha1.TObject<{
|
|
128
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
129
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
130
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
131
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
132
|
-
refreshToken: alepha1.TString;
|
|
133
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
134
|
-
expiresAt: alepha1.TString;
|
|
135
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
136
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
137
|
-
os: alepha1.TString;
|
|
138
|
-
browser: alepha1.TString;
|
|
139
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
140
|
-
}>>;
|
|
141
|
-
}>>;
|
|
142
|
-
protected readonly defaultUsers: Repository<alepha1.TObject<{
|
|
143
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
144
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
145
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
146
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
147
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
148
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
149
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
150
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
151
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
152
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
153
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
154
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
155
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
156
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
157
|
-
}>>;
|
|
158
|
-
protected realms: Map<string, UserRealm>;
|
|
159
|
-
avatars: alepha_bucket0.BucketDescriptor;
|
|
160
|
-
protected readonly onConfigure: alepha1.HookDescriptor<"configure">;
|
|
161
|
-
register(userRealmName: string, userRealmOptions?: UserRealmOptions): void;
|
|
162
|
-
/**
|
|
163
|
-
* Gets a registered realm by name, auto-creating default if needed.
|
|
164
|
-
*/
|
|
165
|
-
getRealm(userRealmName?: string): UserRealm;
|
|
166
|
-
identityRepository(userRealmName?: string): Repository<typeof identities.schema>;
|
|
167
|
-
sessionRepository(userRealmName?: string): Repository<typeof sessions.schema>;
|
|
168
|
-
userRepository(userRealmName?: string): Repository<typeof users.schema>;
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/api-users/schemas/identityQuerySchema.d.ts
|
|
172
|
-
declare const identityQuerySchema: alepha1.TObject<{
|
|
173
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
174
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
175
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
176
|
-
userId: alepha1.TOptional<alepha1.TString>;
|
|
177
|
-
provider: alepha1.TOptional<alepha1.TString>;
|
|
178
|
-
}>;
|
|
179
|
-
type IdentityQuery = Static<typeof identityQuerySchema>;
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/api-users/services/IdentityService.d.ts
|
|
182
|
-
declare class IdentityService {
|
|
183
|
-
protected readonly log: alepha_logger1.Logger;
|
|
184
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
185
|
-
identities(userRealmName?: string): alepha_orm198.Repository<alepha1.TObject<{
|
|
186
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
187
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
188
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
189
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
190
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
191
|
-
password: alepha1.TOptional<alepha1.TString>;
|
|
192
|
-
provider: alepha1.TString;
|
|
193
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
194
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
195
|
-
}>>;
|
|
196
|
-
/**
|
|
197
|
-
* Find identities with pagination and filtering.
|
|
198
|
-
*/
|
|
199
|
-
findIdentities(q?: IdentityQuery, userRealmName?: string): Promise<Page$1<IdentityEntity>>;
|
|
200
|
-
/**
|
|
201
|
-
* Get an identity by ID.
|
|
202
|
-
*/
|
|
203
|
-
getIdentityById(id: string, userRealmName?: string): Promise<IdentityEntity>;
|
|
204
|
-
/**
|
|
205
|
-
* Delete an identity by ID.
|
|
206
|
-
*/
|
|
207
|
-
deleteIdentity(id: string, userRealmName?: string): Promise<void>;
|
|
208
|
-
}
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/api-users/controllers/IdentityController.d.ts
|
|
211
|
-
declare class IdentityController {
|
|
212
|
-
protected readonly url = "/identities";
|
|
213
|
-
protected readonly group = "identities";
|
|
214
|
-
protected readonly identityService: IdentityService;
|
|
215
|
-
/**
|
|
216
|
-
* Find identities with pagination and filtering.
|
|
217
|
-
*/
|
|
218
|
-
readonly findIdentities: alepha_server0.ActionDescriptorFn<{
|
|
219
|
-
query: alepha1.TObject<{
|
|
220
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
221
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
222
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
223
|
-
userId: alepha1.TOptional<alepha1.TString>;
|
|
224
|
-
provider: alepha1.TOptional<alepha1.TString>;
|
|
225
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
226
|
-
}>;
|
|
227
|
-
response: alepha1.TPage<alepha1.TObject<{
|
|
228
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
229
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
230
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
231
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
232
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
233
|
-
provider: alepha1.TString;
|
|
234
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
235
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
236
|
-
}>>;
|
|
237
|
-
}>;
|
|
238
|
-
/**
|
|
239
|
-
* Get an identity by ID.
|
|
240
|
-
*/
|
|
241
|
-
readonly getIdentity: alepha_server0.ActionDescriptorFn<{
|
|
242
|
-
params: alepha1.TObject<{
|
|
243
|
-
id: alepha1.TString;
|
|
244
|
-
}>;
|
|
245
|
-
query: alepha1.TObject<{
|
|
246
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
247
|
-
}>;
|
|
248
|
-
response: alepha1.TObject<{
|
|
249
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
250
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
251
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
252
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
253
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
254
|
-
provider: alepha1.TString;
|
|
255
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
256
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
257
|
-
}>;
|
|
258
|
-
}>;
|
|
259
|
-
/**
|
|
260
|
-
* Delete an identity.
|
|
261
|
-
*/
|
|
262
|
-
readonly deleteIdentity: alepha_server0.ActionDescriptorFn<{
|
|
263
|
-
params: alepha1.TObject<{
|
|
264
|
-
id: alepha1.TString;
|
|
265
|
-
}>;
|
|
266
|
-
query: alepha1.TObject<{
|
|
267
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
268
|
-
}>;
|
|
269
|
-
response: alepha1.TObject<{
|
|
270
|
-
ok: alepha1.TBoolean;
|
|
271
|
-
id: alepha1.TOptional<alepha1.TUnion<[alepha1.TString, alepha1.TInteger]>>;
|
|
272
|
-
count: alepha1.TOptional<alepha1.TNumber>;
|
|
273
|
-
}>;
|
|
274
|
-
}>;
|
|
275
|
-
}
|
|
276
|
-
//#endregion
|
|
277
|
-
//#region src/api-users/schemas/sessionQuerySchema.d.ts
|
|
278
|
-
declare const sessionQuerySchema: alepha1.TObject<{
|
|
279
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
280
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
281
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
282
|
-
userId: alepha1.TOptional<alepha1.TString>;
|
|
283
|
-
}>;
|
|
284
|
-
type SessionQuery = Static<typeof sessionQuerySchema>;
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region src/api-users/services/SessionCrudService.d.ts
|
|
287
|
-
declare class SessionCrudService {
|
|
288
|
-
protected readonly log: alepha_logger1.Logger;
|
|
289
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
290
|
-
sessions(userRealmName?: string): alepha_orm198.Repository<alepha1.TObject<{
|
|
291
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
292
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
293
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
294
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
295
|
-
refreshToken: alepha1.TString;
|
|
296
|
-
userId: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_REF>;
|
|
297
|
-
expiresAt: alepha1.TString;
|
|
298
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
299
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
300
|
-
os: alepha1.TString;
|
|
301
|
-
browser: alepha1.TString;
|
|
302
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
303
|
-
}>>;
|
|
304
|
-
}>>;
|
|
305
|
-
/**
|
|
306
|
-
* Find sessions with pagination and filtering.
|
|
307
|
-
*/
|
|
308
|
-
findSessions(q?: SessionQuery, userRealmName?: string): Promise<Page$1<SessionEntity>>;
|
|
309
|
-
/**
|
|
310
|
-
* Get a session by ID.
|
|
311
|
-
*/
|
|
312
|
-
getSessionById(id: string, userRealmName?: string): Promise<SessionEntity>;
|
|
313
|
-
/**
|
|
314
|
-
* Delete a session by ID.
|
|
315
|
-
*/
|
|
316
|
-
deleteSession(id: string, userRealmName?: string): Promise<void>;
|
|
317
|
-
}
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/api-users/controllers/SessionController.d.ts
|
|
320
|
-
declare class SessionController {
|
|
321
|
-
protected readonly url = "/sessions";
|
|
322
|
-
protected readonly group = "sessions";
|
|
323
|
-
protected readonly sessionService: SessionCrudService;
|
|
324
|
-
/**
|
|
325
|
-
* Find sessions with pagination and filtering.
|
|
326
|
-
*/
|
|
327
|
-
readonly findSessions: alepha_server0.ActionDescriptorFn<{
|
|
328
|
-
query: alepha1.TObject<{
|
|
329
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
330
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
331
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
332
|
-
userId: alepha1.TOptional<alepha1.TString>;
|
|
333
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
334
|
-
}>;
|
|
335
|
-
response: alepha1.TPage<alepha1.TObject<{
|
|
336
|
-
id: alepha1.TString;
|
|
337
|
-
version: alepha1.TNumber;
|
|
338
|
-
createdAt: alepha1.TString;
|
|
339
|
-
updatedAt: alepha1.TString;
|
|
340
|
-
refreshToken: alepha1.TString;
|
|
341
|
-
userId: alepha1.TString;
|
|
342
|
-
expiresAt: alepha1.TString;
|
|
343
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
344
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
345
|
-
os: alepha1.TString;
|
|
346
|
-
browser: alepha1.TString;
|
|
347
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
348
|
-
}>>;
|
|
349
|
-
}>>;
|
|
350
|
-
}>;
|
|
351
|
-
/**
|
|
352
|
-
* Get a session by ID.
|
|
353
|
-
*/
|
|
354
|
-
readonly getSession: alepha_server0.ActionDescriptorFn<{
|
|
355
|
-
params: alepha1.TObject<{
|
|
356
|
-
id: alepha1.TString;
|
|
357
|
-
}>;
|
|
358
|
-
query: alepha1.TObject<{
|
|
359
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
360
|
-
}>;
|
|
361
|
-
response: alepha1.TObject<{
|
|
362
|
-
id: alepha1.TString;
|
|
363
|
-
version: alepha1.TNumber;
|
|
364
|
-
createdAt: alepha1.TString;
|
|
365
|
-
updatedAt: alepha1.TString;
|
|
366
|
-
refreshToken: alepha1.TString;
|
|
367
|
-
userId: alepha1.TString;
|
|
368
|
-
expiresAt: alepha1.TString;
|
|
369
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
370
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
371
|
-
os: alepha1.TString;
|
|
372
|
-
browser: alepha1.TString;
|
|
373
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
374
|
-
}>>;
|
|
375
|
-
}>;
|
|
376
|
-
}>;
|
|
377
|
-
/**
|
|
378
|
-
* Delete a session.
|
|
379
|
-
*/
|
|
380
|
-
readonly deleteSession: alepha_server0.ActionDescriptorFn<{
|
|
381
|
-
params: alepha1.TObject<{
|
|
382
|
-
id: alepha1.TString;
|
|
383
|
-
}>;
|
|
384
|
-
query: alepha1.TObject<{
|
|
385
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
386
|
-
}>;
|
|
387
|
-
response: alepha1.TObject<{
|
|
388
|
-
ok: alepha1.TBoolean;
|
|
389
|
-
id: alepha1.TOptional<alepha1.TUnion<[alepha1.TString, alepha1.TInteger]>>;
|
|
390
|
-
count: alepha1.TOptional<alepha1.TNumber>;
|
|
391
|
-
}>;
|
|
392
|
-
}>;
|
|
393
|
-
}
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region src/server-security/providers/ServerBasicAuthProvider.d.ts
|
|
396
|
-
interface BasicAuthOptions {
|
|
397
|
-
username: string;
|
|
398
|
-
password: string;
|
|
399
|
-
}
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region src/server-security/providers/ServerSecurityProvider.d.ts
|
|
402
|
-
type ServerRouteSecure = {
|
|
403
|
-
realm?: string;
|
|
404
|
-
basic?: BasicAuthOptions;
|
|
405
|
-
};
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/server-security/index.d.ts
|
|
408
|
-
declare module "alepha" {
|
|
409
|
-
interface State {
|
|
410
|
-
/**
|
|
411
|
-
* Real (or fake) user account, used for internal actions.
|
|
412
|
-
*
|
|
413
|
-
* If you define this, you assume that all actions are executed by this user by default.
|
|
414
|
-
* > To force a different user, you need to pass it explicitly in the options.
|
|
415
|
-
*/
|
|
416
|
-
"alepha.server.security.system.user"?: UserAccountToken;
|
|
417
|
-
/**
|
|
418
|
-
* The authenticated user account attached to the server request state.
|
|
419
|
-
*
|
|
420
|
-
* @internal
|
|
421
|
-
*/
|
|
422
|
-
"alepha.server.request.user"?: UserAccount;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
declare module "alepha/server" {
|
|
426
|
-
interface ServerRequest<TConfig> {
|
|
427
|
-
user?: UserAccountToken;
|
|
428
|
-
}
|
|
429
|
-
interface ServerActionRequest<TConfig> {
|
|
430
|
-
user: UserAccountToken;
|
|
431
|
-
}
|
|
432
|
-
interface ServerRoute {
|
|
433
|
-
/**
|
|
434
|
-
* If true, the route will be protected by the security provider.
|
|
435
|
-
* All actions are secure by default, but you can disable it for specific actions.
|
|
436
|
-
*/
|
|
437
|
-
secure?: boolean | ServerRouteSecure;
|
|
438
|
-
}
|
|
439
|
-
interface ClientRequestOptions extends FetchOptions {
|
|
440
|
-
/**
|
|
441
|
-
* Forward user from the previous request.
|
|
442
|
-
* If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
|
|
443
|
-
* If "context", use the user from the current context (e.g. request).
|
|
444
|
-
*
|
|
445
|
-
* @default "system" if provided, else "context" if available.
|
|
446
|
-
*/
|
|
447
|
-
user?: UserAccountToken | "system" | "context";
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
|
|
452
|
-
*
|
|
453
|
-
* By default, all $action will be guarded by a permission check.
|
|
454
|
-
*
|
|
455
|
-
* @see {@link ServerSecurityProvider}
|
|
456
|
-
* @module alepha.server.security
|
|
457
|
-
*/
|
|
458
|
-
//#endregion
|
|
459
|
-
//#region src/server-links/schemas/apiLinksResponseSchema.d.ts
|
|
460
|
-
declare const apiLinkSchema: alepha1.TObject<{
|
|
461
|
-
name: alepha1.TString;
|
|
462
|
-
group: alepha1.TOptional<alepha1.TString>;
|
|
463
|
-
path: alepha1.TString;
|
|
464
|
-
method: alepha1.TOptional<alepha1.TString>;
|
|
465
|
-
requestBodyType: alepha1.TOptional<alepha1.TString>;
|
|
466
|
-
service: alepha1.TOptional<alepha1.TString>;
|
|
467
|
-
}>;
|
|
468
|
-
declare const apiLinksResponseSchema: alepha1.TObject<{
|
|
469
|
-
prefix: alepha1.TOptional<alepha1.TString>;
|
|
470
|
-
links: alepha1.TArray<alepha1.TObject<{
|
|
471
|
-
name: alepha1.TString;
|
|
472
|
-
group: alepha1.TOptional<alepha1.TString>;
|
|
473
|
-
path: alepha1.TString;
|
|
474
|
-
method: alepha1.TOptional<alepha1.TString>;
|
|
475
|
-
requestBodyType: alepha1.TOptional<alepha1.TString>;
|
|
476
|
-
service: alepha1.TOptional<alepha1.TString>;
|
|
477
|
-
}>>;
|
|
478
|
-
}>;
|
|
479
|
-
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
480
|
-
type ApiLink = Static<typeof apiLinkSchema>;
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/server-links/providers/LinkProvider.d.ts
|
|
483
|
-
/**
|
|
484
|
-
* Browser, SSR friendly, service to handle links.
|
|
485
|
-
*/
|
|
486
|
-
declare class LinkProvider {
|
|
487
|
-
static path: {
|
|
488
|
-
apiLinks: string;
|
|
489
|
-
apiSchema: string;
|
|
490
|
-
};
|
|
491
|
-
protected readonly log: alepha_logger1.Logger;
|
|
492
|
-
protected readonly alepha: Alepha;
|
|
493
|
-
protected readonly httpClient: HttpClient;
|
|
494
|
-
protected serverLinks: Array<HttpClientLink>;
|
|
495
|
-
/**
|
|
496
|
-
* Get applicative links registered on the server.
|
|
497
|
-
* This does not include lazy-loaded remote links.
|
|
498
|
-
*/
|
|
499
|
-
getServerLinks(): HttpClientLink[];
|
|
500
|
-
/**
|
|
501
|
-
* Register a new link for the application.
|
|
502
|
-
*/
|
|
503
|
-
registerLink(link: HttpClientLink): void;
|
|
504
|
-
get links(): HttpClientLink[];
|
|
505
|
-
/**
|
|
506
|
-
* Force browser to refresh links from the server.
|
|
507
|
-
*/
|
|
508
|
-
fetchLinks(): Promise<HttpClientLink[]>;
|
|
509
|
-
/**
|
|
510
|
-
* Create a virtual client that can be used to call actions.
|
|
511
|
-
*
|
|
512
|
-
* Use js Proxy under the hood.
|
|
513
|
-
*/
|
|
514
|
-
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
515
|
-
/**
|
|
516
|
-
* Check if a link with the given name exists.
|
|
517
|
-
* @param name
|
|
518
|
-
*/
|
|
519
|
-
can(name: string): boolean;
|
|
520
|
-
/**
|
|
521
|
-
* Resolve a link by its name and call it.
|
|
522
|
-
* - If link is local, it will call the local handler.
|
|
523
|
-
* - If link is remote, it will make a fetch request to the remote server.
|
|
524
|
-
*/
|
|
525
|
-
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
526
|
-
protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
|
|
527
|
-
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
528
|
-
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
529
|
-
}
|
|
530
|
-
interface HttpClientLink extends ApiLink {
|
|
531
|
-
secured?: boolean | ServerRouteSecure;
|
|
532
|
-
prefix?: string;
|
|
533
|
-
host?: string;
|
|
534
|
-
service?: string;
|
|
535
|
-
schema?: RequestConfigSchema;
|
|
536
|
-
handler?: (request: ServerRequest, options: ClientRequestOptions) => Async<ServerResponseBody>;
|
|
537
|
-
}
|
|
538
|
-
interface ClientScope {
|
|
539
|
-
group?: string;
|
|
540
|
-
service?: string;
|
|
541
|
-
hostname?: string;
|
|
542
|
-
}
|
|
543
|
-
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
|
|
544
|
-
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
|
|
545
|
-
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
546
|
-
can: () => boolean;
|
|
547
|
-
}
|
|
548
|
-
//#endregion
|
|
549
|
-
//#region src/server-proxy/descriptors/$proxy.d.ts
|
|
550
|
-
type ProxyDescriptorOptions = {
|
|
551
|
-
/**
|
|
552
|
-
* Path pattern to match for proxying requests.
|
|
553
|
-
*
|
|
554
|
-
* Supports wildcards and path parameters:
|
|
555
|
-
* - `/api/*` - Matches all paths starting with `/api/`
|
|
556
|
-
* - `/api/v1/*` - Matches all paths starting with `/api/v1/`
|
|
557
|
-
* - `/users/:id` - Matches `/users/123`, `/users/abc`, etc.
|
|
558
|
-
*
|
|
559
|
-
* @example "/api/*"
|
|
560
|
-
* @example "/secure/admin/*"
|
|
561
|
-
* @example "/users/:id/posts"
|
|
562
|
-
*/
|
|
563
|
-
path: string;
|
|
564
|
-
/**
|
|
565
|
-
* Target URL to which matching requests should be forwarded.
|
|
566
|
-
*
|
|
567
|
-
* Can be either:
|
|
568
|
-
* - **Static string**: A fixed URL like `"https://api.example.com"`
|
|
569
|
-
* - **Dynamic function**: A function that returns the URL, enabling runtime target resolution
|
|
570
|
-
*
|
|
571
|
-
* The target URL will be combined with the remaining path from the original request.
|
|
572
|
-
*
|
|
573
|
-
* @example "https://api.example.com"
|
|
574
|
-
* @example () => process.env.API_URL || "http://localhost:3001"
|
|
575
|
-
*/
|
|
576
|
-
target: string | (() => string);
|
|
577
|
-
/**
|
|
578
|
-
* Whether this proxy is disabled.
|
|
579
|
-
*
|
|
580
|
-
* When `true`, requests matching the path will not be proxied and will be handled
|
|
581
|
-
* by other routes or return 404. Useful for feature toggles or conditional proxying.
|
|
582
|
-
*
|
|
583
|
-
* @default false
|
|
584
|
-
* @example !process.env.ENABLE_PROXY
|
|
585
|
-
*/
|
|
586
|
-
disabled?: boolean;
|
|
587
|
-
/**
|
|
588
|
-
* Hook called before forwarding the request to the target server.
|
|
589
|
-
*
|
|
590
|
-
* Use this to:
|
|
591
|
-
* - Add authentication headers
|
|
592
|
-
* - Modify request headers or body
|
|
593
|
-
* - Add request tracking/logging
|
|
594
|
-
* - Transform the request before forwarding
|
|
595
|
-
*
|
|
596
|
-
* @param request - The original incoming server request
|
|
597
|
-
* @param proxyRequest - The request that will be sent to the target (modifiable)
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* ```ts
|
|
601
|
-
* beforeRequest: async (request, proxyRequest) => {
|
|
602
|
-
* proxyRequest.headers = {
|
|
603
|
-
* ...proxyRequest.headers,
|
|
604
|
-
* 'Authorization': `Bearer ${await getToken()}`,
|
|
605
|
-
* 'X-Request-ID': generateRequestId()
|
|
606
|
-
* };
|
|
607
|
-
* }
|
|
608
|
-
* ```
|
|
609
|
-
*/
|
|
610
|
-
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
611
|
-
/**
|
|
612
|
-
* Hook called after receiving the response from the target server.
|
|
613
|
-
*
|
|
614
|
-
* Use this to:
|
|
615
|
-
* - Log response details for monitoring
|
|
616
|
-
* - Add custom headers to the response
|
|
617
|
-
* - Transform response data
|
|
618
|
-
* - Handle error responses
|
|
619
|
-
*
|
|
620
|
-
* @param request - The original incoming server request
|
|
621
|
-
* @param proxyResponse - The response received from the target server
|
|
622
|
-
*
|
|
623
|
-
* @example
|
|
624
|
-
* ```ts
|
|
625
|
-
* afterResponse: async (request, proxyResponse) => {
|
|
626
|
-
* console.log(`Proxy ${request.method} ${request.url} -> ${proxyResponse.status}`);
|
|
627
|
-
*
|
|
628
|
-
* if (!proxyResponse.ok) {
|
|
629
|
-
* await logError(`Proxy error: ${proxyResponse.status}`, { request, response: proxyResponse });
|
|
630
|
-
* }
|
|
631
|
-
* }
|
|
632
|
-
* ```
|
|
633
|
-
*/
|
|
634
|
-
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
635
|
-
/**
|
|
636
|
-
* Function to rewrite the URL before sending to the target server.
|
|
637
|
-
*
|
|
638
|
-
* Use this to:
|
|
639
|
-
* - Remove or add path prefixes
|
|
640
|
-
* - Transform path parameters
|
|
641
|
-
* - Modify query parameters
|
|
642
|
-
* - Change the URL structure entirely
|
|
643
|
-
*
|
|
644
|
-
* The function receives a mutable URL object and should modify it in-place.
|
|
645
|
-
*
|
|
646
|
-
* @param url - The URL object to modify (mutable)
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* ```ts
|
|
650
|
-
* // Remove /api prefix when forwarding
|
|
651
|
-
* rewrite: (url) => {
|
|
652
|
-
* url.pathname = url.pathname.replace('/api', '');
|
|
653
|
-
* }
|
|
654
|
-
* ```
|
|
655
|
-
*
|
|
656
|
-
* @example
|
|
657
|
-
* ```ts
|
|
658
|
-
* // Add version prefix
|
|
659
|
-
* rewrite: (url) => {
|
|
660
|
-
* url.pathname = `/v2${url.pathname}`;
|
|
661
|
-
* }
|
|
662
|
-
* ```
|
|
663
|
-
*/
|
|
664
|
-
rewrite?: (url: URL) => void;
|
|
665
|
-
};
|
|
666
|
-
//#endregion
|
|
667
|
-
//#region src/server-proxy/providers/ServerProxyProvider.d.ts
|
|
668
|
-
declare class ServerProxyProvider {
|
|
669
|
-
protected readonly log: alepha_logger1.Logger;
|
|
670
|
-
protected readonly routerProvider: ServerRouterProvider;
|
|
671
|
-
protected readonly alepha: Alepha;
|
|
672
|
-
protected readonly configure: alepha1.HookDescriptor<"configure">;
|
|
673
|
-
createProxy(options: ProxyDescriptorOptions): void;
|
|
674
|
-
createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
675
|
-
private getRawRequestBody;
|
|
676
|
-
}
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region src/server-links/descriptors/$remote.d.ts
|
|
679
|
-
interface RemoteDescriptorOptions {
|
|
680
|
-
/**
|
|
681
|
-
* The URL of the remote service.
|
|
682
|
-
* You can use a function to generate the URL dynamically.
|
|
683
|
-
* You probably should use $env(env) to get the URL from the environment.
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```ts
|
|
687
|
-
* import { $remote } from "alepha/server";
|
|
688
|
-
* import { $inject, t } from "alepha";
|
|
689
|
-
*
|
|
690
|
-
* class App {
|
|
691
|
-
* env = $env(t.object({
|
|
692
|
-
* REMOTE_URL: t.text({default: "http://localhost:3000"}),
|
|
693
|
-
* }));
|
|
694
|
-
* remote = $remote({
|
|
695
|
-
* url: this.env.REMOTE_URL,
|
|
696
|
-
* });
|
|
697
|
-
* }
|
|
698
|
-
* ```
|
|
699
|
-
*/
|
|
700
|
-
url: string | (() => string);
|
|
701
|
-
/**
|
|
702
|
-
* The name of the remote service.
|
|
703
|
-
*
|
|
704
|
-
* @default Member of the class containing the remote service.
|
|
705
|
-
*/
|
|
706
|
-
name?: string;
|
|
707
|
-
/**
|
|
708
|
-
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
709
|
-
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
710
|
-
*/
|
|
711
|
-
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
712
|
-
/**
|
|
713
|
-
* If true, the remote service won't be available internally, only through the proxy.
|
|
714
|
-
*/
|
|
715
|
-
noInternal: boolean;
|
|
716
|
-
}>;
|
|
717
|
-
/**
|
|
718
|
-
* For communication between the server and the remote service with a security layer.
|
|
719
|
-
* This will be used for internal communication and will not be exposed to the client.
|
|
720
|
-
*/
|
|
721
|
-
serviceAccount?: ServiceAccountDescriptor;
|
|
722
|
-
}
|
|
723
|
-
declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
|
|
724
|
-
get name(): string;
|
|
725
|
-
}
|
|
726
|
-
//#endregion
|
|
727
|
-
//#region src/server-links/providers/RemoteDescriptorProvider.d.ts
|
|
728
|
-
declare class RemoteDescriptorProvider {
|
|
729
|
-
protected readonly env: {
|
|
730
|
-
SERVER_API_PREFIX: string;
|
|
731
|
-
};
|
|
732
|
-
protected readonly alepha: Alepha;
|
|
733
|
-
protected readonly proxyProvider: ServerProxyProvider;
|
|
734
|
-
protected readonly linkProvider: LinkProvider;
|
|
735
|
-
protected readonly remotes: Array<ServerRemote>;
|
|
736
|
-
protected readonly log: alepha_logger1.Logger;
|
|
737
|
-
getRemotes(): ServerRemote[];
|
|
738
|
-
readonly configure: alepha1.HookDescriptor<"configure">;
|
|
739
|
-
readonly start: alepha1.HookDescriptor<"start">;
|
|
740
|
-
registerRemote(value: RemoteDescriptor): Promise<void>;
|
|
741
|
-
protected readonly fetchLinks: alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
742
|
-
}
|
|
743
|
-
interface FetchLinksOptions {
|
|
744
|
-
/**
|
|
745
|
-
* Name of the remote service.
|
|
746
|
-
*/
|
|
747
|
-
service: string;
|
|
748
|
-
/**
|
|
749
|
-
* URL to fetch links from.
|
|
750
|
-
*/
|
|
751
|
-
url: string;
|
|
752
|
-
/**
|
|
753
|
-
* Authorization header containing access token.
|
|
754
|
-
*/
|
|
755
|
-
authorization?: string;
|
|
756
|
-
}
|
|
757
|
-
interface ServerRemote {
|
|
758
|
-
/**
|
|
759
|
-
* URL of the remote service.
|
|
760
|
-
*/
|
|
761
|
-
url: string;
|
|
762
|
-
/**
|
|
763
|
-
* Name of the remote service.
|
|
764
|
-
*/
|
|
765
|
-
name: string;
|
|
766
|
-
/**
|
|
767
|
-
* Expose links as endpoint. It's not only internal.
|
|
768
|
-
*/
|
|
769
|
-
proxy: boolean;
|
|
770
|
-
/**
|
|
771
|
-
* It's only used inside the application.
|
|
772
|
-
*/
|
|
773
|
-
internal: boolean;
|
|
774
|
-
/**
|
|
775
|
-
* Links fetcher.
|
|
776
|
-
*/
|
|
777
|
-
links: (args: {
|
|
778
|
-
authorization?: string;
|
|
779
|
-
}) => Promise<ApiLinksResponse>;
|
|
780
|
-
/**
|
|
781
|
-
* Fetches schema for the remote service.
|
|
782
|
-
*/
|
|
783
|
-
schema: (args: {
|
|
784
|
-
name: string;
|
|
785
|
-
authorization?: string;
|
|
786
|
-
}) => Promise<any>;
|
|
787
|
-
/**
|
|
788
|
-
* Force a default access token provider when not provided.
|
|
789
|
-
*/
|
|
790
|
-
serviceAccount?: ServiceAccountDescriptor;
|
|
791
|
-
/**
|
|
792
|
-
* Prefix for the remote service links.
|
|
793
|
-
*/
|
|
794
|
-
prefix: string;
|
|
795
|
-
}
|
|
796
|
-
//#endregion
|
|
797
|
-
//#region src/server-links/providers/ServerLinksProvider.d.ts
|
|
798
|
-
declare class ServerLinksProvider {
|
|
799
|
-
protected readonly env: {
|
|
800
|
-
SERVER_API_PREFIX: string;
|
|
801
|
-
};
|
|
802
|
-
protected readonly alepha: Alepha;
|
|
803
|
-
protected readonly linkProvider: LinkProvider;
|
|
804
|
-
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
805
|
-
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
806
|
-
get prefix(): string;
|
|
807
|
-
readonly onRoute: alepha1.HookDescriptor<"configure">;
|
|
808
|
-
/**
|
|
809
|
-
* First API - Get all API links for the user.
|
|
810
|
-
*
|
|
811
|
-
* This is based on the user's permissions.
|
|
812
|
-
*/
|
|
813
|
-
readonly links: alepha_server0.RouteDescriptor<{
|
|
814
|
-
response: alepha1.TObject<{
|
|
815
|
-
prefix: alepha1.TOptional<alepha1.TString>;
|
|
816
|
-
links: alepha1.TArray<alepha1.TObject<{
|
|
817
|
-
name: alepha1.TString;
|
|
818
|
-
group: alepha1.TOptional<alepha1.TString>;
|
|
819
|
-
path: alepha1.TString;
|
|
820
|
-
method: alepha1.TOptional<alepha1.TString>;
|
|
821
|
-
requestBodyType: alepha1.TOptional<alepha1.TString>;
|
|
822
|
-
service: alepha1.TOptional<alepha1.TString>;
|
|
823
|
-
}>>;
|
|
824
|
-
}>;
|
|
825
|
-
}>;
|
|
826
|
-
/**
|
|
827
|
-
* Second API - Get schema for a specific API link.
|
|
828
|
-
*
|
|
829
|
-
* Note: Body/Response schema are not included in `links` API because it's TOO BIG.
|
|
830
|
-
* I mean for 150+ links, you got 50ms of serialization time.
|
|
831
|
-
*/
|
|
832
|
-
readonly schema: alepha_server0.RouteDescriptor<{
|
|
833
|
-
params: alepha1.TObject<{
|
|
834
|
-
name: alepha1.TString;
|
|
835
|
-
}>;
|
|
836
|
-
response: alepha1.TRecord<string, alepha1.TAny>;
|
|
837
|
-
}>;
|
|
838
|
-
getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
|
|
839
|
-
/**
|
|
840
|
-
* Retrieves API links for the user based on their permissions.
|
|
841
|
-
* Will check on local links and remote links.
|
|
842
|
-
*/
|
|
843
|
-
getUserApiLinks(options: GetApiLinksOptions): Promise<ApiLinksResponse>;
|
|
844
|
-
}
|
|
845
|
-
interface GetApiLinksOptions {
|
|
846
|
-
user?: UserAccountToken;
|
|
847
|
-
authorization?: string;
|
|
848
|
-
}
|
|
849
|
-
//#endregion
|
|
850
|
-
//#region src/server-links/index.d.ts
|
|
851
|
-
declare module "alepha" {
|
|
852
|
-
interface State {
|
|
853
|
-
/**
|
|
854
|
-
* API links attached to the server request state.
|
|
855
|
-
*
|
|
856
|
-
* @see {@link ApiLinksResponse}
|
|
857
|
-
* @internal
|
|
858
|
-
*/
|
|
859
|
-
"alepha.server.request.apiLinks"?: ApiLinksResponse;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* Provides server-side link management and remote capabilities for client-server interactions.
|
|
864
|
-
*
|
|
865
|
-
* The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
|
|
866
|
-
* facilitating seamless API endpoint management and client-server communication. It integrates with server
|
|
867
|
-
* security features to ensure safe and controlled access to resources.
|
|
868
|
-
*
|
|
869
|
-
* @see {@link $remote}
|
|
870
|
-
* @see {@link $client}
|
|
871
|
-
* @module alepha.server.links
|
|
872
|
-
*/
|
|
873
|
-
//#endregion
|
|
874
|
-
//#region src/orm/schemas/insertSchema.d.ts
|
|
875
|
-
/**
|
|
876
|
-
* Transforms a TObject schema for insert operations.
|
|
877
|
-
* All default properties at the root level are made optional.
|
|
878
|
-
*
|
|
879
|
-
* @example
|
|
880
|
-
* Before: { name: string; age: number(default=0); }
|
|
881
|
-
* After: { name: string; age?: number; }
|
|
882
|
-
*/
|
|
883
|
-
type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends {
|
|
884
|
-
[PG_DEFAULT]: any;
|
|
885
|
-
} | {
|
|
886
|
-
"~optional": true;
|
|
887
|
-
} ? TOptional<T["properties"][K]> : T["properties"][K] }>;
|
|
888
|
-
//#endregion
|
|
889
|
-
//#region src/orm/schemas/updateSchema.d.ts
|
|
890
|
-
/**
|
|
891
|
-
* Transforms a TObject schema for update operations.
|
|
892
|
-
* All optional properties at the root level are made nullable (i.e., `T | null`).
|
|
893
|
-
* This allows an API endpoint to explicitly accept `null` to clear an optional field in the database.
|
|
894
|
-
*
|
|
895
|
-
* @example
|
|
896
|
-
* Before: { name?: string; age: number; }
|
|
897
|
-
* After: { name?: string | null; age: number; }
|
|
898
|
-
*/
|
|
899
|
-
type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends TOptional<infer U> ? TOptional<TUnion<[U, TNull]>> : T["properties"][K] }>;
|
|
900
|
-
//#endregion
|
|
901
|
-
//#region src/orm/descriptors/$entity.d.ts
|
|
902
|
-
interface EntityDescriptorOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
903
|
-
/**
|
|
904
|
-
* The database table name that will be created for this entity.
|
|
905
|
-
* If not provided, name will be inferred from the $repository variable name.
|
|
906
|
-
*/
|
|
907
|
-
name: string;
|
|
908
|
-
/**
|
|
909
|
-
* TypeBox schema defining the table structure and column types.
|
|
910
|
-
*/
|
|
911
|
-
schema: T;
|
|
912
|
-
/**
|
|
913
|
-
* Database indexes to create for query optimization.
|
|
914
|
-
*/
|
|
915
|
-
indexes?: (Keys | {
|
|
916
|
-
/**
|
|
917
|
-
* Single column to index.
|
|
918
|
-
*/
|
|
919
|
-
column: Keys;
|
|
920
|
-
/**
|
|
921
|
-
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
922
|
-
*/
|
|
923
|
-
unique?: boolean;
|
|
924
|
-
/**
|
|
925
|
-
* Custom name for the index. If not provided, generates name automatically.
|
|
926
|
-
*/
|
|
927
|
-
name?: string;
|
|
928
|
-
} | {
|
|
929
|
-
/**
|
|
930
|
-
* Multiple columns for composite index (order matters for query optimization).
|
|
931
|
-
*/
|
|
932
|
-
columns: Keys[];
|
|
933
|
-
/**
|
|
934
|
-
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
935
|
-
*/
|
|
936
|
-
unique?: boolean;
|
|
937
|
-
/**
|
|
938
|
-
* Custom name for the index. If not provided, generates name automatically.
|
|
939
|
-
*/
|
|
940
|
-
name?: string;
|
|
941
|
-
})[];
|
|
942
|
-
/**
|
|
943
|
-
* Foreign key constraints to maintain referential integrity.
|
|
944
|
-
*/
|
|
945
|
-
foreignKeys?: Array<{
|
|
946
|
-
/**
|
|
947
|
-
* Optional name for the foreign key constraint.
|
|
948
|
-
*/
|
|
949
|
-
name?: string;
|
|
950
|
-
/**
|
|
951
|
-
* Local columns that reference the foreign table.
|
|
952
|
-
*/
|
|
953
|
-
columns: Array<keyof Static<T>>;
|
|
954
|
-
/**
|
|
955
|
-
* Referenced columns in the foreign table.
|
|
956
|
-
* Must be EntityColumn references from other entities.
|
|
957
|
-
*/
|
|
958
|
-
foreignColumns: Array<() => EntityColumn<any>>;
|
|
959
|
-
}>;
|
|
960
|
-
/**
|
|
961
|
-
* Additional table constraints for data validation.
|
|
962
|
-
*
|
|
963
|
-
* Constraints enforce business rules at the database level, providing
|
|
964
|
-
* an additional layer of data integrity beyond application validation.
|
|
965
|
-
*
|
|
966
|
-
* **Constraint Types**:
|
|
967
|
-
* - **Unique constraints**: Prevent duplicate values across columns
|
|
968
|
-
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
969
|
-
*
|
|
970
|
-
* @example
|
|
971
|
-
* ```ts
|
|
972
|
-
* constraints: [
|
|
973
|
-
* {
|
|
974
|
-
* name: "unique_user_email",
|
|
975
|
-
* columns: ["email"],
|
|
976
|
-
* unique: true
|
|
977
|
-
* },
|
|
978
|
-
* {
|
|
979
|
-
* name: "valid_age_range",
|
|
980
|
-
* columns: ["age"],
|
|
981
|
-
* check: sql`age >= 0 AND age <= 150`
|
|
982
|
-
* },
|
|
983
|
-
* {
|
|
984
|
-
* name: "unique_user_username_per_tenant",
|
|
985
|
-
* columns: ["tenantId", "username"],
|
|
986
|
-
* unique: true
|
|
987
|
-
* }
|
|
988
|
-
* ]
|
|
989
|
-
* ```
|
|
990
|
-
*/
|
|
991
|
-
constraints?: Array<{
|
|
992
|
-
/**
|
|
993
|
-
* Columns involved in this constraint.
|
|
994
|
-
*/
|
|
995
|
-
columns: Array<keyof Static<T>>;
|
|
996
|
-
/**
|
|
997
|
-
* Optional name for the constraint.
|
|
998
|
-
*/
|
|
999
|
-
name?: string;
|
|
1000
|
-
/**
|
|
1001
|
-
* Whether this is a unique constraint.
|
|
1002
|
-
*/
|
|
1003
|
-
unique?: boolean | {};
|
|
1004
|
-
/**
|
|
1005
|
-
* SQL expression for check constraint validation.
|
|
1006
|
-
*/
|
|
1007
|
-
check?: SQL;
|
|
1008
|
-
}>;
|
|
1009
|
-
/**
|
|
1010
|
-
* Advanced Drizzle ORM configuration for complex table setups.
|
|
1011
|
-
*/
|
|
1012
|
-
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
1013
|
-
}
|
|
1014
|
-
declare class EntityDescriptor<T extends TObject = TObject> {
|
|
1015
|
-
readonly options: EntityDescriptorOptions<T>;
|
|
1016
|
-
constructor(options: EntityDescriptorOptions<T>);
|
|
1017
|
-
alias(alias: string): this;
|
|
1018
|
-
get cols(): EntityColumns<T>;
|
|
1019
|
-
get name(): string;
|
|
1020
|
-
get schema(): T;
|
|
1021
|
-
get insertSchema(): TObjectInsert<T>;
|
|
1022
|
-
get updateSchema(): TObjectUpdate<T>;
|
|
1023
|
-
}
|
|
1024
|
-
/**
|
|
1025
|
-
* Convert a schema to columns.
|
|
1026
|
-
*/
|
|
1027
|
-
type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
|
|
1028
|
-
type SchemaToTableConfig<T extends TObject> = {
|
|
1029
|
-
name: string;
|
|
1030
|
-
schema: string | undefined;
|
|
1031
|
-
columns: { [key in keyof T["properties"]]: PgColumn };
|
|
1032
|
-
dialect: string;
|
|
1033
|
-
};
|
|
1034
|
-
type EntityColumn<T extends TObject> = {
|
|
1035
|
-
name: string;
|
|
1036
|
-
entity: EntityDescriptor<T>;
|
|
1037
|
-
};
|
|
1038
|
-
type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
|
|
1039
|
-
//#endregion
|
|
1040
|
-
//#region src/orm/constants/PG_SYMBOLS.d.ts
|
|
1041
|
-
declare const PG_DEFAULT: unique symbol;
|
|
1042
|
-
declare const PG_PRIMARY_KEY: unique symbol;
|
|
1043
|
-
declare const PG_CREATED_AT: unique symbol;
|
|
1044
|
-
declare const PG_UPDATED_AT: unique symbol;
|
|
1045
|
-
declare const PG_DELETED_AT: unique symbol;
|
|
1046
|
-
declare const PG_VERSION: unique symbol;
|
|
1047
|
-
declare const PG_IDENTITY: unique symbol;
|
|
1048
|
-
declare const PG_ENUM: unique symbol;
|
|
1049
|
-
declare const PG_REF: unique symbol;
|
|
1050
|
-
/**
|
|
1051
|
-
* @deprecated Use `PG_IDENTITY` instead.
|
|
1052
|
-
*/
|
|
1053
|
-
declare const PG_SERIAL: unique symbol;
|
|
1054
|
-
type PgSymbols = {
|
|
1055
|
-
[PG_DEFAULT]: {};
|
|
1056
|
-
[PG_PRIMARY_KEY]: {};
|
|
1057
|
-
[PG_CREATED_AT]: {};
|
|
1058
|
-
[PG_UPDATED_AT]: {};
|
|
1059
|
-
[PG_DELETED_AT]: {};
|
|
1060
|
-
[PG_VERSION]: {};
|
|
1061
|
-
[PG_IDENTITY]: PgIdentityOptions;
|
|
1062
|
-
[PG_REF]: PgRefOptions;
|
|
1063
|
-
[PG_ENUM]: PgEnumOptions;
|
|
1064
|
-
/**
|
|
1065
|
-
* @deprecated Use `PG_IDENTITY` instead.
|
|
1066
|
-
*/
|
|
1067
|
-
[PG_SERIAL]: {};
|
|
1068
|
-
};
|
|
1069
|
-
type PgSymbolKeys = keyof PgSymbols;
|
|
1070
|
-
type PgIdentityOptions = {
|
|
1071
|
-
mode: "always" | "byDefault";
|
|
1072
|
-
} & PgSequenceOptions & {
|
|
1073
|
-
name?: string;
|
|
1074
|
-
};
|
|
1075
|
-
interface PgEnumOptions {
|
|
1076
|
-
name?: string;
|
|
1077
|
-
description?: string;
|
|
1078
|
-
}
|
|
1079
|
-
interface PgRefOptions {
|
|
1080
|
-
ref: () => {
|
|
1081
|
-
name: string;
|
|
1082
|
-
entity: EntityDescriptor;
|
|
1083
|
-
};
|
|
1084
|
-
actions?: {
|
|
1085
|
-
onUpdate?: UpdateDeleteAction;
|
|
1086
|
-
onDelete?: UpdateDeleteAction;
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
//#endregion
|
|
1090
|
-
//#region src/orm/errors/DbError.d.ts
|
|
1091
|
-
declare class DbError extends AlephaError {
|
|
1092
|
-
name: string;
|
|
1093
|
-
constructor(message: string, cause?: unknown);
|
|
1094
|
-
}
|
|
1095
|
-
//#endregion
|
|
1096
|
-
//#region src/orm/helpers/pgAttr.d.ts
|
|
1097
|
-
/**
|
|
1098
|
-
* Type representation.
|
|
1099
|
-
*/
|
|
1100
|
-
type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1101
|
-
interface PgAttrField {
|
|
1102
|
-
key: string;
|
|
1103
|
-
type: TSchema;
|
|
1104
|
-
data: any;
|
|
1105
|
-
nested?: any[];
|
|
1106
|
-
one?: boolean;
|
|
1107
|
-
}
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region src/orm/interfaces/FilterOperators.d.ts
|
|
1110
|
-
interface FilterOperators<TValue> {
|
|
1111
|
-
/**
|
|
1112
|
-
* Test that two values are equal.
|
|
1113
|
-
*
|
|
1114
|
-
* Remember that the SQL standard dictates that
|
|
1115
|
-
* two NULL values are not equal, so if you want to test
|
|
1116
|
-
* whether a value is null, you may want to use
|
|
1117
|
-
* `isNull` instead.
|
|
1118
|
-
*
|
|
1119
|
-
* ## Examples
|
|
1120
|
-
*
|
|
1121
|
-
* ```ts
|
|
1122
|
-
* // Select cars made by Ford
|
|
1123
|
-
* db.select().from(cars)
|
|
1124
|
-
* .where(eq(cars.make, 'Ford'))
|
|
1125
|
-
* ```
|
|
1126
|
-
*
|
|
1127
|
-
* @see isNull for a way to test equality to NULL.
|
|
1128
|
-
*/
|
|
1129
|
-
eq?: TValue;
|
|
1130
|
-
/**
|
|
1131
|
-
* Test that two values are not equal.
|
|
1132
|
-
*
|
|
1133
|
-
* Remember that the SQL standard dictates that
|
|
1134
|
-
* two NULL values are not equal, so if you want to test
|
|
1135
|
-
* whether a value is not null, you may want to use
|
|
1136
|
-
* `isNotNull` instead.
|
|
1137
|
-
*
|
|
1138
|
-
* ## Examples
|
|
1139
|
-
*
|
|
1140
|
-
* ```ts
|
|
1141
|
-
* // Select cars not made by Ford
|
|
1142
|
-
* db.select().from(cars)
|
|
1143
|
-
* .where(ne(cars.make, 'Ford'))
|
|
1144
|
-
* ```
|
|
1145
|
-
*
|
|
1146
|
-
* @see isNotNull for a way to test whether a value is not null.
|
|
1147
|
-
*/
|
|
1148
|
-
ne?: TValue;
|
|
1149
|
-
/**
|
|
1150
|
-
* Test that the first expression passed is greater than
|
|
1151
|
-
* the second expression.
|
|
1152
|
-
*
|
|
1153
|
-
* ## Examples
|
|
1154
|
-
*
|
|
1155
|
-
* ```ts
|
|
1156
|
-
* // Select cars made after 2000.
|
|
1157
|
-
* db.select().from(cars)
|
|
1158
|
-
* .where(gt(cars.year, 2000))
|
|
1159
|
-
* ```
|
|
1160
|
-
*
|
|
1161
|
-
* @see gte for greater-than-or-equal
|
|
1162
|
-
*/
|
|
1163
|
-
gt?: TValue;
|
|
1164
|
-
/**
|
|
1165
|
-
* Test that the first expression passed is greater than
|
|
1166
|
-
* or equal to the second expression. Use `gt` to
|
|
1167
|
-
* test whether an expression is strictly greater
|
|
1168
|
-
* than another.
|
|
1169
|
-
*
|
|
1170
|
-
* ## Examples
|
|
1171
|
-
*
|
|
1172
|
-
* ```ts
|
|
1173
|
-
* // Select cars made on or after 2000.
|
|
1174
|
-
* db.select().from(cars)
|
|
1175
|
-
* .where(gte(cars.year, 2000))
|
|
1176
|
-
* ```
|
|
1177
|
-
*
|
|
1178
|
-
* @see gt for a strictly greater-than condition
|
|
1179
|
-
*/
|
|
1180
|
-
gte?: TValue;
|
|
1181
|
-
/**
|
|
1182
|
-
* Test that the first expression passed is less than
|
|
1183
|
-
* the second expression.
|
|
1184
|
-
*
|
|
1185
|
-
* ## Examples
|
|
1186
|
-
*
|
|
1187
|
-
* ```ts
|
|
1188
|
-
* // Select cars made before 2000.
|
|
1189
|
-
* db.select().from(cars)
|
|
1190
|
-
* .where(lt(cars.year, 2000))
|
|
1191
|
-
* ```
|
|
1192
|
-
*
|
|
1193
|
-
* @see lte for greater-than-or-equal
|
|
1194
|
-
*/
|
|
1195
|
-
lt?: TValue;
|
|
1196
|
-
/**
|
|
1197
|
-
* Test that the first expression passed is less than
|
|
1198
|
-
* or equal to the second expression.
|
|
1199
|
-
*
|
|
1200
|
-
* ## Examples
|
|
1201
|
-
*
|
|
1202
|
-
* ```ts
|
|
1203
|
-
* // Select cars made before 2000.
|
|
1204
|
-
* db.select().from(cars)
|
|
1205
|
-
* .where(lte(cars.year, 2000))
|
|
1206
|
-
* ```
|
|
1207
|
-
*
|
|
1208
|
-
* @see lt for a strictly less-than condition
|
|
1209
|
-
*/
|
|
1210
|
-
lte?: TValue;
|
|
1211
|
-
/**
|
|
1212
|
-
* Test whether the first parameter, a column or expression,
|
|
1213
|
-
* has a value from a list passed as the second argument.
|
|
1214
|
-
*
|
|
1215
|
-
* ## Throws
|
|
1216
|
-
*
|
|
1217
|
-
* The argument passed in the second array can't be empty:
|
|
1218
|
-
* if an empty is provided, this method will throw.
|
|
1219
|
-
*
|
|
1220
|
-
* ## Examples
|
|
1221
|
-
*
|
|
1222
|
-
* ```ts
|
|
1223
|
-
* // Select cars made by Ford or GM.
|
|
1224
|
-
* db.select().from(cars)
|
|
1225
|
-
* .where(inArray(cars.make, ['Ford', 'GM']))
|
|
1226
|
-
* ```
|
|
1227
|
-
*
|
|
1228
|
-
* @see notInArray for the inverse of this test
|
|
1229
|
-
*/
|
|
1230
|
-
inArray?: TValue[];
|
|
1231
|
-
/**
|
|
1232
|
-
* Test whether the first parameter, a column or expression,
|
|
1233
|
-
* has a value that is not present in a list passed as the
|
|
1234
|
-
* second argument.
|
|
1235
|
-
*
|
|
1236
|
-
* ## Throws
|
|
1237
|
-
*
|
|
1238
|
-
* The argument passed in the second array can't be empty:
|
|
1239
|
-
* if an empty is provided, this method will throw.
|
|
1240
|
-
*
|
|
1241
|
-
* ## Examples
|
|
1242
|
-
*
|
|
1243
|
-
* ```ts
|
|
1244
|
-
* // Select cars made by any company except Ford or GM.
|
|
1245
|
-
* db.select().from(cars)
|
|
1246
|
-
* .where(notInArray(cars.make, ['Ford', 'GM']))
|
|
1247
|
-
* ```
|
|
1248
|
-
*
|
|
1249
|
-
* @see inArray for the inverse of this test
|
|
1250
|
-
*/
|
|
1251
|
-
notInArray?: TValue[];
|
|
1252
|
-
/**
|
|
1253
|
-
* Test whether an expression is not NULL. By the SQL standard,
|
|
1254
|
-
* NULL is neither equal nor not equal to itself, so
|
|
1255
|
-
* it's recommended to use `isNull` and `notIsNull` for
|
|
1256
|
-
* comparisons to NULL.
|
|
1257
|
-
*
|
|
1258
|
-
* ## Examples
|
|
1259
|
-
*
|
|
1260
|
-
* ```ts
|
|
1261
|
-
* // Select cars that have been discontinued.
|
|
1262
|
-
* db.select().from(cars)
|
|
1263
|
-
* .where(isNotNull(cars.discontinuedAt))
|
|
1264
|
-
* ```
|
|
1265
|
-
*
|
|
1266
|
-
* @see isNull for the inverse of this test
|
|
1267
|
-
*/
|
|
1268
|
-
isNotNull?: true;
|
|
1269
|
-
/**
|
|
1270
|
-
* Test whether an expression is NULL. By the SQL standard,
|
|
1271
|
-
* NULL is neither equal nor not equal to itself, so
|
|
1272
|
-
* it's recommended to use `isNull` and `notIsNull` for
|
|
1273
|
-
* comparisons to NULL.
|
|
1274
|
-
*
|
|
1275
|
-
* ## Examples
|
|
1276
|
-
*
|
|
1277
|
-
* ```ts
|
|
1278
|
-
* // Select cars that have no discontinuedAt date.
|
|
1279
|
-
* db.select().from(cars)
|
|
1280
|
-
* .where(isNull(cars.discontinuedAt))
|
|
1281
|
-
* ```
|
|
1282
|
-
*
|
|
1283
|
-
* @see isNotNull for the inverse of this test
|
|
1284
|
-
*/
|
|
1285
|
-
isNull?: true;
|
|
1286
|
-
/**
|
|
1287
|
-
* Test whether an expression is between two values. This
|
|
1288
|
-
* is an easier way to express range tests, which would be
|
|
1289
|
-
* expressed mathematically as `x <= a <= y` but in SQL
|
|
1290
|
-
* would have to be like `a >= x AND a <= y`.
|
|
1291
|
-
*
|
|
1292
|
-
* Between is inclusive of the endpoints: if `column`
|
|
1293
|
-
* is equal to `min` or `max`, it will be TRUE.
|
|
1294
|
-
*
|
|
1295
|
-
* ## Examples
|
|
1296
|
-
*
|
|
1297
|
-
* ```ts
|
|
1298
|
-
* // Select cars made between 1990 and 2000
|
|
1299
|
-
* db.select().from(cars)
|
|
1300
|
-
* .where(between(cars.year, 1990, 2000))
|
|
1301
|
-
* ```
|
|
1302
|
-
*
|
|
1303
|
-
* @see notBetween for the inverse of this test
|
|
1304
|
-
*/
|
|
1305
|
-
between?: [number, number];
|
|
1306
|
-
/**
|
|
1307
|
-
* Test whether an expression is not between two values.
|
|
1308
|
-
*
|
|
1309
|
-
* This, like `between`, includes its endpoints, so if
|
|
1310
|
-
* the `column` is equal to `min` or `max`, in this case
|
|
1311
|
-
* it will evaluate to FALSE.
|
|
1312
|
-
*
|
|
1313
|
-
* ## Examples
|
|
1314
|
-
*
|
|
1315
|
-
* ```ts
|
|
1316
|
-
* // Exclude cars made in the 1970s
|
|
1317
|
-
* db.select().from(cars)
|
|
1318
|
-
* .where(notBetween(cars.year, 1970, 1979))
|
|
1319
|
-
* ```
|
|
1320
|
-
*
|
|
1321
|
-
* @see between for the inverse of this test
|
|
1322
|
-
*/
|
|
1323
|
-
notBetween?: [number, number];
|
|
1324
|
-
/**
|
|
1325
|
-
* Compare a column to a pattern, which can include `%` and `_`
|
|
1326
|
-
* characters to match multiple variations. Including `%`
|
|
1327
|
-
* in the pattern matches zero or more characters, and including
|
|
1328
|
-
* `_` will match a single character.
|
|
1329
|
-
*
|
|
1330
|
-
* ## Examples
|
|
1331
|
-
*
|
|
1332
|
-
* ```ts
|
|
1333
|
-
* // Select all cars with 'Turbo' in their names.
|
|
1334
|
-
* db.select().from(cars)
|
|
1335
|
-
* .where(like(cars.name, '%Turbo%'))
|
|
1336
|
-
* ```
|
|
1337
|
-
*
|
|
1338
|
-
* @see ilike for a case-insensitive version of this condition
|
|
1339
|
-
*/
|
|
1340
|
-
like?: string;
|
|
1341
|
-
/**
|
|
1342
|
-
* The inverse of like - this tests that a given column
|
|
1343
|
-
* does not match a pattern, which can include `%` and `_`
|
|
1344
|
-
* characters to match multiple variations. Including `%`
|
|
1345
|
-
* in the pattern matches zero or more characters, and including
|
|
1346
|
-
* `_` will match a single character.
|
|
1347
|
-
*
|
|
1348
|
-
* ## Examples
|
|
1349
|
-
*
|
|
1350
|
-
* ```ts
|
|
1351
|
-
* // Select all cars that don't have "ROver" in their name.
|
|
1352
|
-
* db.select().from(cars)
|
|
1353
|
-
* .where(notLike(cars.name, '%Rover%'))
|
|
1354
|
-
* ```
|
|
1355
|
-
*
|
|
1356
|
-
* @see like for the inverse condition
|
|
1357
|
-
* @see notIlike for a case-insensitive version of this condition
|
|
1358
|
-
*/
|
|
1359
|
-
notLike?: string;
|
|
1360
|
-
/**
|
|
1361
|
-
* Case-insensitively compare a column to a pattern,
|
|
1362
|
-
* which can include `%` and `_`
|
|
1363
|
-
* characters to match multiple variations. Including `%`
|
|
1364
|
-
* in the pattern matches zero or more characters, and including
|
|
1365
|
-
* `_` will match a single character.
|
|
1366
|
-
*
|
|
1367
|
-
* Unlike like, this performs a case-insensitive comparison.
|
|
1368
|
-
*
|
|
1369
|
-
* ## Examples
|
|
1370
|
-
*
|
|
1371
|
-
* ```ts
|
|
1372
|
-
* // Select all cars with 'Turbo' in their names.
|
|
1373
|
-
* db.select().from(cars)
|
|
1374
|
-
* .where(ilike(cars.name, '%Turbo%'))
|
|
1375
|
-
* ```
|
|
1376
|
-
*
|
|
1377
|
-
* @see like for a case-sensitive version of this condition
|
|
1378
|
-
*/
|
|
1379
|
-
ilike?: string;
|
|
1380
|
-
/**
|
|
1381
|
-
* The inverse of ilike - this case-insensitively tests that a given column
|
|
1382
|
-
* does not match a pattern, which can include `%` and `_`
|
|
1383
|
-
* characters to match multiple variations. Including `%`
|
|
1384
|
-
* in the pattern matches zero or more characters, and including
|
|
1385
|
-
* `_` will match a single character.
|
|
1386
|
-
*
|
|
1387
|
-
* ## Examples
|
|
1388
|
-
*
|
|
1389
|
-
* ```ts
|
|
1390
|
-
* // Select all cars that don't have "Rover" in their name.
|
|
1391
|
-
* db.select().from(cars)
|
|
1392
|
-
* .where(notLike(cars.name, '%Rover%'))
|
|
1393
|
-
* ```
|
|
1394
|
-
*
|
|
1395
|
-
* @see ilike for the inverse condition
|
|
1396
|
-
* @see notLike for a case-sensitive version of this condition
|
|
1397
|
-
*/
|
|
1398
|
-
notIlike?: string;
|
|
1399
|
-
/**
|
|
1400
|
-
* Syntactic sugar for case-insensitive substring matching.
|
|
1401
|
-
* Automatically wraps the value with `%` wildcards on both sides.
|
|
1402
|
-
*
|
|
1403
|
-
* Equivalent to: `ilike: '%value%'`
|
|
1404
|
-
*
|
|
1405
|
-
* ## Examples
|
|
1406
|
-
*
|
|
1407
|
-
* ```ts
|
|
1408
|
-
* // Select all cars with "Turbo" anywhere in their name.
|
|
1409
|
-
* db.select().from(cars)
|
|
1410
|
-
* .where({ name: { contains: 'Turbo' } })
|
|
1411
|
-
* // Same as: .where(ilike(cars.name, '%Turbo%'))
|
|
1412
|
-
* ```
|
|
1413
|
-
*
|
|
1414
|
-
* @see ilike for manual pattern matching
|
|
1415
|
-
* @see startsWith for prefix matching
|
|
1416
|
-
* @see endsWith for suffix matching
|
|
1417
|
-
*/
|
|
1418
|
-
contains?: string;
|
|
1419
|
-
/**
|
|
1420
|
-
* Syntactic sugar for case-insensitive prefix matching.
|
|
1421
|
-
* Automatically appends a `%` wildcard to the end of the value.
|
|
1422
|
-
*
|
|
1423
|
-
* Equivalent to: `ilike: 'value%'`
|
|
1424
|
-
*
|
|
1425
|
-
* ## Examples
|
|
1426
|
-
*
|
|
1427
|
-
* ```ts
|
|
1428
|
-
* // Select all cars whose names start with "Ford".
|
|
1429
|
-
* db.select().from(cars)
|
|
1430
|
-
* .where({ name: { startsWith: 'Ford' } })
|
|
1431
|
-
* // Same as: .where(ilike(cars.name, 'Ford%'))
|
|
1432
|
-
* ```
|
|
1433
|
-
*
|
|
1434
|
-
* @see ilike for manual pattern matching
|
|
1435
|
-
* @see contains for substring matching
|
|
1436
|
-
* @see endsWith for suffix matching
|
|
1437
|
-
*/
|
|
1438
|
-
startsWith?: string;
|
|
1439
|
-
/**
|
|
1440
|
-
* Syntactic sugar for case-insensitive suffix matching.
|
|
1441
|
-
* Automatically prepends a `%` wildcard to the beginning of the value.
|
|
1442
|
-
*
|
|
1443
|
-
* Equivalent to: `ilike: '%value'`
|
|
1444
|
-
*
|
|
1445
|
-
* ## Examples
|
|
1446
|
-
*
|
|
1447
|
-
* ```ts
|
|
1448
|
-
* // Select all cars whose names end with "Turbo".
|
|
1449
|
-
* db.select().from(cars)
|
|
1450
|
-
* .where({ name: { endsWith: 'Turbo' } })
|
|
1451
|
-
* // Same as: .where(ilike(cars.name, '%Turbo'))
|
|
1452
|
-
* ```
|
|
1453
|
-
*
|
|
1454
|
-
* @see ilike for manual pattern matching
|
|
1455
|
-
* @see contains for substring matching
|
|
1456
|
-
* @see startsWith for prefix matching
|
|
1457
|
-
*/
|
|
1458
|
-
endsWith?: string;
|
|
1459
|
-
/**
|
|
1460
|
-
* Test that a column or expression contains all elements of
|
|
1461
|
-
* the list passed as the second argument.
|
|
1462
|
-
*
|
|
1463
|
-
* ## Throws
|
|
1464
|
-
*
|
|
1465
|
-
* The argument passed in the second array can't be empty:
|
|
1466
|
-
* if an empty is provided, this method will throw.
|
|
1467
|
-
*
|
|
1468
|
-
* ## Examples
|
|
1469
|
-
*
|
|
1470
|
-
* ```ts
|
|
1471
|
-
* // Select posts where its tags contain "Typescript" and "ORM".
|
|
1472
|
-
* db.select().from(posts)
|
|
1473
|
-
* .where(arrayContains(posts.tags, ['Typescript', 'ORM']))
|
|
1474
|
-
* ```
|
|
1475
|
-
*
|
|
1476
|
-
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
1477
|
-
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
1478
|
-
*/
|
|
1479
|
-
arrayContains?: TValue;
|
|
1480
|
-
/**
|
|
1481
|
-
* Test that the list passed as the second argument contains
|
|
1482
|
-
* all elements of a column or expression.
|
|
1483
|
-
*
|
|
1484
|
-
* ## Throws
|
|
1485
|
-
*
|
|
1486
|
-
* The argument passed in the second array can't be empty:
|
|
1487
|
-
* if an empty is provided, this method will throw.
|
|
1488
|
-
*
|
|
1489
|
-
* ## Examples
|
|
1490
|
-
*
|
|
1491
|
-
* ```ts
|
|
1492
|
-
* // Select posts where its tags contain "Typescript", "ORM" or both,
|
|
1493
|
-
* // but filtering posts that have additional tags.
|
|
1494
|
-
* db.select().from(posts)
|
|
1495
|
-
* .where(arrayContained(posts.tags, ['Typescript', 'ORM']))
|
|
1496
|
-
* ```
|
|
1497
|
-
*
|
|
1498
|
-
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
1499
|
-
* @see arrayOverlaps to find if a column or expression contains any elements of an array
|
|
1500
|
-
*/
|
|
1501
|
-
arrayContained?: TValue;
|
|
1502
|
-
/**
|
|
1503
|
-
* Test that a column or expression contains any elements of
|
|
1504
|
-
* the list passed as the second argument.
|
|
1505
|
-
*
|
|
1506
|
-
* ## Throws
|
|
1507
|
-
*
|
|
1508
|
-
* The argument passed in the second array can't be empty:
|
|
1509
|
-
* if an empty is provided, this method will throw.
|
|
1510
|
-
*
|
|
1511
|
-
* ## Examples
|
|
1512
|
-
*
|
|
1513
|
-
* ```ts
|
|
1514
|
-
* // Select posts where its tags contain "Typescript", "ORM" or both.
|
|
1515
|
-
* db.select().from(posts)
|
|
1516
|
-
* .where(arrayOverlaps(posts.tags, ['Typescript', 'ORM']))
|
|
1517
|
-
* ```
|
|
1518
|
-
*
|
|
1519
|
-
* @see arrayContains to find if a column or expression contains all elements of an array
|
|
1520
|
-
* @see arrayContained to find if an array contains all elements of a column or expression
|
|
1521
|
-
*/
|
|
1522
|
-
arrayOverlaps?: TValue;
|
|
1523
|
-
}
|
|
1524
|
-
//#endregion
|
|
1525
|
-
//#region src/orm/interfaces/PgQueryWhere.d.ts
|
|
1526
|
-
type PgQueryWhere<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = (PgQueryWhereOperators<T> & PgQueryWhereConditions<T>) | (PgQueryWhereRelations<Relations> & PgQueryWhereOperators<T> & PgQueryWhereConditions<T, Relations>);
|
|
1527
|
-
type PgQueryWhereOrSQL<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = SQLWrapper | PgQueryWhere<T, Relations>;
|
|
1528
|
-
type PgQueryWhereOperators<T extends TObject> = { [Key in keyof Static<T>]?: FilterOperators<Static<T>[Key]> | Static<T>[Key] | (Static<T>[Key] extends object ? NestedJsonbQuery<Static<T>[Key]> : never) };
|
|
1529
|
-
type PgQueryWhereConditions<T extends TObject, Relations extends PgRelationMap<TObject> | undefined = undefined> = {
|
|
1530
|
-
/**
|
|
1531
|
-
* Combine a list of conditions with the `and` operator. Conditions
|
|
1532
|
-
* that are equal `undefined` are automatically ignored.
|
|
1533
|
-
*
|
|
1534
|
-
* ## Examples
|
|
1535
|
-
*
|
|
1536
|
-
* ```ts
|
|
1537
|
-
* db.select().from(cars)
|
|
1538
|
-
* .where(
|
|
1539
|
-
* and(
|
|
1540
|
-
* eq(cars.make, 'Volvo'),
|
|
1541
|
-
* eq(cars.year, 1950),
|
|
1542
|
-
* )
|
|
1543
|
-
* )
|
|
1544
|
-
* ```
|
|
1545
|
-
*/
|
|
1546
|
-
and?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
1547
|
-
/**
|
|
1548
|
-
* Combine a list of conditions with the `or` operator. Conditions
|
|
1549
|
-
* that are equal `undefined` are automatically ignored.
|
|
1550
|
-
*
|
|
1551
|
-
* ## Examples
|
|
1552
|
-
*
|
|
1553
|
-
* ```ts
|
|
1554
|
-
* db.select().from(cars)
|
|
1555
|
-
* .where(
|
|
1556
|
-
* or(
|
|
1557
|
-
* eq(cars.make, 'GM'),
|
|
1558
|
-
* eq(cars.make, 'Ford'),
|
|
1559
|
-
* )
|
|
1560
|
-
* )
|
|
1561
|
-
* ```
|
|
1562
|
-
*/
|
|
1563
|
-
or?: Array<PgQueryWhereOrSQL<T, Relations>>;
|
|
1564
|
-
/**
|
|
1565
|
-
* Negate the meaning of an expression using the `not` keyword.
|
|
1566
|
-
*
|
|
1567
|
-
* ## Examples
|
|
1568
|
-
*
|
|
1569
|
-
* ```ts
|
|
1570
|
-
* // Select cars _not_ made by GM or Ford.
|
|
1571
|
-
* db.select().from(cars)
|
|
1572
|
-
* .where(not(inArray(cars.make, ['GM', 'Ford'])))
|
|
1573
|
-
* ```
|
|
1574
|
-
*/
|
|
1575
|
-
not?: PgQueryWhereOrSQL<T, Relations>;
|
|
1576
|
-
/**
|
|
1577
|
-
* Test whether a subquery evaluates to have any rows.
|
|
1578
|
-
*
|
|
1579
|
-
* ## Examples
|
|
1580
|
-
*
|
|
1581
|
-
* ```ts
|
|
1582
|
-
* // Users whose `homeCity` column has a match in a cities
|
|
1583
|
-
* // table.
|
|
1584
|
-
* db
|
|
1585
|
-
* .select()
|
|
1586
|
-
* .from(users)
|
|
1587
|
-
* .where(
|
|
1588
|
-
* exists(db.select()
|
|
1589
|
-
* .from(cities)
|
|
1590
|
-
* .where(eq(users.homeCity, cities.id))),
|
|
1591
|
-
* );
|
|
1592
|
-
* ```
|
|
1593
|
-
*
|
|
1594
|
-
* @see notExists for the inverse of this test
|
|
1595
|
-
*/
|
|
1596
|
-
exists?: SQLWrapper;
|
|
1597
|
-
};
|
|
1598
|
-
type PgQueryWhereRelations<Relations extends PgRelationMap<TObject> | undefined = undefined> = Relations extends PgRelationMap<TObject> ? { [K in keyof Relations]?: PgQueryWhere<Relations[K]["join"]["schema"], Relations[K]["with"]> } : {};
|
|
1599
|
-
/**
|
|
1600
|
-
* Recursively allow nested queries for JSONB object/array types
|
|
1601
|
-
*/
|
|
1602
|
-
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;
|
|
1603
|
-
//#endregion
|
|
1604
|
-
//#region src/orm/interfaces/PgQuery.d.ts
|
|
1605
|
-
/**
|
|
1606
|
-
* Order direction for sorting
|
|
1607
|
-
*/
|
|
1608
|
-
type OrderDirection = "asc" | "desc";
|
|
1609
|
-
/**
|
|
1610
|
-
* Single order by clause with column and direction
|
|
1611
|
-
*/
|
|
1612
|
-
interface OrderByClause<T> {
|
|
1613
|
-
column: keyof T;
|
|
1614
|
-
direction?: OrderDirection;
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* Order by parameter - supports 3 modes:
|
|
1618
|
-
* 1. String: orderBy: "name" (defaults to ASC)
|
|
1619
|
-
* 2. Single object: orderBy: { column: "name", direction: "desc" }
|
|
1620
|
-
* 3. Array: orderBy: [{ column: "name", direction: "asc" }, { column: "age", direction: "desc" }]
|
|
1621
|
-
*/
|
|
1622
|
-
type OrderBy<T> = keyof T | OrderByClause<T> | Array<OrderByClause<T>>;
|
|
1623
|
-
/**
|
|
1624
|
-
* Generic query interface for PostgreSQL entities
|
|
1625
|
-
*/
|
|
1626
|
-
interface PgQuery<T extends TObject = TObject> {
|
|
1627
|
-
distinct?: (keyof Static<T>)[];
|
|
1628
|
-
columns?: (keyof Static<T>)[];
|
|
1629
|
-
where?: PgQueryWhereOrSQL<T>;
|
|
1630
|
-
limit?: number;
|
|
1631
|
-
offset?: number;
|
|
1632
|
-
orderBy?: OrderBy<Static<T>>;
|
|
1633
|
-
groupBy?: (keyof Static<T>)[];
|
|
1634
|
-
}
|
|
1635
|
-
type PgStatic<T extends TObject, Relations extends PgRelationMap<T>> = Static<T> & { [K in keyof Relations]: Static<Relations[K]["join"]["schema"]> & (Relations[K]["with"] extends PgRelationMap<TObject> ? PgStatic<Relations[K]["join"]["schema"], Relations[K]["with"]> : {}) };
|
|
1636
|
-
interface PgQueryRelations<T extends TObject = TObject, Relations extends PgRelationMap<T> | undefined = undefined> extends PgQuery<T> {
|
|
1637
|
-
with?: Relations;
|
|
1638
|
-
where?: PgQueryWhereOrSQL<T, Relations>;
|
|
1639
|
-
}
|
|
1640
|
-
type PgRelationMap<Base extends TObject> = Record<string, PgRelation<Base>>;
|
|
1641
|
-
type PgRelation<Base extends TObject> = {
|
|
1642
|
-
type?: "left" | "inner" | "right";
|
|
1643
|
-
join: {
|
|
1644
|
-
schema: TObject;
|
|
1645
|
-
name: string;
|
|
1646
|
-
};
|
|
1647
|
-
on: SQLWrapper | [keyof Static<Base>, {
|
|
1648
|
-
name: string;
|
|
1649
|
-
}];
|
|
1650
|
-
with?: PgRelationMap<TObject>;
|
|
1651
|
-
};
|
|
1652
|
-
//#endregion
|
|
1653
|
-
//#region src/orm/descriptors/$sequence.d.ts
|
|
1654
|
-
interface SequenceDescriptorOptions extends PgSequenceOptions {
|
|
1655
|
-
/**
|
|
1656
|
-
* The name of the sequence. If not provided, the property key will be used.
|
|
1657
|
-
*/
|
|
1658
|
-
name?: string;
|
|
1659
|
-
provider?: DatabaseProvider;
|
|
1660
|
-
}
|
|
1661
|
-
declare class SequenceDescriptor extends Descriptor<SequenceDescriptorOptions> {
|
|
1662
|
-
readonly provider: DatabaseProvider;
|
|
1663
|
-
onInit(): void;
|
|
1664
|
-
get name(): string;
|
|
1665
|
-
next(): Promise<number>;
|
|
1666
|
-
current(): Promise<number>;
|
|
1667
|
-
protected $provider(): DatabaseProvider;
|
|
1668
|
-
}
|
|
1669
|
-
//#endregion
|
|
1670
|
-
//#region src/orm/services/ModelBuilder.d.ts
|
|
1671
|
-
/**
|
|
1672
|
-
* Database-specific table configuration functions
|
|
1673
|
-
*/
|
|
1674
|
-
interface TableConfigBuilders<TConfig> {
|
|
1675
|
-
index: (name: string) => {
|
|
1676
|
-
on: (...columns: any[]) => TConfig;
|
|
1677
|
-
};
|
|
1678
|
-
uniqueIndex: (name: string) => {
|
|
1679
|
-
on: (...columns: any[]) => TConfig;
|
|
1680
|
-
};
|
|
1681
|
-
unique: (name: string) => {
|
|
1682
|
-
on: (...columns: any[]) => TConfig;
|
|
1683
|
-
};
|
|
1684
|
-
check: (name: string, sql: SQL) => TConfig;
|
|
1685
|
-
foreignKey: (config: {
|
|
1686
|
-
name: string;
|
|
1687
|
-
columns: any[];
|
|
1688
|
-
foreignColumns: any[];
|
|
1689
|
-
}) => TConfig;
|
|
1690
|
-
}
|
|
1691
|
-
/**
|
|
1692
|
-
* Abstract base class for transforming Alepha Descriptors (Entity, Sequence, etc...)
|
|
1693
|
-
* into drizzle models (tables, enums, sequences, etc...).
|
|
1694
|
-
*/
|
|
1695
|
-
declare abstract class ModelBuilder {
|
|
1696
|
-
/**
|
|
1697
|
-
* Build a table from an entity descriptor.
|
|
1698
|
-
*/
|
|
1699
|
-
abstract buildTable(entity: EntityDescriptor, options: {
|
|
1700
|
-
tables: Map<string, unknown>;
|
|
1701
|
-
enums: Map<string, unknown>;
|
|
1702
|
-
schema: string;
|
|
1703
|
-
}): void;
|
|
1704
|
-
/**
|
|
1705
|
-
* Build a sequence from a sequence descriptor.
|
|
1706
|
-
*/
|
|
1707
|
-
abstract buildSequence(sequence: SequenceDescriptor, options: {
|
|
1708
|
-
sequences: Map<string, unknown>;
|
|
1709
|
-
schema: string;
|
|
1710
|
-
}): void;
|
|
1711
|
-
/**
|
|
1712
|
-
* Convert camelCase to snake_case for column names.
|
|
1713
|
-
*/
|
|
1714
|
-
protected toColumnName(str: string): string;
|
|
1715
|
-
/**
|
|
1716
|
-
* Build the table configuration function for any database.
|
|
1717
|
-
* This includes indexes, foreign keys, constraints, and custom config.
|
|
1718
|
-
*
|
|
1719
|
-
* @param entity - The entity descriptor
|
|
1720
|
-
* @param builders - Database-specific builder functions
|
|
1721
|
-
* @param tableResolver - Function to resolve entity references to table columns
|
|
1722
|
-
* @param customConfigHandler - Optional handler for custom config
|
|
1723
|
-
*/
|
|
1724
|
-
protected buildTableConfig<TConfig, TSelf>(entity: EntityDescriptor, builders: TableConfigBuilders<TConfig>, tableResolver?: (entityName: string) => any, customConfigHandler?: (config: any, self: TSelf) => TConfig[]): ((self: TSelf) => TConfig[]) | undefined;
|
|
1725
|
-
}
|
|
1726
|
-
//#endregion
|
|
1727
|
-
//#region src/orm/providers/DrizzleKitProvider.d.ts
|
|
1728
|
-
declare class DrizzleKitProvider {
|
|
1729
|
-
protected readonly log: alepha_logger1.Logger;
|
|
1730
|
-
protected readonly alepha: Alepha;
|
|
1731
|
-
/**
|
|
1732
|
-
* Synchronize database with current schema definitions.
|
|
1733
|
-
*
|
|
1734
|
-
* In development mode, it will generate and execute migrations based on the current state.
|
|
1735
|
-
* In testing mode, it will generate migrations from scratch without applying them.
|
|
1736
|
-
*
|
|
1737
|
-
* Does nothing in production mode, you must handle migrations manually.
|
|
1738
|
-
*/
|
|
1739
|
-
synchronize(provider: DatabaseProvider): Promise<void>;
|
|
1740
|
-
/**
|
|
1741
|
-
* Mostly used for testing purposes. You can generate SQL migration statements without executing them.
|
|
1742
|
-
*/
|
|
1743
|
-
generateMigration(provider: DatabaseProvider, prevSnapshot?: any): Promise<{
|
|
1744
|
-
statements: string[];
|
|
1745
|
-
models: Record<string, unknown>;
|
|
1746
|
-
snapshot?: any;
|
|
1747
|
-
}>;
|
|
1748
|
-
/**
|
|
1749
|
-
* Load all tables, enums, sequences, etc. from the provider's repositories.
|
|
1750
|
-
*/
|
|
1751
|
-
getModels(provider: DatabaseProvider): Record<string, unknown>;
|
|
1752
|
-
/**
|
|
1753
|
-
* Load the migration snapshot from the database.
|
|
1754
|
-
*/
|
|
1755
|
-
protected loadDevMigrations(provider: DatabaseProvider): Promise<DevMigrations | undefined>;
|
|
1756
|
-
protected saveDevMigrations(provider: DatabaseProvider, curr: Record<string, any>, devMigrations?: DevMigrations): Promise<void>;
|
|
1757
|
-
protected executeStatements(statements: string[], provider: DatabaseProvider, catchErrors?: boolean): Promise<void>;
|
|
1758
|
-
protected createSchemaIfNotExists(provider: DatabaseProvider, schemaName: string): Promise<void>;
|
|
1759
|
-
/**
|
|
1760
|
-
* Try to load the official Drizzle Kit API.
|
|
1761
|
-
* If not available, fallback to the local kit import.
|
|
1762
|
-
*/
|
|
1763
|
-
protected importDrizzleKit(): typeof DrizzleKit;
|
|
1764
|
-
}
|
|
1765
|
-
declare const devMigrationsSchema: alepha1.TObject<{
|
|
1766
|
-
id: alepha1.TNumber;
|
|
1767
|
-
name: alepha1.TString;
|
|
1768
|
-
snapshot: alepha1.TString;
|
|
1769
|
-
created_at: alepha1.TString;
|
|
1770
|
-
}>;
|
|
1771
|
-
type DevMigrations = Static<typeof devMigrationsSchema>;
|
|
1772
|
-
//#endregion
|
|
1773
|
-
//#region src/orm/providers/drivers/DatabaseProvider.d.ts
|
|
1774
|
-
type SQLLike = SQLWrapper | string;
|
|
1775
|
-
declare abstract class DatabaseProvider {
|
|
1776
|
-
protected readonly alepha: Alepha;
|
|
1777
|
-
protected readonly log: alepha_logger1.Logger;
|
|
1778
|
-
protected abstract readonly builder: ModelBuilder;
|
|
1779
|
-
protected abstract readonly kit: DrizzleKitProvider;
|
|
1780
|
-
abstract readonly db: PgDatabase<any>;
|
|
1781
|
-
abstract readonly dialect: "postgresql" | "sqlite";
|
|
1782
|
-
abstract readonly url: string;
|
|
1783
|
-
readonly enums: Map<string, unknown>;
|
|
1784
|
-
readonly tables: Map<string, unknown>;
|
|
1785
|
-
readonly sequences: Map<string, unknown>;
|
|
1786
|
-
get name(): string;
|
|
1787
|
-
get schema(): string;
|
|
1788
|
-
table<T extends TObject>(entity: EntityDescriptor<T>): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
1789
|
-
registerEntity(entity: EntityDescriptor): void;
|
|
1790
|
-
registerSequence(sequence: SequenceDescriptor): void;
|
|
1791
|
-
abstract execute(statement: SQLLike): Promise<Record<string, unknown>[]>;
|
|
1792
|
-
run<T extends TObject>(statement: SQLLike, schema: T): Promise<Array<Static<T>>>;
|
|
1793
|
-
/**
|
|
1794
|
-
* Get migrations folder path - can be overridden
|
|
1795
|
-
*/
|
|
1796
|
-
protected getMigrationsFolder(): string;
|
|
1797
|
-
/**
|
|
1798
|
-
* Base migration orchestration - handles environment logic
|
|
1799
|
-
*/
|
|
1800
|
-
protected migrateDatabase(): Promise<void>;
|
|
1801
|
-
/**
|
|
1802
|
-
* Production: run migrations from folder
|
|
1803
|
-
*/
|
|
1804
|
-
protected runProductionMigration(migrationsFolder: string): Promise<void>;
|
|
1805
|
-
/**
|
|
1806
|
-
* Test: always synchronize
|
|
1807
|
-
*/
|
|
1808
|
-
protected runTestMigration(): Promise<void>;
|
|
1809
|
-
/**
|
|
1810
|
-
* Development: default to synchronize (can be overridden)
|
|
1811
|
-
*/
|
|
1812
|
-
protected runDevelopmentMigration(migrationsFolder: string): Promise<void>;
|
|
1813
|
-
/**
|
|
1814
|
-
* Common synchronization with error handling
|
|
1815
|
-
*/
|
|
1816
|
-
protected synchronizeSchema(): Promise<void>;
|
|
1817
|
-
/**
|
|
1818
|
-
* Provider-specific migration execution
|
|
1819
|
-
* MUST be implemented by each provider
|
|
1820
|
-
*/
|
|
1821
|
-
protected abstract executeMigrations(migrationsFolder: string): Promise<void>;
|
|
1822
|
-
}
|
|
1823
|
-
//#endregion
|
|
1824
|
-
//#region src/orm/services/PgJsonQueryManager.d.ts
|
|
1825
|
-
/**
|
|
1826
|
-
* Manages JSONB query generation for nested object and array queries in PostgreSQL.
|
|
1827
|
-
* This class handles complex nested queries using PostgreSQL's JSONB operators.
|
|
1828
|
-
*/
|
|
1829
|
-
declare class PgJsonQueryManager {
|
|
1830
|
-
/**
|
|
1831
|
-
* Check if a query contains nested JSONB queries.
|
|
1832
|
-
* A nested query is when the value is an object with operator keys.
|
|
1833
|
-
*/
|
|
1834
|
-
hasNestedQuery(where: PgQueryWhere<TObject>): boolean;
|
|
1835
|
-
/**
|
|
1836
|
-
* Build a JSONB query condition for nested object queries.
|
|
1837
|
-
* Supports deep nesting like: { profile: { contact: { email: { eq: "test@example.com" } } } }
|
|
1838
|
-
*
|
|
1839
|
-
* @param column The JSONB column
|
|
1840
|
-
* @param path The path to the nested property (e.g., ['profile', 'contact', 'email'])
|
|
1841
|
-
* @param operator The filter operator (e.g., { eq: "test@example.com" })
|
|
1842
|
-
* @param dialect Database dialect (postgresql or sqlite)
|
|
1843
|
-
* @param columnSchema Optional schema of the JSON column for type inference
|
|
1844
|
-
* @returns SQL condition
|
|
1845
|
-
*/
|
|
1846
|
-
buildJsonbCondition(column: PgColumn, path: string[], operator: FilterOperators<any>, dialect: "postgresql" | "sqlite", columnSchema?: any): SQL | undefined;
|
|
1847
|
-
/**
|
|
1848
|
-
* Build JSONB array query conditions.
|
|
1849
|
-
* Supports queries like: { addresses: { city: { eq: "Wonderland" } } }
|
|
1850
|
-
* which translates to: EXISTS (SELECT 1 FROM jsonb_array_elements(addresses) elem WHERE elem->>'city' = 'Wonderland')
|
|
1851
|
-
*
|
|
1852
|
-
* @param dialect Database dialect (postgresql or sqlite)
|
|
1853
|
-
* Note: SQLite array queries are not yet supported
|
|
1854
|
-
*/
|
|
1855
|
-
buildJsonbArrayCondition(column: PgColumn, path: string[], arrayPath: string, operator: FilterOperators<any>, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
1856
|
-
/**
|
|
1857
|
-
* Apply a filter operator to a JSONB value.
|
|
1858
|
-
* @param dialect Database dialect for appropriate casting syntax
|
|
1859
|
-
* @param fieldType Optional field type from schema for smart casting
|
|
1860
|
-
*/
|
|
1861
|
-
private applyOperatorToJsonValue;
|
|
1862
|
-
/**
|
|
1863
|
-
* Parse a nested query object and extract the path and operator.
|
|
1864
|
-
* For example: { profile: { contact: { email: { eq: "test@example.com" } } } }
|
|
1865
|
-
* Returns: { path: ['profile', 'contact', 'email'], operator: { eq: "test@example.com" } }
|
|
1866
|
-
*/
|
|
1867
|
-
parseNestedQuery(nestedQuery: any, currentPath?: string[]): Array<{
|
|
1868
|
-
path: string[];
|
|
1869
|
-
operator: FilterOperators<any>;
|
|
1870
|
-
}>;
|
|
1871
|
-
/**
|
|
1872
|
-
* Determine if a property is a JSONB column based on the schema.
|
|
1873
|
-
* A column is JSONB if it's defined as an object or array in the TypeBox schema.
|
|
1874
|
-
*/
|
|
1875
|
-
isJsonbColumn(schema: TObject, columnName: string): boolean;
|
|
1876
|
-
/**
|
|
1877
|
-
* Check if an array property contains primitive types (string, number, boolean, etc.)
|
|
1878
|
-
* rather than objects. Primitive arrays should use native Drizzle operators.
|
|
1879
|
-
* @returns true if the array contains primitives, false if it contains objects
|
|
1880
|
-
*/
|
|
1881
|
-
isPrimitiveArray(schema: TObject, columnName: string): boolean;
|
|
1882
|
-
/**
|
|
1883
|
-
* Get the type of a field by navigating through a schema path.
|
|
1884
|
-
* Used for smart type casting in SQL queries.
|
|
1885
|
-
*
|
|
1886
|
-
* @param columnSchema The schema of the JSON column (e.g., t.object({ age: t.integer() }))
|
|
1887
|
-
* @param path The path to navigate (e.g., ['contact', 'email'])
|
|
1888
|
-
* @returns The type string (e.g., 'integer', 'number', 'string') or undefined if not found
|
|
1889
|
-
*/
|
|
1890
|
-
private getFieldType;
|
|
1891
|
-
/**
|
|
1892
|
-
* Check if a nested path points to an array property.
|
|
1893
|
-
*/
|
|
1894
|
-
isArrayProperty(schema: TObject, path: string[]): boolean;
|
|
1895
|
-
}
|
|
1896
|
-
//#endregion
|
|
1897
|
-
//#region src/orm/services/QueryManager.d.ts
|
|
1898
|
-
declare class QueryManager {
|
|
1899
|
-
protected readonly jsonQueryManager: PgJsonQueryManager;
|
|
1900
|
-
protected readonly alepha: Alepha;
|
|
1901
|
-
/**
|
|
1902
|
-
* Convert a query object to a SQL query.
|
|
1903
|
-
*/
|
|
1904
|
-
toSQL(query: PgQueryWhereOrSQL<TObject>, options: {
|
|
1905
|
-
schema: TObject;
|
|
1906
|
-
col: (key: string) => PgColumn;
|
|
1907
|
-
joins?: PgJoin[];
|
|
1908
|
-
dialect: "postgresql" | "sqlite";
|
|
1909
|
-
}): SQL | undefined;
|
|
1910
|
-
/**
|
|
1911
|
-
* Build a JSONB query for nested object/array queries.
|
|
1912
|
-
*/
|
|
1913
|
-
protected buildJsonbQuery(column: PgColumn, nestedQuery: any, schema: TObject, columnName: string, dialect: "postgresql" | "sqlite"): SQL | undefined;
|
|
1914
|
-
/**
|
|
1915
|
-
* Check if an object has any filter operator properties.
|
|
1916
|
-
*/
|
|
1917
|
-
protected hasFilterOperatorProperties(obj: any): boolean;
|
|
1918
|
-
/**
|
|
1919
|
-
* Map a filter operator to a SQL query.
|
|
1920
|
-
*/
|
|
1921
|
-
mapOperatorToSql(operator: FilterOperators<any> | any, column: PgColumn, columnSchema?: TObject, columnName?: string, dialect?: "postgresql" | "sqlite"): SQL | undefined;
|
|
1922
|
-
/**
|
|
1923
|
-
* Parse pagination sort string to orderBy format.
|
|
1924
|
-
* Format: "firstName,-lastName" -> [{ column: "firstName", direction: "asc" }, { column: "lastName", direction: "desc" }]
|
|
1925
|
-
* - Columns separated by comma
|
|
1926
|
-
* - Prefix with '-' for DESC direction
|
|
1927
|
-
*
|
|
1928
|
-
* @param sort Pagination sort string
|
|
1929
|
-
* @returns OrderBy array or single object
|
|
1930
|
-
*/
|
|
1931
|
-
parsePaginationSort(sort: string): Array<{
|
|
1932
|
-
column: string;
|
|
1933
|
-
direction: "asc" | "desc";
|
|
1934
|
-
}> | {
|
|
1935
|
-
column: string;
|
|
1936
|
-
direction: "asc" | "desc";
|
|
1937
|
-
};
|
|
1938
|
-
/**
|
|
1939
|
-
* Normalize orderBy parameter to array format.
|
|
1940
|
-
* Supports 3 modes:
|
|
1941
|
-
* 1. String: "name" -> [{ column: "name", direction: "asc" }]
|
|
1942
|
-
* 2. Object: { column: "name", direction: "desc" } -> [{ column: "name", direction: "desc" }]
|
|
1943
|
-
* 3. Array: [{ column: "name" }, { column: "age", direction: "desc" }] -> normalized array
|
|
1944
|
-
*
|
|
1945
|
-
* @param orderBy The orderBy parameter
|
|
1946
|
-
* @returns Normalized array of order by clauses
|
|
1947
|
-
*/
|
|
1948
|
-
normalizeOrderBy(orderBy: any): Array<{
|
|
1949
|
-
column: string;
|
|
1950
|
-
direction: "asc" | "desc";
|
|
1951
|
-
}>;
|
|
1952
|
-
/**
|
|
1953
|
-
* Create a pagination object.
|
|
1954
|
-
*
|
|
1955
|
-
* @deprecated Use `createPagination` from alepha instead.
|
|
1956
|
-
* This method now delegates to the framework-level helper.
|
|
1957
|
-
*
|
|
1958
|
-
* @param entities The entities to paginate.
|
|
1959
|
-
* @param limit The limit of the pagination.
|
|
1960
|
-
* @param offset The offset of the pagination.
|
|
1961
|
-
* @param sort Optional sort metadata to include in response.
|
|
1962
|
-
*/
|
|
1963
|
-
createPagination<T>(entities: T[], limit?: number, offset?: number, sort?: Array<{
|
|
1964
|
-
column: string;
|
|
1965
|
-
direction: "asc" | "desc";
|
|
1966
|
-
}>): alepha1.Page<T>;
|
|
1967
|
-
}
|
|
1968
|
-
interface PgJoin {
|
|
1969
|
-
table: string;
|
|
1970
|
-
schema: TObject;
|
|
1971
|
-
key: string;
|
|
1972
|
-
col: (key: string) => PgColumn;
|
|
1973
|
-
parent?: string;
|
|
1974
|
-
}
|
|
1975
|
-
//#endregion
|
|
1976
|
-
//#region src/orm/services/PgRelationManager.d.ts
|
|
1977
|
-
declare class PgRelationManager {
|
|
1978
|
-
/**
|
|
1979
|
-
* Recursively build joins for the query builder based on the relations map
|
|
1980
|
-
*/
|
|
1981
|
-
buildJoins(provider: DatabaseProvider, builder: PgSelectBase<any, any, any>, joins: Array<PgJoin>, withRelations: PgRelationMap<TObject>, table: PgTableWithColumns<any>, parentKey?: string): void;
|
|
1982
|
-
/**
|
|
1983
|
-
* Map a row with its joined relations based on the joins definition
|
|
1984
|
-
*/
|
|
1985
|
-
mapRowWithJoins(record: Record<string, unknown>, row: Record<string, unknown>, schema: TObject, joins: PgJoin[], parentKey?: string): Record<string, unknown>;
|
|
1986
|
-
/**
|
|
1987
|
-
* Check if all values in an object are null (indicates a left join with no match)
|
|
1988
|
-
*/
|
|
1989
|
-
private isAllNull;
|
|
1990
|
-
/**
|
|
1991
|
-
* Build a schema that includes all join properties recursively
|
|
1992
|
-
*/
|
|
1993
|
-
buildSchemaWithJoins(baseSchema: TObject, joins: PgJoin[], parentPath?: string): TObject;
|
|
1994
|
-
}
|
|
1995
|
-
//#endregion
|
|
1996
|
-
//#region src/orm/services/Repository.d.ts
|
|
1997
|
-
declare abstract class Repository$1<T extends TObject> {
|
|
1998
|
-
readonly entity: EntityDescriptor<T>;
|
|
1999
|
-
readonly provider: DatabaseProvider;
|
|
2000
|
-
protected readonly relationManager: PgRelationManager;
|
|
2001
|
-
protected readonly queryManager: QueryManager;
|
|
2002
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2003
|
-
protected readonly alepha: Alepha;
|
|
2004
|
-
constructor(entity: EntityDescriptor<T>, provider?: typeof DatabaseProvider);
|
|
2005
|
-
/**
|
|
2006
|
-
* Represents the primary key of the table.
|
|
2007
|
-
* - Key is the name of the primary key column.
|
|
2008
|
-
* - Type is the type (TypeBox) of the primary key column.
|
|
2009
|
-
*
|
|
2010
|
-
* ID is mandatory. If the table does not have a primary key, it will throw an error.
|
|
2011
|
-
*/
|
|
2012
|
-
get id(): {
|
|
2013
|
-
type: TSchema;
|
|
2014
|
-
key: keyof T["properties"];
|
|
2015
|
-
col: PgColumn;
|
|
2016
|
-
};
|
|
2017
|
-
/**
|
|
2018
|
-
* Get Drizzle table object.
|
|
2019
|
-
*/
|
|
2020
|
-
get table(): PgTableWithColumns<SchemaToTableConfig<T>>;
|
|
2021
|
-
/**
|
|
2022
|
-
* Get SQL table name. (from Drizzle table object)
|
|
2023
|
-
*/
|
|
2024
|
-
get tableName(): string;
|
|
2025
|
-
/**
|
|
2026
|
-
* Getter for the database connection from the database provider.
|
|
2027
|
-
*/
|
|
2028
|
-
protected get db(): PgDatabase<any>;
|
|
2029
|
-
/**
|
|
2030
|
-
* Execute a SQL query.
|
|
2031
|
-
*
|
|
2032
|
-
* This method allows executing raw SQL queries against the database.
|
|
2033
|
-
* This is by far the easiest way to run custom queries that are not covered by the repository's built-in methods!
|
|
2034
|
-
*
|
|
2035
|
-
* You must use the `sql` tagged template function from Drizzle ORM to create the query. https://orm.drizzle.team/docs/sql
|
|
2036
|
-
*
|
|
2037
|
-
* @example
|
|
2038
|
-
* ```ts
|
|
2039
|
-
* class App {
|
|
2040
|
-
* repository = $repository({ ... });
|
|
2041
|
-
* async getAdults() {
|
|
2042
|
-
* const users = repository.table; // Drizzle table object
|
|
2043
|
-
* await repository.query(sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
2044
|
-
* // or better
|
|
2045
|
-
* await repository.query((users) => sql`SELECT * FROM ${users} WHERE ${users.age} > ${18}`);
|
|
2046
|
-
* }
|
|
2047
|
-
* }
|
|
2048
|
-
* ```
|
|
2049
|
-
*/
|
|
2050
|
-
query<R extends TObject = T>(query: SQLLike | ((table: PgTableWithColumns<SchemaToTableConfig<T>>, db: PgDatabase<any>) => SQLLike), schema?: R): Promise<Static<R>[]>;
|
|
2051
|
-
/**
|
|
2052
|
-
* Map raw database fields to entity fields. (handles column name differences)
|
|
2053
|
-
*/
|
|
2054
|
-
protected mapRawFieldsToEntity(row: Record<string, unknown>): any;
|
|
2055
|
-
/**
|
|
2056
|
-
* Get a Drizzle column from the table by his name.
|
|
2057
|
-
*/
|
|
2058
|
-
protected col(name: keyof StaticEncode<T>): PgColumn;
|
|
2059
|
-
/**
|
|
2060
|
-
* Run a transaction.
|
|
2061
|
-
*/
|
|
2062
|
-
transaction<T>(transaction: (tx: PgTransaction<any, Record<string, any>, any>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
2063
|
-
/**
|
|
2064
|
-
* Start a SELECT query on the table.
|
|
2065
|
-
*/
|
|
2066
|
-
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, {
|
|
2067
|
-
[x: string]: unknown;
|
|
2068
|
-
}[], {
|
|
2069
|
-
[x: string]: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
2070
|
-
}>;
|
|
2071
|
-
/**
|
|
2072
|
-
* Start a SELECT DISTINCT query on the table.
|
|
2073
|
-
*/
|
|
2074
|
-
protected rawSelectDistinct(opts?: StatementOptions, columns?: (keyof Static<T>)[]): drizzle_orm_pg_core0.PgSelectBase<string, Record<string, any>, "partial", Record<string, "not-null">, false, never, {
|
|
2075
|
-
[x: string]: any;
|
|
2076
|
-
}[], {
|
|
2077
|
-
[x: string]: any;
|
|
2078
|
-
}>;
|
|
2079
|
-
/**
|
|
2080
|
-
* Start an INSERT query on the table.
|
|
2081
|
-
*/
|
|
2082
|
-
protected rawInsert(opts?: StatementOptions): drizzle_orm_pg_core0.PgInsertBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any, false>;
|
|
2083
|
-
/**
|
|
2084
|
-
* Start an UPDATE query on the table.
|
|
2085
|
-
*/
|
|
2086
|
-
protected rawUpdate(opts?: StatementOptions): drizzle_orm_pg_core0.PgUpdateBuilder<PgTableWithColumns<SchemaToTableConfig<T>>, any>;
|
|
2087
|
-
/**
|
|
2088
|
-
* Start a DELETE query on the table.
|
|
2089
|
-
*/
|
|
2090
|
-
protected rawDelete(opts?: StatementOptions): drizzle_orm_pg_core0.PgDeleteBase<PgTableWithColumns<SchemaToTableConfig<T>>, any, undefined, undefined, false, never>;
|
|
2091
|
-
/**
|
|
2092
|
-
* Create a Drizzle `select` query based on a JSON query object.
|
|
2093
|
-
*
|
|
2094
|
-
* > This method is the base for `find`, `findOne`, `findById`, and `paginate`.
|
|
2095
|
-
*/
|
|
2096
|
-
findMany<R extends PgRelationMap<T>>(query?: PgQueryRelations<T, R>, opts?: StatementOptions): Promise<PgStatic<T, R>[]>;
|
|
2097
|
-
/**
|
|
2098
|
-
* Find a single entity.
|
|
2099
|
-
*/
|
|
2100
|
-
findOne<R extends PgRelationMap<T>>(query: Pick<PgQueryRelations<T, R>, "with" | "where">, opts?: StatementOptions): Promise<PgStatic<T, R>>;
|
|
2101
|
-
/**
|
|
2102
|
-
* Find entities with pagination.
|
|
2103
|
-
*
|
|
2104
|
-
* It uses the same parameters as `find()`, but adds pagination metadata to the response.
|
|
2105
|
-
*
|
|
2106
|
-
* > Pagination CAN also do a count query to get the total number of elements.
|
|
2107
|
-
*/
|
|
2108
|
-
paginate<R extends PgRelationMap<T>>(pagination?: PageQuery, query?: PgQueryRelations<T, R>, opts?: StatementOptions & {
|
|
2109
|
-
count?: boolean;
|
|
2110
|
-
}): Promise<Page<PgStatic<T, R>>>;
|
|
2111
|
-
/**
|
|
2112
|
-
* Find an entity by ID.
|
|
2113
|
-
*
|
|
2114
|
-
* This is a convenience method for `findOne` with a where clause on the primary key.
|
|
2115
|
-
* If you need more complex queries, use `findOne` instead.
|
|
2116
|
-
*/
|
|
2117
|
-
findById(id: string | number, opts?: StatementOptions): Promise<Static<T>>;
|
|
2118
|
-
/**
|
|
2119
|
-
* Helper to create a type-safe query object.
|
|
2120
|
-
*/
|
|
2121
|
-
createQuery(): PgQuery<T>;
|
|
2122
|
-
/**
|
|
2123
|
-
* Helper to create a type-safe where clause.
|
|
2124
|
-
*/
|
|
2125
|
-
createQueryWhere(): PgQueryWhere<T>;
|
|
2126
|
-
/**
|
|
2127
|
-
* Create an entity.
|
|
2128
|
-
*
|
|
2129
|
-
* @param data The entity to create.
|
|
2130
|
-
* @param opts The options for creating the entity.
|
|
2131
|
-
* @returns The ID of the created entity.
|
|
2132
|
-
*/
|
|
2133
|
-
create(data: Static<TObjectInsert<T>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
2134
|
-
/**
|
|
2135
|
-
* Create many entities.
|
|
2136
|
-
*
|
|
2137
|
-
* @param values The entities to create.
|
|
2138
|
-
* @param opts The statement options.
|
|
2139
|
-
* @returns The created entities.
|
|
2140
|
-
*/
|
|
2141
|
-
createMany(values: Array<Static<TObjectInsert<T>>>, opts?: StatementOptions): Promise<Static<T>[]>;
|
|
2142
|
-
/**
|
|
2143
|
-
* Find an entity and update it.
|
|
2144
|
-
*/
|
|
2145
|
-
updateOne(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
2146
|
-
/**
|
|
2147
|
-
* Save a given entity.
|
|
2148
|
-
*
|
|
2149
|
-
* @example
|
|
2150
|
-
* ```ts
|
|
2151
|
-
* const entity = await repository.findById(1);
|
|
2152
|
-
* entity.name = "New Name"; // update a field
|
|
2153
|
-
* delete entity.description; // delete a field
|
|
2154
|
-
* await repository.save(entity);
|
|
2155
|
-
* ```
|
|
2156
|
-
*
|
|
2157
|
-
* Difference with `updateById/updateOne`:
|
|
2158
|
-
*
|
|
2159
|
-
* - requires the entity to be fetched first (whole object is expected)
|
|
2160
|
-
* - check pg.version() if present -> optimistic locking
|
|
2161
|
-
* - validate entity against schema
|
|
2162
|
-
* - undefined values will be set to null, not ignored!
|
|
2163
|
-
*
|
|
2164
|
-
* @see {@link DbVersionMismatchError}
|
|
2165
|
-
*/
|
|
2166
|
-
save(entity: Static<T>, opts?: StatementOptions): Promise<void>;
|
|
2167
|
-
/**
|
|
2168
|
-
* Find an entity by ID and update it.
|
|
2169
|
-
*/
|
|
2170
|
-
updateById(id: string | number, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Static<T>>;
|
|
2171
|
-
/**
|
|
2172
|
-
* Find many entities and update all of them.
|
|
2173
|
-
*/
|
|
2174
|
-
updateMany(where: PgQueryWhereOrSQL<T>, data: Partial<Static<TObjectUpdate<T>>>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2175
|
-
/**
|
|
2176
|
-
* Find many and delete all of them.
|
|
2177
|
-
* @returns Array of deleted entity IDs
|
|
2178
|
-
*/
|
|
2179
|
-
deleteMany(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2180
|
-
/**
|
|
2181
|
-
* Delete all entities.
|
|
2182
|
-
* @returns Array of deleted entity IDs
|
|
2183
|
-
*/
|
|
2184
|
-
clear(opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2185
|
-
/**
|
|
2186
|
-
* Delete the given entity.
|
|
2187
|
-
*
|
|
2188
|
-
* You must fetch the entity first in order to delete it.
|
|
2189
|
-
* @returns Array containing the deleted entity ID
|
|
2190
|
-
*/
|
|
2191
|
-
destroy(entity: Static<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2192
|
-
/**
|
|
2193
|
-
* Find an entity and delete it.
|
|
2194
|
-
* @returns Array of deleted entity IDs (should contain at most one ID)
|
|
2195
|
-
*/
|
|
2196
|
-
deleteOne(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2197
|
-
/**
|
|
2198
|
-
* Find an entity by ID and delete it.
|
|
2199
|
-
* @returns Array containing the deleted entity ID
|
|
2200
|
-
* @throws DbEntityNotFoundError if the entity is not found
|
|
2201
|
-
*/
|
|
2202
|
-
deleteById(id: string | number, opts?: StatementOptions): Promise<Array<number | string>>;
|
|
2203
|
-
/**
|
|
2204
|
-
* Count entities.
|
|
2205
|
-
*/
|
|
2206
|
-
count(where?: PgQueryWhereOrSQL<T>, opts?: StatementOptions): Promise<number>;
|
|
2207
|
-
protected conflictMessagePattern: string;
|
|
2208
|
-
protected handleError(error: unknown, message: string): DbError;
|
|
2209
|
-
protected withDeletedAt(where: PgQueryWhereOrSQL<T>, opts?: {
|
|
2210
|
-
force?: boolean;
|
|
2211
|
-
}): PgQueryWhereOrSQL<T>;
|
|
2212
|
-
protected deletedAt(): PgAttrField | undefined;
|
|
2213
|
-
/**
|
|
2214
|
-
* Convert something to valid Pg Insert Value.
|
|
2215
|
-
*/
|
|
2216
|
-
protected cast(data: any, insert: boolean): PgInsertValue<PgTableWithColumns<SchemaToTableConfig<T>>>;
|
|
2217
|
-
/**
|
|
2218
|
-
* Transform a row from the database into a clean entity.
|
|
2219
|
-
*/
|
|
2220
|
-
protected clean<T extends TObject>(row: Record<string, unknown>, schema: T): Static<T>;
|
|
2221
|
-
/**
|
|
2222
|
-
* Clean a row with joins recursively
|
|
2223
|
-
*/
|
|
2224
|
-
protected cleanWithJoins<T extends TObject>(row: Record<string, unknown>, schema: T, joins: PgJoin[], parentPath?: string): Static<T>;
|
|
2225
|
-
/**
|
|
2226
|
-
* Convert a where clause to SQL.
|
|
2227
|
-
*/
|
|
2228
|
-
protected toSQL(where: PgQueryWhereOrSQL<T>, joins?: PgJoin[]): SQL | undefined;
|
|
2229
|
-
/**
|
|
2230
|
-
* Get the where clause for an ID.
|
|
2231
|
-
*
|
|
2232
|
-
* @param id The ID to get the where clause for.
|
|
2233
|
-
* @returns The where clause for the ID.
|
|
2234
|
-
*/
|
|
2235
|
-
protected getWhereId(id: string | number): PgQueryWhere<T>;
|
|
2236
|
-
/**
|
|
2237
|
-
* Find a primary key in the schema.
|
|
2238
|
-
*/
|
|
2239
|
-
protected getPrimaryKey(schema: TObject): {
|
|
2240
|
-
key: string;
|
|
2241
|
-
col: PgColumn<drizzle_orm0.ColumnBaseConfig<drizzle_orm0.ColumnDataType, string>, {}, {}>;
|
|
2242
|
-
type: TSchema;
|
|
2243
|
-
};
|
|
2244
|
-
}
|
|
2245
|
-
/**
|
|
2246
|
-
* The options for a statement.
|
|
2247
|
-
*/
|
|
2248
|
-
interface StatementOptions {
|
|
2249
|
-
/**
|
|
2250
|
-
* Transaction to use.
|
|
2251
|
-
*/
|
|
2252
|
-
tx?: PgTransaction<any, Record<string, any>>;
|
|
2253
|
-
/**
|
|
2254
|
-
* Lock strength.
|
|
2255
|
-
*/
|
|
2256
|
-
for?: LockStrength | {
|
|
2257
|
-
config: LockConfig;
|
|
2258
|
-
strength: LockStrength;
|
|
2259
|
-
};
|
|
2260
|
-
/**
|
|
2261
|
-
* If true, ignore soft delete.
|
|
2262
|
-
*/
|
|
2263
|
-
force?: boolean;
|
|
2264
|
-
/**
|
|
2265
|
-
* Force the current time.
|
|
2266
|
-
*/
|
|
2267
|
-
now?: DateTime | string;
|
|
2268
|
-
}
|
|
2269
|
-
//#endregion
|
|
2270
|
-
//#region src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
2271
|
-
declare module "alepha" {
|
|
2272
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
2273
|
-
}
|
|
2274
|
-
declare const envSchema: alepha1.TObject<{
|
|
2275
|
-
/**
|
|
2276
|
-
* Main configuration for database connection.
|
|
2277
|
-
* Accept a string in the format of a Postgres connection URL.
|
|
2278
|
-
* Example: postgres://user:password@localhost:5432/database
|
|
2279
|
-
* or
|
|
2280
|
-
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
2281
|
-
*/
|
|
2282
|
-
DATABASE_URL: alepha1.TOptional<alepha1.TString>;
|
|
2283
|
-
/**
|
|
2284
|
-
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
2285
|
-
*
|
|
2286
|
-
* It will monkey patch drizzle tables.
|
|
2287
|
-
*/
|
|
2288
|
-
POSTGRES_SCHEMA: alepha1.TOptional<alepha1.TString>;
|
|
2289
|
-
}>;
|
|
2290
|
-
//#endregion
|
|
2291
|
-
//#region src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
2292
|
-
/**
|
|
2293
|
-
* Configuration options for the Node.js SQLite database provider.
|
|
2294
|
-
*/
|
|
2295
|
-
declare const nodeSqliteOptions: alepha1.Atom<alepha1.TObject<{
|
|
2296
|
-
path: alepha1.TOptional<alepha1.TString>;
|
|
2297
|
-
}>, "alepha.postgres.node-sqlite.options">;
|
|
2298
|
-
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
2299
|
-
declare module "alepha" {
|
|
2300
|
-
interface State {
|
|
2301
|
-
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
/**
|
|
2305
|
-
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
2306
|
-
*
|
|
2307
|
-
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
2308
|
-
* This is NOT recommended for production use.
|
|
2309
|
-
*/
|
|
2310
|
-
//#endregion
|
|
2311
|
-
//#region src/orm/index.d.ts
|
|
2312
|
-
declare module "alepha" {
|
|
2313
|
-
interface Hooks {
|
|
2314
|
-
/**
|
|
2315
|
-
* Fires before creating an entity in the repository.
|
|
2316
|
-
*/
|
|
2317
|
-
"repository:create:before": {
|
|
2318
|
-
tableName: string;
|
|
2319
|
-
data: any;
|
|
2320
|
-
};
|
|
2321
|
-
/**
|
|
2322
|
-
* Fires after creating an entity in the repository.
|
|
2323
|
-
*/
|
|
2324
|
-
"repository:create:after": {
|
|
2325
|
-
tableName: string;
|
|
2326
|
-
data: any;
|
|
2327
|
-
entity: any;
|
|
2328
|
-
};
|
|
2329
|
-
/**
|
|
2330
|
-
* Fires before updating entities in the repository.
|
|
2331
|
-
*/
|
|
2332
|
-
"repository:update:before": {
|
|
2333
|
-
tableName: string;
|
|
2334
|
-
where: any;
|
|
2335
|
-
data: any;
|
|
2336
|
-
};
|
|
2337
|
-
/**
|
|
2338
|
-
* Fires after updating entities in the repository.
|
|
2339
|
-
*/
|
|
2340
|
-
"repository:update:after": {
|
|
2341
|
-
tableName: string;
|
|
2342
|
-
where: any;
|
|
2343
|
-
data: any;
|
|
2344
|
-
entities: any[];
|
|
2345
|
-
};
|
|
2346
|
-
/**
|
|
2347
|
-
* Fires before deleting entities from the repository.
|
|
2348
|
-
*/
|
|
2349
|
-
"repository:delete:before": {
|
|
2350
|
-
tableName: string;
|
|
2351
|
-
where: any;
|
|
2352
|
-
};
|
|
2353
|
-
/**
|
|
2354
|
-
* Fires after deleting entities from the repository.
|
|
2355
|
-
*/
|
|
2356
|
-
"repository:delete:after": {
|
|
2357
|
-
tableName: string;
|
|
2358
|
-
where: any;
|
|
2359
|
-
ids: Array<string | number>;
|
|
2360
|
-
};
|
|
2361
|
-
/**
|
|
2362
|
-
* Fires before reading entities from the repository.
|
|
2363
|
-
*/
|
|
2364
|
-
"repository:read:before": {
|
|
2365
|
-
tableName: string;
|
|
2366
|
-
query: any;
|
|
2367
|
-
};
|
|
2368
|
-
/**
|
|
2369
|
-
* Fires after reading entities from the repository.
|
|
2370
|
-
*/
|
|
2371
|
-
"repository:read:after": {
|
|
2372
|
-
tableName: string;
|
|
2373
|
-
query: any;
|
|
2374
|
-
entities: any[];
|
|
2375
|
-
};
|
|
2376
|
-
}
|
|
2377
|
-
}
|
|
2378
|
-
//#endregion
|
|
2379
|
-
//#region src/api-verifications/entities/verifications.d.ts
|
|
2380
|
-
declare const verifications: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
2381
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2382
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2383
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2384
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2385
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2386
|
-
target: alepha1.TString;
|
|
2387
|
-
code: alepha1.TString;
|
|
2388
|
-
verifiedAt: alepha1.TOptional<alepha1.TString>;
|
|
2389
|
-
attempts: alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_DEFAULT>;
|
|
2390
|
-
}>>;
|
|
2391
|
-
type VerificationEntity = Static<typeof verifications.schema>;
|
|
2392
|
-
//#endregion
|
|
2393
|
-
//#region src/api-verifications/schemas/verificationSettingsSchema.d.ts
|
|
2394
|
-
declare const verificationSettingsSchema: alepha1.TObject<{
|
|
2395
|
-
code: alepha1.TObject<{
|
|
2396
|
-
maxAttempts: alepha1.TInteger;
|
|
2397
|
-
codeLength: alepha1.TInteger;
|
|
2398
|
-
codeExpiration: alepha1.TInteger;
|
|
2399
|
-
verificationCooldown: alepha1.TInteger;
|
|
2400
|
-
limitPerDay: alepha1.TInteger;
|
|
2401
|
-
}>;
|
|
2402
|
-
link: alepha1.TObject<{
|
|
2403
|
-
maxAttempts: alepha1.TInteger;
|
|
2404
|
-
codeExpiration: alepha1.TInteger;
|
|
2405
|
-
verificationCooldown: alepha1.TInteger;
|
|
2406
|
-
limitPerDay: alepha1.TInteger;
|
|
2407
|
-
}>;
|
|
2408
|
-
purgeDays: alepha1.TInteger;
|
|
2409
|
-
}>;
|
|
2410
|
-
type VerificationSettings = Static<typeof verificationSettingsSchema>;
|
|
2411
|
-
//#endregion
|
|
2412
|
-
//#region src/api-verifications/parameters/VerificationParameters.d.ts
|
|
2413
|
-
/**
|
|
2414
|
-
* Verification settings configuration atom
|
|
2415
|
-
*/
|
|
2416
|
-
declare const verificationOptions: alepha1.Atom<alepha1.TObject<{
|
|
2417
|
-
code: alepha1.TObject<{
|
|
2418
|
-
maxAttempts: alepha1.TInteger;
|
|
2419
|
-
codeLength: alepha1.TInteger;
|
|
2420
|
-
codeExpiration: alepha1.TInteger;
|
|
2421
|
-
verificationCooldown: alepha1.TInteger;
|
|
2422
|
-
limitPerDay: alepha1.TInteger;
|
|
2423
|
-
}>;
|
|
2424
|
-
link: alepha1.TObject<{
|
|
2425
|
-
maxAttempts: alepha1.TInteger;
|
|
2426
|
-
codeExpiration: alepha1.TInteger;
|
|
2427
|
-
verificationCooldown: alepha1.TInteger;
|
|
2428
|
-
limitPerDay: alepha1.TInteger;
|
|
2429
|
-
}>;
|
|
2430
|
-
purgeDays: alepha1.TInteger;
|
|
2431
|
-
}>, "alepha.api.verifications.options">;
|
|
2432
|
-
type VerificationOptions = Static<typeof verificationOptions.schema>;
|
|
2433
|
-
declare module "alepha" {
|
|
2434
|
-
interface State {
|
|
2435
|
-
[verificationOptions.key]: VerificationOptions;
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
declare class VerificationParameters {
|
|
2439
|
-
protected readonly options: Readonly<{
|
|
2440
|
-
link: {
|
|
2441
|
-
maxAttempts: number;
|
|
2442
|
-
codeExpiration: number;
|
|
2443
|
-
verificationCooldown: number;
|
|
2444
|
-
limitPerDay: number;
|
|
2445
|
-
};
|
|
2446
|
-
code: {
|
|
2447
|
-
maxAttempts: number;
|
|
2448
|
-
codeLength: number;
|
|
2449
|
-
codeExpiration: number;
|
|
2450
|
-
verificationCooldown: number;
|
|
2451
|
-
limitPerDay: number;
|
|
2452
|
-
};
|
|
2453
|
-
purgeDays: number;
|
|
2454
|
-
}>;
|
|
2455
|
-
get<K$1 extends keyof VerificationSettings>(key: K$1): VerificationSettings[K$1];
|
|
2456
|
-
}
|
|
2457
|
-
//#endregion
|
|
2458
|
-
//#region src/api-verifications/schemas/requestVerificationCodeResponseSchema.d.ts
|
|
2459
|
-
declare const requestVerificationCodeResponseSchema: alepha1.TObject<{
|
|
2460
|
-
token: alepha1.TString;
|
|
2461
|
-
codeExpiration: alepha1.TInteger;
|
|
2462
|
-
verificationCooldown: alepha1.TInteger;
|
|
2463
|
-
maxVerificationAttempts: alepha1.TInteger;
|
|
2464
|
-
}>;
|
|
2465
|
-
type RequestVerificationResponse = Static<typeof requestVerificationCodeResponseSchema>;
|
|
2466
|
-
//#endregion
|
|
2467
|
-
//#region src/api-verifications/schemas/validateVerificationCodeResponseSchema.d.ts
|
|
2468
|
-
declare const validateVerificationCodeResponseSchema: alepha1.TObject<{
|
|
2469
|
-
ok: alepha1.TBoolean;
|
|
2470
|
-
alreadyVerified: alepha1.TOptional<alepha1.TBoolean>;
|
|
2471
|
-
}>;
|
|
2472
|
-
type ValidateVerificationCodeResponse = Static<typeof validateVerificationCodeResponseSchema>;
|
|
2473
|
-
//#endregion
|
|
2474
|
-
//#region src/api-verifications/schemas/verificationTypeEnumSchema.d.ts
|
|
2475
|
-
declare const verificationTypeEnumSchema: alepha1.TUnsafe<"link" | "code">;
|
|
2476
|
-
type VerificationTypeEnum = Static<typeof verificationTypeEnumSchema>;
|
|
2477
|
-
//#endregion
|
|
2478
|
-
//#region src/api-verifications/services/VerificationService.d.ts
|
|
2479
|
-
declare class VerificationService {
|
|
2480
|
-
protected readonly log: alepha_logger1.Logger;
|
|
2481
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2482
|
-
protected readonly verificationParameters: VerificationParameters;
|
|
2483
|
-
protected readonly verificationRepository: alepha_orm198.Repository<alepha1.TObject<{
|
|
2484
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2485
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2486
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2487
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2488
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2489
|
-
target: alepha1.TString;
|
|
2490
|
-
code: alepha1.TString;
|
|
2491
|
-
verifiedAt: alepha1.TOptional<alepha1.TString>;
|
|
2492
|
-
attempts: alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_DEFAULT>;
|
|
2493
|
-
}>>;
|
|
2494
|
-
findByEntry(entry: VerificationEntry): Promise<VerificationEntity>;
|
|
2495
|
-
findRecentsByEntry(entry: VerificationEntry): Promise<alepha_orm198.PgStatic<alepha1.TObject<{
|
|
2496
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2497
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2498
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2499
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2500
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2501
|
-
target: alepha1.TString;
|
|
2502
|
-
code: alepha1.TString;
|
|
2503
|
-
verifiedAt: alepha1.TOptional<alepha1.TString>;
|
|
2504
|
-
attempts: alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_DEFAULT>;
|
|
2505
|
-
}>, alepha_orm198.PgRelationMap<alepha1.TObject<{
|
|
2506
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2507
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2508
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2509
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2510
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2511
|
-
target: alepha1.TString;
|
|
2512
|
-
code: alepha1.TString;
|
|
2513
|
-
verifiedAt: alepha1.TOptional<alepha1.TString>;
|
|
2514
|
-
attempts: alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_DEFAULT>;
|
|
2515
|
-
}>>>[]>;
|
|
2516
|
-
/**
|
|
2517
|
-
* Creates a verification entry and returns the token.
|
|
2518
|
-
* The caller is responsible for sending notifications with the token.
|
|
2519
|
-
* This allows for context-specific notifications (e.g., password reset vs email verification).
|
|
2520
|
-
*/
|
|
2521
|
-
createVerification(entry: VerificationEntry): Promise<RequestVerificationResponse>;
|
|
2522
|
-
verifyCode(entry: VerificationEntry, code: string): Promise<ValidateVerificationCodeResponse>;
|
|
2523
|
-
hashCode(code: string): string;
|
|
2524
|
-
generateToken(type: VerificationTypeEnum): string;
|
|
2525
|
-
}
|
|
2526
|
-
interface VerificationEntry {
|
|
2527
|
-
type: VerificationTypeEnum;
|
|
2528
|
-
target: string;
|
|
2529
|
-
}
|
|
2530
|
-
//#endregion
|
|
2531
|
-
//#region src/api-verifications/controllers/VerificationController.d.ts
|
|
2532
|
-
declare class VerificationController {
|
|
2533
|
-
protected readonly verificationService: VerificationService;
|
|
2534
|
-
readonly url = "/verifications";
|
|
2535
|
-
readonly group = "verifications";
|
|
2536
|
-
readonly requestVerificationCode: alepha_server0.ActionDescriptorFn<{
|
|
2537
|
-
params: alepha1.TObject<{
|
|
2538
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2539
|
-
}>;
|
|
2540
|
-
body: alepha1.TObject<{
|
|
2541
|
-
target: alepha1.TString;
|
|
2542
|
-
}>;
|
|
2543
|
-
response: alepha1.TObject<{
|
|
2544
|
-
token: alepha1.TString;
|
|
2545
|
-
codeExpiration: alepha1.TInteger;
|
|
2546
|
-
verificationCooldown: alepha1.TInteger;
|
|
2547
|
-
maxVerificationAttempts: alepha1.TInteger;
|
|
2548
|
-
}>;
|
|
2549
|
-
}>;
|
|
2550
|
-
readonly validateVerificationCode: alepha_server0.ActionDescriptorFn<{
|
|
2551
|
-
params: alepha1.TObject<{
|
|
2552
|
-
type: alepha1.TUnsafe<"link" | "code">;
|
|
2553
|
-
}>;
|
|
2554
|
-
body: alepha1.TObject<{
|
|
2555
|
-
target: alepha1.TString;
|
|
2556
|
-
token: alepha1.TString;
|
|
2557
|
-
}>;
|
|
2558
|
-
response: alepha1.TObject<{
|
|
2559
|
-
ok: alepha1.TBoolean;
|
|
2560
|
-
alreadyVerified: alepha1.TOptional<alepha1.TBoolean>;
|
|
2561
|
-
}>;
|
|
2562
|
-
}>;
|
|
2563
|
-
}
|
|
2564
|
-
//#endregion
|
|
2565
|
-
//#region src/api-notifications/schemas/notificationCreateSchema.d.ts
|
|
2566
|
-
declare const notificationCreateSchema: alepha1.TObject<{
|
|
2567
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2568
|
-
template: alepha1.TString;
|
|
2569
|
-
contact: alepha1.TString;
|
|
2570
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2571
|
-
}>;
|
|
2572
|
-
type NotificationCreate = Static<typeof notificationCreateSchema>;
|
|
2573
|
-
//#endregion
|
|
2574
|
-
//#region src/api-notifications/entities/notifications.d.ts
|
|
2575
|
-
declare const notifications: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
2576
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2577
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2578
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2579
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2580
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2581
|
-
template: alepha1.TString;
|
|
2582
|
-
category: alepha1.TOptional<alepha1.TString>;
|
|
2583
|
-
critical: alepha1.TOptional<alepha1.TBoolean>;
|
|
2584
|
-
sensitive: alepha1.TOptional<alepha1.TBoolean>;
|
|
2585
|
-
contact: alepha1.TString;
|
|
2586
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2587
|
-
scheduledAt: alepha1.TOptional<alepha1.TString>;
|
|
2588
|
-
sentAt: alepha1.TOptional<alepha1.TString>;
|
|
2589
|
-
error: alepha1.TOptional<alepha1.TObject<{
|
|
2590
|
-
at: alepha1.TString;
|
|
2591
|
-
name: alepha1.TString;
|
|
2592
|
-
message: alepha1.TString;
|
|
2593
|
-
}>>;
|
|
2594
|
-
}>>;
|
|
2595
|
-
type NotificationEntity = Static<typeof notifications.schema>;
|
|
2596
|
-
//#endregion
|
|
2597
|
-
//#region src/api-notifications/providers/SmsProvider.d.ts
|
|
2598
|
-
declare abstract class SmsProvider {
|
|
2599
|
-
abstract send(options: SmsSendOptions): Promise<void>;
|
|
2600
|
-
}
|
|
2601
|
-
interface SmsSendOptions {
|
|
2602
|
-
to: string;
|
|
2603
|
-
message: string;
|
|
2604
|
-
}
|
|
2605
|
-
//#endregion
|
|
2606
|
-
//#region src/api-notifications/services/NotificationSenderService.d.ts
|
|
2607
|
-
declare class NotificationSenderService {
|
|
2608
|
-
protected readonly alepha: Alepha;
|
|
2609
|
-
protected readonly log: alepha_logger1.Logger;
|
|
2610
|
-
protected readonly notificationRepository: alepha_orm198.Repository<alepha1.TObject<{
|
|
2611
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2612
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2613
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2614
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2615
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2616
|
-
template: alepha1.TString;
|
|
2617
|
-
category: alepha1.TOptional<alepha1.TString>;
|
|
2618
|
-
critical: alepha1.TOptional<alepha1.TBoolean>;
|
|
2619
|
-
sensitive: alepha1.TOptional<alepha1.TBoolean>;
|
|
2620
|
-
contact: alepha1.TString;
|
|
2621
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2622
|
-
scheduledAt: alepha1.TOptional<alepha1.TString>;
|
|
2623
|
-
sentAt: alepha1.TOptional<alepha1.TString>;
|
|
2624
|
-
error: alepha1.TOptional<alepha1.TObject<{
|
|
2625
|
-
at: alepha1.TString;
|
|
2626
|
-
name: alepha1.TString;
|
|
2627
|
-
message: alepha1.TString;
|
|
2628
|
-
}>>;
|
|
2629
|
-
}>>;
|
|
2630
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2631
|
-
protected readonly emailProvider: EmailProvider;
|
|
2632
|
-
protected readonly smsProvider: SmsProvider;
|
|
2633
|
-
send(notificationId: string | NotificationEntity): Promise<void>;
|
|
2634
|
-
renderSms(notification: NotificationEntity): {
|
|
2635
|
-
to: string;
|
|
2636
|
-
message: string;
|
|
2637
|
-
};
|
|
2638
|
-
renderEmail(notification: NotificationEntity): {
|
|
2639
|
-
to: string;
|
|
2640
|
-
subject: string;
|
|
2641
|
-
body: string;
|
|
2642
|
-
};
|
|
2643
|
-
protected load(notification: NotificationEntity): {
|
|
2644
|
-
template: NotificationDescriptor<alepha1.TObject<alepha1.TProperties>>;
|
|
2645
|
-
variables: Record<string, any>;
|
|
2646
|
-
contact: string;
|
|
2647
|
-
};
|
|
2648
|
-
}
|
|
2649
|
-
//#endregion
|
|
2650
|
-
//#region src/api-notifications/services/NotificationService.d.ts
|
|
2651
|
-
declare const notificationServiceEnvSchema: alepha1.TObject<{
|
|
2652
|
-
NOTIFICATION_QUEUE: alepha1.TOptional<alepha1.TBoolean>;
|
|
2653
|
-
}>;
|
|
2654
|
-
declare module "alepha" {
|
|
2655
|
-
interface Env extends Partial<Static<typeof notificationServiceEnvSchema>> {}
|
|
2656
|
-
}
|
|
2657
|
-
declare class NotificationService {
|
|
2658
|
-
protected readonly alepha: Alepha;
|
|
2659
|
-
protected readonly log: alepha_logger1.Logger;
|
|
2660
|
-
protected readonly env: {
|
|
2661
|
-
NOTIFICATION_QUEUE?: boolean | undefined;
|
|
2662
|
-
};
|
|
2663
|
-
protected readonly notificationRepository: alepha_orm198.Repository<alepha1.TObject<{
|
|
2664
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2665
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2666
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2667
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2668
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2669
|
-
template: alepha1.TString;
|
|
2670
|
-
category: alepha1.TOptional<alepha1.TString>;
|
|
2671
|
-
critical: alepha1.TOptional<alepha1.TBoolean>;
|
|
2672
|
-
sensitive: alepha1.TOptional<alepha1.TBoolean>;
|
|
2673
|
-
contact: alepha1.TString;
|
|
2674
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2675
|
-
scheduledAt: alepha1.TOptional<alepha1.TString>;
|
|
2676
|
-
sentAt: alepha1.TOptional<alepha1.TString>;
|
|
2677
|
-
error: alepha1.TOptional<alepha1.TObject<{
|
|
2678
|
-
at: alepha1.TString;
|
|
2679
|
-
name: alepha1.TString;
|
|
2680
|
-
message: alepha1.TString;
|
|
2681
|
-
}>>;
|
|
2682
|
-
}>>;
|
|
2683
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2684
|
-
protected readonly notificationSenderService: NotificationSenderService;
|
|
2685
|
-
readonly notificationBatch: alepha_batch0.BatchDescriptor<alepha1.TObject<{
|
|
2686
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2687
|
-
template: alepha1.TString;
|
|
2688
|
-
contact: alepha1.TString;
|
|
2689
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2690
|
-
}>, Promise<void>>;
|
|
2691
|
-
findNotificationById(id: string): Promise<alepha_orm198.PgStatic<alepha1.TObject<{
|
|
2692
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2693
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2694
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2695
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2696
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2697
|
-
template: alepha1.TString;
|
|
2698
|
-
category: alepha1.TOptional<alepha1.TString>;
|
|
2699
|
-
critical: alepha1.TOptional<alepha1.TBoolean>;
|
|
2700
|
-
sensitive: alepha1.TOptional<alepha1.TBoolean>;
|
|
2701
|
-
contact: alepha1.TString;
|
|
2702
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2703
|
-
scheduledAt: alepha1.TOptional<alepha1.TString>;
|
|
2704
|
-
sentAt: alepha1.TOptional<alepha1.TString>;
|
|
2705
|
-
error: alepha1.TOptional<alepha1.TObject<{
|
|
2706
|
-
at: alepha1.TString;
|
|
2707
|
-
name: alepha1.TString;
|
|
2708
|
-
message: alepha1.TString;
|
|
2709
|
-
}>>;
|
|
2710
|
-
}>, alepha_orm198.PgRelationMap<alepha1.TObject<{
|
|
2711
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2712
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2713
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2714
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
2715
|
-
type: alepha1.TUnsafe<"email" | "sms">;
|
|
2716
|
-
template: alepha1.TString;
|
|
2717
|
-
category: alepha1.TOptional<alepha1.TString>;
|
|
2718
|
-
critical: alepha1.TOptional<alepha1.TBoolean>;
|
|
2719
|
-
sensitive: alepha1.TOptional<alepha1.TBoolean>;
|
|
2720
|
-
contact: alepha1.TString;
|
|
2721
|
-
variables: alepha1.TOptional<alepha1.TRecord<"^.*$", alepha1.TAny>>;
|
|
2722
|
-
scheduledAt: alepha1.TOptional<alepha1.TString>;
|
|
2723
|
-
sentAt: alepha1.TOptional<alepha1.TString>;
|
|
2724
|
-
error: alepha1.TOptional<alepha1.TObject<{
|
|
2725
|
-
at: alepha1.TString;
|
|
2726
|
-
name: alepha1.TString;
|
|
2727
|
-
message: alepha1.TString;
|
|
2728
|
-
}>>;
|
|
2729
|
-
}>>>>;
|
|
2730
|
-
/**
|
|
2731
|
-
* Create a new notification.
|
|
2732
|
-
*/
|
|
2733
|
-
createNotification(entry: NotificationCreate): Promise<void>;
|
|
2734
|
-
}
|
|
2735
|
-
//#endregion
|
|
2736
|
-
//#region src/api-notifications/descriptors/$notification.d.ts
|
|
2737
|
-
interface NotificationDescriptorOptions<T extends TObject> extends NotificationMessage<T> {
|
|
2738
|
-
name?: string;
|
|
2739
|
-
description?: string;
|
|
2740
|
-
category?: string;
|
|
2741
|
-
critical?: boolean;
|
|
2742
|
-
sensitive?: boolean;
|
|
2743
|
-
translations?: {
|
|
2744
|
-
[lang: string]: NotificationMessage<T>;
|
|
2745
|
-
};
|
|
2746
|
-
schema: T;
|
|
2747
|
-
}
|
|
2748
|
-
declare class NotificationDescriptor<T extends TObject> extends Descriptor<NotificationDescriptorOptions<T>> {
|
|
2749
|
-
protected readonly notificationService: NotificationService;
|
|
2750
|
-
get name(): string;
|
|
2751
|
-
push(options: NotificationPushOptions<T>): Promise<void>;
|
|
2752
|
-
configure(options: Partial<NotificationDescriptorOptions<T>>): void;
|
|
2753
|
-
}
|
|
2754
|
-
interface NotificationPushOptions<T extends TObject> {
|
|
2755
|
-
variables: StaticEncode<T>;
|
|
2756
|
-
contact: string;
|
|
2757
|
-
}
|
|
2758
|
-
interface NotificationMessage<T extends TObject> {
|
|
2759
|
-
email?: {
|
|
2760
|
-
subject: string;
|
|
2761
|
-
body: string | ((variables: Static<T>) => string);
|
|
2762
|
-
};
|
|
2763
|
-
sms?: {
|
|
2764
|
-
message: string | ((variables: Static<T>) => string);
|
|
2765
|
-
};
|
|
2766
|
-
}
|
|
2767
|
-
//#endregion
|
|
2768
|
-
//#region src/api-users/notifications/UserNotifications.d.ts
|
|
2769
|
-
declare class UserNotifications {
|
|
2770
|
-
readonly passwordReset: NotificationDescriptor<alepha1.TObject<{
|
|
2771
|
-
email: alepha1.TString;
|
|
2772
|
-
code: alepha1.TString;
|
|
2773
|
-
expiresInMinutes: alepha1.TNumber;
|
|
2774
|
-
}>>;
|
|
2775
|
-
readonly emailVerification: NotificationDescriptor<alepha1.TObject<{
|
|
2776
|
-
email: alepha1.TString;
|
|
2777
|
-
code: alepha1.TString;
|
|
2778
|
-
expiresInMinutes: alepha1.TNumber;
|
|
2779
|
-
}>>;
|
|
2780
|
-
readonly phoneVerification: NotificationDescriptor<alepha1.TObject<{
|
|
2781
|
-
phoneNumber: alepha1.TString;
|
|
2782
|
-
code: alepha1.TString;
|
|
2783
|
-
expiresInMinutes: alepha1.TNumber;
|
|
2784
|
-
}>>;
|
|
2785
|
-
readonly passwordResetLink: NotificationDescriptor<alepha1.TObject<{
|
|
2786
|
-
email: alepha1.TString;
|
|
2787
|
-
resetUrl: alepha1.TString;
|
|
2788
|
-
expiresInMinutes: alepha1.TNumber;
|
|
2789
|
-
}>>;
|
|
2790
|
-
readonly emailVerificationLink: NotificationDescriptor<alepha1.TObject<{
|
|
2791
|
-
email: alepha1.TString;
|
|
2792
|
-
verifyUrl: alepha1.TString;
|
|
2793
|
-
expiresInMinutes: alepha1.TNumber;
|
|
2794
|
-
}>>;
|
|
2795
|
-
}
|
|
2796
|
-
//#endregion
|
|
2797
|
-
//#region src/api-users/schemas/completePasswordResetRequestSchema.d.ts
|
|
2798
|
-
/**
|
|
2799
|
-
* Request schema for completing a password reset.
|
|
2800
|
-
*
|
|
2801
|
-
* Requires the intent ID from Phase 1, the verification code,
|
|
2802
|
-
* and the new password.
|
|
2803
|
-
*/
|
|
2804
|
-
declare const completePasswordResetRequestSchema: alepha1.TObject<{
|
|
2805
|
-
intentId: alepha1.TString;
|
|
2806
|
-
code: alepha1.TString;
|
|
2807
|
-
newPassword: alepha1.TString;
|
|
2808
|
-
}>;
|
|
2809
|
-
type CompletePasswordResetRequest = Static<typeof completePasswordResetRequestSchema>;
|
|
2810
|
-
//#endregion
|
|
2811
|
-
//#region src/api-users/schemas/passwordResetIntentResponseSchema.d.ts
|
|
2812
|
-
/**
|
|
2813
|
-
* Response schema for password reset intent creation.
|
|
2814
|
-
*
|
|
2815
|
-
* Contains the intent ID needed for Phase 2 completion,
|
|
2816
|
-
* along with expiration time.
|
|
2817
|
-
*/
|
|
2818
|
-
declare const passwordResetIntentResponseSchema: alepha1.TObject<{
|
|
2819
|
-
intentId: alepha1.TString;
|
|
2820
|
-
expiresAt: alepha1.TString;
|
|
2821
|
-
}>;
|
|
2822
|
-
type PasswordResetIntentResponse = Static<typeof passwordResetIntentResponseSchema>;
|
|
2823
|
-
//#endregion
|
|
2824
|
-
//#region src/api-users/services/CredentialService.d.ts
|
|
2825
|
-
/**
|
|
2826
|
-
* Intent stored in cache during the password reset flow.
|
|
2827
|
-
*/
|
|
2828
|
-
interface PasswordResetIntent {
|
|
2829
|
-
email: string;
|
|
2830
|
-
userId: string;
|
|
2831
|
-
identityId: string;
|
|
2832
|
-
realmName?: string;
|
|
2833
|
-
expiresAt: string;
|
|
2834
|
-
}
|
|
2835
|
-
declare class CredentialService {
|
|
2836
|
-
protected readonly log: alepha_logger1.Logger;
|
|
2837
|
-
protected readonly cryptoProvider: CryptoProvider;
|
|
2838
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2839
|
-
protected readonly verificationController: HttpVirtualClient<VerificationController>;
|
|
2840
|
-
protected readonly userNotifications: UserNotifications;
|
|
2841
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
2842
|
-
protected readonly intentCache: alepha_cache0.CacheDescriptorFn<PasswordResetIntent, any[]>;
|
|
2843
|
-
users(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
2844
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
2845
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
2846
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
2847
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
2848
|
-
realm: PgAttr<alepha1.TString, typeof PG_DEFAULT>;
|
|
2849
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
2850
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
2851
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
2852
|
-
roles: PgAttr<alepha1.TArray<alepha1.TString>, typeof PG_DEFAULT>;
|
|
2853
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
2854
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
2855
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
2856
|
-
enabled: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
2857
|
-
emailVerified: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
2858
|
-
}>>;
|
|
2859
|
-
sessions(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
2860
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
2861
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
2862
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
2863
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
2864
|
-
refreshToken: alepha1.TString;
|
|
2865
|
-
userId: PgAttr<alepha1.TString, typeof PG_REF>;
|
|
2866
|
-
expiresAt: alepha1.TString;
|
|
2867
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
2868
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
2869
|
-
os: alepha1.TString;
|
|
2870
|
-
browser: alepha1.TString;
|
|
2871
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
2872
|
-
}>>;
|
|
2873
|
-
}>>;
|
|
2874
|
-
identities(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
2875
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
2876
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
2877
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
2878
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
2879
|
-
userId: PgAttr<alepha1.TString, typeof PG_REF>;
|
|
2880
|
-
password: alepha1.TOptional<alepha1.TString>;
|
|
2881
|
-
provider: alepha1.TString;
|
|
2882
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
2883
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
2884
|
-
}>>;
|
|
2885
|
-
/**
|
|
2886
|
-
* Phase 1: Create a password reset intent.
|
|
2887
|
-
*
|
|
2888
|
-
* Validates the email, checks for existing user with credentials,
|
|
2889
|
-
* sends verification code, and stores the intent in cache.
|
|
2890
|
-
*
|
|
2891
|
-
* @param email - User's email address
|
|
2892
|
-
* @param userRealmName - Optional realm name
|
|
2893
|
-
* @returns Intent response with intentId and expiration (always returns for security)
|
|
2894
|
-
*/
|
|
2895
|
-
createPasswordResetIntent(email: string, userRealmName?: string): Promise<PasswordResetIntentResponse>;
|
|
2896
|
-
/**
|
|
2897
|
-
* Phase 2: Complete password reset using an intent.
|
|
2898
|
-
*
|
|
2899
|
-
* Validates the verification code, updates the password,
|
|
2900
|
-
* and invalidates all existing sessions.
|
|
2901
|
-
*
|
|
2902
|
-
* @param body - Request body with intentId, code, and newPassword
|
|
2903
|
-
*/
|
|
2904
|
-
completePasswordReset(body: CompletePasswordResetRequest): Promise<void>;
|
|
2905
|
-
/**
|
|
2906
|
-
* @deprecated Use createPasswordResetIntent instead
|
|
2907
|
-
*/
|
|
2908
|
-
requestPasswordReset(email: string, userRealmName?: string): Promise<boolean>;
|
|
2909
|
-
/**
|
|
2910
|
-
* @deprecated Use completePasswordReset instead
|
|
2911
|
-
*/
|
|
2912
|
-
validateResetToken(email: string, token: string, _userRealmName?: string): Promise<string>;
|
|
2913
|
-
/**
|
|
2914
|
-
* @deprecated Use completePasswordReset instead
|
|
2915
|
-
*/
|
|
2916
|
-
resetPassword(email: string, token: string, newPassword: string, userRealmName?: string): Promise<void>;
|
|
2917
|
-
}
|
|
2918
|
-
//#endregion
|
|
2919
|
-
//#region src/api-users/schemas/completeRegistrationRequestSchema.d.ts
|
|
2920
|
-
declare const completeRegistrationRequestSchema: alepha1.TObject<{
|
|
2921
|
-
intentId: alepha1.TString;
|
|
2922
|
-
emailCode: alepha1.TOptional<alepha1.TString>;
|
|
2923
|
-
phoneCode: alepha1.TOptional<alepha1.TString>;
|
|
2924
|
-
captchaToken: alepha1.TOptional<alepha1.TString>;
|
|
2925
|
-
}>;
|
|
2926
|
-
type CompleteRegistrationRequest = Static<typeof completeRegistrationRequestSchema>;
|
|
2927
|
-
//#endregion
|
|
2928
|
-
//#region src/api-users/schemas/registerRequestSchema.d.ts
|
|
2929
|
-
/**
|
|
2930
|
-
* Schema for user registration request body.
|
|
2931
|
-
* Password is always required, other fields depend on realm settings.
|
|
2932
|
-
*/
|
|
2933
|
-
declare const registerRequestSchema: alepha1.TObject<{
|
|
2934
|
-
password: alepha1.TString;
|
|
2935
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
2936
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
2937
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
2938
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
2939
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
2940
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
2941
|
-
}>;
|
|
2942
|
-
type RegisterRequest = Static<typeof registerRequestSchema>;
|
|
2943
|
-
//#endregion
|
|
2944
|
-
//#region src/api-users/schemas/registrationIntentResponseSchema.d.ts
|
|
2945
|
-
declare const registrationIntentResponseSchema: alepha1.TObject<{
|
|
2946
|
-
intentId: alepha1.TString;
|
|
2947
|
-
expectCaptcha: alepha1.TBoolean;
|
|
2948
|
-
expectEmailVerification: alepha1.TBoolean;
|
|
2949
|
-
expectPhoneVerification: alepha1.TBoolean;
|
|
2950
|
-
expiresAt: alepha1.TString;
|
|
2951
|
-
}>;
|
|
2952
|
-
type RegistrationIntentResponse = Static<typeof registrationIntentResponseSchema>;
|
|
2953
|
-
//#endregion
|
|
2954
|
-
//#region src/api-users/services/RegistrationService.d.ts
|
|
2955
|
-
/**
|
|
2956
|
-
* Intent stored in cache during the registration flow.
|
|
2957
|
-
*/
|
|
2958
|
-
interface RegistrationIntent {
|
|
2959
|
-
data: {
|
|
2960
|
-
username?: string;
|
|
2961
|
-
email?: string;
|
|
2962
|
-
phoneNumber?: string;
|
|
2963
|
-
firstName?: string;
|
|
2964
|
-
lastName?: string;
|
|
2965
|
-
picture?: string;
|
|
2966
|
-
passwordHash: string;
|
|
2967
|
-
};
|
|
2968
|
-
requirements: {
|
|
2969
|
-
email: boolean;
|
|
2970
|
-
phone: boolean;
|
|
2971
|
-
captcha: boolean;
|
|
2972
|
-
};
|
|
2973
|
-
realmName?: string;
|
|
2974
|
-
expiresAt: string;
|
|
2975
|
-
}
|
|
2976
|
-
declare class RegistrationService {
|
|
2977
|
-
protected readonly log: alepha_logger1.Logger;
|
|
2978
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
2979
|
-
protected readonly cryptoProvider: CryptoProvider;
|
|
2980
|
-
protected readonly verificationController: HttpVirtualClient<VerificationController>;
|
|
2981
|
-
protected readonly userNotifications: UserNotifications;
|
|
2982
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
2983
|
-
protected readonly intentCache: alepha_cache0.CacheDescriptorFn<RegistrationIntent, any[]>;
|
|
2984
|
-
/**
|
|
2985
|
-
* Phase 1: Create a registration intent.
|
|
2986
|
-
*
|
|
2987
|
-
* Validates the registration data, checks for existing users,
|
|
2988
|
-
* creates verification sessions, and stores the intent in cache.
|
|
2989
|
-
*/
|
|
2990
|
-
createRegistrationIntent(body: RegisterRequest, userRealmName?: string): Promise<RegistrationIntentResponse>;
|
|
2991
|
-
/**
|
|
2992
|
-
* Phase 2: Complete registration using an intent.
|
|
2993
|
-
*
|
|
2994
|
-
* Validates all requirements (verification codes, captcha),
|
|
2995
|
-
* creates the user and credentials, and returns the user.
|
|
2996
|
-
*/
|
|
2997
|
-
completeRegistration(body: CompleteRegistrationRequest): Promise<UserEntity>;
|
|
2998
|
-
/**
|
|
2999
|
-
* Check if username, email, and phone are available.
|
|
3000
|
-
*/
|
|
3001
|
-
protected checkUserAvailability(body: Pick<RegisterRequest, "username" | "email" | "phoneNumber">, userRealmName?: string): Promise<void>;
|
|
3002
|
-
/**
|
|
3003
|
-
* Send email verification code.
|
|
3004
|
-
*/
|
|
3005
|
-
protected sendEmailVerification(email: string): Promise<void>;
|
|
3006
|
-
/**
|
|
3007
|
-
* Send phone verification code.
|
|
3008
|
-
*/
|
|
3009
|
-
protected sendPhoneVerification(phoneNumber: string): Promise<void>;
|
|
3010
|
-
/**
|
|
3011
|
-
* Verify email code using verification service.
|
|
3012
|
-
*/
|
|
3013
|
-
protected verifyEmailCode(email: string, code: string): Promise<void>;
|
|
3014
|
-
/**
|
|
3015
|
-
* Verify phone code using verification service.
|
|
3016
|
-
*/
|
|
3017
|
-
protected verifyPhoneCode(phoneNumber: string, code: string): Promise<void>;
|
|
3018
|
-
}
|
|
3019
|
-
//#endregion
|
|
3020
|
-
//#region src/api-users/schemas/createUserSchema.d.ts
|
|
3021
|
-
declare const createUserSchema: alepha1.TObject<{
|
|
3022
|
-
id: alepha1.TOptional<PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>>;
|
|
3023
|
-
version: alepha1.TOptional<PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>>;
|
|
3024
|
-
email: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3025
|
-
createdAt: alepha1.TOptional<PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>>;
|
|
3026
|
-
updatedAt: alepha1.TOptional<PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>>;
|
|
3027
|
-
username: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3028
|
-
phoneNumber: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3029
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3030
|
-
firstName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3031
|
-
lastName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3032
|
-
picture: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3033
|
-
enabled: alepha1.TOptional<PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>>;
|
|
3034
|
-
emailVerified: alepha1.TOptional<PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>>;
|
|
3035
|
-
}>;
|
|
3036
|
-
type CreateUser = Static<typeof createUserSchema>;
|
|
3037
|
-
//#endregion
|
|
3038
|
-
//#region src/api-users/schemas/updateUserSchema.d.ts
|
|
3039
|
-
declare const updateUserSchema: alepha1.TObject<{
|
|
3040
|
-
email: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3041
|
-
realm: alepha1.TOptional<PgAttr<alepha1.TString, typeof PG_DEFAULT>>;
|
|
3042
|
-
phoneNumber: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3043
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3044
|
-
firstName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3045
|
-
lastName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3046
|
-
picture: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3047
|
-
enabled: alepha1.TOptional<PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>>;
|
|
3048
|
-
}>;
|
|
3049
|
-
type UpdateUser = Static<typeof updateUserSchema>;
|
|
3050
|
-
//#endregion
|
|
3051
|
-
//#region src/api-users/schemas/userQuerySchema.d.ts
|
|
3052
|
-
declare const userQuerySchema: alepha1.TObject<{
|
|
3053
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
3054
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
3055
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
3056
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3057
|
-
enabled: alepha1.TOptional<alepha1.TBoolean>;
|
|
3058
|
-
emailVerified: alepha1.TOptional<alepha1.TBoolean>;
|
|
3059
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3060
|
-
query: alepha1.TOptional<alepha1.TString>;
|
|
3061
|
-
}>;
|
|
3062
|
-
type UserQuery = Static<typeof userQuerySchema>;
|
|
3063
|
-
//#endregion
|
|
3064
|
-
//#region src/api-users/services/UserService.d.ts
|
|
3065
|
-
declare class UserService {
|
|
3066
|
-
protected readonly log: alepha_logger1.Logger;
|
|
3067
|
-
protected readonly verificationController: HttpVirtualClient<VerificationController>;
|
|
3068
|
-
protected readonly userNotifications: UserNotifications;
|
|
3069
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
3070
|
-
users(userRealmName?: string): alepha_orm198.Repository<alepha1.TObject<{
|
|
3071
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3072
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3073
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3074
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3075
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3076
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3077
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3078
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3079
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3080
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3081
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3082
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3083
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3084
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3085
|
-
}>>;
|
|
3086
|
-
/**
|
|
3087
|
-
* Request email verification for a user.
|
|
3088
|
-
*/
|
|
3089
|
-
requestEmailVerification(email: string, userRealmName?: string): Promise<boolean>;
|
|
3090
|
-
/**
|
|
3091
|
-
* Verify a user's email using a valid verification token.
|
|
3092
|
-
*/
|
|
3093
|
-
verifyEmail(email: string, token: string, userRealmName?: string): Promise<void>;
|
|
3094
|
-
/**
|
|
3095
|
-
* Check if an email is verified.
|
|
3096
|
-
*/
|
|
3097
|
-
isEmailVerified(email: string, userRealmName?: string): Promise<boolean>;
|
|
3098
|
-
/**
|
|
3099
|
-
* Find users with pagination and filtering.
|
|
3100
|
-
*/
|
|
3101
|
-
findUsers(q?: UserQuery, userRealmName?: string): Promise<Page$1<UserEntity>>;
|
|
3102
|
-
/**
|
|
3103
|
-
* Get a user by ID.
|
|
3104
|
-
*/
|
|
3105
|
-
getUserById(id: string, userRealmName?: string): Promise<UserEntity>;
|
|
3106
|
-
/**
|
|
3107
|
-
* Create a new user.
|
|
3108
|
-
*/
|
|
3109
|
-
createUser(data: CreateUser, userRealmName?: string): Promise<UserEntity>;
|
|
3110
|
-
/**
|
|
3111
|
-
* Update an existing user.
|
|
3112
|
-
*/
|
|
3113
|
-
updateUser(id: string, data: UpdateUser, userRealmName?: string): Promise<UserEntity>;
|
|
3114
|
-
/**
|
|
3115
|
-
* Delete a user by ID.
|
|
3116
|
-
*/
|
|
3117
|
-
deleteUser(id: string, userRealmName?: string): Promise<void>;
|
|
3118
|
-
}
|
|
3119
|
-
//#endregion
|
|
3120
|
-
//#region src/api-users/controllers/UserController.d.ts
|
|
3121
|
-
declare class UserController {
|
|
3122
|
-
protected readonly url = "/users";
|
|
3123
|
-
protected readonly group = "users";
|
|
3124
|
-
protected readonly credentialService: CredentialService;
|
|
3125
|
-
protected readonly userService: UserService;
|
|
3126
|
-
protected readonly registrationService: RegistrationService;
|
|
3127
|
-
/**
|
|
3128
|
-
* Phase 1: Create a registration intent.
|
|
3129
|
-
* Validates data, creates verification sessions, and stores intent in cache.
|
|
3130
|
-
*/
|
|
3131
|
-
readonly createRegistrationIntent: alepha_server0.ActionDescriptorFn<{
|
|
3132
|
-
body: alepha1.TObject<{
|
|
3133
|
-
password: alepha1.TString;
|
|
3134
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3135
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3136
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3137
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3138
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3139
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3140
|
-
}>;
|
|
3141
|
-
query: alepha1.TObject<{
|
|
3142
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3143
|
-
}>;
|
|
3144
|
-
response: alepha1.TObject<{
|
|
3145
|
-
intentId: alepha1.TString;
|
|
3146
|
-
expectCaptcha: alepha1.TBoolean;
|
|
3147
|
-
expectEmailVerification: alepha1.TBoolean;
|
|
3148
|
-
expectPhoneVerification: alepha1.TBoolean;
|
|
3149
|
-
expiresAt: alepha1.TString;
|
|
3150
|
-
}>;
|
|
3151
|
-
}>;
|
|
3152
|
-
/**
|
|
3153
|
-
* Find users with pagination and filtering.
|
|
3154
|
-
*/
|
|
3155
|
-
readonly findUsers: alepha_server0.ActionDescriptorFn<{
|
|
3156
|
-
query: alepha1.TObject<{
|
|
3157
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
3158
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
3159
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
3160
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3161
|
-
enabled: alepha1.TOptional<alepha1.TBoolean>;
|
|
3162
|
-
emailVerified: alepha1.TOptional<alepha1.TBoolean>;
|
|
3163
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3164
|
-
query: alepha1.TOptional<alepha1.TString>;
|
|
3165
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3166
|
-
}>;
|
|
3167
|
-
response: alepha1.TPage<alepha1.TObject<{
|
|
3168
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3169
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3170
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3171
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3172
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3173
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3174
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3175
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3176
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3177
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3178
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3179
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3180
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3181
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3182
|
-
}>>;
|
|
3183
|
-
}>;
|
|
3184
|
-
/**
|
|
3185
|
-
* Get a user by ID.
|
|
3186
|
-
*/
|
|
3187
|
-
readonly getUser: alepha_server0.ActionDescriptorFn<{
|
|
3188
|
-
params: alepha1.TObject<{
|
|
3189
|
-
id: alepha1.TString;
|
|
3190
|
-
}>;
|
|
3191
|
-
query: alepha1.TObject<{
|
|
3192
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3193
|
-
}>;
|
|
3194
|
-
response: alepha1.TObject<{
|
|
3195
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3196
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3197
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3198
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3199
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3200
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3201
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3202
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3203
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3204
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3205
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3206
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3207
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3208
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3209
|
-
}>;
|
|
3210
|
-
}>;
|
|
3211
|
-
/**
|
|
3212
|
-
* Create a new user.
|
|
3213
|
-
*/
|
|
3214
|
-
readonly createUser: alepha_server0.ActionDescriptorFn<{
|
|
3215
|
-
query: alepha1.TObject<{
|
|
3216
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3217
|
-
}>;
|
|
3218
|
-
body: alepha1.TObject<{
|
|
3219
|
-
id: alepha1.TOptional<alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3220
|
-
version: alepha1.TOptional<alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3221
|
-
email: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3222
|
-
createdAt: alepha1.TOptional<alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3223
|
-
updatedAt: alepha1.TOptional<alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3224
|
-
username: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3225
|
-
phoneNumber: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3226
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3227
|
-
firstName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3228
|
-
lastName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3229
|
-
picture: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3230
|
-
enabled: alepha1.TOptional<alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3231
|
-
emailVerified: alepha1.TOptional<alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3232
|
-
}>;
|
|
3233
|
-
response: alepha1.TObject<{
|
|
3234
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3235
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3236
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3237
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3238
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3239
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3240
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3241
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3242
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3243
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3244
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3245
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3246
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3247
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3248
|
-
}>;
|
|
3249
|
-
}>;
|
|
3250
|
-
/**
|
|
3251
|
-
* Phase 2: Complete registration using an intent.
|
|
3252
|
-
* Validates verification codes and creates the user.
|
|
3253
|
-
*/
|
|
3254
|
-
readonly createUserFromIntent: alepha_server0.ActionDescriptorFn<{
|
|
3255
|
-
body: alepha1.TObject<{
|
|
3256
|
-
intentId: alepha1.TString;
|
|
3257
|
-
emailCode: alepha1.TOptional<alepha1.TString>;
|
|
3258
|
-
phoneCode: alepha1.TOptional<alepha1.TString>;
|
|
3259
|
-
captchaToken: alepha1.TOptional<alepha1.TString>;
|
|
3260
|
-
}>;
|
|
3261
|
-
response: alepha1.TObject<{
|
|
3262
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3263
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3264
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3265
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3266
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3267
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3268
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3269
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3270
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3271
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3272
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3273
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3274
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3275
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3276
|
-
}>;
|
|
3277
|
-
}>;
|
|
3278
|
-
/**
|
|
3279
|
-
* Update a user.
|
|
3280
|
-
*/
|
|
3281
|
-
readonly updateUser: alepha_server0.ActionDescriptorFn<{
|
|
3282
|
-
params: alepha1.TObject<{
|
|
3283
|
-
id: alepha1.TString;
|
|
3284
|
-
}>;
|
|
3285
|
-
query: alepha1.TObject<{
|
|
3286
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3287
|
-
}>;
|
|
3288
|
-
body: alepha1.TObject<{
|
|
3289
|
-
email: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3290
|
-
realm: alepha1.TOptional<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3291
|
-
phoneNumber: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3292
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3293
|
-
firstName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3294
|
-
lastName: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3295
|
-
picture: alepha1.TOptional<alepha1.TOptional<alepha1.TString>>;
|
|
3296
|
-
enabled: alepha1.TOptional<alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>>;
|
|
3297
|
-
}>;
|
|
3298
|
-
response: alepha1.TObject<{
|
|
3299
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3300
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3301
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3302
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3303
|
-
realm: alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_DEFAULT>;
|
|
3304
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3305
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3306
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
3307
|
-
roles: alepha_orm198.PgAttr<alepha1.TArray<alepha1.TString>, typeof alepha_orm198.PG_DEFAULT>;
|
|
3308
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
3309
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
3310
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3311
|
-
enabled: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3312
|
-
emailVerified: alepha_orm198.PgAttr<alepha1.TBoolean, typeof alepha_orm198.PG_DEFAULT>;
|
|
3313
|
-
}>;
|
|
3314
|
-
}>;
|
|
3315
|
-
/**
|
|
3316
|
-
* Delete a user.
|
|
3317
|
-
*/
|
|
3318
|
-
readonly deleteUser: alepha_server0.ActionDescriptorFn<{
|
|
3319
|
-
params: alepha1.TObject<{
|
|
3320
|
-
id: alepha1.TString;
|
|
3321
|
-
}>;
|
|
3322
|
-
query: alepha1.TObject<{
|
|
3323
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3324
|
-
}>;
|
|
3325
|
-
response: alepha1.TObject<{
|
|
3326
|
-
ok: alepha1.TBoolean;
|
|
3327
|
-
id: alepha1.TOptional<alepha1.TUnion<[alepha1.TString, alepha1.TInteger]>>;
|
|
3328
|
-
count: alepha1.TOptional<alepha1.TNumber>;
|
|
3329
|
-
}>;
|
|
3330
|
-
}>;
|
|
3331
|
-
/**
|
|
3332
|
-
* Phase 1: Create a password reset intent.
|
|
3333
|
-
* Validates email, sends verification code, and stores intent in cache.
|
|
3334
|
-
*/
|
|
3335
|
-
readonly createPasswordResetIntent: alepha_server0.ActionDescriptorFn<{
|
|
3336
|
-
query: alepha1.TObject<{
|
|
3337
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3338
|
-
}>;
|
|
3339
|
-
body: alepha1.TObject<{
|
|
3340
|
-
email: alepha1.TString;
|
|
3341
|
-
}>;
|
|
3342
|
-
response: alepha1.TObject<{
|
|
3343
|
-
intentId: alepha1.TString;
|
|
3344
|
-
expiresAt: alepha1.TString;
|
|
3345
|
-
}>;
|
|
3346
|
-
}>;
|
|
3347
|
-
/**
|
|
3348
|
-
* Phase 2: Complete password reset using an intent.
|
|
3349
|
-
* Validates verification code, updates password, and invalidates sessions.
|
|
3350
|
-
*/
|
|
3351
|
-
readonly completePasswordReset: alepha_server0.ActionDescriptorFn<{
|
|
3352
|
-
body: alepha1.TObject<{
|
|
3353
|
-
intentId: alepha1.TString;
|
|
3354
|
-
code: alepha1.TString;
|
|
3355
|
-
newPassword: alepha1.TString;
|
|
3356
|
-
}>;
|
|
3357
|
-
response: alepha1.TObject<{
|
|
3358
|
-
ok: alepha1.TBoolean;
|
|
3359
|
-
id: alepha1.TOptional<alepha1.TUnion<[alepha1.TString, alepha1.TInteger]>>;
|
|
3360
|
-
count: alepha1.TOptional<alepha1.TNumber>;
|
|
3361
|
-
}>;
|
|
3362
|
-
}>;
|
|
3363
|
-
/**
|
|
3364
|
-
* @deprecated Use createPasswordResetIntent instead
|
|
3365
|
-
*/
|
|
3366
|
-
requestPasswordReset: alepha_server0.ActionDescriptorFn<{
|
|
3367
|
-
query: alepha1.TObject<{
|
|
3368
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3369
|
-
}>;
|
|
3370
|
-
body: alepha1.TObject<{
|
|
3371
|
-
email: alepha1.TString;
|
|
3372
|
-
}>;
|
|
3373
|
-
response: alepha1.TObject<{
|
|
3374
|
-
success: alepha1.TBoolean;
|
|
3375
|
-
message: alepha1.TString;
|
|
3376
|
-
}>;
|
|
3377
|
-
}>;
|
|
3378
|
-
/**
|
|
3379
|
-
* @deprecated Use completePasswordReset instead
|
|
3380
|
-
*/
|
|
3381
|
-
validateResetToken: alepha_server0.ActionDescriptorFn<{
|
|
3382
|
-
query: alepha1.TObject<{
|
|
3383
|
-
email: alepha1.TString;
|
|
3384
|
-
token: alepha1.TString;
|
|
3385
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3386
|
-
}>;
|
|
3387
|
-
response: alepha1.TObject<{
|
|
3388
|
-
valid: alepha1.TBoolean;
|
|
3389
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3390
|
-
}>;
|
|
3391
|
-
}>;
|
|
3392
|
-
/**
|
|
3393
|
-
* @deprecated Use completePasswordReset instead
|
|
3394
|
-
*/
|
|
3395
|
-
resetPassword: alepha_server0.ActionDescriptorFn<{
|
|
3396
|
-
query: alepha1.TObject<{
|
|
3397
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3398
|
-
}>;
|
|
3399
|
-
body: alepha1.TObject<{
|
|
3400
|
-
email: alepha1.TString;
|
|
3401
|
-
token: alepha1.TString;
|
|
3402
|
-
newPassword: alepha1.TString;
|
|
3403
|
-
}>;
|
|
3404
|
-
response: alepha1.TObject<{
|
|
3405
|
-
success: alepha1.TBoolean;
|
|
3406
|
-
message: alepha1.TString;
|
|
3407
|
-
}>;
|
|
3408
|
-
}>;
|
|
3409
|
-
/**
|
|
3410
|
-
* Request email verification.
|
|
3411
|
-
* Generates a verification token using verification service and sends an email to the user.
|
|
3412
|
-
*/
|
|
3413
|
-
requestEmailVerification: alepha_server0.ActionDescriptorFn<{
|
|
3414
|
-
query: alepha1.TObject<{
|
|
3415
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3416
|
-
}>;
|
|
3417
|
-
body: alepha1.TObject<{
|
|
3418
|
-
email: alepha1.TString;
|
|
3419
|
-
}>;
|
|
3420
|
-
response: alepha1.TObject<{
|
|
3421
|
-
success: alepha1.TBoolean;
|
|
3422
|
-
message: alepha1.TString;
|
|
3423
|
-
}>;
|
|
3424
|
-
}>;
|
|
3425
|
-
/**
|
|
3426
|
-
* Verify email with a valid token.
|
|
3427
|
-
* Updates the user's emailVerified status.
|
|
3428
|
-
*/
|
|
3429
|
-
verifyEmail: alepha_server0.ActionDescriptorFn<{
|
|
3430
|
-
query: alepha1.TObject<{
|
|
3431
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3432
|
-
}>;
|
|
3433
|
-
body: alepha1.TObject<{
|
|
3434
|
-
email: alepha1.TString;
|
|
3435
|
-
token: alepha1.TString;
|
|
3436
|
-
}>;
|
|
3437
|
-
response: alepha1.TObject<{
|
|
3438
|
-
success: alepha1.TBoolean;
|
|
3439
|
-
message: alepha1.TString;
|
|
3440
|
-
}>;
|
|
3441
|
-
}>;
|
|
3442
|
-
/**
|
|
3443
|
-
* Check if an email is verified.
|
|
3444
|
-
*/
|
|
3445
|
-
checkEmailVerification: alepha_server0.ActionDescriptorFn<{
|
|
3446
|
-
query: alepha1.TObject<{
|
|
3447
|
-
email: alepha1.TString;
|
|
3448
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
3449
|
-
}>;
|
|
3450
|
-
response: alepha1.TObject<{
|
|
3451
|
-
verified: alepha1.TBoolean;
|
|
3452
|
-
}>;
|
|
3453
|
-
}>;
|
|
3454
|
-
}
|
|
3455
|
-
//#endregion
|
|
3456
|
-
//#region src/server-cookies/services/CookieParser.d.ts
|
|
3457
|
-
declare class CookieParser {
|
|
3458
|
-
parseRequestCookies(header: string): Record<string, string>;
|
|
3459
|
-
serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
3460
|
-
cookieToString(name: string, cookie: Cookie, isHttps?: boolean): string;
|
|
3461
|
-
}
|
|
3462
|
-
//#endregion
|
|
3463
|
-
//#region src/server-cookies/providers/ServerCookiesProvider.d.ts
|
|
3464
|
-
declare class ServerCookiesProvider {
|
|
3465
|
-
protected readonly alepha: Alepha;
|
|
3466
|
-
protected readonly log: alepha_logger1.Logger;
|
|
3467
|
-
protected readonly cookieParser: CookieParser;
|
|
3468
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
3469
|
-
protected readonly env: {
|
|
3470
|
-
APP_SECRET: string;
|
|
3471
|
-
};
|
|
3472
|
-
protected readonly ALGORITHM = "aes-256-gcm";
|
|
3473
|
-
protected readonly IV_LENGTH = 16;
|
|
3474
|
-
protected readonly AUTH_TAG_LENGTH = 16;
|
|
3475
|
-
protected readonly SIGNATURE_LENGTH = 32;
|
|
3476
|
-
readonly onRequest: alepha1.HookDescriptor<"server:onRequest">;
|
|
3477
|
-
readonly onAction: alepha1.HookDescriptor<"action:onRequest">;
|
|
3478
|
-
readonly onSend: alepha1.HookDescriptor<"server:onSend">;
|
|
3479
|
-
protected getCookiesFromContext(cookies?: Cookies): Cookies;
|
|
3480
|
-
getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
|
|
3481
|
-
setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
|
|
3482
|
-
deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
|
|
3483
|
-
protected encrypt(text: string): string;
|
|
3484
|
-
protected decrypt(encryptedText: string): string;
|
|
3485
|
-
secretKey(): string;
|
|
3486
|
-
protected sign(data: string): string;
|
|
3487
|
-
}
|
|
3488
|
-
//#endregion
|
|
3489
|
-
//#region src/server-cookies/descriptors/$cookie.d.ts
|
|
3490
|
-
interface CookieDescriptorOptions<T extends TSchema> {
|
|
3491
|
-
/** The schema for the cookie's value, used for validation and type safety. */
|
|
3492
|
-
schema: T;
|
|
3493
|
-
/** The name of the cookie. */
|
|
3494
|
-
name?: string;
|
|
3495
|
-
/** The cookie's path. Defaults to "/". */
|
|
3496
|
-
path?: string;
|
|
3497
|
-
/** Time-to-live for the cookie. Maps to `Max-Age`. */
|
|
3498
|
-
ttl?: DurationLike;
|
|
3499
|
-
/** If true, the cookie is only sent over HTTPS. Defaults to true in production. */
|
|
3500
|
-
secure?: boolean;
|
|
3501
|
-
/** If true, the cookie cannot be accessed by client-side scripts. */
|
|
3502
|
-
httpOnly?: boolean;
|
|
3503
|
-
/** SameSite policy for the cookie. Defaults to "lax". */
|
|
3504
|
-
sameSite?: "strict" | "lax" | "none";
|
|
3505
|
-
/** The domain for the cookie. */
|
|
3506
|
-
domain?: string;
|
|
3507
|
-
/** If true, the cookie value will be compressed using zlib. */
|
|
3508
|
-
compress?: boolean;
|
|
3509
|
-
/** If true, the cookie value will be encrypted. Requires `COOKIE_SECRET` env var. */
|
|
3510
|
-
encrypt?: boolean;
|
|
3511
|
-
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
3512
|
-
sign?: boolean;
|
|
3513
|
-
}
|
|
3514
|
-
interface AbstractCookieDescriptor<T extends TSchema> {
|
|
3515
|
-
readonly name: string;
|
|
3516
|
-
readonly options: CookieDescriptorOptions<T>;
|
|
3517
|
-
set(value: Static<T>, options?: {
|
|
3518
|
-
cookies?: Cookies;
|
|
3519
|
-
ttl?: DurationLike;
|
|
3520
|
-
}): void;
|
|
3521
|
-
get(options?: {
|
|
3522
|
-
cookies?: Cookies;
|
|
3523
|
-
}): Static<T> | undefined;
|
|
3524
|
-
del(options?: {
|
|
3525
|
-
cookies?: Cookies;
|
|
3526
|
-
}): void;
|
|
3527
|
-
}
|
|
3528
|
-
interface Cookies {
|
|
3529
|
-
req: Record<string, string>;
|
|
3530
|
-
res: Record<string, Cookie | null>;
|
|
3531
|
-
}
|
|
3532
|
-
interface Cookie {
|
|
3533
|
-
value: string;
|
|
3534
|
-
path?: string;
|
|
3535
|
-
maxAge?: number;
|
|
3536
|
-
secure?: boolean;
|
|
3537
|
-
httpOnly?: boolean;
|
|
3538
|
-
sameSite?: "strict" | "lax" | "none";
|
|
3539
|
-
domain?: string;
|
|
3540
|
-
}
|
|
3541
|
-
//#endregion
|
|
3542
|
-
//#region src/server-cookies/index.d.ts
|
|
3543
|
-
declare module "alepha/server" {
|
|
3544
|
-
interface ServerRequest {
|
|
3545
|
-
cookies: Cookies;
|
|
3546
|
-
}
|
|
3547
|
-
}
|
|
3548
|
-
/**
|
|
3549
|
-
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
|
|
3550
|
-
*
|
|
3551
|
-
* The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
|
|
3552
|
-
* It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
|
|
3553
|
-
* for managing user sessions, preferences, and authentication tokens.
|
|
3554
|
-
*
|
|
3555
|
-
* @see {@link $cookie}
|
|
3556
|
-
* @module alepha.server.cookies
|
|
3557
|
-
*/
|
|
3558
|
-
//#endregion
|
|
3559
|
-
//#region src/server-auth/schemas/authenticationProviderSchema.d.ts
|
|
3560
|
-
declare const authenticationProviderSchema: alepha1.TObject<{
|
|
3561
|
-
name: alepha1.TString;
|
|
3562
|
-
type: alepha1.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
3563
|
-
}>;
|
|
3564
|
-
type AuthenticationProvider = Static<typeof authenticationProviderSchema>;
|
|
3565
|
-
//#endregion
|
|
3566
|
-
//#region src/server-auth/schemas/tokensSchema.d.ts
|
|
3567
|
-
declare const tokensSchema: alepha1.TObject<{
|
|
3568
|
-
provider: alepha1.TString;
|
|
3569
|
-
access_token: alepha1.TString;
|
|
3570
|
-
issued_at: alepha1.TNumber;
|
|
3571
|
-
expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3572
|
-
refresh_token: alepha1.TOptional<alepha1.TString>;
|
|
3573
|
-
refresh_token_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3574
|
-
refresh_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3575
|
-
id_token: alepha1.TOptional<alepha1.TString>;
|
|
3576
|
-
scope: alepha1.TOptional<alepha1.TString>;
|
|
3577
|
-
}>;
|
|
3578
|
-
type Tokens = Static<typeof tokensSchema>;
|
|
3579
|
-
//#endregion
|
|
3580
|
-
//#region src/server-auth/providers/ServerAuthProvider.d.ts
|
|
3581
|
-
declare class ServerAuthProvider {
|
|
3582
|
-
protected readonly log: alepha_logger1.Logger;
|
|
3583
|
-
protected readonly alepha: Alepha;
|
|
3584
|
-
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
3585
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
3586
|
-
protected readonly serverLinksProvider: ServerLinksProvider;
|
|
3587
|
-
protected readonly authorizationCode: AbstractCookieDescriptor<alepha1.TObject<{
|
|
3588
|
-
provider: alepha1.TString;
|
|
3589
|
-
codeVerifier: alepha1.TOptional<alepha1.TString>;
|
|
3590
|
-
redirectUri: alepha1.TOptional<alepha1.TString>;
|
|
3591
|
-
state: alepha1.TOptional<alepha1.TString>;
|
|
3592
|
-
nonce: alepha1.TOptional<alepha1.TString>;
|
|
3593
|
-
}>>;
|
|
3594
|
-
readonly tokens: AbstractCookieDescriptor<alepha1.TObject<{
|
|
3595
|
-
provider: alepha1.TString;
|
|
3596
|
-
access_token: alepha1.TString;
|
|
3597
|
-
issued_at: alepha1.TNumber;
|
|
3598
|
-
expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3599
|
-
refresh_token: alepha1.TOptional<alepha1.TString>;
|
|
3600
|
-
refresh_token_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3601
|
-
refresh_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3602
|
-
id_token: alepha1.TOptional<alepha1.TString>;
|
|
3603
|
-
scope: alepha1.TOptional<alepha1.TString>;
|
|
3604
|
-
}>>;
|
|
3605
|
-
get identities(): Array<AuthDescriptor>;
|
|
3606
|
-
getAuthenticationProviders(filters?: {
|
|
3607
|
-
realmName?: string;
|
|
3608
|
-
}): AuthenticationProvider[];
|
|
3609
|
-
protected readonly configure: alepha1.HookDescriptor<"configure">;
|
|
3610
|
-
protected getAccessTokens(tokens: Tokens): string | undefined;
|
|
3611
|
-
/**
|
|
3612
|
-
* Fill request headers with access token from cookies or fallback to provider's fallback function.
|
|
3613
|
-
*/
|
|
3614
|
-
protected readonly onRequest: alepha1.HookDescriptor<"server:onRequest">;
|
|
3615
|
-
/**
|
|
3616
|
-
* Convert cookies to tokens.
|
|
3617
|
-
* If the tokens are expired, try to refresh them using the refresh token.
|
|
3618
|
-
*/
|
|
3619
|
-
protected cookiesToTokens(cookies: Cookies): Promise<Tokens | undefined>;
|
|
3620
|
-
protected refreshTokens(tokens: Tokens): Promise<Tokens | undefined>;
|
|
3621
|
-
/**
|
|
3622
|
-
* Get user information.
|
|
3623
|
-
*/
|
|
3624
|
-
readonly userinfo: alepha_server0.RouteDescriptor<{
|
|
3625
|
-
response: alepha1.TObject<{
|
|
3626
|
-
user: alepha1.TOptional<alepha1.TObject<{
|
|
3627
|
-
id: alepha1.TString;
|
|
3628
|
-
name: alepha1.TOptional<alepha1.TString>;
|
|
3629
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3630
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3631
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3632
|
-
sessionId: alepha1.TOptional<alepha1.TString>;
|
|
3633
|
-
organizations: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3634
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3635
|
-
}>>;
|
|
3636
|
-
api: alepha1.TObject<{
|
|
3637
|
-
prefix: alepha1.TOptional<alepha1.TString>;
|
|
3638
|
-
links: alepha1.TArray<alepha1.TObject<{
|
|
3639
|
-
name: alepha1.TString;
|
|
3640
|
-
group: alepha1.TOptional<alepha1.TString>;
|
|
3641
|
-
path: alepha1.TString;
|
|
3642
|
-
method: alepha1.TOptional<alepha1.TString>;
|
|
3643
|
-
requestBodyType: alepha1.TOptional<alepha1.TString>;
|
|
3644
|
-
service: alepha1.TOptional<alepha1.TString>;
|
|
3645
|
-
}>>;
|
|
3646
|
-
}>;
|
|
3647
|
-
}>;
|
|
3648
|
-
}>;
|
|
3649
|
-
/**
|
|
3650
|
-
* Refresh a token for internal providers.
|
|
3651
|
-
*/
|
|
3652
|
-
readonly refresh: alepha_server0.RouteDescriptor<{
|
|
3653
|
-
query: alepha1.TObject<{
|
|
3654
|
-
provider: alepha1.TString;
|
|
3655
|
-
}>;
|
|
3656
|
-
body: alepha1.TObject<{
|
|
3657
|
-
refresh_token: alepha1.TString;
|
|
3658
|
-
access_token: alepha1.TOptional<alepha1.TString>;
|
|
3659
|
-
}>;
|
|
3660
|
-
response: alepha1.TObject<{
|
|
3661
|
-
provider: alepha1.TString;
|
|
3662
|
-
access_token: alepha1.TString;
|
|
3663
|
-
issued_at: alepha1.TNumber;
|
|
3664
|
-
expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3665
|
-
refresh_token: alepha1.TOptional<alepha1.TString>;
|
|
3666
|
-
refresh_token_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3667
|
-
refresh_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3668
|
-
id_token: alepha1.TOptional<alepha1.TString>;
|
|
3669
|
-
scope: alepha1.TOptional<alepha1.TString>;
|
|
3670
|
-
}>;
|
|
3671
|
-
}>;
|
|
3672
|
-
/**
|
|
3673
|
-
* Login for local password-based authentication.
|
|
3674
|
-
*/
|
|
3675
|
-
readonly token: alepha_server0.RouteDescriptor<{
|
|
3676
|
-
query: alepha1.TObject<{
|
|
3677
|
-
provider: alepha1.TString;
|
|
3678
|
-
}>;
|
|
3679
|
-
body: alepha1.TObject<{
|
|
3680
|
-
username: alepha1.TString;
|
|
3681
|
-
password: alepha1.TString;
|
|
3682
|
-
}>;
|
|
3683
|
-
response: alepha1.TObject<{
|
|
3684
|
-
provider: alepha1.TString;
|
|
3685
|
-
access_token: alepha1.TString;
|
|
3686
|
-
issued_at: alepha1.TNumber;
|
|
3687
|
-
expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3688
|
-
refresh_token: alepha1.TOptional<alepha1.TString>;
|
|
3689
|
-
refresh_token_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3690
|
-
refresh_expires_in: alepha1.TOptional<alepha1.TNumber>;
|
|
3691
|
-
id_token: alepha1.TOptional<alepha1.TString>;
|
|
3692
|
-
scope: alepha1.TOptional<alepha1.TString>;
|
|
3693
|
-
user: alepha1.TObject<{
|
|
3694
|
-
id: alepha1.TString;
|
|
3695
|
-
name: alepha1.TOptional<alepha1.TString>;
|
|
3696
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
3697
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
3698
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
3699
|
-
sessionId: alepha1.TOptional<alepha1.TString>;
|
|
3700
|
-
organizations: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3701
|
-
roles: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
3702
|
-
}>;
|
|
3703
|
-
api: alepha1.TObject<{
|
|
3704
|
-
prefix: alepha1.TOptional<alepha1.TString>;
|
|
3705
|
-
links: alepha1.TArray<alepha1.TObject<{
|
|
3706
|
-
name: alepha1.TString;
|
|
3707
|
-
group: alepha1.TOptional<alepha1.TString>;
|
|
3708
|
-
path: alepha1.TString;
|
|
3709
|
-
method: alepha1.TOptional<alepha1.TString>;
|
|
3710
|
-
requestBodyType: alepha1.TOptional<alepha1.TString>;
|
|
3711
|
-
service: alepha1.TOptional<alepha1.TString>;
|
|
3712
|
-
}>>;
|
|
3713
|
-
}>;
|
|
3714
|
-
}>;
|
|
3715
|
-
}>;
|
|
3716
|
-
/**
|
|
3717
|
-
* Oauth2/OIDC login route.
|
|
3718
|
-
*/
|
|
3719
|
-
readonly login: alepha_server0.RouteDescriptor<{
|
|
3720
|
-
query: alepha1.TObject<{
|
|
3721
|
-
provider: alepha1.TString;
|
|
3722
|
-
redirect_uri: alepha1.TOptional<alepha1.TString>;
|
|
3723
|
-
}>;
|
|
3724
|
-
}>;
|
|
3725
|
-
/**
|
|
3726
|
-
* Callback for OAuth2/OIDC providers.
|
|
3727
|
-
* It handles the authorization code flow and retrieves the access token.
|
|
3728
|
-
*/
|
|
3729
|
-
readonly callback: alepha_server0.RouteDescriptor<alepha_server0.RequestConfigSchema>;
|
|
3730
|
-
/**
|
|
3731
|
-
* Logout route for OAuth2/OIDC providers.
|
|
3732
|
-
*/
|
|
3733
|
-
readonly logout: alepha_server0.RouteDescriptor<{
|
|
3734
|
-
query: alepha1.TObject<{
|
|
3735
|
-
post_logout_redirect_uri: alepha1.TOptional<alepha1.TString>;
|
|
3736
|
-
}>;
|
|
3737
|
-
}>;
|
|
3738
|
-
protected provider(opts: string | {
|
|
3739
|
-
provider: string;
|
|
3740
|
-
}): AuthDescriptor;
|
|
3741
|
-
protected setTokens(tokens: Tokens, cookies?: Cookies): void;
|
|
3742
|
-
}
|
|
3743
|
-
interface OAuth2Profile {
|
|
3744
|
-
sub: string;
|
|
3745
|
-
email?: string;
|
|
3746
|
-
name?: string;
|
|
3747
|
-
given_name?: string;
|
|
3748
|
-
family_name?: string;
|
|
3749
|
-
middle_name?: string;
|
|
3750
|
-
nickname?: string;
|
|
3751
|
-
preferred_username?: string;
|
|
3752
|
-
profile?: string;
|
|
3753
|
-
picture?: string;
|
|
3754
|
-
website?: string;
|
|
3755
|
-
email_verified?: boolean;
|
|
3756
|
-
gender?: string;
|
|
3757
|
-
birthdate?: string;
|
|
3758
|
-
zoneinfo?: string;
|
|
3759
|
-
locale?: string;
|
|
3760
|
-
phone_number?: string;
|
|
3761
|
-
phone_number_verified?: boolean;
|
|
3762
|
-
address?: {
|
|
3763
|
-
formatted?: string;
|
|
3764
|
-
street_address?: string;
|
|
3765
|
-
locality?: string;
|
|
3766
|
-
region?: string;
|
|
3767
|
-
postal_code?: string;
|
|
3768
|
-
country?: string;
|
|
3769
|
-
};
|
|
3770
|
-
updated_at?: number;
|
|
3771
|
-
[key: string]: unknown;
|
|
3772
|
-
}
|
|
3773
|
-
//#endregion
|
|
3774
|
-
//#region src/server-auth/descriptors/$auth.d.ts
|
|
3775
|
-
type AuthDescriptorOptions = {
|
|
3776
|
-
/**
|
|
3777
|
-
* Name of the identity provider.
|
|
3778
|
-
* If not provided, it will be derived from the property key.
|
|
3779
|
-
*/
|
|
3780
|
-
name?: string;
|
|
3781
|
-
/**
|
|
3782
|
-
* If true, auth provider will be skipped.
|
|
3783
|
-
*/
|
|
3784
|
-
disabled?: boolean;
|
|
3785
|
-
} & (AuthExternal | AuthInternal);
|
|
3786
|
-
/**
|
|
3787
|
-
* When you let an external service handle authentication. (e.g. Keycloak, Auth0, etc.)
|
|
3788
|
-
*/
|
|
3789
|
-
type AuthExternal = {
|
|
3790
|
-
/**
|
|
3791
|
-
* Only OIDC is supported for external authentication.
|
|
3792
|
-
*/
|
|
3793
|
-
oidc: OidcOptions;
|
|
3794
|
-
/**
|
|
3795
|
-
* For anonymous access, this will expect a service account access token.
|
|
3796
|
-
*
|
|
3797
|
-
* ```ts
|
|
3798
|
-
* class App {
|
|
3799
|
-
* anonymous = $serviceAccount(...);
|
|
3800
|
-
* auth = $auth({
|
|
3801
|
-
* // ... config ...
|
|
3802
|
-
* fallback: this.anonymous,
|
|
3803
|
-
* })
|
|
3804
|
-
* }
|
|
3805
|
-
* ```
|
|
3806
|
-
*/
|
|
3807
|
-
fallback?: () => Async<AccessToken>;
|
|
3808
|
-
};
|
|
3809
|
-
/**
|
|
3810
|
-
* When using your own authentication system, e.g. using a database to store user accounts.
|
|
3811
|
-
* This is usually used with a custom login form.
|
|
3812
|
-
*
|
|
3813
|
-
* This relies on the `realm`, which is used to create/verify the access token.
|
|
3814
|
-
*/
|
|
3815
|
-
type AuthInternal = {
|
|
3816
|
-
realm: RealmDescriptor;
|
|
3817
|
-
} & ({
|
|
3818
|
-
/**
|
|
3819
|
-
* The common username/password authentication.
|
|
3820
|
-
*
|
|
3821
|
-
* - It uses the OAuth2 Client Credentials flow to obtain an access token.
|
|
3822
|
-
*
|
|
3823
|
-
* This is usually used with a custom login form on your website or mobile app.
|
|
3824
|
-
*/
|
|
3825
|
-
credentials: CredentialsOptions;
|
|
3826
|
-
} | {
|
|
3827
|
-
/**
|
|
3828
|
-
* OAuth2 authentication. Delegates authentication to an OAuth2 provider. (e.g. Google, GitHub, etc.)
|
|
3829
|
-
*
|
|
3830
|
-
* - It uses the OAuth2 Authorization Code flow to obtain an access token and user information.
|
|
3831
|
-
*
|
|
3832
|
-
* This is usually used with a login button that redirects to the OAuth2 provider.
|
|
3833
|
-
*/
|
|
3834
|
-
oauth: OAuth2Options;
|
|
3835
|
-
} | {
|
|
3836
|
-
/**
|
|
3837
|
-
* Like OAuth2, but uses OIDC (OpenID Connect) for authentication and user information retrieval.
|
|
3838
|
-
* OIDC is an identity layer on top of OAuth2, providing user authentication and profile information.
|
|
3839
|
-
*
|
|
3840
|
-
* - It uses the OAuth2 Authorization Code flow to obtain an access token and user information.
|
|
3841
|
-
* - PCKE (Proof Key for Code Exchange) is recommended for security.
|
|
3842
|
-
*
|
|
3843
|
-
* This is usually used with a login button that redirects to the OIDC provider.
|
|
3844
|
-
*/
|
|
3845
|
-
oidc: OidcOptions;
|
|
3846
|
-
});
|
|
3847
|
-
type CredentialsOptions = {
|
|
3848
|
-
account: CredentialsFn;
|
|
3849
|
-
};
|
|
3850
|
-
type CredentialsFn = (credentials: Credentials) => Async<UserAccount | undefined>;
|
|
3851
|
-
interface Credentials {
|
|
3852
|
-
username: string;
|
|
3853
|
-
password: string;
|
|
3854
|
-
}
|
|
3855
|
-
interface OidcOptions {
|
|
3856
|
-
/**
|
|
3857
|
-
* URL of the OIDC issuer.
|
|
3858
|
-
*/
|
|
3859
|
-
issuer: string;
|
|
3860
|
-
/**
|
|
3861
|
-
* Client ID for the OIDC client.
|
|
3862
|
-
*/
|
|
3863
|
-
clientId: string;
|
|
3864
|
-
/**
|
|
3865
|
-
* Client secret for the OIDC client.
|
|
3866
|
-
* Optional if PKCE (Proof Key for Code Exchange) is used.
|
|
3867
|
-
*/
|
|
3868
|
-
clientSecret?: string;
|
|
3869
|
-
/**
|
|
3870
|
-
* Redirect URI for the OIDC client.
|
|
3871
|
-
* This is where the user will be redirected after authentication.
|
|
3872
|
-
*/
|
|
3873
|
-
redirectUri?: string;
|
|
3874
|
-
/**
|
|
3875
|
-
* For external auth providers only.
|
|
3876
|
-
* Take the ID token instead of the access token for validation.
|
|
3877
|
-
*/
|
|
3878
|
-
useIdToken?: boolean;
|
|
3879
|
-
/**
|
|
3880
|
-
* URI to redirect the user after logout.
|
|
3881
|
-
*/
|
|
3882
|
-
logoutUri?: string;
|
|
3883
|
-
/**
|
|
3884
|
-
* Optional scope for the OIDC client.
|
|
3885
|
-
* @default "openid profile email".
|
|
3886
|
-
*/
|
|
3887
|
-
scope?: string;
|
|
3888
|
-
account?: LinkAccountFn;
|
|
3889
|
-
}
|
|
3890
|
-
interface LinkAccountOptions {
|
|
3891
|
-
access_token: string;
|
|
3892
|
-
user: OAuth2Profile;
|
|
3893
|
-
id_token?: string;
|
|
3894
|
-
expires_in?: number;
|
|
3895
|
-
scope?: string;
|
|
3896
|
-
}
|
|
3897
|
-
type LinkAccountFn = (tokens: LinkAccountOptions) => Async<UserAccount>;
|
|
3898
|
-
interface OAuth2Options {
|
|
3899
|
-
/**
|
|
3900
|
-
* URL of the OAuth2 authorization endpoint.
|
|
3901
|
-
*/
|
|
3902
|
-
clientId: string;
|
|
3903
|
-
/**
|
|
3904
|
-
* Client secret for the OAuth2 client.
|
|
3905
|
-
*/
|
|
3906
|
-
clientSecret: string;
|
|
3907
|
-
/**
|
|
3908
|
-
* URL of the OAuth2 authorization endpoint.
|
|
3909
|
-
*/
|
|
3910
|
-
authorization: string;
|
|
3911
|
-
/**
|
|
3912
|
-
* URL of the OAuth2 token endpoint.
|
|
3913
|
-
*/
|
|
3914
|
-
token: string;
|
|
3915
|
-
/**
|
|
3916
|
-
* Function to retrieve user profile information from the OAuth2 tokens.
|
|
3917
|
-
*/
|
|
3918
|
-
userinfo: (tokens: Tokens) => Async<OAuth2Profile>;
|
|
3919
|
-
account?: LinkAccountFn;
|
|
3920
|
-
/**
|
|
3921
|
-
* URL of the OAuth2 authorization endpoint.
|
|
3922
|
-
*/
|
|
3923
|
-
redirectUri?: string;
|
|
3924
|
-
/**
|
|
3925
|
-
* URL of the OAuth2 authorization endpoint.
|
|
3926
|
-
*/
|
|
3927
|
-
scope?: string;
|
|
3928
|
-
}
|
|
3929
|
-
declare class AuthDescriptor extends Descriptor<AuthDescriptorOptions> {
|
|
3930
|
-
protected readonly securityProvider: SecurityProvider;
|
|
3931
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
3932
|
-
oauth?: Configuration;
|
|
3933
|
-
get name(): string;
|
|
3934
|
-
get jwks_uri(): string;
|
|
3935
|
-
get scope(): string | undefined;
|
|
3936
|
-
get redirect_uri(): string | undefined;
|
|
3937
|
-
/**
|
|
3938
|
-
* Refreshes the access token using the refresh token.
|
|
3939
|
-
* Can be used on oauth2, oidc or credentials auth providers.
|
|
3940
|
-
*/
|
|
3941
|
-
refresh(refreshToken: string, accessToken?: string): Promise<AccessTokenResponse>;
|
|
3942
|
-
/**
|
|
3943
|
-
* Extracts user information from the access token.
|
|
3944
|
-
* This is used to create a user account from the access token.
|
|
3945
|
-
*/
|
|
3946
|
-
user(tokens: Tokens): Promise<UserAccount>;
|
|
3947
|
-
protected getUserFromIdToken(idToken: string): OAuth2Profile;
|
|
3948
|
-
prepare(): Promise<void>;
|
|
3949
|
-
}
|
|
3950
|
-
type AccessToken = string | {
|
|
3951
|
-
token: () => Async<string>;
|
|
3952
|
-
};
|
|
3953
|
-
interface WithLinkFn {
|
|
3954
|
-
link?: (name: string) => (opts: LinkAccountOptions) => Async<UserAccount>;
|
|
3955
|
-
}
|
|
3956
|
-
interface WithLoginFn {
|
|
3957
|
-
login?: (provider: string) => (creds: Credentials) => Async<UserAccount | undefined>;
|
|
3958
|
-
}
|
|
3959
|
-
//#endregion
|
|
3960
|
-
//#region src/server-auth/index.d.ts
|
|
3961
|
-
declare module "alepha" {
|
|
3962
|
-
interface State {
|
|
3963
|
-
/**
|
|
3964
|
-
* The authenticated user account attached to the server request state.
|
|
3965
|
-
*
|
|
3966
|
-
* @internal
|
|
3967
|
-
*/
|
|
3968
|
-
"alepha.server.request.user"?: UserAccount;
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
/**
|
|
3972
|
-
* Allow authentication services for server applications.
|
|
3973
|
-
* It provides login and logout functionalities.
|
|
3974
|
-
*
|
|
3975
|
-
* There are multiple authentication providers available (e.g., Google, GitHub).
|
|
3976
|
-
* You can also delegate authentication to your own OIDC/OAuth2, for example using Keycloak or Auth0.
|
|
3977
|
-
*
|
|
3978
|
-
* It's cookie-based and SSR friendly.
|
|
3979
|
-
*
|
|
3980
|
-
* @see {@link $auth}
|
|
3981
|
-
* @see {@link ServerAuthProvider}
|
|
3982
|
-
* @module alepha.server.auth
|
|
3983
|
-
*/
|
|
3984
|
-
//#endregion
|
|
3985
|
-
//#region src/api-users/controllers/UserRealmController.d.ts
|
|
3986
|
-
/**
|
|
3987
|
-
* Controller for exposing realm configuration.
|
|
3988
|
-
* Uses $route instead of $action to keep endpoints hidden from API documentation.
|
|
3989
|
-
*/
|
|
3990
|
-
declare class UserRealmController {
|
|
3991
|
-
protected readonly url = "/realms";
|
|
3992
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
3993
|
-
protected readonly serverAuthProvider: ServerAuthProvider;
|
|
3994
|
-
protected readonly cryptoProvider: CryptoProvider;
|
|
3995
|
-
/**
|
|
3996
|
-
* Get realm configuration settings.
|
|
3997
|
-
* This endpoint is not exposed in the API documentation.
|
|
3998
|
-
*/
|
|
3999
|
-
readonly getRealmConfig: alepha_server0.ActionDescriptorFn<{
|
|
4000
|
-
query: alepha1.TObject<{
|
|
4001
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
4002
|
-
}>;
|
|
4003
|
-
response: alepha1.TObject<{
|
|
4004
|
-
settings: alepha1.TObject<{
|
|
4005
|
-
registrationAllowed: alepha1.TBoolean;
|
|
4006
|
-
emailEnabled: alepha1.TBoolean;
|
|
4007
|
-
emailRequired: alepha1.TBoolean;
|
|
4008
|
-
usernameEnabled: alepha1.TBoolean;
|
|
4009
|
-
usernameRequired: alepha1.TBoolean;
|
|
4010
|
-
phoneEnabled: alepha1.TBoolean;
|
|
4011
|
-
phoneRequired: alepha1.TBoolean;
|
|
4012
|
-
verifyEmailRequired: alepha1.TBoolean;
|
|
4013
|
-
verifyPhoneRequired: alepha1.TBoolean;
|
|
4014
|
-
firstNameLastNameEnabled: alepha1.TBoolean;
|
|
4015
|
-
firstNameLastNameRequired: alepha1.TBoolean;
|
|
4016
|
-
resetPasswordAllowed: alepha1.TBoolean;
|
|
4017
|
-
passwordPolicy: alepha1.TObject<{
|
|
4018
|
-
minLength: alepha1.TInteger;
|
|
4019
|
-
requireUppercase: alepha1.TBoolean;
|
|
4020
|
-
requireLowercase: alepha1.TBoolean;
|
|
4021
|
-
requireNumbers: alepha1.TBoolean;
|
|
4022
|
-
requireSpecialCharacters: alepha1.TBoolean;
|
|
4023
|
-
}>;
|
|
4024
|
-
}>;
|
|
4025
|
-
realmName: alepha1.TString;
|
|
4026
|
-
authenticationMethods: alepha1.TArray<alepha1.TObject<{
|
|
4027
|
-
name: alepha1.TString;
|
|
4028
|
-
type: alepha1.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
4029
|
-
}>>;
|
|
4030
|
-
}>;
|
|
4031
|
-
}>;
|
|
4032
|
-
readonly checkUsernameAvailability: alepha_server0.ActionDescriptorFn<{
|
|
4033
|
-
query: alepha1.TObject<{
|
|
4034
|
-
userRealmName: alepha1.TOptional<alepha1.TString>;
|
|
4035
|
-
}>;
|
|
4036
|
-
body: alepha1.TObject<{
|
|
4037
|
-
username: alepha1.TString;
|
|
4038
|
-
}>;
|
|
4039
|
-
response: alepha1.TObject<{
|
|
4040
|
-
available: alepha1.TBoolean;
|
|
4041
|
-
}>;
|
|
4042
|
-
}>;
|
|
4043
|
-
}
|
|
4044
|
-
//#endregion
|
|
4045
|
-
//#region src/api-users/descriptors/$userRealm.d.ts
|
|
4046
|
-
type UserRealmDescriptor = RealmDescriptor & WithLinkFn & WithLoginFn;
|
|
4047
|
-
/**
|
|
4048
|
-
* Already configured realm for user management.
|
|
4049
|
-
*
|
|
4050
|
-
* Realm contains two roles: `admin` and `user`.
|
|
4051
|
-
*
|
|
4052
|
-
* - `admin`: Has full access to all resources and permissions.
|
|
4053
|
-
* - `user`: Has access to their own resources and permissions, but cannot access admin-level resources.
|
|
4054
|
-
*
|
|
4055
|
-
* Realm uses session management for handling user sessions.
|
|
4056
|
-
*
|
|
4057
|
-
* Environment Variables:
|
|
4058
|
-
* - `APP_SECRET`: Secret key for signing tokens (if not provided in options).
|
|
4059
|
-
*/
|
|
4060
|
-
declare const $userRealm: (options?: UserRealmOptions) => UserRealmDescriptor;
|
|
4061
|
-
interface UserRealmOptions {
|
|
4062
|
-
/**
|
|
4063
|
-
* Secret key for signing tokens.
|
|
4064
|
-
*
|
|
4065
|
-
* If not provided, the secret from the SecurityProvider will be used (usually from the APP_SECRET environment variable).
|
|
4066
|
-
*/
|
|
4067
|
-
secret?: string;
|
|
4068
|
-
/**
|
|
4069
|
-
* Realm configuration options.
|
|
4070
|
-
*
|
|
4071
|
-
* It's already pre-configured for user management with admin and user roles.
|
|
4072
|
-
*/
|
|
4073
|
-
realm?: Partial<RealmDescriptorOptions>;
|
|
4074
|
-
/**
|
|
4075
|
-
* Override entities.
|
|
4076
|
-
*/
|
|
4077
|
-
entities?: {
|
|
4078
|
-
users?: Repository<typeof users.schema>;
|
|
4079
|
-
identities?: Repository<typeof identities.schema>;
|
|
4080
|
-
sessions?: Repository<typeof sessions.schema>;
|
|
4081
|
-
};
|
|
4082
|
-
settings?: Partial<RealmAuthSettings>;
|
|
4083
|
-
identities?: {
|
|
4084
|
-
credentials?: true;
|
|
4085
|
-
google?: true;
|
|
4086
|
-
github?: true;
|
|
4087
|
-
};
|
|
4088
|
-
}
|
|
4089
|
-
//#endregion
|
|
4090
|
-
//#region src/api-users/schemas/identityResourceSchema.d.ts
|
|
4091
|
-
declare const identityResourceSchema: alepha1.TObject<{
|
|
4092
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4093
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4094
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4095
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4096
|
-
userId: PgAttr<alepha1.TString, typeof PG_REF>;
|
|
4097
|
-
provider: alepha1.TString;
|
|
4098
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
4099
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
4100
|
-
}>;
|
|
4101
|
-
type IdentityResource = Static<typeof identityResourceSchema>;
|
|
4102
|
-
//#endregion
|
|
4103
|
-
//#region src/api-users/schemas/loginSchema.d.ts
|
|
4104
|
-
declare const loginSchema: alepha1.TObject<{
|
|
4105
|
-
username: alepha1.TString;
|
|
4106
|
-
password: alepha1.TString;
|
|
4107
|
-
}>;
|
|
4108
|
-
type LoginInput = Static<typeof loginSchema>;
|
|
4109
|
-
//#endregion
|
|
4110
|
-
//#region src/api-users/schemas/registerSchema.d.ts
|
|
4111
|
-
declare const registerSchema: alepha1.TObject<{
|
|
4112
|
-
username: alepha1.TString;
|
|
4113
|
-
email: alepha1.TString;
|
|
4114
|
-
password: alepha1.TString;
|
|
4115
|
-
confirmPassword: alepha1.TString;
|
|
4116
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
4117
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
4118
|
-
}>;
|
|
4119
|
-
type RegisterInput = Static<typeof registerSchema>;
|
|
4120
|
-
//#endregion
|
|
4121
|
-
//#region src/api-users/schemas/resetPasswordSchema.d.ts
|
|
4122
|
-
declare const resetPasswordRequestSchema: alepha1.TObject<{
|
|
4123
|
-
email: alepha1.TString;
|
|
4124
|
-
}>;
|
|
4125
|
-
declare const resetPasswordSchema: alepha1.TObject<{
|
|
4126
|
-
token: alepha1.TString;
|
|
4127
|
-
password: alepha1.TString;
|
|
4128
|
-
confirmPassword: alepha1.TString;
|
|
4129
|
-
}>;
|
|
4130
|
-
type ResetPasswordRequest = Static<typeof resetPasswordRequestSchema>;
|
|
4131
|
-
type ResetPasswordInput = Static<typeof resetPasswordSchema>;
|
|
4132
|
-
//#endregion
|
|
4133
|
-
//#region src/api-users/schemas/sessionResourceSchema.d.ts
|
|
4134
|
-
declare const sessionResourceSchema: alepha1.TObject<{
|
|
4135
|
-
id: alepha1.TString;
|
|
4136
|
-
version: alepha1.TNumber;
|
|
4137
|
-
createdAt: alepha1.TString;
|
|
4138
|
-
updatedAt: alepha1.TString;
|
|
4139
|
-
refreshToken: alepha1.TString;
|
|
4140
|
-
userId: alepha1.TString;
|
|
4141
|
-
expiresAt: alepha1.TString;
|
|
4142
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
4143
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
4144
|
-
os: alepha1.TString;
|
|
4145
|
-
browser: alepha1.TString;
|
|
4146
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
4147
|
-
}>>;
|
|
4148
|
-
}>;
|
|
4149
|
-
type SessionResource = Static<typeof sessionResourceSchema>;
|
|
4150
|
-
//#endregion
|
|
4151
|
-
//#region src/api-users/schemas/userRealmConfigSchema.d.ts
|
|
4152
|
-
declare const userRealmConfigSchema: alepha1.TObject<{
|
|
4153
|
-
settings: alepha1.TObject<{
|
|
4154
|
-
registrationAllowed: alepha1.TBoolean;
|
|
4155
|
-
emailEnabled: alepha1.TBoolean;
|
|
4156
|
-
emailRequired: alepha1.TBoolean;
|
|
4157
|
-
usernameEnabled: alepha1.TBoolean;
|
|
4158
|
-
usernameRequired: alepha1.TBoolean;
|
|
4159
|
-
phoneEnabled: alepha1.TBoolean;
|
|
4160
|
-
phoneRequired: alepha1.TBoolean;
|
|
4161
|
-
verifyEmailRequired: alepha1.TBoolean;
|
|
4162
|
-
verifyPhoneRequired: alepha1.TBoolean;
|
|
4163
|
-
firstNameLastNameEnabled: alepha1.TBoolean;
|
|
4164
|
-
firstNameLastNameRequired: alepha1.TBoolean;
|
|
4165
|
-
resetPasswordAllowed: alepha1.TBoolean;
|
|
4166
|
-
passwordPolicy: alepha1.TObject<{
|
|
4167
|
-
minLength: alepha1.TInteger;
|
|
4168
|
-
requireUppercase: alepha1.TBoolean;
|
|
4169
|
-
requireLowercase: alepha1.TBoolean;
|
|
4170
|
-
requireNumbers: alepha1.TBoolean;
|
|
4171
|
-
requireSpecialCharacters: alepha1.TBoolean;
|
|
4172
|
-
}>;
|
|
4173
|
-
}>;
|
|
4174
|
-
realmName: alepha1.TString;
|
|
4175
|
-
authenticationMethods: alepha1.TArray<alepha1.TObject<{
|
|
4176
|
-
name: alepha1.TString;
|
|
4177
|
-
type: alepha1.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
|
|
4178
|
-
}>>;
|
|
4179
|
-
}>;
|
|
4180
|
-
type UserRealmConfig = Static<typeof userRealmConfigSchema>;
|
|
4181
|
-
//#endregion
|
|
4182
|
-
//#region src/api-users/schemas/userResourceSchema.d.ts
|
|
4183
|
-
declare const userResourceSchema: alepha1.TObject<{
|
|
4184
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4185
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4186
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4187
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4188
|
-
realm: PgAttr<alepha1.TString, typeof PG_DEFAULT>;
|
|
4189
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
4190
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
4191
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
4192
|
-
roles: PgAttr<alepha1.TArray<alepha1.TString>, typeof PG_DEFAULT>;
|
|
4193
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
4194
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
4195
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
4196
|
-
enabled: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4197
|
-
emailVerified: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4198
|
-
}>;
|
|
4199
|
-
type UserResource = Static<typeof userResourceSchema>;
|
|
4200
|
-
//#endregion
|
|
4201
|
-
//#region src/api-files/entities/files.d.ts
|
|
4202
|
-
declare const files: alepha_orm198.EntityDescriptor<alepha1.TObject<{
|
|
4203
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4204
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4205
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4206
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4207
|
-
blobId: alepha1.TString;
|
|
4208
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4209
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4210
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4211
|
-
bucket: alepha1.TString;
|
|
4212
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4213
|
-
name: alepha1.TString;
|
|
4214
|
-
size: alepha1.TNumber;
|
|
4215
|
-
mimeType: alepha1.TString;
|
|
4216
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4217
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4218
|
-
}>>;
|
|
4219
|
-
type FileEntity = Static<typeof files.schema>;
|
|
4220
|
-
//#endregion
|
|
4221
|
-
//#region src/api-files/schemas/fileQuerySchema.d.ts
|
|
4222
|
-
declare const fileQuerySchema: alepha1.TObject<{
|
|
4223
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
4224
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
4225
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
4226
|
-
bucket: alepha1.TOptional<alepha1.TString>;
|
|
4227
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4228
|
-
name: alepha1.TOptional<alepha1.TString>;
|
|
4229
|
-
mimeType: alepha1.TOptional<alepha1.TString>;
|
|
4230
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4231
|
-
createdAfter: alepha1.TOptional<alepha1.TString>;
|
|
4232
|
-
createdBefore: alepha1.TOptional<alepha1.TString>;
|
|
4233
|
-
}>;
|
|
4234
|
-
type FileQuery = Static<typeof fileQuerySchema>;
|
|
4235
|
-
//#endregion
|
|
4236
|
-
//#region src/api-files/schemas/fileResourceSchema.d.ts
|
|
4237
|
-
declare const fileResourceSchema: alepha1.TObject<{
|
|
4238
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4239
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4240
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4241
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4242
|
-
blobId: alepha1.TString;
|
|
4243
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4244
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4245
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4246
|
-
bucket: alepha1.TString;
|
|
4247
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4248
|
-
name: alepha1.TString;
|
|
4249
|
-
size: alepha1.TNumber;
|
|
4250
|
-
mimeType: alepha1.TString;
|
|
4251
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4252
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4253
|
-
}>;
|
|
4254
|
-
type FileResource = Static<typeof fileResourceSchema>;
|
|
4255
|
-
//#endregion
|
|
4256
|
-
//#region src/api-files/schemas/storageStatsSchema.d.ts
|
|
4257
|
-
declare const storageStatsSchema: alepha1.TObject<{
|
|
4258
|
-
totalSize: alepha1.TNumber;
|
|
4259
|
-
totalFiles: alepha1.TNumber;
|
|
4260
|
-
byBucket: alepha1.TArray<alepha1.TObject<{
|
|
4261
|
-
bucket: alepha1.TString;
|
|
4262
|
-
totalSize: alepha1.TNumber;
|
|
4263
|
-
fileCount: alepha1.TNumber;
|
|
4264
|
-
}>>;
|
|
4265
|
-
byMimeType: alepha1.TArray<alepha1.TObject<{
|
|
4266
|
-
mimeType: alepha1.TString;
|
|
4267
|
-
fileCount: alepha1.TNumber;
|
|
4268
|
-
}>>;
|
|
4269
|
-
}>;
|
|
4270
|
-
type StorageStats = Static<typeof storageStatsSchema>;
|
|
4271
|
-
//#endregion
|
|
4272
|
-
//#region src/api-files/services/FileService.d.ts
|
|
4273
|
-
declare class FileService {
|
|
4274
|
-
protected readonly alepha: Alepha;
|
|
4275
|
-
protected readonly log: alepha_logger1.Logger;
|
|
4276
|
-
protected readonly fileRepository: alepha_orm198.Repository<alepha1.TObject<{
|
|
4277
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4278
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4279
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4280
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4281
|
-
blobId: alepha1.TString;
|
|
4282
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4283
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4284
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4285
|
-
bucket: alepha1.TString;
|
|
4286
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4287
|
-
name: alepha1.TString;
|
|
4288
|
-
size: alepha1.TNumber;
|
|
4289
|
-
mimeType: alepha1.TString;
|
|
4290
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4291
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4292
|
-
}>>;
|
|
4293
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
4294
|
-
protected readonly defaultBucket: BucketDescriptor;
|
|
4295
|
-
protected onUploadFile: alepha1.HookDescriptor<"bucket:file:uploaded">;
|
|
4296
|
-
protected onDeleteBucketFile: alepha1.HookDescriptor<"bucket:file:deleted">;
|
|
4297
|
-
/**
|
|
4298
|
-
* Calculates SHA-256 checksum of a file.
|
|
4299
|
-
*
|
|
4300
|
-
* @param file - The file to calculate checksum for
|
|
4301
|
-
* @returns Hexadecimal string representation of the SHA-256 hash
|
|
4302
|
-
* @protected
|
|
4303
|
-
*/
|
|
4304
|
-
protected calculateChecksum(file: FileLike): Promise<string>;
|
|
4305
|
-
/**
|
|
4306
|
-
* Gets a bucket descriptor by name.
|
|
4307
|
-
*
|
|
4308
|
-
* @param bucketName - The name of the bucket to retrieve (defaults to "default")
|
|
4309
|
-
* @returns The bucket descriptor
|
|
4310
|
-
* @throws {NotFoundError} If the bucket is not found
|
|
4311
|
-
*/
|
|
4312
|
-
bucket(bucketName?: string): BucketDescriptor;
|
|
4313
|
-
/**
|
|
4314
|
-
* Finds files matching the given query criteria with pagination support.
|
|
4315
|
-
* Supports filtering by bucket, tags, name, mimeType, creator, and date range.
|
|
4316
|
-
*
|
|
4317
|
-
* @param q - Query parameters including bucket, tags, name, mimeType, creator, date range, pagination, and sorting
|
|
4318
|
-
* @returns Paginated list of file entities
|
|
4319
|
-
*/
|
|
4320
|
-
findFiles(q?: FileQuery): Promise<Page$1<FileEntity>>;
|
|
4321
|
-
/**
|
|
4322
|
-
* Finds files that have expired based on their expiration date.
|
|
4323
|
-
* Limited to 1000 files per call to prevent memory issues.
|
|
4324
|
-
*
|
|
4325
|
-
* @returns Array of expired file entities
|
|
4326
|
-
*/
|
|
4327
|
-
findExpiredFiles(): Promise<FileEntity[]>;
|
|
4328
|
-
/**
|
|
4329
|
-
* Calculates an expiration date based on a TTL (time to live) duration.
|
|
4330
|
-
*
|
|
4331
|
-
* @param ttl - Duration like "1 day", "2 hours", etc.
|
|
4332
|
-
* @returns DateTime representation of the expiration date, or undefined if no TTL provided
|
|
4333
|
-
* @protected
|
|
4334
|
-
*/
|
|
4335
|
-
protected getExpirationDate(ttl?: DurationLike): string | undefined;
|
|
4336
|
-
/**
|
|
4337
|
-
* Uploads a file to a bucket and creates a database record with metadata.
|
|
4338
|
-
* Automatically calculates and stores the file checksum (SHA-256).
|
|
4339
|
-
*
|
|
4340
|
-
* @param file - The file to upload
|
|
4341
|
-
* @param options - Upload options including bucket, expiration, user, and tags
|
|
4342
|
-
* @param options.bucket - Target bucket name (defaults to "default")
|
|
4343
|
-
* @param options.expirationDate - When the file should expire
|
|
4344
|
-
* @param options.user - User performing the upload (for audit trail)
|
|
4345
|
-
* @param options.tags - Tags to associate with the file
|
|
4346
|
-
* @returns The created file entity with all metadata
|
|
4347
|
-
* @throws {NotFoundError} If the specified bucket doesn't exist
|
|
4348
|
-
*/
|
|
4349
|
-
uploadFile(file: FileLike, options?: {
|
|
4350
|
-
expirationDate?: string | DateTime;
|
|
4351
|
-
bucket?: string;
|
|
4352
|
-
user?: UserAccountToken;
|
|
4353
|
-
tags?: string[];
|
|
4354
|
-
}): Promise<FileEntity>;
|
|
4355
|
-
/**
|
|
4356
|
-
* Streams a file from storage by its database ID.
|
|
4357
|
-
*
|
|
4358
|
-
* @param id - The database ID (UUID) of the file to stream
|
|
4359
|
-
* @returns The file object ready for streaming/downloading
|
|
4360
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
4361
|
-
* @throws {FileNotFoundError} If the file exists in database but not in storage
|
|
4362
|
-
*/
|
|
4363
|
-
streamFile(id: string): Promise<FileLike>;
|
|
4364
|
-
/**
|
|
4365
|
-
* Updates file metadata (name, tags, expiration date).
|
|
4366
|
-
* Does not modify the actual file content in storage.
|
|
4367
|
-
*
|
|
4368
|
-
* @param id - The database ID (UUID) of the file to update
|
|
4369
|
-
* @param data - Partial file data to update
|
|
4370
|
-
* @param data.name - New file name
|
|
4371
|
-
* @param data.tags - New tags array
|
|
4372
|
-
* @param data.expirationDate - New expiration date
|
|
4373
|
-
* @returns The updated file entity
|
|
4374
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
4375
|
-
*/
|
|
4376
|
-
updateFile(id: string, data: {
|
|
4377
|
-
name?: string;
|
|
4378
|
-
tags?: string[];
|
|
4379
|
-
expirationDate?: DateTime | string;
|
|
4380
|
-
}): Promise<FileEntity>;
|
|
4381
|
-
/**
|
|
4382
|
-
* Deletes a file from both storage and database.
|
|
4383
|
-
* Handles cases where file is already deleted from storage gracefully.
|
|
4384
|
-
* Always ensures database record is removed even if storage deletion fails.
|
|
4385
|
-
*
|
|
4386
|
-
* @param id - The database ID (UUID) of the file to delete
|
|
4387
|
-
* @returns Success response with the deleted file ID
|
|
4388
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
4389
|
-
*/
|
|
4390
|
-
deleteFile(id: string): Promise<Ok>;
|
|
4391
|
-
/**
|
|
4392
|
-
* Retrieves a file entity by its ID.
|
|
4393
|
-
* If already an entity object, returns it as-is (convenience method).
|
|
4394
|
-
*
|
|
4395
|
-
* @param id - Either a UUID string or an existing FileEntity object
|
|
4396
|
-
* @returns The file entity
|
|
4397
|
-
* @throws {NotFoundError} If the file doesn't exist in the database
|
|
4398
|
-
*/
|
|
4399
|
-
getFileById(id: string | FileEntity): Promise<FileEntity>;
|
|
4400
|
-
/**
|
|
4401
|
-
* Gets storage statistics including total size, file count, and breakdowns by bucket and MIME type.
|
|
4402
|
-
*
|
|
4403
|
-
* @returns Storage statistics with aggregated data
|
|
4404
|
-
*/
|
|
4405
|
-
getStorageStats(): Promise<StorageStats>;
|
|
4406
|
-
/**
|
|
4407
|
-
* Converts a file entity to a file resource (API response format).
|
|
4408
|
-
* Currently a pass-through, but allows for future transformation logic.
|
|
4409
|
-
*
|
|
4410
|
-
* @param entity - The file entity to convert
|
|
4411
|
-
* @returns The file resource for API responses
|
|
4412
|
-
*/
|
|
4413
|
-
entityToResource(entity: FileEntity): FileResource;
|
|
4414
|
-
}
|
|
4415
|
-
//#endregion
|
|
4416
|
-
//#region src/api-files/controllers/FileController.d.ts
|
|
4417
|
-
/**
|
|
4418
|
-
* REST API controller for file management operations.
|
|
4419
|
-
* Provides endpoints for uploading, downloading, listing, and deleting files.
|
|
4420
|
-
*/
|
|
4421
|
-
declare class FileController {
|
|
4422
|
-
protected readonly url = "/files";
|
|
4423
|
-
protected readonly group = "files";
|
|
4424
|
-
protected readonly fileService: FileService;
|
|
4425
|
-
/**
|
|
4426
|
-
* GET /files - Lists files with optional filtering and pagination.
|
|
4427
|
-
* Supports filtering by bucket and tags.
|
|
4428
|
-
*/
|
|
4429
|
-
readonly findFiles: alepha_server0.ActionDescriptorFn<{
|
|
4430
|
-
query: alepha1.TObject<{
|
|
4431
|
-
page: alepha1.TOptional<alepha1.TInteger>;
|
|
4432
|
-
size: alepha1.TOptional<alepha1.TInteger>;
|
|
4433
|
-
sort: alepha1.TOptional<alepha1.TString>;
|
|
4434
|
-
bucket: alepha1.TOptional<alepha1.TString>;
|
|
4435
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4436
|
-
name: alepha1.TOptional<alepha1.TString>;
|
|
4437
|
-
mimeType: alepha1.TOptional<alepha1.TString>;
|
|
4438
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4439
|
-
createdAfter: alepha1.TOptional<alepha1.TString>;
|
|
4440
|
-
createdBefore: alepha1.TOptional<alepha1.TString>;
|
|
4441
|
-
}>;
|
|
4442
|
-
response: alepha1.TPage<alepha1.TObject<{
|
|
4443
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4444
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4445
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4446
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4447
|
-
blobId: alepha1.TString;
|
|
4448
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4449
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4450
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4451
|
-
bucket: alepha1.TString;
|
|
4452
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4453
|
-
name: alepha1.TString;
|
|
4454
|
-
size: alepha1.TNumber;
|
|
4455
|
-
mimeType: alepha1.TString;
|
|
4456
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4457
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4458
|
-
}>>;
|
|
4459
|
-
}>;
|
|
4460
|
-
/**
|
|
4461
|
-
* DELETE /files/:id - Deletes a file from both storage and database.
|
|
4462
|
-
* Removes the file from the bucket and cleans up the database record.
|
|
4463
|
-
*/
|
|
4464
|
-
readonly deleteFile: alepha_server0.ActionDescriptorFn<{
|
|
4465
|
-
params: alepha1.TObject<{
|
|
4466
|
-
id: alepha1.TString;
|
|
4467
|
-
}>;
|
|
4468
|
-
response: alepha1.TObject<{
|
|
4469
|
-
ok: alepha1.TBoolean;
|
|
4470
|
-
id: alepha1.TOptional<alepha1.TUnion<[alepha1.TString, alepha1.TInteger]>>;
|
|
4471
|
-
count: alepha1.TOptional<alepha1.TNumber>;
|
|
4472
|
-
}>;
|
|
4473
|
-
}>;
|
|
4474
|
-
/**
|
|
4475
|
-
* POST /files - Uploads a new file to storage.
|
|
4476
|
-
* Creates a database record with metadata and calculates checksum.
|
|
4477
|
-
* Optionally specify bucket and expiration date.
|
|
4478
|
-
*/
|
|
4479
|
-
readonly uploadFile: alepha_server0.ActionDescriptorFn<{
|
|
4480
|
-
body: alepha1.TObject<{
|
|
4481
|
-
file: alepha1.TFile;
|
|
4482
|
-
}>;
|
|
4483
|
-
query: alepha1.TObject<{
|
|
4484
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4485
|
-
bucket: alepha1.TOptional<alepha1.TString>;
|
|
4486
|
-
}>;
|
|
4487
|
-
response: alepha1.TObject<{
|
|
4488
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4489
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4490
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4491
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4492
|
-
blobId: alepha1.TString;
|
|
4493
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4494
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4495
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4496
|
-
bucket: alepha1.TString;
|
|
4497
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4498
|
-
name: alepha1.TString;
|
|
4499
|
-
size: alepha1.TNumber;
|
|
4500
|
-
mimeType: alepha1.TString;
|
|
4501
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4502
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4503
|
-
}>;
|
|
4504
|
-
}>;
|
|
4505
|
-
/**
|
|
4506
|
-
* PATCH /files/:id - Updates file metadata.
|
|
4507
|
-
* Allows updating name, tags, and expiration date without modifying file content.
|
|
4508
|
-
*/
|
|
4509
|
-
readonly updateFile: alepha_server0.ActionDescriptorFn<{
|
|
4510
|
-
params: alepha1.TObject<{
|
|
4511
|
-
id: alepha1.TString;
|
|
4512
|
-
}>;
|
|
4513
|
-
body: alepha1.TObject<{
|
|
4514
|
-
name: alepha1.TOptional<alepha1.TString>;
|
|
4515
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4516
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4517
|
-
}>;
|
|
4518
|
-
response: alepha1.TObject<{
|
|
4519
|
-
id: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_PRIMARY_KEY>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4520
|
-
version: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TInteger, typeof alepha_orm198.PG_VERSION>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4521
|
-
createdAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_CREATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4522
|
-
updatedAt: alepha_orm198.PgAttr<alepha_orm198.PgAttr<alepha1.TString, typeof alepha_orm198.PG_UPDATED_AT>, typeof alepha_orm198.PG_DEFAULT>;
|
|
4523
|
-
blobId: alepha1.TString;
|
|
4524
|
-
creator: alepha1.TOptional<alepha1.TString>;
|
|
4525
|
-
creatorRealm: alepha1.TOptional<alepha1.TString>;
|
|
4526
|
-
creatorName: alepha1.TOptional<alepha1.TString>;
|
|
4527
|
-
bucket: alepha1.TString;
|
|
4528
|
-
expirationDate: alepha1.TOptional<alepha1.TString>;
|
|
4529
|
-
name: alepha1.TString;
|
|
4530
|
-
size: alepha1.TNumber;
|
|
4531
|
-
mimeType: alepha1.TString;
|
|
4532
|
-
tags: alepha1.TOptional<alepha1.TArray<alepha1.TString>>;
|
|
4533
|
-
checksum: alepha1.TOptional<alepha1.TString>;
|
|
4534
|
-
}>;
|
|
4535
|
-
}>;
|
|
4536
|
-
/**
|
|
4537
|
-
* GET /files/:id - Streams/downloads a file by its ID.
|
|
4538
|
-
* Returns the file content with appropriate Content-Type header.
|
|
4539
|
-
* Cached with ETag support for 1 year (immutable).
|
|
4540
|
-
*/
|
|
4541
|
-
readonly streamFile: alepha_server0.ActionDescriptorFn<{
|
|
4542
|
-
params: alepha1.TObject<{
|
|
4543
|
-
id: alepha1.TString;
|
|
4544
|
-
}>;
|
|
4545
|
-
response: alepha1.TFile;
|
|
4546
|
-
}>;
|
|
4547
|
-
}
|
|
4548
|
-
//#endregion
|
|
4549
|
-
//#region src/api-files/index.d.ts
|
|
4550
|
-
declare module "alepha/bucket" {
|
|
4551
|
-
interface BucketFileOptions {
|
|
4552
|
-
/**
|
|
4553
|
-
* Time to live for the files in the bucket.
|
|
4554
|
-
*/
|
|
4555
|
-
ttl?: DurationLike;
|
|
4556
|
-
/**
|
|
4557
|
-
* Tags for the bucket.
|
|
4558
|
-
*/
|
|
4559
|
-
tags?: string[];
|
|
4560
|
-
/**
|
|
4561
|
-
* User performing the operation.
|
|
4562
|
-
*/
|
|
4563
|
-
user?: UserAccountToken;
|
|
4564
|
-
/**
|
|
4565
|
-
* Whether to persist the file metadata in the database.
|
|
4566
|
-
*
|
|
4567
|
-
* @default true
|
|
4568
|
-
*/
|
|
4569
|
-
persist?: boolean;
|
|
4570
|
-
}
|
|
4571
|
-
}
|
|
4572
|
-
/**
|
|
4573
|
-
* Provides file management API endpoints for Alepha applications.
|
|
4574
|
-
*
|
|
4575
|
-
* This module includes file upload, download, storage management,
|
|
4576
|
-
* and file metadata operations.
|
|
4577
|
-
*
|
|
4578
|
-
* @module alepha.api.files
|
|
4579
|
-
*/
|
|
4580
|
-
//#endregion
|
|
4581
|
-
//#region src/api-users/services/SessionService.d.ts
|
|
4582
|
-
declare class SessionService {
|
|
4583
|
-
protected readonly alepha: Alepha;
|
|
4584
|
-
protected readonly fsp: FileSystemProvider;
|
|
4585
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
4586
|
-
protected readonly cryptoProvider: CryptoProvider;
|
|
4587
|
-
protected readonly log: alepha_logger1.Logger;
|
|
4588
|
-
protected readonly userRealmProvider: UserRealmProvider;
|
|
4589
|
-
protected readonly fileController: HttpVirtualClient<FileController>;
|
|
4590
|
-
users(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
4591
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4592
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4593
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4594
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4595
|
-
realm: PgAttr<alepha1.TString, typeof PG_DEFAULT>;
|
|
4596
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
4597
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
4598
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
4599
|
-
roles: PgAttr<alepha1.TArray<alepha1.TString>, typeof PG_DEFAULT>;
|
|
4600
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
4601
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
4602
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
4603
|
-
enabled: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4604
|
-
emailVerified: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4605
|
-
}>>;
|
|
4606
|
-
sessions(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
4607
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4608
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4609
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4610
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4611
|
-
refreshToken: alepha1.TString;
|
|
4612
|
-
userId: PgAttr<alepha1.TString, typeof PG_REF>;
|
|
4613
|
-
expiresAt: alepha1.TString;
|
|
4614
|
-
ip: alepha1.TOptional<alepha1.TString>;
|
|
4615
|
-
userAgent: alepha1.TOptional<alepha1.TObject<{
|
|
4616
|
-
os: alepha1.TString;
|
|
4617
|
-
browser: alepha1.TString;
|
|
4618
|
-
device: alepha1.TUnsafe<"MOBILE" | "DESKTOP" | "TABLET">;
|
|
4619
|
-
}>>;
|
|
4620
|
-
}>>;
|
|
4621
|
-
identities(userRealmName?: string): Repository$1<alepha1.TObject<{
|
|
4622
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4623
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4624
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4625
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4626
|
-
userId: PgAttr<alepha1.TString, typeof PG_REF>;
|
|
4627
|
-
password: alepha1.TOptional<alepha1.TString>;
|
|
4628
|
-
provider: alepha1.TString;
|
|
4629
|
-
providerUserId: alepha1.TOptional<alepha1.TString>;
|
|
4630
|
-
providerData: alepha1.TOptional<alepha1.TRecord<string, alepha1.TAny>>;
|
|
4631
|
-
}>>;
|
|
4632
|
-
/**
|
|
4633
|
-
* Random delay to prevent timing attacks (50-200ms)
|
|
4634
|
-
* Uses cryptographically secure random number generation
|
|
4635
|
-
*/
|
|
4636
|
-
protected randomDelay(): Promise<void>;
|
|
4637
|
-
/**
|
|
4638
|
-
* Validate user credentials and return the user if valid.
|
|
4639
|
-
*/
|
|
4640
|
-
login(provider: string, username: string, password: string, userRealmName?: string): Promise<UserEntity>;
|
|
4641
|
-
createSession(user: UserAccount, expiresIn: number, userRealmName?: string): Promise<{
|
|
4642
|
-
refreshToken: string;
|
|
4643
|
-
sessionId: string;
|
|
4644
|
-
}>;
|
|
4645
|
-
refreshSession(refreshToken: string, userRealmName?: string): Promise<{
|
|
4646
|
-
user: PgStatic<alepha1.TObject<{
|
|
4647
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4648
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4649
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4650
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4651
|
-
realm: PgAttr<alepha1.TString, typeof PG_DEFAULT>;
|
|
4652
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
4653
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
4654
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
4655
|
-
roles: PgAttr<alepha1.TArray<alepha1.TString>, typeof PG_DEFAULT>;
|
|
4656
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
4657
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
4658
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
4659
|
-
enabled: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4660
|
-
emailVerified: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4661
|
-
}>, PgRelationMap<alepha1.TObject<{
|
|
4662
|
-
id: PgAttr<PgAttr<alepha1.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
4663
|
-
version: PgAttr<PgAttr<alepha1.TInteger, typeof PG_VERSION>, typeof PG_DEFAULT>;
|
|
4664
|
-
createdAt: PgAttr<PgAttr<alepha1.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
4665
|
-
updatedAt: PgAttr<PgAttr<alepha1.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
4666
|
-
realm: PgAttr<alepha1.TString, typeof PG_DEFAULT>;
|
|
4667
|
-
username: alepha1.TOptional<alepha1.TString>;
|
|
4668
|
-
email: alepha1.TOptional<alepha1.TString>;
|
|
4669
|
-
phoneNumber: alepha1.TOptional<alepha1.TString>;
|
|
4670
|
-
roles: PgAttr<alepha1.TArray<alepha1.TString>, typeof PG_DEFAULT>;
|
|
4671
|
-
firstName: alepha1.TOptional<alepha1.TString>;
|
|
4672
|
-
lastName: alepha1.TOptional<alepha1.TString>;
|
|
4673
|
-
picture: alepha1.TOptional<alepha1.TString>;
|
|
4674
|
-
enabled: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4675
|
-
emailVerified: PgAttr<alepha1.TBoolean, typeof PG_DEFAULT>;
|
|
4676
|
-
}>>>;
|
|
4677
|
-
expiresIn: number;
|
|
4678
|
-
sessionId: string;
|
|
4679
|
-
}>;
|
|
4680
|
-
deleteSession(refreshToken: string, userRealmName?: string): Promise<void>;
|
|
4681
|
-
link(provider: string, profile: OAuth2Profile, userRealmName?: string): Promise<{
|
|
4682
|
-
email?: string | undefined;
|
|
4683
|
-
username?: string | undefined;
|
|
4684
|
-
phoneNumber?: string | undefined;
|
|
4685
|
-
firstName?: string | undefined;
|
|
4686
|
-
lastName?: string | undefined;
|
|
4687
|
-
picture?: string | undefined;
|
|
4688
|
-
id: string;
|
|
4689
|
-
version: number;
|
|
4690
|
-
createdAt: string;
|
|
4691
|
-
updatedAt: string;
|
|
4692
|
-
realm: string;
|
|
4693
|
-
roles: string[];
|
|
4694
|
-
enabled: boolean;
|
|
4695
|
-
emailVerified: boolean;
|
|
4696
|
-
} | {
|
|
4697
|
-
sub: string;
|
|
4698
|
-
email?: string;
|
|
4699
|
-
name?: string;
|
|
4700
|
-
given_name?: string;
|
|
4701
|
-
family_name?: string;
|
|
4702
|
-
middle_name?: string;
|
|
4703
|
-
nickname?: string;
|
|
4704
|
-
preferred_username?: string;
|
|
4705
|
-
profile?: string;
|
|
4706
|
-
picture?: string;
|
|
4707
|
-
website?: string;
|
|
4708
|
-
email_verified?: boolean;
|
|
4709
|
-
gender?: string;
|
|
4710
|
-
birthdate?: string;
|
|
4711
|
-
zoneinfo?: string;
|
|
4712
|
-
locale?: string;
|
|
4713
|
-
phone_number?: string;
|
|
4714
|
-
phone_number_verified?: boolean;
|
|
4715
|
-
address?: {
|
|
4716
|
-
formatted?: string;
|
|
4717
|
-
street_address?: string;
|
|
4718
|
-
locality?: string;
|
|
4719
|
-
region?: string;
|
|
4720
|
-
postal_code?: string;
|
|
4721
|
-
country?: string;
|
|
4722
|
-
};
|
|
4723
|
-
updated_at?: number;
|
|
4724
|
-
id: string;
|
|
4725
|
-
}>;
|
|
4726
|
-
}
|
|
4727
|
-
//#endregion
|
|
4728
|
-
//#region src/api-users/index.d.ts
|
|
4729
|
-
/**
|
|
4730
|
-
* Provides user management API endpoints for Alepha applications.
|
|
4731
|
-
*
|
|
4732
|
-
* This module includes user CRUD operations, authentication endpoints,
|
|
4733
|
-
* password reset functionality, and user profile management capabilities.
|
|
4734
|
-
*
|
|
4735
|
-
* @module alepha.api.users
|
|
4736
|
-
*/
|
|
4737
|
-
declare const AlephaApiUsers: alepha1.Service<alepha1.Module>;
|
|
4738
|
-
//#endregion
|
|
4739
|
-
export { $userRealm, AlephaApiUsers, CompletePasswordResetRequest, CompleteRegistrationRequest, CreateUser, CredentialService, DEFAULT_USER_REALM_NAME, IdentityController, IdentityEntity, IdentityQuery, IdentityResource, IdentityService, LoginInput, PasswordResetIntentResponse, RealmAuthSettings, RegisterInput, RegistrationIntentResponse, RegistrationService, ResetPasswordInput, ResetPasswordRequest, SessionController, SessionCrudService, SessionEntity, SessionQuery, SessionResource, SessionService, UpdateUser, UserController, UserEntity, UserQuery, UserRealm, UserRealmConfig, UserRealmController, UserRealmDescriptor, UserRealmOptions, UserRealmProvider, UserRealmRepositories, UserResource, UserService, completePasswordResetRequestSchema, completeRegistrationRequestSchema, createUserSchema, identities, identityQuerySchema, identityResourceSchema, loginSchema, passwordResetIntentResponseSchema, realmAuthSettingsAtom, registerSchema, registrationIntentResponseSchema, resetPasswordRequestSchema, resetPasswordSchema, sessionQuerySchema, sessionResourceSchema, sessions, updateUserSchema, userQuerySchema, userRealmConfigSchema, userResourceSchema, users };
|
|
4740
|
-
//# sourceMappingURL=index.d.cts.map
|