alepha 0.8.0 → 0.9.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.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
@@ -1,8 +1,53 @@
1
- import { Alepha, HookDescriptor, KIND, Logger, Module, OPTIONS, Static, TObject, TOptional, TSchema, TString } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha, Descriptor, KIND, Static, TSchema } from "alepha";
2
4
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
3
5
 
6
+ //#region src/providers/ServerCookiesProvider.d.ts
7
+ declare const envSchema: _alepha_core0$1.TObject<{
8
+ /**
9
+ * A 32-byte secret key used for cookie encryption and signing. MUST be set for `encrypt` or `sign` to work.
10
+ */
11
+ COOKIE_SECRET: _alepha_core0$1.TOptional<_alepha_core0$1.TString>;
12
+ }>;
13
+ declare module "alepha" {
14
+ interface Env extends Partial<Static<typeof envSchema>> {}
15
+ }
16
+ declare class ServerCookiesProvider {
17
+ protected readonly alepha: Alepha;
18
+ protected readonly log: _alepha_core0$1.Logger;
19
+ protected readonly env: {
20
+ COOKIE_SECRET?: string | undefined;
21
+ };
22
+ protected readonly dateTimeProvider: DateTimeProvider;
23
+ protected readonly ALGORITHM = "aes-256-gcm";
24
+ protected readonly IV_LENGTH = 16;
25
+ protected readonly AUTH_TAG_LENGTH = 16;
26
+ protected readonly SIGNATURE_LENGTH = 32;
27
+ readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
28
+ readonly onSend: _alepha_core0$1.HookDescriptor<"server:onSend">;
29
+ protected getCookiesFromContext(cookies?: Cookies): Cookies;
30
+ getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
31
+ setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
32
+ deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
33
+ protected encrypt(text: string): string;
34
+ protected decrypt(encryptedText: string): string;
35
+ secretKey(): string;
36
+ 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
+ }
40
+ //#endregion
4
41
  //#region src/descriptors/$cookie.d.ts
