alepha 0.10.5 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server/cache.d.ts CHANGED
@@ -9,8 +9,14 @@ import { RequestConfigSchema, ServerRequest, ServerRoute } from "alepha/server";
9
9
  //#region src/providers/ServerCacheProvider.d.ts
10
10
  declare module "alepha/server" {
11
11
  interface ServerRoute {
12
+ /**
13
+ * Enable caching for this route.
14
+ * - If true: enables both store and etag
15
+ * - If object: fine-grained control over store, etag, and cache-control headers
16
+ *
17
+ * @default false
18
+ */
12
19
  cache?: ServerRouteCache;
13
- etag?: string;
14
20
  }
15
21
  interface ActionDescriptor<TConfig extends RequestConfigSchema> {
16
22
  invalidate: () => Promise<void>;
@@ -26,16 +32,94 @@ declare class ServerCacheProvider {
26
32
  protected readonly onActionRequest: _alepha_core1.HookDescriptor<"action:onRequest">;
27
33
  protected readonly onActionResponse: _alepha_core1.HookDescriptor<"action:onResponse">;
28
34
  protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
35
+ protected readonly onSend: _alepha_core1.HookDescriptor<"server:onSend">;
29
36
  protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
30
- protected getCacheOptions(cache: ServerRouteCache): {
31
- provider?: (_alepha_core1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
32
- name?: string | undefined;
33
- ttl?: DurationLike | undefined;
34
- disabled?: boolean | undefined;
35
- };
37
+ buildCacheControlHeader(cache?: ServerRouteCache): string | undefined;
38
+ protected durationToSeconds(duration: number | DurationLike): number;
39
+ protected shouldStore(cache?: ServerRouteCache): boolean;
40
+ protected shouldUseEtag(cache?: ServerRouteCache): boolean;
36
41
  protected createCacheKey(route: ServerRoute, config?: ServerRequest): string;
37
42
  }
38
- type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
43
+ type ServerRouteCache =
44
+ /**
45
+ * If true, enables caching with:
46
+ * - store: true
47
+ * - etag: true
48
+ */
49
+ boolean
50
+ /**
51
+ * Object configuration for fine-grained cache control.
52
+ *
53
+ * If empty, no caching will be applied.
54
+ */ | {
55
+ /**
56
+ * If true, enables storing cached responses. (in-memory, Redis, @see @alepha/cache for other providers)
57
+ * If a DurationLike is provided, it will be used as the TTL for the cache.
58
+ * If CacheDescriptorOptions is provided, it will be used to configure the cache storage.
59
+ *
60
+ * @default false
61
+ */
62
+ store?: true | DurationLike | CacheDescriptorOptions;
63
+ /**
64
+ * If true, enables ETag support for the cached responses.
65
+ */
66
+ etag?: true;
67
+ /**
68
+ * - If true, sets Cache-Control to "public, max-age=300" (5 minutes).
69
+ * - If string, sets Cache-Control to the provided value directly.
70
+ * - If object, configures Cache-Control directives.
71
+ */
72
+ control?: true
73
+ /**
74
+ * If string, sets Cache-Control to the provided value directly.
75
+ */ | string
76
+ /**
77
+ * If object, configures Cache-Control directives.
78
+ */ | {
79
+ /**
80
+ * Indicates that the response may be cached by any cache.
81
+ */
82
+ public?: boolean;
83
+ /**
84
+ * Indicates that the response is intended for a single user and must not be stored by a shared cache.
85
+ */
86
+ private?: boolean;
87
+ /**
88
+ * Forces caches to submit the request to the origin server for validation before releasing a cached copy.
89
+ */
90
+ noCache?: boolean;
91
+ /**
92
+ * Instructs caches not to store the response.
93
+ */
94
+ noStore?: boolean;
95
+ /**
96
+ * Maximum amount of time a resource is considered fresh.
97
+ * Can be specified as a number (seconds) or as a DurationLike object.
98
+ *
99
+ * @example 300 // 5 minutes in seconds
100
+ * @example { minutes: 5 } // 5 minutes
101
+ * @example { hours: 1 } // 1 hour
102
+ */
103
+ maxAge?: number | DurationLike;
104
+ /**
105
+ * Overrides max-age for shared caches (e.g., CDNs).
106
+ * Can be specified as a number (seconds) or as a DurationLike object.
107
+ */
108
+ sMaxAge?: number | DurationLike;
109
+ /**
110
+ * Indicates that once a resource becomes stale, caches must not use it without successful validation.
111
+ */
112
+ mustRevalidate?: boolean;
113
+ /**
114
+ * Similar to must-revalidate, but only for shared caches.
115
+ */
116
+ proxyRevalidate?: boolean;
117
+ /**
118
+ * Indicates that the response can be stored but must be revalidated before each use.
119
+ */
120
+ immutable?: boolean;
121
+ };
122
+ };
39
123
  interface RouteCacheEntry {
40
124
  contentType?: string;
41
125
  body: any;
@@ -45,9 +45,9 @@ declare const $cookie: {
45
45
  <T extends TSchema>(options: CookieDescriptorOptions<T>): AbstractCookieDescriptor<T>;
46
46
  [KIND]: typeof CookieDescriptor;
47
47
  };
48
- interface CookieDescriptorOptions<T extends TSchema> {
48
+ interface CookieDescriptorOptions<T$1 extends TSchema> {
49
49
  /** The schema for the cookie's value, used for validation and type safety. */
50
- schema: T;
50
+ schema: T$1;
51
51
  /** The name of the cookie. */
52
52
  name?: string;
53
53
  /** The cookie's path. Defaults to "/". */
@@ -69,28 +69,28 @@ interface CookieDescriptorOptions<T extends TSchema> {
69
69
  /** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
70
70
  sign?: boolean;
71
71
  }
72
- interface AbstractCookieDescriptor<T extends TSchema> {
72
+ interface AbstractCookieDescriptor<T$1 extends TSchema> {
73
73
  readonly name: string;
74
- readonly options: CookieDescriptorOptions<T>;
75
- set(value: Static<T>, options?: {
74
+ readonly options: CookieDescriptorOptions<T$1>;
75
+ set(value: Static<T$1>, options?: {
76
76
  cookies?: Cookies;
77
77
  ttl?: DurationLike;
78
78
  }): void;
79
79
  get(options?: {
80
80
  cookies?: Cookies;
81
- }): Static<T> | undefined;
81
+ }): Static<T$1> | undefined;
82
82
  del(options?: {
83
83
  cookies?: Cookies;
84
84
  }): void;
85
85
  }
86
- declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> implements AbstractCookieDescriptor<T> {
86
+ declare class CookieDescriptor<T$1 extends TSchema> extends Descriptor<CookieDescriptorOptions<T$1>> implements AbstractCookieDescriptor<T$1> {
87
87
  protected readonly serverCookiesProvider: ServerCookiesProvider;
88
- get schema(): T;
88
+ get schema(): T$1;
89
89
  get name(): string;
90
90
  /**
91
91
  * Sets the cookie with the given value in the current request's response.
92
92
  */
93
- set(value: Static<T>, options?: {
93
+ set(value: Static<T$1>, options?: {
94
94
  cookies?: Cookies;
95
95
  ttl?: DurationLike;
96
96
  }): void;
@@ -99,7 +99,7 @@ declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescr
99
99
  */
100
100
  get(options?: {
101
101
  cookies?: Cookies;
102
- }): Static<T> | undefined;
102
+ }): Static<T$1> | undefined;
103
103
  /**
104
104
  * Deletes the cookie in the current request's response.
105
105
  */
package/server/links.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "alepha/server/security";
1
+ import { ServerRouteSecure } from "alepha/server/security";
2
2
  import * as _alepha_core2 from "alepha";
3
3
  import { Alepha, Descriptor, KIND, Static } from "alepha";
4
4
  import * as _alepha_server0 from "alepha/server";
@@ -7,26 +7,26 @@ import * as _alepha_logger0 from "alepha/logger";
7
7
  import * as _alepha_retry0 from "alepha/retry";
8
8
  import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
9
9
  import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
10
- import * as typebox0 from "typebox";
10
+ import * as typebox18 from "typebox";
11
11
 
12
12
  //#region src/schemas/apiLinksResponseSchema.d.ts
13
- declare const apiLinkSchema: typebox0.TObject<{
14
- name: typebox0.TString;
15
- group: typebox0.TOptional<typebox0.TString>;
16
- path: typebox0.TString;
17
- method: typebox0.TOptional<typebox0.TString>;
18
- requestBodyType: typebox0.TOptional<typebox0.TString>;
19
- service: typebox0.TOptional<typebox0.TString>;
13
+ declare const apiLinkSchema: typebox18.TObject<{
14
+ name: typebox18.TString;
15
+ group: typebox18.TOptional<typebox18.TString>;
16
+ path: typebox18.TString;
17
+ method: typebox18.TOptional<typebox18.TString>;
18
+ requestBodyType: typebox18.TOptional<typebox18.TString>;
19
+ service: typebox18.TOptional<typebox18.TString>;
20
20
  }>;
21
- declare const apiLinksResponseSchema: typebox0.TObject<{
22
- prefix: typebox0.TOptional<typebox0.TString>;
23
- links: typebox0.TArray<typebox0.TObject<{
24
- name: typebox0.TString;
25
- group: typebox0.TOptional<typebox0.TString>;
26
- path: typebox0.TString;
27
- method: typebox0.TOptional<typebox0.TString>;
28
- requestBodyType: typebox0.TOptional<typebox0.TString>;
29
- service: typebox0.TOptional<typebox0.TString>;
21
+ declare const apiLinksResponseSchema: typebox18.TObject<{
22
+ prefix: typebox18.TOptional<typebox18.TString>;
23
+ links: typebox18.TArray<typebox18.TObject<{
24
+ name: typebox18.TString;
25
+ group: typebox18.TOptional<typebox18.TString>;
26
+ path: typebox18.TString;
27
+ method: typebox18.TOptional<typebox18.TString>;
28
+ requestBodyType: typebox18.TOptional<typebox18.TString>;
29
+ service: typebox18.TOptional<typebox18.TString>;
30
30
  }>>;
31
31
  }>;
32
32
  type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
@@ -81,7 +81,7 @@ declare class LinkProvider {
81
81
  protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
82
82
  }
83
83
  interface HttpClientLink extends ApiLink {
84
- secured?: boolean;
84
+ secured?: boolean | ServerRouteSecure;
85
85
  prefix?: string;
86
86
  host?: string;
87
87
  service?: string;
@@ -93,9 +93,9 @@ interface ClientScope {
93
93
  service?: string;
94
94
  hostname?: string;
95
95
  }
96
- type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
97
- interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
98
- (config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
96
+ type HttpVirtualClient<T$1> = { [K in keyof T$1 as T$1[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T$1[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
97
+ interface VirtualAction<T$1 extends RequestConfigSchema> extends Pick<ActionDescriptor<T$1>, "name" | "run" | "fetch"> {
98
+ (config?: ClientRequestEntry<T$1>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T$1>>;
99
99
  can: () => boolean;
100
100
  }
101
101
  //#endregion
@@ -257,15 +257,15 @@ declare class ServerLinksProvider {
257
257
  * This is based on the user's permissions.
258
258
  */
259
259
  readonly links: _alepha_server0.RouteDescriptor<{
260
- response: typebox0.TObject<{
261
- prefix: typebox0.TOptional<typebox0.TString>;
262
- links: typebox0.TArray<typebox0.TObject<{
263
- name: typebox0.TString;
264
- group: typebox0.TOptional<typebox0.TString>;
265
- path: typebox0.TString;
266
- method: typebox0.TOptional<typebox0.TString>;
267
- requestBodyType: typebox0.TOptional<typebox0.TString>;
268
- service: typebox0.TOptional<typebox0.TString>;
260
+ response: typebox18.TObject<{
261
+ prefix: typebox18.TOptional<typebox18.TString>;
262
+ links: typebox18.TArray<typebox18.TObject<{
263
+ name: typebox18.TString;
264
+ group: typebox18.TOptional<typebox18.TString>;
265
+ path: typebox18.TString;
266
+ method: typebox18.TOptional<typebox18.TString>;
267
+ requestBodyType: typebox18.TOptional<typebox18.TString>;
268
+ service: typebox18.TOptional<typebox18.TString>;
269
269
  }>>;
270
270
  }>;
271
271
  }>;
@@ -276,10 +276,10 @@ declare class ServerLinksProvider {
276
276
  * I mean for 150+ links, you got 50ms of serialization time.
277
277
  */
278
278
  readonly schema: _alepha_server0.RouteDescriptor<{
279
- params: typebox0.TObject<{
280
- name: typebox0.TString;
279
+ params: typebox18.TObject<{
280
+ name: typebox18.TString;
281
281
  }>;
282
- response: typebox0.TRecord<string, typebox0.TAny>;
282
+ response: typebox18.TRecord<string, typebox18.TAny>;
283
283
  }>;
284
284
  getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
285
285
  /**
@@ -13,6 +13,7 @@ declare class ServerSecurityProvider {
13
13
  protected readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
14
14
  protected readonly onActionRequest: _alepha_core1.HookDescriptor<"action:onRequest">;
15
15
  protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
16
+ protected check(user: UserAccountToken, secure: ServerRouteSecure): void;
16
17
  /**
17
18
  * Get the user account token for a local action call.
18
19
  * There are three possible sources for the user:
@@ -30,11 +31,8 @@ declare class ServerSecurityProvider {
30
31
  protected createTestUser(): UserAccountToken;
31
32
  protected readonly onClientRequest: _alepha_core1.HookDescriptor<"client:onRequest">;
32
33
  }
33
- type ServerRouteSecure = boolean | {
34
- permissions?: string[];
35
- roles?: string[];
36
- realms?: string[];
37
- organizations?: string[];
34
+ type ServerRouteSecure = {
35
+ realm?: string;
38
36
  };
39
37
  //#endregion
40
38
  //#region src/index.d.ts
@@ -62,7 +60,7 @@ declare module "alepha/server" {
62
60
  * If true, the route will be protected by the security provider.
63
61
  * All actions are secure by default, but you can disable it for specific actions.
64
62
  */
65
- secure?: boolean;
63
+ secure?: boolean | ServerRouteSecure;
66
64
  }
67
65
  interface ClientRequestOptions extends FetchOptions {
68
66
  /**
@@ -1,7 +1,7 @@
1
1
  import "alepha/server/security";
2
2
  import * as _alepha_core1 from "alepha";
3
3
  import { Alepha, Descriptor, KIND, TObject } from "alepha";
4
- import { ActionDescriptor, RequestConfigSchema, ServerRouterProvider } from "alepha/server";
4
+ import { ActionDescriptor, RequestConfigSchema, ServerProvider, ServerRouterProvider } from "alepha/server";
5
5
  import * as _alepha_logger0 from "alepha/logger";
6
6
  import { ServerStaticProvider } from "alepha/server/static";
7
7
  import { OpenAPIV3 } from "openapi-types";
@@ -99,6 +99,7 @@ declare class SwaggerDescriptor extends Descriptor<SwaggerDescriptorOptions> {}
99
99
  declare class ServerSwaggerProvider {
100
100
  protected readonly serverStaticProvider: ServerStaticProvider;
101
101
  protected readonly serverRouterProvider: ServerRouterProvider;
102
+ protected readonly serverProvider: ServerProvider;
102
103
  protected readonly alepha: Alepha;
103
104
  protected readonly log: _alepha_logger0.Logger;
104
105
  json?: OpenAPIV3.Document;
package/server.d.ts CHANGED
@@ -68,14 +68,14 @@ interface RequestConfigSchema {
68
68
  headers?: TObject;
69
69
  response?: TResponseBody;
70
70
  }
71
- interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
72
- body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
73
- headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
74
- params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
75
- query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
76
- }
77
- type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
78
- interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
71
+ interface ServerRequestConfig<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> {
72
+ body: TConfig$1["body"] extends TRequestBody ? Static<TConfig$1["body"]> : any;
73
+ headers: TConfig$1["headers"] extends TObject ? Static<TConfig$1["headers"]> : Record<string, string>;
74
+ params: TConfig$1["params"] extends TObject ? Static<TConfig$1["params"]> : Record<string, string>;
75
+ query: TConfig$1["query"] extends TObject ? Static<TConfig$1["query"]> : Record<string, any>;
76
+ }
77
+ type ServerRequestConfigEntry<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig$1>>;
78
+ interface ServerRequest<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig$1> {
79
79
  method: RouteMethod;
80
80
  url: URL;
81
81
  requestId: string;
@@ -120,19 +120,19 @@ interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchem
120
120
  };
121
121
  };
122
122
  }
123
- interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
124
- handler: ServerHandler<TConfig>;
123
+ interface ServerRoute<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> extends Route {
124
+ handler: ServerHandler<TConfig$1>;
125
125
  method?: RouteMethod;
126
- schema?: TConfig;
126
+ schema?: TConfig$1;
127
127
  /**
128
128
  * @see ServerLoggerProvider
129
129
  */
130
130
  silent?: boolean;
131
131
  }
132
- type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
132
+ type ServerResponseBody<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> = TConfig$1["response"] extends TResponseBody ? Static<TConfig$1["response"]> : ResponseBodyType;
133
133
  type ResponseKind = "json" | "text" | "void" | "file" | "any";
134
134
  type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
135
- type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
135
+ type ServerHandler<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig$1>) => Async<ServerResponseBody<TConfig$1>>;
136
136
  interface ServerResponse {
137
137
  body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
138
138
  headers: Record<string, string>;
@@ -153,6 +153,10 @@ interface ServerRawRequest {
153
153
  req: IncomingMessage;
154
154
  res: ServerResponse$1;
155
155
  };
156
+ web?: {
157
+ req: Request;
158
+ res?: Response;
159
+ };
156
160
  };
157
161
  }
158
162
  //#endregion
@@ -161,6 +165,12 @@ declare abstract class ServerProvider {
161
165
  protected readonly alepha: Alepha;
162
166
  abstract get hostname(): string;
163
167
  protected isViteNotFound(url?: string, route?: Route, params?: Record<string, string>): boolean;
168
+ protected createRouterRequest(req: {
169
+ method?: string;
170
+ url?: string;
171
+ headers?: Record<string, string | string[] | undefined>;
172
+ }, params?: Record<string, string>): ServerRawRequest;
173
+ protected getProtocol(headers: Record<string, string>): "http" | "https";
164
174
  }
165
175
  //#endregion
166
176
  //#region src/services/ServerRequestParser.d.ts
@@ -179,6 +189,7 @@ declare class ServerTimingProvider {
179
189
  protected readonly log: _alepha_logger3.Logger;
180
190
  protected readonly alepha: Alepha;
181
191
  options: {
192
+ prefix: string;
182
193
  disabled: boolean;
183
194
  };
184
195
  readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
@@ -260,8 +271,8 @@ interface FetchOptions {
260
271
  */
261
272
  cache?: boolean | number | DurationLike;
262
273
  }
263
- interface FetchResponse<T = any> {
264
- data: T;
274
+ interface FetchResponse<T$1 = any> {
275
+ data: T$1;
265
276
  status: number;
266
277
  statusText: string;
267
278
  headers: Headers;
@@ -474,7 +485,7 @@ declare const $action: {
474
485
  <TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptorFn<TConfig>;
475
486
  [KIND]: typeof ActionDescriptor;
476
487
  };
477
- interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
488
+ interface ActionDescriptorOptions<TConfig$1 extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
478
489
  /**
479
490
  * Name of the action.
480
491
  *
@@ -525,7 +536,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
525
536
  * - query: The request query-params schema.
526
537
  * - response: The response schema.
527
538
  */
528
- schema?: TConfig;
539
+ schema?: TConfig$1;
529
540
  /**
530
541
  * A short description of the action. Used for documentation purposes.
531
542
  */
@@ -538,9 +549,9 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
538
549
  /**
539
550
  * Main route handler. This is where the route logic is implemented.
540
551
  */
541
- handler: ServerActionHandler<TConfig>;
552
+ handler: ServerActionHandler<TConfig$1>;
542
553
  }
543
- declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
554
+ declare class ActionDescriptor<TConfig$1 extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig$1>> {
544
555
  protected readonly log: _alepha_logger3.Logger;
545
556
  protected readonly env: {
546
557
  SERVER_API_PREFIX: string;
@@ -569,27 +580,27 @@ declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Desc
569
580
  * Path is prefixed by `/api` by default.
570
581
  */
571
582
  get path(): string;
572
- get schema(): TConfig | undefined;
583
+ get schema(): TConfig$1 | undefined;
573
584
  getBodyContentType(): string | undefined;
574
585
  /**
575
586
  * Call the action handler directly.
576
587
  * There is no HTTP layer involved.
577
588
  */
578
- run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
589
+ run(config?: ClientRequestEntry<TConfig$1>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig$1>>;
579
590
  /**
580
591
  * Works like `run`, but always fetches (http request) the route.
581
592
  */
582
- fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
593
+ fetch(config?: ClientRequestEntry<TConfig$1>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig$1>>>;
583
594
  }
584
- interface ActionDescriptorFn<TConfig extends RequestConfigSchema> extends ActionDescriptor<TConfig> {
585
- (config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
595
+ interface ActionDescriptorFn<TConfig$1 extends RequestConfigSchema> extends ActionDescriptor<TConfig$1> {
596
+ (config?: ClientRequestEntry<TConfig$1>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig$1>>;
586
597
  }
587
- type ClientRequestEntry<TConfig extends RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
588
- type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
589
- body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
590
- params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
591
- headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
592
- query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
598
+ type ClientRequestEntry<TConfig$1 extends RequestConfigSchema, T$1 = ClientRequestEntryContainer<TConfig$1>> = { [K in keyof T$1 as T$1[K] extends undefined ? never : K]: T$1[K] };
599
+ type ClientRequestEntryContainer<TConfig$1 extends RequestConfigSchema> = {
600
+ body: TConfig$1["body"] extends TObject ? Static<TConfig$1["body"]> : undefined;
601
+ params: TConfig$1["params"] extends TObject ? Static<TConfig$1["params"]> : undefined;
602
+ headers?: TConfig$1["headers"] extends TObject ? Static<TConfig$1["headers"]> : undefined;
603
+ query?: TConfig$1["query"] extends TObject ? Partial<Static<TConfig$1["query"]>> : undefined;
593
604
  };
594
605
  interface ClientRequestOptions extends FetchOptions {
595
606
  /**
@@ -597,11 +608,11 @@ interface ClientRequestOptions extends FetchOptions {
597
608
  */
598
609
  request?: RequestInit;
599
610
  }
600
- type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
611
+ type ClientRequestResponse<TConfig$1 extends RequestConfigSchema> = TConfig$1["response"] extends TSchema ? Static<TConfig$1["response"]> : any;
601
612
  /**
602
613
  * Specific handler for server actions.
603
614
  */
604
- type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
615
+ type ServerActionHandler<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig$1>) => Async<ServerResponseBody<TConfig$1>>;
605
616
  /**
606
617
  * Server Action Request Interface
607
618
  *
@@ -609,7 +620,7 @@ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSche
609
620
  *
610
621
  * This is NOT Server Request, but a specific type for actions.
611
622
  */
612
- interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
623
+ interface ServerActionRequest<TConfig$1 extends RequestConfigSchema> extends ServerRequest<TConfig$1> {}
613
624
  //#endregion
614
625
  //#region src/schemas/errorSchema.d.ts
615
626
  declare const errorSchema: typebox0.TObject<{
@@ -659,8 +670,8 @@ declare const $route: {
659
670
  <TConfig extends RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
660
671
  [KIND]: typeof RouteDescriptor;
661
672
  };
662
- interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {}
663
- declare class RouteDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<RouteDescriptorOptions<TConfig>> {
673
+ interface RouteDescriptorOptions<TConfig$1 extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig$1> {}
674
+ declare class RouteDescriptor<TConfig$1 extends RequestConfigSchema> extends Descriptor<RouteDescriptorOptions<TConfig$1>> {
664
675
  protected readonly serverRouterProvider: ServerRouterProvider;
665
676
  protected onInit(): void;
666
677
  }
@@ -732,8 +743,6 @@ declare class NodeHttpServerProvider extends ServerProvider {
732
743
  protected readonly server: http0.Server<typeof IncomingMessage, typeof ServerResponse$1>;
733
744
  protected readonly onNodeRequest: _alepha_core11.HookDescriptor<"node:request">;
734
745
  handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
735
- createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
736
- getProtocol(req: IncomingMessage): "http" | "https";
737
746
  get hostname(): string;
738
747
  readonly start: _alepha_core11.HookDescriptor<"start">;
739
748
  protected readonly stop: _alepha_core11.HookDescriptor<"stop">;
@@ -815,6 +824,10 @@ declare module "alepha" {
815
824
  req: IncomingMessage;
816
825
  res: ServerResponse$1;
817
826
  };
827
+ "web:request": {
828
+ req: Request;
829
+ res?: Response;
830
+ };
818
831
  }
819
832
  }
820
833
  /**
package/topic.d.ts CHANGED
@@ -220,7 +220,7 @@ declare const $topic: {
220
220
  <T extends TopicMessageSchema>(options: TopicDescriptorOptions<T>): TopicDescriptor<T>;
221
221
  [KIND]: typeof TopicDescriptor;
222
222
  };
223
- interface TopicDescriptorOptions<T extends TopicMessageSchema> {
223
+ interface TopicDescriptorOptions<T$1 extends TopicMessageSchema> {
224
224
  /**
225
225
  * Unique name identifier for the topic.
226
226
  *
@@ -329,7 +329,7 @@ interface TopicDescriptorOptions<T extends TopicMessageSchema> {
329
329
  * }
330
330
  * ```
331
331
  */
332
- schema: T;
332
+ schema: T$1;
333
333
  /**
334
334
  * Default subscriber handler function that processes messages published to this topic.
335
335
  *
@@ -393,32 +393,32 @@ interface TopicDescriptorOptions<T extends TopicMessageSchema> {
393
393
  * }
394
394
  * ```
395
395
  */
396
- handler?: TopicHandler<T>;
396
+ handler?: TopicHandler<T$1>;
397
397
  }
398
- declare class TopicDescriptor<T extends TopicMessageSchema> extends Descriptor<TopicDescriptorOptions<T>> {
398
+ declare class TopicDescriptor<T$1 extends TopicMessageSchema> extends Descriptor<TopicDescriptorOptions<T$1>> {
399
399
  protected readonly log: _alepha_logger0.Logger;
400
400
  protected readonly dateTimeProvider: DateTimeProvider;
401
401
  readonly provider: TopicProvider;
402
402
  get name(): string;
403
- publish(payload: TopicMessage<T>["payload"]): Promise<void>;
404
- subscribe(handler: TopicHandler<T>): Promise<UnSubscribeFn>;
405
- wait(options?: TopicWaitOptions<T>): Promise<TopicMessage<T>>;
403
+ publish(payload: TopicMessage<T$1>["payload"]): Promise<void>;
404
+ subscribe(handler: TopicHandler<T$1>): Promise<UnSubscribeFn>;
405
+ wait(options?: TopicWaitOptions<T$1>): Promise<TopicMessage<T$1>>;
406
406
  protected $provider(): TopicProvider;
407
- protected parseMessage(message: string): TopicMessage<T>;
407
+ protected parseMessage(message: string): TopicMessage<T$1>;
408
408
  }
409
- interface TopicMessage<T extends TopicMessageSchema> {
410
- payload: Static<T["payload"]>;
409
+ interface TopicMessage<T$1 extends TopicMessageSchema> {
410
+ payload: Static<T$1["payload"]>;
411
411
  }
412
- interface TopicWaitOptions<T extends TopicMessageSchema> {
412
+ interface TopicWaitOptions<T$1 extends TopicMessageSchema> {
413
413
  timeout?: DurationLike;
414
414
  filter?: (message: {
415
- payload: Static<T["payload"]>;
415
+ payload: Static<T$1["payload"]>;
416
416
  }) => boolean;
417
417
  }
418
418
  interface TopicMessageSchema {
419
419
  payload: TSchema;
420
420
  }
421
- type TopicHandler<T extends TopicMessageSchema = TopicMessageSchema> = (message: TopicMessage<T>) => unknown;
421
+ type TopicHandler<T$1 extends TopicMessageSchema = TopicMessageSchema> = (message: TopicMessage<T$1>) => unknown;
422
422
  //#endregion
423
423
  //#region src/descriptors/$subscriber.d.ts
424
424
  /**
@@ -636,7 +636,7 @@ declare const $subscriber: {
636
636
  <T extends TopicMessageSchema>(options: SubscriberDescriptorOptions<T>): SubscriberDescriptor<T>;
637
637
  [KIND]: typeof SubscriberDescriptor;
638
638
  };
639
- interface SubscriberDescriptorOptions<T extends TopicMessageSchema> {
639
+ interface SubscriberDescriptorOptions<T$1 extends TopicMessageSchema> {
640
640
  /**
641
641
  * The topic descriptor that this subscriber will listen to for messages.
642
642
  *
@@ -670,7 +670,7 @@ interface SubscriberDescriptorOptions<T extends TopicMessageSchema> {
670
670
  * });
671
671
  * ```
672
672
  */
673
- topic: TopicDescriptor<T>;
673
+ topic: TopicDescriptor<T$1>;
674
674
  /**
675
675
  * Message handler function that processes individual messages from the topic.
676
676
  *
@@ -765,9 +765,9 @@ interface SubscriberDescriptorOptions<T extends TopicMessageSchema> {
765
765
  * }
766
766
  * ```
767
767
  */
768
- handler: TopicHandler<T>;
768
+ handler: TopicHandler<T$1>;
769
769
  }
770
- declare class SubscriberDescriptor<T extends TopicMessageSchema> extends Descriptor<SubscriberDescriptorOptions<T>> {}
770
+ declare class SubscriberDescriptor<T$1 extends TopicMessageSchema> extends Descriptor<SubscriberDescriptorOptions<T$1>> {}
771
771
  //#endregion
772
772
  //#region src/errors/TopicTimeoutError.d.ts
773
773
  declare class TopicTimeoutError extends Error {
package/ui.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/ui');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });