@alepha/react 0.13.7 → 0.14.0

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.
@@ -1,1053 +1,18 @@
1
- import * as alepha44 from "alepha";
2
- import { Alepha, AlephaError, Async, Atom, FileLike, Hook, Hooks, InstantiableClass, KIND, LogLevel, LoggerInterface, Primitive, Service, State, Static, StreamLike, TArray, TAtomObject, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
1
+ import * as alepha19 from "alepha";
2
+ import { Alepha, Async, Atom, Hook, Hooks, KIND, Primitive, Service, State, Static, TAtomObject, TObject, TSchema } from "alepha";
3
+ import { DateTimeProvider, DurationLike } from "alepha/datetime";
4
+ import * as alepha_server0 from "alepha/server";
5
+ import { RequestConfigSchema, ServerHandler, ServerProvider, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
6
+ import * as alepha_server_cache0 from "alepha/server/cache";
7
+ import { ServerRouteCache } from "alepha/server/cache";
8
+ import { ClientScope, HttpVirtualClient, LinkProvider, VirtualAction } from "alepha/server/links";
9
+ import * as alepha_logger1 from "alepha/logger";
3
10
  import * as react0 from "react";
4
11
  import React, { AnchorHTMLAttributes, CSSProperties, DependencyList, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
5
12
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
- import { IncomingMessage, Server, ServerResponse } from "node:http";
7
- import { Readable } from "node:stream";
8
- import { ReadableStream } from "node:stream/web";
9
- import dayjsDuration from "dayjs/plugin/duration.js";
10
- import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
13
+ import { ServerStaticProvider } from "alepha/server/static";
14
+ import { Route, RouterProvider } from "alepha/router";
11
15
 
12
- //#region ../../../alepha/src/server/schemas/errorSchema.d.ts
13
- declare const errorSchema: alepha44.TObject<{
14
- error: alepha44.TString;
15
- status: alepha44.TInteger;
16
- message: alepha44.TString;
17
- details: alepha44.TOptional<alepha44.TString>;
18
- requestId: alepha44.TOptional<alepha44.TString>;
19
- cause: alepha44.TOptional<alepha44.TObject<{
20
- name: alepha44.TString;
21
- message: alepha44.TString;
22
- }>>;
23
- }>;
24
- type ErrorSchema = Static<typeof errorSchema>;
25
- //#endregion
26
- //#region ../../../alepha/src/server/errors/HttpError.d.ts
27
- declare class HttpError extends AlephaError {
28
- name: string;
29
- static is: (error: unknown, status?: number) => error is HttpErrorLike;
30
- static toJSON(error: HttpError): ErrorSchema;
31
- readonly error: string;
32
- readonly status: number;
33
- readonly requestId?: string;
34
- readonly details?: string;
35
- readonly reason?: {
36
- name: string;
37
- message: string;
38
- };
39
- constructor(options: Partial<ErrorSchema>, cause?: unknown);
40
- }
41
- interface HttpErrorLike extends Error {
42
- status: number;
43
- }
44
- //#endregion
45
- //#region ../../../alepha/src/router/providers/RouterProvider.d.ts
46
- declare abstract class RouterProvider<T$1 extends Route = Route> {
47
- protected routePathRegex: RegExp;
48
- protected tree: Tree<T$1>;
49
- protected cache: Map<string, RouteMatch<T$1>>;
50
- match(path: string): RouteMatch<T$1>;
51
- protected test(path: string): void;
52
- protected push(route: T$1): void;
53
- protected createRouteMatch(path: string): RouteMatch<T$1>;
54
- protected mapParams(match: RouteMatch<T$1>): RouteMatch<T$1>;
55
- protected createParts(path: string): string[];
56
- }
57
- interface RouteMatch<T$1 extends Route> {
58
- route?: T$1;
59
- params?: Record<string, string>;
60
- }
61
- interface Route {
62
- path: string;
63
- /**
64
- * Rename a param in the route.
65
- * This is automatically filled when you have scenarios like:
66
- * `/customers/:id` and `/customers/:userId/payments`
67
- *
68
- * In this case, `:id` will be renamed to `:userId` in the second route.
69
- */
70
- mapParams?: Record<string, string>;
71
- }
72
- interface Tree<T$1 extends Route> {
73
- route?: T$1;
74
- children: {
75
- [key: string]: Tree<T$1>;
76
- };
77
- param?: {
78
- route?: T$1;
79
- name: string;
80
- children: {
81
- [key: string]: Tree<T$1>;
82
- };
83
- };
84
- wildcard?: {
85
- route: T$1;
86
- };
87
- }
88
- //#endregion
89
- //#region ../../../alepha/src/server/constants/routeMethods.d.ts
90
- declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
91
- type RouteMethod = (typeof routeMethods)[number];
92
- //#endregion
93
- //#region ../../../alepha/src/server/helpers/ServerReply.d.ts
94
- /**
95
- * Helper for building server replies.
96
- */
97
- declare class ServerReply {
98
- headers: Record<string, string> & {
99
- "set-cookie"?: string[];
100
- };
101
- status?: number;
102
- body?: any;
103
- /**
104
- * Redirect to a given URL with optional status code (default 302).
105
- */
106
- redirect(url: string, status?: number): void;
107
- /**
108
- * Set the response status code.
109
- */
110
- setStatus(status: number): this;
111
- /**
112
- * Set a response header.
113
- */
114
- setHeader(name: string, value: string): this;
115
- /**
116
- * Set the response body.
117
- */
118
- setBody(body: any): this;
119
- }
120
- //#endregion
121
- //#region ../../../alepha/src/server/services/UserAgentParser.d.ts
122
- interface UserAgentInfo {
123
- os: "Windows" | "Android" | "Ubuntu" | "MacOS" | "iOS" | "Linux" | "FreeBSD" | "OpenBSD" | "ChromeOS" | "BlackBerry" | "Symbian" | "Windows Phone";
124
- browser: "Chrome" | "Firefox" | "Safari" | "Edge" | "Opera" | "Internet Explorer" | "Brave" | "Vivaldi" | "Samsung Browser" | "UC Browser" | "Yandex";
125
- device: "MOBILE" | "DESKTOP" | "TABLET";
126
- }
127
- /**
128
- * Simple User-Agent parser to detect OS, browser, and device type.
129
- * This parser is not exhaustive and may not cover all edge cases.
130
- *
131
- * Use result for non
132
- */
133
- declare class UserAgentParser {
134
- parse(userAgent?: string): UserAgentInfo;
135
- }
136
- //#endregion
137
- //#region ../../../alepha/src/server/interfaces/ServerRequest.d.ts
138
- type TRequestBody = TObject | TString | TArray | TRecord | TStream;
139
- type TResponseBody = TObject | TString | TRecord | TFile | TArray | TStream | TVoid;
140
- interface RequestConfigSchema {
141
- body?: TRequestBody;
142
- params?: TObject;
143
- query?: TObject;
144
- headers?: TObject;
145
- response?: TResponseBody;
146
- }
147
- interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
148
- body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
149
- headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
150
- params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
151
- query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
152
- }
153
- type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
154
- interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
155
- /**
156
- * HTTP method used for this request.
157
- */
158
- method: RouteMethod;
159
- /**
160
- * Full request URL.
161
- */
162
- url: URL;
163
- /**
164
- * Unique request ID assigned to this request.
165
- */
166
- requestId: string;
167
- /**
168
- * Client IP address.
169
- * Will parse `X-Forwarded-For` header if present.
170
- */
171
- ip?: string;
172
- /**
173
- * Value of the `Host` header sent by the client.
174
- */
175
- host?: string;
176
- /**
177
- * Browser user agent information.
178
- * Information are not guaranteed to be accurate. Use with caution.
179
- *
180
- * @see {@link UserAgentParser}
181
- */
182
- userAgent: UserAgentInfo;
183
- /**
184
- * Arbitrary metadata attached to the request. Can be used by middlewares to store information.
185
- */
186
- metadata: Record<string, any>;
187
- /**
188
- * Reply object to be used to send response.
189
- */
190
- reply: ServerReply;
191
- /**
192
- * The raw underlying request object (Web Request).
193
- */
194
- raw: ServerRawRequest;
195
- }
196
- interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
197
- /**
198
- * Handler function for this route.
199
- */
200
- handler: ServerHandler<TConfig>;
201
- /**
202
- * HTTP method for this route.
203
- */
204
- method?: RouteMethod;
205
- /**
206
- * Request/response schema for this route.
207
- *
208
- * Request schema contains:
209
- * - body, for POST/PUT/PATCH requests
210
- * - params, for URL parameters (e.g. /user/:id)
211
- * - query, for URL query parameters (e.g. /user?id=123)
212
- * - headers, for HTTP headers
213
- *
214
- * Response schema contains:
215
- * - response
216
- *
217
- * Response schema is used to validate and serialize the response sent by the handler.
218
- */
219
- schema?: TConfig;
220
- /**
221
- * @see ServerLoggerProvider
222
- */
223
- silent?: boolean;
224
- }
225
- type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
226
- type ResponseKind = "json" | "text" | "void" | "file" | "any";
227
- type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
228
- type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
229
- interface ServerResponse$1 {
230
- body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
231
- headers: Record<string, string>;
232
- status: number;
233
- }
234
- type ServerRouteRequestHandler = (request: ServerRequestData) => Promise<ServerResponse$1>;
235
- interface ServerRouteMatcher extends Route {
236
- handler: ServerRouteRequestHandler;
237
- }
238
- interface ServerRequestData {
239
- method: RouteMethod;
240
- url: URL;
241
- headers: Record<string, string>;
242
- query: Record<string, string>;
243
- params: Record<string, string>;
244
- raw: ServerRawRequest;
245
- }
246
- interface ServerRawRequest {
247
- node?: NodeRequestEvent;
248
- web?: WebRequestEvent;
249
- }
250
- interface NodeRequestEvent {
251
- req: IncomingMessage;
252
- res: ServerResponse;
253
- }
254
- interface WebRequestEvent {
255
- req: Request;
256
- res?: Response;
257
- }
258
- //#endregion
259
- //#region ../../../alepha/src/logger/schemas/logEntrySchema.d.ts
260
- declare const logEntrySchema: alepha44.TObject<{
261
- level: alepha44.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
262
- message: alepha44.TString;
263
- service: alepha44.TString;
264
- module: alepha44.TString;
265
- context: alepha44.TOptional<alepha44.TString>;
266
- app: alepha44.TOptional<alepha44.TString>;
267
- data: alepha44.TOptional<alepha44.TAny>;
268
- timestamp: alepha44.TNumber;
269
- }>;
270
- type LogEntry = Static<typeof logEntrySchema>;
271
- //#endregion
272
- //#region ../../../alepha/src/datetime/providers/DateTimeProvider.d.ts
273
- type DateTime = DayjsApi.Dayjs;
274
- type Duration = dayjsDuration.Duration;
275
- type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
276
- declare class DateTimeProvider {
277
- static PLUGINS: Array<PluginFunc<any>>;
278
- protected alepha: Alepha;
279
- protected ref: DateTime | null;
280
- protected readonly timeouts: Timeout[];
281
- protected readonly intervals: Interval[];
282
- constructor();
283
- protected readonly onStart: alepha44.HookPrimitive<"start">;
284
- protected readonly onStop: alepha44.HookPrimitive<"stop">;
285
- setLocale(locale: string): void;
286
- isDateTime(value: unknown): value is DateTime;
287
- /**
288
- * Create a new UTC DateTime instance.
289
- */
290
- utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
291
- /**
292
- * Create a new DateTime instance.
293
- */
294
- of(date: string | number | Date | Dayjs | null | undefined): DateTime;
295
- /**
296
- * Get the current date as a string.
297
- */
298
- toISOString(date?: Date | string | DateTime): string;
299
- /**
300
- * Get the current date.
301
- */
302
- now(): DateTime;
303
- /**
304
- * Get the current date as a string.
305
- *
306
- * This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
307
- */
308
- nowISOString(): string;
309
- /**
310
- * Get the current date as milliseconds since epoch.
311
- *
312
- * This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
313
- */
314
- nowMillis(): number;
315
- /**
316
- * Get the current date as a string.
317
- *
318
- * @protected
319
- */
320
- protected getCurrentDate(): DateTime;
321
- /**
322
- * Create a new Duration instance.
323
- */
324
- duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
325
- isDurationLike(value: unknown): value is DurationLike;
326
- /**
327
- * Return a promise that resolves after the next tick.
328
- * It uses `setTimeout` with 0 ms delay.
329
- */
330
- tick(): Promise<void>;
331
- /**
332
- * Wait for a certain duration.
333
- *
334
- * You can clear the timeout by using the `AbortSignal` API.
335
- * Aborted signal will resolve the promise immediately, it does not reject it.
336
- */
337
- wait(duration: DurationLike, options?: {
338
- signal?: AbortSignal;
339
- now?: number;
340
- }): Promise<void>;
341
- createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
342
- /**
343
- * Run a callback after a certain duration.
344
- */
345
- createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
346
- clearTimeout(timeout: Timeout): void;
347
- clearInterval(interval: Interval): void;
348
- /**
349
- * Run a function with a deadline.
350
- */
351
- deadline<T$1>(fn: (signal: AbortSignal) => Promise<T$1>, duration: DurationLike): Promise<T$1>;
352
- /**
353
- * Add time to the current date.
354
- */
355
- travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
356
- /**
357
- * Stop the time.
358
- */
359
- pause(): DateTime;
360
- /**
361
- * Reset the reference date.
362
- */
363
- reset(): void;
364
- }
365
- interface Interval {
366
- timer?: any;
367
- duration: number;
368
- run: () => unknown;
369
- }
370
- interface Timeout {
371
- now: number;
372
- timer?: any;
373
- duration: number;
374
- callback: () => void;
375
- clear: () => void;
376
- }
377
- //#endregion
378
- //#region ../../../alepha/src/logger/providers/LogDestinationProvider.d.ts
379
- declare abstract class LogDestinationProvider {
380
- abstract write(message: string, entry: LogEntry): void;
381
- }
382
- //#endregion
383
- //#region ../../../alepha/src/logger/providers/LogFormatterProvider.d.ts
384
- declare abstract class LogFormatterProvider {
385
- abstract format(entry: LogEntry): string;
386
- }
387
- //#endregion
388
- //#region ../../../alepha/src/logger/services/Logger.d.ts
389
- declare class Logger implements LoggerInterface {
390
- protected readonly alepha: Alepha;
391
- protected readonly formatter: LogFormatterProvider;
392
- protected readonly destination: LogDestinationProvider;
393
- protected readonly dateTimeProvider: DateTimeProvider;
394
- protected readonly levels: Record<string, number>;
395
- protected readonly service: string;
396
- protected readonly module: string;
397
- protected readonly app?: string;
398
- protected appLogLevel: string;
399
- protected logLevel: LogLevel;
400
- constructor(service: string, module: string);
401
- get context(): string | undefined;
402
- get level(): string;
403
- parseLevel(level: string, app: string): LogLevel;
404
- private matchesPattern;
405
- asLogLevel(something: string): LogLevel;
406
- error(message: string, data?: unknown): void;
407
- warn(message: string, data?: unknown): void;
408
- info(message: string, data?: unknown): void;
409
- debug(message: string, data?: unknown): void;
410
- trace(message: string, data?: unknown): void;
411
- protected log(level: LogLevel, message: string, data?: unknown): void;
412
- protected emit(entry: LogEntry, message?: string): void;
413
- }
414
- //#endregion
415
- //#region ../../../alepha/src/logger/index.d.ts
416
- declare const envSchema$6: alepha44.TObject<{
417
- /**
418
- * Default log level for the application.
419
- *
420
- * Default by environment:
421
- * - dev = info
422
- * - prod = info
423
- * - test = error
424
- *
425
- * Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
426
- *
427
- * Level can be set for a specific module:
428
- *
429
- * @example
430
- * LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
431
- * LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
432
- */
433
- LOG_LEVEL: alepha44.TOptional<alepha44.TString>;
434
- /**
435
- * Built-in log formats.
436
- * - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
437
- * - "pretty" - Simple text format, human-readable, with colors. {@link PrettyFormatterProvider}
438
- * - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
439
- */
440
- LOG_FORMAT: alepha44.TOptional<alepha44.TUnsafe<"json" | "pretty" | "raw">>;
441
- }>;
442
- declare module "alepha" {
443
- interface Env extends Partial<Static<typeof envSchema$6>> {}
444
- interface State {
445
- /**
446
- * Current log level for the application or specific modules.
447
- */
448
- "alepha.logger.level"?: string;
449
- }
450
- interface Hooks {
451
- log: {
452
- message?: string;
453
- entry: LogEntry;
454
- };
455
- }
456
- }
457
- //#endregion
458
- //#region ../../../alepha/src/server/services/ServerRequestParser.d.ts
459
- declare class ServerRequestParser {
460
- protected readonly alepha: Alepha;
461
- protected readonly userAgentParser: UserAgentParser;
462
- createServerRequest(rawRequest: ServerRequestData): ServerRequest;
463
- getRequestId(request: ServerRequestData): string | undefined;
464
- getRequestUserAgent(request: ServerRequestData): UserAgentInfo;
465
- getRequestIp(request: ServerRequestData): string | undefined;
466
- }
467
- //#endregion
468
- //#region ../../../alepha/src/server/providers/ServerTimingProvider.d.ts
469
- type TimingMap = Record<string, [number, number]>;
470
- declare class ServerTimingProvider {
471
- protected readonly log: Logger;
472
- protected readonly alepha: Alepha;
473
- options: {
474
- prefix: string;
475
- disabled: boolean;
476
- };
477
- readonly onRequest: alepha44.HookPrimitive<"server:onRequest">;
478
- readonly onResponse: alepha44.HookPrimitive<"server:onResponse">;
479
- protected get handlerName(): string;
480
- beginTiming(name: string): void;
481
- endTiming(name: string): void;
482
- protected setDuration(name: string, timing: TimingMap): void;
483
- }
484
- //#endregion
485
- //#region ../../../alepha/src/server/providers/ServerRouterProvider.d.ts
486
- /**
487
- * Main router for all routes on the server side.
488
- *
489
- * - $route => generic route
490
- * - $action => action route (for API calls)
491
- * - $page => React route (for SSR)
492
- */
493
- declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
494
- protected readonly log: Logger;
495
- protected readonly alepha: Alepha;
496
- protected readonly routes: ServerRoute[];
497
- protected readonly serverTimingProvider: ServerTimingProvider;
498
- protected readonly serverRequestParser: ServerRequestParser;
499
- /**
500
- * Get all registered routes, optionally filtered by a pattern.
501
- *
502
- * Pattern accept simple wildcard '*' at the end.
503
- * Example: '/api/*' will match all routes starting with '/api/' but '/api/' will match only that exact route.
504
- */
505
- getRoutes(pattern?: string): ServerRoute[];
506
- createRoute<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): void;
507
- protected getContextId(headers: Record<string, string>): string;
508
- protected processRequest(request: ServerRequest, route: ServerRoute, responseKind: ResponseKind): Promise<{
509
- status: number;
510
- headers: Record<string, string> & {
511
- "set-cookie"?: string[];
512
- };
513
- body: any;
514
- }>;
515
- protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseKind: ResponseKind): Promise<void>;
516
- serializeResponse(route: ServerRoute, reply: ServerReply, responseKind: ResponseKind): void;
517
- protected getResponseType(schema?: RequestConfigSchema): ResponseKind;
518
- protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
519
- validateRequest(route: {
520
- schema?: RequestConfigSchema;
521
- }, request: ServerRequestConfig): void;
522
- }
523
- //#endregion
524
- //#region ../../../alepha/src/server/providers/ServerProvider.d.ts
525
- /**
526
- * Base server provider to handle incoming requests and route them.
527
- *
528
- * This is the default implementation for serverless environments.
529
- *
530
- * ServerProvider supports both Node.js HTTP requests and Web (Fetch API) requests.
531
- */
532
- declare class ServerProvider {
533
- protected readonly log: Logger;
534
- protected readonly alepha: Alepha;
535
- protected readonly dateTimeProvider: DateTimeProvider;
536
- protected readonly router: ServerRouterProvider;
537
- protected readonly internalServerErrorMessage = "Internal Server Error";
538
- get hostname(): string;
539
- /**
540
- * When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
541
- */
542
- protected readonly onNodeRequest: alepha44.HookPrimitive<"node:request">;
543
- /**
544
- * When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
545
- */
546
- protected readonly onWebRequest: alepha44.HookPrimitive<"web:request">;
547
- /**
548
- * Handle Node.js HTTP request event.
549
- *
550
- * Technically, we just convert Node.js request to Web Standard Request.
551
- */
552
- handleNodeRequest(nodeRequestEvent: NodeRequestEvent): Promise<void>;
553
- /**
554
- * Handle Web (Fetch API) request event.
555
- */
556
- handleWebRequest(ev: WebRequestEvent): Promise<void>;
557
- /**
558
- * Helper for Vite development mode to let Vite handle (or not) 404.
559
- */
560
- protected isViteNotFound(url?: string, route?: Route, params?: Record<string, string>): boolean;
561
- }
562
- //#endregion
563
- //#region ../../../alepha/src/cache/providers/CacheProvider.d.ts
564
- /**
565
- * Cache provider interface.
566
- *
567
- * All methods are asynchronous and return promises.
568
- * Values are stored as Uint8Array.
569
- */
570
- declare abstract class CacheProvider {
571
- /**
572
- * Get the value of a key.
573
- *
574
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
575
- * @param key The key of the value to get.
576
- *
577
- * @return The value of the key, or undefined if the key does not exist.
578
- */
579
- abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
580
- /**
581
- * Set the string value of a key.
582
- *
583
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
584
- * @param key The key of the value to set.
585
- * @param value The value to set.
586
- * @param ttl The time-to-live of the key, in milliseconds.
587
- *
588
- * @return The value of the key.
589
- */
590
- abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
591
- /**
592
- * Remove the specified keys.
593
- *
594
- * @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
595
- * @param keys The keys to delete.
596
- */
597
- abstract del(name: string, ...keys: string[]): Promise<void>;
598
- abstract has(name: string, key: string): Promise<boolean>;
599
- abstract keys(name: string, filter?: string): Promise<string[]>;
600
- /**
601
- * Remove all keys from all cache names.
602
- */
603
- abstract clear(): Promise<void>;
604
- }
605
- //#endregion
606
- //#region ../../../alepha/src/cache/primitives/$cache.d.ts
607
- interface CachePrimitiveOptions<TReturn = any, TParameter extends any[] = any[]> {
608
- /**
609
- * The cache name. This is useful for invalidating multiple caches at once.
610
- *
611
- * Store key as `cache:$name:$key`.
612
- *
613
- * @default Name of the key of the class.
614
- */
615
- name?: string;
616
- /**
617
- * Function which returns cached data.
618
- */
619
- handler?: (...args: TParameter) => TReturn;
620
- /**
621
- * The key generator for the cache.
622
- * If not provided, the arguments will be json.stringify().
623
- */
624
- key?: (...args: TParameter) => string;
625
- /**
626
- * The store provider for the cache.
627
- * If not provided, the default store provider will be used.
628
- */
629
- provider?: InstantiableClass<CacheProvider> | "memory";
630
- /**
631
- * The time-to-live for the cache in seconds.
632
- * Set 0 to skip expiration.
633
- *
634
- * @default 300 (5 minutes).
635
- */
636
- ttl?: DurationLike;
637
- /**
638
- * If the cache is disabled.
639
- */
640
- disabled?: boolean;
641
- }
642
- declare class CachePrimitive<TReturn = any, TParameter extends any[] = any[]> extends Primitive<CachePrimitiveOptions<TReturn, TParameter>> {
643
- protected readonly env: {
644
- CACHE_ENABLED: boolean;
645
- CACHE_DEFAULT_TTL: number;
646
- };
647
- protected readonly dateTimeProvider: DateTimeProvider;
648
- protected readonly provider: CacheProvider;
649
- protected encoder: TextEncoder;
650
- protected decoder: TextDecoder;
651
- protected codes: {
652
- BINARY: number;
653
- JSON: number;
654
- STRING: number;
655
- };
656
- get container(): string;
657
- run(...args: TParameter): Promise<TReturn>;
658
- key(...args: TParameter): string;
659
- invalidate(...keys: string[]): Promise<void>;
660
- set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
661
- get(key: string): Promise<TReturn | undefined>;
662
- protected serialize<TReturn>(value: TReturn): Uint8Array;
663
- protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
664
- protected $provider(): CacheProvider;
665
- }
666
- interface CachePrimitiveFn<TReturn = any, TParameter extends any[] = any[]> extends CachePrimitive<TReturn, TParameter> {
667
- /**
668
- * Run the cache primitive with the provided arguments.
669
- */
670
- (...args: TParameter): Promise<TReturn>;
671
- }
672
- //#endregion
673
- //#region ../../../alepha/src/server/services/HttpClient.d.ts
674
- declare class HttpClient {
675
- protected readonly log: Logger;
676
- protected readonly alepha: Alepha;
677
- readonly cache: CachePrimitiveFn<HttpClientCache, any[]>;
678
- protected readonly pendingRequests: HttpClientPendingRequests;
679
- fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
680
- fetch<T$1 extends TSchema>(url: string, request?: RequestInitWithOptions<T$1>): Promise<FetchResponse<Static<T$1>>>;
681
- protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
682
- protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
683
- protected responseData(response: Response, options: FetchOptions): Promise<any>;
684
- protected isMaybeFile(response: Response): boolean;
685
- protected createFileLike(response: Response, defaultFileName?: string): FileLike;
686
- pathVariables(url: string, action: {
687
- schema?: {
688
- params?: TObject;
689
- };
690
- }, args?: ServerRequestConfigEntry): string;
691
- queryParams(url: string, action: {
692
- schema?: {
693
- query?: TObject;
694
- };
695
- }, args?: ServerRequestConfigEntry): string;
696
- }
697
- interface FetchOptions<T$1 extends TSchema = TSchema> {
698
- /**
699
- * Key to identify the request in the pending requests.
700
- */
701
- key?: string;
702
- /**
703
- * The schema to validate the response against.
704
- */
705
- schema?: {
706
- response?: T$1;
707
- };
708
- /**
709
- * Built-in cache options.
710
- */
711
- localCache?: boolean | number | DurationLike;
712
- }
713
- type RequestInitWithOptions<T$1 extends TSchema = TSchema> = RequestInit & FetchOptions<T$1>;
714
- interface FetchResponse<T$1 = any> {
715
- data: T$1;
716
- status: number;
717
- statusText: string;
718
- headers: Headers;
719
- raw?: Response;
720
- }
721
- type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
722
- interface HttpClientCache {
723
- data: any;
724
- etag?: string;
725
- }
726
- interface FetchActionArgs {
727
- action: HttpAction;
728
- host?: string;
729
- config?: ServerRequestConfigEntry;
730
- options?: ClientRequestOptions;
731
- }
732
- interface HttpAction {
733
- method?: string;
734
- prefix?: string;
735
- path: string;
736
- requestBodyType?: string;
737
- schema?: {
738
- params?: TObject;
739
- query?: TObject;
740
- body?: TRequestBody;
741
- response?: TResponseBody;
742
- };
743
- }
744
- //#endregion
745
- //#region ../../../alepha/src/server/primitives/$action.d.ts
746
- interface ActionPrimitiveOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
747
- /**
748
- * Name of the action.
749
- *
750
- * - It will be used to generate the route path if `path` is not provided.
751
- * - It will be used to generate the permission name if `security` is enabled.
752
- */
753
- name?: string;
754
- /**
755
- * Group actions together.
756
- *
757
- * - If not provided, the service name containing the route will be used.
758
- * - It will be used as Tag for documentation purposes.
759
- * - It will be used for permission name generation if `security` is enabled.
760
- *
761
- * @example
762
- * ```ts
763
- * // group = "MyController"
764
- * class MyController {
765
- * hello = $action({ handler: () => "Hello World" });
766
- * }
767
- *
768
- * // group = "users"
769
- * class MyOtherController {
770
- * group = "users";
771
- * a1 = $action({ handler: () => "Action 1", group: this.group });
772
- * a2 = $action({ handler: () => "Action 2", group: this.group });
773
- * }
774
- * ```
775
- */
776
- group?: string;
777
- /**
778
- * Pathname of the route. If not provided, property key is used.
779
- */
780
- path?: string;
781
- /**
782
- * The route method.
783
- *
784
- * - If not provided, it will be set to "GET" by default.
785
- * - If not provider and a body is provided, it will be set to "POST".
786
- *
787
- * Wildcard methods are not supported for now. (e.g. "ALL", "ANY", etc.)
788
- */
789
- method?: RouteMethod;
790
- /**
791
- * The config schema of the route.
792
- * - body: The request body schema.
793
- * - params: Path variables schema.
794
- * - query: The request query-params schema.
795
- * - response: The response schema.
796
- */
797
- schema?: TConfig;
798
- /**
799
- * A short description of the action. Used for documentation purposes.
800
- */
801
- description?: string;
802
- /**
803
- * Disable the route. Useful with env variables do disable one specific route.
804
- * Route won't be available in the API but can still be called locally!
805
- */
806
- disabled?: boolean;
807
- /**
808
- * Main route handler. This is where the route logic is implemented.
809
- */
810
- handler: ServerActionHandler<TConfig>;
811
- }
812
- declare class ActionPrimitive<TConfig extends RequestConfigSchema> extends Primitive<ActionPrimitiveOptions<TConfig>> {
813
- protected readonly log: Logger;
814
- protected readonly env: {
815
- SERVER_API_PREFIX: string;
816
- };
817
- protected readonly httpClient: HttpClient;
818
- protected readonly serverProvider: ServerProvider;
819
- protected readonly serverRouterProvider: ServerRouterProvider;
820
- protected onInit(): void;
821
- get prefix(): string;
822
- get route(): ServerRoute;
823
- /**
824
- * Returns the name of the action.
825
- */
826
- get name(): string;
827
- /**
828
- * Returns the group of the action. (e.g. "orders", "admin", etc.)
829
- */
830
- get group(): string;
831
- /**
832
- * Returns the HTTP method of the action.
833
- */
834
- get method(): RouteMethod;
835
- /**
836
- * Returns the path of the action.
837
- *
838
- * Path is prefixed by `/api` by default.
839
- */
840
- get path(): string;
841
- get schema(): TConfig | undefined;
842
- getBodyContentType(): string | undefined;
843
- /**
844
- * Call the action handler directly.
845
- * There is no HTTP layer involved.
846
- */
847
- run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
848
- /**
849
- * Works like `run`, but always fetches (http request) the route.
850
- */
851
- fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
852
- }
853
- 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] };
854
- type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
855
- body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
856
- params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
857
- headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
858
- query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
859
- };
860
- interface ClientRequestOptions extends FetchOptions {
861
- /**
862
- * Standard request fetch options.
863
- */
864
- request?: RequestInit;
865
- }
866
- type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
867
- /**
868
- * Specific handler for server actions.
869
- */
870
- type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
871
- /**
872
- * Server Action Request Interface
873
- *
874
- * Can be extended with module augmentation to add custom properties (like `user` in Server Security).
875
- *
876
- * This is NOT Server Request, but a specific type for actions.
877
- */
878
- interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
879
- //#endregion
880
- //#region ../../../alepha/src/server/providers/BunHttpServerProvider.d.ts
881
- declare const envSchema$5: alepha44.TObject<{
882
- SERVER_PORT: alepha44.TInteger;
883
- SERVER_HOST: alepha44.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: alepha44.TObject<{
891
- SERVER_PORT: alepha44.TInteger;
892
- SERVER_HOST: alepha44.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: ActionPrimitive<RequestConfigSchema>;
906
- request: ServerRequest;
907
- options: ClientRequestOptions;
908
- };
909
- "action:onResponse": {
910
- action: ActionPrimitive<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 ActionPrimitive<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 CachePrimitiveOptions is provided, it will be used to configure the cache storage.
986
- *
987
- * @default false
988
- */
989
- store?: true | DurationLike | CachePrimitiveOptions;
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
1051
16
  //#region ../../src/core/components/ClientOnly.d.ts
1052
17
  interface ClientOnlyProps {
1053
18
  fallback?: ReactNode;
@@ -1077,14 +42,14 @@ declare class Redirection extends Error {
1077
42
  }
1078
43
  //#endregion
1079
44
  //#region ../../src/core/providers/ReactPageProvider.d.ts
1080
- declare const envSchema$3: alepha44.TObject<{
1081
- REACT_STRICT_MODE: alepha44.TBoolean;
45
+ declare const envSchema$2: alepha19.TObject<{
46
+ REACT_STRICT_MODE: alepha19.TBoolean;
1082
47
  }>;
1083
48
  declare module "alepha" {
1084
- interface Env extends Partial<Static<typeof envSchema$3>> {}
49
+ interface Env extends Partial<Static<typeof envSchema$2>> {}
1085
50
  }
1086
51
  declare class ReactPageProvider {
1087
- protected readonly log: Logger;
52
+ protected readonly log: alepha_logger1.Logger;
1088
53
  protected readonly env: {
1089
54
  REACT_STRICT_MODE: boolean;
1090
55
  };
@@ -1120,7 +85,7 @@ declare class ReactPageProvider {
1120
85
  }, params?: Record<string, any>): string;
1121
86
  compile(path: string, params?: Record<string, string>): string;
1122
87
  protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
1123
- protected readonly configure: alepha44.HookPrimitive<"configure">;
88
+ protected readonly configure: alepha19.HookPrimitive<"configure">;
1124
89
  protected map(pages: Array<PagePrimitive>, target: PagePrimitive): PageRouteEntry;
1125
90
  add(entry: PageRouteEntry): void;
1126
91
  protected createMatch(page: PageRoute): string;
@@ -1550,265 +515,23 @@ type CssAnimation = {
1550
515
  timing?: string;
1551
516
  };
1552
517
  //#endregion
1553
- //#region ../../../alepha/src/security/schemas/userAccountInfoSchema.d.ts
1554
- declare const userAccountInfoSchema: alepha44.TObject<{
1555
- id: alepha44.TString;
1556
- name: alepha44.TOptional<alepha44.TString>;
1557
- email: alepha44.TOptional<alepha44.TString>;
1558
- username: alepha44.TOptional<alepha44.TString>;
1559
- picture: alepha44.TOptional<alepha44.TString>;
1560
- sessionId: alepha44.TOptional<alepha44.TString>;
1561
- organizations: alepha44.TOptional<alepha44.TArray<alepha44.TString>>;
1562
- roles: alepha44.TOptional<alepha44.TArray<alepha44.TString>>;
1563
- }>;
1564
- type UserAccount = Static<typeof userAccountInfoSchema>;
1565
- //#endregion
1566
- //#region ../../../alepha/src/security/interfaces/UserAccountToken.d.ts
1567
- /**
1568
- * Add contextual metadata to a user account info.
1569
- * E.g. UserAccountToken is a UserAccountInfo during a request.
1570
- */
1571
- interface UserAccountToken extends UserAccount {
1572
- /**
1573
- * Access token for the user.
1574
- */
1575
- token?: string;
1576
- /**
1577
- * Realm name of the user.
1578
- */
1579
- realm?: string;
1580
- /**
1581
- * Is user dedicated to his own resources for this scope ?
1582
- * Mostly, Admin is false and Customer is true.
1583
- */
1584
- ownership?: string | boolean;
1585
- }
1586
- //#endregion
1587
- //#region ../../../alepha/src/security/providers/SecurityProvider.d.ts
1588
- declare const envSchema$2: alepha44.TObject<{
1589
- APP_SECRET: alepha44.TString;
1590
- }>;
1591
- declare module "alepha" {
1592
- interface Env extends Partial<Static<typeof envSchema$2>> {}
1593
- }
1594
- //#endregion
1595
- //#region ../../../alepha/src/security/index.d.ts
1596
- declare module "alepha" {
1597
- interface Hooks {
1598
- "security:user:created": {
1599
- realm: string;
1600
- user: UserAccount;
1601
- };
1602
- }
1603
- }
1604
- /**
1605
- * Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
1606
- *
1607
- * The security module enables building secure applications using primitives like `$realm`, `$role`, and `$permission`
1608
- * on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
1609
- * integration with various authentication providers and user management systems.
1610
- *
1611
- * @see {@link $realm}
1612
- * @see {@link $role}
1613
- * @see {@link $permission}
1614
- * @module alepha.security
1615
- */
1616
- //#endregion
1617
- //#region ../../../alepha/src/server-security/providers/ServerBasicAuthProvider.d.ts
1618
- interface BasicAuthOptions {
1619
- username: string;
1620
- password: string;
1621
- }
1622
- //#endregion
1623
- //#region ../../../alepha/src/server-security/providers/ServerSecurityProvider.d.ts
1624
- type ServerRouteSecure = {
1625
- realm?: string;
1626
- basic?: BasicAuthOptions;
1627
- };
1628
- //#endregion
1629
- //#region ../../../alepha/src/server-security/index.d.ts
1630
- declare module "alepha" {
1631
- interface State {
1632
- /**
1633
- * Real (or fake) user account, used for internal actions.
1634
- *
1635
- * If you define this, you assume that all actions are executed by this user by default.
1636
- * > To force a different user, you need to pass it explicitly in the options.
1637
- */
1638
- "alepha.server.security.system.user"?: UserAccountToken;
1639
- /**
1640
- * The authenticated user account attached to the server request state.
1641
- *
1642
- * @internal
1643
- */
1644
- "alepha.server.request.user"?: UserAccount;
1645
- }
1646
- }
1647
- declare module "alepha/server" {
1648
- interface ServerRequest<TConfig> {
1649
- user?: UserAccountToken;
1650
- }
1651
- interface ServerActionRequest<TConfig> {
1652
- user: UserAccountToken;
1653
- }
1654
- interface ServerRoute {
1655
- /**
1656
- * If true, the route will be protected by the security provider.
1657
- * All actions are secure by default, but you can disable it for specific actions.
1658
- */
1659
- secure?: boolean | ServerRouteSecure;
1660
- }
1661
- interface ClientRequestOptions extends FetchOptions {
1662
- /**
1663
- * Forward user from the previous request.
1664
- * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
1665
- * If "context", use the user from the current context (e.g. request).
1666
- *
1667
- * @default "system" if provided, else "context" if available.
1668
- */
1669
- user?: UserAccountToken | "system" | "context";
1670
- }
1671
- }
1672
- /**
1673
- * Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
1674
- *
1675
- * By default, all $action will be guarded by a permission check.
1676
- *
1677
- * @see {@link ServerSecurityProvider}
1678
- * @module alepha.server.security
1679
- */
1680
- //#endregion
1681
- //#region ../../../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
1682
- declare const apiLinkSchema: alepha44.TObject<{
1683
- name: alepha44.TString;
1684
- group: alepha44.TOptional<alepha44.TString>;
1685
- path: alepha44.TString;
1686
- method: alepha44.TOptional<alepha44.TString>;
1687
- requestBodyType: alepha44.TOptional<alepha44.TString>;
1688
- service: alepha44.TOptional<alepha44.TString>;
1689
- }>;
1690
- declare const apiLinksResponseSchema: alepha44.TObject<{
1691
- prefix: alepha44.TOptional<alepha44.TString>;
1692
- links: alepha44.TArray<alepha44.TObject<{
1693
- name: alepha44.TString;
1694
- group: alepha44.TOptional<alepha44.TString>;
1695
- path: alepha44.TString;
1696
- method: alepha44.TOptional<alepha44.TString>;
1697
- requestBodyType: alepha44.TOptional<alepha44.TString>;
1698
- service: alepha44.TOptional<alepha44.TString>;
1699
- }>>;
1700
- }>;
1701
- type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
1702
- type ApiLink = Static<typeof apiLinkSchema>;
1703
- //#endregion
1704
- //#region ../../../alepha/src/server-links/providers/LinkProvider.d.ts
1705
- /**
1706
- * Browser, SSR friendly, service to handle links.
1707
- */
1708
- declare class LinkProvider {
1709
- static path: {
1710
- apiLinks: string;
1711
- apiSchema: string;
1712
- };
1713
- protected readonly log: Logger;
1714
- protected readonly alepha: Alepha;
1715
- protected readonly httpClient: HttpClient;
1716
- protected serverLinks: Array<HttpClientLink>;
1717
- /**
1718
- * Get applicative links registered on the server.
1719
- * This does not include lazy-loaded remote links.
1720
- */
1721
- getServerLinks(): HttpClientLink[];
1722
- /**
1723
- * Register a new link for the application.
1724
- */
1725
- registerLink(link: HttpClientLink): void;
1726
- get links(): HttpClientLink[];
1727
- /**
1728
- * Force browser to refresh links from the server.
1729
- */
1730
- fetchLinks(): Promise<HttpClientLink[]>;
1731
- /**
1732
- * Create a virtual client that can be used to call actions.
1733
- *
1734
- * Use js Proxy under the hood.
1735
- */
1736
- client<T$1 extends object>(scope?: ClientScope): HttpVirtualClient<T$1>;
1737
- /**
1738
- * Check if a link with the given name exists.
1739
- * @param name
1740
- */
1741
- can(name: string): boolean;
1742
- /**
1743
- * Resolve a link by its name and call it.
1744
- * - If link is local, it will call the local handler.
1745
- * - If link is remote, it will make a fetch request to the remote server.
1746
- */
1747
- follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
1748
- protected createVirtualAction<T$1 extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T$1>;
1749
- protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
1750
- protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
1751
- }
1752
- interface HttpClientLink extends ApiLink {
1753
- secured?: boolean | ServerRouteSecure;
1754
- prefix?: string;
1755
- host?: string;
1756
- service?: string;
1757
- schema?: RequestConfigSchema;
1758
- handler?: (request: ServerRequest, options: ClientRequestOptions) => Async<ServerResponseBody>;
1759
- }
1760
- interface ClientScope {
1761
- group?: string;
1762
- service?: string;
1763
- hostname?: string;
1764
- }
1765
- type HttpVirtualClient<T$1> = { [K in keyof T$1 as T$1[K] extends ActionPrimitive<RequestConfigSchema> ? K : never]: T$1[K] extends ActionPrimitive<infer Schema> ? VirtualAction<Schema> : never };
1766
- interface VirtualAction<T$1 extends RequestConfigSchema> extends Pick<ActionPrimitive<T$1>, "name" | "run" | "fetch"> {
1767
- (config?: ClientRequestEntry<T$1>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T$1>>;
1768
- can: () => boolean;
1769
- }
1770
- //#endregion
1771
- //#region ../../../alepha/src/server-links/index.d.ts
1772
- declare module "alepha" {
1773
- interface State {
1774
- /**
1775
- * API links attached to the server request state.
1776
- *
1777
- * @see {@link ApiLinksResponse}
1778
- * @internal
1779
- */
1780
- "alepha.server.request.apiLinks"?: ApiLinksResponse;
1781
- }
1782
- }
1783
- /**
1784
- * Provides server-side link management and remote capabilities for client-server interactions.
1785
- *
1786
- * The server-links module enables declarative link definitions using `$remote` and `$client` primitives,
1787
- * facilitating seamless API endpoint management and client-server communication. It integrates with server
1788
- * security features to ensure safe and controlled access to resources.
1789
- *
1790
- * @see {@link $remote}
1791
- * @see {@link $client}
1792
- * @module alepha.server.links
1793
- */
1794
- //#endregion
1795
518
  //#region ../../src/core/providers/ReactBrowserRouterProvider.d.ts
1796
519
  interface BrowserRoute extends Route {
1797
520
  page: PageRoute;
1798
521
  }
1799
522
  declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
1800
- protected readonly log: Logger;
523
+ protected readonly log: alepha_logger1.Logger;
1801
524
  protected readonly alepha: Alepha;
1802
525
  protected readonly pageApi: ReactPageProvider;
1803
526
  add(entry: PageRouteEntry): void;
1804
- protected readonly configure: alepha44.HookPrimitive<"configure">;
527
+ protected readonly configure: alepha19.HookPrimitive<"configure">;
1805
528
  transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
1806
529
  root(state: ReactRouterState): ReactNode;
1807
530
  }
1808
531
  //#endregion
1809
532
  //#region ../../src/core/providers/ReactBrowserProvider.d.ts
1810
- declare const envSchema$1: alepha44.TObject<{
1811
- REACT_ROOT_ID: alepha44.TString;
533
+ declare const envSchema$1: alepha19.TObject<{
534
+ REACT_ROOT_ID: alepha19.TString;
1812
535
  }>;
1813
536
  declare module "alepha" {
1814
537
  interface Env extends Partial<Static<typeof envSchema$1>> {}
@@ -1816,8 +539,8 @@ declare module "alepha" {
1816
539
  /**
1817
540
  * React browser renderer configuration atom
1818
541
  */
1819
- declare const reactBrowserOptions: alepha44.Atom<alepha44.TObject<{
1820
- scrollRestoration: alepha44.TUnsafe<"top" | "manual">;
542
+ declare const reactBrowserOptions: alepha19.Atom<alepha19.TObject<{
543
+ scrollRestoration: alepha19.TUnsafe<"top" | "manual">;
1821
544
  }>, "alepha.react.browser.options">;
1822
545
  type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
1823
546
  declare module "alepha" {
@@ -1829,7 +552,7 @@ declare class ReactBrowserProvider {
1829
552
  protected readonly env: {
1830
553
  REACT_ROOT_ID: string;
1831
554
  };
1832
- protected readonly log: Logger;
555
+ protected readonly log: alepha_logger1.Logger;
1833
556
  protected readonly client: LinkProvider;
1834
557
  protected readonly alepha: Alepha;
1835
558
  protected readonly router: ReactBrowserRouterProvider;
@@ -1865,8 +588,8 @@ declare class ReactBrowserProvider {
1865
588
  * Get embedded layers from the server.
1866
589
  */
1867
590
  protected getHydrationState(): ReactHydrationState | undefined;
1868
- protected readonly onTransitionEnd: alepha44.HookPrimitive<"react:transition:end">;
1869
- readonly ready: alepha44.HookPrimitive<"ready">;
591
+ protected readonly onTransitionEnd: alepha19.HookPrimitive<"react:transition:end">;
592
+ readonly ready: alepha19.HookPrimitive<"ready">;
1870
593
  }
1871
594
  interface RouterGoOptions {
1872
595
  replace?: boolean;
@@ -1890,6 +613,18 @@ interface RouterRenderOptions {
1890
613
  meta?: Record<string, any>;
1891
614
  }
1892
615
  //#endregion
616
+ //#region ../../src/core/contexts/AlephaProvider.d.ts
617
+ interface AlephaProviderProps {
618
+ children: ReactNode;
619
+ onError: (error: Error) => ReactNode;
620
+ onLoading: () => ReactNode;
621
+ }
622
+ /**
623
+ * AlephaProvider component to initialize and provide Alepha instance to the app.
624
+ * This isn't recommended for apps using alepha/react/router, as Router will handle this for you.
625
+ */
626
+ declare const AlephaProvider: (props: AlephaProviderProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react0.ReactPortal | react0.ReactElement<unknown, string | react0.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime0.JSX.Element | null | undefined;
627
+ //#endregion
1893
628
  //#region ../../src/core/contexts/AlephaContext.d.ts
1894
629
  declare const AlephaContext: react0.Context<Alepha | undefined>;
1895
630
  //#endregion
@@ -2338,9 +1073,9 @@ declare class ReactRouter<T$1 extends object> {
2338
1073
  static?: boolean | {
2339
1074
  entries?: Partial<PageRequestConfig<PageConfigSchema>>[] | undefined;
2340
1075
  } | undefined;
2341
- cache?: ServerRouteCache | undefined;
1076
+ cache?: alepha_server_cache0.ServerRouteCache | undefined;
2342
1077
  client?: (boolean | ClientOnlyProps) | undefined;
2343
- onServerResponse?: ((request: ServerRequest) => unknown) | undefined;
1078
+ onServerResponse?: ((request: alepha_server0.ServerRequest) => unknown) | undefined;
2344
1079
  onLeave?: (() => void) | undefined;
2345
1080
  animation?: PageAnimation | undefined;
2346
1081
  };
@@ -2401,232 +1136,10 @@ declare const useRouter: <T$1 extends object = any>() => ReactRouter<T$1>;
2401
1136
  //#region ../../src/core/hooks/useRouterState.d.ts
2402
1137
  declare const useRouterState: () => ReactRouterState;
2403
1138
  //#endregion
2404
- //#region ../../../alepha/src/server-static/primitives/$serve.d.ts
2405
- interface ServePrimitiveOptions {
2406
- /**
2407
- * Prefix for the served path.
2408
- *
2409
- * @default "/"
2410
- */
2411
- path?: string;
2412
- /**
2413
- * Path to the directory to serve.
2414
- *
2415
- * @default process.cwd()
2416
- */
2417
- root?: string;
2418
- /**
2419
- * If true, primitive will be ignored.
2420
- *
2421
- * @default false
2422
- */
2423
- disabled?: boolean;
2424
- /**
2425
- * Whether to keep dot files (e.g. `.gitignore`, `.env`) in the served directory.
2426
- *
2427
- * @default true
2428
- */
2429
- ignoreDotEnvFiles?: boolean;
2430
- /**
2431
- * Whether to use the index.html file when the path is a directory.
2432
- *
2433
- * @default true
2434
- */
2435
- indexFallback?: boolean;
2436
- /**
2437
- * Force all requests "not found" to be served with the index.html file.
2438
- * This is useful for single-page applications (SPAs) that use client-side only routing.
2439
- */
2440
- historyApiFallback?: boolean;
2441
- /**
2442
- * Optional name of the primitive.
2443
- * This is used for logging and debugging purposes.
2444
- *
2445
- * @default Key name.
2446
- */
2447
- name?: string;
2448
- /**
2449
- * Whether to use cache control headers.
2450
- *
2451
- * @default {}
2452
- */
2453
- cacheControl?: Partial<CacheControlOptions> | false;
2454
- }
2455
- interface CacheControlOptions {
2456
- /**
2457
- * Whether to use cache control headers.
2458
- *
2459
- * @default [.js, .css]
2460
- */
2461
- fileTypes: string[];
2462
- /**
2463
- * The maximum age of the cache in seconds.
2464
- *
2465
- * @default 60 * 60 * 24 * 2 // 2 days
2466
- */
2467
- maxAge: DurationLike;
2468
- /**
2469
- * Whether to use immutable cache control headers.
2470
- *
2471
- * @default true
2472
- */
2473
- immutable: boolean;
2474
- }
2475
- //#endregion
2476
- //#region ../../../alepha/src/file/services/FileDetector.d.ts
2477
- interface FileTypeResult {
2478
- /**
2479
- * The detected MIME type
2480
- */
2481
- mimeType: string;
2482
- /**
2483
- * The detected file extension
2484
- */
2485
- extension: string;
2486
- /**
2487
- * Whether the file type was verified by magic bytes
2488
- */
2489
- verified: boolean;
2490
- /**
2491
- * The stream (potentially wrapped to allow re-reading)
2492
- */
2493
- stream: Readable;
2494
- }
2495
- /**
2496
- * Service for detecting file types and getting content types.
2497
- *
2498
- * @example
2499
- * ```typescript
2500
- * const detector = alepha.inject(FileDetector);
2501
- *
2502
- * // Get content type from filename
2503
- * const mimeType = detector.getContentType("image.png"); // "image/png"
2504
- *
2505
- * // Detect file type by magic bytes
2506
- * const stream = createReadStream('image.png');
2507
- * const result = await detector.detectFileType(stream, 'image.png');
2508
- * console.log(result.mimeType); // 'image/png'
2509
- * console.log(result.verified); // true if magic bytes match
2510
- * ```
2511
- */
2512
- declare class FileDetector {
2513
- /**
2514
- * Magic byte signatures for common file formats.
2515
- * Each signature is represented as an array of bytes or null (wildcard).
2516
- */
2517
- protected static readonly MAGIC_BYTES: Record<string, {
2518
- signature: (number | null)[];
2519
- mimeType: string;
2520
- }[]>;
2521
- /**
2522
- * All possible format signatures for checking against actual file content
2523
- */
2524
- protected static readonly ALL_SIGNATURES: {
2525
- signature: (number | null)[];
2526
- mimeType: string;
2527
- ext: string;
2528
- }[];
2529
- /**
2530
- * MIME type map for file extensions.
2531
- *
2532
- * Can be used to get the content type of file based on its extension.
2533
- * Feel free to add more mime types in your project!
2534
- */
2535
- static readonly mimeMap: Record<string, string>;
2536
- /**
2537
- * Reverse MIME type map for looking up extensions from MIME types.
2538
- * Prefers shorter, more common extensions when multiple exist.
2539
- */
2540
- protected static readonly reverseMimeMap: Record<string, string>;
2541
- /**
2542
- * Returns the file extension for a given MIME type.
2543
- *
2544
- * @param mimeType - The MIME type to look up
2545
- * @returns The file extension (without dot), or "bin" if not found
2546
- *
2547
- * @example
2548
- * ```typescript
2549
- * const detector = alepha.inject(FileDetector);
2550
- * const ext = detector.getExtensionFromMimeType("image/png"); // "png"
2551
- * const ext2 = detector.getExtensionFromMimeType("application/octet-stream"); // "bin"
2552
- * ```
2553
- */
2554
- getExtensionFromMimeType(mimeType: string): string;
2555
- /**
2556
- * Returns the content type of file based on its filename.
2557
- *
2558
- * @param filename - The filename to check
2559
- * @returns The MIME type
2560
- *
2561
- * @example
2562
- * ```typescript
2563
- * const detector = alepha.inject(FileDetector);
2564
- * const mimeType = detector.getContentType("image.png"); // "image/png"
2565
- * ```
2566
- */
2567
- getContentType(filename: string): string;
2568
- /**
2569
- * Detects the file type by checking magic bytes against the stream content.
2570
- *
2571
- * @param stream - The readable stream to check
2572
- * @param filename - The filename (used to get the extension)
2573
- * @returns File type information including MIME type, extension, and verification status
2574
- *
2575
- * @example
2576
- * ```typescript
2577
- * const detector = alepha.inject(FileDetector);
2578
- * const stream = createReadStream('image.png');
2579
- * const result = await detector.detectFileType(stream, 'image.png');
2580
- * console.log(result.mimeType); // 'image/png'
2581
- * console.log(result.verified); // true if magic bytes match
2582
- * ```
2583
- */
2584
- detectFileType(stream: Readable, filename: string): Promise<FileTypeResult>;
2585
- /**
2586
- * Reads all bytes from a stream and returns the first N bytes along with a new stream containing all data.
2587
- * This approach reads the entire stream upfront to avoid complex async handling issues.
2588
- *
2589
- * @protected
2590
- */
2591
- protected peekBytes(stream: Readable, numBytes: number): Promise<{
2592
- buffer: Buffer;
2593
- stream: Readable;
2594
- }>;
2595
- /**
2596
- * Checks if a buffer matches a magic byte signature.
2597
- *
2598
- * @protected
2599
- */
2600
- protected matchesSignature(buffer: Buffer, signature: (number | null)[]): boolean;
2601
- }
2602
- //#endregion
2603
- //#region ../../../alepha/src/server-static/providers/ServerStaticProvider.d.ts
2604
- declare class ServerStaticProvider {
2605
- protected readonly alepha: Alepha;
2606
- protected readonly routerProvider: ServerRouterProvider;
2607
- protected readonly dateTimeProvider: DateTimeProvider;
2608
- protected readonly fileDetector: FileDetector;
2609
- protected readonly log: Logger;
2610
- protected readonly directories: ServeDirectory[];
2611
- protected readonly configure: alepha44.HookPrimitive<"configure">;
2612
- createStaticServer(options: ServePrimitiveOptions): Promise<void>;
2613
- createFileHandler(filepath: string, options: ServePrimitiveOptions): Promise<ServerHandler>;
2614
- protected getCacheFileTypes(): string[];
2615
- protected getCacheControl(filename: string, options: ServePrimitiveOptions): {
2616
- maxAge: number;
2617
- immutable: boolean;
2618
- } | undefined;
2619
- getAllFiles(dir: string, ignoreDotEnvFiles?: boolean): Promise<string[]>;
2620
- }
2621
- interface ServeDirectory {
2622
- options: ServePrimitiveOptions;
2623
- files: string[];
2624
- }
2625
- //#endregion
2626
1139
  //#region ../../src/core/providers/ReactServerProvider.d.ts
2627
- declare const envSchema: alepha44.TObject<{
2628
- REACT_SSR_ENABLED: alepha44.TOptional<alepha44.TBoolean>;
2629
- REACT_ROOT_ID: alepha44.TString;
1140
+ declare const envSchema: alepha19.TObject<{
1141
+ REACT_SSR_ENABLED: alepha19.TOptional<alepha19.TBoolean>;
1142
+ REACT_ROOT_ID: alepha19.TString;
2630
1143
  }>;
2631
1144
  declare module "alepha" {
2632
1145
  interface Env extends Partial<Static<typeof envSchema>> {}
@@ -2638,11 +1151,11 @@ declare module "alepha" {
2638
1151
  /**
2639
1152
  * React server provider configuration atom
2640
1153
  */
2641
- declare const reactServerOptions: alepha44.Atom<alepha44.TObject<{
2642
- publicDir: alepha44.TString;
2643
- staticServer: alepha44.TObject<{
2644
- disabled: alepha44.TBoolean;
2645
- path: alepha44.TString;
1154
+ declare const reactServerOptions: alepha19.Atom<alepha19.TObject<{
1155
+ publicDir: alepha19.TString;
1156
+ staticServer: alepha19.TObject<{
1157
+ disabled: alepha19.TBoolean;
1158
+ path: alepha19.TString;
2646
1159
  }>;
2647
1160
  }>, "alepha.react.server.options">;
2648
1161
  type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
@@ -2652,7 +1165,7 @@ declare module "alepha" {
2652
1165
  }
2653
1166
  }
2654
1167
  declare class ReactServerProvider {
2655
- protected readonly log: Logger;
1168
+ protected readonly log: alepha_logger1.Logger;
2656
1169
  protected readonly alepha: Alepha;
2657
1170
  protected readonly env: {
2658
1171
  REACT_SSR_ENABLED?: boolean | undefined;
@@ -2675,7 +1188,7 @@ declare class ReactServerProvider {
2675
1188
  /**
2676
1189
  * Configure the React server provider.
2677
1190
  */
2678
- readonly onConfigure: alepha44.HookPrimitive<"configure">;
1191
+ readonly onConfigure: alepha19.HookPrimitive<"configure">;
2679
1192
  get template(): string;
2680
1193
  protected registerPages(templateLoader: TemplateLoader): Promise<void>;
2681
1194
  /**
@@ -2811,7 +1324,7 @@ declare module "alepha" {
2811
1324
  * @see {@link $page}
2812
1325
  * @module alepha.react
2813
1326
  */
2814
- declare const AlephaReact: alepha44.Service<alepha44.Module>;
1327
+ declare const AlephaReact: alepha19.Service<alepha19.Module>;
2815
1328
  //#endregion
2816
- export { $page, ActionContext, AlephaContext, AlephaReact, AnchorProps, ClientOnly, ConcretePageRoute, CreateLayersResult, ErrorBoundary, ErrorHandler, ErrorViewer, Layer, Link, type LinkProps, _default as NestedView, NotFoundPage as NotFound, PageAnimation, PageConfigSchema, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, 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 };
1329
+ export { $page, ActionContext, AlephaContext, AlephaProvider, AlephaProviderProps, AlephaReact, AnchorProps, ClientOnly, ConcretePageRoute, CreateLayersResult, ErrorBoundary, ErrorHandler, ErrorViewer, Layer, Link, type LinkProps, _default as NestedView, NotFoundPage as NotFound, PageAnimation, PageConfigSchema, PagePrimitive, PagePrimitiveOptions, PagePrimitiveRenderOptions, PagePrimitiveRenderResult, 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 };
2817
1330
  //# sourceMappingURL=index.d.ts.map