alepha 0.7.7 → 0.8.1
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/LICENSE +21 -21
- package/README.md +7 -34
- package/batch.cjs +8 -0
- package/batch.d.ts +147 -0
- package/batch.js +1 -0
- package/cache/redis.d.ts +13 -18
- package/cache.d.ts +183 -119
- package/command.cjs +8 -0
- package/command.d.ts +152 -0
- package/command.js +1 -0
- package/core.d.ts +846 -838
- package/datetime.d.ts +78 -78
- package/file.cjs +8 -0
- package/file.d.ts +46 -0
- package/file.js +1 -0
- package/lock/redis.d.ts +10 -12
- package/lock.d.ts +73 -80
- package/package.json +86 -34
- package/postgres.d.ts +348 -170
- package/queue/redis.d.ts +13 -13
- package/queue.d.ts +107 -18
- package/react/auth.d.ts +22 -16
- package/react/head.d.ts +10 -4
- package/react.d.ts +206 -49
- package/redis.d.ts +23 -27
- package/retry.d.ts +75 -54
- package/router.cjs +8 -0
- package/router.d.ts +45 -0
- package/router.js +1 -0
- package/scheduler.d.ts +15 -16
- package/security.d.ts +229 -40
- package/server/cache.d.ts +7 -8
- package/server/compress.cjs +8 -0
- package/server/compress.d.ts +26 -0
- package/server/compress.js +1 -0
- package/server/cookies.d.ts +249 -18
- package/server/cors.d.ts +7 -3
- package/server/health.d.ts +21 -24
- package/server/helmet.cjs +8 -0
- package/server/helmet.d.ts +70 -0
- package/server/helmet.js +1 -0
- package/server/links.d.ts +87 -93
- package/server/metrics.cjs +8 -0
- package/server/metrics.d.ts +35 -0
- package/server/metrics.js +1 -0
- package/server/multipart.cjs +8 -0
- package/server/multipart.d.ts +46 -0
- package/server/multipart.js +1 -0
- package/server/proxy.d.ts +11 -11
- package/server/static.d.ts +70 -55
- package/server/swagger.d.ts +55 -54
- package/server.d.ts +273 -123
- package/topic/redis.d.ts +22 -23
- package/topic.d.ts +26 -19
- package/vite.d.ts +59 -36
package/server.d.ts
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import * as _alepha_core1 from "
|
|
2
|
-
import * as _alepha_core3 from "
|
|
3
|
-
import * as _alepha_core7 from "
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import { BusboyConfig } from "@fastify/busboy";
|
|
12
|
-
import * as _alepha_cache2 from "@alepha/cache";
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
|
+
import * as _alepha_core3 from "alepha";
|
|
3
|
+
import * as _alepha_core7 from "alepha";
|
|
4
|
+
import * as _alepha_core8 from "alepha";
|
|
5
|
+
import * as _alepha_core12 from "alepha";
|
|
6
|
+
import * as _alepha_core15 from "alepha";
|
|
7
|
+
import * as _alepha_core24 from "alepha";
|
|
8
|
+
import { Alepha, Async, FileLike, KIND, Module, OPTIONS, Static, StreamLike, TObject, TSchema } from "alepha";
|
|
9
|
+
import { JwtProvider, Permission, SecurityProvider, ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
10
|
+
import * as _alepha_cache2 from "alepha/cache";
|
|
13
11
|
import { Readable } from "node:stream";
|
|
14
12
|
import { ReadableStream } from "node:stream/web";
|
|
15
|
-
import { Route, RouterProvider } from "
|
|
13
|
+
import { Route, RouterProvider } from "alepha/router";
|
|
16
14
|
import { IncomingMessage, ServerResponse as ServerResponse$1 } from "node:http";
|
|
17
|
-
import { DurationLike } from "
|
|
18
|
-
import * as
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as _sinclair_typebox63 from "@sinclair/typebox";
|
|
23
|
-
import * as http18 from "http";
|
|
15
|
+
import { DurationLike } from "alepha/datetime";
|
|
16
|
+
import * as _sinclair_typebox38 from "@sinclair/typebox";
|
|
17
|
+
import * as _sinclair_typebox64 from "@sinclair/typebox";
|
|
18
|
+
import * as _sinclair_typebox30 from "@sinclair/typebox";
|
|
19
|
+
import * as http20 from "http";
|
|
24
20
|
|
|
25
21
|
//#region src/constants/routeMethods.d.ts
|
|
26
22
|
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
27
23
|
type RouteMethod = (typeof routeMethods)[number];
|
|
24
|
+
//# sourceMappingURL=routeMethods.d.ts.map
|
|
28
25
|
//#endregion
|
|
29
26
|
//#region src/helpers/ServerReply.d.ts
|
|
30
27
|
declare class ServerReply {
|
|
@@ -37,6 +34,7 @@ declare class ServerReply {
|
|
|
37
34
|
setStatus(status: number): void;
|
|
38
35
|
setHeader(name: string, value: string): void;
|
|
39
36
|
}
|
|
37
|
+
//# sourceMappingURL=ServerReply.d.ts.map
|
|
40
38
|
//#endregion
|
|
41
39
|
//#region src/interfaces/index.d.ts
|
|
42
40
|
interface RequestConfigSchema {
|
|
@@ -111,6 +109,7 @@ type ServerRouteSecure = boolean | {
|
|
|
111
109
|
realms?: string[];
|
|
112
110
|
organizations?: string[];
|
|
113
111
|
};
|
|
112
|
+
//# sourceMappingURL=index.d.ts.map
|
|
114
113
|
//#endregion
|
|
115
114
|
//#region src/helpers/ActionDescriptorHelper.d.ts
|
|
116
115
|
declare class ActionDescriptorHelper {
|
|
@@ -129,6 +128,7 @@ declare class ActionDescriptorHelper {
|
|
|
129
128
|
protected short(name: string): string;
|
|
130
129
|
fetchLinks(_url: string): void;
|
|
131
130
|
}
|
|
131
|
+
//# sourceMappingURL=ActionDescriptorHelper.d.ts.map
|
|
132
132
|
//#endregion
|
|
133
133
|
//#region src/services/HttpClient.d.ts
|
|
134
134
|
declare class HttpClient {
|
|
@@ -205,6 +205,10 @@ interface HttpAction {
|
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region src/descriptors/$action.d.ts
|
|
207
207
|
declare const KEY$1 = "ACTION";
|
|
208
|
+
declare const $action: {
|
|
209
|
+
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
|
|
210
|
+
[KIND]: string;
|
|
211
|
+
};
|
|
208
212
|
interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema"> {
|
|
209
213
|
/**
|
|
210
214
|
* Name the route.
|
|
@@ -271,7 +275,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestC
|
|
|
271
275
|
handler?: ServerHandler<TConfig>;
|
|
272
276
|
}
|
|
273
277
|
interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
274
|
-
[KIND
|
|
278
|
+
[KIND]: typeof KEY$1;
|
|
275
279
|
[OPTIONS]: ActionDescriptorOptions<TConfig>;
|
|
276
280
|
/**
|
|
277
281
|
* Fetch or just call local route when available.
|
|
@@ -286,10 +290,6 @@ interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSc
|
|
|
286
290
|
*/
|
|
287
291
|
permission: () => string;
|
|
288
292
|
}
|
|
289
|
-
declare const $action: {
|
|
290
|
-
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
|
|
291
|
-
[KIND$1]: string;
|
|
292
|
-
};
|
|
293
293
|
type ClientRequestEntry<TConfig extends RequestConfigSchema = RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
294
294
|
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema = RequestConfigSchema> = {
|
|
295
295
|
body: TConfig["body"] extends TSchema ? Static<TConfig["body"]> : undefined;
|
|
@@ -350,48 +350,101 @@ declare const isHttpError: (error: unknown) => error is HttpErrorLike;
|
|
|
350
350
|
interface HttpErrorLike extends Error {
|
|
351
351
|
status: number;
|
|
352
352
|
}
|
|
353
|
+
//# sourceMappingURL=HttpError.d.ts.map
|
|
353
354
|
//#endregion
|
|
354
355
|
//#region src/descriptors/$route.d.ts
|
|
355
356
|
declare const KEY = "ROUTE";
|
|
357
|
+
declare const $route: {
|
|
358
|
+
<TConfig extends RequestConfigSchema = RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
|
|
359
|
+
[KIND]: string;
|
|
360
|
+
};
|
|
356
361
|
interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {}
|
|
357
362
|
type RouteDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> = {
|
|
358
|
-
[KIND
|
|
363
|
+
[KIND]: typeof KEY;
|
|
359
364
|
[OPTIONS]: RouteDescriptorOptions<TConfig>;
|
|
360
365
|
};
|
|
361
|
-
declare const $route: {
|
|
362
|
-
<TConfig extends RequestConfigSchema = RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
|
|
363
|
-
[KIND$1]: string;
|
|
364
|
-
};
|
|
365
366
|
//#endregion
|
|
366
367
|
//#region src/errors/BadRequestError.d.ts
|
|
367
368
|
declare class BadRequestError extends HttpError {
|
|
368
369
|
constructor(message?: string, cause?: unknown);
|
|
369
370
|
}
|
|
371
|
+
//# sourceMappingURL=BadRequestError.d.ts.map
|
|
370
372
|
//#endregion
|
|
371
373
|
//#region src/errors/ConflictError.d.ts
|
|
372
374
|
declare class ConflictError extends HttpError {
|
|
373
375
|
constructor(message?: string, cause?: unknown);
|
|
374
376
|
}
|
|
377
|
+
//# sourceMappingURL=ConflictError.d.ts.map
|
|
375
378
|
//#endregion
|
|
376
379
|
//#region src/errors/ForbiddenError.d.ts
|
|
377
380
|
declare class ForbiddenError extends HttpError {
|
|
378
381
|
constructor(message?: string, cause?: unknown);
|
|
379
382
|
}
|
|
383
|
+
//# sourceMappingURL=ForbiddenError.d.ts.map
|
|
380
384
|
//#endregion
|
|
381
385
|
//#region src/errors/NotFoundError.d.ts
|
|
382
386
|
declare class NotFoundError extends HttpError {
|
|
383
387
|
constructor(message?: string, cause?: unknown);
|
|
384
388
|
}
|
|
389
|
+
//# sourceMappingURL=NotFoundError.d.ts.map
|
|
385
390
|
//#endregion
|
|
386
391
|
//#region src/errors/UnauthorizedError.d.ts
|
|
387
392
|
declare class UnauthorizedError extends HttpError {
|
|
388
393
|
constructor(message?: string, cause?: unknown);
|
|
389
394
|
}
|
|
395
|
+
//# sourceMappingURL=UnauthorizedError.d.ts.map
|
|
390
396
|
//#endregion
|
|
391
397
|
//#region src/errors/ValidationError.d.ts
|
|
392
398
|
declare class ValidationError extends HttpError {
|
|
393
399
|
constructor(message?: string, cause?: unknown);
|
|
394
400
|
}
|
|
401
|
+
//# sourceMappingURL=ValidationError.d.ts.map
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
404
|
+
declare const apiLinkSchema: _sinclair_typebox38.TObject<{
|
|
405
|
+
name: _sinclair_typebox38.TString;
|
|
406
|
+
path: _sinclair_typebox38.TString;
|
|
407
|
+
method: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
408
|
+
group: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
409
|
+
requestBodyType: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
410
|
+
service: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
411
|
+
}>;
|
|
412
|
+
declare const apiLinksResponseSchema: _sinclair_typebox38.TObject<{
|
|
413
|
+
prefix: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
414
|
+
links: _sinclair_typebox38.TArray<_sinclair_typebox38.TObject<{
|
|
415
|
+
name: _sinclair_typebox38.TString;
|
|
416
|
+
path: _sinclair_typebox38.TString;
|
|
417
|
+
method: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
418
|
+
group: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
419
|
+
requestBodyType: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
420
|
+
service: _sinclair_typebox38.TOptional<_sinclair_typebox38.TString>;
|
|
421
|
+
}>>;
|
|
422
|
+
}>;
|
|
423
|
+
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
424
|
+
type ApiLink = Static<typeof apiLinkSchema>;
|
|
425
|
+
//# sourceMappingURL=apiLinksResponseSchema.d.ts.map
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/schemas/errorSchema.d.ts
|
|
428
|
+
declare const errorSchema: _sinclair_typebox64.TObject<{
|
|
429
|
+
error: _sinclair_typebox64.TString;
|
|
430
|
+
status: _sinclair_typebox64.TNumber;
|
|
431
|
+
message: _sinclair_typebox64.TString;
|
|
432
|
+
details: _sinclair_typebox64.TOptional<_sinclair_typebox64.TString>;
|
|
433
|
+
cause: _sinclair_typebox64.TOptional<_sinclair_typebox64.TObject<{
|
|
434
|
+
name: _sinclair_typebox64.TString;
|
|
435
|
+
message: _sinclair_typebox64.TString;
|
|
436
|
+
}>>;
|
|
437
|
+
}>;
|
|
438
|
+
//# sourceMappingURL=errorSchema.d.ts.map
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/schemas/okSchema.d.ts
|
|
441
|
+
declare const okSchema: _sinclair_typebox30.TObject<{
|
|
442
|
+
ok: _sinclair_typebox30.TBoolean;
|
|
443
|
+
id: _sinclair_typebox30.TOptional<_sinclair_typebox30.TUnion<[_sinclair_typebox30.TString, _sinclair_typebox30.TInteger]>>;
|
|
444
|
+
count: _sinclair_typebox30.TOptional<_sinclair_typebox30.TNumber>;
|
|
445
|
+
}>;
|
|
446
|
+
type Ok = Static<typeof okSchema>;
|
|
447
|
+
//# sourceMappingURL=okSchema.d.ts.map
|
|
395
448
|
//#endregion
|
|
396
449
|
//#region src/providers/features/ServerLoggerProvider.d.ts
|
|
397
450
|
declare class ServerLoggerProvider {
|
|
@@ -401,31 +454,7 @@ declare class ServerLoggerProvider {
|
|
|
401
454
|
readonly onError: _alepha_core3.HookDescriptor<"server:onError">;
|
|
402
455
|
readonly onResponse: _alepha_core3.HookDescriptor<"server:onResponse">;
|
|
403
456
|
}
|
|
404
|
-
//#
|
|
405
|
-
//#region src/providers/features/ServerMultipartProvider.d.ts
|
|
406
|
-
declare class ServerMultipartProvider {
|
|
407
|
-
protected readonly helper: ActionDescriptorHelper;
|
|
408
|
-
protected readonly alepha: Alepha;
|
|
409
|
-
readonly onRequest: _alepha_core7.HookDescriptor<"server:onRequest">;
|
|
410
|
-
readonly onSend: _alepha_core7.HookDescriptor<"server:onResponse">;
|
|
411
|
-
handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
|
|
412
|
-
body: Record<string, any>;
|
|
413
|
-
cleanup: () => Promise<void>;
|
|
414
|
-
}>;
|
|
415
|
-
parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
|
|
416
|
-
}
|
|
417
|
-
interface MultipartResult {
|
|
418
|
-
fields: Record<string, string | string[]>;
|
|
419
|
-
files: Record<string, HybridFile>;
|
|
420
|
-
}
|
|
421
|
-
interface HybridFile extends FileLike {
|
|
422
|
-
cleanup(): Promise<void>;
|
|
423
|
-
_state: {
|
|
424
|
-
cleanup: boolean;
|
|
425
|
-
size: number;
|
|
426
|
-
tmpPath: string;
|
|
427
|
-
};
|
|
428
|
-
}
|
|
457
|
+
//# sourceMappingURL=ServerLoggerProvider.d.ts.map
|
|
429
458
|
//#endregion
|
|
430
459
|
//#region src/providers/features/ServerNotReadyProvider.d.ts
|
|
431
460
|
/**
|
|
@@ -437,27 +466,29 @@ interface HybridFile extends FileLike {
|
|
|
437
466
|
*/
|
|
438
467
|
declare class ServerNotReadyProvider {
|
|
439
468
|
protected readonly alepha: Alepha;
|
|
440
|
-
readonly onRequest:
|
|
469
|
+
readonly onRequest: _alepha_core7.HookDescriptor<"server:onRequest">;
|
|
441
470
|
}
|
|
471
|
+
//# sourceMappingURL=ServerNotReadyProvider.d.ts.map
|
|
442
472
|
//#endregion
|
|
443
473
|
//#region src/providers/features/ServerSecurityProvider.d.ts
|
|
444
474
|
declare class ServerSecurityProvider {
|
|
445
|
-
protected readonly log:
|
|
475
|
+
protected readonly log: _alepha_core8.Logger;
|
|
446
476
|
protected readonly securityProvider: SecurityProvider;
|
|
447
477
|
protected readonly jwtProvider: JwtProvider;
|
|
448
478
|
protected readonly alepha: Alepha;
|
|
449
|
-
readonly onClientRequest:
|
|
450
|
-
protected readonly onRequest:
|
|
451
|
-
protected readonly onRoute:
|
|
479
|
+
readonly onClientRequest: _alepha_core8.HookDescriptor<"client:onRequest">;
|
|
480
|
+
protected readonly onRequest: _alepha_core8.HookDescriptor<"server:onRequest">;
|
|
481
|
+
protected readonly onRoute: _alepha_core8.HookDescriptor<"server:onRoute">;
|
|
452
482
|
}
|
|
483
|
+
//# sourceMappingURL=ServerSecurityProvider.d.ts.map
|
|
453
484
|
//#endregion
|
|
454
485
|
//#region src/providers/features/ServerTimingProvider.d.ts
|
|
455
486
|
type TimingMap = Record<string, [number, number]>;
|
|
456
487
|
declare class ServerTimingProvider {
|
|
457
|
-
protected readonly log:
|
|
488
|
+
protected readonly log: _alepha_core12.Logger;
|
|
458
489
|
protected readonly alepha: Alepha;
|
|
459
|
-
readonly onRequest:
|
|
460
|
-
readonly onResponse:
|
|
490
|
+
readonly onRequest: _alepha_core12.HookDescriptor<"server:onRequest">;
|
|
491
|
+
readonly onResponse: _alepha_core12.HookDescriptor<"server:onResponse">;
|
|
461
492
|
protected get handlerName(): string;
|
|
462
493
|
beginTiming(name: string): void;
|
|
463
494
|
endTiming(name: string): void;
|
|
@@ -491,22 +522,25 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler
|
|
|
491
522
|
}, request: ServerRequestConfig): void;
|
|
492
523
|
serializeResponse(route: ServerRoute, reply: ServerReply, responseKind: ResponseKind): void;
|
|
493
524
|
}
|
|
525
|
+
//# sourceMappingURL=ServerRouterProvider.d.ts.map
|
|
494
526
|
//#endregion
|
|
495
527
|
//#region src/providers/platforms/ServerProvider.d.ts
|
|
496
|
-
declare class ServerProvider {
|
|
497
|
-
|
|
498
|
-
get hostname(): string;
|
|
528
|
+
declare abstract class ServerProvider {
|
|
529
|
+
protected readonly alepha: Alepha;
|
|
530
|
+
abstract get hostname(): string;
|
|
531
|
+
protected isViteNotFound(url?: string, route?: Route, params?: Record<string, string>): boolean;
|
|
499
532
|
}
|
|
533
|
+
//# sourceMappingURL=ServerProvider.d.ts.map
|
|
500
534
|
//#endregion
|
|
501
535
|
//#region src/providers/platforms/NodeHttpServerProvider.d.ts
|
|
502
536
|
declare const envSchema$1: _alepha_core15.TObject<{
|
|
503
|
-
SERVER_PORT:
|
|
504
|
-
SERVER_HOST:
|
|
537
|
+
SERVER_PORT: _alepha_core15.TNumber;
|
|
538
|
+
SERVER_HOST: _alepha_core15.TString;
|
|
505
539
|
}>;
|
|
506
540
|
declare module "alepha" {
|
|
507
541
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
508
542
|
}
|
|
509
|
-
declare class NodeHttpServerProvider
|
|
543
|
+
declare class NodeHttpServerProvider extends ServerProvider {
|
|
510
544
|
protected readonly alepha: Alepha;
|
|
511
545
|
protected readonly log: _alepha_core15.Logger;
|
|
512
546
|
protected readonly env: {
|
|
@@ -514,11 +548,11 @@ declare class NodeHttpServerProvider implements ServerProvider {
|
|
|
514
548
|
SERVER_HOST: string;
|
|
515
549
|
};
|
|
516
550
|
protected readonly router: ServerRouterProvider;
|
|
517
|
-
protected readonly server:
|
|
518
|
-
|
|
551
|
+
protected readonly server: http20.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
552
|
+
protected readonly onNodeRequest: _alepha_core15.HookDescriptor<"node:request">;
|
|
553
|
+
handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
|
|
519
554
|
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
520
555
|
getProtocol(req: IncomingMessage): "http" | "https";
|
|
521
|
-
shouldHaveBody(method: string): boolean;
|
|
522
556
|
get hostname(): string;
|
|
523
557
|
readonly start: _alepha_core15.HookDescriptor<"start">;
|
|
524
558
|
protected readonly stop: _alepha_core15.HookDescriptor<"stop">;
|
|
@@ -526,35 +560,12 @@ declare class NodeHttpServerProvider implements ServerProvider {
|
|
|
526
560
|
protected close(): Promise<void>;
|
|
527
561
|
}
|
|
528
562
|
//#endregion
|
|
529
|
-
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
530
|
-
declare const apiLinkSchema: _sinclair_typebox37.TObject<{
|
|
531
|
-
name: _sinclair_typebox37.TString;
|
|
532
|
-
path: _sinclair_typebox37.TString;
|
|
533
|
-
method: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
534
|
-
group: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
535
|
-
requestBodyType: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
536
|
-
service: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
537
|
-
}>;
|
|
538
|
-
declare const apiLinksResponseSchema: _sinclair_typebox37.TObject<{
|
|
539
|
-
prefix: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
540
|
-
links: _sinclair_typebox37.TArray<_sinclair_typebox37.TObject<{
|
|
541
|
-
name: _sinclair_typebox37.TString;
|
|
542
|
-
path: _sinclair_typebox37.TString;
|
|
543
|
-
method: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
544
|
-
group: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
545
|
-
requestBodyType: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
546
|
-
service: _sinclair_typebox37.TOptional<_sinclair_typebox37.TString>;
|
|
547
|
-
}>>;
|
|
548
|
-
}>;
|
|
549
|
-
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
550
|
-
type ApiLink = Static<typeof apiLinkSchema>;
|
|
551
|
-
//#endregion
|
|
552
563
|
//#region src/providers/ServerActionDescriptorProvider.d.ts
|
|
553
|
-
declare const envSchema:
|
|
554
|
-
SERVER_API_PREFIX:
|
|
555
|
-
SERVER_SECURITY_ENABLED:
|
|
564
|
+
declare const envSchema: _alepha_core24.TObject<{
|
|
565
|
+
SERVER_API_PREFIX: _alepha_core24.TString;
|
|
566
|
+
SERVER_SECURITY_ENABLED: _alepha_core24.TBoolean;
|
|
556
567
|
}>;
|
|
557
|
-
declare module "alepha
|
|
568
|
+
declare module "alepha" {
|
|
558
569
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
559
570
|
interface State {
|
|
560
571
|
/**
|
|
@@ -566,7 +577,7 @@ declare module "alepha/core" {
|
|
|
566
577
|
}
|
|
567
578
|
}
|
|
568
579
|
declare class ServerActionDescriptorProvider {
|
|
569
|
-
protected readonly log:
|
|
580
|
+
protected readonly log: _alepha_core24.Logger;
|
|
570
581
|
protected readonly alepha: Alepha;
|
|
571
582
|
protected readonly env: {
|
|
572
583
|
SERVER_API_PREFIX: string;
|
|
@@ -579,7 +590,7 @@ declare class ServerActionDescriptorProvider {
|
|
|
579
590
|
protected readonly actions: ServerRouteAction[];
|
|
580
591
|
getActions(): ServerRouteAction<RequestConfigSchema>[];
|
|
581
592
|
getPrefix(): string;
|
|
582
|
-
readonly configure:
|
|
593
|
+
readonly configure: _alepha_core24.HookDescriptor<"configure">;
|
|
583
594
|
registerAction(value: ActionDescriptor, key: string, instance: any, prefix?: string): Promise<void>;
|
|
584
595
|
/**
|
|
585
596
|
* Check a mock function for the specified route.
|
|
@@ -622,29 +633,13 @@ interface ServerRouteAction<TConfig extends RequestConfigSchema = RequestConfigS
|
|
|
622
633
|
}
|
|
623
634
|
type LocalHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (config?: ServerRequestConfigEntry<TConfig>, options?: ClientRequestOptions) => Promise<any>;
|
|
624
635
|
//#endregion
|
|
625
|
-
//#region src/schemas/errorSchema.d.ts
|
|
626
|
-
declare const errorSchema: _sinclair_typebox27.TObject<{
|
|
627
|
-
error: _sinclair_typebox27.TString;
|
|
628
|
-
status: _sinclair_typebox27.TNumber;
|
|
629
|
-
message: _sinclair_typebox27.TString;
|
|
630
|
-
details: _sinclair_typebox27.TOptional<_sinclair_typebox27.TString>;
|
|
631
|
-
cause: _sinclair_typebox27.TOptional<_sinclair_typebox27.TObject<{
|
|
632
|
-
name: _sinclair_typebox27.TString;
|
|
633
|
-
message: _sinclair_typebox27.TString;
|
|
634
|
-
}>>;
|
|
635
|
-
}>;
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region src/schemas/okSchema.d.ts
|
|
638
|
-
declare const okSchema: _sinclair_typebox63.TObject<{
|
|
639
|
-
ok: _sinclair_typebox63.TBoolean;
|
|
640
|
-
id: _sinclair_typebox63.TOptional<_sinclair_typebox63.TUnion<[_sinclair_typebox63.TString, _sinclair_typebox63.TInteger]>>;
|
|
641
|
-
count: _sinclair_typebox63.TOptional<_sinclair_typebox63.TNumber>;
|
|
642
|
-
}>;
|
|
643
|
-
type Ok = Static<typeof okSchema>;
|
|
644
|
-
//#endregion
|
|
645
636
|
//#region src/index.d.ts
|
|
646
|
-
declare module "
|
|
637
|
+
declare module "alepha" {
|
|
647
638
|
interface Hooks {
|
|
639
|
+
"node:request": {
|
|
640
|
+
req: IncomingMessage;
|
|
641
|
+
res: ServerResponse$1;
|
|
642
|
+
};
|
|
648
643
|
"server:onRoute": {
|
|
649
644
|
route: ServerRoute;
|
|
650
645
|
};
|
|
@@ -684,10 +679,165 @@ declare module "@alepha/core" {
|
|
|
684
679
|
};
|
|
685
680
|
}
|
|
686
681
|
}
|
|
682
|
+
/**
|
|
683
|
+
* Provides high-performance HTTP server capabilities with declarative routing and action descriptors.
|
|
684
|
+
*
|
|
685
|
+
* The server module enables building REST APIs and web applications using `$route` and `$action` descriptors
|
|
686
|
+
* on class properties. It provides automatic request/response handling, schema validation, middleware support,
|
|
687
|
+
* and seamless integration with other Alepha modules for a complete backend solution.
|
|
688
|
+
*
|
|
689
|
+
* **Key Features:**
|
|
690
|
+
* - Declarative route definition with `$route` descriptor
|
|
691
|
+
* - API action handlers with `$action` descriptor
|
|
692
|
+
* - Schema validation for requests and responses
|
|
693
|
+
* - Automatic body parsing and response formatting
|
|
694
|
+
* - Built-in middleware system and error handling
|
|
695
|
+
* - Type-safe request parameters and response data
|
|
696
|
+
* - Integration with authentication and security modules
|
|
697
|
+
*
|
|
698
|
+
* **Basic Routing:**
|
|
699
|
+
* ```ts
|
|
700
|
+
* import { Alepha, run, t } from "alepha";
|
|
701
|
+
* import { AlephaServer, $route } from "alepha/server";
|
|
702
|
+
*
|
|
703
|
+
* class ApiRoutes {
|
|
704
|
+
* // Simple GET route
|
|
705
|
+
* getUsers = $route({
|
|
706
|
+
* path: "/api/users",
|
|
707
|
+
* method: "GET",
|
|
708
|
+
* handler: async () => {
|
|
709
|
+
* const users = await getAllUsers();
|
|
710
|
+
* return Response.json(users);
|
|
711
|
+
* },
|
|
712
|
+
* });
|
|
713
|
+
*
|
|
714
|
+
* // POST route with body validation
|
|
715
|
+
* createUser = $route({
|
|
716
|
+
* path: "/api/users",
|
|
717
|
+
* method: "POST",
|
|
718
|
+
* schema: {
|
|
719
|
+
* body: t.object({
|
|
720
|
+
* name: t.string(),
|
|
721
|
+
* email: t.string(),
|
|
722
|
+
* }),
|
|
723
|
+
* },
|
|
724
|
+
* handler: async ({ body }) => {
|
|
725
|
+
* const user = await createUser(body);
|
|
726
|
+
* return Response.json(user, { status: 201 });
|
|
727
|
+
* },
|
|
728
|
+
* });
|
|
729
|
+
*
|
|
730
|
+
* // Dynamic route with parameters
|
|
731
|
+
* getUserById = $route({
|
|
732
|
+
* path: "/api/users/:id",
|
|
733
|
+
* method: "GET",
|
|
734
|
+
* schema: {
|
|
735
|
+
* params: t.object({
|
|
736
|
+
* id: t.string(),
|
|
737
|
+
* }),
|
|
738
|
+
* },
|
|
739
|
+
* handler: async ({ params }) => {
|
|
740
|
+
* const user = await findUserById(params.id);
|
|
741
|
+
* if (!user) {
|
|
742
|
+
* return new Response("User not found", { status: 404 });
|
|
743
|
+
* }
|
|
744
|
+
* return Response.json(user);
|
|
745
|
+
* },
|
|
746
|
+
* });
|
|
747
|
+
* }
|
|
748
|
+
*
|
|
749
|
+
* const alepha = Alepha.create()
|
|
750
|
+
* .with(AlephaServer)
|
|
751
|
+
* .with(ApiRoutes);
|
|
752
|
+
*
|
|
753
|
+
* run(alepha);
|
|
754
|
+
* ```
|
|
755
|
+
*
|
|
756
|
+
* **Action Descriptors:**
|
|
757
|
+
* ```ts
|
|
758
|
+
* import { $action } from "alepha/server";
|
|
759
|
+
*
|
|
760
|
+
* class UserController {
|
|
761
|
+
* // Reusable business logic action
|
|
762
|
+
* getUserProfile = $action({
|
|
763
|
+
* schema: {
|
|
764
|
+
* params: t.object({
|
|
765
|
+
* userId: t.string(),
|
|
766
|
+
* }),
|
|
767
|
+
* response: t.object({
|
|
768
|
+
* id: t.string(),
|
|
769
|
+
* name: t.string(),
|
|
770
|
+
* email: t.string(),
|
|
771
|
+
* }),
|
|
772
|
+
* },
|
|
773
|
+
* handler: async ({ params }) => {
|
|
774
|
+
* const user = await getUserById(params.userId);
|
|
775
|
+
* return {
|
|
776
|
+
* id: user.id,
|
|
777
|
+
* name: user.name,
|
|
778
|
+
* email: user.email,
|
|
779
|
+
* };
|
|
780
|
+
* },
|
|
781
|
+
* });
|
|
782
|
+
*
|
|
783
|
+
* // Route that uses the action
|
|
784
|
+
* profileRoute = $route({
|
|
785
|
+
* path: "/api/profile/:userId",
|
|
786
|
+
* method: "GET",
|
|
787
|
+
* handler: async ({ params }) => {
|
|
788
|
+
* const profile = await this.getUserProfile({ params });
|
|
789
|
+
* return Response.json(profile);
|
|
790
|
+
* },
|
|
791
|
+
* });
|
|
792
|
+
* }
|
|
793
|
+
* ```
|
|
794
|
+
*
|
|
795
|
+
* **Middleware and Error Handling:**
|
|
796
|
+
* ```ts
|
|
797
|
+
* class AppServer {
|
|
798
|
+
* // Global middleware
|
|
799
|
+
* middleware = $route({
|
|
800
|
+
* path: "*",
|
|
801
|
+
* method: "*",
|
|
802
|
+
* handler: async ({ request, next }) => {
|
|
803
|
+
* console.log(`${request.method} ${request.url}`);
|
|
804
|
+
* try {
|
|
805
|
+
* return await next();
|
|
806
|
+
* } catch (error) {
|
|
807
|
+
* console.error("Request failed:", error);
|
|
808
|
+
* return Response.json({ error: "Internal Server Error" }, { status: 500 });
|
|
809
|
+
* }
|
|
810
|
+
* },
|
|
811
|
+
* });
|
|
812
|
+
*
|
|
813
|
+
* // CORS preflight handling
|
|
814
|
+
* corsPrelight = $route({
|
|
815
|
+
* path: "*",
|
|
816
|
+
* method: "OPTIONS",
|
|
817
|
+
* handler: async () => {
|
|
818
|
+
* return new Response(null, {
|
|
819
|
+
* status: 200,
|
|
820
|
+
* headers: {
|
|
821
|
+
* "Access-Control-Allow-Origin": "*",
|
|
822
|
+
* "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
|
|
823
|
+
* "Access-Control-Allow-Headers": "Content-Type, Authorization",
|
|
824
|
+
* },
|
|
825
|
+
* });
|
|
826
|
+
* },
|
|
827
|
+
* });
|
|
828
|
+
* }
|
|
829
|
+
* ```
|
|
830
|
+
*
|
|
831
|
+
* @see {@link $route}
|
|
832
|
+
* @see {@link $action}
|
|
833
|
+
* @module alepha.server
|
|
834
|
+
*/
|
|
687
835
|
declare class AlephaServer implements Module {
|
|
688
836
|
readonly name = "alepha.server";
|
|
689
837
|
readonly $services: (alepha: Alepha) => void;
|
|
690
838
|
}
|
|
839
|
+
//# sourceMappingURL=index.d.ts.map
|
|
840
|
+
|
|
691
841
|
//#endregion
|
|
692
|
-
export { $action, $route, ActionDescriptor, ActionDescriptorHelper, ActionDescriptorOptions, AlephaServer, ApiLink, ApiLinksResponse, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike,
|
|
842
|
+
export { $action, $route, ActionDescriptor, ActionDescriptorHelper, ActionDescriptorOptions, AlephaServer, ApiLink, ApiLinksResponse, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, LocalHandler, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionDescriptorProvider, ServerHandler, ServerLoggerProvider, ServerMiddlewareHandler, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerRemote, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteAction, ServerRouteSecure, ServerRouteWithHandler, ServerRouterProvider, ServerSecurityProvider, ServerTimingProvider, UnauthorizedError, ValidationError, apiLinkSchema, apiLinksResponseSchema, errorNameByStatus, errorSchema, isHttpError, isServerAction, okSchema, routeMethods };
|
|
693
843
|
//# sourceMappingURL=index.d.ts.map
|
package/topic/redis.d.ts
CHANGED
|
@@ -1,42 +1,41 @@
|
|
|
1
|
-
import { SubscribeCallback, TopicProvider, UnSubscribeFn } from "
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { RedisProvider, RedisSubscriberProvider } from "@alepha/redis";
|
|
1
|
+
import { SubscribeCallback, TopicProvider, UnSubscribeFn } from "alepha/topic";
|
|
2
|
+
import { Alepha, HookDescriptor, Logger, Module, Static, TObject, TString } from "alepha";
|
|
3
|
+
import { RedisProvider, RedisSubscriberProvider } from "alepha/redis";
|
|
5
4
|
|
|
6
5
|
//#region src/providers/RedisTopicProvider.d.ts
|
|
6
|
+
declare const envSchema: TObject<{
|
|
7
|
+
REDIS_TOPIC_PREFIX: TString;
|
|
8
|
+
}>;
|
|
7
9
|
declare class RedisTopicProvider implements TopicProvider {
|
|
8
|
-
protected readonly env:
|
|
9
|
-
REDIS_TOPIC_PREFIX: string;
|
|
10
|
-
};
|
|
10
|
+
protected readonly env: Static<typeof envSchema>;
|
|
11
11
|
protected readonly redisProvider: RedisProvider;
|
|
12
12
|
protected readonly redisSubscriberProvider: RedisSubscriberProvider;
|
|
13
|
-
protected readonly log:
|
|
14
|
-
protected readonly stop:
|
|
13
|
+
protected readonly log: Logger;
|
|
14
|
+
protected readonly stop: HookDescriptor<"stop">;
|
|
15
15
|
prefix(queue: string): string;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Publish a message to a topic.
|
|
18
|
+
*/
|
|
19
19
|
publish(topic: string, message: string): Promise<void>;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* Subscribe to a topic.
|
|
22
|
+
*/
|
|
23
23
|
subscribe(name: string, callback: SubscribeCallback): Promise<UnSubscribeFn>;
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
* Unsubscribe from a topic.
|
|
26
|
+
*/
|
|
27
27
|
unsubscribe(name: string, callback?: SubscribeCallback): Promise<void>;
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/index.d.ts
|
|
31
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
31
32
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
39
|
-
declare class AlephaTopicRedis {
|
|
33
|
+
* Plugin for Alepha Topic that provides Redis pub/sub capabilities.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link RedisTopicProvider}
|
|
36
|
+
* @module alepha.topic.redis
|
|
37
|
+
*/
|
|
38
|
+
declare class AlephaTopicRedis implements Module {
|
|
40
39
|
readonly name = "alepha.topic.redis";
|
|
41
40
|
readonly $services: (alepha: Alepha) => Alepha;
|
|
42
41
|
}
|