alepha 0.13.6 → 0.13.7
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-audits/index.browser.js +116 -0
- package/dist/api-audits/index.browser.js.map +1 -0
- package/dist/api-audits/index.d.ts +1194 -0
- package/dist/api-audits/index.js +674 -0
- package/dist/api-audits/index.js.map +1 -0
- package/dist/api-notifications/index.d.ts +147 -147
- package/dist/api-parameters/index.browser.js +36 -5
- package/dist/api-parameters/index.browser.js.map +1 -1
- package/dist/api-parameters/index.d.ts +711 -33
- package/dist/api-parameters/index.js +831 -17
- package/dist/api-parameters/index.js.map +1 -1
- package/dist/api-users/index.d.ts +793 -780
- package/dist/api-users/index.js +699 -19
- package/dist/api-users/index.js.map +1 -1
- package/dist/api-verifications/index.js +2 -1
- package/dist/api-verifications/index.js.map +1 -1
- package/dist/bin/index.js +1 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/cli/index.d.ts +85 -31
- package/dist/cli/index.js +205 -33
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +67 -6
- package/dist/command/index.js +30 -3
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +241 -61
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +170 -90
- package/dist/core/index.js +264 -67
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +248 -65
- package/dist/core/index.native.js.map +1 -1
- package/dist/email/index.js +15 -10554
- package/dist/email/index.js.map +1 -1
- package/dist/logger/index.d.ts +4 -4
- package/dist/logger/index.js +77 -72
- package/dist/logger/index.js.map +1 -1
- package/dist/orm/index.d.ts +5 -1
- package/dist/orm/index.js +24 -7
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/server/index.d.ts +10 -1
- package/dist/server/index.js +20 -6
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.d.ts +163 -152
- package/dist/server-auth/index.js +40 -10
- package/dist/server-auth/index.js.map +1 -1
- package/dist/server-cookies/index.js +5 -1
- package/dist/server-cookies/index.js.map +1 -1
- package/dist/server-links/index.d.ts +33 -33
- package/dist/server-security/index.d.ts +9 -9
- package/dist/thread/index.js +2 -2
- package/dist/thread/index.js.map +1 -1
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +102 -45
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.browser.js +3 -3
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.js +4 -4
- package/dist/websocket/index.js.map +1 -1
- package/package.json +14 -9
- package/src/api-audits/controllers/AuditController.ts +186 -0
- package/src/api-audits/entities/audits.ts +132 -0
- package/src/api-audits/index.browser.ts +18 -0
- package/src/api-audits/index.ts +58 -0
- package/src/api-audits/primitives/$audit.ts +159 -0
- package/src/api-audits/schemas/auditQuerySchema.ts +23 -0
- package/src/api-audits/schemas/auditResourceSchema.ts +9 -0
- package/src/api-audits/schemas/createAuditSchema.ts +27 -0
- package/src/api-audits/services/AuditService.ts +412 -0
- package/src/api-parameters/controllers/ConfigController.ts +324 -0
- package/src/api-parameters/entities/parameters.ts +93 -10
- package/src/api-parameters/index.ts +43 -4
- package/src/api-parameters/primitives/$config.ts +291 -19
- package/src/api-parameters/schedulers/ConfigActivationScheduler.ts +30 -0
- package/src/api-parameters/services/ConfigStore.ts +491 -0
- package/src/api-users/atoms/realmAuthSettingsAtom.ts +19 -0
- package/src/api-users/controllers/UserRealmController.ts +0 -2
- package/src/api-users/index.ts +2 -0
- package/src/api-users/primitives/$userRealm.ts +18 -3
- package/src/api-users/providers/UserRealmProvider.ts +6 -3
- package/src/api-users/services/RegistrationService.ts +2 -1
- package/src/api-users/services/SessionService.ts +4 -0
- package/src/api-users/services/UserService.ts +3 -0
- package/src/api-verifications/index.ts +7 -1
- package/src/bin/index.ts +1 -0
- package/src/cli/assets/biomeJson.ts +1 -1
- package/src/cli/assets/dummySpecTs.ts +7 -0
- package/src/cli/assets/editorconfig.ts +13 -0
- package/src/cli/assets/mainTs.ts +14 -0
- package/src/cli/commands/BiomeCommands.ts +2 -0
- package/src/cli/commands/CoreCommands.ts +28 -9
- package/src/cli/commands/VerifyCommands.ts +2 -1
- package/src/cli/commands/ViteCommands.ts +8 -9
- package/src/cli/services/AlephaCliUtils.ts +214 -23
- package/src/command/helpers/Asker.ts +0 -1
- package/src/command/primitives/$command.ts +67 -0
- package/src/command/providers/CliProvider.ts +39 -8
- package/src/core/Alepha.ts +40 -30
- package/src/core/helpers/jsonSchemaToTypeBox.ts +307 -0
- package/src/core/index.shared.ts +1 -0
- package/src/core/index.ts +30 -3
- package/src/core/providers/EventManager.ts +1 -1
- package/src/core/providers/StateManager.ts +23 -12
- package/src/core/providers/TypeProvider.ts +26 -34
- package/src/logger/index.ts +8 -6
- package/src/logger/primitives/$logger.ts +1 -1
- package/src/logger/providers/{SimpleFormatterProvider.ts → PrettyFormatterProvider.ts} +10 -1
- package/src/orm/index.ts +6 -0
- package/src/orm/services/PgRelationManager.ts +2 -2
- package/src/orm/services/PostgresModelBuilder.ts +11 -7
- package/src/orm/services/Repository.ts +16 -7
- package/src/orm/services/SqliteModelBuilder.ts +10 -0
- package/src/server/index.ts +6 -0
- package/src/server/primitives/$action.ts +10 -1
- package/src/server/providers/ServerBodyParserProvider.ts +11 -5
- package/src/server/providers/ServerRouterProvider.ts +13 -7
- package/src/server-auth/primitives/$auth.ts +7 -0
- package/src/server-auth/providers/ServerAuthProvider.ts +51 -8
- package/src/server-cookies/index.ts +2 -1
- package/src/thread/primitives/$thread.ts +2 -2
- package/src/vite/index.ts +0 -2
- package/src/vite/tasks/buildServer.ts +3 -4
- package/src/vite/tasks/generateCloudflare.ts +35 -19
- package/src/vite/tasks/generateDocker.ts +18 -4
- package/src/vite/tasks/generateSitemap.ts +5 -7
- package/src/vite/tasks/generateVercel.ts +76 -41
- package/src/vite/tasks/runAlepha.ts +16 -1
- package/src/websocket/providers/NodeWebSocketServerProvider.ts +3 -11
- package/src/websocket/services/WebSocketClient.ts +3 -3
- package/dist/cli/dist-BlfFtOk2.js +0 -2770
- package/dist/cli/dist-BlfFtOk2.js.map +0 -1
- package/src/api-parameters/controllers/ParameterController.ts +0 -45
- package/src/api-parameters/services/ParameterStore.ts +0 -23
|
@@ -0,0 +1,1194 @@
|
|
|
1
|
+
import * as alepha349 from "alepha";
|
|
2
|
+
import { Alepha, KIND, Primitive, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha";
|
|
3
|
+
import * as alepha_orm71 from "alepha/orm";
|
|
4
|
+
import { Page } from "alepha/orm";
|
|
5
|
+
import * as alepha_server0 from "alepha/server";
|
|
6
|
+
import { ServerRequest } from "alepha/server";
|
|
7
|
+
import * as alepha_logger0 from "alepha/logger";
|
|
8
|
+
import { BuildExtraConfigColumns, SQL } from "drizzle-orm";
|
|
9
|
+
import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core";
|
|
10
|
+
import "alepha/datetime";
|
|
11
|
+
import "alepha/retry";
|
|
12
|
+
import "alepha/lock";
|
|
13
|
+
import "drizzle-orm/postgres-js";
|
|
14
|
+
import "postgres";
|
|
15
|
+
import "drizzle-orm/sqlite-core";
|
|
16
|
+
|
|
17
|
+
//#region ../../src/api-audits/entities/audits.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Audit severity levels for categorizing events.
|
|
20
|
+
*/
|
|
21
|
+
declare const auditSeveritySchema: alepha349.TUnsafe<"info" | "warning" | "critical">;
|
|
22
|
+
type AuditSeverity = Static<typeof auditSeveritySchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Audit log entity for tracking important system events.
|
|
25
|
+
*
|
|
26
|
+
* Stores comprehensive audit information including:
|
|
27
|
+
* - Who performed the action (userId, userRealm)
|
|
28
|
+
* - What happened (type, action, resource)
|
|
29
|
+
* - When it happened (createdAt)
|
|
30
|
+
* - Context and details (metadata, ipAddress, userAgent)
|
|
31
|
+
*/
|
|
32
|
+
declare const audits: alepha_orm71.EntityPrimitive<alepha349.TObject<{
|
|
33
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
34
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
35
|
+
/**
|
|
36
|
+
* Audit event type (e.g., "auth", "user", "payment", "system").
|
|
37
|
+
* Used for categorizing and filtering audit events.
|
|
38
|
+
*/
|
|
39
|
+
type: alepha349.TString;
|
|
40
|
+
/**
|
|
41
|
+
* Specific action performed (e.g., "login", "logout", "create", "update", "delete").
|
|
42
|
+
*/
|
|
43
|
+
action: alepha349.TString;
|
|
44
|
+
/**
|
|
45
|
+
* Severity level of the event.
|
|
46
|
+
*/
|
|
47
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
48
|
+
/**
|
|
49
|
+
* User ID who performed the action (null for system events).
|
|
50
|
+
*/
|
|
51
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
52
|
+
/**
|
|
53
|
+
* User realm for multi-tenant support.
|
|
54
|
+
*/
|
|
55
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
56
|
+
/**
|
|
57
|
+
* User email at the time of the event (denormalized for history).
|
|
58
|
+
*/
|
|
59
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
60
|
+
/**
|
|
61
|
+
* Resource type affected (e.g., "user", "order", "file").
|
|
62
|
+
*/
|
|
63
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
64
|
+
/**
|
|
65
|
+
* Resource ID affected.
|
|
66
|
+
*/
|
|
67
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
68
|
+
/**
|
|
69
|
+
* Human-readable description of the event.
|
|
70
|
+
*/
|
|
71
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
72
|
+
/**
|
|
73
|
+
* Additional metadata/context as JSON.
|
|
74
|
+
*/
|
|
75
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
76
|
+
/**
|
|
77
|
+
* Client IP address.
|
|
78
|
+
*/
|
|
79
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
80
|
+
/**
|
|
81
|
+
* Client user agent.
|
|
82
|
+
*/
|
|
83
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
84
|
+
/**
|
|
85
|
+
* Session ID if applicable.
|
|
86
|
+
*/
|
|
87
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
88
|
+
/**
|
|
89
|
+
* Request ID for correlation.
|
|
90
|
+
*/
|
|
91
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the action was successful.
|
|
94
|
+
*/
|
|
95
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
96
|
+
/**
|
|
97
|
+
* Error message if the action failed.
|
|
98
|
+
*/
|
|
99
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
100
|
+
}>>;
|
|
101
|
+
declare const auditEntitySchema: alepha349.TObject<{
|
|
102
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
103
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
104
|
+
/**
|
|
105
|
+
* Audit event type (e.g., "auth", "user", "payment", "system").
|
|
106
|
+
* Used for categorizing and filtering audit events.
|
|
107
|
+
*/
|
|
108
|
+
type: alepha349.TString;
|
|
109
|
+
/**
|
|
110
|
+
* Specific action performed (e.g., "login", "logout", "create", "update", "delete").
|
|
111
|
+
*/
|
|
112
|
+
action: alepha349.TString;
|
|
113
|
+
/**
|
|
114
|
+
* Severity level of the event.
|
|
115
|
+
*/
|
|
116
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
117
|
+
/**
|
|
118
|
+
* User ID who performed the action (null for system events).
|
|
119
|
+
*/
|
|
120
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
121
|
+
/**
|
|
122
|
+
* User realm for multi-tenant support.
|
|
123
|
+
*/
|
|
124
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
125
|
+
/**
|
|
126
|
+
* User email at the time of the event (denormalized for history).
|
|
127
|
+
*/
|
|
128
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
129
|
+
/**
|
|
130
|
+
* Resource type affected (e.g., "user", "order", "file").
|
|
131
|
+
*/
|
|
132
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
133
|
+
/**
|
|
134
|
+
* Resource ID affected.
|
|
135
|
+
*/
|
|
136
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
137
|
+
/**
|
|
138
|
+
* Human-readable description of the event.
|
|
139
|
+
*/
|
|
140
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
141
|
+
/**
|
|
142
|
+
* Additional metadata/context as JSON.
|
|
143
|
+
*/
|
|
144
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
145
|
+
/**
|
|
146
|
+
* Client IP address.
|
|
147
|
+
*/
|
|
148
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
149
|
+
/**
|
|
150
|
+
* Client user agent.
|
|
151
|
+
*/
|
|
152
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
153
|
+
/**
|
|
154
|
+
* Session ID if applicable.
|
|
155
|
+
*/
|
|
156
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
157
|
+
/**
|
|
158
|
+
* Request ID for correlation.
|
|
159
|
+
*/
|
|
160
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
161
|
+
/**
|
|
162
|
+
* Whether the action was successful.
|
|
163
|
+
*/
|
|
164
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
165
|
+
/**
|
|
166
|
+
* Error message if the action failed.
|
|
167
|
+
*/
|
|
168
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
169
|
+
}>;
|
|
170
|
+
declare const auditEntityInsertSchema: alepha_orm71.TObjectInsert<alepha349.TObject<{
|
|
171
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
172
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
173
|
+
/**
|
|
174
|
+
* Audit event type (e.g., "auth", "user", "payment", "system").
|
|
175
|
+
* Used for categorizing and filtering audit events.
|
|
176
|
+
*/
|
|
177
|
+
type: alepha349.TString;
|
|
178
|
+
/**
|
|
179
|
+
* Specific action performed (e.g., "login", "logout", "create", "update", "delete").
|
|
180
|
+
*/
|
|
181
|
+
action: alepha349.TString;
|
|
182
|
+
/**
|
|
183
|
+
* Severity level of the event.
|
|
184
|
+
*/
|
|
185
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
186
|
+
/**
|
|
187
|
+
* User ID who performed the action (null for system events).
|
|
188
|
+
*/
|
|
189
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
190
|
+
/**
|
|
191
|
+
* User realm for multi-tenant support.
|
|
192
|
+
*/
|
|
193
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
194
|
+
/**
|
|
195
|
+
* User email at the time of the event (denormalized for history).
|
|
196
|
+
*/
|
|
197
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
198
|
+
/**
|
|
199
|
+
* Resource type affected (e.g., "user", "order", "file").
|
|
200
|
+
*/
|
|
201
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
202
|
+
/**
|
|
203
|
+
* Resource ID affected.
|
|
204
|
+
*/
|
|
205
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
206
|
+
/**
|
|
207
|
+
* Human-readable description of the event.
|
|
208
|
+
*/
|
|
209
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
210
|
+
/**
|
|
211
|
+
* Additional metadata/context as JSON.
|
|
212
|
+
*/
|
|
213
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
214
|
+
/**
|
|
215
|
+
* Client IP address.
|
|
216
|
+
*/
|
|
217
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
218
|
+
/**
|
|
219
|
+
* Client user agent.
|
|
220
|
+
*/
|
|
221
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
222
|
+
/**
|
|
223
|
+
* Session ID if applicable.
|
|
224
|
+
*/
|
|
225
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
226
|
+
/**
|
|
227
|
+
* Request ID for correlation.
|
|
228
|
+
*/
|
|
229
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
230
|
+
/**
|
|
231
|
+
* Whether the action was successful.
|
|
232
|
+
*/
|
|
233
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
234
|
+
/**
|
|
235
|
+
* Error message if the action failed.
|
|
236
|
+
*/
|
|
237
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
238
|
+
}>>;
|
|
239
|
+
type AuditEntity = Static<typeof audits.schema>;
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region ../../src/api-audits/schemas/auditQuerySchema.d.ts
|
|
242
|
+
/**
|
|
243
|
+
* Query schema for searching and filtering audit logs.
|
|
244
|
+
*/
|
|
245
|
+
declare const auditQuerySchema: alepha349.TObject<{
|
|
246
|
+
page: alepha349.TOptional<alepha349.TInteger>;
|
|
247
|
+
size: alepha349.TOptional<alepha349.TInteger>;
|
|
248
|
+
sort: alepha349.TOptional<alepha349.TString>;
|
|
249
|
+
type: alepha349.TOptional<alepha349.TString>;
|
|
250
|
+
action: alepha349.TOptional<alepha349.TString>;
|
|
251
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
252
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
253
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
254
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
255
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
256
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
257
|
+
from: alepha349.TOptional<alepha349.TString>;
|
|
258
|
+
to: alepha349.TOptional<alepha349.TString>;
|
|
259
|
+
search: alepha349.TOptional<alepha349.TString>;
|
|
260
|
+
}>;
|
|
261
|
+
type AuditQuery = Static<typeof auditQuerySchema>;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region ../../src/api-audits/schemas/createAuditSchema.d.ts
|
|
264
|
+
/**
|
|
265
|
+
* Schema for creating a new audit log entry.
|
|
266
|
+
*/
|
|
267
|
+
declare const createAuditSchema: alepha349.TObject<{
|
|
268
|
+
type: alepha349.TString;
|
|
269
|
+
action: alepha349.TString;
|
|
270
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
271
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
272
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
273
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
274
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
275
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
276
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
277
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
278
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
279
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
280
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
281
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
282
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
283
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
284
|
+
}>;
|
|
285
|
+
type CreateAudit = Static<typeof createAuditSchema>;
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region ../../src/api-audits/services/AuditService.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* Registered audit type definition.
|
|
290
|
+
*/
|
|
291
|
+
interface AuditTypeDefinition {
|
|
292
|
+
type: string;
|
|
293
|
+
description?: string;
|
|
294
|
+
actions: string[];
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Service for managing audit logs.
|
|
298
|
+
*
|
|
299
|
+
* Provides methods for:
|
|
300
|
+
* - Creating audit entries
|
|
301
|
+
* - Querying audit history
|
|
302
|
+
* - Aggregating audit statistics
|
|
303
|
+
* - Managing registered audit types
|
|
304
|
+
*/
|
|
305
|
+
declare class AuditService {
|
|
306
|
+
protected readonly alepha: Alepha;
|
|
307
|
+
protected readonly log: alepha_logger0.Logger;
|
|
308
|
+
protected readonly repo: alepha_orm71.Repository<alepha349.TObject<{
|
|
309
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
310
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
311
|
+
type: alepha349.TString;
|
|
312
|
+
action: alepha349.TString;
|
|
313
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
314
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
315
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
316
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
317
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
318
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
319
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
320
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
321
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
322
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
323
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
324
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
325
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
326
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
327
|
+
}>>;
|
|
328
|
+
/**
|
|
329
|
+
* Registry of audit types and their allowed actions.
|
|
330
|
+
*/
|
|
331
|
+
protected readonly auditTypes: Map<string, AuditTypeDefinition>;
|
|
332
|
+
/**
|
|
333
|
+
* Register an audit type with its allowed actions.
|
|
334
|
+
*/
|
|
335
|
+
registerType(definition: AuditTypeDefinition): void;
|
|
336
|
+
/**
|
|
337
|
+
* Get all registered audit types.
|
|
338
|
+
*/
|
|
339
|
+
getRegisteredTypes(): AuditTypeDefinition[];
|
|
340
|
+
/**
|
|
341
|
+
* Get current request context if available.
|
|
342
|
+
*/
|
|
343
|
+
protected getRequestContext(): ServerRequest | undefined;
|
|
344
|
+
/**
|
|
345
|
+
* Create a new audit log entry.
|
|
346
|
+
* Automatically populates ipAddress, userAgent, and requestId from the current request context.
|
|
347
|
+
*/
|
|
348
|
+
create(data: CreateAudit): Promise<AuditEntity>;
|
|
349
|
+
/**
|
|
350
|
+
* Record an audit event (convenience method).
|
|
351
|
+
*/
|
|
352
|
+
record(type: string, action: string, options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
353
|
+
/**
|
|
354
|
+
* Record an authentication event.
|
|
355
|
+
*/
|
|
356
|
+
recordAuth(action: "login" | "logout" | "login_failed" | "token_refresh" | "mfa_setup" | "mfa_verify", options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
357
|
+
/**
|
|
358
|
+
* Record a user management event.
|
|
359
|
+
*/
|
|
360
|
+
recordUser(action: "create" | "update" | "delete" | "enable" | "disable" | "role_change", options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
361
|
+
/**
|
|
362
|
+
* Record a data access event.
|
|
363
|
+
*/
|
|
364
|
+
recordAccess(action: "view" | "export" | "download", options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
365
|
+
/**
|
|
366
|
+
* Record a security event.
|
|
367
|
+
*/
|
|
368
|
+
recordSecurity(action: "permission_denied" | "suspicious_activity" | "rate_limited" | "blocked", options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
369
|
+
/**
|
|
370
|
+
* Record a system event.
|
|
371
|
+
*/
|
|
372
|
+
recordSystem(action: "startup" | "shutdown" | "config_change" | "maintenance" | "error", options?: Omit<CreateAudit, "type" | "action">): Promise<AuditEntity>;
|
|
373
|
+
/**
|
|
374
|
+
* Find audit entries with filtering and pagination.
|
|
375
|
+
*/
|
|
376
|
+
find(query?: AuditQuery): Promise<Page<AuditEntity>>;
|
|
377
|
+
/**
|
|
378
|
+
* Get audit entry by ID.
|
|
379
|
+
*/
|
|
380
|
+
getById(id: string): Promise<AuditEntity>;
|
|
381
|
+
/**
|
|
382
|
+
* Get audit entries for a specific user.
|
|
383
|
+
*/
|
|
384
|
+
findByUser(userId: string, query?: Omit<AuditQuery, "userId">): Promise<Page<AuditEntity>>;
|
|
385
|
+
/**
|
|
386
|
+
* Get audit entries for a specific resource.
|
|
387
|
+
*/
|
|
388
|
+
findByResource(resourceType: string, resourceId: string, query?: Omit<AuditQuery, "resourceType" | "resourceId">): Promise<Page<AuditEntity>>;
|
|
389
|
+
/**
|
|
390
|
+
* Get audit statistics for a time period.
|
|
391
|
+
*/
|
|
392
|
+
getStats(options?: {
|
|
393
|
+
from?: Date;
|
|
394
|
+
to?: Date;
|
|
395
|
+
userRealm?: string;
|
|
396
|
+
}): Promise<AuditStats>;
|
|
397
|
+
/**
|
|
398
|
+
* Delete old audit entries (for retention policy).
|
|
399
|
+
*/
|
|
400
|
+
deleteOlderThan(date: Date): Promise<number>;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Audit statistics summary.
|
|
404
|
+
*/
|
|
405
|
+
interface AuditStats {
|
|
406
|
+
total: number;
|
|
407
|
+
byType: Record<string, number>;
|
|
408
|
+
bySeverity: Record<AuditSeverity, number>;
|
|
409
|
+
successRate: number;
|
|
410
|
+
recentFailures: AuditEntity[];
|
|
411
|
+
}
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region ../../src/api-audits/controllers/AuditController.d.ts
|
|
414
|
+
/**
|
|
415
|
+
* REST API controller for audit log management.
|
|
416
|
+
*
|
|
417
|
+
* Provides endpoints for:
|
|
418
|
+
* - Querying audit logs with filtering
|
|
419
|
+
* - Creating audit entries
|
|
420
|
+
* - Getting audit statistics
|
|
421
|
+
* - Viewing registered audit types
|
|
422
|
+
*/
|
|
423
|
+
declare class AuditController {
|
|
424
|
+
protected readonly url = "/audits";
|
|
425
|
+
protected readonly group = "audits";
|
|
426
|
+
protected readonly auditService: AuditService;
|
|
427
|
+
/**
|
|
428
|
+
* Find audit entries with filtering and pagination.
|
|
429
|
+
*/
|
|
430
|
+
readonly findAudits: alepha_server0.ActionPrimitiveFn<{
|
|
431
|
+
query: alepha349.TObject<{
|
|
432
|
+
page: alepha349.TOptional<alepha349.TInteger>;
|
|
433
|
+
size: alepha349.TOptional<alepha349.TInteger>;
|
|
434
|
+
sort: alepha349.TOptional<alepha349.TString>;
|
|
435
|
+
type: alepha349.TOptional<alepha349.TString>;
|
|
436
|
+
action: alepha349.TOptional<alepha349.TString>;
|
|
437
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
438
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
439
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
440
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
441
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
442
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
443
|
+
from: alepha349.TOptional<alepha349.TString>;
|
|
444
|
+
to: alepha349.TOptional<alepha349.TString>;
|
|
445
|
+
search: alepha349.TOptional<alepha349.TString>;
|
|
446
|
+
}>;
|
|
447
|
+
response: alepha349.TPage<alepha349.TObject<{
|
|
448
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
449
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
450
|
+
type: alepha349.TString;
|
|
451
|
+
action: alepha349.TString;
|
|
452
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
453
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
454
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
455
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
456
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
457
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
458
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
459
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
460
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
461
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
462
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
463
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
464
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
465
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
466
|
+
}>>;
|
|
467
|
+
}>;
|
|
468
|
+
/**
|
|
469
|
+
* Get a single audit entry by ID.
|
|
470
|
+
*/
|
|
471
|
+
readonly getAudit: alepha_server0.ActionPrimitiveFn<{
|
|
472
|
+
params: alepha349.TObject<{
|
|
473
|
+
id: alepha349.TString;
|
|
474
|
+
}>;
|
|
475
|
+
response: alepha349.TObject<{
|
|
476
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
477
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
478
|
+
type: alepha349.TString;
|
|
479
|
+
action: alepha349.TString;
|
|
480
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
481
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
482
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
483
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
484
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
485
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
486
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
487
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
488
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
489
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
490
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
491
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
492
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
493
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
494
|
+
}>;
|
|
495
|
+
}>;
|
|
496
|
+
/**
|
|
497
|
+
* Create a new audit entry.
|
|
498
|
+
*/
|
|
499
|
+
readonly createAudit: alepha_server0.ActionPrimitiveFn<{
|
|
500
|
+
body: alepha349.TObject<{
|
|
501
|
+
type: alepha349.TString;
|
|
502
|
+
action: alepha349.TString;
|
|
503
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
504
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
505
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
506
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
507
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
508
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
509
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
510
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
511
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
512
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
513
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
514
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
515
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
516
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
517
|
+
}>;
|
|
518
|
+
response: alepha349.TObject<{
|
|
519
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
520
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
521
|
+
type: alepha349.TString;
|
|
522
|
+
action: alepha349.TString;
|
|
523
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
524
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
525
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
526
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
527
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
528
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
529
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
530
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
531
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
532
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
533
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
534
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
535
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
536
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
537
|
+
}>;
|
|
538
|
+
}>;
|
|
539
|
+
/**
|
|
540
|
+
* Get audit entries for a specific user.
|
|
541
|
+
*/
|
|
542
|
+
readonly findByUser: alepha_server0.ActionPrimitiveFn<{
|
|
543
|
+
params: alepha349.TObject<{
|
|
544
|
+
userId: alepha349.TString;
|
|
545
|
+
}>;
|
|
546
|
+
query: alepha349.TObject<{
|
|
547
|
+
page: alepha349.TOptional<alepha349.TInteger>;
|
|
548
|
+
type: alepha349.TOptional<alepha349.TString>;
|
|
549
|
+
size: alepha349.TOptional<alepha349.TInteger>;
|
|
550
|
+
sort: alepha349.TOptional<alepha349.TString>;
|
|
551
|
+
action: alepha349.TOptional<alepha349.TString>;
|
|
552
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
553
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
554
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
555
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
556
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
557
|
+
from: alepha349.TOptional<alepha349.TString>;
|
|
558
|
+
to: alepha349.TOptional<alepha349.TString>;
|
|
559
|
+
search: alepha349.TOptional<alepha349.TString>;
|
|
560
|
+
}>;
|
|
561
|
+
response: alepha349.TPage<alepha349.TObject<{
|
|
562
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
563
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
564
|
+
type: alepha349.TString;
|
|
565
|
+
action: alepha349.TString;
|
|
566
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
567
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
568
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
569
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
570
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
571
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
572
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
573
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
574
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
575
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
576
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
577
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
578
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
579
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
580
|
+
}>>;
|
|
581
|
+
}>;
|
|
582
|
+
/**
|
|
583
|
+
* Get audit entries for a specific resource.
|
|
584
|
+
*/
|
|
585
|
+
readonly findByResource: alepha_server0.ActionPrimitiveFn<{
|
|
586
|
+
params: alepha349.TObject<{
|
|
587
|
+
resourceType: alepha349.TString;
|
|
588
|
+
resourceId: alepha349.TString;
|
|
589
|
+
}>;
|
|
590
|
+
query: alepha349.TObject<{
|
|
591
|
+
page: alepha349.TOptional<alepha349.TInteger>;
|
|
592
|
+
type: alepha349.TOptional<alepha349.TString>;
|
|
593
|
+
size: alepha349.TOptional<alepha349.TInteger>;
|
|
594
|
+
sort: alepha349.TOptional<alepha349.TString>;
|
|
595
|
+
action: alepha349.TOptional<alepha349.TString>;
|
|
596
|
+
severity: alepha349.TOptional<alepha349.TUnsafe<"info" | "warning" | "critical">>;
|
|
597
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
598
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
599
|
+
success: alepha349.TOptional<alepha349.TBoolean>;
|
|
600
|
+
from: alepha349.TOptional<alepha349.TString>;
|
|
601
|
+
to: alepha349.TOptional<alepha349.TString>;
|
|
602
|
+
search: alepha349.TOptional<alepha349.TString>;
|
|
603
|
+
}>;
|
|
604
|
+
response: alepha349.TPage<alepha349.TObject<{
|
|
605
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
606
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
607
|
+
type: alepha349.TString;
|
|
608
|
+
action: alepha349.TString;
|
|
609
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
610
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
611
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
612
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
613
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
614
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
615
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
616
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
617
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
618
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
619
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
620
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
621
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
622
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
623
|
+
}>>;
|
|
624
|
+
}>;
|
|
625
|
+
/**
|
|
626
|
+
* Get audit statistics.
|
|
627
|
+
*/
|
|
628
|
+
readonly getStats: alepha_server0.ActionPrimitiveFn<{
|
|
629
|
+
query: alepha349.TObject<{
|
|
630
|
+
from: alepha349.TOptional<alepha349.TString>;
|
|
631
|
+
to: alepha349.TOptional<alepha349.TString>;
|
|
632
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
633
|
+
}>;
|
|
634
|
+
response: alepha349.TObject<{
|
|
635
|
+
total: alepha349.TInteger;
|
|
636
|
+
byType: alepha349.TRecord<"^.*$", alepha349.TInteger>;
|
|
637
|
+
bySeverity: alepha349.TObject<{
|
|
638
|
+
info: alepha349.TInteger;
|
|
639
|
+
warning: alepha349.TInteger;
|
|
640
|
+
critical: alepha349.TInteger;
|
|
641
|
+
}>;
|
|
642
|
+
successRate: alepha349.TNumber;
|
|
643
|
+
recentFailures: alepha349.TArray<alepha349.TObject<{
|
|
644
|
+
id: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_PRIMARY_KEY>, typeof alepha_orm71.PG_DEFAULT>;
|
|
645
|
+
createdAt: alepha_orm71.PgAttr<alepha_orm71.PgAttr<alepha349.TString, typeof alepha_orm71.PG_CREATED_AT>, typeof alepha_orm71.PG_DEFAULT>;
|
|
646
|
+
type: alepha349.TString;
|
|
647
|
+
action: alepha349.TString;
|
|
648
|
+
severity: alepha_orm71.PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof alepha_orm71.PG_DEFAULT>;
|
|
649
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
650
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
651
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
652
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
653
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
654
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
655
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
656
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
657
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
658
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
659
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
660
|
+
success: alepha_orm71.PgAttr<alepha349.TBoolean, typeof alepha_orm71.PG_DEFAULT>;
|
|
661
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
662
|
+
}>>;
|
|
663
|
+
}>;
|
|
664
|
+
}>;
|
|
665
|
+
/**
|
|
666
|
+
* Get registered audit types.
|
|
667
|
+
*/
|
|
668
|
+
readonly getTypes: alepha_server0.ActionPrimitiveFn<{
|
|
669
|
+
response: alepha349.TArray<alepha349.TObject<{
|
|
670
|
+
type: alepha349.TString;
|
|
671
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
672
|
+
actions: alepha349.TArray<alepha349.TString>;
|
|
673
|
+
}>>;
|
|
674
|
+
}>;
|
|
675
|
+
/**
|
|
676
|
+
* Get distinct values for filters.
|
|
677
|
+
*/
|
|
678
|
+
readonly getFilterOptions: alepha_server0.ActionPrimitiveFn<{
|
|
679
|
+
response: alepha349.TObject<{
|
|
680
|
+
types: alepha349.TArray<alepha349.TString>;
|
|
681
|
+
actions: alepha349.TArray<alepha349.TString>;
|
|
682
|
+
resourceTypes: alepha349.TArray<alepha349.TString>;
|
|
683
|
+
userRealms: alepha349.TArray<alepha349.TString>;
|
|
684
|
+
}>;
|
|
685
|
+
}>;
|
|
686
|
+
}
|
|
687
|
+
//#endregion
|
|
688
|
+
//#region ../../src/api-audits/primitives/$audit.d.ts
|
|
689
|
+
/**
|
|
690
|
+
* Options for creating an audit type primitive.
|
|
691
|
+
*/
|
|
692
|
+
interface AuditPrimitiveOptions {
|
|
693
|
+
/**
|
|
694
|
+
* Unique audit type identifier (e.g., "auth", "payment", "order").
|
|
695
|
+
*/
|
|
696
|
+
type: string;
|
|
697
|
+
/**
|
|
698
|
+
* Human-readable description of this audit type.
|
|
699
|
+
*/
|
|
700
|
+
description?: string;
|
|
701
|
+
/**
|
|
702
|
+
* List of allowed actions for this audit type.
|
|
703
|
+
*/
|
|
704
|
+
actions: string[];
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Audit type primitive for registering domain-specific audit events.
|
|
708
|
+
*
|
|
709
|
+
* Provides a type-safe way to define and log audit events within a specific domain.
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* ```ts
|
|
713
|
+
* class PaymentAudits {
|
|
714
|
+
* audit = $audit({
|
|
715
|
+
* type: "payment",
|
|
716
|
+
* description: "Payment-related audit events",
|
|
717
|
+
* actions: ["create", "refund", "cancel", "dispute"],
|
|
718
|
+
* });
|
|
719
|
+
*
|
|
720
|
+
* async logPaymentCreated(paymentId: string, userId: string, amount: number) {
|
|
721
|
+
* await this.audit.log("create", {
|
|
722
|
+
* userId,
|
|
723
|
+
* resourceType: "payment",
|
|
724
|
+
* resourceId: paymentId,
|
|
725
|
+
* description: `Payment of ${amount} created`,
|
|
726
|
+
* metadata: { amount },
|
|
727
|
+
* });
|
|
728
|
+
* }
|
|
729
|
+
* }
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
declare class AuditPrimitive extends Primitive<AuditPrimitiveOptions> {
|
|
733
|
+
protected readonly auditService: AuditService;
|
|
734
|
+
/**
|
|
735
|
+
* The audit type identifier.
|
|
736
|
+
*/
|
|
737
|
+
get type(): string;
|
|
738
|
+
/**
|
|
739
|
+
* The audit type description.
|
|
740
|
+
*/
|
|
741
|
+
get description(): string | undefined;
|
|
742
|
+
/**
|
|
743
|
+
* The allowed actions for this audit type.
|
|
744
|
+
*/
|
|
745
|
+
get actions(): string[];
|
|
746
|
+
/**
|
|
747
|
+
* Log an audit event for this type.
|
|
748
|
+
*/
|
|
749
|
+
log(action: string, options?: AuditLogOptions): Promise<void>;
|
|
750
|
+
/**
|
|
751
|
+
* Log a successful audit event.
|
|
752
|
+
*/
|
|
753
|
+
logSuccess(action: string, options?: Omit<AuditLogOptions, "success">): Promise<void>;
|
|
754
|
+
/**
|
|
755
|
+
* Log a failed audit event.
|
|
756
|
+
*/
|
|
757
|
+
logFailure(action: string, errorMessage: string, options?: Omit<AuditLogOptions, "success" | "errorMessage">): Promise<void>;
|
|
758
|
+
/**
|
|
759
|
+
* Called during initialization to register this audit type.
|
|
760
|
+
*/
|
|
761
|
+
protected onInit(): void;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Options for logging an audit event.
|
|
765
|
+
*/
|
|
766
|
+
interface AuditLogOptions {
|
|
767
|
+
severity?: "info" | "warning" | "critical";
|
|
768
|
+
userId?: string;
|
|
769
|
+
userRealm?: string;
|
|
770
|
+
userEmail?: string;
|
|
771
|
+
resourceType?: string;
|
|
772
|
+
resourceId?: string;
|
|
773
|
+
description?: string;
|
|
774
|
+
metadata?: Record<string, unknown>;
|
|
775
|
+
ipAddress?: string;
|
|
776
|
+
userAgent?: string;
|
|
777
|
+
sessionId?: string;
|
|
778
|
+
requestId?: string;
|
|
779
|
+
success?: boolean;
|
|
780
|
+
errorMessage?: string;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Create an audit type primitive.
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```ts
|
|
787
|
+
* class OrderAudits {
|
|
788
|
+
* audit = $audit({
|
|
789
|
+
* type: "order",
|
|
790
|
+
* description: "Order management events",
|
|
791
|
+
* actions: ["create", "update", "cancel", "fulfill", "ship"],
|
|
792
|
+
* });
|
|
793
|
+
* }
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
declare const $audit: {
|
|
797
|
+
(options: AuditPrimitiveOptions): AuditPrimitive;
|
|
798
|
+
[KIND]: typeof AuditPrimitive;
|
|
799
|
+
};
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region ../../src/orm/schemas/insertSchema.d.ts
|
|
802
|
+
/**
|
|
803
|
+
* Transforms a TObject schema for insert operations.
|
|
804
|
+
* All default properties at the root level are made optional.
|
|
805
|
+
*
|
|
806
|
+
* @example
|
|
807
|
+
* Before: { name: string; age: number(default=0); }
|
|
808
|
+
* After: { name: string; age?: number; }
|
|
809
|
+
*/
|
|
810
|
+
type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["properties"]]: T["properties"][K] extends {
|
|
811
|
+
[PG_DEFAULT]: any;
|
|
812
|
+
} | {
|
|
813
|
+
"~optional": true;
|
|
814
|
+
} ? TOptional<T["properties"][K]> : T["properties"][K] }>;
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region ../../src/orm/schemas/updateSchema.d.ts
|
|
817
|
+
/**
|
|
818
|
+
* Transforms a TObject schema for update operations.
|
|
819
|
+
* All optional properties at the root level are made nullable (i.e., `T | null`).
|
|
820
|
+
* This allows an API endpoint to explicitly accept `null` to clear an optional field in the database.
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* Before: { name?: string; age: number; }
|
|
824
|
+
* After: { name?: string | null; age: number; }
|
|
825
|
+
*/
|
|
826
|
+
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] }>;
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region ../../src/orm/primitives/$entity.d.ts
|
|
829
|
+
interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> {
|
|
830
|
+
/**
|
|
831
|
+
* The database table name that will be created for this entity.
|
|
832
|
+
* If not provided, name will be inferred from the $repository variable name.
|
|
833
|
+
*/
|
|
834
|
+
name: string;
|
|
835
|
+
/**
|
|
836
|
+
* TypeBox schema defining the table structure and column types.
|
|
837
|
+
*/
|
|
838
|
+
schema: T;
|
|
839
|
+
/**
|
|
840
|
+
* Database indexes to create for query optimization.
|
|
841
|
+
*/
|
|
842
|
+
indexes?: (Keys | {
|
|
843
|
+
/**
|
|
844
|
+
* Single column to index.
|
|
845
|
+
*/
|
|
846
|
+
column: Keys;
|
|
847
|
+
/**
|
|
848
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
849
|
+
*/
|
|
850
|
+
unique?: boolean;
|
|
851
|
+
/**
|
|
852
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
853
|
+
*/
|
|
854
|
+
name?: string;
|
|
855
|
+
} | {
|
|
856
|
+
/**
|
|
857
|
+
* Multiple columns for composite index (order matters for query optimization).
|
|
858
|
+
*/
|
|
859
|
+
columns: Keys[];
|
|
860
|
+
/**
|
|
861
|
+
* Whether this should be a unique index (enforces uniqueness constraint).
|
|
862
|
+
*/
|
|
863
|
+
unique?: boolean;
|
|
864
|
+
/**
|
|
865
|
+
* Custom name for the index. If not provided, generates name automatically.
|
|
866
|
+
*/
|
|
867
|
+
name?: string;
|
|
868
|
+
})[];
|
|
869
|
+
/**
|
|
870
|
+
* Foreign key constraints to maintain referential integrity.
|
|
871
|
+
*/
|
|
872
|
+
foreignKeys?: Array<{
|
|
873
|
+
/**
|
|
874
|
+
* Optional name for the foreign key constraint.
|
|
875
|
+
*/
|
|
876
|
+
name?: string;
|
|
877
|
+
/**
|
|
878
|
+
* Local columns that reference the foreign table.
|
|
879
|
+
*/
|
|
880
|
+
columns: Array<keyof Static<T>>;
|
|
881
|
+
/**
|
|
882
|
+
* Referenced columns in the foreign table.
|
|
883
|
+
* Must be EntityColumn references from other entities.
|
|
884
|
+
*/
|
|
885
|
+
foreignColumns: Array<() => EntityColumn<any>>;
|
|
886
|
+
}>;
|
|
887
|
+
/**
|
|
888
|
+
* Additional table constraints for data validation.
|
|
889
|
+
*
|
|
890
|
+
* Constraints enforce business rules at the database level, providing
|
|
891
|
+
* an additional layer of data integrity beyond application validation.
|
|
892
|
+
*
|
|
893
|
+
* **Constraint Types**:
|
|
894
|
+
* - **Unique constraints**: Prevent duplicate values across columns
|
|
895
|
+
* - **Check constraints**: Enforce custom validation rules with SQL expressions
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* ```ts
|
|
899
|
+
* constraints: [
|
|
900
|
+
* {
|
|
901
|
+
* name: "unique_user_email",
|
|
902
|
+
* columns: ["email"],
|
|
903
|
+
* unique: true
|
|
904
|
+
* },
|
|
905
|
+
* {
|
|
906
|
+
* name: "valid_age_range",
|
|
907
|
+
* columns: ["age"],
|
|
908
|
+
* check: sql`age >= 0 AND age <= 150`
|
|
909
|
+
* },
|
|
910
|
+
* {
|
|
911
|
+
* name: "unique_user_username_per_tenant",
|
|
912
|
+
* columns: ["tenantId", "username"],
|
|
913
|
+
* unique: true
|
|
914
|
+
* }
|
|
915
|
+
* ]
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
constraints?: Array<{
|
|
919
|
+
/**
|
|
920
|
+
* Columns involved in this constraint.
|
|
921
|
+
*/
|
|
922
|
+
columns: Array<keyof Static<T>>;
|
|
923
|
+
/**
|
|
924
|
+
* Optional name for the constraint.
|
|
925
|
+
*/
|
|
926
|
+
name?: string;
|
|
927
|
+
/**
|
|
928
|
+
* Whether this is a unique constraint.
|
|
929
|
+
*/
|
|
930
|
+
unique?: boolean | {};
|
|
931
|
+
/**
|
|
932
|
+
* SQL expression for check constraint validation.
|
|
933
|
+
*/
|
|
934
|
+
check?: SQL;
|
|
935
|
+
}>;
|
|
936
|
+
/**
|
|
937
|
+
* Advanced Drizzle ORM configuration for complex table setups.
|
|
938
|
+
*/
|
|
939
|
+
config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[];
|
|
940
|
+
}
|
|
941
|
+
declare class EntityPrimitive<T extends TObject = TObject> {
|
|
942
|
+
readonly options: EntityPrimitiveOptions<T>;
|
|
943
|
+
constructor(options: EntityPrimitiveOptions<T>);
|
|
944
|
+
alias(alias: string): this;
|
|
945
|
+
get cols(): EntityColumns<T>;
|
|
946
|
+
get name(): string;
|
|
947
|
+
get schema(): T;
|
|
948
|
+
get insertSchema(): TObjectInsert<T>;
|
|
949
|
+
get updateSchema(): TObjectUpdate<T>;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Convert a schema to columns.
|
|
953
|
+
*/
|
|
954
|
+
type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase };
|
|
955
|
+
type EntityColumn<T extends TObject> = {
|
|
956
|
+
name: string;
|
|
957
|
+
entity: EntityPrimitive<T>;
|
|
958
|
+
};
|
|
959
|
+
type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T> };
|
|
960
|
+
//#endregion
|
|
961
|
+
//#region ../../src/orm/constants/PG_SYMBOLS.d.ts
|
|
962
|
+
declare const PG_DEFAULT: unique symbol;
|
|
963
|
+
declare const PG_PRIMARY_KEY: unique symbol;
|
|
964
|
+
declare const PG_CREATED_AT: unique symbol;
|
|
965
|
+
declare const PG_UPDATED_AT: unique symbol;
|
|
966
|
+
declare const PG_DELETED_AT: unique symbol;
|
|
967
|
+
declare const PG_VERSION: unique symbol;
|
|
968
|
+
declare const PG_IDENTITY: unique symbol;
|
|
969
|
+
declare const PG_ENUM: unique symbol;
|
|
970
|
+
declare const PG_REF: unique symbol;
|
|
971
|
+
/**
|
|
972
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
973
|
+
*/
|
|
974
|
+
declare const PG_SERIAL: unique symbol;
|
|
975
|
+
type PgSymbols = {
|
|
976
|
+
[PG_DEFAULT]: {};
|
|
977
|
+
[PG_PRIMARY_KEY]: {};
|
|
978
|
+
[PG_CREATED_AT]: {};
|
|
979
|
+
[PG_UPDATED_AT]: {};
|
|
980
|
+
[PG_DELETED_AT]: {};
|
|
981
|
+
[PG_VERSION]: {};
|
|
982
|
+
[PG_IDENTITY]: PgIdentityOptions;
|
|
983
|
+
[PG_REF]: PgRefOptions;
|
|
984
|
+
[PG_ENUM]: PgEnumOptions;
|
|
985
|
+
/**
|
|
986
|
+
* @deprecated Use `PG_IDENTITY` instead.
|
|
987
|
+
*/
|
|
988
|
+
[PG_SERIAL]: {};
|
|
989
|
+
};
|
|
990
|
+
type PgSymbolKeys = keyof PgSymbols;
|
|
991
|
+
type PgIdentityOptions = {
|
|
992
|
+
mode: "always" | "byDefault";
|
|
993
|
+
} & PgSequenceOptions & {
|
|
994
|
+
name?: string;
|
|
995
|
+
};
|
|
996
|
+
interface PgEnumOptions {
|
|
997
|
+
name?: string;
|
|
998
|
+
description?: string;
|
|
999
|
+
}
|
|
1000
|
+
interface PgRefOptions {
|
|
1001
|
+
ref: () => {
|
|
1002
|
+
name: string;
|
|
1003
|
+
entity: EntityPrimitive;
|
|
1004
|
+
};
|
|
1005
|
+
actions?: {
|
|
1006
|
+
onUpdate?: UpdateDeleteAction;
|
|
1007
|
+
onDelete?: UpdateDeleteAction;
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region ../../src/orm/helpers/pgAttr.d.ts
|
|
1012
|
+
/**
|
|
1013
|
+
* Type representation.
|
|
1014
|
+
*/
|
|
1015
|
+
type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region ../../src/orm/providers/drivers/NodePostgresProvider.d.ts
|
|
1018
|
+
declare module "alepha" {
|
|
1019
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1020
|
+
}
|
|
1021
|
+
declare const envSchema: alepha349.TObject<{
|
|
1022
|
+
/**
|
|
1023
|
+
* Main configuration for database connection.
|
|
1024
|
+
* Accept a string in the format of a Postgres connection URL.
|
|
1025
|
+
* Example: postgres://user:password@localhost:5432/database
|
|
1026
|
+
* or
|
|
1027
|
+
* Example: postgres://user:password@localhost:5432/database?sslmode=require
|
|
1028
|
+
*/
|
|
1029
|
+
DATABASE_URL: alepha349.TOptional<alepha349.TString>;
|
|
1030
|
+
/**
|
|
1031
|
+
* In addition to the DATABASE_URL, you can specify the postgres schema name.
|
|
1032
|
+
*
|
|
1033
|
+
* It will monkey patch drizzle tables.
|
|
1034
|
+
*/
|
|
1035
|
+
POSTGRES_SCHEMA: alepha349.TOptional<alepha349.TString>;
|
|
1036
|
+
}>;
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region ../../src/orm/providers/drivers/NodeSqliteProvider.d.ts
|
|
1039
|
+
/**
|
|
1040
|
+
* Configuration options for the Node.js SQLite database provider.
|
|
1041
|
+
*/
|
|
1042
|
+
declare const nodeSqliteOptions: alepha349.Atom<alepha349.TObject<{
|
|
1043
|
+
path: alepha349.TOptional<alepha349.TString>;
|
|
1044
|
+
}>, "alepha.postgres.node-sqlite.options">;
|
|
1045
|
+
type NodeSqliteProviderOptions = Static<typeof nodeSqliteOptions.schema>;
|
|
1046
|
+
declare module "alepha" {
|
|
1047
|
+
interface State {
|
|
1048
|
+
[nodeSqliteOptions.key]: NodeSqliteProviderOptions;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Add a fake support for SQLite in Node.js based on Postgres interfaces.
|
|
1053
|
+
*
|
|
1054
|
+
* This is NOT a real SQLite provider, it's a workaround to use SQLite with Drizzle ORM.
|
|
1055
|
+
* This is NOT recommended for production use.
|
|
1056
|
+
*/
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region ../../src/orm/index.d.ts
|
|
1059
|
+
declare module "alepha" {
|
|
1060
|
+
interface Hooks {
|
|
1061
|
+
/**
|
|
1062
|
+
* Fires before creating an entity in the repository.
|
|
1063
|
+
*/
|
|
1064
|
+
"repository:create:before": {
|
|
1065
|
+
tableName: string;
|
|
1066
|
+
data: any;
|
|
1067
|
+
};
|
|
1068
|
+
/**
|
|
1069
|
+
* Fires after creating an entity in the repository.
|
|
1070
|
+
*/
|
|
1071
|
+
"repository:create:after": {
|
|
1072
|
+
tableName: string;
|
|
1073
|
+
data: any;
|
|
1074
|
+
entity: any;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* Fires before updating entities in the repository.
|
|
1078
|
+
*/
|
|
1079
|
+
"repository:update:before": {
|
|
1080
|
+
tableName: string;
|
|
1081
|
+
where: any;
|
|
1082
|
+
data: any;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* Fires after updating entities in the repository.
|
|
1086
|
+
*/
|
|
1087
|
+
"repository:update:after": {
|
|
1088
|
+
tableName: string;
|
|
1089
|
+
where: any;
|
|
1090
|
+
data: any;
|
|
1091
|
+
entities: any[];
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* Fires before deleting entities from the repository.
|
|
1095
|
+
*/
|
|
1096
|
+
"repository:delete:before": {
|
|
1097
|
+
tableName: string;
|
|
1098
|
+
where: any;
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* Fires after deleting entities from the repository.
|
|
1102
|
+
*/
|
|
1103
|
+
"repository:delete:after": {
|
|
1104
|
+
tableName: string;
|
|
1105
|
+
where: any;
|
|
1106
|
+
ids: Array<string | number>;
|
|
1107
|
+
};
|
|
1108
|
+
/**
|
|
1109
|
+
* Fires before reading entities from the repository.
|
|
1110
|
+
*/
|
|
1111
|
+
"repository:read:before": {
|
|
1112
|
+
tableName: string;
|
|
1113
|
+
query: any;
|
|
1114
|
+
};
|
|
1115
|
+
/**
|
|
1116
|
+
* Fires after reading entities from the repository.
|
|
1117
|
+
*/
|
|
1118
|
+
"repository:read:after": {
|
|
1119
|
+
tableName: string;
|
|
1120
|
+
query: any;
|
|
1121
|
+
entities: any[];
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region ../../src/api-audits/schemas/auditResourceSchema.d.ts
|
|
1127
|
+
/**
|
|
1128
|
+
* Resource schema for audit log responses.
|
|
1129
|
+
*/
|
|
1130
|
+
declare const auditResourceSchema: alepha349.TObject<{
|
|
1131
|
+
id: PgAttr<PgAttr<alepha349.TString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>;
|
|
1132
|
+
createdAt: PgAttr<PgAttr<alepha349.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1133
|
+
type: alepha349.TString;
|
|
1134
|
+
action: alepha349.TString;
|
|
1135
|
+
severity: PgAttr<alepha349.TUnsafe<"info" | "warning" | "critical">, typeof PG_DEFAULT>;
|
|
1136
|
+
userId: alepha349.TOptional<alepha349.TString>;
|
|
1137
|
+
userRealm: alepha349.TOptional<alepha349.TString>;
|
|
1138
|
+
userEmail: alepha349.TOptional<alepha349.TString>;
|
|
1139
|
+
resourceType: alepha349.TOptional<alepha349.TString>;
|
|
1140
|
+
resourceId: alepha349.TOptional<alepha349.TString>;
|
|
1141
|
+
description: alepha349.TOptional<alepha349.TString>;
|
|
1142
|
+
metadata: alepha349.TOptional<alepha349.TRecord<string, alepha349.TAny>>;
|
|
1143
|
+
ipAddress: alepha349.TOptional<alepha349.TString>;
|
|
1144
|
+
userAgent: alepha349.TOptional<alepha349.TString>;
|
|
1145
|
+
sessionId: alepha349.TOptional<alepha349.TString>;
|
|
1146
|
+
requestId: alepha349.TOptional<alepha349.TString>;
|
|
1147
|
+
success: PgAttr<alepha349.TBoolean, typeof PG_DEFAULT>;
|
|
1148
|
+
errorMessage: alepha349.TOptional<alepha349.TString>;
|
|
1149
|
+
}>;
|
|
1150
|
+
type AuditResource = Static<typeof auditResourceSchema>;
|
|
1151
|
+
//#endregion
|
|
1152
|
+
//#region ../../src/api-audits/index.d.ts
|
|
1153
|
+
/**
|
|
1154
|
+
* Provides audit logging API endpoints for Alepha applications.
|
|
1155
|
+
*
|
|
1156
|
+
* This module includes:
|
|
1157
|
+
* - Audit log CRUD operations
|
|
1158
|
+
* - Filtering and searching audit events
|
|
1159
|
+
* - Audit statistics and analytics
|
|
1160
|
+
* - `$audit` primitive for domain-specific audit types
|
|
1161
|
+
*
|
|
1162
|
+
* @module alepha.api.audits
|
|
1163
|
+
*
|
|
1164
|
+
* @example
|
|
1165
|
+
* ```ts
|
|
1166
|
+
* // In your app module
|
|
1167
|
+
* import { AlephaApiAudits } from "alepha/api/audits";
|
|
1168
|
+
*
|
|
1169
|
+
* const App = $module({
|
|
1170
|
+
* name: "app",
|
|
1171
|
+
* services: [AlephaApiAudits, ...],
|
|
1172
|
+
* });
|
|
1173
|
+
*
|
|
1174
|
+
* // Create domain-specific audit types
|
|
1175
|
+
* class PaymentAudits {
|
|
1176
|
+
* audit = $audit({
|
|
1177
|
+
* type: "payment",
|
|
1178
|
+
* actions: ["create", "refund", "cancel"],
|
|
1179
|
+
* });
|
|
1180
|
+
*
|
|
1181
|
+
* async onPaymentCreated(paymentId: string, userId: string) {
|
|
1182
|
+
* await this.audit.log("create", {
|
|
1183
|
+
* userId,
|
|
1184
|
+
* resourceType: "payment",
|
|
1185
|
+
* resourceId: paymentId,
|
|
1186
|
+
* });
|
|
1187
|
+
* }
|
|
1188
|
+
* }
|
|
1189
|
+
* ```
|
|
1190
|
+
*/
|
|
1191
|
+
declare const AlephaApiAudits: alepha349.Service<alepha349.Module>;
|
|
1192
|
+
//#endregion
|
|
1193
|
+
export { $audit, AlephaApiAudits, AuditController, AuditEntity, AuditLogOptions, AuditPrimitive, AuditPrimitiveOptions, AuditQuery, AuditResource, AuditService, AuditSeverity, AuditStats, AuditTypeDefinition, CreateAudit, auditEntityInsertSchema, auditEntitySchema, auditQuerySchema, auditResourceSchema, auditSeveritySchema, audits, createAuditSchema };
|
|
1194
|
+
//# sourceMappingURL=index.d.ts.map
|