alepha 0.11.4 → 0.11.6

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 (49) hide show
  1. package/api/files.d.ts +439 -1
  2. package/api/jobs.d.ts +290 -1
  3. package/api/notifications.d.ts +264 -1
  4. package/api/users.d.ts +924 -1
  5. package/batch.d.ts +154 -1
  6. package/bucket.d.ts +520 -1
  7. package/cache/redis.d.ts +40 -1
  8. package/cache.d.ts +288 -1
  9. package/command.d.ts +269 -1
  10. package/core.d.ts +1877 -1
  11. package/datetime.d.ts +1 -1
  12. package/devtools.d.ts +408 -1
  13. package/email.d.ts +187 -1
  14. package/fake.d.ts +73 -1
  15. package/file.d.ts +528 -1
  16. package/lock/redis.d.ts +24 -1
  17. package/lock.d.ts +552 -1
  18. package/logger.d.ts +288 -1
  19. package/package.json +51 -51
  20. package/postgres.d.ts +2146 -1
  21. package/queue/redis.d.ts +29 -1
  22. package/queue.d.ts +760 -1
  23. package/react/auth.d.ts +504 -1
  24. package/react/form.d.ts +208 -1
  25. package/react/head.d.ts +120 -1
  26. package/react/i18n.d.ts +168 -1
  27. package/react.d.ts +1261 -1
  28. package/redis.d.ts +82 -1
  29. package/retry.d.ts +84 -21
  30. package/scheduler.d.ts +145 -1
  31. package/security.d.ts +586 -1
  32. package/server/cache.d.ts +163 -1
  33. package/server/compress.d.ts +38 -1
  34. package/server/cookies.d.ts +144 -1
  35. package/server/cors.d.ts +45 -1
  36. package/server/health.d.ts +59 -1
  37. package/server/helmet.d.ts +98 -1
  38. package/server/links.d.ts +322 -1
  39. package/server/metrics.d.ts +35 -1
  40. package/server/multipart.d.ts +42 -1
  41. package/server/proxy.d.ts +234 -1
  42. package/server/security.d.ts +92 -1
  43. package/server/static.d.ts +119 -1
  44. package/server/swagger.d.ts +161 -1
  45. package/server.d.ts +849 -1
  46. package/topic/redis.d.ts +42 -1
  47. package/topic.d.ts +819 -1
  48. package/ui.d.ts +786 -1
  49. package/vite.d.ts +186 -1
