@alepha/react 0.12.0 → 0.12.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.
Files changed (85) hide show
  1. package/dist/auth/chunk-DhGyd7sr.js +28 -0
  2. package/dist/auth/index.browser.js +394 -114
  3. package/dist/auth/index.browser.js.map +1 -1
  4. package/dist/auth/index.cjs +80 -1927
  5. package/dist/auth/index.cjs.map +1 -1
  6. package/dist/auth/index.d.cts +1130 -420
  7. package/dist/auth/index.d.ts +1130 -420
  8. package/dist/auth/index.js +72 -1918
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/core/chunk-DhGyd7sr.js +28 -0
  11. package/dist/core/index.browser.js +79 -79
  12. package/dist/core/index.browser.js.map +1 -1
  13. package/dist/core/index.cjs +89 -85
  14. package/dist/core/index.cjs.map +1 -1
  15. package/dist/core/index.d.cts +1654 -154
  16. package/dist/core/index.d.ts +1654 -154
  17. package/dist/core/index.js +79 -79
  18. package/dist/core/index.js.map +1 -1
  19. package/dist/form/chunk-DhGyd7sr.js +28 -0
  20. package/dist/form/index.cjs +28 -8
  21. package/dist/form/index.cjs.map +1 -1
  22. package/dist/form/index.d.cts +215 -7
  23. package/dist/form/index.d.ts +215 -7
  24. package/dist/form/index.js +18 -3
  25. package/dist/form/index.js.map +1 -1
  26. package/dist/head/chunk-DhGyd7sr.js +28 -0
  27. package/dist/head/index.browser.js +385 -59
  28. package/dist/head/index.browser.js.map +1 -1
  29. package/dist/head/index.cjs +12 -8
  30. package/dist/head/index.cjs.map +1 -1
  31. package/dist/head/index.d.cts +1230 -24
  32. package/dist/head/index.d.ts +1230 -29
  33. package/dist/head/index.js +2 -2
  34. package/dist/head/index.js.map +1 -1
  35. package/dist/i18n/chunk-DhGyd7sr.js +28 -0
  36. package/dist/i18n/index.cjs +33 -20
  37. package/dist/i18n/index.cjs.map +1 -1
  38. package/dist/i18n/index.d.cts +282 -13
  39. package/dist/i18n/index.d.ts +282 -13
  40. package/dist/i18n/index.js +23 -14
  41. package/dist/i18n/index.js.map +1 -1
  42. package/dist/websocket/index.cjs +21 -8
  43. package/dist/websocket/index.cjs.map +1 -1
  44. package/dist/websocket/index.js +11 -2
  45. package/dist/websocket/index.js.map +1 -1
  46. package/package.json +7 -6
  47. package/src/auth/index.browser.ts +3 -6
  48. package/src/auth/index.shared.ts +0 -1
  49. package/src/auth/index.ts +3 -16
  50. package/src/auth/providers/ReactAuthProvider.ts +1 -614
  51. package/src/auth/services/ReactAuth.ts +6 -17
  52. package/src/core/descriptors/$page.ts +1 -1
  53. package/src/core/index.browser.ts +1 -0
  54. package/src/core/index.native.ts +21 -0
  55. package/src/core/index.shared-router.ts +15 -0
  56. package/src/core/index.shared.ts +0 -14
  57. package/src/core/index.ts +1 -0
  58. package/src/core/services/ReactRouter.ts +2 -2
  59. package/src/form/errors/FormValidationError.ts +20 -0
  60. package/src/form/hooks/useForm.ts +1 -1
  61. package/src/form/index.ts +1 -0
  62. package/src/head/providers/BrowserHeadProvider.ts +1 -1
  63. package/src/i18n/descriptors/$dictionary.ts +7 -3
  64. package/src/i18n/providers/I18nProvider.ts +9 -10
  65. package/src/websocket/hooks/useRoom.tsx +21 -2
  66. package/dist/auth/index.d.cts.map +0 -1
  67. package/dist/auth/index.d.ts.map +0 -1
  68. package/dist/core/index.d.cts.map +0 -1
  69. package/dist/core/index.d.ts.map +0 -1
  70. package/dist/form/index.d.cts.map +0 -1
  71. package/dist/form/index.d.ts.map +0 -1
  72. package/dist/head/index.d.cts.map +0 -1
  73. package/dist/head/index.d.ts.map +0 -1
  74. package/dist/i18n/index.d.cts.map +0 -1
  75. package/dist/i18n/index.d.ts.map +0 -1
  76. package/dist/websocket/index.d.cts.map +0 -1
  77. package/dist/websocket/index.d.ts.map +0 -1
  78. package/src/auth/descriptors/$auth.ts +0 -436
  79. package/src/auth/descriptors/$authApple.ts +0 -8
  80. package/src/auth/descriptors/$authGithub.ts +0 -81
  81. package/src/auth/descriptors/$authGoogle.ts +0 -38
  82. package/src/auth/errors/SessionExpiredError.ts +0 -6
  83. package/src/auth/schemas/tokenResponseSchema.ts +0 -11
  84. package/src/auth/schemas/tokensSchema.ts +0 -21
  85. package/src/auth/schemas/userinfoResponseSchema.ts +0 -10
