alepha 0.7.0 → 0.7.2

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 (100) hide show
  1. package/README.md +14 -3
  2. package/assets/logo.png +0 -0
  3. package/cache.cjs +0 -1
  4. package/cache.d.ts +30 -13
  5. package/cache.js +0 -1
  6. package/core.cjs +0 -1
  7. package/core.d.ts +465 -196
  8. package/core.js +0 -1
  9. package/datetime.cjs +0 -1
  10. package/datetime.d.ts +68 -79
  11. package/datetime.js +0 -1
  12. package/lock.cjs +0 -1
  13. package/lock.d.ts +3 -14
  14. package/lock.js +0 -1
  15. package/package.json +54 -53
  16. package/postgres.cjs +0 -1
  17. package/postgres.d.ts +3250 -288
  18. package/postgres.js +0 -1
  19. package/queue.cjs +0 -1
  20. package/queue.d.ts +2 -2
  21. package/queue.js +0 -1
  22. package/react/auth.cjs +0 -1
  23. package/react/auth.d.ts +12 -5
  24. package/react/auth.js +0 -1
  25. package/react.cjs +0 -1
  26. package/react.d.ts +317 -206
  27. package/react.js +0 -1
  28. package/redis.cjs +0 -1
  29. package/redis.d.ts +10 -8
  30. package/redis.js +0 -1
  31. package/retry.cjs +12 -0
  32. package/retry.d.ts +68 -0
  33. package/retry.js +1 -0
  34. package/scheduler.cjs +0 -1
  35. package/scheduler.js +0 -1
  36. package/security.cjs +0 -1
  37. package/security.d.ts +82 -35
  38. package/security.js +0 -1
  39. package/server/cookies.cjs +0 -1
  40. package/server/cookies.d.ts +1 -1
  41. package/server/cookies.js +0 -1
  42. package/server/metrics.cjs +0 -1
  43. package/server/metrics.js +0 -1
  44. package/server/static.cjs +0 -1
  45. package/server/static.d.ts +1 -0
  46. package/server/static.js +0 -1
  47. package/server/swagger.cjs +0 -1
  48. package/server/swagger.js +0 -1
  49. package/server.cjs +0 -1
  50. package/server.d.ts +402 -327
  51. package/server.js +0 -1
  52. package/src/retry.ts +1 -0
  53. package/topic.cjs +0 -1
  54. package/topic.d.ts +3 -20
  55. package/topic.js +0 -1
  56. package/vite.cjs +0 -1
  57. package/vite.d.ts +57 -38
  58. package/vite.js +0 -1
  59. package/cache.cjs.map +0 -1
  60. package/cache.js.map +0 -1
  61. package/core.cjs.map +0 -1
  62. package/core.js.map +0 -1
  63. package/datetime.cjs.map +0 -1
  64. package/datetime.js.map +0 -1
  65. package/lock.cjs.map +0 -1
  66. package/lock.js.map +0 -1
  67. package/postgres.cjs.map +0 -1
  68. package/postgres.js.map +0 -1
  69. package/queue.cjs.map +0 -1
  70. package/queue.js.map +0 -1
  71. package/react/auth.cjs.map +0 -1
  72. package/react/auth.js.map +0 -1
  73. package/react.cjs.map +0 -1
  74. package/react.js.map +0 -1
  75. package/redis.cjs.map +0 -1
  76. package/redis.js.map +0 -1
  77. package/scheduler.cjs.map +0 -1
  78. package/scheduler.js.map +0 -1
  79. package/security.cjs.map +0 -1
  80. package/security.js.map +0 -1
  81. package/server/cookies.cjs.map +0 -1
  82. package/server/cookies.js.map +0 -1
  83. package/server/metrics.cjs.map +0 -1
  84. package/server/metrics.js.map +0 -1
  85. package/server/proxy.cjs +0 -13
  86. package/server/proxy.cjs.map +0 -1
  87. package/server/proxy.d.ts +0 -1
  88. package/server/proxy.js +0 -2
  89. package/server/proxy.js.map +0 -1
  90. package/server/static.cjs.map +0 -1
  91. package/server/static.js.map +0 -1
  92. package/server/swagger.cjs.map +0 -1
  93. package/server/swagger.js.map +0 -1
  94. package/server.cjs.map +0 -1
  95. package/server.js.map +0 -1
  96. package/src/server/proxy.ts +0 -1
  97. package/topic.cjs.map +0 -1
  98. package/topic.js.map +0 -1
  99. package/vite.cjs.map +0 -1
  100. package/vite.js.map +0 -1
package/server.d.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import * as _alepha_core from '@alepha/core';
2
- import { Static as Static$1, TObject as TObject$1, TSchema as TSchema$2, Async, StreamLike, Alepha, OPTIONS, KIND, FileLike } from '@alepha/core';
2
+ import { Static as Static$1, TObject as TObject$1, TSchema as TSchema$2, Async, StreamLike, Alepha, FileLike, OPTIONS, KIND, Service } from '@alepha/core';
3
3
  export { KIND } from '@alepha/core';
4
+ import * as _alepha_cache from '@alepha/cache';
5
+ import { CacheDescriptorOptions } from '@alepha/cache';
6
+ import { DurationLike, DateTimeProvider } from '@alepha/datetime';
4
7
  import { UserAccountToken, Permission, ServiceAccountDescriptor as ServiceAccountDescriptor$1, SecurityProvider, JwtProvider } from '@alepha/security';
5
8
  import { IncomingMessage, ServerResponse as ServerResponse$1 } from 'node:http';
6
9
  import { Readable } from 'node:stream';
7
10
  import { ReadableStream } from 'node:stream/web';
8
11
  import { Route, RouterProvider } from '@alepha/router';
9
- import * as _alepha_cache from '@alepha/cache';
10
- import { DurationLike, DateTimeProvider } from '@alepha/datetime';
12
+ import * as _alepha_retry from '@alepha/retry';
11
13
  import { BusboyConfig } from '@fastify/busboy';
12
14
  import * as http from 'http';
13
15
 
@@ -20,6 +22,11 @@ declare const Hint$1: unique symbol;
20
22
  /** Symbol key applied to types */
21
23
  declare const Kind$1: unique symbol;
22
24
 
25
+ interface TAny extends TSchema$1 {
26
+ [Kind$1]: 'Any';
27
+ static: any;
28
+ }
29
+
23
30
  type TReadonly<T extends TSchema$1> = T & {
24
31
  [ReadonlyKind$1]: 'Readonly';
25
32
  };
@@ -91,6 +98,19 @@ type TOptional<T extends TSchema$1> = T & {
91
98
  [OptionalKind$1]: 'Optional';
92
99
  };
93
100
 
101
+ type RecordStatic<Key extends TSchema$1, Type extends TSchema$1, P extends unknown[]> = (Evaluate<{
102
+ [_ in Assert<Static<Key>, PropertyKey>]: Static<Type, P>;
103
+ }>);
104
+ interface TRecord<Key extends TSchema$1 = TSchema$1, Type extends TSchema$1 = TSchema$1> extends TSchema$1 {
105
+ [Kind$1]: 'Record';
106
+ static: RecordStatic<Key, Type, this['params']>;
107
+ type: 'object';
108
+ patternProperties: {
109
+ [pattern: string]: Type;
110
+ };
111
+ additionalProperties: TAdditionalProperties;
112
+ }
113
+
94
114
  /** Creates a static type from a TypeBox type */
95
115
  type Static<Type extends TSchema$1, Params extends unknown[] = [], Result = (Type & {
96
116
  params: Params;
@@ -130,6 +150,7 @@ interface TObject<T extends TProperties = TProperties> extends TSchema$1, Object
130
150
  required?: string[];
131
151
  }
132
152
 
153
+ type Assert<T, E> = T extends E ? T : never;
133
154
  type Evaluate<T> = T extends infer O ? {
134
155
  [K in keyof O]: O[K];
135
156
  } : never;
@@ -189,13 +210,23 @@ interface TSchema$1 extends TKind$1, SchemaOptions$1 {
189
210
  declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
190
211
  type RouteMethod = (typeof routeMethods)[number];
191
212
 
192
- declare const envSchema$5: TObject$1<{
213
+ type ServiceRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
214
+
215
+ declare const envSchema$4: TObject$1<{
193
216
  SERVER_ALS_ENABLED: TBoolean;
194
217
  }>;
195
218
  declare module "alepha" {
196
- interface Env extends Partial<Static$1<typeof envSchema$5>> {
219
+ interface Env extends Partial<Static$1<typeof envSchema$4>> {
197
220
  }
198
221
  }
222
+ /**
223
+ * Main router for all routes on the server side.
224
+ *
225
+ * Remember:
226
+ * - $route => generic route
227
+ * - $action => action route (for API calls)
228
+ * - $page => React route (for SSR)
229
+ */
199
230
  declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler> {
200
231
  protected readonly alepha: Alepha;
201
232
  protected readonly env: {
@@ -203,7 +234,7 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler
203
234
  };
204
235
  createRequestId(): string;
205
236
  route<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): Promise<void>;
206
- handle(route: ServerRoute, rawRequest: ServerRawRequest, responseType: ResponseType, withAls: boolean): Promise<ServerResponse>;
237
+ onRequest(route: ServerRoute, rawRequest: ServerRawRequest, responseType: ResponseType, withAls: boolean): Promise<ServerResponse>;
207
238
  protected processRequest(request: ServerRequest, route: ServerRoute, responseType: ResponseType, withAls: boolean): Promise<{
208
239
  status: number;
209
240
  headers: Record<string, string> & {
@@ -211,7 +242,7 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler
211
242
  };
212
243
  body: any;
213
244
  }>;
214
- protected tryRequestProcessing(route: ServerRoute, request: ServerRequest, responseType: ResponseType, withAls: boolean): Promise<void>;
245
+ protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseType: ResponseType, withAls: boolean): Promise<void>;
215
246
  protected getResponseType(schema?: RequestConfigSchema): ResponseType;
216
247
  protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
217
248
  validateRequest(route: {
@@ -248,14 +279,26 @@ interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchem
248
279
  }
249
280
  interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
250
281
  method?: RouteMethod;
251
- silent?: boolean;
252
282
  handler: ServerHandler<TConfig>;
253
283
  schema?: TConfig;
284
+ /**
285
+ * @see ServerLoggerProvider
286
+ */
287
+ silent?: boolean;
288
+ /**
289
+ * @see ServerSecurityProvider
290
+ */
291
+ secure?: ServerRouteSecure;
292
+ /**
293
+ * @see ServerCacheProvider
294
+ */
295
+ cache?: ServiceRouteCache;
254
296
  }
255
297
  type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : ResponseBodyType;
256
298
  type ResponseType = "json" | "text" | "void" | "file" | "any";
257
299
  type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
258
300
  type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
301
+ type ServerMiddlewareHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig> | undefined>;
259
302
  interface ServerReply {
260
303
  headers: Record<string, string> & {
261
304
  "set-cookie"?: string[];
@@ -265,7 +308,7 @@ interface ServerReply {
265
308
  redirect(url: string): void;
266
309
  }
267
310
  interface ServerResponse {
268
- body: string | ArrayBuffer | Readable | ReadableStream;
311
+ body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
269
312
  headers: Record<string, string>;
270
313
  status: number;
271
314
  }
@@ -285,6 +328,149 @@ interface ServerRawRequest {
285
328
  };
286
329
  };
287
330
  }
331
+ type ServerRouteSecure = boolean | {
332
+ permissions?: string[];
333
+ roles?: string[];
334
+ realms?: string[];
335
+ organizations?: string[];
336
+ };
337
+
338
+ declare class ActionDescriptorHelper {
339
+ name(options: ActionDescriptorOptions, _instance: any, key: string): string;
340
+ path(options: ActionDescriptorOptions, _instance: any, key: string): string;
341
+ link(options: ActionDescriptorOptions, instance: any, key: string, prefix?: string): HttpClientLink;
342
+ method(options: {
343
+ method?: string;
344
+ schema?: any;
345
+ }): RouteMethod;
346
+ permission(options: ActionDescriptorOptions, instance: any, key: string): Permission;
347
+ group(options: ActionDescriptorOptions, instance: any): string;
348
+ isMultipart(options: {
349
+ schema?: RequestConfigSchema;
350
+ }): boolean;
351
+ bodyContentType(options: ActionDescriptorOptions): string | undefined;
352
+ protected short(name: string): string;
353
+ fetchLinks(_url: string): void;
354
+ }
355
+
356
+ declare const apiLinkSchema: TObject<{
357
+ name: TString$1;
358
+ path: TString$1;
359
+ method: TOptional<TString$1>;
360
+ group: TOptional<TString$1>;
361
+ requestBodyType: TOptional<TString$1>;
362
+ service: TOptional<TString$1>;
363
+ }>;
364
+ declare const apiLinksResponseSchema: TObject<{
365
+ prefix: TOptional<TString$1>;
366
+ links: TArray<TObject<{
367
+ name: TString$1;
368
+ path: TString$1;
369
+ method: TOptional<TString$1>;
370
+ group: TOptional<TString$1>;
371
+ requestBodyType: TOptional<TString$1>;
372
+ service: TOptional<TString$1>;
373
+ }>>;
374
+ }>;
375
+ type ApiLinksResponse = Static$1<typeof apiLinksResponseSchema>;
376
+ type ApiLink = Static$1<typeof apiLinkSchema>;
377
+
378
+ declare class HttpClient {
379
+ protected readonly log: _alepha_core.Logger;
380
+ protected readonly alepha: Alepha;
381
+ protected readonly helper: ActionDescriptorHelper;
382
+ readonly cache: _alepha_cache.CacheDescriptor<HttpClientCache, any[]>;
383
+ protected readonly pendingRequests: HttpClientPendingRequests;
384
+ readonly URL_LINKS = "/api/_links";
385
+ links?: Array<HttpClientLink>;
386
+ pushLink(link: HttpClientLink): void;
387
+ clear(): Promise<void>;
388
+ fetch<T>(url: string, request?: RequestInit, options?: FetchRunOptions): Promise<FetchResponse<T>>;
389
+ json<T = any>(url: string, options?: RequestInit): Promise<T>;
390
+ protected url(host: string, link: HttpClientLink, args: ServerRequestConfigEntry): string;
391
+ protected body(init: RequestInit, headers: Record<string, string>, link: HttpClientLink, args?: ServerRequestConfigEntry): Promise<void>;
392
+ protected responseData(response: Response, options: FetchRunOptions): Promise<any>;
393
+ protected isMaybeFile(response: Response): boolean;
394
+ protected createFileLike(response: Response, defaultFileName?: string): FileLike;
395
+ protected pathVariables(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
396
+ protected queryParams(url: string, action: {
397
+ schema?: {
398
+ query?: TObject$1;
399
+ };
400
+ }, args?: ServerRequestConfigEntry): string;
401
+ /**
402
+ * Transform a link into a fetch-request then call fetch().
403
+ */
404
+ fetchLink(args: FetchLinkArgs): Promise<FetchResponse>;
405
+ /**
406
+ * Create a proxy client.
407
+ * This allows to call actions as methods, e.g. `client.actionName()`.
408
+ */
409
+ of<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
410
+ protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
411
+ /**
412
+ * Resolve a link by its name and call it.
413
+ * - If link is local, it will call the local handler.
414
+ * - If link is remote, it will make a fetch request to the remote server.
415
+ */
416
+ follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
417
+ protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
418
+ can(name: string): boolean;
419
+ getLinks(force?: boolean): Promise<HttpClientLink[]>;
420
+ }
421
+ type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
422
+ interface FetchFactoryAdditionalOptions {
423
+ host?: string | (() => string);
424
+ }
425
+ interface FetchRunOptions {
426
+ /**
427
+ * Key to identify the request in the pending requests.
428
+ */
429
+ key?: string;
430
+ /**
431
+ * The schema to validate the response against.
432
+ */
433
+ schema?: TSchema$2;
434
+ /**
435
+ * Built-in cache options.
436
+ */
437
+ cache?: boolean | number | DurationLike;
438
+ }
439
+ interface HttpClientLink extends ApiLink {
440
+ secured?: boolean;
441
+ prefix?: string;
442
+ host?: string;
443
+ service?: string;
444
+ schema?: RequestConfigSchema;
445
+ handler?: ServerHandler;
446
+ }
447
+ interface ClientScope {
448
+ group?: string;
449
+ service?: string;
450
+ }
451
+ type HttpVirtualClient<T> = {
452
+ [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
453
+ can: () => boolean;
454
+ schema: Schema;
455
+ } : never;
456
+ };
457
+ interface HttpClientCache {
458
+ data: any;
459
+ etag?: string;
460
+ }
461
+ interface FetchResponse<T = any> {
462
+ data: T;
463
+ status: number;
464
+ statusText: string;
465
+ headers: Headers;
466
+ raw?: Response;
467
+ }
468
+ interface FetchLinkArgs {
469
+ link: HttpClientLink;
470
+ host?: string;
471
+ config?: ServerRequestConfigEntry;
472
+ options?: ClientRequestOptions;
473
+ }
288
474
 
289
475
  declare const KEY$2 = "ACTION";
290
476
  interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema"> {
@@ -305,12 +491,6 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestC
305
491
  * @deprecated
306
492
  */
307
493
  security?: boolean;
308
- /**
309
- * If true, the route is secure.
310
- *
311
- * Can be a string or an array of strings to specify required roles or permissions.
312
- */
313
- secure?: boolean | string | string[];
314
494
  /**
315
495
  * Pathname of the route.
316
496
  */
@@ -357,6 +537,11 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestC
357
537
  * Main route handler. This is where the route logic is implemented.
358
538
  */
359
539
  handler?: ServerHandler<TConfig>;
540
+ /**
541
+ * If true, the route will be cached.
542
+ * - Number as seconds or boolean to enable cache.
543
+ */
544
+ cache?: boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
360
545
  }
361
546
  interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> {
362
547
  [KIND]: typeof KEY$2;
@@ -364,15 +549,20 @@ interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSc
364
549
  /**
365
550
  * Fetch or just call local route when available.
366
551
  */
367
- (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions): ClientRequestResponse<TConfig>;
552
+ (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
368
553
  /**
369
554
  * Just fetch the route. Skip any local route.
370
555
  */
371
- fetch: (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions) => ClientRequestResponse<TConfig>;
556
+ fetch: (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions) => Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
372
557
  /**
373
558
  * Name of the permission required to access this route.
374
559
  */
375
560
  permission: () => string;
561
+ /**
562
+ * Invalidate the cache for this action.
563
+ * This is only available if the action has cache enabled.
564
+ */
565
+ invalidate: () => Promise<void>;
376
566
  }
377
567
  declare const $action: {
378
568
  <TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
@@ -387,24 +577,21 @@ type ClientRequestEntryContainer<TConfig extends RequestConfigSchema = RequestCo
387
577
  headers?: TConfig["headers"] extends TSchema$2 ? Static$1<TConfig["headers"]> : undefined;
388
578
  query?: TConfig["query"] extends TSchema$2 ? Partial<Static$1<TConfig["query"]>> : undefined;
389
579
  };
390
- interface ClientRequestOptions {
391
- /**
392
- * Built-in cache options.
393
- * Number as seconds or boolean to enable cache.
394
- */
395
- cache?: number | boolean;
580
+ interface ClientRequestOptions extends FetchRunOptions {
396
581
  /**
397
582
  * Forward user from the previous request.
583
+ * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
584
+ * If "context", use the user from the current context (e.g. request).
398
585
  *
399
- * In testing environments, you can pass a partial user token.
586
+ * @default "system" is provided, else "context" is used.
400
587
  */
401
- user?: Partial<UserAccountToken>;
588
+ user?: UserAccountToken | "system" | "context";
402
589
  /**
403
590
  * Standard request fetch options.
404
591
  */
405
592
  request?: RequestInit;
406
593
  }
407
- type ClientRequestResponse<TConfig extends RequestConfigSchema> = Promise<TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : Response>;
594
+ type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : any;
408
595
 
409
596
  declare class HttpError extends Error {
410
597
  static toJSON(error: HttpError): {
@@ -438,116 +625,59 @@ declare class HttpError extends Error {
438
625
  }, cause?: unknown);
439
626
  }
440
627
  declare const errorNameByStatus: Record<number, string>;
441
-
442
- declare class ActionDescriptorHelper {
443
- name(options: ActionDescriptorOptions, instance: any, key: string): string;
444
- path(options: ActionDescriptorOptions, instance: any, key: string): string;
445
- link(options: ActionDescriptorOptions, instance: any, key: string, prefix?: string): HttpClientLink;
446
- method(options: {
447
- method?: string;
448
- schema?: any;
449
- }): RouteMethod;
450
- permission(options: ActionDescriptorOptions, instance: any, key: string): Permission;
451
- group(options: ActionDescriptorOptions, instance: any): string;
452
- isMultipart(options: {
453
- schema?: RequestConfigSchema;
454
- }): boolean;
455
- bodyContentType(options: ActionDescriptorOptions): string | undefined;
456
- protected short(name: string): string;
457
- fetchLinks(url: string): void;
628
+ declare const isHttpError: (error: unknown) => error is HttpErrorLike;
629
+ interface HttpErrorLike extends Error {
630
+ status: number;
458
631
  }
459
632
 
460
- declare const apiLinkSchema: TObject<{
461
- name: TString$1;
462
- path: TString$1;
463
- method: TOptional<TString$1>;
464
- group: TOptional<TString$1>;
465
- requestBodyType: TOptional<TString$1>;
466
- service: TOptional<TString$1>;
467
- }>;
468
- declare const apiLinksResponseSchema: TObject<{
469
- userId: TOptional<TString$1>;
470
- prefix: TOptional<TString$1>;
471
- links: TArray<TObject<{
472
- name: TString$1;
473
- path: TString$1;
474
- method: TOptional<TString$1>;
475
- group: TOptional<TString$1>;
476
- requestBodyType: TOptional<TString$1>;
477
- service: TOptional<TString$1>;
478
- }>>;
479
- }>;
480
- type ApiLinksResponse = Static$1<typeof apiLinksResponseSchema>;
481
- type ApiLink = Static$1<typeof apiLinkSchema>;
633
+ declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
482
634
 
483
- declare class HttpClient {
484
- protected readonly alepha: Alepha;
485
- protected readonly helper: ActionDescriptorHelper;
486
- readonly URL_LINKS = "/api/_links";
487
- readonly cache: _alepha_cache.CacheDescriptor<any, any[]>;
488
- protected links?: Array<HttpClientLink>;
489
- protected readonly pendingRequests: HttpClientPendingRequests;
490
- pushLink(link: HttpClientLink): void;
491
- clear(): Promise<void>;
492
- createFetchFunction(link: HttpClientLink, args?: FetchFactoryAdditionalOptions): (config?: Partial<ClientRequestEntry>, options?: ClientRequestOptions) => Promise<any>;
493
- request(args: {
494
- config?: ServerRequestConfigEntry;
495
- link: HttpClientLink;
496
- options?: ClientRequestOptions;
497
- host?: string;
498
- }): Promise<any>;
499
- protected url(host: string, link: HttpClientLink, args: ServerRequestConfigEntry): string;
500
- protected body(init: RequestInit, headers: Record<string, string>, link: HttpClientLink, args?: ServerRequestConfigEntry): Promise<void>;
501
- fetch<T>(url: string, request: RequestInit, options?: FetchRunOptions): Promise<T>;
635
+ type ProxyDescriptorOptions = {
636
+ path: string;
637
+ target: string;
638
+ disabled?: boolean;
639
+ beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
640
+ afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
641
+ rewrite?: (url: URL) => void;
642
+ };
643
+ interface ProxyDescriptor {
644
+ [KIND]: "PROXY";
645
+ [OPTIONS]: ProxyDescriptorOptions;
646
+ }
647
+ declare const $proxy: {
648
+ (options: ProxyDescriptorOptions): ProxyDescriptor;
649
+ [KIND]: string;
650
+ };
651
+
652
+ /**
653
+ * Represents a User Account extracted from JWT.
654
+ */
655
+ interface UserAccountInfo {
502
656
  /**
503
- * Parse the response.
504
- *
505
- * @param response
506
- * @param options
507
- * @protected
657
+ * ID of user account. Based on JWT.sub.
508
658
  */
509
- protected response(response: Response, options: FetchRunOptions): Promise<Response | any>;
510
- protected isMaybeFile(response: Response): boolean;
511
- protected getFileLike(response: Response, defaultFileName?: string): FileLike;
512
- protected pathVariables(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
513
- queryParams(url: string, action: {
514
- schema?: {
515
- query?: TObject$1;
516
- };
517
- }, args?: ServerRequestConfigEntry): string;
518
- of<T extends object>(link?: {
519
- group?: string;
520
- }): HttpVirtualClient<T>;
521
- follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & {
522
- group?: string;
523
- service?: string;
524
- }): Promise<any>;
525
- can(name: string): boolean;
526
- getLinks(): Promise<HttpClientLink[]>;
527
- json<T = any>(url: string, options?: RequestInit): Promise<T>;
528
- }
529
- type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
530
- interface FetchFactoryAdditionalOptions {
531
- host?: string | (() => string);
532
- }
533
- interface FetchRunOptions {
534
- schema?: TSchema$2;
535
- raw?: boolean;
536
- cache?: boolean | DurationLike;
537
- }
538
- interface HttpClientLink extends ApiLink {
539
- secured?: boolean;
540
- prefix?: string;
541
- host?: string;
542
- service?: string;
543
- schema?: RequestConfigSchema;
544
- handler?: ServerHandler;
659
+ id: string;
660
+ /**
661
+ * Represents the roles assigned to a user.
662
+ */
663
+ roles?: string[];
664
+ /**
665
+ * User full name, if available.
666
+ */
667
+ name?: string;
668
+ /**
669
+ * User email, if available.
670
+ */
671
+ email?: string;
672
+ /**
673
+ * User profile picture URL, if available.
674
+ */
675
+ picture?: string;
676
+ /**
677
+ * Organization ID, if available.
678
+ */
679
+ organization?: string;
545
680
  }
546
- type HttpVirtualClient<T> = {
547
- [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] & {
548
- can: () => boolean;
549
- };
550
- };
551
681
 
552
682
  /** Symbol key applied to readonly types */
553
683
  declare const ReadonlyKind: unique symbol;
@@ -609,69 +739,25 @@ interface TSchema extends TKind, SchemaOptions {
609
739
  static: unknown;
610
740
  }
611
741
 
612
- declare const envSchema$4: _alepha_core.TObject<{
742
+ declare const envSchema$3: _alepha_core.TObject<{
613
743
  SECURITY_SECRET_KEY: TString;
614
744
  }>;
615
- declare module "alepha/core" {
616
- interface Env extends Partial<Static$1<typeof envSchema$4>> {
617
- }
618
- }
619
- type ServiceAccountDescriptorOptions = {
620
- oauth2: {
621
- /**
622
- * Get Token URL.
623
- */
624
- url: string;
625
- /**
626
- * Client ID.
627
- */
628
- clientId: string;
629
- /**
630
- * Client Secret.
631
- */
632
- clientSecret: string;
633
- /**
634
- * Scopes to request.
635
- */
636
- scope?: string;
637
- };
638
- } | {
639
- jwt: {
640
- secret: string;
641
- roles?: string[];
642
- };
643
- };
644
745
  interface ServiceAccountDescriptor {
645
- options: ServiceAccountDescriptorOptions;
646
- store: ServiceAccountStore;
647
746
  token: () => Promise<string>;
648
- fetch(url: string, options?: RequestInit): Promise<Response>;
649
747
  }
650
- interface AccessTokenResponse {
651
- access_token: string;
652
- expires_in: number;
653
- at: number;
654
- }
655
- interface ServiceAccountStore {
656
- response?: AccessTokenResponse;
748
+ declare module "alepha/core" {
749
+ interface Env extends Partial<Static$1<typeof envSchema$3>> {
750
+ }
657
751
  }
658
752
 
659
- type ProxyDescriptorOptions = {
660
- path: string;
661
- target: string;
662
- disabled?: boolean;
663
- beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
664
- afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
665
- rewrite?: (url: URL) => void;
666
- };
667
- interface ProxyDescriptor {
668
- [KIND]: "PROXY";
669
- [OPTIONS]: ProxyDescriptorOptions;
753
+ declare module "@alepha/core" {
754
+ interface Hooks {
755
+ "security:user:created": {
756
+ realm: string;
757
+ user: UserAccountInfo;
758
+ };
759
+ }
670
760
  }
671
- declare const $proxy: {
672
- (options: ProxyDescriptorOptions): ProxyDescriptor;
673
- [KIND]: string;
674
- };
675
761
 
676
762
  declare const KEY$1 = "REMOTE";
677
763
  interface RemoteDescriptorOptions {
@@ -706,7 +792,12 @@ interface RemoteDescriptorOptions {
706
792
  * If true, all methods of the remote service will be exposed as actions in this context.
707
793
  * > Note: Proxy will never use the service account, it just... proxies the request.
708
794
  */
709
- proxy?: boolean | Partial<ProxyDescriptorOptions>;
795
+ proxy?: boolean | Partial<ProxyDescriptorOptions & {
796
+ /**
797
+ * If true, the remote service won't be available internally, only through the proxy.
798
+ */
799
+ noInternal: boolean;
800
+ }>;
710
801
  /**
711
802
  * For communication between the server and the remote service with a security layer.
712
803
  * This will be used for internal communication and will not be exposed to the client.
@@ -731,8 +822,6 @@ declare const $remote: {
731
822
  [KIND]: string;
732
823
  };
733
824
 
734
- declare const $client: <T extends object>() => HttpVirtualClient<T>;
735
-
736
825
  declare const KEY = "ROUTE";
737
826
  interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {
738
827
  }
@@ -745,17 +834,77 @@ declare const $route: {
745
834
  [KIND]: string;
746
835
  };
747
836
 
837
+ declare class BadRequestError extends HttpError {
838
+ constructor(message?: string, cause?: unknown);
839
+ }
840
+
841
+ declare class ConflictError extends HttpError {
842
+ constructor(message?: string, cause?: unknown);
843
+ }
844
+
845
+ declare class ForbiddenError extends HttpError {
846
+ constructor(message?: string, cause?: unknown);
847
+ }
848
+
849
+ declare class NotFoundError extends HttpError {
850
+ constructor(message?: string, cause?: unknown);
851
+ }
852
+
853
+ declare class UnauthorizedError extends HttpError {
854
+ constructor(message?: string, cause?: unknown);
855
+ }
856
+
857
+ declare class ValidationError extends HttpError {
858
+ constructor(message?: string, cause?: unknown);
859
+ }
860
+
861
+ /**
862
+ * Register `/health` endpoint.
863
+ *
864
+ * - Provides basic health information about the server.
865
+ */
866
+ declare class ServerHealthProvider {
867
+ protected readonly dateTimeProvider: DateTimeProvider;
868
+ protected readonly alepha: Alepha;
869
+ readonly health: RouteDescriptor<{
870
+ response: TObject<{
871
+ message: TString$1;
872
+ uptime: TNumber;
873
+ date: TString$1;
874
+ ready: TBoolean;
875
+ }>;
876
+ }>;
877
+ }
878
+
879
+ declare class ProxyDescriptorProvider {
880
+ protected readonly log: _alepha_core.Logger;
881
+ protected readonly routerProvider: ServerRouterProvider;
882
+ protected readonly alepha: Alepha;
883
+ readonly configure: _alepha_core.HookDescriptor<"configure">;
884
+ createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
885
+ proxy(options: ProxyDescriptorOptions): Promise<void>;
886
+ private getRawRequestBody;
887
+ }
888
+
748
889
  declare class ServerProvider {
749
890
  constructor();
750
891
  get hostname(): string;
751
892
  }
752
893
 
753
- declare const envSchema$3: _alepha_core.TObject<{
894
+ declare const envSchema$2: _alepha_core.TObject<{
754
895
  SERVER_API_PREFIX: TString$1;
755
896
  SERVER_SECURITY_ENABLED: TBoolean;
756
897
  }>;
757
898
  declare module "@alepha/core" {
758
- interface Env extends Partial<Static$1<typeof envSchema$3>> {
899
+ interface Env extends Partial<Static$1<typeof envSchema$2>> {
900
+ }
901
+ interface State {
902
+ /**
903
+ * Real (or fake) user account, used for internal actions.
904
+ * If you define this, you assume that all actions are executed by this user by default.
905
+ * And to force a different user, you need to pass it explicitly in the options.
906
+ */
907
+ "ServerSecurityProvider.localSystemUser"?: UserAccountToken;
759
908
  }
760
909
  }
761
910
  declare class ServerActionDescriptorProvider {
@@ -774,37 +923,33 @@ declare class ServerActionDescriptorProvider {
774
923
  getPrefix(): string;
775
924
  readonly configure: _alepha_core.HookDescriptor<"configure">;
776
925
  registerAction(value: ActionDescriptor, key: string, instance: any, prefix?: string): Promise<void>;
777
- /**
778
- * @deprecated
779
- */
780
- registerActionApi(routeDescriptor: ActionDescriptor, instance: any, key: string): void;
781
926
  /**
782
927
  * Check a mock function for the specified route.
783
928
  *
784
929
  * This is mostly used for testing purposes.
785
- *
786
- * @param value
787
- * @param permission
788
- * @protected
789
930
  */
790
- protected createLocalFunction(value: ActionDescriptor, permission: Permission): (config?: ServerRequestConfigEntry, options?: ClientRequestOptions) => Promise<any>;
931
+ protected createLocalFunction(action: ActionDescriptorOptions, permission: Permission): (config?: ServerRequestConfigEntry, options?: ClientRequestOptions) => Promise<any>;
791
932
  /**
792
- * Security adapted for local function.
933
+ * Get the user account token for a local action call.
934
+ * It will check the options, context, and system user.
793
935
  */
794
936
  protected getUserFromLocalFunctionContext(options: {
795
- user?: Partial<UserAccountToken>;
796
- }, permission: Permission, security: boolean): UserAccountToken | undefined;
797
- /**
798
- * TODO: remove it, this is a hack for testing purposes
799
- */
800
- protected createSystemUser(): UserAccountToken;
937
+ user?: UserAccountToken | "system" | "context";
938
+ }, permission: Permission, isRouteSecure: boolean): UserAccountToken | undefined;
801
939
  }
802
940
  declare const isServerAction: (value: any) => value is ServerRouteAction;
803
941
  interface ServerRemote {
804
942
  url: string;
805
943
  name: string;
806
944
  proxy: boolean;
807
- links: (authorization?: string) => Promise<ApiLinksResponse>;
945
+ internal: boolean;
946
+ links: (args: {
947
+ authorization?: string;
948
+ }) => Promise<ApiLinksResponse>;
949
+ schema: (args: {
950
+ name: string;
951
+ authorization?: string;
952
+ }) => Promise<any>;
808
953
  serviceAccount?: ServiceAccountDescriptor$1;
809
954
  prefix: string;
810
955
  }
@@ -817,16 +962,10 @@ interface ServerRouteAction<TConfig extends RequestConfigSchema = RequestConfigS
817
962
  options: ActionDescriptorOptions;
818
963
  }
819
964
 
820
- declare class ProxyDescriptorProvider {
821
- protected readonly routerProvider: ServerRouterProvider;
822
- protected readonly alepha: Alepha;
823
- readonly configure: _alepha_core.HookDescriptor<"configure">;
824
- createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
825
- proxy(options: ProxyDescriptorOptions): Promise<void>;
826
- private getRawRequestBody;
827
- }
828
-
829
965
  declare class RemoteDescriptorProvider {
966
+ static path: {
967
+ apiLinks: string;
968
+ };
830
969
  protected readonly alepha: Alepha;
831
970
  protected readonly client: HttpClient;
832
971
  protected readonly proxyProvider: ProxyDescriptorProvider;
@@ -836,52 +975,21 @@ declare class RemoteDescriptorProvider {
836
975
  readonly configure: _alepha_core.HookDescriptor<"configure">;
837
976
  readonly start: _alepha_core.HookDescriptor<"start">;
838
977
  registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
839
- protected readonly fetchLinks: (opts: {
978
+ protected readonly fetchLinks: _alepha_retry.RetryDescriptor<(opts: {
840
979
  service: string;
841
980
  url: string;
842
981
  authorization?: string;
843
982
  }) => Promise<{
844
- userId?: string | undefined;
845
983
  prefix?: string | undefined;
846
984
  links: {
847
- method?: string | undefined;
848
985
  group?: string | undefined;
986
+ method?: string | undefined;
849
987
  requestBodyType?: string | undefined;
850
988
  service?: string | undefined;
851
989
  path: string;
852
990
  name: string;
853
991
  }[];
854
- }>;
855
- }
856
-
857
- declare const envSchema$2: _alepha_core.TObject<{
858
- SERVER_API_URL: TString$1;
859
- }>;
860
- declare module "@alepha/core" {
861
- interface Env extends Partial<Static$1<typeof envSchema$2>> {
862
- }
863
- }
864
- declare class BrowserActionDescriptorProvider {
865
- protected readonly log: _alepha_core.Logger;
866
- protected readonly alepha: Alepha;
867
- protected readonly client: HttpClient;
868
- protected readonly env: {
869
- SERVER_API_URL: string;
870
- };
871
- protected readonly helper: ActionDescriptorHelper;
872
- readonly configure: _alepha_core.HookDescriptor<"configure">;
873
- configureActions(): void;
874
- registerAction(value: ActionDescriptor, instance: any, key: string): void;
875
- }
876
-
877
- declare class ServerSecurityProvider {
878
- protected readonly log: _alepha_core.Logger;
879
- protected readonly securityProvider: SecurityProvider;
880
- protected readonly jwtProvider: JwtProvider;
881
- protected readonly alepha: Alepha;
882
- readonly onClientRequest: _alepha_core.HookDescriptor<"client:onRequest">;
883
- protected readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
884
- protected readonly onRoute: _alepha_core.HookDescriptor<"server:onRoute">;
992
+ }>>;
885
993
  }
886
994
 
887
995
  declare class ServerLinksProvider {
@@ -891,7 +999,6 @@ declare class ServerLinksProvider {
891
999
  protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
892
1000
  readonly links: RouteDescriptor<{
893
1001
  response: TObject<{
894
- userId: TOptional<TString$1>;
895
1002
  prefix: TOptional<TString$1>;
896
1003
  links: TArray<TObject<{
897
1004
  name: TString$1;
@@ -903,21 +1010,16 @@ declare class ServerLinksProvider {
903
1010
  }>>;
904
1011
  }>;
905
1012
  }>;
1013
+ readonly schema: RouteDescriptor<{
1014
+ params: TObject<{
1015
+ name: TString$1;
1016
+ }>;
1017
+ response: TRecord<TString$1, TAny>;
1018
+ }>;
906
1019
  getLinks(options: {
907
1020
  user?: UserAccountToken;
908
1021
  authorization?: string;
909
- }): Promise<{
910
- userId: string | undefined;
911
- prefix: string;
912
- links: {
913
- method?: string | undefined;
914
- group?: string | undefined;
915
- requestBodyType?: string | undefined;
916
- service?: string | undefined;
917
- path: string;
918
- name: string;
919
- }[];
920
- }>;
1022
+ }): Promise<ApiLinksResponse>;
921
1023
  }
922
1024
 
923
1025
  declare class ServerLoggerProvider {
@@ -928,36 +1030,6 @@ declare class ServerLoggerProvider {
928
1030
  readonly onResponse: _alepha_core.HookDescriptor<"server:onResponse">;
929
1031
  }
930
1032
 
931
- /**
932
- * Register `/health` endpoint.
933
- *
934
- * - Provides basic health information about the server.
935
- */
936
- declare class ServerHealthProvider {
937
- protected readonly dateTimeProvider: DateTimeProvider;
938
- protected readonly alepha: Alepha;
939
- readonly health: RouteDescriptor<{
940
- response: TObject<{
941
- message: TString$1;
942
- uptime: TNumber;
943
- date: TString$1;
944
- ready: TBoolean;
945
- }>;
946
- }>;
947
- }
948
-
949
- /**
950
- * On every request, this provider checks if the server is ready.
951
- *
952
- * If the server is not ready, it responds with a 503 status code and a message indicating that the server is not ready yet.
953
- *
954
- * The response also includes a `Retry-After` header indicating that the client should retry after 5 seconds.
955
- */
956
- declare class ServerNotReadyProvider {
957
- protected readonly alepha: Alepha;
958
- readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
959
- }
960
-
961
1033
  declare class ServerMultipartProvider {
962
1034
  protected readonly helper: ActionDescriptorHelper;
963
1035
  protected readonly alepha: Alepha;
@@ -981,17 +1053,40 @@ interface HybridFile extends FileLike {
981
1053
  tmpPath: string;
982
1054
  };
983
1055
  }
1056
+
984
1057
  /**
985
- * Create a file-like object from various sources.
1058
+ * On every request, this provider checks if the server is ready.
1059
+ *
1060
+ * If the server is not ready, it responds with a 503 status code and a message indicating that the server is not ready yet.
1061
+ *
1062
+ * The response also includes a `Retry-After` header indicating that the client should retry after 5 seconds.
986
1063
  */
987
- declare const file: (source: string | Buffer | ArrayBuffer | StreamLike, options?: {
988
- type?: string;
989
- name?: string;
990
- }) => FileLike;
991
- declare const bufferToStream: (buffer: Buffer) => Readable;
992
- declare const streamToBuffer: (stream: Readable) => Promise<Buffer>;
993
- declare const bufferToArrayBuffer: (buffer: Buffer) => ArrayBuffer;
994
- declare const getContentType: (filename: string) => string;
1064
+ declare class ServerNotReadyProvider {
1065
+ protected readonly alepha: Alepha;
1066
+ readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1067
+ }
1068
+
1069
+ declare class ServerSecurityProvider {
1070
+ protected readonly log: _alepha_core.Logger;
1071
+ protected readonly securityProvider: SecurityProvider;
1072
+ protected readonly jwtProvider: JwtProvider;
1073
+ protected readonly alepha: Alepha;
1074
+ readonly onClientRequest: _alepha_core.HookDescriptor<"client:onRequest">;
1075
+ protected readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1076
+ protected readonly onRoute: _alepha_core.HookDescriptor<"server:onRoute">;
1077
+ }
1078
+
1079
+ type TimingMap = Record<string, [number, number]>;
1080
+ declare class ServerTimingProvider {
1081
+ protected readonly log: _alepha_core.Logger;
1082
+ protected readonly alepha: Alepha;
1083
+ readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1084
+ readonly onResponse: _alepha_core.HookDescriptor<"server:onResponse">;
1085
+ protected get handlerName(): string;
1086
+ beginTiming(name: string): void;
1087
+ endTiming(name: string): void;
1088
+ protected setDuration(name: string, timing: TimingMap): void;
1089
+ }
995
1090
 
996
1091
  declare const envSchema$1: _alepha_core.TObject<{
997
1092
  SERVER_PORT: TNumber;
@@ -1012,6 +1107,7 @@ declare class NodeHttpServerProvider implements ServerProvider {
1012
1107
  protected readonly server: http.Server<typeof IncomingMessage, typeof ServerResponse$1>;
1013
1108
  handle(req: IncomingMessage, res: ServerResponse$1): Promise<number | void>;
1014
1109
  createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
1110
+ getProtocol(req: IncomingMessage): "http" | "https";
1015
1111
  shouldHaveBody(method: string): boolean;
1016
1112
  get hostname(): string;
1017
1113
  readonly start: _alepha_core.HookDescriptor<"start">;
@@ -1038,34 +1134,11 @@ declare const okSchema: TObject<{
1038
1134
  }>;
1039
1135
  type Ok = Static$1<typeof okSchema>;
1040
1136
 
1041
- declare class BadRequestError extends HttpError {
1042
- constructor(message?: string, cause?: unknown);
1043
- }
1044
-
1045
- declare class ConflictError extends HttpError {
1046
- constructor(message?: string, cause?: unknown);
1047
- }
1048
-
1049
- declare class ForbiddenError extends HttpError {
1050
- constructor(message?: string, cause?: unknown);
1051
- }
1052
-
1053
- declare class NotFoundError extends HttpError {
1054
- constructor(message?: string, cause?: unknown);
1055
- }
1056
-
1057
- declare class UnauthorizedError extends HttpError {
1058
- constructor(message?: string, cause?: unknown);
1059
- }
1060
-
1061
- declare class ValidationError extends HttpError {
1062
- constructor(message?: string, cause?: unknown);
1063
- }
1064
-
1065
1137
  declare const envSchema: _alepha_core.TObject<{
1066
1138
  SERVER_LINKS_ENABLED: TBoolean;
1067
1139
  SERVER_HEALTH_ENABLED: TBoolean;
1068
1140
  SERVER_NOT_READY_ENABLED: TBoolean;
1141
+ SERVER_TIMING_ENABLED: TOptional<TBoolean>;
1069
1142
  }>;
1070
1143
  declare module "@alepha/core" {
1071
1144
  interface Hooks {
@@ -1113,7 +1186,9 @@ declare module "@alepha/core" {
1113
1186
  }
1114
1187
  }
1115
1188
  declare class ServerModule {
1189
+ static plugins: Array<Service>;
1116
1190
  protected readonly env: {
1191
+ SERVER_TIMING_ENABLED?: boolean | undefined;
1117
1192
  SERVER_LINKS_ENABLED: boolean;
1118
1193
  SERVER_HEALTH_ENABLED: boolean;
1119
1194
  SERVER_NOT_READY_ENABLED: boolean;
@@ -1122,4 +1197,4 @@ declare class ServerModule {
1122
1197
  constructor();
1123
1198
  }
1124
1199
 
1125
- export { $action, $client, $proxy, $remote, $route, type ActionDescriptor, type ActionDescriptorOptions, type ApiLink, type ApiLinksResponse, BadRequestError, BrowserActionDescriptorProvider, type ClientRequestEntry, type ClientRequestEntryContainer, type ClientRequestOptions, type ClientRequestResponse, ConflictError, type FetchFactoryAdditionalOptions, type FetchRunOptions, ForbiddenError, HttpClient, type HttpClientLink, type HttpClientPendingRequests, HttpError, type HttpVirtualClient, NodeHttpServerProvider, NotFoundError, type Ok, type ProxyDescriptor, type ProxyDescriptorOptions, ProxyDescriptorProvider, type RemoteDescriptor, type RemoteDescriptorOptions, RemoteDescriptorProvider, type RequestConfigSchema, type ResponseBodyType, type ResponseType, type RouteDescriptor, type RouteDescriptorOptions, type RouteMethod, ServerActionDescriptorProvider, type ServerHandler, ServerHealthProvider, ServerLinksProvider, ServerLoggerProvider, ServerModule, ServerMultipartProvider, ServerNotReadyProvider, ServerProvider, type ServerRawRequest, type ServerRemote, type ServerReply, type ServerRequest, type ServerRequestConfig, type ServerRequestConfigEntry, type ServerResponse, type ServerResponseBody, type ServerRoute, type ServerRouteAction, type ServerRouteWithHandler, ServerRouterProvider, ServerSecurityProvider, UnauthorizedError, ValidationError, apiLinkSchema, apiLinksResponseSchema, bufferToArrayBuffer, bufferToStream, errorNameByStatus, errorSchema, file, getContentType, isServerAction, okSchema, routeMethods, streamToBuffer };
1200
+ export { $action, $client, $proxy, $remote, $route, type ActionDescriptor, type ActionDescriptorOptions, type ApiLink, type ApiLinksResponse, BadRequestError, type ClientRequestEntry, type ClientRequestEntryContainer, type ClientRequestOptions, type ClientRequestResponse, type ClientScope, ConflictError, type FetchFactoryAdditionalOptions, type FetchLinkArgs, type FetchResponse, type FetchRunOptions, ForbiddenError, HttpClient, type HttpClientLink, type HttpClientPendingRequests, HttpError, type HttpErrorLike, type HttpVirtualClient, NodeHttpServerProvider, NotFoundError, type Ok, type ProxyDescriptor, type ProxyDescriptorOptions, ProxyDescriptorProvider, type RemoteDescriptor, type RemoteDescriptorOptions, RemoteDescriptorProvider, type RequestConfigSchema, type ResponseBodyType, type ResponseType, type RouteDescriptor, type RouteDescriptorOptions, type RouteMethod, ServerActionDescriptorProvider, type ServerHandler, ServerHealthProvider, ServerLinksProvider, ServerLoggerProvider, type ServerMiddlewareHandler, ServerModule, ServerMultipartProvider, ServerNotReadyProvider, ServerProvider, type ServerRawRequest, type ServerRemote, type ServerReply, type ServerRequest, type ServerRequestConfig, type ServerRequestConfigEntry, type ServerResponse, type ServerResponseBody, type ServerRoute, type ServerRouteAction, type ServerRouteSecure, type ServerRouteWithHandler, ServerRouterProvider, ServerSecurityProvider, ServerTimingProvider, UnauthorizedError, ValidationError, apiLinkSchema, apiLinksResponseSchema, errorNameByStatus, errorSchema, isHttpError, isServerAction, okSchema, routeMethods };