alepha 0.9.2 → 0.9.4
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 +46 -0
- package/batch.d.ts +5 -8
- package/bucket.d.ts +9 -16
- package/cache/redis.d.ts +10 -10
- package/cache.d.ts +3 -7
- package/command.d.ts +19 -17
- package/core.d.ts +188 -340
- package/datetime.d.ts +6 -10
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +3 -6
- package/lock.d.ts +9 -16
- package/{testing.cjs → logger.cjs} +1 -1
- package/logger.d.ts +222 -0
- package/logger.js +1 -0
- package/package.json +50 -49
- package/postgres.d.ts +273 -315
- package/queue/redis.d.ts +1 -3
- package/queue.d.ts +11 -19
- package/react/auth.d.ts +453 -146
- package/react/form.d.ts +119 -69
- package/react/head.d.ts +49 -18
- package/react/i18n.d.ts +61 -27
- package/react.d.ts +304 -212
- package/redis.d.ts +15 -15
- package/retry.d.ts +0 -4
- package/router.d.ts +0 -1
- package/scheduler.d.ts +6 -10
- package/security.d.ts +140 -138
- package/server/cache.d.ts +11 -11
- package/server/compress.d.ts +1 -4
- package/server/cookies.d.ts +45 -19
- package/server/cors.d.ts +4 -8
- package/server/health.d.ts +1 -4
- package/server/helmet.d.ts +28 -28
- package/server/links.d.ts +147 -45
- package/server/metrics.d.ts +5 -9
- package/server/multipart.d.ts +1 -3
- package/server/proxy.d.ts +5 -9
- package/server/security.d.ts +12 -15
- package/server/static.d.ts +6 -10
- package/server/swagger.d.ts +4 -8
- package/server.d.ts +75 -91
- package/topic/redis.d.ts +5 -8
- package/topic.d.ts +4 -12
- package/vite.d.ts +59 -30
- package/testing.d.ts +0 -1
- package/testing.js +0 -1
package/server/cache.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _alepha_cache0 from "alepha/cache";
|
|
2
2
|
import { CacheDescriptorOptions } from "alepha/cache";
|
|
3
|
-
import * as
|
|
4
|
-
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import * as _alepha_core1 from "alepha";
|
|
5
4
|
import { Alepha } from "alepha";
|
|
6
5
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
6
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
7
7
|
import { RequestConfigSchema, ServerRequest, ServerRoute } from "alepha/server";
|
|
8
8
|
|
|
9
9
|
//#region src/providers/ServerCacheProvider.d.ts
|
|
@@ -16,26 +16,28 @@ declare module "alepha/server" {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
declare class ServerCacheProvider {
|
|
19
|
-
protected readonly log:
|
|
19
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
20
20
|
protected readonly alepha: Alepha;
|
|
21
21
|
protected readonly time: DateTimeProvider;
|
|
22
22
|
protected readonly cache: _alepha_cache0.CacheDescriptorFn<RouteCacheEntry, any[]>;
|
|
23
23
|
generateETag(content: string): string;
|
|
24
24
|
invalidate(route: ServerRoute): Promise<void>;
|
|
25
|
-
protected readonly
|
|
26
|
-
protected readonly
|
|
25
|
+
protected readonly onActionRequest: _alepha_core1.HookDescriptor<"action:onRequest">;
|
|
26
|
+
protected readonly onActionResponse: _alepha_core1.HookDescriptor<"action:onResponse">;
|
|
27
|
+
protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
28
|
+
protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
27
29
|
protected getCacheOptions(cache: ServerRouteCache): {
|
|
28
|
-
provider?: (
|
|
30
|
+
provider?: (_alepha_core1.InstantiableClass<_alepha_cache0.CacheProvider> | "memory") | undefined;
|
|
29
31
|
name?: string | undefined;
|
|
30
32
|
ttl?: DurationLike | undefined;
|
|
31
33
|
disabled?: boolean | undefined;
|
|
32
34
|
};
|
|
33
|
-
protected createCacheKey(route: ServerRoute,
|
|
35
|
+
protected createCacheKey(route: ServerRoute, config?: ServerRequest): string;
|
|
34
36
|
}
|
|
35
37
|
type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
36
38
|
interface RouteCacheEntry {
|
|
37
39
|
contentType?: string;
|
|
38
|
-
body:
|
|
40
|
+
body: any;
|
|
39
41
|
status?: number;
|
|
40
42
|
lastModified: string;
|
|
41
43
|
hash: string;
|
|
@@ -70,9 +72,7 @@ interface RouteCacheEntry {
|
|
|
70
72
|
* @see {@link ServerCacheProvider}
|
|
71
73
|
* @module alepha.server.cache
|
|
72
74
|
*/
|
|
73
|
-
declare const AlephaServerCache:
|
|
74
|
-
//# sourceMappingURL=index.d.ts.map
|
|
75
|
-
|
|
75
|
+
declare const AlephaServerCache: _alepha_core1.Service<_alepha_core1.Module>;
|
|
76
76
|
//#endregion
|
|
77
77
|
export { AlephaServerCache, ServerCacheProvider, ServerRouteCache };
|
|
78
78
|
//# sourceMappingURL=index.d.ts.map
|
package/server/compress.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ declare class ServerCompressProvider {
|
|
|
19
19
|
interface ServerCompressProviderOptions {
|
|
20
20
|
allowedContentTypes: string[];
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=ServerCompressProvider.d.ts.map
|
|
23
22
|
//#endregion
|
|
24
23
|
//#region src/index.d.ts
|
|
25
24
|
/**
|
|
@@ -27,9 +26,7 @@ interface ServerCompressProviderOptions {
|
|
|
27
26
|
*
|
|
28
27
|
* Compresses responses using gzip, brotli, or zstd based on the `Accept-Encoding` header.
|
|
29
28
|
*/
|
|
30
|
-
declare const AlephaServerCompress: _alepha_core0.
|
|
31
|
-
//# sourceMappingURL=index.d.ts.map
|
|
32
|
-
|
|
29
|
+
declare const AlephaServerCompress: _alepha_core0.Service<_alepha_core0.Module>;
|
|
33
30
|
//#endregion
|
|
34
31
|
export { AlephaServerCompress, ServerCompressProvider, ServerCompressProviderOptions };
|
|
35
32
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cookies.d.ts
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as _alepha_core0 from "alepha";
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
3
2
|
import { Alepha, Descriptor, KIND, Static, TSchema } from "alepha";
|
|
4
3
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
4
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
5
5
|
|
|
6
|
+
//#region src/services/CookieParser.d.ts
|
|
7
|
+
declare class CookieParser {
|
|
8
|
+
parseRequestCookies(header: string): Record<string, string>;
|
|
9
|
+
serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
10
|
+
cookieToString(name: string, cookie: Cookie, isHttps?: boolean): string;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
6
13
|
//#region src/providers/ServerCookiesProvider.d.ts
|
|
7
|
-
declare const envSchema:
|
|
14
|
+
declare const envSchema: _alepha_core1.TObject<{
|
|
8
15
|
/**
|
|
9
16
|
* A 32-byte secret key used for cookie encryption and signing. MUST be set for `encrypt` or `sign` to work.
|
|
10
17
|
*/
|
|
11
|
-
COOKIE_SECRET:
|
|
18
|
+
COOKIE_SECRET: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
12
19
|
}>;
|
|
13
20
|
declare module "alepha" {
|
|
14
21
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
15
22
|
}
|
|
16
23
|
declare class ServerCookiesProvider {
|
|
17
24
|
protected readonly alepha: Alepha;
|
|
18
|
-
protected readonly log:
|
|
25
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
19
26
|
protected readonly env: {
|
|
20
27
|
COOKIE_SECRET?: string | undefined;
|
|
21
28
|
};
|
|
29
|
+
protected readonly cookieParser: CookieParser;
|
|
22
30
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
23
31
|
protected readonly ALGORITHM = "aes-256-gcm";
|
|
24
32
|
protected readonly IV_LENGTH = 16;
|
|
25
33
|
protected readonly AUTH_TAG_LENGTH = 16;
|
|
26
34
|
protected readonly SIGNATURE_LENGTH = 32;
|
|
27
|
-
readonly onRequest:
|
|
28
|
-
readonly
|
|
35
|
+
readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
36
|
+
readonly onAction: _alepha_core1.HookDescriptor<"action:onRequest">;
|
|
37
|
+
readonly onSend: _alepha_core1.HookDescriptor<"server:onSend">;
|
|
29
38
|
protected getCookiesFromContext(cookies?: Cookies): Cookies;
|
|
30
39
|
getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
|
|
31
40
|
setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
|
|
@@ -34,8 +43,6 @@ declare class ServerCookiesProvider {
|
|
|
34
43
|
protected decrypt(encryptedText: string): string;
|
|
35
44
|
secretKey(): string;
|
|
36
45
|
protected sign(data: string): string;
|
|
37
|
-
protected parseRequestCookies(header: string): Record<string, string>;
|
|
38
|
-
protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
|
|
39
46
|
}
|
|
40
47
|
//#endregion
|
|
41
48
|
//#region src/descriptors/$cookie.d.ts
|
|
@@ -45,7 +52,7 @@ declare class ServerCookiesProvider {
|
|
|
45
52
|
* within the server request/response cycle.
|
|
46
53
|
*/
|
|
47
54
|
declare const $cookie: {
|
|
48
|
-
<T extends TSchema>(options: CookieDescriptorOptions<T>):
|
|
55
|
+
<T extends TSchema>(options: CookieDescriptorOptions<T>): AbstractCookieDescriptor<T>;
|
|
49
56
|
[KIND]: typeof CookieDescriptor;
|
|
50
57
|
};
|
|
51
58
|
interface CookieDescriptorOptions<T extends TSchema> {
|
|
@@ -72,18 +79,40 @@ interface CookieDescriptorOptions<T extends TSchema> {
|
|
|
72
79
|
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
73
80
|
sign?: boolean;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
interface AbstractCookieDescriptor<T extends TSchema> {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly options: CookieDescriptorOptions<T>;
|
|
85
|
+
set(value: Static<T>, options?: {
|
|
86
|
+
cookies?: Cookies;
|
|
87
|
+
ttl?: DurationLike;
|
|
88
|
+
}): void;
|
|
89
|
+
get(options?: {
|
|
90
|
+
cookies?: Cookies;
|
|
91
|
+
}): Static<T> | undefined;
|
|
92
|
+
del(options?: {
|
|
93
|
+
cookies?: Cookies;
|
|
94
|
+
}): void;
|
|
95
|
+
}
|
|
96
|
+
declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> implements AbstractCookieDescriptor<T> {
|
|
76
97
|
protected readonly serverCookiesProvider: ServerCookiesProvider;
|
|
98
|
+
get schema(): T;
|
|
77
99
|
get name(): string;
|
|
78
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Sets the cookie with the given value in the current request's response.
|
|
102
|
+
*/
|
|
79
103
|
set(value: Static<T>, options?: {
|
|
80
104
|
cookies?: Cookies;
|
|
105
|
+
ttl?: DurationLike;
|
|
81
106
|
}): void;
|
|
82
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Gets the cookie value from the current request. Returns undefined if not found or invalid.
|
|
109
|
+
*/
|
|
83
110
|
get(options?: {
|
|
84
111
|
cookies?: Cookies;
|
|
85
112
|
}): Static<T> | undefined;
|
|
86
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Deletes the cookie in the current request's response.
|
|
115
|
+
*/
|
|
87
116
|
del(options?: {
|
|
88
117
|
cookies?: Cookies;
|
|
89
118
|
}): void;
|
|
@@ -101,7 +130,6 @@ interface Cookie {
|
|
|
101
130
|
sameSite?: "strict" | "lax" | "none";
|
|
102
131
|
domain?: string;
|
|
103
132
|
}
|
|
104
|
-
//# sourceMappingURL=$cookie.d.ts.map
|
|
105
133
|
//#endregion
|
|
106
134
|
//#region src/index.d.ts
|
|
107
135
|
declare module "alepha/server" {
|
|
@@ -119,9 +147,7 @@ declare module "alepha/server" {
|
|
|
119
147
|
* @see {@link $cookie}
|
|
120
148
|
* @module alepha.server.cookies
|
|
121
149
|
*/
|
|
122
|
-
declare const AlephaServerCookies:
|
|
123
|
-
//# sourceMappingURL=index.d.ts.map
|
|
124
|
-
|
|
150
|
+
declare const AlephaServerCookies: _alepha_core1.Service<_alepha_core1.Module>;
|
|
125
151
|
//#endregion
|
|
126
|
-
export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
152
|
+
export { $cookie, AbstractCookieDescriptor, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
127
153
|
//# sourceMappingURL=index.d.ts.map
|
package/server/cors.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as _alepha_core0 from "alepha";
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
3
2
|
import { ServerRouterProvider } from "alepha/server";
|
|
4
3
|
|
|
5
4
|
//#region src/providers/ServerCorsProvider.d.ts
|
|
6
5
|
declare class ServerCorsProvider {
|
|
7
6
|
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
8
7
|
options: ServerCorsProviderOptions;
|
|
9
|
-
protected readonly configure:
|
|
10
|
-
protected readonly onRequest:
|
|
8
|
+
protected readonly configure: _alepha_core1.HookDescriptor<"configure">;
|
|
9
|
+
protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
11
10
|
isOriginAllowed(origin: string | undefined, allowed: ServerCorsProviderOptions["origin"]): boolean;
|
|
12
11
|
}
|
|
13
12
|
interface ServerCorsProviderOptions {
|
|
@@ -17,15 +16,12 @@ interface ServerCorsProviderOptions {
|
|
|
17
16
|
credentials?: boolean;
|
|
18
17
|
maxAge?: number;
|
|
19
18
|
}
|
|
20
|
-
//# sourceMappingURL=ServerCorsProvider.d.ts.map
|
|
21
19
|
//#endregion
|
|
22
20
|
//#region src/index.d.ts
|
|
23
21
|
/**
|
|
24
22
|
* Plugin for configuring CORS on the Alepha server.
|
|
25
23
|
*/
|
|
26
|
-
declare const AlephaServerCors:
|
|
27
|
-
//# sourceMappingURL=index.d.ts.map
|
|
28
|
-
|
|
24
|
+
declare const AlephaServerCors: _alepha_core1.Service<_alepha_core1.Module>;
|
|
29
25
|
//#endregion
|
|
30
26
|
export { AlephaServerCors, ServerCorsProvider, ServerCorsProviderOptions };
|
|
31
27
|
//# sourceMappingURL=index.d.ts.map
|
package/server/health.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ declare class ServerHealthProvider {
|
|
|
22
22
|
}>;
|
|
23
23
|
}>;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=ServerHealthProvider.d.ts.map
|
|
26
25
|
//#endregion
|
|
27
26
|
//#region src/index.d.ts
|
|
28
27
|
/**
|
|
@@ -31,9 +30,7 @@ declare class ServerHealthProvider {
|
|
|
31
30
|
* @see {@link ServerHealthProvider}
|
|
32
31
|
* @module alepha.server.health
|
|
33
32
|
*/
|
|
34
|
-
declare const AlephaServerHealth: _alepha_core0.
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
|
36
|
-
|
|
33
|
+
declare const AlephaServerHealth: _alepha_core0.Service<_alepha_core0.Module>;
|
|
37
34
|
//#endregion
|
|
38
35
|
export { AlephaServerHealth, ServerHealthProvider };
|
|
39
36
|
//# sourceMappingURL=index.d.ts.map
|
package/server/helmet.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Alepha
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
|
+
import { Alepha } from "alepha";
|
|
3
3
|
|
|
4
4
|
//#region src/providers/ServerHelmetProvider.d.ts
|
|
5
5
|
type CspDirective = string | string[];
|
|
6
|
+
interface CspDirectives {
|
|
7
|
+
"default-src"?: CspDirective;
|
|
8
|
+
"script-src"?: CspDirective;
|
|
9
|
+
"style-src"?: CspDirective;
|
|
10
|
+
"img-src"?: CspDirective;
|
|
11
|
+
"connect-src"?: CspDirective;
|
|
12
|
+
"font-src"?: CspDirective;
|
|
13
|
+
"object-src"?: CspDirective;
|
|
14
|
+
"media-src"?: CspDirective;
|
|
15
|
+
"frame-src"?: CspDirective;
|
|
16
|
+
sandbox?: CspDirective | boolean;
|
|
17
|
+
"report-uri"?: string;
|
|
18
|
+
"child-src"?: CspDirective;
|
|
19
|
+
"form-action"?: CspDirective;
|
|
20
|
+
"frame-ancestors"?: CspDirective;
|
|
21
|
+
"plugin-types"?: CspDirective;
|
|
22
|
+
"base-uri"?: CspDirective;
|
|
23
|
+
[key: string]: CspDirective | undefined | boolean;
|
|
24
|
+
}
|
|
6
25
|
interface CspOptions {
|
|
7
|
-
directives:
|
|
8
|
-
"default-src"?: CspDirective;
|
|
9
|
-
"script-src"?: CspDirective;
|
|
10
|
-
"style-src"?: CspDirective;
|
|
11
|
-
"img-src"?: CspDirective;
|
|
12
|
-
"connect-src"?: CspDirective;
|
|
13
|
-
"font-src"?: CspDirective;
|
|
14
|
-
"object-src"?: CspDirective;
|
|
15
|
-
"media-src"?: CspDirective;
|
|
16
|
-
"frame-src"?: CspDirective;
|
|
17
|
-
sandbox?: CspDirective | boolean;
|
|
18
|
-
"report-uri"?: string;
|
|
19
|
-
"child-src"?: CspDirective;
|
|
20
|
-
"form-action"?: CspDirective;
|
|
21
|
-
"frame-ancestors"?: CspDirective;
|
|
22
|
-
"plugin-types"?: CspDirective;
|
|
23
|
-
"base-uri"?: CspDirective;
|
|
24
|
-
[key: string]: CspDirective | undefined | boolean;
|
|
25
|
-
};
|
|
26
|
+
directives: CspDirectives;
|
|
26
27
|
}
|
|
27
28
|
interface HstsOptions {
|
|
28
29
|
maxAge?: number;
|
|
@@ -35,7 +36,7 @@ interface HelmetOptions {
|
|
|
35
36
|
xContentTypeOptions?: false;
|
|
36
37
|
xFrameOptions?: "DENY" | "SAMEORIGIN" | false;
|
|
37
38
|
xXssProtection?: false;
|
|
38
|
-
contentSecurityPolicy?: CspOptions | false;
|
|
39
|
+
contentSecurityPolicy?: CspOptions | false | "default";
|
|
39
40
|
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | false;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
@@ -49,8 +50,9 @@ declare class ServerHelmetProvider {
|
|
|
49
50
|
* the application's configuration phase using `alepha.configure()`.
|
|
50
51
|
*/
|
|
51
52
|
options: HelmetOptions;
|
|
52
|
-
|
|
53
|
-
protected
|
|
53
|
+
protected defaultCspDirectives(): CspDirectives;
|
|
54
|
+
protected buildHeaders(): Record<string, string>;
|
|
55
|
+
protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
54
56
|
}
|
|
55
57
|
//#endregion
|
|
56
58
|
//#region src/index.d.ts
|
|
@@ -61,9 +63,7 @@ declare class ServerHelmetProvider {
|
|
|
61
63
|
* @see {@link ServerHelmetProvider}
|
|
62
64
|
* @module alepha.server.helmet
|
|
63
65
|
*/
|
|
64
|
-
declare const AlephaServerHelmet:
|
|
65
|
-
//# sourceMappingURL=index.d.ts.map
|
|
66
|
-
|
|
66
|
+
declare const AlephaServerHelmet: _alepha_core1.Service<_alepha_core1.Module>;
|
|
67
67
|
//#endregion
|
|
68
|
-
export { AlephaServerHelmet, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
|
|
68
|
+
export { AlephaServerHelmet, CspDirectives, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
|
|
69
69
|
//# sourceMappingURL=index.d.ts.map
|
package/server/links.d.ts
CHANGED
|
@@ -1,33 +1,83 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { Alepha, Descriptor, KIND, Logger } from "alepha";
|
|
1
|
+
import "alepha/server/security";
|
|
2
|
+
import * as _alepha_core2 from "alepha";
|
|
3
|
+
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
5
4
|
import * as _alepha_server0 from "alepha/server";
|
|
6
|
-
import { ActionDescriptor,
|
|
5
|
+
import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry, ServerTimingProvider } from "alepha/server";
|
|
6
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
7
7
|
import * as _alepha_retry0 from "alepha/retry";
|
|
8
8
|
import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
|
|
9
9
|
import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
10
|
-
import * as
|
|
10
|
+
import * as _sinclair_typebox19 from "@sinclair/typebox";
|
|
11
11
|
|
|
12
|
+
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
13
|
+
declare const apiLinkSchema: _sinclair_typebox19.TObject<{
|
|
14
|
+
name: _sinclair_typebox19.TString;
|
|
15
|
+
group: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
16
|
+
path: _sinclair_typebox19.TString;
|
|
17
|
+
method: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
18
|
+
requestBodyType: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
19
|
+
service: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
20
|
+
}>;
|
|
21
|
+
declare const apiLinksResponseSchema: _sinclair_typebox19.TObject<{
|
|
22
|
+
prefix: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
23
|
+
links: _sinclair_typebox19.TArray<_sinclair_typebox19.TObject<{
|
|
24
|
+
name: _sinclair_typebox19.TString;
|
|
25
|
+
group: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
26
|
+
path: _sinclair_typebox19.TString;
|
|
27
|
+
method: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
28
|
+
requestBodyType: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
29
|
+
service: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
30
|
+
}>>;
|
|
31
|
+
}>;
|
|
32
|
+
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
33
|
+
type ApiLink = Static<typeof apiLinkSchema>;
|
|
34
|
+
//#endregion
|
|
12
35
|
//#region src/providers/LinkProvider.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Browser, SSR friendly, service to handle links.
|
|
38
|
+
*/
|
|
13
39
|
declare class LinkProvider {
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
static path: {
|
|
41
|
+
apiLinks: string;
|
|
42
|
+
apiSchema: string;
|
|
43
|
+
};
|
|
44
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
16
45
|
protected readonly alepha: Alepha;
|
|
17
46
|
protected readonly httpClient: HttpClient;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
47
|
+
protected serverLinks: Array<HttpClientLink>;
|
|
48
|
+
/**
|
|
49
|
+
* Get applicative links registered on the server.
|
|
50
|
+
* This does not include lazy-loaded remote links.
|
|
51
|
+
*/
|
|
52
|
+
getServerLinks(): HttpClientLink[];
|
|
53
|
+
/**
|
|
54
|
+
* Register a new link for the application.
|
|
55
|
+
*/
|
|
56
|
+
registerLink(link: HttpClientLink): void;
|
|
57
|
+
get links(): HttpClientLink[];
|
|
58
|
+
/**
|
|
59
|
+
* Force browser to refresh links from the server.
|
|
60
|
+
*/
|
|
61
|
+
fetchLinks(): Promise<HttpClientLink[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Create a virtual client that can be used to call actions.
|
|
64
|
+
*
|
|
65
|
+
* Use js Proxy under the hood.
|
|
66
|
+
*/
|
|
21
67
|
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
22
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Check if a link with the given name exists.
|
|
70
|
+
* @param name
|
|
71
|
+
*/
|
|
72
|
+
can(name: string): boolean;
|
|
23
73
|
/**
|
|
24
74
|
* Resolve a link by its name and call it.
|
|
25
75
|
* - If link is local, it will call the local handler.
|
|
26
76
|
* - If link is remote, it will make a fetch request to the remote server.
|
|
27
77
|
*/
|
|
28
78
|
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
79
|
+
protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
|
|
29
80
|
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
30
|
-
can(name: string): boolean;
|
|
31
81
|
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
32
82
|
}
|
|
33
83
|
interface HttpClientLink extends ApiLink {
|
|
@@ -41,13 +91,13 @@ interface HttpClientLink extends ApiLink {
|
|
|
41
91
|
interface ClientScope {
|
|
42
92
|
group?: string;
|
|
43
93
|
service?: string;
|
|
94
|
+
hostname?: string;
|
|
44
95
|
}
|
|
45
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 };
|
|
46
97
|
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
|
|
47
98
|
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
48
99
|
can: () => boolean;
|
|
49
100
|
}
|
|
50
|
-
//# sourceMappingURL=LinkProvider.d.ts.map
|
|
51
101
|
//#endregion
|
|
52
102
|
//#region src/descriptors/$client.d.ts
|
|
53
103
|
/**
|
|
@@ -57,8 +107,6 @@ declare const $client: {
|
|
|
57
107
|
<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
58
108
|
[KIND]: string;
|
|
59
109
|
};
|
|
60
|
-
//# sourceMappingURL=$client.d.ts.map
|
|
61
|
-
|
|
62
110
|
//#endregion
|
|
63
111
|
//#region src/descriptors/$remote.d.ts
|
|
64
112
|
/**
|
|
@@ -121,83 +169,137 @@ interface RemoteDescriptorOptions {
|
|
|
121
169
|
declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
|
|
122
170
|
get name(): string;
|
|
123
171
|
}
|
|
124
|
-
//# sourceMappingURL=$remote.d.ts.map
|
|
125
172
|
//#endregion
|
|
126
173
|
//#region src/providers/RemoteDescriptorProvider.d.ts
|
|
127
174
|
declare class RemoteDescriptorProvider {
|
|
128
|
-
|
|
129
|
-
|
|
175
|
+
protected readonly env: {
|
|
176
|
+
SERVER_API_PREFIX: string;
|
|
130
177
|
};
|
|
131
178
|
protected readonly alepha: Alepha;
|
|
132
|
-
protected readonly client: LinkProvider;
|
|
133
179
|
protected readonly proxyProvider: ServerProxyProvider;
|
|
180
|
+
protected readonly linkProvider: LinkProvider;
|
|
134
181
|
protected readonly remotes: Array<ServerRemote>;
|
|
135
|
-
protected readonly log: Logger;
|
|
182
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
136
183
|
getRemotes(): ServerRemote[];
|
|
137
|
-
readonly configure:
|
|
138
|
-
readonly start:
|
|
184
|
+
readonly configure: _alepha_core2.HookDescriptor<"configure">;
|
|
185
|
+
readonly start: _alepha_core2.HookDescriptor<"start">;
|
|
139
186
|
registerRemote(value: RemoteDescriptor): Promise<void>;
|
|
140
187
|
protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
141
188
|
}
|
|
142
189
|
interface FetchLinksOptions {
|
|
190
|
+
/**
|
|
191
|
+
* Name of the remote service.
|
|
192
|
+
*/
|
|
143
193
|
service: string;
|
|
194
|
+
/**
|
|
195
|
+
* URL to fetch links from.
|
|
196
|
+
*/
|
|
144
197
|
url: string;
|
|
198
|
+
/**
|
|
199
|
+
* Authorization header containing access token.
|
|
200
|
+
*/
|
|
145
201
|
authorization?: string;
|
|
146
202
|
}
|
|
147
203
|
interface ServerRemote {
|
|
204
|
+
/**
|
|
205
|
+
* URL of the remote service.
|
|
206
|
+
*/
|
|
148
207
|
url: string;
|
|
208
|
+
/**
|
|
209
|
+
* Name of the remote service.
|
|
210
|
+
*/
|
|
149
211
|
name: string;
|
|
212
|
+
/**
|
|
213
|
+
* Expose links as endpoint. It's not only internal.
|
|
214
|
+
*/
|
|
150
215
|
proxy: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* It's only used inside the application.
|
|
218
|
+
*/
|
|
151
219
|
internal: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Links fetcher.
|
|
222
|
+
*/
|
|
152
223
|
links: (args: {
|
|
153
224
|
authorization?: string;
|
|
154
225
|
}) => Promise<ApiLinksResponse>;
|
|
226
|
+
/**
|
|
227
|
+
* Fetches schema for the remote service.
|
|
228
|
+
*/
|
|
155
229
|
schema: (args: {
|
|
156
230
|
name: string;
|
|
157
231
|
authorization?: string;
|
|
158
232
|
}) => Promise<any>;
|
|
233
|
+
/**
|
|
234
|
+
* Force a default access token provider when not provided.
|
|
235
|
+
*/
|
|
159
236
|
serviceAccount?: ServiceAccountDescriptor;
|
|
237
|
+
/**
|
|
238
|
+
* Prefix for the remote service links.
|
|
239
|
+
*/
|
|
160
240
|
prefix: string;
|
|
161
241
|
}
|
|
162
|
-
//# sourceMappingURL=RemoteDescriptorProvider.d.ts.map
|
|
163
242
|
//#endregion
|
|
164
243
|
//#region src/providers/ServerLinksProvider.d.ts
|
|
165
244
|
declare class ServerLinksProvider {
|
|
245
|
+
protected readonly env: {
|
|
246
|
+
SERVER_API_PREFIX: string;
|
|
247
|
+
};
|
|
166
248
|
protected readonly alepha: Alepha;
|
|
167
|
-
protected readonly
|
|
249
|
+
protected readonly linkProvider: LinkProvider;
|
|
168
250
|
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
169
|
-
readonly
|
|
251
|
+
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
252
|
+
get prefix(): string;
|
|
253
|
+
readonly onRoute: _alepha_core2.HookDescriptor<"configure">;
|
|
254
|
+
/**
|
|
255
|
+
* First API - Get all API links for the user.
|
|
256
|
+
*
|
|
257
|
+
* This is based on the user's permissions.
|
|
258
|
+
*/
|
|
170
259
|
readonly links: _alepha_server0.RouteDescriptor<{
|
|
171
|
-
response:
|
|
172
|
-
prefix:
|
|
173
|
-
links:
|
|
174
|
-
name:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
requestBodyType:
|
|
179
|
-
service:
|
|
260
|
+
response: _sinclair_typebox19.TObject<{
|
|
261
|
+
prefix: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
262
|
+
links: _sinclair_typebox19.TArray<_sinclair_typebox19.TObject<{
|
|
263
|
+
name: _sinclair_typebox19.TString;
|
|
264
|
+
group: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
265
|
+
path: _sinclair_typebox19.TString;
|
|
266
|
+
method: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
267
|
+
requestBodyType: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
268
|
+
service: _sinclair_typebox19.TOptional<_sinclair_typebox19.TString>;
|
|
180
269
|
}>>;
|
|
181
270
|
}>;
|
|
182
271
|
}>;
|
|
272
|
+
/**
|
|
273
|
+
* Second API - Get schema for a specific API link.
|
|
274
|
+
*
|
|
275
|
+
* Note: Body/Response schema are not included in `links` API because it's TOO BIG.
|
|
276
|
+
* I mean for 150+ links, you got 50ms of serialization time.
|
|
277
|
+
*/
|
|
183
278
|
readonly schema: _alepha_server0.RouteDescriptor<{
|
|
184
|
-
params:
|
|
185
|
-
name:
|
|
279
|
+
params: _sinclair_typebox19.TObject<{
|
|
280
|
+
name: _sinclair_typebox19.TString;
|
|
186
281
|
}>;
|
|
187
|
-
response:
|
|
282
|
+
response: _sinclair_typebox19.TRecord<_sinclair_typebox19.TString, _sinclair_typebox19.TAny>;
|
|
188
283
|
}>;
|
|
189
|
-
|
|
284
|
+
getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
|
|
285
|
+
/**
|
|
286
|
+
* Retrieves API links for the user based on their permissions.
|
|
287
|
+
* Will check on local links and remote links.
|
|
288
|
+
*/
|
|
289
|
+
getUserApiLinks(options: GetApiLinksOptions): Promise<ApiLinksResponse>;
|
|
190
290
|
}
|
|
191
|
-
interface
|
|
291
|
+
interface GetApiLinksOptions {
|
|
192
292
|
user?: UserAccountToken;
|
|
193
293
|
authorization?: string;
|
|
194
294
|
}
|
|
195
|
-
//# sourceMappingURL=ServerLinksProvider.d.ts.map
|
|
196
295
|
//#endregion
|
|
197
296
|
//#region src/index.d.ts
|
|
198
|
-
declare
|
|
199
|
-
|
|
200
|
-
|
|
297
|
+
declare module "alepha" {
|
|
298
|
+
interface State {
|
|
299
|
+
api?: ApiLinksResponse;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
declare const AlephaServerLinks: _alepha_core2.Service<_alepha_core2.Module>;
|
|
201
303
|
//#endregion
|
|
202
|
-
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions,
|
|
304
|
+
export { $client, $remote, AlephaServerLinks, ApiLink, ApiLinksResponse, ClientScope, FetchLinksOptions, GetApiLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction, apiLinkSchema, apiLinksResponseSchema };
|
|
203
305
|
//# sourceMappingURL=index.d.ts.map
|
package/server/metrics.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as _alepha_core0 from "alepha";
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
3
2
|
import { Alepha } from "alepha";
|
|
4
3
|
import * as _alepha_server0 from "alepha/server";
|
|
5
4
|
import { Histogram, Registry } from "prom-client";
|
|
@@ -11,9 +10,9 @@ declare class ServerMetricsProvider {
|
|
|
11
10
|
protected httpRequestDuration?: Histogram<string>;
|
|
12
11
|
readonly options: ServerMetricsProviderOptions;
|
|
13
12
|
readonly metrics: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
14
|
-
protected readonly onStart:
|
|
15
|
-
protected readonly onRequest:
|
|
16
|
-
protected readonly onResponse:
|
|
13
|
+
protected readonly onStart: _alepha_core1.HookDescriptor<"start">;
|
|
14
|
+
protected readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
15
|
+
protected readonly onResponse: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
17
16
|
}
|
|
18
17
|
interface ServerMetricsProviderOptions {
|
|
19
18
|
prefix?: string;
|
|
@@ -21,7 +20,6 @@ interface ServerMetricsProviderOptions {
|
|
|
21
20
|
eventLoopMonitoringPrecision?: number;
|
|
22
21
|
labels?: object;
|
|
23
22
|
}
|
|
24
|
-
//# sourceMappingURL=ServerMetricsProvider.d.ts.map
|
|
25
23
|
//#endregion
|
|
26
24
|
//#region src/index.d.ts
|
|
27
25
|
/**
|
|
@@ -31,9 +29,7 @@ interface ServerMetricsProviderOptions {
|
|
|
31
29
|
* @see {@link ServerMetricsProvider}
|
|
32
30
|
* @module alepha.server.metrics
|
|
33
31
|
*/
|
|
34
|
-
declare const AlephaServerMetrics:
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
|
36
|
-
|
|
32
|
+
declare const AlephaServerMetrics: _alepha_core1.Service<_alepha_core1.Module>;
|
|
37
33
|
//#endregion
|
|
38
34
|
export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
|
|
39
35
|
//# sourceMappingURL=index.d.ts.map
|