package/server/links.d.ts CHANGED
@@ -1 +1,322 @@
1
- export * from '@alepha/server-links';
1
+ import { ServerRouteSecure } from "alepha/server/security";
2
+ import * as _alepha_core2 from "alepha";
3
+ import { Alepha, Descriptor, KIND, Static } from "alepha";
4
+ import * as _alepha_server0 from "alepha/server";
5
+ import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry, ServerTimingProvider } from "alepha/server";
6
+ import * as _alepha_logger0 from "alepha/logger";
7
+ import * as _alepha_retry0 from "alepha/retry";
8
+ import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
9
+ import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
10
+ import * as typebox18 from "typebox";
11
+
12
+ //#region src/schemas/apiLinksResponseSchema.d.ts
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
+ }>;
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
+ }>>;
31
+ }>;
32
+ type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
33
+ type ApiLink = Static<typeof apiLinkSchema>;
34
+ //#endregion
35
+ //#region src/providers/LinkProvider.d.ts
36
+ /**
37
+ * Browser, SSR friendly, service to handle links.
38
+ */
39
+ declare class LinkProvider {
40
+ static path: {
41
+ apiLinks: string;
42
+ apiSchema: string;
43
+ };
44
+ protected readonly log: _alepha_logger0.Logger;
45
+ protected readonly alepha: Alepha;
46
+ protected readonly httpClient: HttpClient;
47
+ protected serverLinks: Array<HttpClientLink>;
48
+ /**
49
+ * Get applicative links registered on the server.
50
+ * This does not include lazy-loaded remote links.
51
+ */
52
+ getServerLinks(): HttpClientLink[];
53
+ /**
54
+ * Register a new link for the application.
55
+ */
56
+ registerLink(link: HttpClientLink): void;
57
+ get links(): HttpClientLink[];
58
+ /**
59
+ * Force browser to refresh links from the server.
60
+ */
61
+ fetchLinks(): Promise<HttpClientLink[]>;
62
+ /**
63
+ * Create a virtual client that can be used to call actions.
64
+ *
65
+ * Use js Proxy under the hood.
66
+ */
67
+ client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
68
+ /**
69
+ * Check if a link with the given name exists.
70
+ * @param name
71
+ */
72
+ can(name: string): boolean;
73
+ /**
74
+ * Resolve a link by its name and call it.
75
+ * - If link is local, it will call the local handler.
76
+ * - If link is remote, it will make a fetch request to the remote server.
77
+ */
78
+ follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
79
+ protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
80
+ protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
81
+ protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
82
+ }
83
+ interface HttpClientLink extends ApiLink {
84
+ secured?: boolean | ServerRouteSecure;
85
+ prefix?: string;
86
+ host?: string;
87
+ service?: string;
88
+ schema?: RequestConfigSchema;
89
+ handler?: ServerHandler;
90
+ }
91
+ interface ClientScope {
92
+ group?: string;
93
+ service?: string;
94
+ hostname?: string;
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>>;
99
+ can: () => boolean;
100
+ }
101
+ //#endregion
102
+ //#region src/descriptors/$client.d.ts
103
+ /**
104
+ * Create a new client.
105
+ */
106
+ declare const $client: {
107
+ <T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
108
+ [KIND]: string;
109
+ };
110
+ //#endregion
111
+ //#region src/descriptors/$remote.d.ts
112
+ /**
113
+ * $remote is a descriptor that allows you to define remote service access.
114
+ *
115
+ * Use it only when you have 2 or more services that need to communicate with each other.
116
+ *
117
+ * All remote services can be exposed as actions, ... or not.
118
+ *
119
+ * You can add a service account if you want to use a security layer.
120
+ */
121
+ declare const $remote: {
122
+ (options: RemoteDescriptorOptions): RemoteDescriptor;
123
+ [KIND]: typeof RemoteDescriptor;
124
+ };
125
+ interface RemoteDescriptorOptions {
126
+ /**
127
+ * The URL of the remote service.
128
+ * You can use a function to generate the URL dynamically.
129
+ * You probably should use $env(env) to get the URL from the environment.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * import { $remote } from "alepha/server";
134
+ * import { $inject, t } from "alepha";
135
+ *
136
+ * class App {
137
+ * env = $env(t.object({
138
+ * REMOTE_URL: t.text({default: "http://localhost:3000"}),
139
+ * }));
140
+ * remote = $remote({
141
+ * url: this.env.REMOTE_URL,
142
+ * });
143
+ * }
144
+ * ```
145
+ */
146
+ url: string | (() => string);
147
+ /**
148
+ * The name of the remote service.
149
+ *
150
+ * @default Member of the class containing the remote service.
151
+ */
152
+ name?: string;
153
+ /**
154
+ * If true, all methods of the remote service will be exposed as actions in this context.
155
+ * > Note: Proxy will never use the service account, it just... proxies the request.
156
+ */
157
+ proxy?: boolean | Partial<ProxyDescriptorOptions & {
158
+ /**
159
+ * If true, the remote service won't be available internally, only through the proxy.
160
+ */
161
+ noInternal: boolean;
162
+ }>;
163
+ /**
164
+ * For communication between the server and the remote service with a security layer.
165
+ * This will be used for internal communication and will not be exposed to the client.
166
+ */
167
+ serviceAccount?: ServiceAccountDescriptor;
168
+ }
169
+ declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
170
+ get name(): string;
171
+ }
172
+ //#endregion
173
+ //#region src/providers/RemoteDescriptorProvider.d.ts
174
+ declare class RemoteDescriptorProvider {
175
+ protected readonly env: {
176
+ SERVER_API_PREFIX: string;
177
+ };
178
+ protected readonly alepha: Alepha;
179
+ protected readonly proxyProvider: ServerProxyProvider;
180
+ protected readonly linkProvider: LinkProvider;
181
+ protected readonly remotes: Array<ServerRemote>;
182
+ protected readonly log: _alepha_logger0.Logger;
183
+ getRemotes(): ServerRemote[];
184
+ readonly configure: _alepha_core2.HookDescriptor<"configure">;
185
+ readonly start: _alepha_core2.HookDescriptor<"start">;
186
+ registerRemote(value: RemoteDescriptor): Promise<void>;
187
+ protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
188
+ }
189
+ interface FetchLinksOptions {
190
+ /**
191
+ * Name of the remote service.
192
+ */
193
+ service: string;
194
+ /**
195
+ * URL to fetch links from.
196
+ */
197
+ url: string;
198
+ /**
199
+ * Authorization header containing access token.
200
+ */
201
+ authorization?: string;
202
+ }
203
+ interface ServerRemote {
204
+ /**
205
+ * URL of the remote service.
206
+ */
207
+ url: string;
208
+ /**
209
+ * Name of the remote service.
210
+ */
211
+ name: string;
212
+ /**
213
+ * Expose links as endpoint. It's not only internal.
214
+ */
215
+ proxy: boolean;
216
+ /**
217
+ * It's only used inside the application.
218
+ */
219
+ internal: boolean;
220
+ /**
221
+ * Links fetcher.
222
+ */
223
+ links: (args: {
224
+ authorization?: string;
225
+ }) => Promise<ApiLinksResponse>;
226
+ /**
227
+ * Fetches schema for the remote service.
228
+ */
229
+ schema: (args: {
230
+ name: string;
231
+ authorization?: string;
232
+ }) => Promise<any>;
233
+ /**
234
+ * Force a default access token provider when not provided.
235
+ */
236
+ serviceAccount?: ServiceAccountDescriptor;
237
+ /**
238
+ * Prefix for the remote service links.
239
+ */
240
+ prefix: string;
241
+ }
242
+ //#endregion
243
+ //#region src/providers/ServerLinksProvider.d.ts
244
+ declare class ServerLinksProvider {
245
+ protected readonly env: {
246
+ SERVER_API_PREFIX: string;
247
+ };
248
+ protected readonly alepha: Alepha;
249
+ protected readonly linkProvider: LinkProvider;
250
+ protected readonly remoteProvider: RemoteDescriptorProvider;
251
+ protected readonly serverTimingProvider: ServerTimingProvider;
252
+ get prefix(): string;
253
+ readonly onRoute: _alepha_core2.HookDescriptor<"configure">;
254
+ /**
255
+ * First API - Get all API links for the user.
256
+ *
257
+ * This is based on the user's permissions.
258
+ */
259
+ readonly links: _alepha_server0.RouteDescriptor<{
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
+ }>>;
270
+ }>;
271
+ }>;
272
+ /**
273
+ * Second API - Get schema for a specific API link.
274
+ *
275
+ * Note: Body/Response schema are not included in `links` API because it's TOO BIG.
276
+ * I mean for 150+ links, you got 50ms of serialization time.
277
+ */
278
+ readonly schema: _alepha_server0.RouteDescriptor<{
279
+ params: typebox18.TObject<{
280
+ name: typebox18.TString;
281
+ }>;
282
+ response: typebox18.TRecord<string, typebox18.TAny>;
283
+ }>;
284
+ getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
285
+ /**
286
+ * Retrieves API links for the user based on their permissions.
287
+ * Will check on local links and remote links.
288
+ */
289
+ getUserApiLinks(options: GetApiLinksOptions): Promise<ApiLinksResponse>;
290
+ }
291
+ interface GetApiLinksOptions {
292
+ user?: UserAccountToken;
293
+ authorization?: string;
294
+ }
295
+ //#endregion
296
+ //#region src/index.d.ts
297
+ declare module "alepha" {
298
+ interface State {
299
+ /**
300
+ * API links attached to the server request state.
301
+ *
302
+ * @see {@link ApiLinksResponse}
303
+ * @internal
304
+ */
305
+ "alepha.server.request.apiLinks"?: ApiLinksResponse;
306
+ }
307
+ }
308
+ /**
309
+ * Provides server-side link management and remote capabilities for client-server interactions.
310
+ *
311
+ * The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
312
+ * facilitating seamless API endpoint management and client-server communication. It integrates with server
313
+ * security features to ensure safe and controlled access to resources.
314
+ *
315
+ * @see {@link $remote}
316
+ * @see {@link $client}
317
+ * @module alepha.server.links
318
+ */
319
+ declare const AlephaServerLinks: _alepha_core2.Service<_alepha_core2.Module>;
320
+ //#endregion
321
+ export { $client, $remote, AlephaServerLinks, ApiLink, ApiLinksResponse, ClientScope, FetchLinksOptions, GetApiLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction, apiLinkSchema, apiLinksResponseSchema };
322
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1,35 @@
1
- export * from '@alepha/server-metrics';
1
+ import * as _alepha_core1 from "alepha";
2
+ import { Alepha } from "alepha";
3
+ import * as _alepha_server0 from "alepha/server";
4
+ import { Histogram, Registry } from "prom-client";
5
+
6
+ //#region src/providers/ServerMetricsProvider.d.ts
7
+ declare class ServerMetricsProvider {
8
+ protected readonly register: Registry;
9
+ protected readonly alepha: Alepha;
10
+ protected httpRequestDuration?: Histogram<string>;
11
+ readonly options: ServerMetricsProviderOptions;
12
+ readonly metrics: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
13
+ protected readonly onStart: _alepha_core1.HookDescriptor<"start">;
14
+ protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
15
+ protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
16
+ }
17
+ interface ServerMetricsProviderOptions {
18
+ prefix?: string;
19
+ gcDurationBuckets?: number[];
20
+ eventLoopMonitoringPrecision?: number;
21
+ labels?: object;
22
+ }
23
+ //#endregion
24
+ //#region src/index.d.ts
25
+ /**
26
+ * This module provides prometheus metrics for the Alepha server.
27
+ * Metrics are exposed at the `/metrics` endpoint.
28
+ *
29
+ * @see {@link ServerMetricsProvider}
30
+ * @module alepha.server.metrics
31
+ */
32
+ declare const AlephaServerMetrics: _alepha_core1.Service<_alepha_core1.Module>;
33
+ //#endregion
34
+ export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
35
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1,42 @@
1
- export * from '@alepha/server-multipart';
1
+ import * as _alepha_core0 from "alepha";
2
+ import { Alepha, FileLike, HookDescriptor } from "alepha";
3
+ import { ServerRoute } from "alepha/server";
4
+ import { IncomingMessage } from "node:http";
5
+ import { BusboyConfig } from "@fastify/busboy";
6
+
7
+ //#region src/providers/ServerMultipartProvider.d.ts
8
+ declare class ServerMultipartProvider {
9
+ protected readonly alepha: Alepha;
10
+ readonly onRequest: HookDescriptor<"server:onRequest">;
11
+ readonly onSend: HookDescriptor<"server:onResponse">;
12
+ handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
13
+ body: Record<string, unknown>;
14
+ cleanup: () => Promise<void>;
15
+ }>;
16
+ parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
17
+ }
18
+ interface MultipartResult {
19
+ fields: Record<string, string | string[]>;
20
+ files: Record<string, HybridFile>;
21
+ }
22
+ interface HybridFile extends FileLike {
23
+ cleanup(): Promise<void>;
24
+ _state: {
25
+ cleanup: boolean;
26
+ size: number;
27
+ tmpPath: string;
28
+ };
29
+ }
30
+ //#endregion
31
+ //#region src/index.d.ts
32
+ /**
33
+ * This module provides support for handling multipart/form-data requests.
34
+ * It allows to parse body data containing t.file().
35
+ *
36
+ * @see {@link ServerMultipartProvider}
37
+ * @module alepha.server.multipart
38
+ */
39
+ declare const AlephaServerMultipart: _alepha_core0.Service<_alepha_core0.Module>;
40
+ //#endregion
41
+ export { AlephaServerMultipart, ServerMultipartProvider };
42
+ //# sourceMappingURL=index.d.ts.map
package/server/proxy.d.ts CHANGED
@@ -1 +1,234 @@
1
- export * from '@alepha/server-proxy';
1
+ import * as _alepha_core1 from "alepha";
2
+ import { Alepha, Async, Descriptor, KIND } from "alepha";
3
+ import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
4
+ import * as _alepha_logger0 from "alepha/logger";
5
+
6
+ //#region src/descriptors/$proxy.d.ts
7
+
8
+ /**
9
+ * Creates a proxy descriptor to forward requests to another server.
10
+ *
11
+ * This descriptor enables you to create reverse proxy functionality, allowing your Alepha server
12
+ * to forward requests to other services while maintaining a unified API surface. It's particularly
13
+ * useful for microservice architectures, API gateways, or when you need to aggregate multiple
14
+ * services behind a single endpoint.
15
+ *
16
+ * **Key Features**
17
+ *
18
+ * - **Path-based routing**: Match specific paths or patterns to proxy
19
+ * - **Dynamic targets**: Support both static and dynamic target resolution
20
+ * - **Request/Response hooks**: Modify requests before forwarding and responses after receiving
21
+ * - **URL rewriting**: Transform URLs before forwarding to the target
22
+ * - **Conditional proxying**: Enable/disable proxies based on environment or conditions
23
+ *
24
+ * @example
25
+ * **Basic proxy setup:**
26
+ * ```ts
27
+ * import { $proxy } from "alepha/server-proxy";
28
+ *
29
+ * class ApiGateway {
30
+ * // Forward all /api/* requests to external service
31
+ * api = $proxy({
32
+ * path: "/api/*",
33
+ * target: "https://api.example.com"
34
+ * });
35
+ * }
36
+ * ```
37
+ *
38
+ * @example
39
+ * **Dynamic target with environment-based routing:**
40
+ * ```ts
41
+ * class ApiGateway {
42
+ * // Route to different environments based on configuration
43
+ * api = $proxy({
44
+ * path: "/api/*",
45
+ * target: () => process.env.NODE_ENV === "production"
46
+ * ? "https://api.prod.example.com"
47
+ * : "https://api.dev.example.com"
48
+ * });
49
+ * }
50
+ * ```
51
+ *
52
+ * @example
53
+ * **Advanced proxy with request/response modification:**
54
+ * ```ts
55
+ * class SecureProxy {
56
+ * secure = $proxy({
57
+ * path: "/secure/*",
58
+ * target: "https://secure-api.example.com",
59
+ * beforeRequest: async (request, proxyRequest) => {
60
+ * // Add authentication headers
61
+ * proxyRequest.headers = {
62
+ * ...proxyRequest.headers,
63
+ * 'Authorization': `Bearer ${await getServiceToken()}`,
64
+ * 'X-Forwarded-For': request.headers['x-forwarded-for'] || request.ip
65
+ * };
66
+ * },
67
+ * afterResponse: async (request, proxyResponse) => {
68
+ * // Log response for monitoring
69
+ * console.log(`Proxied ${request.url} -> ${proxyResponse.status}`);
70
+ * },
71
+ * rewrite: (url) => {
72
+ * // Remove /secure prefix when forwarding
73
+ * url.pathname = url.pathname.replace('/secure', '');
74
+ * }
75
+ * });
76
+ * }
77
+ * ```
78
+ *
79
+ * @example
80
+ * **Conditional proxy based on feature flags:**
81
+ * ```ts
82
+ * class FeatureProxy {
83
+ * newApi = $proxy({
84
+ * path: "/v2/*",
85
+ * target: "https://new-api.example.com",
86
+ * disabled: !process.env.ENABLE_V2_API // Disable if feature flag is off
87
+ * });
88
+ * }
89
+ * ```
90
+ */
91
+ declare const $proxy: {
92
+ (options: ProxyDescriptorOptions): ProxyDescriptor;
93
+ [KIND]: typeof ProxyDescriptor;
94
+ };
95
+ type ProxyDescriptorOptions = {
96
+ /**
97
+ * Path pattern to match for proxying requests.
98
+ *
99
+ * Supports wildcards and path parameters:
100
+ * - `/api/*` - Matches all paths starting with `/api/`
101
+ * - `/api/v1/*` - Matches all paths starting with `/api/v1/`
102
+ * - `/users/:id` - Matches `/users/123`, `/users/abc`, etc.
103
+ *
104
+ * @example "/api/*"
105
+ * @example "/secure/admin/*"
106
+ * @example "/users/:id/posts"
107
+ */
108
+ path: string;
109
+ /**
110
+ * Target URL to which matching requests should be forwarded.
111
+ *
112
+ * Can be either:
113
+ * - **Static string**: A fixed URL like `"https://api.example.com"`
114
+ * - **Dynamic function**: A function that returns the URL, enabling runtime target resolution
115
+ *
116
+ * The target URL will be combined with the remaining path from the original request.
117
+ *
118
+ * @example "https://api.example.com"
119
+ * @example () => process.env.API_URL || "http://localhost:3001"
120
+ */
121
+ target: string | (() => string);
122
+ /**
123
+ * Whether this proxy is disabled.
124
+ *
125
+ * When `true`, requests matching the path will not be proxied and will be handled
126
+ * by other routes or return 404. Useful for feature toggles or conditional proxying.
127
+ *
128
+ * @default false
129
+ * @example !process.env.ENABLE_PROXY
130
+ */
131
+ disabled?: boolean;
132
+ /**
133
+ * Hook called before forwarding the request to the target server.
134
+ *
135
+ * Use this to:
136
+ * - Add authentication headers
137
+ * - Modify request headers or body
138
+ * - Add request tracking/logging
139
+ * - Transform the request before forwarding
140
+ *
141
+ * @param request - The original incoming server request
142
+ * @param proxyRequest - The request that will be sent to the target (modifiable)
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * beforeRequest: async (request, proxyRequest) => {
147
+ * proxyRequest.headers = {
148
+ * ...proxyRequest.headers,
149
+ * 'Authorization': `Bearer ${await getToken()}`,
150
+ * 'X-Request-ID': generateRequestId()
151
+ * };
152
+ * }
153
+ * ```
154
+ */
155
+ beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
156
+ /**
157
+ * Hook called after receiving the response from the target server.
158
+ *
159
+ * Use this to:
160
+ * - Log response details for monitoring
161
+ * - Add custom headers to the response
162
+ * - Transform response data
163
+ * - Handle error responses
164
+ *
165
+ * @param request - The original incoming server request
166
+ * @param proxyResponse - The response received from the target server
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * afterResponse: async (request, proxyResponse) => {
171
+ * console.log(`Proxy ${request.method} ${request.url} -> ${proxyResponse.status}`);
172
+ *
173
+ * if (!proxyResponse.ok) {
174
+ * await logError(`Proxy error: ${proxyResponse.status}`, { request, response: proxyResponse });
175
+ * }
176
+ * }
177
+ * ```
178
+ */
179
+ afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
180
+ /**
181
+ * Function to rewrite the URL before sending to the target server.
182
+ *
183
+ * Use this to:
184
+ * - Remove or add path prefixes
185
+ * - Transform path parameters
186
+ * - Modify query parameters
187
+ * - Change the URL structure entirely
188
+ *
189
+ * The function receives a mutable URL object and should modify it in-place.
190
+ *
191
+ * @param url - The URL object to modify (mutable)
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * // Remove /api prefix when forwarding
196
+ * rewrite: (url) => {
197
+ * url.pathname = url.pathname.replace('/api', '');
198
+ * }
199
+ * ```
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * // Add version prefix
204
+ * rewrite: (url) => {
205
+ * url.pathname = `/v2${url.pathname}`;
206
+ * }
207
+ * ```
208
+ */
209
+ rewrite?: (url: URL) => void;
210
+ };
211
+ declare class ProxyDescriptor extends Descriptor<ProxyDescriptorOptions> {}
212
+ //#endregion
213
+ //#region src/providers/ServerProxyProvider.d.ts
214
+ declare class ServerProxyProvider {
215
+ protected readonly log: _alepha_logger0.Logger;
216
+ protected readonly routerProvider: ServerRouterProvider;
217
+ protected readonly alepha: Alepha;
218
+ protected readonly configure: _alepha_core1.HookDescriptor<"configure">;
219
+ createProxy(options: ProxyDescriptorOptions): void;
220
+ createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
221
+ private getRawRequestBody;
222
+ }
223
+ //#endregion
224
+ //#region src/index.d.ts
225
+ /**
226
+ * Plugin for Alepha that provides a proxy server functionality.
227
+ *
228
+ * @see {@link $proxy}
229
+ * @module alepha.server.proxy
230
+ */
231
+ declare const AlephaServerProxy: _alepha_core1.Service<_alepha_core1.Module>;
232
+ //#endregion
233
+ export { $proxy, AlephaServerProxy, ProxyDescriptor, ProxyDescriptorOptions, ServerProxyProvider };
234
+ //# sourceMappingURL=index.d.ts.map