@@ -1,17 +1,1053 @@
1
- import * as alepha7 from "alepha";
2
- import { Alepha, Async, Atom, Descriptor, Hook, Hooks, KIND, Service, State, Static, TAtomObject, TObject, TSchema } from "alepha";
3
- import { RequestConfigSchema, ServerHandler, ServerProvider, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
4
- import * as react0 from "react";
1
+ import * as alepha139 from "alepha";
2
+ import { Alepha, AlephaError, Async, Atom, Descriptor, FileLike, Hook, Hooks, InstantiableClass, KIND, LogLevel, LoggerInterface, Service, State, Static, StreamLike, TArray, TAtomObject, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
3
+ import { IncomingMessage, Server, ServerResponse } from "node:http";
4
+ import dayjsDuration from "dayjs/plugin/duration.js";
5
+ import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
6
+ import { Readable } from "node:stream";
7
+ import { ReadableStream } from "node:stream/web";
8
+ import * as react1 from "react";
5
9
  import React, { AnchorHTMLAttributes, CSSProperties, DependencyList, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
6
- import { ServerRouteCache } from "alepha/server/cache";
7
- import * as alepha_logger0 from "alepha/logger";
8
- import * as typebox0 from "typebox";
9
- import { DateTimeProvider, DurationLike } from "alepha/datetime";
10
- import { ClientScope, HttpVirtualClient, LinkProvider, VirtualAction } from "alepha/server/links";
11
- import { Route, RouterProvider } from "alepha/router";
12
10
  import * as react_jsx_runtime0 from "react/jsx-runtime";
13
- import { ServerStaticProvider } from "alepha/server/static";
14
11
 
12
+ //#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
13
+ declare const logEntrySchema: alepha139.TObject<{
14
+ level: alepha139.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
15
+ message: alepha139.TString;
16
+ service: alepha139.TString;
17
+ module: alepha139.TString;
18
+ context: alepha139.TOptional<alepha139.TString>;
19
+ app: alepha139.TOptional<alepha139.TString>;
20
+ data: alepha139.TOptional<alepha139.TAny>;
21
+ timestamp: alepha139.TNumber;
22
+ }>;
23
+ type LogEntry = Static<typeof logEntrySchema>;
24
+ //#endregion
25
+ //#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
26
+ type DateTime = DayjsApi.Dayjs;
27
+ type Duration = dayjsDuration.Duration;
28
+ type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
29
+ declare class DateTimeProvider {
30
+ static PLUGINS: Array<PluginFunc<any>>;
31
+ protected alepha: Alepha;
32
+ protected ref: DateTime | null;
33
+ protected readonly timeouts: Timeout[];
34
+ protected readonly intervals: Interval[];
35
+ constructor();
36
+ protected readonly onStart: alepha139.HookDescriptor<"start">;
37
+ protected readonly onStop: alepha139.HookDescriptor<"stop">;
38
+ setLocale(locale: string): void;
39
+ isDateTime(value: unknown): value is DateTime;
40
+ /**
41
+ * Create a new UTC DateTime instance.
42
+ */
43
+ utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
44
+ /**
45
+ * Create a new DateTime instance.
46
+ */
47
+ of(date: string | number | Date | Dayjs | null | undefined): DateTime;
48
+ /**
49
+ * Get the current date as a string.
50
+ */
51
+ toISOString(date?: Date | string | DateTime): string;
52
+ /**
53
+ * Get the current date.
54
+ */
55
+ now(): DateTime;
56
+ /**
57
+ * Get the current date as a string.
58
+ *
59
+ * This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
60
+ */
61
+ nowISOString(): string;
62
+ /**
63
+ * Get the current date as milliseconds since epoch.
64
+ *
65
+ * This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
66
+ */
67
+ nowMillis(): number;
68
+ /**
69
+ * Get the current date as a string.
70
+ *
71
+ * @protected
72
+ */
73
+ protected getCurrentDate(): DateTime;
74
+ /**
75
+ * Create a new Duration instance.
76
+ */
77
+ duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
78
+ isDurationLike(value: unknown): value is DurationLike;
79
+ /**
80
+ * Return a promise that resolves after the next tick.
81
+ * It uses `setTimeout` with 0 ms delay.
82
+ */
83
+ tick(): Promise<void>;
84
+ /**
85
+ * Wait for a certain duration.
86
+ *
87
+ * You can clear the timeout by using the `AbortSignal` API.
88
+ * Aborted signal will resolve the promise immediately, it does not reject it.
89
+ */
90
+ wait(duration: DurationLike, options?: {
91
+ signal?: AbortSignal;
92
+ now?: number;
93
+ }): Promise<void>;
94
+ createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
95
+ /**
96
+ * Run a callback after a certain duration.
97
+ */
98
+ createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
99
+ clearTimeout(timeout: Timeout): void;
100
+ clearInterval(interval: Interval): void;
101
+ /**
102
+ * Run a function with a deadline.
103
+ */
104
+ deadline<T$1>(fn: (signal: AbortSignal) => Promise<T$1>, duration: DurationLike): Promise<T$1>;
105
+ /**
106
+ * Add time to the current date.
107
+ */
108
+ travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
109
+ /**
110
+ * Stop the time.
111
+ */
112
+ pause(): DateTime;
113
+ /**
114
+ * Reset the reference date.
115
+ */
116
+ reset(): void;
117
+ }
118
+ interface Interval {
119
+ timer?: any;
120
+ duration: number;
121
+ run: () => unknown;
122
+ }
123
+ interface Timeout {
124
+ now: number;
125
+ timer?: any;
126
+ duration: number;
127
+ callback: () => void;
128
+ clear: () => void;
129
+ }
130
+ //#endregion
131
+ //#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
132
+ declare abstract class LogDestinationProvider {
133
+ abstract write(message: string, entry: LogEntry): void;
134
+ }
135
+ //#endregion
136
+ //#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
137
+ declare abstract class LogFormatterProvider {
138
+ abstract format(entry: LogEntry): string;
139
+ }
140
+ //#endregion
141
+ //#region ../alepha/src/logger/services/Logger.d.ts
142
+ declare class Logger implements LoggerInterface {
143
+ protected readonly alepha: Alepha;
144
+ protected readonly formatter: LogFormatterProvider;
145
+ protected readonly destination: LogDestinationProvider;
146
+ protected readonly dateTimeProvider: DateTimeProvider;
147
+ protected readonly levels: Record<string, number>;
148
+ protected readonly service: string;
149
+ protected readonly module: string;
150
+ protected readonly app?: string;
151
+ protected appLogLevel: string;
152
+ protected logLevel: LogLevel;
153
+ constructor(service: string, module: string);
154
+ get context(): string | undefined;
155
+ get level(): string;
156
+ parseLevel(level: string, app: string): LogLevel;
157
+ private matchesPattern;
158
+ asLogLevel(something: string): LogLevel;
159
+ error(message: string, data?: unknown): void;
160
+ warn(message: string, data?: unknown): void;
161
+ info(message: string, data?: unknown): void;
162
+ debug(message: string, data?: unknown): void;
163
+ trace(message: string, data?: unknown): void;
164
+ protected log(level: LogLevel, message: string, data?: unknown): void;
165
+ protected emit(entry: LogEntry, message?: string): void;
166
+ }
167
+ //#endregion
168
+ //#region ../alepha/src/logger/index.d.ts
169
+ declare const envSchema$6: alepha139.TObject<{
170
+ /**
171
+ * Default log level for the application.
172
+ *
173
+ * Default by environment:
174
+ * - dev = info
175
+ * - prod = info
176
+ * - test = error
177
+ *
178
+ * Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
179
+ *
180
+ * Level can be set for a specific module:
181
+ *
182
+ * @example
183
+ * LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
184
+ * LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
185
+ */
186
+ LOG_LEVEL: alepha139.TOptional<alepha139.TString>;
187
+ /**
188
+ * Built-in log formats.
189
+ * - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
190
+ * - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
191
+ * - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
192
+ */
193
+ LOG_FORMAT: alepha139.TOptional<alepha139.TUnsafe<"json" | "pretty" | "raw">>;
194
+ }>;
195
+ declare module "alepha" {
196
+ interface Env extends Partial<Static<typeof envSchema$6>> {}
197
+ interface State {
198
+ /**
199
+ * Current log level for the application or specific modules.
200
+ */
201
+ "alepha.logger.level"?: string;
202
+ }
203
+ interface Hooks {
204
+ log: {
205
+ message?: string;
206
+ entry: LogEntry;
207
+ };
208
+ }
209
+ }
210
+ //#endregion
211
+ //#region ../alepha/src/server/constants/routeMethods.d.ts
212
+ declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
213
+ type RouteMethod = (typeof routeMethods)[number];
214
+ //#endregion
215
+ //#region ../alepha/src/router/providers/RouterProvider.d.ts
216
+ declare abstract class RouterProvider<T$1 extends Route = Route> {
217
+ protected routePathRegex: RegExp;
218
+ protected tree: Tree<T$1>;
219
+ protected cache: Map<string, RouteMatch<T$1>>;
220
+ match(path: string): RouteMatch<T$1>;
221
+ protected test(path: string): void;
222
+ protected push(route: T$1): void;
223
+ protected createRouteMatch(path: string): RouteMatch<T$1>;
224
+ protected mapParams(match: RouteMatch<T$1>): RouteMatch<T$1>;
225
+ protected createParts(path: string): string[];
226
+ }
227
+ interface RouteMatch<T$1 extends Route> {
228
+ route?: T$1;
229
+ params?: Record<string, string>;
230
+ }
231
+ interface Route {
232
+ path: string;
233
+ /**
234
+ * Rename a param in the route.
235
+ * This is automatically filled when you have scenarios like:
236
+ * `/customers/:id` and `/customers/:userId/payments`
237
+ *
238
+ * In this case, `:id` will be renamed to `:userId` in the second route.
239
+ */
240
+ mapParams?: Record<string, string>;
241
+ }
242
+ interface Tree<T$1 extends Route> {
243
+ route?: T$1;
244
+ children: {
245
+ [key: string]: Tree<T$1>;
246
+ };
247
+ param?: {
248
+ route?: T$1;
249
+ name: string;
250
+ children: {
251
+ [key: string]: Tree<T$1>;
252
+ };
253
+ };
254
+ wildcard?: {
255
+ route: T$1;
256
+ };
257
+ }
258
+ //#endregion
259
+ //#region ../alepha/src/server/helpers/ServerReply.d.ts
260
+ /**
261
+ * Helper for building server replies.
262
+ */
263
+ declare class ServerReply {
264
+ headers: Record<string, string> & {
265
+ "set-cookie"?: string[];
266
+ };
267
+ status?: number;
268
+ body?: any;
269
+ /**
270
+ * Redirect to a given URL with optional status code (default 302).
271
+ */
272
+ redirect(url: string, status?: number): void;
273
+ /**
274
+ * Set the response status code.
275
+ */
276
+ setStatus(status: number): this;
277
+ /**
278
+ * Set a response header.
279
+ */
280
+ setHeader(name: string, value: string): this;
281
+ /**
282
+ * Set the response body.
283
+ */
284
+ setBody(body: any): this;
285
+ }
286
+ //#endregion
287
+ //#region ../alepha/src/server/services/UserAgentParser.d.ts
288
+ interface UserAgentInfo {
289
+ os: "Windows" | "Android" | "Ubuntu" | "MacOS" | "iOS" | "Linux" | "FreeBSD" | "OpenBSD" | "ChromeOS" | "BlackBerry" | "Symbian" | "Windows Phone";
290
+ browser: "Chrome" | "Firefox" | "Safari" | "Edge" | "Opera" | "Internet Explorer" | "Brave" | "Vivaldi" | "Samsung Browser" | "UC Browser" | "Yandex";
291
+ device: "MOBILE" | "DESKTOP" | "TABLET";
292
+ }
293
+ /**
294
+ * Simple User-Agent parser to detect OS, browser, and device type.
295
+ * This parser is not exhaustive and may not cover all edge cases.
296
+ *
297
+ * Use result for non
298
+ */
299
+ declare class UserAgentParser {
300
+ parse(userAgent?: string): UserAgentInfo;
301
+ }
302
+ //#endregion
303
+ //#region ../alepha/src/server/interfaces/ServerRequest.d.ts
304
+ type TRequestBody = TObject | TString | TArray | TRecord | TStream;
305
+ type TResponseBody = TObject | TString | TRecord | TFile | TArray | TStream | TVoid;
306
+ interface RequestConfigSchema {
307
+ body?: TRequestBody;
308
+ params?: TObject;
309
+ query?: TObject;
310
+ headers?: TObject;
311
+ response?: TResponseBody;
312
+ }
313
+ interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
314
+ body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
315
+ headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
316
+ params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
317
+ query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
318
+ }
319
+ type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
320
+ interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
321
+ /**
322
+ * HTTP method used for this request.
323
+ */
324
+ method: RouteMethod;
325
+ /**
326
+ * Full request URL.
327
+ */
328
+ url: URL;
329
+ /**
330
+ * Unique request ID assigned to this request.
331
+ */
332
+ requestId: string;
333
+ /**
334
+ * Client IP address.
335
+ * Will parse `X-Forwarded-For` header if present.
336
+ */
337
+ ip?: string;
338
+ /**
339
+ * Value of the `Host` header sent by the client.
340
+ */
341
+ host?: string;
342
+ /**
343
+ * Browser user agent information.
344
+ * Information are not guaranteed to be accurate. Use with caution.
345
+ *
346
+ * @see {@link UserAgentParser}
347
+ */
348
+ userAgent: UserAgentInfo;
349
+ /**
350
+ * Arbitrary metadata attached to the request. Can be used by middlewares to store information.
351
+ */
352
+ metadata: Record<string, any>;
353
+ /**
354
+ * Reply object to be used to send response.
355
+ */
356
+ reply: ServerReply;
357
+ /**
358
+ * The raw underlying request object (Web Request).
359
+ */
360
+ raw: ServerRawRequest;
361
+ }
362
+ interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
363
+ /**
364
+ * Handler function for this route.
365
+ */
366
+ handler: ServerHandler<TConfig>;
367
+ /**
368
+ * HTTP method for this route.
369
+ */
370
+ method?: RouteMethod;
371
+ /**
372
+ * Request/response schema for this route.
373
+ *
374
+ * Request schema contains:
375
+ * - body, for POST/PUT/PATCH requests
376
+ * - params, for URL parameters (e.g. /user/:id)
377
+ * - query, for URL query parameters (e.g. /user?id=123)
378
+ * - headers, for HTTP headers
379
+ *
380
+ * Response schema contains:
381
+ * - response
382
+ *
383
+ * Response schema is used to validate and serialize the response sent by the handler.
384
+ */
385
+ schema?: TConfig;
386
+ /**
387
+ * @see ServerLoggerProvider
388
+ */
389
+ silent?: boolean;
390
+ }
391
+ type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
392
+ type ResponseKind = "json" | "text" | "void" | "file" | "any";
393
+ type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
394
+ type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
395
+ interface ServerResponse$1 {
396
+ body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
397
+ headers: Record<string, string>;
398
+ status: number;
399
+ }
400
+ type ServerRouteRequestHandler = (request: ServerRequestData) => Promise<ServerResponse$1>;
401
+ interface ServerRouteMatcher extends Route {
402
+ handler: ServerRouteRequestHandler;
403
+ }
404
+ interface ServerRequestData {
405
+ method: RouteMethod;
406
+ url: URL;
407
+ headers: Record<string, string>;
408
+ query: Record<string, string>;
409
+ params: Record<string, string>;
410
+ raw: ServerRawRequest;
411
+ }
412
+ interface ServerRawRequest {
413
+ node?: NodeRequestEvent;
414
+ web?: WebRequestEvent;
415
+ }
416
+ interface NodeRequestEvent {
417
+ req: IncomingMessage;
418
+ res: ServerResponse;
419
+ }
420
+ interface WebRequestEvent {
421
+ req: Request;
422
+ res?: Response;
423
+ }
424
+ //#endregion
425
+ //#region ../alepha/src/server/services/ServerRequestParser.d.ts
426
+ declare class ServerRequestParser {
427
+ protected readonly alepha: Alepha;
428
+ protected readonly userAgentParser: UserAgentParser;
429
+ createServerRequest(rawRequest: ServerRequestData): ServerRequest;
430
+ getRequestId(request: ServerRequestData): string | undefined;
431
+ getRequestUserAgent(request: ServerRequestData): UserAgentInfo;
432
+ getRequestIp(request: ServerRequestData): string | undefined;
433
+ }
434
+ //#endregion
435
+ //#region ../alepha/src/server/providers/ServerTimingProvider.d.ts
436
+ type TimingMap = Record<string, [number, number]>;
437
+ declare class ServerTimingProvider {
438
+ protected readonly log: Logger;
439
+ protected readonly alepha: Alepha;
440
+ options: {
441
+ prefix: string;
442
+ disabled: boolean;
443
+ };
444
+ readonly onRequest: alepha139.HookDescriptor<"server:onRequest">;
445
+ readonly onResponse: alepha139.HookDescriptor<"server:onResponse">;
446
+ protected get handlerName(): string;
447
+ beginTiming(name: string): void;
448
+ endTiming(name: string): void;
449
+ protected setDuration(name: string, timing: TimingMap): void;
450
+ }
451
+ //#endregion
452
+ //#region ../alepha/src/server/providers/ServerRouterProvider.d.ts
453
+ /**
454
+ * Main router for all routes on the server side.
455
+ *
456
+ * - $route => generic route
457
+ * - $action => action route (for API calls)
458
+ * - $page => React route (for SSR)
459
+ */
460
+ declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
461
+ protected readonly log: Logger;
462
+ protected readonly alepha: Alepha;
463
+ protected readonly routes: ServerRoute[];
464
+ protected readonly serverTimingProvider: ServerTimingProvider;
465
+ protected readonly serverRequestParser: ServerRequestParser;
466
+ /**
467
+ * Get all registered routes, optionally filtered by a pattern.
468
+ *
469
+ * Pattern accept simple wildcard '*' at the end.
470
+ * Example: '/api/*' will match all routes starting with '/api/' but '/api/' will match only that exact route.
471
+ */
472
+ getRoutes(pattern?: string): ServerRoute[];
473
+ createRoute<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): void;
474
+ protected getContextId(headers: Record<string, string>): string;
475
+ protected processRequest(request: ServerRequest, route: ServerRoute, responseKind: ResponseKind): Promise<{
476
+ status: number;
477
+ headers: Record<string, string> & {
478
+ "set-cookie"?: string[];
479
+ };
480
+ body: any;
481
+ }>;
482
+ protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseKind: ResponseKind): Promise<void>;
483
+ serializeResponse(route: ServerRoute, reply: ServerReply, responseKind: ResponseKind): void;
484
+ protected getResponseType(schema?: RequestConfigSchema): ResponseKind;
485
+ protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
486
+ validateRequest(route: {
487
+ schema?: RequestConfigSchema;
488
+ }, request: ServerRequestConfig): void;
489
+ }
490
+ //#endregion
491
+ //#region ../alepha/src/server/providers/ServerProvider.d.ts
492
+ /**
493
+ * Base server provider to handle incoming requests and route them.
494
+ *
495
+ * This is the default implementation for serverless environments.
496
+ *
497
+ * ServerProvider supports both Node.js HTTP requests and Web (Fetch API) requests.
498
+ */
499
+ declare class ServerProvider {
500
+ protected readonly log: Logger;
501
+ protected readonly alepha: Alepha;
502
+ protected readonly dateTimeProvider: DateTimeProvider;
503
+ protected readonly router: ServerRouterProvider;
504
+ protected readonly internalServerErrorMessage = "Internal Server Error";
505
+ get hostname(): string;
506
+ /**
507
+ * When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
508
+ */
509
+ protected readonly onNodeRequest: alepha139.HookDescriptor<"node:request">;
510
+ /**
511
+ * When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
512
+ */
513
+ protected readonly onWebRequest: alepha139.HookDescriptor<"web:request">;
514
+ /**
515
+ * Handle Node.js HTTP request event.
516
+ *
517
+ * Technically, we just convert Node.js request to Web Standard Request.
518
+ */
519
+ handleNodeRequest(nodeRequestEvent: NodeRequestEvent): Promise<void>;
520
+ /**
521
+ * Handle Web (Fetch API) request event.
522
+ */
523
+ handleWebRequest(ev: WebRequestEvent): Promise<void>;
524
+ /**
525
+ * Helper for Vite development mode to let Vite handle (or not) 404.
526
+ */
527
+ protected isViteNotFound(url?: string, route?: Route, params?: Record<string, string>): boolean;
528
+ }
529
+ //#endregion
530
+ //#region ../alepha/src/cache/providers/CacheProvider.d.ts
531
+ /**
532
+ * Cache provider interface.
533
+ *
534
+ * All methods are asynchronous and return promises.
535
+ * Values are stored as Uint8Array.
536
+ */
537
+ declare abstract class CacheProvider {
538
+ /**
539
+ * Get the value of a key.
540
+ *
541
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
542
+ * @param key The key of the value to get.
543
+ *
544
+ * @return The value of the key, or undefined if the key does not exist.
545
+ */
546
+ abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
547
+ /**
548
+ * Set the string value of a key.
549
+ *
550
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
551
+ * @param key The key of the value to set.
552
+ * @param value The value to set.
553
+ * @param ttl The time-to-live of the key, in milliseconds.
554
+ *
555
+ * @return The value of the key.
556
+ */
557
+ abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
558
+ /**
559
+ * Remove the specified keys.
560
+ *
561
+ * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
562
+ * @param keys The keys to delete.
563
+ */
564
+ abstract del(name: string, ...keys: string[]): Promise<void>;
565
+ abstract has(name: string, key: string): Promise<boolean>;
566
+ abstract keys(name: string, filter?: string): Promise<string[]>;
567
+ /**
568
+ * Remove all keys from all cache names.
569
+ */
570
+ abstract clear(): Promise<void>;
571
+ }
572
+ //#endregion
573
+ //#region ../alepha/src/cache/descriptors/$cache.d.ts
574
+ interface CacheDescriptorOptions<TReturn = any, TParameter extends any[] = any[]> {
575
+ /**
576
+ * The cache name. This is useful for invalidating multiple caches at once.
577
+ *
578
+ * Store key as `cache:$name:$key`.
579
+ *
580
+ * @default Name of the key of the class.
581
+ */
582
+ name?: string;
583
+ /**
584
+ * Function which returns cached data.
585
+ */
586
+ handler?: (...args: TParameter) => TReturn;
587
+ /**
588
+ * The key generator for the cache.
589
+ * If not provided, the arguments will be json.stringify().
590
+ */
591
+ key?: (...args: TParameter) => string;
592
+ /**
593
+ * The store provider for the cache.
594
+ * If not provided, the default store provider will be used.
595
+ */
596
+ provider?: InstantiableClass<CacheProvider> | "memory";
597
+ /**
598
+ * The time-to-live for the cache in seconds.
599
+ * Set 0 to skip expiration.
600
+ *
601
+ * @default 300 (5 minutes).
602
+ */
603
+ ttl?: DurationLike;
604
+ /**
605
+ * If the cache is disabled.
606
+ */
607
+ disabled?: boolean;
608
+ }
609
+ declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn, TParameter>> {
610
+ protected readonly env: {
611
+ CACHE_ENABLED: boolean;
612
+ CACHE_DEFAULT_TTL: number;
613
+ };
614
+ protected readonly dateTimeProvider: DateTimeProvider;
615
+ protected readonly provider: CacheProvider;
616
+ protected encoder: TextEncoder;
617
+ protected decoder: TextDecoder;
618
+ protected codes: {
619
+ BINARY: number;
620
+ JSON: number;
621
+ STRING: number;
622
+ };
623
+ get container(): string;
624
+ run(...args: TParameter): Promise<TReturn>;
625
+ key(...args: TParameter): string;
626
+ invalidate(...keys: string[]): Promise<void>;
627
+ set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
628
+ get(key: string): Promise<TReturn | undefined>;
629
+ protected serialize<TReturn>(value: TReturn): Uint8Array;
630
+ protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
631
+ protected $provider(): CacheProvider;
632
+ }
633
+ interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> extends CacheDescriptor<TReturn, TParameter> {
634
+ /**
635
+ * Run the cache descriptor with the provided arguments.
636
+ */
637
+ (...args: TParameter): Promise<TReturn>;
638
+ }
639
+ //#endregion
640
+ //#region ../alepha/src/server/services/HttpClient.d.ts
641
+ declare class HttpClient {
642
+ protected readonly log: Logger;
643
+ protected readonly alepha: Alepha;
644
+ readonly cache: CacheDescriptorFn<HttpClientCache, any[]>;
645
+ protected readonly pendingRequests: HttpClientPendingRequests;
646
+ fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
647
+ fetch<T$1 extends TSchema>(url: string, request?: RequestInitWithOptions<T$1>): Promise<FetchResponse<Static<T$1>>>;
648
+ protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
649
+ protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
650
+ protected responseData(response: Response, options: FetchOptions): Promise<any>;
651
+ protected isMaybeFile(response: Response): boolean;
652
+ protected createFileLike(response: Response, defaultFileName?: string): FileLike;
653
+ pathVariables(url: string, action: {
654
+ schema?: {
655
+ params?: TObject;
656
+ };
657
+ }, args?: ServerRequestConfigEntry): string;
658
+ queryParams(url: string, action: {
659
+ schema?: {
660
+ query?: TObject;
661
+ };
662
+ }, args?: ServerRequestConfigEntry): string;
663
+ }
664
+ interface FetchOptions<T$1 extends TSchema = TSchema> {
665
+ /**
666
+ * Key to identify the request in the pending requests.
667
+ */
668
+ key?: string;
669
+ /**
670
+ * The schema to validate the response against.
671
+ */
672
+ schema?: {
673
+ response?: T$1;
674
+ };
675
+ /**
676
+ * Built-in cache options.
677
+ */
678
+ localCache?: boolean | number | DurationLike;
679
+ }
680
+ type RequestInitWithOptions<T$1 extends TSchema = TSchema> = RequestInit & FetchOptions<T$1>;
681
+ interface FetchResponse<T$1 = any> {
682
+ data: T$1;
683
+ status: number;
684
+ statusText: string;
685
+ headers: Headers;
686
+ raw?: Response;
687
+ }
688
+ type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
689
+ interface HttpClientCache {
690
+ data: any;
691
+ etag?: string;
692
+ }
693
+ interface FetchActionArgs {
694
+ action: HttpAction;
695
+ host?: string;
696
+ config?: ServerRequestConfigEntry;
697
+ options?: ClientRequestOptions;
698
+ }
699
+ interface HttpAction {
700
+ method?: string;
701
+ prefix?: string;
702
+ path: string;
703
+ requestBodyType?: string;
704
+ schema?: {
705
+ params?: TObject;
706
+ query?: TObject;
707
+ body?: TRequestBody;
708
+ response?: TResponseBody;
709
+ };
710
+ }
711
+ //#endregion
712
+ //#region ../alepha/src/server/descriptors/$action.d.ts
713
+ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
714
+ /**
715
+ * Name of the action.
716
+ *
717
+ * - It will be used to generate the route path if `path` is not provided.
718
+ * - It will be used to generate the permission name if `security` is enabled.
719
+ */
720
+ name?: string;
721
+ /**
722
+ * Group actions together.
723
+ *
724
+ * - If not provided, the service name containing the route will be used.
725
+ * - It will be used as Tag for documentation purposes.
726
+ * - It will be used for permission name generation if `security` is enabled.
727
+ *
728
+ * @example
729
+ * ```ts
730
+ * // group = "MyController"
731
+ * class MyController {
732
+ * hello = $action({ handler: () => "Hello World" });
733
+ * }
734
+ *
735
+ * // group = "users"
736
+ * class MyOtherController {
737
+ * group = "users";
738
+ * a1 = $action({ handler: () => "Action 1", group: this.group });
739
+ * a2 = $action({ handler: () => "Action 2", group: this.group });
740
+ * }
741
+ * ```
742
+ */
743
+ group?: string;
744
+ /**
745
+ * Pathname of the route. If not provided, property key is used.
746
+ */
747
+ path?: string;
748
+ /**
749
+ * The route method.
750
+ *
751
+ * - If not provided, it will be set to "GET" by default.
752
+ * - If not provider and a body is provided, it will be set to "POST".
753
+ *
754
+ * Wildcard methods are not supported for now. (e.g. "ALL", "ANY", etc.)
755
+ */
756
+ method?: RouteMethod;
757
+ /**
758
+ * The config schema of the route.
759
+ * - body: The request body schema.
760
+ * - params: Path variables schema.
761
+ * - query: The request query-params schema.
762
+ * - response: The response schema.
763
+ */
764
+ schema?: TConfig;
765
+ /**
766
+ * A short description of the action. Used for documentation purposes.
767
+ */
768
+ description?: string;
769
+ /**
770
+ * Disable the route. Useful with env variables do disable one specific route.
771
+ * Route won't be available in the API but can still be called locally!
772
+ */
773
+ disabled?: boolean;
774
+ /**
775
+ * Main route handler. This is where the route logic is implemented.
776
+ */
777
+ handler: ServerActionHandler<TConfig>;
778
+ }
779
+ declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
780
+ protected readonly log: Logger;
781
+ protected readonly env: {
782
+ SERVER_API_PREFIX: string;
783
+ };
784
+ protected readonly httpClient: HttpClient;
785
+ protected readonly serverProvider: ServerProvider;
786
+ protected readonly serverRouterProvider: ServerRouterProvider;
787
+ protected onInit(): void;
788
+ get prefix(): string;
789
+ get route(): ServerRoute;
790
+ /**
791
+ * Returns the name of the action.
792
+ */
793
+ get name(): string;
794
+ /**
795
+ * Returns the group of the action. (e.g. "orders", "admin", etc.)
796
+ */
797
+ get group(): string;
798
+ /**
799
+ * Returns the HTTP method of the action.
800
+ */
801
+ get method(): RouteMethod;
802
+ /**
803
+ * Returns the path of the action.
804
+ *
805
+ * Path is prefixed by `/api` by default.
806
+ */
807
+ get path(): string;
808
+ get schema(): TConfig | undefined;
809
+ getBodyContentType(): string | undefined;
810
+ /**
811
+ * Call the action handler directly.
812
+ * There is no HTTP layer involved.
813
+ */
814
+ run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
815
+ /**
816
+ * Works like `run`, but always fetches (http request) the route.
817
+ */
818
+ fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
819
+ }
820
+ type ClientRequestEntry<TConfig extends RequestConfigSchema, T$1 = ClientRequestEntryContainer<TConfig>> = { [K in keyof T$1 as T$1[K] extends undefined ? never : K]: T$1[K] };
821
+ type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
822
+ body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
823
+ params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
824
+ headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
825
+ query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
826
+ };
827
+ interface ClientRequestOptions extends FetchOptions {
828
+ /**
829
+ * Standard request fetch options.
830
+ */
831
+ request?: RequestInit;
832
+ }
833
+ type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
834
+ /**
835
+ * Specific handler for server actions.
836
+ */
837
+ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
838
+ /**
839
+ * Server Action Request Interface
840
+ *
841
+ * Can be extended with module augmentation to add custom properties (like `user` in Server Security).
842
+ *
843
+ * This is NOT Server Request, but a specific type for actions.
844
+ */
845
+ interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
846
+ //#endregion
847
+ //#region ../alepha/src/server/schemas/errorSchema.d.ts
848
+ declare const errorSchema: alepha139.TObject<{
849
+ error: alepha139.TString;
850
+ status: alepha139.TInteger;
851
+ message: alepha139.TString;
852
+ details: alepha139.TOptional<alepha139.TString>;
853
+ requestId: alepha139.TOptional<alepha139.TString>;
854
+ cause: alepha139.TOptional<alepha139.TObject<{
855
+ name: alepha139.TString;
856
+ message: alepha139.TString;
857
+ }>>;
858
+ }>;
859
+ type ErrorSchema = Static<typeof errorSchema>;
860
+ //#endregion
861
+ //#region ../alepha/src/server/errors/HttpError.d.ts
862
+ declare class HttpError extends AlephaError {
863
+ name: string;
864
+ static is: (error: unknown, status?: number) => error is HttpErrorLike;
865
+ static toJSON(error: HttpError): ErrorSchema;
866
+ readonly error: string;
867
+ readonly status: number;
868
+ readonly requestId?: string;
869
+ readonly details?: string;
870
+ readonly reason?: {
871
+ name: string;
872
+ message: string;
873
+ };
874
+ constructor(options: Partial<ErrorSchema>, cause?: unknown);
875
+ }
876
+ interface HttpErrorLike extends Error {
877
+ status: number;
878
+ }
879
+ //#endregion
880
+ //#region ../alepha/src/server/providers/BunHttpServerProvider.d.ts
881
+ declare const envSchema$5: alepha139.TObject<{
882
+ SERVER_PORT: alepha139.TInteger;
883
+ SERVER_HOST: alepha139.TString;
884
+ }>;
885
+ declare module "alepha" {
886
+ interface Env extends Partial<Static<typeof envSchema$5>> {}
887
+ }
888
+ //#endregion
889
+ //#region ../alepha/src/server/providers/NodeHttpServerProvider.d.ts
890
+ declare const envSchema$4: alepha139.TObject<{
891
+ SERVER_PORT: alepha139.TInteger;
892
+ SERVER_HOST: alepha139.TString;
893
+ }>;
894
+ declare module "alepha" {
895
+ interface Env extends Partial<Static<typeof envSchema$4>> {}
896
+ }
897
+ //#endregion
898
+ //#region ../alepha/src/server/index.d.ts
899
+ declare module "alepha" {
900
+ interface State {
901
+ "alepha.node.server"?: Server;
902
+ }
903
+ interface Hooks {
904
+ "action:onRequest": {
905
+ action: ActionDescriptor<RequestConfigSchema>;
906
+ request: ServerRequest;
907
+ options: ClientRequestOptions;
908
+ };
909
+ "action:onResponse": {
910
+ action: ActionDescriptor<RequestConfigSchema>;
911
+ request: ServerRequest;
912
+ options: ClientRequestOptions;
913
+ response: any;
914
+ };
915
+ "server:onRequest": {
916
+ route: ServerRoute;
917
+ request: ServerRequest;
918
+ };
919
+ "server:onError": {
920
+ route: ServerRoute;
921
+ request: ServerRequest;
922
+ error: Error;
923
+ };
924
+ "server:onSend": {
925
+ route: ServerRoute;
926
+ request: ServerRequest;
927
+ };
928
+ "server:onResponse": {
929
+ route: ServerRoute;
930
+ request: ServerRequest;
931
+ response: ServerResponse$1;
932
+ };
933
+ "client:onRequest": {
934
+ route: HttpAction;
935
+ config: ServerRequestConfigEntry;
936
+ options: ClientRequestOptions;
937
+ headers: Record<string, string>;
938
+ request: RequestInit;
939
+ };
940
+ "client:beforeFetch": {
941
+ url: string;
942
+ options: FetchOptions;
943
+ request: RequestInit;
944
+ };
945
+ "client:onError": {
946
+ route?: HttpAction;
947
+ error: HttpError;
948
+ };
949
+ "node:request": NodeRequestEvent;
950
+ "web:request": WebRequestEvent;
951
+ }
952
+ }
953
+ //#endregion
954
+ //#region ../alepha/src/server-cache/providers/ServerCacheProvider.d.ts
955
+ declare module "alepha/server" {
956
+ interface ServerRoute {
957
+ /**
958
+ * Enable caching for this route.
959
+ * - If true: enables both store and etag
960
+ * - If object: fine-grained control over store, etag, and cache-control headers
961
+ *
962
+ * @default false
963
+ */
964
+ cache?: ServerRouteCache;
965
+ }
966
+ interface ActionDescriptor<TConfig extends RequestConfigSchema> {
967
+ invalidate: () => Promise<void>;
968
+ }
969
+ }
970
+ type ServerRouteCache =
971
+ /**
972
+ * If true, enables caching with:
973
+ * - store: true
974
+ * - etag: true
975
+ */
976
+ boolean
977
+ /**
978
+ * Object configuration for fine-grained cache control.
979
+ *
980
+ * If empty, no caching will be applied.
981
+ */ | {
982
+ /**
983
+ * If true, enables storing cached responses. (in-memory, Redis, @see alepha/cache for other providers)
984
+ * If a DurationLike is provided, it will be used as the TTL for the cache.
985
+ * If CacheDescriptorOptions is provided, it will be used to configure the cache storage.
986
+ *
987
+ * @default false
988
+ */
989
+ store?: true | DurationLike | CacheDescriptorOptions;
990
+ /**
991
+ * If true, enables ETag support for the cached responses.
992
+ */
993
+ etag?: true;
994
+ /**
995
+ * - If true, sets Cache-Control to "public, max-age=300" (5 minutes).
996
+ * - If string, sets Cache-Control to the provided value directly.
997
+ * - If object, configures Cache-Control directives.
998
+ */
999
+ control?: true
1000
+ /**
1001
+ * If string, sets Cache-Control to the provided value directly.
1002
+ */ | string
1003
+ /**
1004
+ * If object, configures Cache-Control directives.
1005
+ */ | {
1006
+ /**
1007
+ * Indicates that the response may be cached by any cache.
1008
+ */
1009
+ public?: boolean;
1010
+ /**
1011
+ * Indicates that the response is intended for a single user and must not be stored by a shared cache.
1012
+ */
1013
+ private?: boolean;
1014
+ /**
1015
+ * Forces caches to submit the request to the origin server for validation before releasing a cached copy.
1016
+ */
1017
+ noCache?: boolean;
1018
+ /**
1019
+ * Instructs caches not to store the response.
1020
+ */
1021
+ noStore?: boolean;
1022
+ /**
1023
+ * Maximum amount of time a resource is considered fresh.
1024
+ * Can be specified as a number (seconds) or as a DurationLike object.
1025
+ *
1026
+ * @example 300 // 5 minutes in seconds
1027
+ * @example { minutes: 5 } // 5 minutes
1028
+ * @example { hours: 1 } // 1 hour
1029
+ */
1030
+ maxAge?: number | DurationLike;
1031
+ /**
1032
+ * Overrides max-age for shared caches (e.g., CDNs).
1033
+ * Can be specified as a number (seconds) or as a DurationLike object.
1034
+ */
1035
+ sMaxAge?: number | DurationLike;
1036
+ /**
1037
+ * Indicates that once a resource becomes stale, caches must not use it without successful validation.
1038
+ */
1039
+ mustRevalidate?: boolean;
1040
+ /**
1041
+ * Similar to must-revalidate, but only for shared caches.
1042
+ */
1043
+ proxyRevalidate?: boolean;
1044
+ /**
1045
+ * Indicates that the response can be stored but must be revalidated before each use.
1046
+ */
1047
+ immutable?: boolean;
1048
+ };
1049
+ };
1050
+ //#endregion
15
1051
  //#region src/core/components/ClientOnly.d.ts