5
- declare const KEY = "COOKIE";
42
+ /**
43
+ * Declares a type-safe, configurable HTTP cookie.
44
+ * This descriptor provides methods to get, set, and delete the cookie
45
+ * within the server request/response cycle.
46
+ */
47
+ declare const $cookie: {
48
+ <T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
49
+ [KIND]: typeof CookieDescriptor;
50
+ };
6
51
  interface CookieDescriptorOptions<T extends TSchema> {
7
52
  /** The schema for the cookie's value, used for validation and type safety. */
8
53
  schema: T;
@@ -27,33 +72,22 @@ interface CookieDescriptorOptions<T extends TSchema> {
27
72
  /** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
28
73
  sign?: boolean;
29
74
  }
30
- interface CookieDescriptor<T extends TSchema> {
31
- [KIND]: typeof KEY;
32
- [OPTIONS]: CookieDescriptorOptions<T>;
33
- schema: T;
75
+ declare class CookieDescriptor<T extends TSchema> extends Descriptor<CookieDescriptorOptions<T>> {
76
+ protected readonly serverCookiesProvider: ServerCookiesProvider;
77
+ get name(): string;
34
78
  /** Sets the cookie with the given value in the current request's response. */
35
- set: (value: Static<T>, options?: {
79
+ set(value: Static<T>, options?: {
36
80
  cookies?: Cookies;
37
- }) => void;
81
+ }): void;
38
82
  /** Gets the cookie value from the current request. Returns undefined if not found or invalid. */
39
- get: (options?: {
83
+ get(options?: {
40
84
  cookies?: Cookies;
41
- }) => Static<T> | undefined;
85
+ }): Static<T> | undefined;
42
86
  /** Deletes the cookie in the current request's response. */
43
- del: (options?: {
87
+ del(options?: {
44
88
  cookies?: Cookies;
45
- }) => void;
89
+ }): void;
46
90
  }
47
- /**
48
- * Declares a type-safe, configurable HTTP cookie.
49
- * This descriptor provides methods to get, set, and delete the cookie
50
- * within the server request/response cycle.
51
- */
52
- declare const $cookie: {
53
- <T extends TSchema>(options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
54
- [KIND]: string;
55
- };
56
- // ---------------------------------------------------------------------------------------------------------------------
57
91
  interface Cookies {
58
92
  req: Record<string, string>;
59
93
  res: Record<string, Cookie | null>;
@@ -67,52 +101,27 @@ interface Cookie {
67
101
  sameSite?: "strict" | "lax" | "none";
68
102
  domain?: string;
69
103
  }
70
- //#endregion
71
- //#region src/providers/ServerCookiesProvider.d.ts
72
- declare const envSchema: TObject<{
73
- COOKIE_SECRET: TOptional<TString>;
74
- }>;
75
- declare module "alepha" {
76
- interface Env extends Partial<Static<typeof envSchema>> {}
77
- }
78
- declare class ServerCookiesProvider {
79
- protected readonly alepha: Alepha;
80
- protected readonly log: Logger;
81
- protected readonly env: Static<typeof envSchema>;
82
- protected readonly dateTimeProvider: DateTimeProvider;
83
- // Crypto constants
84
- protected readonly ALGORITHM = "aes-256-gcm";
85
- protected readonly IV_LENGTH = 16;
86
- protected readonly AUTH_TAG_LENGTH = 16;
87
- protected readonly SIGNATURE_LENGTH = 32;
88
- protected readonly configure: HookDescriptor<"configure">;
89
- protected createApi<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>): CookieDescriptor<T>;
90
- readonly onRequest: HookDescriptor<"server:onRequest">;
91
- readonly onSend: HookDescriptor<"server:onSend">;
92
- protected getCookiesFromContext(cookies?: Cookies): Cookies;
93
- protected getCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, contextCookies?: Cookies): Static<T> | undefined;
94
- protected setCookie<T extends TSchema>(name: string, options: CookieDescriptorOptions<T>, data: Static<T>, contextCookies?: Cookies): void;
95
- protected deleteCookie<T extends TSchema>(name: string, contextCookies?: Cookies): void;
96
- // --- Crypto & Parsing ---
97
- protected encrypt(text: string): string;
98
- protected decrypt(encryptedText: string): string;
99
- secretKey(): string;
100
- protected sign(data: string): string;
101
- protected parseRequestCookies(header: string): Record<string, string>;
102
- protected serializeResponseCookies(cookies: Record<string, Cookie | null>, isHttps: boolean): string[];
103
- }
104
+ //# sourceMappingURL=$cookie.d.ts.map
104
105
  //#endregion
105
106
  //#region src/index.d.ts
106
- // ---------------------------------------------------------------------------------------------------------------------
107
107
  declare module "alepha/server" {
108
108
  interface ServerRequest {
109
109
  cookies: Cookies;
110
110
  }
111
111
  }
112
- declare class AlephaServerCookies implements Module {
113
- readonly name = "alepha.server.cookies";
114
- readonly $services: (alepha: Alepha) => void;
115
- }
112
+ /**
113
+ * Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
114
+ *
115
+ * The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
116
+ * It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
117
+ * for managing user sessions, preferences, and authentication tokens.
118
+ *
119
+ * @see {@link $cookie}
120
+ * @module alepha.server.cookies
121
+ */
122
+ declare const AlephaServerCookies: _alepha_core0.ModuleDescriptor;
123
+ //# sourceMappingURL=index.d.ts.map
124
+
116
125
  //#endregion
117
126
  export { $cookie, AlephaServerCookies, Cookie, CookieDescriptor, CookieDescriptorOptions, Cookies, ServerCookiesProvider };
118
127
  //# sourceMappingURL=index.d.ts.map
package/server/cors.d.ts CHANGED
@@ -1,29 +1,31 @@
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
1
3
  import { ServerRouterProvider } from "alepha/server";
2
- import { Alepha, HookDescriptor, Module } from "alepha";
3
4
 
4
5
  //#region src/providers/ServerCorsProvider.d.ts
5
6
  declare class ServerCorsProvider {
6
7
  protected readonly serverRouterProvider: ServerRouterProvider;
7
- options: CorsOptions;
8
- protected readonly onRoute: HookDescriptor<"server:onRoute">;
9
- protected readonly onRequest: HookDescriptor<"server:onRequest">;
10
- isOriginAllowed(origin: string | undefined, allowed: CorsOptions["origin"]): boolean;
8
+ options: ServerCorsProviderOptions;
9
+ protected readonly configure: _alepha_core0$1.HookDescriptor<"configure">;
10
+ protected readonly onRequest: _alepha_core0$1.HookDescriptor<"server:onRequest">;
11
+ isOriginAllowed(origin: string | undefined, allowed: ServerCorsProviderOptions["origin"]): boolean;
11
12
  }
12
- // ---------------------------------------------------------------------------------------------------------------------
13
- interface CorsOptions {
13
+ interface ServerCorsProviderOptions {
14
14
  origin?: string | string[] | ((origin: string | undefined) => boolean);
15
15
  methods: string[];
16
16
  headers: string[];
17
17
  credentials?: boolean;
18
18
  maxAge?: number;
19
19
  }
20
+ //# sourceMappingURL=ServerCorsProvider.d.ts.map
20
21
  //#endregion
21
22
  //#region src/index.d.ts
22
- // ---------------------------------------------------------------------------------------------------------------------
23
- declare class AlephaServerCors implements Module {
24
- readonly name = "alepha.server.cors";
25
- readonly $services: (alepha: Alepha) => void;
26
- }
23
+ /**
24
+ * Plugin for configuring CORS on the Alepha server.
25
+ */
26
+ declare const AlephaServerCors: _alepha_core0.ModuleDescriptor;
27
+ //# sourceMappingURL=index.d.ts.map
28
+
27
29
  //#endregion
28
- export { AlephaServerCors, CorsOptions, ServerCorsProvider };
30
+ export { AlephaServerCors, ServerCorsProvider, ServerCorsProviderOptions };
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1,42 +1,39 @@
1
- import { RouteDescriptor } from "alepha/server";
2
- import { Alepha, TBoolean, TNumber, TObject, TString } from "alepha";
1
+ import * as _alepha_core0 from "alepha";
2
+ import { Alepha } from "alepha";
3
+ import * as _alepha_server0 from "alepha/server";
3
4
  import { DateTimeProvider } from "alepha/datetime";
5
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
4
6
 
5
7
  //#region src/providers/ServerHealthProvider.d.ts
6
-
7
8
  /**
8
- * Register `/health` endpoint.
9
- *
10
- * - Provides basic health information about the server.
11
- */
9
+ * Register `/health` endpoint.
10
+ *
11
+ * - Provides basic health information about the server.
12
+ */
12
13
  declare class ServerHealthProvider {
13
14
  protected readonly time: DateTimeProvider;
14
15
  protected readonly alepha: Alepha;
15
- readonly health: RouteDescriptor<{
16
- response: TObject<{
17
- message: TString;
18
- uptime: TNumber;
19
- date: TString;
20
- ready: TBoolean;
16
+ readonly health: _alepha_server0.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;
21
22
  }>;
22
23
  }>;
23
24
  }
25
+ //# sourceMappingURL=ServerHealthProvider.d.ts.map
24
26
  //#endregion
25
27
  //#region src/index.d.ts
26
- // ---------------------------------------------------------------------------------------------------------------------
27
28
  /**
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: Alepha) => void;
39
- }
29
+ * Plugin for Alepha Server that provides health-check endpoints.
30
+ *
31
+ * @see {@link ServerHealthProvider}
32
+ * @module alepha.server.health
33
+ */
34
+ declare const AlephaServerHealth: _alepha_core0.ModuleDescriptor;
35
+ //# sourceMappingURL=index.d.ts.map
36
+
40
37
  //#endregion
41
38
  export { AlephaServerHealth, ServerHealthProvider };
42
39
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,5 @@
1
- import { Alepha, HookDescriptor, Module } from "alepha";
1
+ import * as _alepha_core0 from "alepha";
2
+ import { Alepha, HookDescriptor } from "alepha";
2
3
 
3
4
  //#region src/providers/ServerHelmetProvider.d.ts
4
5
  type CspDirective = string | string[];
@@ -38,35 +39,31 @@ interface HelmetOptions {
38
39
  referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url" | false;
39
40
  }
40
41
  /**
41
- * Provides a configurable way to apply essential HTTP security headers
42
- * to every server response, without external dependencies.
43
- */
42
+ * Provides a configurable way to apply essential HTTP security headers
43
+ * to every server response, without external dependencies.
44
+ */
44
45
  declare class ServerHelmetProvider {
45
46
  protected readonly alepha: Alepha;
46
47
  /**
47
- * The configuration options. These can be overridden during
48
- * the application's configuration phase using `alepha.configure()`.
49
- */
48
+ * The configuration options. These can be overridden during
49
+ * the application's configuration phase using `alepha.configure()`.
50
+ */
50
51
  options: HelmetOptions;
51
52
  private buildHeaders;
52
53
  protected readonly onResponse: HookDescriptor<"server:onResponse">;
53
54
  }
54
55
  //#endregion
55
56
  //#region src/index.d.ts
56
- // ---------------------------------------------------------------------------------------------------------------------
57
57
  /**
58
- * Alepha Server Helmet Module
59
- *
60
- * Automatically adds important HTTP security headers to every response
61
- * to help protect your application from common web vulnerabilities.
62
- *
63
- * @see {@link ServerHelmetProvider}
64
- * @module alepha.server.helmet
65
- */
66
- declare class AlephaServerHelmet implements Module {
67
- readonly name = "alepha.server.helmet";
68
- readonly $services: (alepha: Alepha) => void;
69
- }
58
+ * Automatically adds important HTTP security headers to every response
59
+ * to help protect your application from common web vulnerabilities.
60
+ *
61
+ * @see {@link ServerHelmetProvider}
62
+ * @module alepha.server.helmet
63
+ */
64
+ declare const AlephaServerHelmet: _alepha_core0.ModuleDescriptor;
65
+ //# sourceMappingURL=index.d.ts.map
66
+
70
67
  //#endregion
71
68
  export { AlephaServerHelmet, CspOptions, HelmetOptions, HstsOptions, ServerHelmetProvider };
72
69
  //# sourceMappingURL=index.d.ts.map
package/server/links.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import { Alepha, HookDescriptor, KIND, Logger, Module, OPTIONS, TAny, TArray, TObject, TOptional, TRecord, TString } from "alepha";
2
- import { ActionDescriptor, ActionDescriptorHelper, ApiLink, ApiLinksResponse, ClientRequestOptions, FetchResponse, HttpClient, RequestConfigSchema, RouteDescriptor, ServerActionDescriptorProvider, ServerHandler, ServerRemote, ServerRequestConfigEntry } from "alepha/server";
3
- import { RetryDescriptor } from "alepha/retry";
4
- import { ProxyDescriptorOptions, ProxyDescriptorProvider } from "alepha/server/proxy";
1
+ import * as _alepha_core1 from "alepha";
2
+ import * as _alepha_core0$1 from "alepha";
3
+ import * as _alepha_core0 from "alepha";
4
+ import { Alepha, Descriptor, KIND, Logger } from "alepha";
5
+ import * as _alepha_server0 from "alepha/server";
6
+ import { ActionDescriptor, ApiLink, ApiLinksResponse, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry } from "alepha/server";
7
+ import * as _alepha_retry0 from "alepha/retry";
8
+ import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
5
9
  import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
10
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
6
11
 
7
12
  //#region src/providers/LinkProvider.d.ts
8
13
  declare class LinkProvider {
@@ -15,24 +20,20 @@ declare class LinkProvider {
15
20
  getLinks(force?: boolean): Promise<HttpClientLink[]>;
16
21
  client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
17
22
  /**
18
- * Resolve a link by its name and call it.
19
- * - If link is local, it will call the local handler.
20
- * - If link is remote, it will make a fetch request to the remote server.
21
- */
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
+ */
22
27
  follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
23
28
  protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
24
29
  can(name: string): boolean;
25
30
  protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
26
31
  }
27
- // ---------------------------------------------------------------------------------------------------------------------
28
32
  interface HttpClientLink extends ApiLink {
29
33
  secured?: boolean;
30
34
  prefix?: string;
31
- // -- server only --
32
- // only for remote actions
33
35
  host?: string;
34
36
  service?: string;
35
- // used only for local actions, not for remote actions
36
37
  schema?: RequestConfigSchema;
37
38
  handler?: ServerHandler;
38
39
  }
@@ -40,77 +41,86 @@ interface ClientScope {
40
41
  group?: string;
41
42
  service?: string;
42
43
  }
43
- type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
44
+ type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
45
+ (config?: ClientRequestEntry<Schema>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<Schema>>;
44
46
  can: () => boolean;
45
47
  schema: Schema;
46
48
  } : never };
49
+ //# sourceMappingURL=LinkProvider.d.ts.map
47
50
  //#endregion
48
51
  //#region src/descriptors/$client.d.ts
49
- declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
52
+ /**
53
+ * Create a new client.
54
+ */
55
+ declare const $client: {
56
+ <T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
57
+ [KIND]: string;
58
+ };
59
+ //# sourceMappingURL=$client.d.ts.map
60
+
50
61
  //#endregion
51
62
  //#region src/descriptors/$remote.d.ts
52
- declare const KEY = "REMOTE";
63
+ /**
64
+ * $remote is a descriptor that allows you to define remote service access.
65
+ *
66
+ * Use it only when you have 2 or more services that need to communicate with each other.
67
+ *
68
+ * All remote services can be exposed as actions, ... or not.
69
+ *
70
+ * You can add a service account if you want to use a security layer.
71
+ */
72
+ declare const $remote: {
73
+ (options: RemoteDescriptorOptions): RemoteDescriptor;
74
+ [KIND]: typeof RemoteDescriptor;
75
+ };
53
76
  interface RemoteDescriptorOptions {
54
77
  /**
55
- * The URL of the remote service.
56
- * You can use a function to generate the URL dynamically.
57
- * You probably should use $inject(env) to get the URL from the environment.
58
- *
59
- * @example
60
- * ```ts
61
- * import { $remote } from "alepha/server";
62
- * import { $inject, t } from "alepha";
63
- *
64
- * class App {
65
- * env = $inject(t.object({
66
- * REMOTE_URL: t.string({default: "http://localhost:3000"}),
67
- * }));
68
- * remote = $remote({
69
- * url: this.env.REMOTE_URL,
70
- * });
71
- * }
72
- * ```
73
- */
78
+ * The URL of the remote service.
79
+ * You can use a function to generate the URL dynamically.
80
+ * You probably should use $env(env) to get the URL from the environment.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { $remote } from "alepha/server";
85
+ * import { $inject, t } from "alepha";
86
+ *
87
+ * class App {
88
+ * env = $env(t.object({
89
+ * REMOTE_URL: t.string({default: "http://localhost:3000"}),
90
+ * }));
91
+ * remote = $remote({
92
+ * url: this.env.REMOTE_URL,
93
+ * });
94
+ * }
95
+ * ```
96
+ */
74
97
  url: string | (() => string);
75
98
  /**
76
- * The name of the remote service.
77
- *
78
- * @default Member of the class containing the remote service.
79
- */
99
+ * The name of the remote service.
100
+ *
101
+ * @default Member of the class containing the remote service.
102
+ */
80
103
  name?: string;
81
104
  /**
82
- * If true, all methods of the remote service will be exposed as actions in this context.
83
- * > Note: Proxy will never use the service account, it just... proxies the request.
84
- */
105
+ * If true, all methods of the remote service will be exposed as actions in this context.
106
+ * > Note: Proxy will never use the service account, it just... proxies the request.
107
+ */
85
108
  proxy?: boolean | Partial<ProxyDescriptorOptions & {
86
109
  /**
87
- * If true, the remote service won't be available internally, only through the proxy.
88
- */
110
+ * If true, the remote service won't be available internally, only through the proxy.
111
+ */
89
112
  noInternal: boolean;
90
113
  }>;
91
114
  /**
92
- * For communication between the server and the remote service with a security layer.
93
- * This will be used for internal communication and will not be exposed to the client.
94
- */
115
+ * For communication between the server and the remote service with a security layer.
116
+ * This will be used for internal communication and will not be exposed to the client.
117
+ */
95
118
  serviceAccount?: ServiceAccountDescriptor;
96
119
  }
97
- interface RemoteDescriptor {
98
- [KIND]: typeof KEY;
99
- [OPTIONS]: RemoteDescriptorOptions;
120
+ declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
121
+ get name(): string;
100
122
  }
101
- /**
102
- * $remote is a descriptor that allows you to define a remote service access.
103
- *
104
- * Use it only when you have 2 or more services that need to communicate with each other.
105
- *
106
- * All remote services can be exposed as actions, ... or not.
107
- *
108
- * You can add a service account if you want to use a security layer.
109
- */
110
- declare const $remote: {
111
- (options: RemoteDescriptorOptions): RemoteDescriptor;
112
- [KIND]: string;
113
- };
123
+ //# sourceMappingURL=$remote.d.ts.map
114
124
  //#endregion
115
125
  //#region src/providers/RemoteDescriptorProvider.d.ts
116
126
  declare class RemoteDescriptorProvider {
@@ -119,47 +129,61 @@ declare class RemoteDescriptorProvider {
119
129
  };
120
130
  protected readonly alepha: Alepha;
121
131
  protected readonly client: LinkProvider;
122
- protected readonly proxyProvider: ProxyDescriptorProvider;
132
+ protected readonly proxyProvider: ServerProxyProvider;
123
133
  protected readonly remotes: Array<ServerRemote>;
124
134
  protected readonly log: Logger;
125
135
  getRemotes(): ServerRemote[];
126
- readonly configure: HookDescriptor<"configure">;
127
- readonly start: HookDescriptor<"start">;
128
- registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
129
- protected readonly fetchLinks: RetryDescriptor<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
136
+ readonly configure: _alepha_core1.HookDescriptor<"configure">;
137
+ readonly start: _alepha_core1.HookDescriptor<"start">;
138
+ registerRemote(value: RemoteDescriptor): Promise<void>;
139
+ protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
130
140
  }
131
141
  interface FetchLinksOptions {
132
142
  service: string;
133
143
  url: string;
134
144
  authorization?: string;
135
145
  }
146
+ interface ServerRemote {
147
+ url: string;
148
+ name: string;
149
+ proxy: boolean;
150
+ internal: boolean;
151
+ links: (args: {
152
+ authorization?: string;
153
+ }) => Promise<ApiLinksResponse>;
154
+ schema: (args: {
155
+ name: string;
156
+ authorization?: string;
157
+ }) => Promise<any>;
158
+ serviceAccount?: ServiceAccountDescriptor;
159
+ prefix: string;
160
+ }
161
+ //# sourceMappingURL=RemoteDescriptorProvider.d.ts.map
136
162
  //#endregion
137
163
  //#region src/providers/ServerLinksProvider.d.ts
138
164
  declare class ServerLinksProvider {
139
165
  protected readonly alepha: Alepha;
140
166
  protected readonly client: LinkProvider;
141
- protected readonly helper: ActionDescriptorHelper;
142
167
  protected readonly remoteProvider: RemoteDescriptorProvider;
143
- protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
144
- readonly onRoute: HookDescriptor<"server:onRoute">;
145
- readonly links: RouteDescriptor<{
146
- response: TObject<{
147
- prefix: TOptional<TString>;
148
- links: TArray<TObject<{
149
- name: TString;
150
- path: TString;
151
- method: TOptional<TString>;
152
- group: TOptional<TString>;
153
- requestBodyType: TOptional<TString>;
154
- service: TOptional<TString>;
168
+ readonly onRoute: _alepha_core0$1.HookDescriptor<"configure">;
169
+ readonly links: _alepha_server0.RouteDescriptor<{
170
+ response: _sinclair_typebox0.TObject<{
171
+ prefix: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
172
+ links: _sinclair_typebox0.TArray<_sinclair_typebox0.TObject<{
173
+ name: _sinclair_typebox0.TString;
174
+ path: _sinclair_typebox0.TString;
175
+ method: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
176
+ group: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
177
+ requestBodyType: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
178
+ service: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
155
179
  }>>;
156
180
  }>;
157
181
  }>;
158
- readonly schema: RouteDescriptor<{
159
- params: TObject<{
160
- name: TString;
182
+ readonly schema: _alepha_server0.RouteDescriptor<{
183
+ params: _sinclair_typebox0.TObject<{
184
+ name: _sinclair_typebox0.TString;
161
185
  }>;
162
- response: TRecord<TString, TAny>;
186
+ response: _sinclair_typebox0.TRecord<_sinclair_typebox0.TString, _sinclair_typebox0.TAny>;
163
187
  }>;
164
188
  getLinks(options: GetLinksOptions): Promise<ApiLinksResponse>;
165
189
  }
@@ -167,13 +191,12 @@ interface GetLinksOptions {
167
191
  user?: UserAccountToken;
168
192
  authorization?: string;
169
193
  }
194
+ //# sourceMappingURL=ServerLinksProvider.d.ts.map
170
195
  //#endregion
171
196
  //#region src/index.d.ts
172
- // ---------------------------------------------------------------------------------------------------------------------
173
- declare class AlephaServerLinks implements Module {
174
- readonly name = "alepha.server.links";
175
- readonly $services: (alepha: Alepha) => void;
176
- }
197
+ declare const AlephaServerLinks: _alepha_core0.ModuleDescriptor;
198
+ //# sourceMappingURL=index.d.ts.map
199
+
177
200
  //#endregion
178
- export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider };
201
+ export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote };
179
202
  //# sourceMappingURL=index.d.ts.map