alepha 0.6.7 → 0.6.9
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/cache.d.ts +353 -1
- package/core.d.ts +998 -19
- package/datetime.d.ts +167 -1
- package/lock.d.ts +280 -1
- package/package.json +36 -22
- package/postgres.d.ts +1452 -1
- package/queue.d.ts +305 -1
- package/react/auth.d.ts +300 -1
- package/react.d.ts +617 -1
- package/redis.d.ts +135 -1
- package/scheduler.d.ts +185 -1
- package/security.d.ts +651 -1
- package/server/cookies.d.ts +56 -1
- package/server/metrics.d.ts +14 -1
- package/server/proxy.d.ts +34 -1
- package/server/static.d.ts +103 -1
- package/server/swagger.d.ts +102 -1
- package/server.d.ts +879 -1
- package/topic.d.ts +301 -1
- package/vite.d.ts +80 -1
package/server.d.ts
CHANGED
|
@@ -1 +1,879 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _alepha_core from '@alepha/core';
|
|
2
|
+
import { Static as Static$1, TObject as TObject$1, TSchema as TSchema$1, Async, StreamLike, Alepha, OPTIONS, KIND, FileLike } from '@alepha/core';
|
|
3
|
+
export { KIND } from '@alepha/core';
|
|
4
|
+
import { UserAccountToken, Permission, SecurityProvider, JwtProvider } from '@alepha/security';
|
|
5
|
+
import { IncomingMessage, ServerResponse as ServerResponse$1 } from 'node:http';
|
|
6
|
+
import { Readable } from 'node:stream';
|
|
7
|
+
import { ReadableStream } from 'node:stream/web';
|
|
8
|
+
import { Route, RouterProvider } from '@alepha/router';
|
|
9
|
+
import * as _alepha_cache from '@alepha/cache';
|
|
10
|
+
import { DurationLike } from '@alepha/datetime';
|
|
11
|
+
import { BusboyConfig } from '@fastify/busboy';
|
|
12
|
+
import * as http from 'http';
|
|
13
|
+
|
|
14
|
+
/** Symbol key applied to readonly types */
|
|
15
|
+
declare const ReadonlyKind: unique symbol;
|
|
16
|
+
/** Symbol key applied to optional types */
|
|
17
|
+
declare const OptionalKind: unique symbol;
|
|
18
|
+
/** Symbol key applied to types */
|
|
19
|
+
declare const Hint: unique symbol;
|
|
20
|
+
/** Symbol key applied to types */
|
|
21
|
+
declare const Kind: unique symbol;
|
|
22
|
+
|
|
23
|
+
type TReadonly<T extends TSchema> = T & {
|
|
24
|
+
[ReadonlyKind]: 'Readonly';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type UnionStatic<T extends TSchema[], P extends unknown[]> = {
|
|
28
|
+
[K in keyof T]: T[K] extends TSchema ? Static<T[K], P> : never;
|
|
29
|
+
}[number];
|
|
30
|
+
interface TUnion<T extends TSchema[] = TSchema[]> extends TSchema {
|
|
31
|
+
[Kind]: 'Union';
|
|
32
|
+
static: UnionStatic<T, this['params']>;
|
|
33
|
+
anyOf: T;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
|
|
37
|
+
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
38
|
+
interface StringOptions extends SchemaOptions {
|
|
39
|
+
/** The maximum string length */
|
|
40
|
+
maxLength?: number;
|
|
41
|
+
/** The minimum string length */
|
|
42
|
+
minLength?: number;
|
|
43
|
+
/** A regular expression pattern this string should match */
|
|
44
|
+
pattern?: string;
|
|
45
|
+
/** A format this string should match */
|
|
46
|
+
format?: StringFormatOption;
|
|
47
|
+
/** The content encoding for this string */
|
|
48
|
+
contentEncoding?: StringContentEncodingOption;
|
|
49
|
+
/** The content media type for this string */
|
|
50
|
+
contentMediaType?: string;
|
|
51
|
+
}
|
|
52
|
+
interface TString extends TSchema, StringOptions {
|
|
53
|
+
[Kind]: 'String';
|
|
54
|
+
static: string;
|
|
55
|
+
type: 'string';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface TBoolean extends TSchema {
|
|
59
|
+
[Kind]: 'Boolean';
|
|
60
|
+
static: boolean;
|
|
61
|
+
type: 'boolean';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface NumberOptions extends SchemaOptions {
|
|
65
|
+
exclusiveMaximum?: number;
|
|
66
|
+
exclusiveMinimum?: number;
|
|
67
|
+
maximum?: number;
|
|
68
|
+
minimum?: number;
|
|
69
|
+
multipleOf?: number;
|
|
70
|
+
}
|
|
71
|
+
interface TNumber extends TSchema, NumberOptions {
|
|
72
|
+
[Kind]: 'Number';
|
|
73
|
+
static: number;
|
|
74
|
+
type: 'number';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface IntegerOptions extends SchemaOptions {
|
|
78
|
+
exclusiveMaximum?: number;
|
|
79
|
+
exclusiveMinimum?: number;
|
|
80
|
+
maximum?: number;
|
|
81
|
+
minimum?: number;
|
|
82
|
+
multipleOf?: number;
|
|
83
|
+
}
|
|
84
|
+
interface TInteger extends TSchema, IntegerOptions {
|
|
85
|
+
[Kind]: 'Integer';
|
|
86
|
+
static: number;
|
|
87
|
+
type: 'integer';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type TOptional<T extends TSchema> = T & {
|
|
91
|
+
[OptionalKind]: 'Optional';
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** Creates a static type from a TypeBox type */
|
|
95
|
+
type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
|
|
96
|
+
params: Params;
|
|
97
|
+
})['static']> = Result;
|
|
98
|
+
|
|
99
|
+
type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
100
|
+
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
|
|
101
|
+
}[keyof T];
|
|
102
|
+
type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
103
|
+
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
|
|
104
|
+
}[keyof T];
|
|
105
|
+
type OptionalPropertyKeys<T extends TProperties> = {
|
|
106
|
+
[K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
|
|
107
|
+
}[keyof T];
|
|
108
|
+
type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
109
|
+
type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
110
|
+
type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
|
|
111
|
+
[K in keyof T]: Static<T[K], P>;
|
|
112
|
+
}>;
|
|
113
|
+
type TPropertyKey = string | number;
|
|
114
|
+
type TProperties = Record<TPropertyKey, TSchema>;
|
|
115
|
+
type TAdditionalProperties = undefined | TSchema | boolean;
|
|
116
|
+
interface ObjectOptions extends SchemaOptions {
|
|
117
|
+
/** Additional property constraints for this object */
|
|
118
|
+
additionalProperties?: TAdditionalProperties;
|
|
119
|
+
/** The minimum number of properties allowed on this object */
|
|
120
|
+
minProperties?: number;
|
|
121
|
+
/** The maximum number of properties allowed on this object */
|
|
122
|
+
maxProperties?: number;
|
|
123
|
+
}
|
|
124
|
+
interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
125
|
+
[Kind]: 'Object';
|
|
126
|
+
static: ObjectStatic<T, this['params']>;
|
|
127
|
+
additionalProperties?: TAdditionalProperties;
|
|
128
|
+
type: 'object';
|
|
129
|
+
properties: T;
|
|
130
|
+
required?: string[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
type Evaluate<T> = T extends infer O ? {
|
|
134
|
+
[K in keyof O]: O[K];
|
|
135
|
+
} : never;
|
|
136
|
+
type Ensure<T> = T extends infer U ? U : never;
|
|
137
|
+
|
|
138
|
+
interface ArrayOptions extends SchemaOptions {
|
|
139
|
+
/** The minimum number of items in this array */
|
|
140
|
+
minItems?: number;
|
|
141
|
+
/** The maximum number of items in this array */
|
|
142
|
+
maxItems?: number;
|
|
143
|
+
/** Should this schema contain unique items */
|
|
144
|
+
uniqueItems?: boolean;
|
|
145
|
+
/** A schema for which some elements should match */
|
|
146
|
+
contains?: TSchema;
|
|
147
|
+
/** A minimum number of contains schema matches */
|
|
148
|
+
minContains?: number;
|
|
149
|
+
/** A maximum number of contains schema matches */
|
|
150
|
+
maxContains?: number;
|
|
151
|
+
}
|
|
152
|
+
type ArrayStatic<T extends TSchema, P extends unknown[]> = Ensure<Static<T, P>[]>;
|
|
153
|
+
interface TArray<T extends TSchema = TSchema> extends TSchema, ArrayOptions {
|
|
154
|
+
[Kind]: 'Array';
|
|
155
|
+
static: ArrayStatic<T, this['params']>;
|
|
156
|
+
type: 'array';
|
|
157
|
+
items: T;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface SchemaOptions {
|
|
161
|
+
$schema?: string;
|
|
162
|
+
/** Id for this schema */
|
|
163
|
+
$id?: string;
|
|
164
|
+
/** Title of this schema */
|
|
165
|
+
title?: string;
|
|
166
|
+
/** Description of this schema */
|
|
167
|
+
description?: string;
|
|
168
|
+
/** Default value for this schema */
|
|
169
|
+
default?: any;
|
|
170
|
+
/** Example values matching this schema */
|
|
171
|
+
examples?: any;
|
|
172
|
+
/** Optional annotation for readOnly */
|
|
173
|
+
readOnly?: boolean;
|
|
174
|
+
/** Optional annotation for writeOnly */
|
|
175
|
+
writeOnly?: boolean;
|
|
176
|
+
[prop: string]: any;
|
|
177
|
+
}
|
|
178
|
+
interface TKind {
|
|
179
|
+
[Kind]: string;
|
|
180
|
+
}
|
|
181
|
+
interface TSchema extends TKind, SchemaOptions {
|
|
182
|
+
[ReadonlyKind]?: string;
|
|
183
|
+
[OptionalKind]?: string;
|
|
184
|
+
[Hint]?: string;
|
|
185
|
+
params: unknown[];
|
|
186
|
+
static: unknown;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
190
|
+
type RouteMethod = (typeof routeMethods)[number];
|
|
191
|
+
|
|
192
|
+
declare const envSchema$4: TObject$1<{
|
|
193
|
+
SERVER_ALS_ENABLED: TBoolean;
|
|
194
|
+
}>;
|
|
195
|
+
declare module "alepha" {
|
|
196
|
+
interface Env extends Partial<Static$1<typeof envSchema$4>> {
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler> {
|
|
200
|
+
protected readonly alepha: Alepha;
|
|
201
|
+
protected readonly env: {
|
|
202
|
+
SERVER_ALS_ENABLED: boolean;
|
|
203
|
+
};
|
|
204
|
+
createRequestId(): string;
|
|
205
|
+
route<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): Promise<void>;
|
|
206
|
+
handle(route: ServerRoute, rawRequest: ServerRawRequest, responseType: ResponseType, withAls: boolean): Promise<ServerResponse>;
|
|
207
|
+
protected processRequest(request: ServerRequest, route: ServerRoute, responseType: ResponseType, withAls: boolean): Promise<{
|
|
208
|
+
status: number;
|
|
209
|
+
headers: Record<string, string> & {
|
|
210
|
+
"set-cookie"?: string[];
|
|
211
|
+
};
|
|
212
|
+
body: any;
|
|
213
|
+
}>;
|
|
214
|
+
protected tryRequestProcessing(route: ServerRoute, request: ServerRequest, responseType: ResponseType, withAls: boolean): Promise<void>;
|
|
215
|
+
protected getResponseType(schema?: RequestConfigSchema): ResponseType;
|
|
216
|
+
protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
|
|
217
|
+
validateRequest(route: {
|
|
218
|
+
schema?: RequestConfigSchema;
|
|
219
|
+
}, request: ServerRequestConfig): void;
|
|
220
|
+
serializeResponse(route: ServerRoute, reply: ServerReply, responseType: ResponseType): void;
|
|
221
|
+
}
|
|
222
|
+
interface RequestConfigSchema {
|
|
223
|
+
body?: TSchema$1;
|
|
224
|
+
params?: TObject$1;
|
|
225
|
+
query?: TObject$1;
|
|
226
|
+
headers?: TObject$1;
|
|
227
|
+
response?: TSchema$1;
|
|
228
|
+
}
|
|
229
|
+
interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
230
|
+
body: TConfig["body"] extends TSchema$1 ? Static$1<TConfig["body"]> : any;
|
|
231
|
+
headers: TConfig["headers"] extends TObject$1 ? Static$1<TConfig["headers"]> : Record<string, string>;
|
|
232
|
+
params: TConfig["params"] extends TObject$1 ? Static$1<TConfig["params"]> : Record<string, string>;
|
|
233
|
+
query: TConfig["query"] extends TObject$1 ? Static$1<TConfig["query"]> : Record<string, string>;
|
|
234
|
+
}
|
|
235
|
+
type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
|
|
236
|
+
interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
|
|
237
|
+
method: RouteMethod;
|
|
238
|
+
url: URL;
|
|
239
|
+
metadata: Record<string, any>;
|
|
240
|
+
reply: ServerReply;
|
|
241
|
+
raw: {
|
|
242
|
+
node?: {
|
|
243
|
+
req: IncomingMessage;
|
|
244
|
+
res: ServerResponse$1;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
user: UserAccountToken;
|
|
248
|
+
}
|
|
249
|
+
interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
|
|
250
|
+
method?: RouteMethod;
|
|
251
|
+
silent?: boolean;
|
|
252
|
+
handler: ServerHandler<TConfig>;
|
|
253
|
+
schema?: TConfig;
|
|
254
|
+
}
|
|
255
|
+
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TSchema$1 ? Static$1<TConfig["response"]> : ResponseBodyType;
|
|
256
|
+
type ResponseType = "json" | "text" | "void" | "file" | "any";
|
|
257
|
+
type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
|
|
258
|
+
type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
259
|
+
interface ServerReply {
|
|
260
|
+
headers: Record<string, string> & {
|
|
261
|
+
"set-cookie"?: string[];
|
|
262
|
+
};
|
|
263
|
+
status?: number;
|
|
264
|
+
body?: any;
|
|
265
|
+
redirect(url: string): void;
|
|
266
|
+
}
|
|
267
|
+
interface ServerResponse {
|
|
268
|
+
body: string | ArrayBuffer | Readable | ReadableStream;
|
|
269
|
+
headers: Record<string, string>;
|
|
270
|
+
status: number;
|
|
271
|
+
}
|
|
272
|
+
interface ServerRouteWithHandler extends Route {
|
|
273
|
+
handler: (request: ServerRawRequest) => Promise<ServerResponse>;
|
|
274
|
+
}
|
|
275
|
+
interface ServerRawRequest {
|
|
276
|
+
method: RouteMethod;
|
|
277
|
+
url: URL;
|
|
278
|
+
headers: Record<string, string>;
|
|
279
|
+
query: Record<string, string>;
|
|
280
|
+
params: Record<string, string>;
|
|
281
|
+
raw: {
|
|
282
|
+
node?: {
|
|
283
|
+
req: IncomingMessage;
|
|
284
|
+
res: ServerResponse$1;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Route descriptor options.
|
|
291
|
+
*/
|
|
292
|
+
interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema"> {
|
|
293
|
+
/**
|
|
294
|
+
* Name the route.
|
|
295
|
+
*/
|
|
296
|
+
name?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Namespace of the route, used for grouping.
|
|
299
|
+
*
|
|
300
|
+
* @default Class name containing the route.
|
|
301
|
+
*/
|
|
302
|
+
group?: string;
|
|
303
|
+
/**
|
|
304
|
+
* If false, disabled the security check for this route.
|
|
305
|
+
*
|
|
306
|
+
* @default true when SecurityModule is enabled, false otherwise.
|
|
307
|
+
*/
|
|
308
|
+
security?: boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Pathname of the route.
|
|
311
|
+
*/
|
|
312
|
+
path?: string;
|
|
313
|
+
/**
|
|
314
|
+
* Inherit options from another route.
|
|
315
|
+
*/
|
|
316
|
+
use?: {
|
|
317
|
+
[OPTIONS]: RouteDescriptorOptions<TConfig>;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* The route method.
|
|
321
|
+
*
|
|
322
|
+
* @default "GET" or "POST" when schema body is defined.
|
|
323
|
+
*/
|
|
324
|
+
method?: RouteMethod;
|
|
325
|
+
/**
|
|
326
|
+
* The config schema of the route.
|
|
327
|
+
* - body: The request body schema.
|
|
328
|
+
* - params: Path variables schema.
|
|
329
|
+
* - query: The request query-params schema.
|
|
330
|
+
* - response: The response schema.
|
|
331
|
+
*/
|
|
332
|
+
schema?: TConfig;
|
|
333
|
+
/**
|
|
334
|
+
* Short description of the route.
|
|
335
|
+
*/
|
|
336
|
+
summary?: string;
|
|
337
|
+
/**
|
|
338
|
+
* Long description of the route.
|
|
339
|
+
*/
|
|
340
|
+
description?: string;
|
|
341
|
+
/**
|
|
342
|
+
* Disable the route. Useful with env variables do disable one specific route.
|
|
343
|
+
*/
|
|
344
|
+
disabled?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Mark the route as private. It will not be exposed in the API documentation.
|
|
347
|
+
*/
|
|
348
|
+
internal?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Main route handler. This is where the route logic is implemented.
|
|
351
|
+
*/
|
|
352
|
+
handler?: ServerHandler<TConfig>;
|
|
353
|
+
}
|
|
354
|
+
interface RouteDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
355
|
+
[KIND]: "ROUTE";
|
|
356
|
+
[OPTIONS]: RouteDescriptorOptions<TConfig>;
|
|
357
|
+
/**
|
|
358
|
+
* Fetch or just call local route when available.
|
|
359
|
+
*/
|
|
360
|
+
(config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions): ClientRequestResponse<TConfig>;
|
|
361
|
+
/**
|
|
362
|
+
* Just fetch the route. Skip any local route.
|
|
363
|
+
*/
|
|
364
|
+
fetch: (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions) => ClientRequestResponse<TConfig>;
|
|
365
|
+
/**
|
|
366
|
+
* Name of the permission required to access this route.
|
|
367
|
+
*/
|
|
368
|
+
permission: () => string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Declare a new route.
|
|
372
|
+
*
|
|
373
|
+
* ```ts
|
|
374
|
+
* class A {
|
|
375
|
+
* hello = $route({
|
|
376
|
+
* url: "/hello",
|
|
377
|
+
* handler: () => "Hello, World!",
|
|
378
|
+
* });
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*
|
|
382
|
+
* @param options The route options.
|
|
383
|
+
* @returns The route.
|
|
384
|
+
*/
|
|
385
|
+
declare const $route: {
|
|
386
|
+
<TConfig extends RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
|
|
387
|
+
[KIND]: string;
|
|
388
|
+
};
|
|
389
|
+
declare const $action: {
|
|
390
|
+
<TConfig extends RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
|
|
391
|
+
[KIND]: string;
|
|
392
|
+
};
|
|
393
|
+
type ClientRequestEntry<TConfig extends RequestConfigSchema = RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = {
|
|
394
|
+
[K in keyof T as T[K] extends undefined ? never : K]: T[K];
|
|
395
|
+
};
|
|
396
|
+
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema = RequestConfigSchema> = {
|
|
397
|
+
body: TConfig["body"] extends TSchema$1 ? Static$1<TConfig["body"]> : undefined;
|
|
398
|
+
params: TConfig["params"] extends TSchema$1 ? Static$1<TConfig["params"]> : undefined;
|
|
399
|
+
headers?: TConfig["headers"] extends TSchema$1 ? Static$1<TConfig["headers"]> : undefined;
|
|
400
|
+
query?: TConfig["query"] extends TSchema$1 ? Partial<Static$1<TConfig["query"]>> : undefined;
|
|
401
|
+
};
|
|
402
|
+
interface ClientRequestOptions {
|
|
403
|
+
/**
|
|
404
|
+
* Built-in cache options.
|
|
405
|
+
* Number as seconds or boolean to enable cache.
|
|
406
|
+
*/
|
|
407
|
+
cache?: number | boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Forward user from the previous request.
|
|
410
|
+
*
|
|
411
|
+
* In testing environments, you can pass a partial user token.
|
|
412
|
+
*/
|
|
413
|
+
user?: Partial<UserAccountToken>;
|
|
414
|
+
/**
|
|
415
|
+
* Standard request fetch options.
|
|
416
|
+
*/
|
|
417
|
+
request?: RequestInit;
|
|
418
|
+
}
|
|
419
|
+
type ClientRequestResponse<TConfig extends RequestConfigSchema> = Promise<TConfig["response"] extends TSchema$1 ? Static$1<TConfig["response"]> : Response>;
|
|
420
|
+
|
|
421
|
+
declare class HttpError extends Error {
|
|
422
|
+
static toJSON(error: HttpError): {
|
|
423
|
+
status: number;
|
|
424
|
+
error: string | undefined;
|
|
425
|
+
message: string;
|
|
426
|
+
cause: {
|
|
427
|
+
name: string;
|
|
428
|
+
message: string;
|
|
429
|
+
};
|
|
430
|
+
} | {
|
|
431
|
+
status: number;
|
|
432
|
+
error: string | undefined;
|
|
433
|
+
message: string;
|
|
434
|
+
cause?: undefined;
|
|
435
|
+
};
|
|
436
|
+
readonly status: number;
|
|
437
|
+
readonly error?: string;
|
|
438
|
+
readonly reason?: {
|
|
439
|
+
name: string;
|
|
440
|
+
message: string;
|
|
441
|
+
};
|
|
442
|
+
constructor(options: {
|
|
443
|
+
error?: string;
|
|
444
|
+
message: string;
|
|
445
|
+
status: number;
|
|
446
|
+
cause?: {
|
|
447
|
+
name: string;
|
|
448
|
+
message: string;
|
|
449
|
+
} | unknown;
|
|
450
|
+
}, cause?: unknown);
|
|
451
|
+
}
|
|
452
|
+
declare const errorNameByStatus: Record<number, string>;
|
|
453
|
+
|
|
454
|
+
declare class RouteDescriptorHelper {
|
|
455
|
+
name(options: RouteDescriptorOptions, instance: any, key: string): string;
|
|
456
|
+
path(options: RouteDescriptorOptions, instance: any, key: string, prefix?: string): string;
|
|
457
|
+
link(options: RouteDescriptorOptions, instance: any, key: string, prefix?: string): HttpClientLink;
|
|
458
|
+
method(options: {
|
|
459
|
+
method?: string;
|
|
460
|
+
schema?: any;
|
|
461
|
+
}): RouteMethod;
|
|
462
|
+
permission(options: RouteDescriptorOptions, instance: any, key: string, prefix?: string): Permission;
|
|
463
|
+
group(options: RouteDescriptorOptions, instance: any): string;
|
|
464
|
+
isMultipart(options: {
|
|
465
|
+
schema?: RequestConfigSchema;
|
|
466
|
+
}): boolean;
|
|
467
|
+
bodyContentType(options: RouteDescriptorOptions): string | undefined;
|
|
468
|
+
protected short(name: string): string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
declare class HttpClient {
|
|
472
|
+
protected readonly alepha: Alepha;
|
|
473
|
+
protected readonly env: {
|
|
474
|
+
SERVER_API_URL: string;
|
|
475
|
+
CLIENT_API_PREFIX: string;
|
|
476
|
+
};
|
|
477
|
+
protected readonly helper: RouteDescriptorHelper;
|
|
478
|
+
readonly URL_LINKS = "/_links";
|
|
479
|
+
readonly cache: _alepha_cache.CacheDescriptor<any, any[]>;
|
|
480
|
+
links?: Array<HttpClientLink>;
|
|
481
|
+
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
482
|
+
json<T = any>(url: string, options?: RequestInit): Promise<T>;
|
|
483
|
+
clear(): Promise<void>;
|
|
484
|
+
createFetchFunction(link: HttpClientLink, options?: FetchFactoryAdditionalOptions): (config?: Partial<ClientRequestEntry>, request?: ClientRequestOptions) => Promise<any>;
|
|
485
|
+
request(args: {
|
|
486
|
+
config?: ServerRequestConfigEntry;
|
|
487
|
+
link: HttpClientLink;
|
|
488
|
+
request?: ClientRequestOptions;
|
|
489
|
+
host?: string;
|
|
490
|
+
}): Promise<any>;
|
|
491
|
+
protected url(host: string, link: HttpClientLink, args: ServerRequestConfigEntry): string;
|
|
492
|
+
protected body(init: RequestInit, headers: Record<string, string>, link: HttpClientLink, args?: ServerRequestConfigEntry): Promise<void>;
|
|
493
|
+
fetch<T>(url: string, request: RequestInit, options?: FetchRunOptions): Promise<T>;
|
|
494
|
+
/**
|
|
495
|
+
* Parse the response.
|
|
496
|
+
*
|
|
497
|
+
* @param response
|
|
498
|
+
* @param options
|
|
499
|
+
* @protected
|
|
500
|
+
*/
|
|
501
|
+
protected response(response: Response, options: FetchRunOptions): Promise<Response | any>;
|
|
502
|
+
protected getFileLike(response: Response, defaultFileName?: string): FileLike;
|
|
503
|
+
protected pathVariables(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
|
|
504
|
+
protected queryParams(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
|
|
505
|
+
of<T extends object>(options?: {
|
|
506
|
+
group?: string;
|
|
507
|
+
host?: string | (() => string);
|
|
508
|
+
}): HttpVirtualClient<T>;
|
|
509
|
+
follow(name: string, config?: any, options?: {
|
|
510
|
+
request?: ClientRequestOptions;
|
|
511
|
+
group?: string;
|
|
512
|
+
host?: string | (() => string);
|
|
513
|
+
}): Promise<any>;
|
|
514
|
+
can(name: string): boolean;
|
|
515
|
+
getLinks(opts?: {
|
|
516
|
+
force?: boolean;
|
|
517
|
+
host?: string;
|
|
518
|
+
}): Promise<HttpClientLink[]>;
|
|
519
|
+
}
|
|
520
|
+
type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
|
|
521
|
+
interface FetchFactoryAdditionalOptions {
|
|
522
|
+
host?: string | (() => string);
|
|
523
|
+
}
|
|
524
|
+
interface FetchRunOptions {
|
|
525
|
+
schema?: TSchema$1;
|
|
526
|
+
raw?: boolean;
|
|
527
|
+
cache?: boolean | DurationLike;
|
|
528
|
+
}
|
|
529
|
+
interface HttpClientLink {
|
|
530
|
+
method: RouteMethod;
|
|
531
|
+
path: string;
|
|
532
|
+
name: string;
|
|
533
|
+
group?: string;
|
|
534
|
+
contentType?: string;
|
|
535
|
+
protected?: boolean;
|
|
536
|
+
schema?: RequestConfigSchema;
|
|
537
|
+
handler?: ServerHandler;
|
|
538
|
+
}
|
|
539
|
+
type HttpVirtualClient<T> = {
|
|
540
|
+
[K in keyof T as T[K] extends RouteDescriptor ? K : never]: T[K] & {
|
|
541
|
+
can: () => boolean;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
declare const REMOTE_DESCRIPTOR_KEY = "REMOTE";
|
|
546
|
+
interface RemoteDescriptorOptions {
|
|
547
|
+
/**
|
|
548
|
+
* The URL of the remote service.
|
|
549
|
+
*/
|
|
550
|
+
url: string | (() => string);
|
|
551
|
+
/**
|
|
552
|
+
* One or many instance of classes to be registered as remote services.
|
|
553
|
+
* Services must contain some $action() descriptors.
|
|
554
|
+
*/
|
|
555
|
+
services: object | Array<object>;
|
|
556
|
+
/**
|
|
557
|
+
* The name of the remote service.
|
|
558
|
+
*
|
|
559
|
+
* @default Member of the class containing the remote service.
|
|
560
|
+
*/
|
|
561
|
+
name?: string;
|
|
562
|
+
}
|
|
563
|
+
interface RemoteDescriptor {
|
|
564
|
+
[KIND]: typeof REMOTE_DESCRIPTOR_KEY;
|
|
565
|
+
[OPTIONS]: RemoteDescriptorOptions;
|
|
566
|
+
}
|
|
567
|
+
declare const $remote: {
|
|
568
|
+
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
569
|
+
[KIND]: string;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
declare class ServerProvider {
|
|
573
|
+
get hostname(): string;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
declare const envSchema$3: _alepha_core.TObject<{
|
|
577
|
+
SERVER_API_PREFIX: TString;
|
|
578
|
+
SERVER_SECURITY_ENABLED: TBoolean;
|
|
579
|
+
}>;
|
|
580
|
+
declare module "alepha/core" {
|
|
581
|
+
interface Env extends Partial<Static$1<typeof envSchema$3>> {
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
declare class ServerActionDescriptorProvider {
|
|
585
|
+
protected readonly log: _alepha_core.Logger;
|
|
586
|
+
protected readonly alepha: Alepha;
|
|
587
|
+
protected readonly env: {
|
|
588
|
+
SERVER_API_PREFIX: string;
|
|
589
|
+
SERVER_SECURITY_ENABLED: boolean;
|
|
590
|
+
};
|
|
591
|
+
protected readonly client: HttpClient;
|
|
592
|
+
protected readonly serverProvider: ServerProvider;
|
|
593
|
+
protected readonly helper: RouteDescriptorHelper;
|
|
594
|
+
protected readonly routerProvider: ServerRouterProvider;
|
|
595
|
+
protected readonly remotes: Array<ServerRemote>;
|
|
596
|
+
protected readonly actions: ServerRouteAction[];
|
|
597
|
+
getActions(): ServerRouteAction<RequestConfigSchema>[];
|
|
598
|
+
readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
599
|
+
registerRemote(value: RemoteDescriptor, key: string): void;
|
|
600
|
+
registerAction(value: RouteDescriptor, key: string, instance: any, prefix?: string): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* When your action has no handler, it's considered as an 'API'.
|
|
603
|
+
* Instead of creating an http route, create a bridge to a local or remote function.
|
|
604
|
+
*
|
|
605
|
+
* ```ts
|
|
606
|
+
* class Api {
|
|
607
|
+
* hello = $action(); // <- route 'Api'
|
|
608
|
+
* }
|
|
609
|
+
*
|
|
610
|
+
* class Controller {
|
|
611
|
+
* api = $inject(Api);
|
|
612
|
+
* hello = $action({ // <-- route
|
|
613
|
+
* use: this.api.hello,
|
|
614
|
+
* handler: () => new Response("Hello world"),
|
|
615
|
+
* })
|
|
616
|
+
* }
|
|
617
|
+
*
|
|
618
|
+
* const api = alepha.get(Api);
|
|
619
|
+
*
|
|
620
|
+
* api.hello(); // <-- call the local controller function if available
|
|
621
|
+
*
|
|
622
|
+
* // or with $remote
|
|
623
|
+
* class Remotes {
|
|
624
|
+
* api = $remote({ url: "http://localhost:8080", services: [Api] });
|
|
625
|
+
* }
|
|
626
|
+
*
|
|
627
|
+
* // or with future auto-discovery
|
|
628
|
+
* ```
|
|
629
|
+
*/
|
|
630
|
+
registerActionApi(routeDescriptor: RouteDescriptor, instance: any, key: string): void;
|
|
631
|
+
/**
|
|
632
|
+
* Check a mock function for the specified route.
|
|
633
|
+
*
|
|
634
|
+
* This is mostly used for testing purposes.
|
|
635
|
+
*
|
|
636
|
+
* @param value
|
|
637
|
+
* @param permission
|
|
638
|
+
* @protected
|
|
639
|
+
*/
|
|
640
|
+
protected createLocalFunction(value: RouteDescriptor, permission: Permission): (config?: ServerRequestConfigEntry, options?: ClientRequestOptions) => Promise<any>;
|
|
641
|
+
/**
|
|
642
|
+
* Security adapted for local function.
|
|
643
|
+
*/
|
|
644
|
+
protected getUserFromLocalFunctionContext(options: {
|
|
645
|
+
user?: Partial<UserAccountToken>;
|
|
646
|
+
}, permission: Permission, security: boolean): UserAccountToken | undefined;
|
|
647
|
+
/**
|
|
648
|
+
* TODO: remove it, this is a hack for testing purposes
|
|
649
|
+
*/
|
|
650
|
+
protected createSystemUser(): UserAccountToken;
|
|
651
|
+
}
|
|
652
|
+
declare const isServerAction: (value: any) => value is ServerRouteAction;
|
|
653
|
+
interface ServerRemote {
|
|
654
|
+
url: string;
|
|
655
|
+
services: object[];
|
|
656
|
+
name: string;
|
|
657
|
+
}
|
|
658
|
+
interface ServerRouteAction<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {
|
|
659
|
+
method: RouteMethod;
|
|
660
|
+
name: string;
|
|
661
|
+
group: string;
|
|
662
|
+
permission: Permission;
|
|
663
|
+
options: RouteDescriptorOptions;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
declare const envSchema$2: _alepha_core.TObject<{
|
|
667
|
+
SERVER_API_URL: TString;
|
|
668
|
+
}>;
|
|
669
|
+
declare module "@alepha/core" {
|
|
670
|
+
interface Env extends Partial<Static$1<typeof envSchema$2>> {
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
declare class BrowserActionDescriptorProvider {
|
|
674
|
+
protected readonly log: _alepha_core.Logger;
|
|
675
|
+
protected readonly alepha: Alepha;
|
|
676
|
+
protected readonly client: HttpClient;
|
|
677
|
+
protected readonly env: {
|
|
678
|
+
SERVER_API_URL: string;
|
|
679
|
+
};
|
|
680
|
+
protected readonly helper: RouteDescriptorHelper;
|
|
681
|
+
readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
682
|
+
configureActions(): void;
|
|
683
|
+
registerAction(value: RouteDescriptor, instance: any, key: string): void;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
declare class ServerSecurityProvider {
|
|
687
|
+
protected readonly log: _alepha_core.Logger;
|
|
688
|
+
protected readonly securityProvider: SecurityProvider;
|
|
689
|
+
protected readonly jwtProvider: JwtProvider;
|
|
690
|
+
protected readonly alepha: Alepha;
|
|
691
|
+
readonly onClientRequest: _alepha_core.HookDescriptor<"client:onRequest">;
|
|
692
|
+
protected readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
|
|
693
|
+
protected readonly onRoute: _alepha_core.HookDescriptor<"server:onRoute">;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
declare class ServerLinksProvider {
|
|
697
|
+
protected readonly alepha: Alepha;
|
|
698
|
+
protected readonly client: HttpClient;
|
|
699
|
+
readonly links: RouteDescriptor<{
|
|
700
|
+
response: TArray<TObject<{
|
|
701
|
+
name: TString;
|
|
702
|
+
method: TOptional<TString>;
|
|
703
|
+
path: TOptional<TString>;
|
|
704
|
+
group: TOptional<TString>;
|
|
705
|
+
protected: TOptional<TBoolean>;
|
|
706
|
+
contentType: TOptional<TString>;
|
|
707
|
+
}>>;
|
|
708
|
+
}>;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
declare class ServerLoggerProvider {
|
|
712
|
+
protected readonly log: _alepha_core.Logger;
|
|
713
|
+
protected readonly alepha: Alepha;
|
|
714
|
+
readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
|
|
715
|
+
readonly onError: _alepha_core.HookDescriptor<"server:onError">;
|
|
716
|
+
readonly onResponse: _alepha_core.HookDescriptor<"server:onResponse">;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
declare class ServerMultipartProvider {
|
|
720
|
+
protected readonly helper: RouteDescriptorHelper;
|
|
721
|
+
protected readonly alepha: Alepha;
|
|
722
|
+
readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
|
|
723
|
+
readonly onSend: _alepha_core.HookDescriptor<"server:onSend">;
|
|
724
|
+
handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
|
|
725
|
+
body: Record<string, any>;
|
|
726
|
+
cleanup: () => Promise<void>;
|
|
727
|
+
}>;
|
|
728
|
+
parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
|
|
729
|
+
}
|
|
730
|
+
interface MultipartResult {
|
|
731
|
+
fields: Record<string, string | string[]>;
|
|
732
|
+
files: Record<string, HybridFile>;
|
|
733
|
+
}
|
|
734
|
+
interface HybridFile extends FileLike {
|
|
735
|
+
cleanup(): Promise<void>;
|
|
736
|
+
_state: {
|
|
737
|
+
cleanup: boolean;
|
|
738
|
+
size: number;
|
|
739
|
+
tmpPath: string;
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Create a file-like object from various sources.
|
|
744
|
+
*/
|
|
745
|
+
declare const file: (source: string | Buffer | ArrayBuffer | StreamLike, options?: {
|
|
746
|
+
type?: string;
|
|
747
|
+
name?: string;
|
|
748
|
+
}) => FileLike;
|
|
749
|
+
declare const bufferToStream: (buffer: Buffer) => Readable;
|
|
750
|
+
declare const streamToBuffer: (stream: Readable) => Promise<Buffer>;
|
|
751
|
+
declare const bufferToArrayBuffer: (buffer: Buffer) => ArrayBuffer;
|
|
752
|
+
declare const getContentType: (filename: string) => string;
|
|
753
|
+
|
|
754
|
+
declare const envSchema$1: _alepha_core.TObject<{
|
|
755
|
+
SERVER_PORT: TNumber;
|
|
756
|
+
SERVER_HOST: TString;
|
|
757
|
+
}>;
|
|
758
|
+
declare module "@alepha/core" {
|
|
759
|
+
interface Env extends Partial<Static$1<typeof envSchema$1>> {
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
declare class NodeHttpServerProvider implements ServerProvider {
|
|
763
|
+
protected readonly alepha: Alepha;
|
|
764
|
+
protected readonly log: _alepha_core.Logger;
|
|
765
|
+
protected readonly env: {
|
|
766
|
+
SERVER_PORT: number;
|
|
767
|
+
SERVER_HOST: string;
|
|
768
|
+
};
|
|
769
|
+
protected readonly router: ServerRouterProvider;
|
|
770
|
+
protected readonly server: http.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
771
|
+
handle(req: IncomingMessage, res: ServerResponse$1): Promise<number | void>;
|
|
772
|
+
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
773
|
+
shouldHaveBody(method: string): boolean;
|
|
774
|
+
get hostname(): string;
|
|
775
|
+
readonly start: _alepha_core.HookDescriptor<"start">;
|
|
776
|
+
protected readonly stop: _alepha_core.HookDescriptor<"stop">;
|
|
777
|
+
protected listen(): Promise<void>;
|
|
778
|
+
protected close(): Promise<void>;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
declare const errorSchema: TObject<{
|
|
782
|
+
error: TString;
|
|
783
|
+
status: TNumber;
|
|
784
|
+
message: TString;
|
|
785
|
+
details: TOptional<TString>;
|
|
786
|
+
cause: TOptional<TObject<{
|
|
787
|
+
name: TString;
|
|
788
|
+
message: TString;
|
|
789
|
+
}>>;
|
|
790
|
+
}>;
|
|
791
|
+
|
|
792
|
+
declare const okSchema: TObject<{
|
|
793
|
+
ok: TBoolean;
|
|
794
|
+
id: TOptional<TUnion<[TString, TInteger]>>;
|
|
795
|
+
count: TOptional<TNumber>;
|
|
796
|
+
}>;
|
|
797
|
+
type Ok = Static$1<typeof okSchema>;
|
|
798
|
+
|
|
799
|
+
declare class BadRequestError extends HttpError {
|
|
800
|
+
constructor(message?: string, cause?: unknown);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
declare class ConflictError extends HttpError {
|
|
804
|
+
constructor(message?: string, cause?: unknown);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
declare class ForbiddenError extends HttpError {
|
|
808
|
+
constructor(message?: string, cause?: unknown);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
declare class NotFoundError extends HttpError {
|
|
812
|
+
constructor(message?: string, cause?: unknown);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
declare class UnauthorizedError extends HttpError {
|
|
816
|
+
constructor(message?: string, cause?: unknown);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
declare class ValidationError extends HttpError {
|
|
820
|
+
constructor(message?: string, cause?: unknown);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
declare const envSchema: _alepha_core.TObject<{
|
|
824
|
+
SERVER_LINKS_ENABLED: TBoolean;
|
|
825
|
+
}>;
|
|
826
|
+
declare module "@alepha/core" {
|
|
827
|
+
interface Hooks {
|
|
828
|
+
"server:onRoute": {
|
|
829
|
+
route: ServerRoute;
|
|
830
|
+
};
|
|
831
|
+
"server:onRequest": {
|
|
832
|
+
route: ServerRoute;
|
|
833
|
+
request: ServerRequest;
|
|
834
|
+
};
|
|
835
|
+
"server:onError": {
|
|
836
|
+
route: ServerRoute;
|
|
837
|
+
request: ServerRequest;
|
|
838
|
+
error: Error;
|
|
839
|
+
};
|
|
840
|
+
"server:onSend": {
|
|
841
|
+
route: ServerRoute;
|
|
842
|
+
request: ServerRequest;
|
|
843
|
+
};
|
|
844
|
+
"server:onResponse": {
|
|
845
|
+
route: ServerRoute;
|
|
846
|
+
request: ServerRequest;
|
|
847
|
+
response: ServerResponse;
|
|
848
|
+
};
|
|
849
|
+
"client:onRequest": {
|
|
850
|
+
route: HttpClientLink;
|
|
851
|
+
config: ServerRequestConfigEntry;
|
|
852
|
+
options: ClientRequestOptions;
|
|
853
|
+
headers: Record<string, string>;
|
|
854
|
+
request: RequestInit;
|
|
855
|
+
};
|
|
856
|
+
"client:beforeFetch": {
|
|
857
|
+
url: string;
|
|
858
|
+
options: FetchRunOptions;
|
|
859
|
+
request: RequestInit;
|
|
860
|
+
};
|
|
861
|
+
"client:onError": {
|
|
862
|
+
route?: HttpClientLink;
|
|
863
|
+
error: HttpError;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
declare module "@alepha/core" {
|
|
868
|
+
interface Env extends Partial<Static$1<typeof envSchema>> {
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
declare class ServerModule {
|
|
872
|
+
protected readonly env: {
|
|
873
|
+
SERVER_LINKS_ENABLED: boolean;
|
|
874
|
+
};
|
|
875
|
+
protected readonly alepha: Alepha;
|
|
876
|
+
constructor();
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export { $action, $remote, $route, 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, REMOTE_DESCRIPTOR_KEY, type RemoteDescriptor, type RemoteDescriptorOptions, type RequestConfigSchema, type ResponseBodyType, type ResponseType, type RouteDescriptor, type RouteDescriptorOptions, type RouteMethod, ServerActionDescriptorProvider, type ServerHandler, ServerLinksProvider, ServerLoggerProvider, ServerModule, ServerMultipartProvider, 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, bufferToArrayBuffer, bufferToStream, errorNameByStatus, errorSchema, file, getContentType, isServerAction, okSchema, routeMethods, streamToBuffer };
|