16
1052
  interface ClientOnlyProps {
17
1053
  fallback?: ReactNode;
@@ -41,14 +1077,14 @@ declare class Redirection extends Error {
41
1077
  }
42
1078
  //#endregion
43
1079
  //#region src/core/providers/ReactPageProvider.d.ts
44
- declare const envSchema$2: alepha7.TObject<{
45
- REACT_STRICT_MODE: alepha7.TBoolean;
1080
+ declare const envSchema$3: alepha139.TObject<{
1081
+ REACT_STRICT_MODE: alepha139.TBoolean;
46
1082
  }>;
47
1083
  declare module "alepha" {
48
- interface Env extends Partial<Static<typeof envSchema$2>> {}
1084
+ interface Env extends Partial<Static<typeof envSchema$3>> {}
49
1085
  }
50
1086
  declare class ReactPageProvider {
51
- protected readonly log: alepha_logger0.Logger;
1087
+ protected readonly log: Logger;
52
1088
  protected readonly env: {
53
1089
  REACT_STRICT_MODE: boolean;
54
1090
  };
@@ -85,7 +1121,7 @@ declare class ReactPageProvider {
85
1121
  }, params?: Record<string, any>): string;
86
1122
  compile(path: string, params?: Record<string, string>): string;
87
1123
  protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
88
- protected readonly configure: alepha7.HookDescriptor<"configure">;
1124
+ protected readonly configure: alepha139.HookDescriptor<"configure">;
89
1125
  protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
90
1126
  add(entry: PageRouteEntry): void;
91
1127
  protected createMatch(page: PageRoute): string;
@@ -220,7 +1256,7 @@ declare class ReactPageService {
220
1256
  * const userProfile = $page({
221
1257
  * path: "/users/:id",
222
1258
  * schema: {
223
- * params: t.object({ id: t.int() }),
1259
+ * params: t.object({ id: t.integer() }),
224
1260
  * query: t.object({ tab: t.optional(t.text()) })
225
1261
  * },
226
1262
  * resolve: async ({ params }) => {
@@ -494,23 +1530,265 @@ type CssAnimation = {
494
1530
  timing?: string;
495
1531
  };
496
1532
  //#endregion
1533
+ //#region ../alepha/src/security/schemas/userAccountInfoSchema.d.ts
1534
+ declare const userAccountInfoSchema: alepha139.TObject<{
1535
+ id: alepha139.TString;
1536
+ name: alepha139.TOptional<alepha139.TString>;
1537
+ email: alepha139.TOptional<alepha139.TString>;
1538
+ username: alepha139.TOptional<alepha139.TString>;
1539
+ picture: alepha139.TOptional<alepha139.TString>;
1540
+ sessionId: alepha139.TOptional<alepha139.TString>;
1541
+ organizations: alepha139.TOptional<alepha139.TArray<alepha139.TString>>;
1542
+ roles: alepha139.TOptional<alepha139.TArray<alepha139.TString>>;
1543
+ }>;
1544
+ type UserAccount = Static<typeof userAccountInfoSchema>;
1545
+ //#endregion
1546
+ //#region ../alepha/src/security/interfaces/UserAccountToken.d.ts
1547
+ /**
1548
+ * Add contextual metadata to a user account info.
1549
+ * E.g. UserAccountToken is a UserAccountInfo during a request.
1550
+ */
1551
+ interface UserAccountToken extends UserAccount {
1552
+ /**
1553
+ * Access token for the user.
1554
+ */
1555
+ token?: string;
1556
+ /**
1557
+ * Realm name of the user.
1558
+ */
1559
+ realm?: string;
1560
+ /**
1561
+ * Is user dedicated to his own resources for this scope ?
1562
+ * Mostly, Admin is false and Customer is true.
1563
+ */
1564
+ ownership?: string | boolean;
1565
+ }
1566
+ //#endregion
1567
+ //#region ../alepha/src/security/providers/SecurityProvider.d.ts
1568
+ declare const envSchema$2: alepha139.TObject<{
1569
+ APP_SECRET: alepha139.TString;
1570
+ }>;
1571
+ declare module "alepha" {
1572
+ interface Env extends Partial<Static<typeof envSchema$2>> {}
1573
+ }
1574
+ //#endregion
1575
+ //#region ../alepha/src/security/index.d.ts
1576
+ declare module "alepha" {
1577
+ interface Hooks {
1578
+ "security:user:created": {
1579
+ realm: string;
1580
+ user: UserAccount;
1581
+ };
1582
+ }
1583
+ }
1584
+ /**
1585
+ * Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
1586
+ *
1587
+ * The security module enables building secure applications using descriptors like `$realm`, `$role`, and `$permission`
1588
+ * on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
1589
+ * integration with various authentication providers and user management systems.
1590
+ *
1591
+ * @see {@link $realm}
1592
+ * @see {@link $role}
1593
+ * @see {@link $permission}
1594
+ * @module alepha.security
1595
+ */
1596
+ //#endregion
1597
+ //#region ../alepha/src/server-security/providers/ServerBasicAuthProvider.d.ts
1598
+ interface BasicAuthOptions {
1599
+ username: string;
1600
+ password: string;
1601
+ }
1602
+ //#endregion
1603
+ //#region ../alepha/src/server-security/providers/ServerSecurityProvider.d.ts
1604
+ type ServerRouteSecure = {
1605
+ realm?: string;
1606
+ basic?: BasicAuthOptions;
1607
+ };
1608
+ //#endregion
1609
+ //#region ../alepha/src/server-security/index.d.ts
1610
+ declare module "alepha" {
1611
+ interface State {
1612
+ /**
1613
+ * Real (or fake) user account, used for internal actions.
1614
+ *
1615
+ * If you define this, you assume that all actions are executed by this user by default.
1616
+ * > To force a different user, you need to pass it explicitly in the options.
1617
+ */
1618
+ "alepha.server.security.system.user"?: UserAccountToken;
1619
+ /**
1620
+ * The authenticated user account attached to the server request state.
1621
+ *
1622
+ * @internal
1623
+ */
1624
+ "alepha.server.request.user"?: UserAccount;
1625
+ }
1626
+ }
1627
+ declare module "alepha/server" {
1628
+ interface ServerRequest<TConfig> {
1629
+ user?: UserAccountToken;
1630
+ }
1631
+ interface ServerActionRequest<TConfig> {
1632
+ user: UserAccountToken;
1633
+ }
1634
+ interface ServerRoute {
1635
+ /**
1636
+ * If true, the route will be protected by the security provider.
1637
+ * All actions are secure by default, but you can disable it for specific actions.
1638
+ */
1639
+ secure?: boolean | ServerRouteSecure;
1640
+ }
1641
+ interface ClientRequestOptions extends FetchOptions {
1642
+ /**
1643
+ * Forward user from the previous request.
1644
+ * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
1645
+ * If "context", use the user from the current context (e.g. request).
1646
+ *
1647
+ * @default "system" if provided, else "context" if available.
1648
+ */
1649
+ user?: UserAccountToken | "system" | "context";
1650
+ }
1651
+ }
1652
+ /**
1653
+ * Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
1654
+ *
1655
+ * By default, all $action will be guarded by a permission check.
1656
+ *
1657
+ * @see {@link ServerSecurityProvider}
1658
+ * @module alepha.server.security
1659
+ */
1660
+ //#endregion
1661
+ //#region ../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
1662
+ declare const apiLinkSchema: alepha139.TObject<{
1663
+ name: alepha139.TString;
1664
+ group: alepha139.TOptional<alepha139.TString>;
1665
+ path: alepha139.TString;
1666
+ method: alepha139.TOptional<alepha139.TString>;
1667
+ requestBodyType: alepha139.TOptional<alepha139.TString>;
1668
+ service: alepha139.TOptional<alepha139.TString>;
1669
+ }>;
1670
+ declare const apiLinksResponseSchema: alepha139.TObject<{
1671
+ prefix: alepha139.TOptional<alepha139.TString>;
1672
+ links: alepha139.TArray<alepha139.TObject<{
1673
+ name: alepha139.TString;
1674
+ group: alepha139.TOptional<alepha139.TString>;
1675
+ path: alepha139.TString;
1676
+ method: alepha139.TOptional<alepha139.TString>;
1677
+ requestBodyType: alepha139.TOptional<alepha139.TString>;
1678
+ service: alepha139.TOptional<alepha139.TString>;
1679
+ }>>;
1680
+ }>;
1681
+ type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
1682
+ type ApiLink = Static<typeof apiLinkSchema>;
1683
+ //#endregion
1684
+ //#region ../alepha/src/server-links/providers/LinkProvider.d.ts
1685
+ /**
1686
+ * Browser, SSR friendly, service to handle links.
1687
+ */
1688
+ declare class LinkProvider {
1689
+ static path: {
1690
+ apiLinks: string;
1691
+ apiSchema: string;
1692
+ };
1693
+ protected readonly log: Logger;
1694
+ protected readonly alepha: Alepha;
1695
+ protected readonly httpClient: HttpClient;
1696
+ protected serverLinks: Array<HttpClientLink>;
1697
+ /**
1698
+ * Get applicative links registered on the server.
1699
+ * This does not include lazy-loaded remote links.
1700
+ */
1701
+ getServerLinks(): HttpClientLink[];
1702
+ /**
1703
+ * Register a new link for the application.
1704
+ */
1705
+ registerLink(link: HttpClientLink): void;
1706
+ get links(): HttpClientLink[];
1707
+ /**
1708
+ * Force browser to refresh links from the server.
1709
+ */
1710
+ fetchLinks(): Promise<HttpClientLink[]>;
1711
+ /**
1712
+ * Create a virtual client that can be used to call actions.
1713
+ *
1714
+ * Use js Proxy under the hood.
1715
+ */
1716
+ client<T$1 extends object>(scope?: ClientScope): HttpVirtualClient<T$1>;
1717
+ /**
1718
+ * Check if a link with the given name exists.
1719
+ * @param name
1720
+ */
1721
+ can(name: string): boolean;
1722
+ /**
1723
+ * Resolve a link by its name and call it.
1724
+ * - If link is local, it will call the local handler.
1725
+ * - If link is remote, it will make a fetch request to the remote server.
1726
+ */
1727
+ follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
1728
+ protected createVirtualAction<T$1 extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T$1>;
1729
+ protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
1730
+ protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
1731
+ }
1732
+ interface HttpClientLink extends ApiLink {
1733
+ secured?: boolean | ServerRouteSecure;
1734
+ prefix?: string;
1735
+ host?: string;
1736
+ service?: string;
1737
+ schema?: RequestConfigSchema;
1738
+ handler?: (request: ServerRequest, options: ClientRequestOptions) => Async<ServerResponseBody>;
1739
+ }
1740
+ interface ClientScope {
1741
+ group?: string;
1742
+ service?: string;
1743
+ hostname?: string;
1744
+ }
1745
+ type HttpVirtualClient<T$1> = { [K in keyof T$1 as T$1[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T$1[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
1746
+ interface VirtualAction<T$1 extends RequestConfigSchema> extends Pick<ActionDescriptor<T$1>, "name" | "run" | "fetch"> {
1747
+ (config?: ClientRequestEntry<T$1>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T$1>>;
1748
+ can: () => boolean;
1749
+ }
1750
+ //#endregion
1751
+ //#region ../alepha/src/server-links/index.d.ts
1752
+ declare module "alepha" {
1753
+ interface State {
1754
+ /**
1755
+ * API links attached to the server request state.
1756
+ *
1757
+ * @see {@link ApiLinksResponse}
1758
+ * @internal
1759
+ */
1760
+ "alepha.server.request.apiLinks"?: ApiLinksResponse;
1761
+ }
1762
+ }
1763
+ /**
1764
+ * Provides server-side link management and remote capabilities for client-server interactions.
1765
+ *
1766
+ * The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
1767
+ * facilitating seamless API endpoint management and client-server communication. It integrates with server
1768
+ * security features to ensure safe and controlled access to resources.
1769
+ *
1770
+ * @see {@link $remote}
1771
+ * @see {@link $client}
1772
+ * @module alepha.server.links
1773
+ */
1774
+ //#endregion
497
1775
  //#region src/core/providers/ReactBrowserRouterProvider.d.ts
498
1776
  interface BrowserRoute extends Route {
499
1777
  page: PageRoute;
500
1778
  }
501
1779
  declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
502
- protected readonly log: alepha_logger0.Logger;
1780
+ protected readonly log: Logger;
503
1781
  protected readonly alepha: Alepha;
504
1782
  protected readonly pageApi: ReactPageProvider;
505
1783
  add(entry: PageRouteEntry): void;
506
- protected readonly configure: alepha7.HookDescriptor<"configure">;
1784
+ protected readonly configure: alepha139.HookDescriptor<"configure">;
507
1785
  transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
508
1786
  root(state: ReactRouterState): ReactNode;
509
1787
  }
510
1788
  //#endregion
511
1789
  //#region src/core/providers/ReactBrowserProvider.d.ts
512
- declare const envSchema$1: alepha7.TObject<{
513
- REACT_ROOT_ID: alepha7.TString;
1790
+ declare const envSchema$1: alepha139.TObject<{
1791
+ REACT_ROOT_ID: alepha139.TString;
514
1792
  }>;
515
1793
  declare module "alepha" {
516
1794
  interface Env extends Partial<Static<typeof envSchema$1>> {}
@@ -518,8 +1796,8 @@ declare module "alepha" {
518
1796
  /**
519
1797
  * React browser renderer configuration atom
520
1798
  */
521
- declare const reactBrowserOptions: alepha7.Atom<alepha7.TObject<{
522
- scrollRestoration: typebox0.TUnsafe<"top" | "manual">;
1799
+ declare const reactBrowserOptions: alepha139.Atom<alepha139.TObject<{
1800
+ scrollRestoration: alepha139.TUnsafe<"top" | "manual">;
523
1801
  }>, "alepha.react.browser.options">;
524
1802
  type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
525
1803
  declare module "alepha" {
@@ -531,7 +1809,7 @@ declare class ReactBrowserProvider {
531
1809
  protected readonly env: {
532
1810
  REACT_ROOT_ID: string;
533
1811
  };
534
- protected readonly log: alepha_logger0.Logger;
1812
+ protected readonly log: Logger;
535
1813
  protected readonly client: LinkProvider;
536
1814
  protected readonly alepha: Alepha;
537
1815
  protected readonly router: ReactBrowserRouterProvider;
@@ -567,8 +1845,8 @@ declare class ReactBrowserProvider {
567
1845
  * Get embedded layers from the server.
568
1846
  */
569
1847
  protected getHydrationState(): ReactHydrationState | undefined;
570
- protected readonly onTransitionEnd: alepha7.HookDescriptor<"react:transition:end">;
571
- readonly ready: alepha7.HookDescriptor<"ready">;
1848
+ protected readonly onTransitionEnd: alepha139.HookDescriptor<"react:transition:end">;
1849
+ readonly ready: alepha139.HookDescriptor<"ready">;
572
1850
  }
573
1851
  interface RouterGoOptions {
574
1852
  replace?: boolean;
@@ -578,97 +1856,22 @@ interface RouterGoOptions {
578
1856
  meta?: Record<string, any>;
579
1857
  /**
580
1858
  * Recreate the whole page, ignoring the current state.
581
- */
582
- force?: boolean;
583
- }
584
- type ReactHydrationState = {
585
- layers?: Array<PreviousLayerData>;
586
- } & {
587
- [key: string]: any;
588
- };
589
- interface RouterRenderOptions {
590
- url?: string;
591
- previous?: PreviousLayerData[];
592
- meta?: Record<string, any>;
593
- }
594
- //#endregion
595
- //#region src/core/components/ErrorBoundary.d.ts
596
- /**
597
- * Props for the ErrorBoundary component.
598
- */
599
- interface ErrorBoundaryProps {
600
- /**
601
- * Fallback React node to render when an error is caught.
602
- * If not provided, a default error message will be shown.
603
- */
604
- fallback: (error: Error) => ReactNode;
605
- /**
606
- * Optional callback that receives the error and error info.
607
- * Use this to log errors to a monitoring service.
608
- */
609
- onError?: (error: Error, info: ErrorInfo) => void;
610
- }
611
- /**
612
- * State of the ErrorBoundary component.
613
- */
614
- interface ErrorBoundaryState {
615
- error?: Error;
616
- }
617
- /**
618
- * A reusable error boundary for catching rendering errors
619
- * in any part of the React component tree.
620
- */
621
- declare class ErrorBoundary extends React.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
622
- constructor(props: ErrorBoundaryProps);
623
- /**
624
- * Update state so the next render shows the fallback UI.
625
- */
626
- static getDerivedStateFromError(error: Error): ErrorBoundaryState;
627
- /**
628
- * Lifecycle method called when an error is caught.
629
- * You can log the error or perform side effects here.
630
- */
631
- componentDidCatch(error: Error, info: ErrorInfo): void;
632
- render(): ReactNode;
633
- }
634
- //#endregion
635
- //#region src/core/components/ErrorViewer.d.ts
636
- interface ErrorViewerProps {
637
- error: Error;
638
- alepha: Alepha;
639
- }
640
- declare const ErrorViewer: ({
641
- error,
642
- alepha
643
- }: ErrorViewerProps) => react_jsx_runtime0.JSX.Element;
644
- //#endregion
645
- //#region src/core/components/Link.d.ts
646
- interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
647
- href: string;
1859
+ */
1860
+ force?: boolean;
648
1861
  }
649
- declare const Link: (props: LinkProps) => react_jsx_runtime0.JSX.Element;
650
- //#endregion
651
- //#region src/core/components/NestedView.d.ts
652
- interface NestedViewProps {
653
- children?: ReactNode;
654
- errorBoundary?: false | ((error: Error) => ReactNode);
1862
+ type ReactHydrationState = {
1863
+ layers?: Array<PreviousLayerData>;
1864
+ } & {
1865
+ [key: string]: any;
1866
+ };
1867
+ interface RouterRenderOptions {
1868
+ url?: string;
1869
+ previous?: PreviousLayerData[];
1870
+ meta?: Record<string, any>;
655
1871
  }
656
- declare const _default: react0.MemoExoticComponent<(props: NestedViewProps) => react_jsx_runtime0.JSX.Element>;
657
- //#endregion
658
- //#region src/core/components/NotFound.d.ts
659
- declare function NotFoundPage(props: {
660
- style?: CSSProperties;
661
- }): react_jsx_runtime0.JSX.Element;
662
1872
  //#endregion
663
1873
  //#region src/core/contexts/AlephaContext.d.ts
664
- declare const AlephaContext: react0.Context<Alepha | undefined>;
665
- //#endregion
666
- //#region src/core/contexts/RouterLayerContext.d.ts
667
- interface RouterLayerContextValue {
668
- index: number;
669
- path: string;
670
- }
671
- declare const RouterLayerContext: react0.Context<RouterLayerContextValue | undefined>;
1874
+ declare const AlephaContext: react1.Context<Alepha | undefined>;
672
1875
  //#endregion
673
1876
  //#region src/core/hooks/useAction.d.ts
674
1877
  /**
@@ -900,18 +2103,6 @@ interface UseActionReturn<Args extends any[], Result> {
900
2103
  cancel: () => void;
901
2104
  }
902
2105
  //#endregion
903
- //#region src/core/hooks/useActive.d.ts
904
- interface UseActiveOptions {
905
- href: string;
906
- startWith?: boolean;
907
- }
908
- declare const useActive: (args: string | UseActiveOptions) => UseActiveHook;
909
- interface UseActiveHook {
910
- isActive: boolean;
911
- anchorProps: AnchorProps;
912
- isPending: boolean;
913
- }
914
- //#endregion
915
2106
  //#region src/core/hooks/useAlepha.d.ts
916
2107
  /**
917
2108
  * Main Alepha hook.
@@ -969,6 +2160,113 @@ type UseEvents = { [T in keyof Hooks]?: Hook<T> | ((payload: Hooks[T]) => Async<
969
2160
  */
970
2161
  declare const useInject: <T$1 extends object>(service: Service<T$1>) => T$1;
971
2162
  //#endregion
2163
+ //#region src/core/hooks/useSchema.d.ts
2164
+ declare const useSchema: <TConfig extends RequestConfigSchema>(action: VirtualAction<TConfig>) => UseSchemaReturn<TConfig>;
2165
+ type UseSchemaReturn<TConfig extends RequestConfigSchema> = TConfig & {
2166
+ loading: boolean;
2167
+ };
2168
+ /**
2169
+ * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
2170
+ */
2171
+ declare const ssrSchemaLoading: (alepha: Alepha, name: string) => RequestConfigSchema | {
2172
+ loading: boolean;
2173
+ };
2174
+ //#endregion
2175
+ //#region src/core/hooks/useStore.d.ts
2176
+ /**
2177
+ * Hook to access and mutate the Alepha state.
2178
+ */
2179
+ declare function useStore<T$1 extends TAtomObject>(target: Atom<T$1>, defaultValue?: Static<T$1>): UseStoreReturn<Static<T$1>>;
2180
+ declare function useStore<Key extends keyof State>(target: Key, defaultValue?: State[Key]): UseStoreReturn<State[Key]>;
2181
+ type UseStoreReturn<T$1> = [T$1, (value: T$1) => void];
2182
+ //#endregion
2183
+ //#region src/core/components/ErrorBoundary.d.ts
2184
+ /**
2185
+ * Props for the ErrorBoundary component.
2186
+ */
2187
+ interface ErrorBoundaryProps {
2188
+ /**
2189
+ * Fallback React node to render when an error is caught.
2190
+ * If not provided, a default error message will be shown.
2191
+ */
2192
+ fallback: (error: Error) => ReactNode;
2193
+ /**
2194
+ * Optional callback that receives the error and error info.
2195
+ * Use this to log errors to a monitoring service.
2196
+ */
2197
+ onError?: (error: Error, info: ErrorInfo) => void;
2198
+ }
2199
+ /**
2200
+ * State of the ErrorBoundary component.
2201
+ */
2202
+ interface ErrorBoundaryState {
2203
+ error?: Error;
2204
+ }
2205
+ /**
2206
+ * A reusable error boundary for catching rendering errors
2207
+ * in any part of the React component tree.
2208
+ */
2209
+ declare class ErrorBoundary extends React.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
2210
+ constructor(props: ErrorBoundaryProps);
2211
+ /**
2212
+ * Update state so the next render shows the fallback UI.
2213
+ */
2214
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
2215
+ /**
2216
+ * Lifecycle method called when an error is caught.
2217
+ * You can log the error or perform side effects here.
2218
+ */
2219
+ componentDidCatch(error: Error, info: ErrorInfo): void;
2220
+ render(): ReactNode;
2221
+ }
2222
+ //#endregion
2223
+ //#region src/core/components/ErrorViewer.d.ts
2224
+ interface ErrorViewerProps {
2225
+ error: Error;
2226
+ alepha: Alepha;
2227
+ }
2228
+ declare const ErrorViewer: ({
2229
+ error,
2230
+ alepha
2231
+ }: ErrorViewerProps) => react_jsx_runtime0.JSX.Element;
2232
+ //#endregion
2233
+ //#region src/core/components/Link.d.ts
2234
+ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
2235
+ href: string;
2236
+ }
2237
+ declare const Link: (props: LinkProps) => react_jsx_runtime0.JSX.Element;
2238
+ //#endregion
2239
+ //#region src/core/components/NestedView.d.ts
2240
+ interface NestedViewProps {
2241
+ children?: ReactNode;
2242
+ errorBoundary?: false | ((error: Error) => ReactNode);
2243
+ }
2244
+ declare const _default: react1.MemoExoticComponent<(props: NestedViewProps) => react_jsx_runtime0.JSX.Element>;
2245
+ //#endregion
2246
+ //#region src/core/components/NotFound.d.ts
2247
+ declare function NotFoundPage(props: {
2248
+ style?: CSSProperties;
2249
+ }): react_jsx_runtime0.JSX.Element;
2250
+ //#endregion
2251
+ //#region src/core/contexts/RouterLayerContext.d.ts
2252
+ interface RouterLayerContextValue {
2253
+ index: number;
2254
+ path: string;
2255
+ }
2256
+ declare const RouterLayerContext: react1.Context<RouterLayerContextValue | undefined>;
2257
+ //#endregion
2258
+ //#region src/core/hooks/useActive.d.ts
2259
+ interface UseActiveOptions {
2260
+ href: string;
2261
+ startWith?: boolean;
2262
+ }
2263
+ declare const useActive: (args: string | UseActiveOptions) => UseActiveHook;
2264
+ interface UseActiveHook {
2265
+ isActive: boolean;
2266
+ anchorProps: AnchorProps;
2267
+ isPending: boolean;
2268
+ }
2269
+ //#endregion
972
2270
  //#region src/core/hooks/useQueryParams.d.ts
973
2271
  /**
974
2272
  * Not well tested. Use with caution.
@@ -991,7 +2289,7 @@ declare class ReactRouter<T$1 extends object> {
991
2289
  isActive(href: string, options?: {
992
2290
  startWith?: boolean;
993
2291
  }): boolean;
994
- path(name: keyof VirtualRouter<T$1>, config?: {
2292
+ path(name: keyof VirtualRouter<T$1> | string, config?: {
995
2293
  params?: Record<string, any>;
996
2294
  query?: Record<string, any>;
997
2295
  }): string;
@@ -1048,31 +2346,233 @@ declare const useRouter: <T$1 extends object = any>() => ReactRouter<T$1>;
1048
2346
  //#region src/core/hooks/useRouterState.d.ts
1049
2347
  declare const useRouterState: () => ReactRouterState;
1050
2348
  //#endregion
1051
- //#region src/core/hooks/useSchema.d.ts
1052
- declare const useSchema: <TConfig extends RequestConfigSchema>(action: VirtualAction<TConfig>) => UseSchemaReturn<TConfig>;
1053
- type UseSchemaReturn<TConfig extends RequestConfigSchema> = TConfig & {
1054
- loading: boolean;
1055
- };
1056
- /**
1057
- * Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
1058
- */
1059
- declare const ssrSchemaLoading: (alepha: Alepha, name: string) => RequestConfigSchema | {
1060
- loading: boolean;
1061
- };
2349
+ //#region ../alepha/src/server-static/descriptors/$serve.d.ts
2350
+ interface ServeDescriptorOptions {
2351
+ /**
2352
+ * Prefix for the served path.
2353
+ *
2354
+ * @default "/"
2355
+ */
2356
+ path?: string;
2357
+ /**
2358
+ * Path to the directory to serve.
2359
+ *
2360
+ * @default process.cwd()
2361
+ */
2362
+ root?: string;
2363
+ /**
2364
+ * If true, descriptor will be ignored.
2365
+ *
2366
+ * @default false
2367
+ */
2368
+ disabled?: boolean;
2369
+ /**
2370
+ * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
2371
+ *
2372
+ * @default true
2373
+ */
2374
+ ignoreDotEnvFiles?: boolean;
2375
+ /**
2376
+ * Whether to use the index.html file when the path is a directory.
2377
+ *
2378
+ * @default true
2379
+ */
2380
+ indexFallback?: boolean;
2381
+ /**
2382
+ * Force all requests "not found" to be served with the index.html file.
2383
+ * This is useful for single-page applications (SPAs) that use client-side only routing.
2384
+ */
2385
+ historyApiFallback?: boolean;
2386
+ /**
2387
+ * Optional name of the descriptor.
2388
+ * This is used for logging and debugging purposes.
2389
+ *
2390
+ * @default Key name.
2391
+ */
2392
+ name?: string;
2393
+ /**
2394
+ * Whether to use cache control headers.
2395
+ *
2396
+ * @default {}
2397
+ */
2398
+ cacheControl?: Partial<CacheControlOptions> | false;
2399
+ }
2400
+ interface CacheControlOptions {
2401
+ /**
2402
+ * Whether to use cache control headers.
2403
+ *
2404
+ * @default [.js, .css]
2405
+ */
2406
+ fileTypes: string[];
2407
+ /**
2408
+ * The maximum age of the cache in seconds.
2409
+ *
2410
+ * @default 60 * 60 * 24 * 2 // 2 days
2411
+ */
2412
+ maxAge: DurationLike;
2413
+ /**
2414
+ * Whether to use immutable cache control headers.
2415
+ *
2416
+ * @default true
2417
+ */
2418
+ immutable: boolean;
2419
+ }
1062
2420
  //#endregion
1063
- //#region src/core/hooks/useStore.d.ts
2421
+ //#region ../alepha/src/file/services/FileDetector.d.ts
2422
+ interface FileTypeResult {
2423
+ /**
2424
+ * The detected MIME type
2425
+ */
2426
+ mimeType: string;
2427
+ /**
2428
+ * The detected file extension
2429
+ */
2430
+ extension: string;
2431
+ /**
2432
+ * Whether the file type was verified by magic bytes
2433
+ */
2434
+ verified: boolean;
2435
+ /**
2436
+ * The stream (potentially wrapped to allow re-reading)
2437
+ */
2438
+ stream: Readable;
2439
+ }
1064
2440
  /**
1065
- * Hook to access and mutate the Alepha state.
2441
+ * Service for detecting file types and getting content types.
2442
+ *
2443
+ * @example
2444
+ * ```typescript
2445
+ * const detector = alepha.inject(FileDetector);
2446
+ *
2447
+ * // Get content type from filename
2448
+ * const mimeType = detector.getContentType("image.png"); // "image/png"
2449
+ *
2450
+ * // Detect file type by magic bytes
2451
+ * const stream = createReadStream('image.png');
2452
+ * const result = await detector.detectFileType(stream, 'image.png');
2453
+ * console.log(result.mimeType); // 'image/png'
2454
+ * console.log(result.verified); // true if magic bytes match
2455
+ * ```
1066
2456
  */
1067
- declare function useStore<T$1 extends TAtomObject>(target: Atom<T$1>, defaultValue?: Static<T$1>): UseStoreReturn<Static<T$1>>;
1068
- declare function useStore<Key extends keyof State>(target: Key, defaultValue?: State[Key]): UseStoreReturn<State[Key]>;
1069
- type UseStoreReturn<T$1> = [T$1, (value: T$1) => void];
2457
+ declare class FileDetector {
2458
+ /**
2459
+ * Magic byte signatures for common file formats.
2460
+ * Each signature is represented as an array of bytes or null (wildcard).
2461
+ */
2462
+ protected static readonly MAGIC_BYTES: Record<string, {
2463
+ signature: (number | null)[];
2464
+ mimeType: string;
2465
+ }[]>;
2466
+ /**
2467
+ * All possible format signatures for checking against actual file content
2468
+ */
2469
+ protected static readonly ALL_SIGNATURES: {
2470
+ signature: (number | null)[];
2471
+ mimeType: string;
2472
+ ext: string;
2473
+ }[];
2474
+ /**
2475
+ * MIME type map for file extensions.
2476
+ *
2477
+ * Can be used to get the content type of file based on its extension.
2478
+ * Feel free to add more mime types in your project!
2479
+ */
2480
+ static readonly mimeMap: Record<string, string>;
2481
+ /**
2482
+ * Reverse MIME type map for looking up extensions from MIME types.
2483
+ * Prefers shorter, more common extensions when multiple exist.
2484
+ */
2485
+ protected static readonly reverseMimeMap: Record<string, string>;
2486
+ /**
2487
+ * Returns the file extension for a given MIME type.
2488
+ *
2489
+ * @param mimeType - The MIME type to look up
2490
+ * @returns The file extension (without dot), or "bin" if not found
2491
+ *
2492
+ * @example
2493
+ * ```typescript
2494
+ * const detector = alepha.inject(FileDetector);
2495
+ * const ext = detector.getExtensionFromMimeType("image/png"); // "png"
2496
+ * const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
2497
+ * ```
2498
+ */
2499
+ getExtensionFromMimeType(mimeType: string): string;
2500
+ /**
2501
+ * Returns the content type of file based on its filename.
2502
+ *
2503
+ * @param filename - The filename to check
2504
+ * @returns The MIME type
2505
+ *
2506
+ * @example
2507
+ * ```typescript
2508
+ * const detector = alepha.inject(FileDetector);
2509
+ * const mimeType = detector.getContentType("image.png"); // "image/png"
2510
+ * ```
2511
+ */
2512
+ getContentType(filename: string): string;
2513
+ /**
2514
+ * Detects the file type by checking magic bytes against the stream content.
2515
+ *
2516
+ * @param stream - The readable stream to check
2517
+ * @param filename - The filename (used to get the extension)
2518
+ * @returns File type information including MIME type, extension, and verification status
2519
+ *
2520
+ * @example
2521
+ * ```typescript
2522
+ * const detector = alepha.inject(FileDetector);
2523
+ * const stream = createReadStream('image.png');
2524
+ * const result = await detector.detectFileType(stream, 'image.png');
2525
+ * console.log(result.mimeType); // 'image/png'
2526
+ * console.log(result.verified); // true if magic bytes match
2527
+ * ```
2528
+ */
2529
+ detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
2530
+ /**
2531
+ * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
2532
+ * This approach reads the entire stream upfront to avoid complex async handling issues.
2533
+ *
2534
+ * @protected
2535
+ */
2536
+ protected peekBytes(stream: Readable, numBytes: number): Promise<{
2537
+ buffer: Buffer;
2538
+ stream: Readable;
2539
+ }>;
2540
+ /**
2541
+ * Checks if a buffer matches a magic byte signature.
2542
+ *
2543
+ * @protected
2544
+ */
2545
+ protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
2546
+ }
2547
+ //#endregion
2548
+ //#region ../alepha/src/server-static/providers/ServerStaticProvider.d.ts
2549
+ declare class ServerStaticProvider {
2550
+ protected readonly alepha: Alepha;
2551
+ protected readonly routerProvider: ServerRouterProvider;
2552
+ protected readonly dateTimeProvider: DateTimeProvider;
2553
+ protected readonly fileDetector: FileDetector;
2554
+ protected readonly log: Logger;
2555
+ protected readonly directories: ServeDirectory[];
2556
+ protected readonly configure: alepha139.HookDescriptor<"configure">;
2557
+ createStaticServer(options: ServeDescriptorOptions): Promise<void>;
2558
+ createFileHandler(filepath: string, options: ServeDescriptorOptions): Promise<ServerHandler>;
2559
+ protected getCacheFileTypes(): string[];
2560
+ protected getCacheControl(filename: string, options: ServeDescriptorOptions): {
2561
+ maxAge: number;
2562
+ immutable: boolean;
2563
+ } | undefined;
2564
+ getAllFiles(dir: string, ignoreDotEnvFiles?: boolean): Promise<string[]>;
2565
+ }
2566
+ interface ServeDirectory {
2567
+ options: ServeDescriptorOptions;
2568
+ files: string[];
2569
+ }
1070
2570
  //#endregion
1071
2571
  //#region src/core/providers/ReactServerProvider.d.ts
1072
- declare const envSchema: alepha7.TObject<{
1073
- REACT_SSR_ENABLED: alepha7.TOptional<alepha7.TBoolean>;
1074
- REACT_ROOT_ID: alepha7.TString;
1075
- REACT_SERVER_TEMPLATE: alepha7.TOptional<alepha7.TString>;
2572
+ declare const envSchema: alepha139.TObject<{
2573
+ REACT_SSR_ENABLED: alepha139.TOptional<alepha139.TBoolean>;
2574
+ REACT_ROOT_ID: alepha139.TString;
2575
+ REACT_SERVER_TEMPLATE: alepha139.TOptional<alepha139.TString>;
1076
2576
  }>;
1077
2577
  declare module "alepha" {
1078
2578
  interface Env extends Partial<Static<typeof envSchema>> {}
@@ -1083,11 +2583,11 @@ declare module "alepha" {
1083
2583
  /**
1084
2584
  * React server provider configuration atom
1085
2585
  */
1086
- declare const reactServerOptions: alepha7.Atom<alepha7.TObject<{
1087
- publicDir: alepha7.TString;
1088
- staticServer: alepha7.TObject<{
1089
- disabled: alepha7.TBoolean;
1090
- path: alepha7.TString;
2586
+ declare const reactServerOptions: alepha139.Atom<alepha139.TObject<{
2587
+ publicDir: alepha139.TString;
2588
+ staticServer: alepha139.TObject<{
2589
+ disabled: alepha139.TBoolean;
2590
+ path: alepha139.TString;
1091
2591
  }>;
1092
2592
  }>, "alepha.react.server.options">;
1093
2593
  type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
@@ -1097,7 +2597,7 @@ declare module "alepha" {
1097
2597
  }
1098
2598
  }
1099
2599
  declare class ReactServerProvider {
1100
- protected readonly log: alepha_logger0.Logger;
2600
+ protected readonly log: Logger;
1101
2601
  protected readonly alepha: Alepha;
1102
2602
  protected readonly env: {
1103
2603
  REACT_SSR_ENABLED?: boolean | undefined;
@@ -1121,7 +2621,7 @@ declare class ReactServerProvider {
1121
2621
  /**
1122
2622
  * Configure the React server provider.
1123
2623
  */
1124
- readonly onConfigure: alepha7.HookDescriptor<"configure">;
2624
+ readonly onConfigure: alepha139.HookDescriptor<"configure">;
1125
2625
  get template(): string;
1126
2626
  protected registerPages(templateLoader: TemplateLoader): Promise<void>;
1127
2627
  /**
@@ -1257,7 +2757,7 @@ declare module "alepha" {
1257
2757
  * @see {@link $page}
1258
2758
  * @module alepha.react
1259
2759
  */
1260
- declare const AlephaReact: alepha7.Service<alepha7.Module>;
2760
+ declare const AlephaReact: alepha139.Service<alepha139.Module>;
1261
2761
  //#endregion
1262
2762
  export { $page, ActionContext, AlephaContext, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, ErrorHandler, ErrorViewer, Layer, Link, type LinkProps, _default as NestedView, NotFoundPage as NotFound, PageAnimation, PageConfigSchema, PageDescriptor, PageDescriptorOptions, PageDescriptorRenderOptions, PageDescriptorRenderResult, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactRouter, ReactRouterState, ReactServerProvider, ReactServerProviderOptions, Redirection, RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActionOptions, UseActionReturn, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, UseSchemaReturn, UseStoreReturn, VirtualRouter, isPageRoute, reactBrowserOptions, reactServerOptions, ssrSchemaLoading, useAction, useActive, useAlepha, useClient, useEvents, useInject, useQueryParams, useRouter, useRouterState, useSchema, useStore };
1263
2763
  //# sourceMappingURL=index.d.cts.map