alepha 0.10.7 → 0.11.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/api/files.d.ts +172 -235
- package/api/jobs.d.ts +133 -208
- package/api/notifications.d.ts +112 -225
- package/api/users.d.ts +499 -786
- package/batch.d.ts +8 -8
- package/bucket.d.ts +1 -1
- package/cache.d.ts +12 -12
- package/command.d.ts +11 -11
- package/core.d.ts +312 -221
- package/datetime.d.ts +41 -10
- package/lock.d.ts +8 -8
- package/logger.d.ts +19 -9
- package/package.json +52 -65
- package/postgres.d.ts +488 -1172
- package/queue.d.ts +14 -14
- package/react/auth.d.ts +1 -1
- package/react/form.d.ts +33 -22
- package/react/i18n.d.ts +8 -8
- package/react.d.ts +76 -56
- package/retry.d.ts +8 -8
- package/scheduler.d.ts +1 -1
- package/security.d.ts +4 -4
- package/server/cookies.d.ts +10 -10
- package/server/health.d.ts +31 -8
- package/server/links.d.ts +3 -3
- package/server/multipart.d.ts +2 -2
- package/server/swagger.d.ts +4 -0
- package/server.d.ts +43 -42
- package/topic.d.ts +17 -17
- package/ui.d.ts +365 -46
- package/vite.d.ts +7 -2
package/retry.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ declare const $retry: {
|
|
|
11
11
|
<T extends (...args: any[]) => any>(options: RetryDescriptorOptions<T>): RetryDescriptorFn<T>;
|
|
12
12
|
[KIND]: typeof RetryDescriptor;
|
|
13
13
|
};
|
|
14
|
-
interface RetryDescriptorOptions<T
|
|
14
|
+
interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
|
|
15
15
|
/**
|
|
16
16
|
* The function to retry.
|
|
17
17
|
*/
|
|
18
|
-
handler: T
|
|
18
|
+
handler: T;
|
|
19
19
|
/**
|
|
20
20
|
* The maximum number of attempts.
|
|
21
21
|
*
|
|
@@ -45,20 +45,20 @@ interface RetryDescriptorOptions<T$1 extends (...args: any[]) => any> {
|
|
|
45
45
|
* A custom callback for when a retry attempt fails.
|
|
46
46
|
* This is called before the delay.
|
|
47
47
|
*/
|
|
48
|
-
onError?: (error: Error, attempt: number, ...args: Parameters<T
|
|
48
|
+
onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;
|
|
49
49
|
/**
|
|
50
50
|
* An AbortSignal to allow for external cancellation of the retry loop.
|
|
51
51
|
*/
|
|
52
52
|
signal?: AbortSignal;
|
|
53
53
|
}
|
|
54
|
-
declare class RetryDescriptor<T
|
|
54
|
+
declare class RetryDescriptor<T extends (...args: any[]) => any> extends Descriptor<RetryDescriptorOptions<T>> {
|
|
55
55
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
56
56
|
protected appAbortController: AbortController;
|
|
57
|
-
constructor(args: DescriptorArgs<RetryDescriptorOptions<T
|
|
58
|
-
run(...args: Parameters<T
|
|
57
|
+
constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>);
|
|
58
|
+
run(...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
59
59
|
}
|
|
60
|
-
interface RetryDescriptorFn<T
|
|
61
|
-
(...args: Parameters<T
|
|
60
|
+
interface RetryDescriptorFn<T extends (...args: any[]) => any> extends RetryDescriptor<T> {
|
|
61
|
+
(...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
62
62
|
}
|
|
63
63
|
interface RetryBackoffOptions {
|
|
64
64
|
/**
|
package/scheduler.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
|
|
|
3
3
|
import * as _alepha_lock0 from "alepha/lock";
|
|
4
4
|
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
5
5
|
import * as _alepha_logger0 from "alepha/logger";
|
|
6
|
-
import { Cron } from "cron-schedule";
|
|
7
6
|
import * as dayjs0 from "dayjs";
|
|
7
|
+
import { Cron } from "cron-schedule";
|
|
8
8
|
|
|
9
9
|
//#region src/constants/CRON.d.ts
|
|
10
10
|
declare const CRON: {
|
package/security.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_logger1 from "alepha/logger";
|
|
4
4
|
import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
|
|
5
5
|
import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
|
|
6
6
|
import * as typebox0 from "typebox";
|
|
@@ -68,7 +68,7 @@ type Role = Static<typeof roleSchema>;
|
|
|
68
68
|
* Provides utilities for working with JSON Web Tokens (JWT).
|
|
69
69
|
*/
|
|
70
70
|
declare class JwtProvider {
|
|
71
|
-
protected readonly log:
|
|
71
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
72
72
|
protected readonly keystore: KeyLoaderHolder[];
|
|
73
73
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
74
74
|
protected readonly encoder: TextEncoder;
|
|
@@ -140,7 +140,7 @@ declare class SecurityProvider {
|
|
|
140
140
|
protected readonly UNKNOWN_USER_NAME = "Anonymous User";
|
|
141
141
|
protected readonly PERMISSION_REGEXP: RegExp;
|
|
142
142
|
protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
|
|
143
|
-
protected readonly log:
|
|
143
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
144
144
|
protected readonly jwt: JwtProvider;
|
|
145
145
|
protected readonly env: {
|
|
146
146
|
APP_SECRET: string;
|
|
@@ -399,7 +399,7 @@ declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
|
|
|
399
399
|
protected readonly securityProvider: SecurityProvider;
|
|
400
400
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
401
401
|
protected readonly jwt: JwtProvider;
|
|
402
|
-
protected readonly log:
|
|
402
|
+
protected readonly log: _alepha_logger1.Logger;
|
|
403
403
|
get name(): string;
|
|
404
404
|
get accessTokenExpiration(): Duration;
|
|
405
405
|
get refreshTokenExpiration(): Duration;
|
package/server/cookies.d.ts
CHANGED
|
@@ -45,9 +45,9 @@ declare const $cookie: {
|
|
|
45
45
|
<T extends TSchema>(options: CookieDescriptorOptions<T>): AbstractCookieDescriptor<T>;
|
|
46
46
|
[KIND]: typeof CookieDescriptor;
|
|
47
47
|
};
|
|
48
|
-
interface CookieDescriptorOptions<T
|
|
48
|
+
interface CookieDescriptorOptions<T extends TSchema> {
|
|
49
49
|
/** The schema for the cookie's value, used for validation and type safety. */
|
|
50
|
-
schema: T
|
|
50
|
+
schema: T;
|
|
51
51
|
/** The name of the cookie. */
|
|
52
52
|
name?: string;
|
|
53
53
|
/** The cookie's path. Defaults to "/". */
|
|
@@ -69,28 +69,28 @@ interface CookieDescriptorOptions<T$1 extends TSchema> {
|
|
|
69
69
|
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
70
70
|
sign?: boolean;
|
|
71
71
|
}
|
|
72
|
-
interface AbstractCookieDescriptor<T
|
|
72
|
+
interface AbstractCookieDescriptor<T extends TSchema> {
|
|
73
73
|
readonly name: string;
|
|
74
|
-
readonly options: CookieDescriptorOptions<T
|
|
75
|
-
set(value: Static<T
|
|
74
|
+
readonly options: CookieDescriptorOptions<T>;
|
|
75
|
+
set(value: Static<T>, options?: {
|
|
76
76
|
cookies?: Cookies;
|
|
77
77
|
ttl?: DurationLike;
|
|
78
78
|
}): void;
|
|
79
79
|
get(options?: {
|
|
80
80
|
cookies?: Cookies;
|
|
81
|
-
}): Static<T
|
|
81
|
+
}): Static<T> | undefined;
|
|
82
82
|
del(options?: {
|
|
83
83
|
cookies?: Cookies;
|
|
84
84
|
}): void;
|
|
85
85
|
}
|
|
86
|
-
declare class CookieDescriptor<T
|
|
86
|
+
declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> implements AbstractCookieDescriptor<T> {
|
|
87
87
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
88
|
-
get schema(): T
|
|
88
|
+
get schema(): T;
|
|
89
89
|
get name(): string;
|
|
90
90
|
/**
|
|
91
91
|
* Sets the cookie with the given value in the current request's response.
|
|
92
92
|
*/
|
|
93
|
-
set(value: Static<T
|
|
93
|
+
set(value: Static<T>, options?: {
|
|
94
94
|
cookies?: Cookies;
|
|
95
95
|
ttl?: DurationLike;
|
|
96
96
|
}): void;
|
|
@@ -99,7 +99,7 @@ declare class CookieDescriptor<T$1 extends TSchema> extends Descriptor<CookieDes
|
|
|
99
99
|
*/
|
|
100
100
|
get(options?: {
|
|
101
101
|
cookies?: Cookies;
|
|
102
|
-
}): Static<T
|
|
102
|
+
}): Static<T> | undefined;
|
|
103
103
|
/**
|
|
104
104
|
* Deletes the cookie in the current request's response.
|
|
105
105
|
*/
|
package/server/health.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import * as _alepha_core0 from "alepha";
|
|
|
2
2
|
import { Alepha } from "alepha";
|
|
3
3
|
import * as _alepha_server0 from "alepha/server";
|
|
4
4
|
import { DateTimeProvider } from "alepha/datetime";
|
|
5
|
-
import * as
|
|
5
|
+
import * as typebox5 from "typebox";
|
|
6
|
+
import * as dayjs0 from "dayjs";
|
|
6
7
|
|
|
7
8
|
//#region src/providers/ServerHealthProvider.d.ts
|
|
8
9
|
/**
|
|
9
|
-
* Register `/health` endpoint.
|
|
10
|
+
* Register `/health` & `/healthz` endpoint.
|
|
10
11
|
*
|
|
11
12
|
* - Provides basic health information about the server.
|
|
12
13
|
*/
|
|
@@ -14,15 +15,37 @@ declare class ServerHealthProvider {
|
|
|
14
15
|
protected readonly time: DateTimeProvider;
|
|
15
16
|
protected readonly alepha: Alepha;
|
|
16
17
|
readonly health: _alepha_server0.RouteDescriptor<{
|
|
17
|
-
response:
|
|
18
|
-
message:
|
|
19
|
-
uptime:
|
|
20
|
-
date:
|
|
21
|
-
ready:
|
|
18
|
+
response: typebox5.TObject<{
|
|
19
|
+
message: typebox5.TString;
|
|
20
|
+
uptime: typebox5.TNumber;
|
|
21
|
+
date: typebox5.TCodec<typebox5.TString, dayjs0.Dayjs>;
|
|
22
|
+
ready: typebox5.TBoolean;
|
|
22
23
|
}>;
|
|
23
24
|
}>;
|
|
25
|
+
readonly healthz: _alepha_server0.RouteDescriptor<{
|
|
26
|
+
response: typebox5.TObject<{
|
|
27
|
+
message: typebox5.TString;
|
|
28
|
+
uptime: typebox5.TNumber;
|
|
29
|
+
date: typebox5.TCodec<typebox5.TString, dayjs0.Dayjs>;
|
|
30
|
+
ready: typebox5.TBoolean;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
protected healthCheck(): {
|
|
34
|
+
message: string;
|
|
35
|
+
uptime: number;
|
|
36
|
+
date: dayjs0.Dayjs;
|
|
37
|
+
ready: boolean;
|
|
38
|
+
};
|
|
24
39
|
}
|
|
25
40
|
//#endregion
|
|
41
|
+
//#region src/schemas/healthSchema.d.ts
|
|
42
|
+
declare const healthSchema: typebox5.TObject<{
|
|
43
|
+
message: typebox5.TString;
|
|
44
|
+
uptime: typebox5.TNumber;
|
|
45
|
+
date: typebox5.TCodec<typebox5.TString, dayjs0.Dayjs>;
|
|
46
|
+
ready: typebox5.TBoolean;
|
|
47
|
+
}>;
|
|
48
|
+
//#endregion
|
|
26
49
|
//#region src/index.d.ts
|
|
27
50
|
/**
|
|
28
51
|
* Plugin for Alepha Server that provides health-check endpoints.
|
|
@@ -32,5 +55,5 @@ declare class ServerHealthProvider {
|
|
|
32
55
|
*/
|
|
33
56
|
declare const AlephaServerHealth: _alepha_core0.Service<_alepha_core0.Module<{}>>;
|
|
34
57
|
//#endregion
|
|
35
|
-
export { AlephaServerHealth, ServerHealthProvider };
|
|
58
|
+
export { AlephaServerHealth, ServerHealthProvider, healthSchema };
|
|
36
59
|
//# sourceMappingURL=index.d.ts.map
|
package/server/links.d.ts
CHANGED
|
@@ -93,9 +93,9 @@ interface ClientScope {
|
|
|
93
93
|
service?: string;
|
|
94
94
|
hostname?: string;
|
|
95
95
|
}
|
|
96
|
-
type HttpVirtualClient<T
|
|
97
|
-
interface VirtualAction<T
|
|
98
|
-
(config?: ClientRequestEntry<T
|
|
96
|
+
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
|
|
97
|
+
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
|
|
98
|
+
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
99
99
|
can: () => boolean;
|
|
100
100
|
}
|
|
101
101
|
//#endregion
|
package/server/multipart.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _alepha_core0 from "alepha";
|
|
2
2
|
import { Alepha, FileLike, HookDescriptor } from "alepha";
|
|
3
3
|
import { ServerRoute } from "alepha/server";
|
|
4
|
-
import { BusboyConfig } from "@fastify/busboy";
|
|
5
4
|
import { IncomingMessage } from "node:http";
|
|
5
|
+
import { BusboyConfig } from "@fastify/busboy";
|
|
6
6
|
|
|
7
7
|
//#region src/providers/ServerMultipartProvider.d.ts
|
|
8
8
|
declare class ServerMultipartProvider {
|
|
@@ -10,7 +10,7 @@ declare class ServerMultipartProvider {
|
|
|
10
10
|
readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
11
11
|
readonly onSend: HookDescriptor<"server:onResponse">;
|
|
12
12
|
handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
|
|
13
|
-
body: Record<string,
|
|
13
|
+
body: Record<string, unknown>;
|
|
14
14
|
cleanup: () => Promise<void>;
|
|
15
15
|
}>;
|
|
16
16
|
parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
|
package/server/swagger.d.ts
CHANGED
|
@@ -103,6 +103,9 @@ declare class ServerSwaggerProvider {
|
|
|
103
103
|
protected readonly alepha: Alepha;
|
|
104
104
|
protected readonly log: _alepha_logger0.Logger;
|
|
105
105
|
json?: OpenAPIV3.Document;
|
|
106
|
+
options: {
|
|
107
|
+
excludeKeys: string[];
|
|
108
|
+
};
|
|
106
109
|
protected readonly configure: _alepha_core1.HookDescriptor<"configure">;
|
|
107
110
|
createSwagger(options: SwaggerDescriptorOptions): Promise<OpenAPIV3.Document | undefined>;
|
|
108
111
|
protected configureOpenApi(actions: ActionDescriptor<RequestConfigSchema>[], doc: SwaggerDescriptorOptions): OpenAPIV3.Document;
|
|
@@ -115,6 +118,7 @@ declare class ServerSwaggerProvider {
|
|
|
115
118
|
} | undefined;
|
|
116
119
|
protected configureSwaggerApi(prefix: string, json: OpenAPIV3.Document): void;
|
|
117
120
|
protected configureSwaggerUi(prefix: string, options: SwaggerDescriptorOptions): Promise<void>;
|
|
121
|
+
removePrivateFields<T extends Record<string, any>>(obj: T, excludeList: string[]): T;
|
|
118
122
|
}
|
|
119
123
|
//#endregion
|
|
120
124
|
//#region src/index.d.ts
|
package/server.d.ts
CHANGED
|
@@ -68,14 +68,14 @@ interface RequestConfigSchema {
|
|
|
68
68
|
headers?: TObject;
|
|
69
69
|
response?: TResponseBody;
|
|
70
70
|
}
|
|
71
|
-
interface ServerRequestConfig<TConfig
|
|
72
|
-
body: TConfig
|
|
73
|
-
headers: TConfig
|
|
74
|
-
params: TConfig
|
|
75
|
-
query: TConfig
|
|
76
|
-
}
|
|
77
|
-
type ServerRequestConfigEntry<TConfig
|
|
78
|
-
interface ServerRequest<TConfig
|
|
71
|
+
interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
72
|
+
body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
|
|
73
|
+
headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
|
|
74
|
+
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
|
|
75
|
+
query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
|
|
76
|
+
}
|
|
77
|
+
type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
|
|
78
|
+
interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
|
|
79
79
|
method: RouteMethod;
|
|
80
80
|
url: URL;
|
|
81
81
|
requestId: string;
|
|
@@ -120,19 +120,19 @@ interface ServerRequest<TConfig$1 extends RequestConfigSchema = RequestConfigSch
|
|
|
120
120
|
};
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
interface ServerRoute<TConfig
|
|
124
|
-
handler: ServerHandler<TConfig
|
|
123
|
+
interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
|
|
124
|
+
handler: ServerHandler<TConfig>;
|
|
125
125
|
method?: RouteMethod;
|
|
126
|
-
schema?: TConfig
|
|
126
|
+
schema?: TConfig;
|
|
127
127
|
/**
|
|
128
128
|
* @see ServerLoggerProvider
|
|
129
129
|
*/
|
|
130
130
|
silent?: boolean;
|
|
131
131
|
}
|
|
132
|
-
type ServerResponseBody<TConfig
|
|
132
|
+
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
|
|
133
133
|
type ResponseKind = "json" | "text" | "void" | "file" | "any";
|
|
134
134
|
type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
|
|
135
|
-
type ServerHandler<TConfig
|
|
135
|
+
type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
136
136
|
interface ServerResponse {
|
|
137
137
|
body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
|
|
138
138
|
headers: Record<string, string>;
|
|
@@ -238,9 +238,7 @@ declare class HttpClient {
|
|
|
238
238
|
readonly cache: _alepha_cache0.CacheDescriptorFn<HttpClientCache, any[]>;
|
|
239
239
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
240
240
|
fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
|
|
241
|
-
fetch<T>(url: string, request?:
|
|
242
|
-
// standard options
|
|
243
|
-
options?: FetchOptions): Promise<FetchResponse<T>>;
|
|
241
|
+
fetch<T extends TSchema>(url: string, request?: RequestInitWithOptions<T>): Promise<FetchResponse<Static<T>>>;
|
|
244
242
|
protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
|
|
245
243
|
protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
|
|
246
244
|
protected responseData(response: Response, options: FetchOptions): Promise<any>;
|
|
@@ -257,7 +255,7 @@ declare class HttpClient {
|
|
|
257
255
|
};
|
|
258
256
|
}, args?: ServerRequestConfigEntry): string;
|
|
259
257
|
}
|
|
260
|
-
interface FetchOptions {
|
|
258
|
+
interface FetchOptions<T extends TSchema = TSchema> {
|
|
261
259
|
/**
|
|
262
260
|
* Key to identify the request in the pending requests.
|
|
263
261
|
*/
|
|
@@ -265,14 +263,17 @@ interface FetchOptions {
|
|
|
265
263
|
/**
|
|
266
264
|
* The schema to validate the response against.
|
|
267
265
|
*/
|
|
268
|
-
schema?:
|
|
266
|
+
schema?: {
|
|
267
|
+
response?: T;
|
|
268
|
+
};
|
|
269
269
|
/**
|
|
270
270
|
* Built-in cache options.
|
|
271
271
|
*/
|
|
272
|
-
|
|
272
|
+
localCache?: boolean | number | DurationLike;
|
|
273
273
|
}
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
type RequestInitWithOptions<T extends TSchema = TSchema> = RequestInit & FetchOptions<T>;
|
|
275
|
+
interface FetchResponse<T = any> {
|
|
276
|
+
data: T;
|
|
276
277
|
status: number;
|
|
277
278
|
statusText: string;
|
|
278
279
|
headers: Headers;
|
|
@@ -485,7 +486,7 @@ declare const $action: {
|
|
|
485
486
|
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptorFn<TConfig>;
|
|
486
487
|
[KIND]: typeof ActionDescriptor;
|
|
487
488
|
};
|
|
488
|
-
interface ActionDescriptorOptions<TConfig
|
|
489
|
+
interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
|
|
489
490
|
/**
|
|
490
491
|
* Name of the action.
|
|
491
492
|
*
|
|
@@ -536,7 +537,7 @@ interface ActionDescriptorOptions<TConfig$1 extends RequestConfigSchema> extends
|
|
|
536
537
|
* - query: The request query-params schema.
|
|
537
538
|
* - response: The response schema.
|
|
538
539
|
*/
|
|
539
|
-
schema?: TConfig
|
|
540
|
+
schema?: TConfig;
|
|
540
541
|
/**
|
|
541
542
|
* A short description of the action. Used for documentation purposes.
|
|
542
543
|
*/
|
|
@@ -549,9 +550,9 @@ interface ActionDescriptorOptions<TConfig$1 extends RequestConfigSchema> extends
|
|
|
549
550
|
/**
|
|
550
551
|
* Main route handler. This is where the route logic is implemented.
|
|
551
552
|
*/
|
|
552
|
-
handler: ServerActionHandler<TConfig
|
|
553
|
+
handler: ServerActionHandler<TConfig>;
|
|
553
554
|
}
|
|
554
|
-
declare class ActionDescriptor<TConfig
|
|
555
|
+
declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
|
|
555
556
|
protected readonly log: _alepha_logger3.Logger;
|
|
556
557
|
protected readonly env: {
|
|
557
558
|
SERVER_API_PREFIX: string;
|
|
@@ -580,27 +581,27 @@ declare class ActionDescriptor<TConfig$1 extends RequestConfigSchema> extends De
|
|
|
580
581
|
* Path is prefixed by `/api` by default.
|
|
581
582
|
*/
|
|
582
583
|
get path(): string;
|
|
583
|
-
get schema(): TConfig
|
|
584
|
+
get schema(): TConfig | undefined;
|
|
584
585
|
getBodyContentType(): string | undefined;
|
|
585
586
|
/**
|
|
586
587
|
* Call the action handler directly.
|
|
587
588
|
* There is no HTTP layer involved.
|
|
588
589
|
*/
|
|
589
|
-
run(config?: ClientRequestEntry<TConfig
|
|
590
|
+
run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
|
|
590
591
|
/**
|
|
591
592
|
* Works like `run`, but always fetches (http request) the route.
|
|
592
593
|
*/
|
|
593
|
-
fetch(config?: ClientRequestEntry<TConfig
|
|
594
|
+
fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
|
|
594
595
|
}
|
|
595
|
-
interface ActionDescriptorFn<TConfig
|
|
596
|
-
(config?: ClientRequestEntry<TConfig
|
|
596
|
+
interface ActionDescriptorFn<TConfig extends RequestConfigSchema> extends ActionDescriptor<TConfig> {
|
|
597
|
+
(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
|
|
597
598
|
}
|
|
598
|
-
type ClientRequestEntry<TConfig
|
|
599
|
-
type ClientRequestEntryContainer<TConfig
|
|
600
|
-
body: TConfig
|
|
601
|
-
params: TConfig
|
|
602
|
-
headers?: TConfig
|
|
603
|
-
query?: TConfig
|
|
599
|
+
type ClientRequestEntry<TConfig extends RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
600
|
+
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
|
|
601
|
+
body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
|
|
602
|
+
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
|
|
603
|
+
headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
|
|
604
|
+
query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
|
|
604
605
|
};
|
|
605
606
|
interface ClientRequestOptions extends FetchOptions {
|
|
606
607
|
/**
|
|
@@ -608,11 +609,11 @@ interface ClientRequestOptions extends FetchOptions {
|
|
|
608
609
|
*/
|
|
609
610
|
request?: RequestInit;
|
|
610
611
|
}
|
|
611
|
-
type ClientRequestResponse<TConfig
|
|
612
|
+
type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
|
|
612
613
|
/**
|
|
613
614
|
* Specific handler for server actions.
|
|
614
615
|
*/
|
|
615
|
-
type ServerActionHandler<TConfig
|
|
616
|
+
type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
616
617
|
/**
|
|
617
618
|
* Server Action Request Interface
|
|
618
619
|
*
|
|
@@ -620,7 +621,7 @@ type ServerActionHandler<TConfig$1 extends RequestConfigSchema = RequestConfigSc
|
|
|
620
621
|
*
|
|
621
622
|
* This is NOT Server Request, but a specific type for actions.
|
|
622
623
|
*/
|
|
623
|
-
interface ServerActionRequest<TConfig
|
|
624
|
+
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
624
625
|
//#endregion
|
|
625
626
|
//#region src/schemas/errorSchema.d.ts
|
|
626
627
|
declare const errorSchema: typebox0.TObject<{
|
|
@@ -670,8 +671,8 @@ declare const $route: {
|
|
|
670
671
|
<TConfig extends RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
|
|
671
672
|
[KIND]: typeof RouteDescriptor;
|
|
672
673
|
};
|
|
673
|
-
interface RouteDescriptorOptions<TConfig
|
|
674
|
-
declare class RouteDescriptor<TConfig
|
|
674
|
+
interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {}
|
|
675
|
+
declare class RouteDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<RouteDescriptorOptions<TConfig>> {
|
|
675
676
|
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
676
677
|
protected onInit(): void;
|
|
677
678
|
}
|
|
@@ -843,5 +844,5 @@ declare module "alepha" {
|
|
|
843
844
|
*/
|
|
844
845
|
declare const AlephaServer: _alepha_core11.Service<_alepha_core11.Module<{}>>;
|
|
845
846
|
//#endregion
|
|
846
|
-
export { $action, $route, ActionDescriptor, ActionDescriptorFn, 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 };
|
|
847
|
+
export { $action, $route, ActionDescriptor, ActionDescriptorFn, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, ErrorSchema, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, RequestInitWithOptions, 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 };
|
|
847
848
|
//# sourceMappingURL=index.d.ts.map
|
package/topic.d.ts
CHANGED
|
@@ -220,7 +220,7 @@ declare const $topic: {
|
|
|
220
220
|
<T extends TopicMessageSchema>(options: TopicDescriptorOptions<T>): TopicDescriptor<T>;
|
|
221
221
|
[KIND]: typeof TopicDescriptor;
|
|
222
222
|
};
|
|
223
|
-
interface TopicDescriptorOptions<T
|
|
223
|
+
interface TopicDescriptorOptions<T extends TopicMessageSchema> {
|
|
224
224
|
/**
|
|
225
225
|
* Unique name identifier for the topic.
|
|
226
226
|
*
|
|
@@ -329,7 +329,7 @@ interface TopicDescriptorOptions<T$1 extends TopicMessageSchema> {
|
|
|
329
329
|
* }
|
|
330
330
|
* ```
|
|
331
331
|
*/
|
|
332
|
-
schema: T
|
|
332
|
+
schema: T;
|
|
333
333
|
/**
|
|
334
334
|
* Default subscriber handler function that processes messages published to this topic.
|
|
335
335
|
*
|
|
@@ -393,32 +393,32 @@ interface TopicDescriptorOptions<T$1 extends TopicMessageSchema> {
|
|
|
393
393
|
* }
|
|
394
394
|
* ```
|
|
395
395
|
*/
|
|
396
|
-
handler?: TopicHandler<T
|
|
396
|
+
handler?: TopicHandler<T>;
|
|
397
397
|
}
|
|
398
|
-
declare class TopicDescriptor<T
|
|
398
|
+
declare class TopicDescriptor<T extends TopicMessageSchema> extends Descriptor<TopicDescriptorOptions<T>> {
|
|
399
399
|
protected readonly log: _alepha_logger0.Logger;
|
|
400
400
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
401
401
|
readonly provider: TopicProvider;
|
|
402
402
|
get name(): string;
|
|
403
|
-
publish(payload: TopicMessage<T
|
|
404
|
-
subscribe(handler: TopicHandler<T
|
|
405
|
-
wait(options?: TopicWaitOptions<T
|
|
403
|
+
publish(payload: TopicMessage<T>["payload"]): Promise<void>;
|
|
404
|
+
subscribe(handler: TopicHandler<T>): Promise<UnSubscribeFn>;
|
|
405
|
+
wait(options?: TopicWaitOptions<T>): Promise<TopicMessage<T>>;
|
|
406
406
|
protected $provider(): TopicProvider;
|
|
407
|
-
protected parseMessage(message: string): TopicMessage<T
|
|
407
|
+
protected parseMessage(message: string): TopicMessage<T>;
|
|
408
408
|
}
|
|
409
|
-
interface TopicMessage<T
|
|
410
|
-
payload: Static<T
|
|
409
|
+
interface TopicMessage<T extends TopicMessageSchema> {
|
|
410
|
+
payload: Static<T["payload"]>;
|
|
411
411
|
}
|
|
412
|
-
interface TopicWaitOptions<T
|
|
412
|
+
interface TopicWaitOptions<T extends TopicMessageSchema> {
|
|
413
413
|
timeout?: DurationLike;
|
|
414
414
|
filter?: (message: {
|
|
415
|
-
payload: Static<T
|
|
415
|
+
payload: Static<T["payload"]>;
|
|
416
416
|
}) => boolean;
|
|
417
417
|
}
|
|
418
418
|
interface TopicMessageSchema {
|
|
419
419
|
payload: TSchema;
|
|
420
420
|
}
|
|
421
|
-
type TopicHandler<T
|
|
421
|
+
type TopicHandler<T extends TopicMessageSchema = TopicMessageSchema> = (message: TopicMessage<T>) => unknown;
|
|
422
422
|
//#endregion
|
|
423
423
|
//#region src/descriptors/$subscriber.d.ts
|
|
424
424
|
/**
|
|
@@ -636,7 +636,7 @@ declare const $subscriber: {
|
|
|
636
636
|
<T extends TopicMessageSchema>(options: SubscriberDescriptorOptions<T>): SubscriberDescriptor<T>;
|
|
637
637
|
[KIND]: typeof SubscriberDescriptor;
|
|
638
638
|
};
|
|
639
|
-
interface SubscriberDescriptorOptions<T
|
|
639
|
+
interface SubscriberDescriptorOptions<T extends TopicMessageSchema> {
|
|
640
640
|
/**
|
|
641
641
|
* The topic descriptor that this subscriber will listen to for messages.
|
|
642
642
|
*
|
|
@@ -670,7 +670,7 @@ interface SubscriberDescriptorOptions<T$1 extends TopicMessageSchema> {
|
|
|
670
670
|
* });
|
|
671
671
|
* ```
|
|
672
672
|
*/
|
|
673
|
-
topic: TopicDescriptor<T
|
|
673
|
+
topic: TopicDescriptor<T>;
|
|
674
674
|
/**
|
|
675
675
|
* Message handler function that processes individual messages from the topic.
|
|
676
676
|
*
|
|
@@ -765,9 +765,9 @@ interface SubscriberDescriptorOptions<T$1 extends TopicMessageSchema> {
|
|
|
765
765
|
* }
|
|
766
766
|
* ```
|
|
767
767
|
*/
|
|
768
|
-
handler: TopicHandler<T
|
|
768
|
+
handler: TopicHandler<T>;
|
|
769
769
|
}
|
|
770
|
-
declare class SubscriberDescriptor<T
|
|
770
|
+
declare class SubscriberDescriptor<T extends TopicMessageSchema> extends Descriptor<SubscriberDescriptorOptions<T>> {}
|
|
771
771
|
//#endregion
|
|
772
772
|
//#region src/errors/TopicTimeoutError.d.ts
|
|
773
773
|
declare class TopicTimeoutError extends Error {
|