alepha 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache/redis.cjs +4 -8
- package/cache/redis.d.ts +28 -89
- package/cache/redis.js +1 -1
- package/cache.cjs +4 -8
- package/cache.d.ts +189 -265
- package/cache.js +1 -1
- package/core.cjs +4 -8
- package/core.d.ts +951 -929
- package/core.js +1 -1
- package/datetime.cjs +4 -8
- package/datetime.d.ts +151 -146
- package/datetime.js +1 -1
- package/lock/redis.cjs +7 -49
- package/lock/redis.d.ts +15 -12
- package/lock/redis.js +1 -47
- package/lock.cjs +4 -8
- package/lock.d.ts +117 -170
- package/lock.js +1 -1
- package/package.json +105 -39
- package/postgres.cjs +4 -8
- package/postgres.d.ts +1410 -4433
- package/postgres.js +1 -1
- package/queue/redis.cjs +8 -0
- package/queue/redis.d.ts +31 -0
- package/queue/redis.js +1 -0
- package/queue.cjs +4 -8
- package/queue.d.ts +162 -205
- package/queue.js +1 -1
- package/react/auth.cjs +4 -8
- package/react/auth.d.ts +161 -282
- package/react/auth.js +1 -1
- package/react/head.cjs +8 -0
- package/react/head.d.ts +86 -0
- package/react/head.js +1 -0
- package/react.cjs +4 -8
- package/react.d.ts +468 -559
- package/react.js +1 -1
- package/redis.cjs +4 -8
- package/redis.d.ts +59 -132
- package/redis.js +1 -1
- package/retry.cjs +4 -8
- package/retry.d.ts +34 -31
- package/retry.js +1 -1
- package/scheduler.cjs +4 -8
- package/scheduler.d.ts +124 -182
- package/scheduler.js +1 -1
- package/security.cjs +4 -8
- package/security.d.ts +459 -595
- package/security.js +1 -1
- package/server/cache.cjs +4 -8
- package/server/cache.d.ts +43 -40
- package/server/cache.js +1 -1
- package/server/cookies.cjs +4 -8
- package/server/cookies.d.ts +49 -41
- package/server/cookies.js +1 -1
- package/server/cors.cjs +8 -0
- package/server/cors.d.ts +25 -0
- package/server/cors.js +1 -0
- package/server/health.cjs +8 -0
- package/server/health.d.ts +42 -0
- package/server/health.js +1 -0
- package/server/links.cjs +8 -0
- package/server/links.d.ts +188 -0
- package/server/links.js +1 -0
- package/server/proxy.cjs +8 -0
- package/server/proxy.d.ts +41 -0
- package/server/proxy.js +1 -0
- package/server/static.cjs +4 -8
- package/server/static.d.ts +98 -95
- package/server/static.js +1 -1
- package/server/swagger.cjs +4 -8
- package/server/swagger.d.ts +96 -92
- package/server/swagger.js +1 -1
- package/server.cjs +4 -8
- package/server.d.ts +602 -1087
- package/server.js +1 -1
- package/testing.cjs +8 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/topic/redis.cjs +8 -0
- package/topic/redis.d.ts +45 -0
- package/topic/redis.js +1 -0
- package/topic.cjs +4 -8
- package/topic.d.ts +161 -169
- package/topic.js +1 -1
- package/vite.cjs +4 -8
- package/vite.d.ts +89 -82
- package/vite.js +1 -1
- package/src/cache/redis.ts +0 -1
- package/src/cache.ts +0 -1
- package/src/core.ts +0 -1
- package/src/datetime.ts +0 -1
- package/src/lock/redis.ts +0 -1
- package/src/lock.ts +0 -1
- package/src/postgres.ts +0 -1
- package/src/queue/redis.ts +0 -1
- package/src/queue.ts +0 -1
- package/src/react/auth.ts +0 -1
- package/src/react.ts +0 -1
- package/src/redis.ts +0 -1
- package/src/retry.ts +0 -1
- package/src/scheduler.ts +0 -1
- package/src/security.ts +0 -1
- package/src/server/cache.ts +0 -1
- package/src/server/cookies.ts +0 -1
- package/src/server/static.ts +0 -1
- package/src/server/swagger.ts +0 -1
- package/src/server.ts +0 -1
- package/src/topic/redis.ts +0 -1
- package/src/topic.ts +0 -1
- package/src/vite.ts +0 -1
package/security.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '@alepha/security'
|
|
1
|
+
export * from '@alepha/security'
|
package/server/cache.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(serverCache).forEach(function (k) {
|
|
2
|
+
var m = require('@alepha/server-cache');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
8
4
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
5
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
6
|
+
get: function () { return m[k]; }
|
|
11
7
|
});
|
|
12
|
-
});
|
|
8
|
+
});
|
package/server/cache.d.ts
CHANGED
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Cache, CacheDescriptorOptions, CacheDescriptorProvider } from "@alepha/cache";
|
|
2
|
+
import { ServerHandler, ServerRequestConfig } from "@alepha/server";
|
|
3
|
+
import * as _alepha_core1 from "@alepha/core";
|
|
4
|
+
import { Alepha, Module, OPTIONS } from "@alepha/core";
|
|
5
|
+
import { DateTimeProvider, DurationLike } from "@alepha/datetime";
|
|
6
6
|
|
|
7
|
+
//#region src/providers/ServerCacheProvider.d.ts
|
|
7
8
|
declare module "alepha/server" {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
interface ServerRoute {
|
|
10
|
+
cache?: ServerRouteCache;
|
|
11
|
+
}
|
|
12
|
+
interface ActionDescriptor {
|
|
13
|
+
invalidate: () => Promise<void>;
|
|
14
|
+
}
|
|
14
15
|
}
|
|
15
16
|
declare class ServerCacheProvider {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
protected readonly log: _alepha_core1.Logger;
|
|
18
|
+
protected readonly alepha: Alepha;
|
|
19
|
+
protected readonly cacheProvider: CacheDescriptorProvider;
|
|
20
|
+
protected readonly time: DateTimeProvider;
|
|
21
|
+
protected readonly caches: Map<ServerHandler, RouteCache>;
|
|
22
|
+
readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
|
|
23
|
+
readonly onRoute: _alepha_core1.HookDescriptor<"server:onRoute">;
|
|
24
|
+
readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
25
|
+
readonly onSend: _alepha_core1.HookDescriptor<"server:onResponse">;
|
|
26
|
+
generateETag(content: string): string;
|
|
27
|
+
invalidate(route: RouteLike): Promise<void>;
|
|
28
|
+
protected getCacheByRoute(route: RouteLike): RouteCache | undefined;
|
|
29
|
+
protected createCacheKey(args: ServerRequestConfig): string;
|
|
29
30
|
}
|
|
30
31
|
type ServerRouteCache = boolean | DurationLike | Omit<CacheDescriptorOptions<any>, "handler" | "key">;
|
|
31
32
|
type RouteCache = Cache<{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
contentType?: string;
|
|
34
|
+
body: string;
|
|
35
|
+
status?: number;
|
|
36
|
+
lastModified: string;
|
|
37
|
+
hash: string;
|
|
37
38
|
}>;
|
|
38
39
|
type RouteLike = {
|
|
39
|
-
|
|
40
|
-
handler?: ServerHandler;
|
|
41
|
-
};
|
|
42
|
-
} | {
|
|
40
|
+
[OPTIONS]: {
|
|
43
41
|
handler?: ServerHandler;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
handler?: ServerHandler;
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/index.d.ts
|
|
46
48
|
/**
|
|
47
49
|
* # Alepha Server Cache Module
|
|
48
50
|
*
|
|
@@ -53,8 +55,8 @@ type RouteLike = {
|
|
|
53
55
|
*
|
|
54
56
|
* @example
|
|
55
57
|
* ```ts
|
|
56
|
-
* import { Alepha } from "
|
|
57
|
-
* import { $action } from "
|
|
58
|
+
* import { Alepha } from "alepha";
|
|
59
|
+
* import { $action } from "alepha/server";
|
|
58
60
|
* import { AlephaServerCache } from "alepha/server/cache";
|
|
59
61
|
*
|
|
60
62
|
* class ApiServer {
|
|
@@ -75,8 +77,9 @@ type RouteLike = {
|
|
|
75
77
|
* @module alepha.server.cache
|
|
76
78
|
*/
|
|
77
79
|
declare class AlephaServerCache implements Module {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
readonly name = "alepha.server.cache";
|
|
81
|
+
readonly $services: (alepha: Alepha) => Alepha;
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
export { AlephaServerCache, ServerCacheProvider,
|
|
83
|
+
//#endregion
|
|
84
|
+
export { AlephaServerCache, ServerCacheProvider, ServerRouteCache };
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '@alepha/server-cache'
|
|
1
|
+
export * from '@alepha/server-cache'
|
package/server/cookies.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(serverCookies).forEach(function (k) {
|
|
2
|
+
var m = require('@alepha/server-cookies');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
8
4
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
5
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
6
|
+
get: function () { return m[k]; }
|
|
11
7
|
});
|
|
12
|
-
});
|
|
8
|
+
});
|
package/server/cookies.d.ts
CHANGED
|
@@ -1,56 +1,64 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import { DurationLike } from
|
|
1
|
+
import * as _alepha_core1 from "@alepha/core";
|
|
2
|
+
import { KIND, OPTIONS, Static, TSchema } from "@alepha/core";
|
|
3
|
+
import { DurationLike } from "@alepha/datetime";
|
|
4
4
|
|
|
5
|
+
//#region src/descriptors/$cookie.d.ts
|
|
5
6
|
interface CookieDescriptorOptions<T extends TSchema> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
schema: T;
|
|
8
|
+
name: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
ttl?: DurationLike;
|
|
11
|
+
secure?: boolean;
|
|
12
|
+
httpOnly?: boolean;
|
|
13
|
+
sameSite?: "strict" | "lax" | "none";
|
|
14
|
+
domain?: string;
|
|
15
|
+
compress?: boolean;
|
|
16
|
+
encrypt?: boolean;
|
|
17
|
+
sign?: boolean;
|
|
17
18
|
}
|
|
18
19
|
interface CookieDescriptor<T extends TSchema> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
[KIND]: "COOKIE";
|
|
21
|
+
[OPTIONS]: CookieDescriptorOptions<T>;
|
|
22
|
+
set: (cookies: Cookies, value: Static<T>) => void;
|
|
23
|
+
get: (cookies: Cookies) => Static<T> | undefined;
|
|
24
|
+
del: (cookies: Cookies) => void;
|
|
24
25
|
}
|
|
25
26
|
declare const $cookie: {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
<T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
|
|
28
|
+
[KIND]: string;
|
|
28
29
|
};
|
|
29
30
|
interface Cookies {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
req: Record<string, string>;
|
|
32
|
+
res: Record<string, Cookie | null>;
|
|
32
33
|
}
|
|
33
34
|
interface Cookie {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
value: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
maxAge?: number;
|
|
38
|
+
secure?: boolean;
|
|
39
|
+
httpOnly?: boolean;
|
|
40
|
+
sameSite?: "strict" | "lax" | "none";
|
|
41
|
+
domain?: string;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/providers/ServerCookiesProvider.d.ts
|
|
43
45
|
declare class ServerCookiesProvider {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
readonly onRequest: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
47
|
+
readonly onSend: _alepha_core1.HookDescriptor<"server:onSend">;
|
|
48
|
+
fromHeader(header: string): Record<string, string>;
|
|
49
|
+
toHeader(cookies: Record<string, Cookie | null>, isHttps?: boolean): string[];
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/index.d.ts
|
|
50
53
|
declare module "alepha/server" {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
interface ServerRequest {
|
|
55
|
+
cookies: Cookies;
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
declare class AlephaServerCookies {
|
|
59
|
+
readonly name = "alepha.server.cookies";
|
|
60
|
+
readonly $services: (alepha: any) => void;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/cookies.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '@alepha/server-cookies'
|
|
1
|
+
export * from '@alepha/server-cookies'
|
package/server/cors.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-cors');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
package/server/cors.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as _alepha_core0 from "@alepha/core";
|
|
2
|
+
import { Alepha, Module } from "@alepha/core";
|
|
3
|
+
|
|
4
|
+
//#region src/providers/ServerCorsProvider.d.ts
|
|
5
|
+
declare class ServerCorsProvider {
|
|
6
|
+
options: CorsOptions;
|
|
7
|
+
protected readonly onRequest: _alepha_core0.HookDescriptor<"server:onRequest">;
|
|
8
|
+
isOriginAllowed(origin: string | undefined, allowed: CorsOptions["origin"]): boolean;
|
|
9
|
+
}
|
|
10
|
+
interface CorsOptions {
|
|
11
|
+
origin?: string | string[] | ((origin: string | undefined) => boolean);
|
|
12
|
+
methods: string[];
|
|
13
|
+
headers: string[];
|
|
14
|
+
credentials?: boolean;
|
|
15
|
+
maxAge?: number;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/index.d.ts
|
|
19
|
+
declare class AlephaServerCors implements Module {
|
|
20
|
+
readonly name = "alepha.server.cors";
|
|
21
|
+
readonly $services: (alepha: Alepha) => void;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { AlephaServerCors, CorsOptions, ServerCorsProvider };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/cors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-cors'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-health');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as _alepha_server5 from "@alepha/server";
|
|
2
|
+
import { Alepha } from "@alepha/core";
|
|
3
|
+
import { DateTimeProvider } from "@alepha/datetime";
|
|
4
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
5
|
+
|
|
6
|
+
//#region src/providers/ServerHealthProvider.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Register `/health` endpoint.
|
|
10
|
+
*
|
|
11
|
+
* - Provides basic health information about the server.
|
|
12
|
+
*/
|
|
13
|
+
declare class ServerHealthProvider {
|
|
14
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
15
|
+
protected readonly alepha: Alepha;
|
|
16
|
+
readonly health: _alepha_server5.RouteDescriptor<{
|
|
17
|
+
response: _sinclair_typebox0.TObject<{
|
|
18
|
+
message: _sinclair_typebox0.TString;
|
|
19
|
+
uptime: _sinclair_typebox0.TNumber;
|
|
20
|
+
date: _sinclair_typebox0.TString;
|
|
21
|
+
ready: _sinclair_typebox0.TBoolean;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/index.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* Alepha Server Health Module
|
|
29
|
+
*
|
|
30
|
+
* @description
|
|
31
|
+
* Plugin for Alepha Server that provides health-check endpoints.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link ServerHealthProvider}
|
|
34
|
+
* @module alepha.server.health
|
|
35
|
+
*/
|
|
36
|
+
declare class AlephaServerHealth {
|
|
37
|
+
readonly name = "alepha.server.health";
|
|
38
|
+
readonly $services: (alepha: any) => void;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { AlephaServerHealth, ServerHealthProvider };
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/health.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-health'
|
package/server/links.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-links');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as _alepha_core23 from "@alepha/core";
|
|
2
|
+
import * as _alepha_core24 from "@alepha/core";
|
|
3
|
+
import * as _alepha_core0 from "@alepha/core";
|
|
4
|
+
import { Alepha, KIND, Module, OPTIONS } from "@alepha/core";
|
|
5
|
+
import * as _alepha_server16 from "@alepha/server";
|
|
6
|
+
import { ActionDescriptor, ActionDescriptorHelper, ApiLink, ApiLinksResponse, ClientRequestOptions, FetchResponse, HttpClient, RequestConfigSchema, ServerActionDescriptorProvider, ServerHandler, ServerRemote, ServerRequestConfigEntry } from "@alepha/server";
|
|
7
|
+
import * as _alepha_retry27 from "@alepha/retry";
|
|
8
|
+
import { ProxyDescriptorOptions, ProxyDescriptorProvider } from "@alepha/server-proxy";
|
|
9
|
+
import { ServiceAccountDescriptor, UserAccountToken } from "@alepha/security";
|
|
10
|
+
import * as _sinclair_typebox1 from "@sinclair/typebox";
|
|
11
|
+
|
|
12
|
+
//#region src/providers/LinkProvider.d.ts
|
|
13
|
+
declare class LinkProvider {
|
|
14
|
+
readonly URL_LINKS = "/api/_links";
|
|
15
|
+
protected readonly log: _alepha_core23.Logger;
|
|
16
|
+
protected readonly alepha: Alepha;
|
|
17
|
+
protected readonly httpClient: HttpClient;
|
|
18
|
+
links?: Array<HttpClientLink>;
|
|
19
|
+
pushLink(link: HttpClientLink): void;
|
|
20
|
+
getLinks(force?: boolean): Promise<HttpClientLink[]>;
|
|
21
|
+
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a link by its name and call it.
|
|
24
|
+
* - If link is local, it will call the local handler.
|
|
25
|
+
* - If link is remote, it will make a fetch request to the remote server.
|
|
26
|
+
*/
|
|
27
|
+
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
28
|
+
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
29
|
+
can(name: string): boolean;
|
|
30
|
+
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
31
|
+
}
|
|
32
|
+
interface HttpClientLink extends ApiLink {
|
|
33
|
+
secured?: boolean;
|
|
34
|
+
prefix?: string;
|
|
35
|
+
host?: string;
|
|
36
|
+
service?: string;
|
|
37
|
+
schema?: RequestConfigSchema;
|
|
38
|
+
handler?: ServerHandler;
|
|
39
|
+
}
|
|
40
|
+
interface ClientScope {
|
|
41
|
+
group?: string;
|
|
42
|
+
service?: string;
|
|
43
|
+
}
|
|
44
|
+
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
|
|
45
|
+
can: () => boolean;
|
|
46
|
+
schema: Schema;
|
|
47
|
+
} : never };
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/descriptors/$client.d.ts
|
|
50
|
+
declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/descriptors/$remote.d.ts
|
|
53
|
+
declare const KEY = "REMOTE";
|
|
54
|
+
interface RemoteDescriptorOptions {
|
|
55
|
+
/**
|
|
56
|
+
* The URL of the remote service.
|
|
57
|
+
* You can use a function to generate the URL dynamically.
|
|
58
|
+
* You probably should use $inject(env) to get the URL from the environment.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { $remote } from "@alepha/server";
|
|
63
|
+
* import { $inject, t } from "@alepha/core";
|
|
64
|
+
*
|
|
65
|
+
* class App {
|
|
66
|
+
* env = $inject(t.object({
|
|
67
|
+
* REMOTE_URL: t.string({default: "http://localhost:3000"}),
|
|
68
|
+
* }));
|
|
69
|
+
* remote = $remote({
|
|
70
|
+
* url: this.env.REMOTE_URL,
|
|
71
|
+
* });
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
url: string | (() => string);
|
|
76
|
+
/**
|
|
77
|
+
* The name of the remote service.
|
|
78
|
+
*
|
|
79
|
+
* @default Member of the class containing the remote service.
|
|
80
|
+
*/
|
|
81
|
+
name?: string;
|
|
82
|
+
/**
|
|
83
|
+
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
84
|
+
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
85
|
+
*/
|
|
86
|
+
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
87
|
+
/**
|
|
88
|
+
* If true, the remote service won't be available internally, only through the proxy.
|
|
89
|
+
*/
|
|
90
|
+
noInternal: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* For communication between the server and the remote service with a security layer.
|
|
94
|
+
* This will be used for internal communication and will not be exposed to the client.
|
|
95
|
+
*/
|
|
96
|
+
serviceAccount?: ServiceAccountDescriptor;
|
|
97
|
+
}
|
|
98
|
+
interface RemoteDescriptor {
|
|
99
|
+
[KIND]: typeof KEY;
|
|
100
|
+
[OPTIONS]: RemoteDescriptorOptions;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* $remote is a descriptor that allows you to define a remote service access.
|
|
104
|
+
*
|
|
105
|
+
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
106
|
+
*
|
|
107
|
+
* All remote services can be exposed as actions, ... or not.
|
|
108
|
+
*
|
|
109
|
+
* You can add a service account if you want to use a security layer.
|
|
110
|
+
*/
|
|
111
|
+
declare const $remote: {
|
|
112
|
+
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
113
|
+
[KIND]: string;
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/providers/RemoteDescriptorProvider.d.ts
|
|
117
|
+
declare class RemoteDescriptorProvider {
|
|
118
|
+
static path: {
|
|
119
|
+
apiLinks: string;
|
|
120
|
+
};
|
|
121
|
+
protected readonly alepha: Alepha;
|
|
122
|
+
protected readonly client: LinkProvider;
|
|
123
|
+
protected readonly proxyProvider: ProxyDescriptorProvider;
|
|
124
|
+
protected readonly remotes: Array<ServerRemote>;
|
|
125
|
+
protected readonly log: _alepha_core24.Logger;
|
|
126
|
+
getRemotes(): ServerRemote[];
|
|
127
|
+
readonly configure: _alepha_core24.HookDescriptor<"configure">;
|
|
128
|
+
readonly start: _alepha_core24.HookDescriptor<"start">;
|
|
129
|
+
registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
|
|
130
|
+
protected readonly fetchLinks: _alepha_retry27.RetryDescriptor<(opts: {
|
|
131
|
+
service: string;
|
|
132
|
+
url: string;
|
|
133
|
+
authorization?: string;
|
|
134
|
+
}) => Promise<{
|
|
135
|
+
prefix?: string | undefined;
|
|
136
|
+
links: {
|
|
137
|
+
method?: string | undefined;
|
|
138
|
+
group?: string | undefined;
|
|
139
|
+
requestBodyType?: string | undefined;
|
|
140
|
+
service?: string | undefined;
|
|
141
|
+
name: string;
|
|
142
|
+
path: string;
|
|
143
|
+
}[];
|
|
144
|
+
}>>;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/providers/ServerLinksProvider.d.ts
|
|
148
|
+
declare class ServerLinksProvider {
|
|
149
|
+
protected readonly alepha: Alepha;
|
|
150
|
+
protected readonly client: LinkProvider;
|
|
151
|
+
protected readonly helper: ActionDescriptorHelper;
|
|
152
|
+
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
153
|
+
protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
|
|
154
|
+
readonly onRoute: _alepha_core0.HookDescriptor<"server:onRoute">;
|
|
155
|
+
readonly links: _alepha_server16.RouteDescriptor<{
|
|
156
|
+
response: _sinclair_typebox1.TObject<{
|
|
157
|
+
prefix: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
158
|
+
links: _sinclair_typebox1.TArray<_sinclair_typebox1.TObject<{
|
|
159
|
+
name: _sinclair_typebox1.TString;
|
|
160
|
+
path: _sinclair_typebox1.TString;
|
|
161
|
+
method: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
162
|
+
group: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
163
|
+
requestBodyType: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
164
|
+
service: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
165
|
+
}>>;
|
|
166
|
+
}>;
|
|
167
|
+
}>;
|
|
168
|
+
readonly schema: _alepha_server16.RouteDescriptor<{
|
|
169
|
+
params: _sinclair_typebox1.TObject<{
|
|
170
|
+
name: _sinclair_typebox1.TString;
|
|
171
|
+
}>;
|
|
172
|
+
response: _sinclair_typebox1.TRecord<_sinclair_typebox1.TString, _sinclair_typebox1.TAny>;
|
|
173
|
+
}>;
|
|
174
|
+
getLinks(options: GetLinksOptions): Promise<ApiLinksResponse>;
|
|
175
|
+
}
|
|
176
|
+
interface GetLinksOptions {
|
|
177
|
+
user?: UserAccountToken;
|
|
178
|
+
authorization?: string;
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/index.d.ts
|
|
182
|
+
declare class AlephaServerLinks implements Module {
|
|
183
|
+
readonly name = "alepha.server.links";
|
|
184
|
+
readonly $services: (alepha: Alepha) => void;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
export { $client, $remote, AlephaServerLinks, ClientScope, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
|
|
188
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/links.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-links'
|
package/server/proxy.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/server-proxy');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as _alepha_core0 from "@alepha/core";
|
|
2
|
+
import { Alepha, Async, KIND, Module, OPTIONS } from "@alepha/core";
|
|
3
|
+
import { ServerHandler, ServerRequest, ServerRouterProvider } from "@alepha/server";
|
|
4
|
+
|
|
5
|
+
//#region src/descriptors/$proxy.d.ts
|
|
6
|
+
type ProxyDescriptorOptions = {
|
|
7
|
+
path: string;
|
|
8
|
+
target: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
11
|
+
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
12
|
+
rewrite?: (url: URL) => void;
|
|
13
|
+
};
|
|
14
|
+
interface ProxyDescriptor {
|
|
15
|
+
[KIND]: "PROXY";
|
|
16
|
+
[OPTIONS]: ProxyDescriptorOptions;
|
|
17
|
+
}
|
|
18
|
+
declare const $proxy: {
|
|
19
|
+
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
20
|
+
[KIND]: string;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/providers/ProxyDescriptorProvider.d.ts
|
|
24
|
+
declare class ProxyDescriptorProvider {
|
|
25
|
+
protected readonly log: _alepha_core0.Logger;
|
|
26
|
+
protected readonly routerProvider: ServerRouterProvider;
|
|
27
|
+
protected readonly alepha: Alepha;
|
|
28
|
+
readonly configure: _alepha_core0.HookDescriptor<"configure">;
|
|
29
|
+
createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
30
|
+
proxy(options: ProxyDescriptorOptions): Promise<void>;
|
|
31
|
+
private getRawRequestBody;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/index.d.ts
|
|
35
|
+
declare class AlephaServerProxy implements Module {
|
|
36
|
+
readonly name = "alepha.server.proxy";
|
|
37
|
+
readonly $services: (alepha: Alepha) => void;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { $proxy, AlephaServerProxy, ProxyDescriptor, ProxyDescriptorOptions, ProxyDescriptorProvider };
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
package/server/proxy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/server-proxy'
|
package/server/static.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(serverStatic).forEach(function (k) {
|
|
2
|
+
var m = require('@alepha/server-static');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
8
4
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
5
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
6
|
+
get: function () { return m[k]; }
|
|
11
7
|
});
|
|
12
|
-
});
|
|
8
|
+
});
|