alepha 0.9.5 → 0.10.0
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/README.md +0 -46
- package/batch.d.ts +2 -3
- package/bucket.d.ts +7 -7
- package/command.d.ts +30 -8
- package/core.d.ts +374 -329
- package/email.d.ts +105 -23
- package/logger.d.ts +45 -12
- package/package.json +56 -45
- package/postgres.d.ts +95 -131
- package/queue/redis.d.ts +3 -3
- package/queue.d.ts +105 -171
- package/react/auth.d.ts +99 -107
- package/react/form.d.ts +4 -1
- package/react/i18n.d.ts +8 -3
- package/react.d.ts +100 -7
- package/redis.d.ts +5 -5
- package/security.d.ts +24 -24
- package/server/cache.d.ts +1 -0
- package/server/health.d.ts +6 -6
- package/server/links.d.ts +29 -29
- package/server.d.ts +58 -73
- package/topic.d.ts +0 -1
- package/vite.d.ts +24 -0
package/server.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Alepha, AlephaError, Async, Descriptor, FileLike, KIND, Static, StreamLike, TObject, TSchema } from "alepha";
|
|
3
|
-
import * as
|
|
1
|
+
import * as _alepha_core11 from "alepha";
|
|
2
|
+
import { Alepha, AlephaError, Async, Descriptor, FileLike, KIND, Static, StreamLike, TArray, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
3
|
+
import * as _alepha_logger3 from "alepha/logger";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { ReadableStream } from "node:stream/web";
|
|
6
6
|
import { Route, RouterProvider } from "alepha/router";
|
|
7
7
|
import * as _alepha_cache0 from "alepha/cache";
|
|
8
8
|
import { IncomingMessage, ServerResponse as ServerResponse$1 } from "node:http";
|
|
9
9
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
10
|
-
import * as
|
|
10
|
+
import * as typebox0 from "typebox";
|
|
11
11
|
import * as http0 from "http";
|
|
12
12
|
|
|
13
13
|
//#region src/constants/routeMethods.d.ts
|
|
@@ -59,15 +59,17 @@ declare class UserAgentParser {
|
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region src/interfaces/ServerRequest.d.ts
|
|
62
|
+
type TRequestBody = TObject | TString | TArray | TRecord | TStream;
|
|
63
|
+
type TResponseBody = TObject | TString | TRecord | TFile | TArray | TStream | TVoid;
|
|
62
64
|
interface RequestConfigSchema {
|
|
63
|
-
body?:
|
|
65
|
+
body?: TRequestBody;
|
|
64
66
|
params?: TObject;
|
|
65
67
|
query?: TObject;
|
|
66
68
|
headers?: TObject;
|
|
67
|
-
response?:
|
|
69
|
+
response?: TResponseBody;
|
|
68
70
|
}
|
|
69
71
|
interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
70
|
-
body: TConfig["body"] extends
|
|
72
|
+
body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
|
|
71
73
|
headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
|
|
72
74
|
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
|
|
73
75
|
query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, string>;
|
|
@@ -127,11 +129,10 @@ interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema>
|
|
|
127
129
|
*/
|
|
128
130
|
silent?: boolean;
|
|
129
131
|
}
|
|
130
|
-
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends
|
|
132
|
+
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
|
|
131
133
|
type ResponseKind = "json" | "text" | "void" | "file" | "any";
|
|
132
134
|
type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
|
|
133
135
|
type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
134
|
-
type ServerMiddlewareHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig> | undefined>;
|
|
135
136
|
interface ServerResponse {
|
|
136
137
|
body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
|
|
137
138
|
headers: Record<string, string>;
|
|
@@ -175,13 +176,13 @@ declare class ServerRequestParser {
|
|
|
175
176
|
//#region src/providers/ServerTimingProvider.d.ts
|
|
176
177
|
type TimingMap = Record<string, [number, number]>;
|
|
177
178
|
declare class ServerTimingProvider {
|
|
178
|
-
protected readonly log:
|
|
179
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
179
180
|
protected readonly alepha: Alepha;
|
|
180
181
|
options: {
|
|
181
182
|
disabled: boolean;
|
|
182
183
|
};
|
|
183
|
-
readonly onRequest:
|
|
184
|
-
readonly onResponse:
|
|
184
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
185
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
185
186
|
protected get handlerName(): string;
|
|
186
187
|
beginTiming(name: string): void;
|
|
187
188
|
endTiming(name: string): void;
|
|
@@ -221,16 +222,14 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
|
|
|
221
222
|
//#endregion
|
|
222
223
|
//#region src/services/HttpClient.d.ts
|
|
223
224
|
declare class HttpClient {
|
|
224
|
-
protected readonly log:
|
|
225
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
225
226
|
protected readonly alepha: Alepha;
|
|
226
227
|
readonly cache: _alepha_cache0.CacheDescriptorFn<HttpClientCache, any[]>;
|
|
227
228
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
228
|
-
clear(): Promise<void>;
|
|
229
229
|
fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
|
|
230
230
|
fetch<T>(url: string, request?: RequestInit,
|
|
231
231
|
// standard options
|
|
232
232
|
options?: FetchOptions): Promise<FetchResponse<T>>;
|
|
233
|
-
json<T = any>(url: string, options?: RequestInit): Promise<T>;
|
|
234
233
|
protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
|
|
235
234
|
protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
|
|
236
235
|
protected responseData(response: Response, options: FetchOptions): Promise<any>;
|
|
@@ -287,8 +286,8 @@ interface HttpAction {
|
|
|
287
286
|
schema?: {
|
|
288
287
|
params?: TObject;
|
|
289
288
|
query?: TObject;
|
|
290
|
-
body?:
|
|
291
|
-
response?:
|
|
289
|
+
body?: TRequestBody;
|
|
290
|
+
response?: TResponseBody;
|
|
292
291
|
};
|
|
293
292
|
}
|
|
294
293
|
//#endregion
|
|
@@ -900,7 +899,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
|
|
|
900
899
|
handler: ServerActionHandler<TConfig>;
|
|
901
900
|
}
|
|
902
901
|
declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
|
|
903
|
-
protected readonly log:
|
|
902
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
904
903
|
protected readonly env: {
|
|
905
904
|
SERVER_API_PREFIX: string;
|
|
906
905
|
};
|
|
@@ -934,7 +933,7 @@ declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Desc
|
|
|
934
933
|
* Call the action handler directly.
|
|
935
934
|
* There is no HTTP layer involved.
|
|
936
935
|
*/
|
|
937
|
-
run(config
|
|
936
|
+
run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
|
|
938
937
|
/**
|
|
939
938
|
* Works like `run`, but always fetches (http request) the route.
|
|
940
939
|
*/
|
|
@@ -967,40 +966,35 @@ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSche
|
|
|
967
966
|
*/
|
|
968
967
|
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
969
968
|
//#endregion
|
|
969
|
+
//#region src/schemas/errorSchema.d.ts
|
|
970
|
+
declare const errorSchema: typebox0.TObject<{
|
|
971
|
+
error: typebox0.TString;
|
|
972
|
+
status: typebox0.TInteger;
|
|
973
|
+
message: typebox0.TString;
|
|
974
|
+
details: typebox0.TOptional<typebox0.TString>;
|
|
975
|
+
requestId: typebox0.TOptional<typebox0.TString>;
|
|
976
|
+
cause: typebox0.TOptional<typebox0.TObject<{
|
|
977
|
+
name: typebox0.TString;
|
|
978
|
+
message: typebox0.TString;
|
|
979
|
+
}>>;
|
|
980
|
+
}>;
|
|
981
|
+
type ErrorSchema = Static<typeof errorSchema>;
|
|
982
|
+
//#endregion
|
|
970
983
|
//#region src/errors/HttpError.d.ts
|
|
971
984
|
declare const isHttpError: (error: unknown, status?: number) => error is HttpErrorLike;
|
|
972
985
|
declare class HttpError extends AlephaError {
|
|
973
986
|
name: string;
|
|
974
987
|
static is: (error: unknown, status?: number) => error is HttpErrorLike;
|
|
975
|
-
static toJSON(error: HttpError):
|
|
976
|
-
|
|
977
|
-
error: string | undefined;
|
|
978
|
-
message: string;
|
|
979
|
-
cause: {
|
|
980
|
-
name: string;
|
|
981
|
-
message: string;
|
|
982
|
-
};
|
|
983
|
-
} | {
|
|
984
|
-
status: number;
|
|
985
|
-
error: string | undefined;
|
|
986
|
-
message: string;
|
|
987
|
-
cause?: undefined;
|
|
988
|
-
};
|
|
988
|
+
static toJSON(error: HttpError): ErrorSchema;
|
|
989
|
+
readonly error: string;
|
|
989
990
|
readonly status: number;
|
|
990
|
-
readonly
|
|
991
|
+
readonly requestId?: string;
|
|
992
|
+
readonly details?: string;
|
|
991
993
|
readonly reason?: {
|
|
992
994
|
name: string;
|
|
993
995
|
message: string;
|
|
994
996
|
};
|
|
995
|
-
constructor(options:
|
|
996
|
-
error?: string;
|
|
997
|
-
message: string;
|
|
998
|
-
status: number;
|
|
999
|
-
cause?: {
|
|
1000
|
-
name: string;
|
|
1001
|
-
message: string;
|
|
1002
|
-
} | unknown;
|
|
1003
|
-
}, cause?: unknown);
|
|
997
|
+
constructor(options: Partial<ErrorSchema>, cause?: unknown);
|
|
1004
998
|
}
|
|
1005
999
|
declare const errorNameByStatus: Record<number, string>;
|
|
1006
1000
|
interface HttpErrorLike extends Error {
|
|
@@ -1057,35 +1051,26 @@ declare class ValidationError extends HttpError {
|
|
|
1057
1051
|
}
|
|
1058
1052
|
//#endregion
|
|
1059
1053
|
//#region src/helpers/isMultipart.d.ts
|
|
1054
|
+
/**
|
|
1055
|
+
* Checks if the route has multipart/form-data request body.
|
|
1056
|
+
*/
|
|
1060
1057
|
declare const isMultipart: (options: {
|
|
1061
1058
|
schema?: RequestConfigSchema;
|
|
1062
1059
|
requestBodyType?: string;
|
|
1063
1060
|
}) => boolean;
|
|
1064
1061
|
//#endregion
|
|
1065
|
-
//#region src/schemas/errorSchema.d.ts
|
|
1066
|
-
declare const errorSchema: _sinclair_typebox0.TObject<{
|
|
1067
|
-
error: _sinclair_typebox0.TString;
|
|
1068
|
-
status: _sinclair_typebox0.TNumber;
|
|
1069
|
-
message: _sinclair_typebox0.TString;
|
|
1070
|
-
details: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
1071
|
-
cause: _sinclair_typebox0.TOptional<_sinclair_typebox0.TObject<{
|
|
1072
|
-
name: _sinclair_typebox0.TString;
|
|
1073
|
-
message: _sinclair_typebox0.TString;
|
|
1074
|
-
}>>;
|
|
1075
|
-
}>;
|
|
1076
|
-
//#endregion
|
|
1077
1062
|
//#region src/schemas/okSchema.d.ts
|
|
1078
|
-
declare const okSchema:
|
|
1079
|
-
ok:
|
|
1080
|
-
id:
|
|
1081
|
-
count:
|
|
1063
|
+
declare const okSchema: typebox0.TObject<{
|
|
1064
|
+
ok: typebox0.TBoolean;
|
|
1065
|
+
id: typebox0.TOptional<typebox0.TUnion<[typebox0.TString, typebox0.TInteger]>>;
|
|
1066
|
+
count: typebox0.TOptional<typebox0.TNumber>;
|
|
1082
1067
|
}>;
|
|
1083
1068
|
type Ok = Static<typeof okSchema>;
|
|
1084
1069
|
//#endregion
|
|
1085
1070
|
//#region src/providers/NodeHttpServerProvider.d.ts
|
|
1086
|
-
declare const envSchema:
|
|
1087
|
-
SERVER_PORT:
|
|
1088
|
-
SERVER_HOST:
|
|
1071
|
+
declare const envSchema: _alepha_core11.TObject<{
|
|
1072
|
+
SERVER_PORT: _alepha_core11.TInteger;
|
|
1073
|
+
SERVER_HOST: _alepha_core11.TString;
|
|
1089
1074
|
}>;
|
|
1090
1075
|
declare module "alepha" {
|
|
1091
1076
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -1093,31 +1078,31 @@ declare module "alepha" {
|
|
|
1093
1078
|
declare class NodeHttpServerProvider extends ServerProvider {
|
|
1094
1079
|
protected readonly alepha: Alepha;
|
|
1095
1080
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1096
|
-
protected readonly log:
|
|
1081
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
1097
1082
|
protected readonly env: {
|
|
1098
1083
|
SERVER_PORT: number;
|
|
1099
1084
|
SERVER_HOST: string;
|
|
1100
1085
|
};
|
|
1101
1086
|
protected readonly router: ServerRouterProvider;
|
|
1102
1087
|
protected readonly server: http0.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
1103
|
-
protected readonly onNodeRequest:
|
|
1088
|
+
protected readonly onNodeRequest: _alepha_core11.HookDescriptor<"node:request">;
|
|
1104
1089
|
handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
|
|
1105
1090
|
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
1106
1091
|
getProtocol(req: IncomingMessage): "http" | "https";
|
|
1107
1092
|
get hostname(): string;
|
|
1108
|
-
readonly start:
|
|
1109
|
-
protected readonly stop:
|
|
1093
|
+
readonly start: _alepha_core11.HookDescriptor<"start">;
|
|
1094
|
+
protected readonly stop: _alepha_core11.HookDescriptor<"stop">;
|
|
1110
1095
|
protected listen(): Promise<void>;
|
|
1111
1096
|
protected close(): Promise<void>;
|
|
1112
1097
|
}
|
|
1113
1098
|
//#endregion
|
|
1114
1099
|
//#region src/providers/ServerLoggerProvider.d.ts
|
|
1115
1100
|
declare class ServerLoggerProvider {
|
|
1116
|
-
protected readonly log:
|
|
1101
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
1117
1102
|
protected readonly alepha: Alepha;
|
|
1118
|
-
readonly onRequest:
|
|
1119
|
-
readonly onError:
|
|
1120
|
-
readonly onResponse:
|
|
1103
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
1104
|
+
readonly onError: _alepha_core11.HookDescriptor<"server:onError">;
|
|
1105
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
1121
1106
|
}
|
|
1122
1107
|
//#endregion
|
|
1123
1108
|
//#region src/providers/ServerNotReadyProvider.d.ts
|
|
@@ -1130,7 +1115,7 @@ declare class ServerLoggerProvider {
|
|
|
1130
1115
|
*/
|
|
1131
1116
|
declare class ServerNotReadyProvider {
|
|
1132
1117
|
protected readonly alepha: Alepha;
|
|
1133
|
-
readonly onRequest:
|
|
1118
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
1134
1119
|
}
|
|
1135
1120
|
//#endregion
|
|
1136
1121
|
//#region src/index.d.ts
|
|
@@ -1198,7 +1183,7 @@ declare module "alepha" {
|
|
|
1198
1183
|
* @see {@link $action}
|
|
1199
1184
|
* @module alepha.server
|
|
1200
1185
|
*/
|
|
1201
|
-
declare const AlephaServer:
|
|
1186
|
+
declare const AlephaServer: _alepha_core11.Service<_alepha_core11.Module>;
|
|
1202
1187
|
//#endregion
|
|
1203
|
-
export { $action, $route, ActionDescriptor, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionHandler, ServerActionRequest, ServerHandler, ServerLoggerProvider,
|
|
1188
|
+
export { $action, $route, ActionDescriptor, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, ErrorSchema, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionHandler, ServerActionRequest, ServerHandler, ServerLoggerProvider, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteMatcher, ServerRouteRequestHandler, ServerRouterProvider, ServerTimingProvider, TRequestBody, TResponseBody, UnauthorizedError, ValidationError, errorNameByStatus, errorSchema, isHttpError, isMultipart, okSchema, routeMethods };
|
|
1204
1189
|
//# sourceMappingURL=index.d.ts.map
|
package/topic.d.ts
CHANGED
|
@@ -480,7 +480,6 @@ interface TopicWaitOptions<T extends TopicMessageSchema> {
|
|
|
480
480
|
}) => boolean;
|
|
481
481
|
}
|
|
482
482
|
interface TopicMessageSchema {
|
|
483
|
-
headers?: TSchema;
|
|
484
483
|
payload: TSchema;
|
|
485
484
|
}
|
|
486
485
|
type TopicHandler<T extends TopicMessageSchema = TopicMessageSchema> = (message: TopicMessage<T>) => unknown;
|
package/vite.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ interface BuildClientOptions {
|
|
|
47
47
|
* @default false
|
|
48
48
|
*/
|
|
49
49
|
prerender?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Build a sitemap.xml file based on the $pages routes.
|
|
52
|
+
*/
|
|
53
|
+
sitemap?: {
|
|
54
|
+
hostname: string;
|
|
55
|
+
};
|
|
50
56
|
config?: UserConfig;
|
|
51
57
|
}
|
|
52
58
|
//#endregion
|
|
@@ -159,6 +165,24 @@ declare function viteAlepha(options?: ViteAlephaOptions): (Plugin | Promise<Plug
|
|
|
159
165
|
declare global {
|
|
160
166
|
var __alepha: Alepha;
|
|
161
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Plugin vite for Alepha framework.
|
|
170
|
+
*
|
|
171
|
+
* This module provides Vite plugins and configurations to integrate Alepha applications with Vite's build and development processes.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* import { defineConfig } from "vite";
|
|
176
|
+
* import { viteAlepha } from "alepha/vite";
|
|
177
|
+
*
|
|
178
|
+
* export default defineConfig({
|
|
179
|
+
* plugins: [viteAlepha()],
|
|
180
|
+
* // other Vite configurations...
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @module alepha.vite
|
|
185
|
+
*/
|
|
162
186
|
//# sourceMappingURL=index.d.ts.map
|
|
163
187
|
|
|
164
188
|
//#endregion
|