alepha 0.12.1 → 0.13.1

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 (198) hide show
  1. package/dist/api-notifications/index.d.ts +111 -111
  2. package/dist/api-users/index.d.ts +1240 -1240
  3. package/dist/api-verifications/index.d.ts +94 -94
  4. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  5. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  6. package/dist/cli/index.d.ts +3 -11
  7. package/dist/cli/index.js +106 -74
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/email/index.js +71 -73
  10. package/dist/email/index.js.map +1 -1
  11. package/dist/orm/index.d.ts +1 -1
  12. package/dist/orm/index.js.map +1 -1
  13. package/dist/queue/index.d.ts +4 -4
  14. package/dist/redis/index.d.ts +10 -10
  15. package/dist/retry/index.d.ts +1 -1
  16. package/dist/retry/index.js +2 -2
  17. package/dist/retry/index.js.map +1 -1
  18. package/dist/scheduler/index.d.ts +6 -6
  19. package/dist/server/index.js +1 -1
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/server-auth/index.d.ts +193 -193
  22. package/dist/server-health/index.d.ts +17 -17
  23. package/dist/server-links/index.d.ts +34 -34
  24. package/dist/server-metrics/index.js +170 -174
  25. package/dist/server-metrics/index.js.map +1 -1
  26. package/dist/server-security/index.d.ts +9 -9
  27. package/dist/vite/index.js +4 -5
  28. package/dist/vite/index.js.map +1 -1
  29. package/dist/websocket/index.d.ts +7 -7
  30. package/package.json +52 -103
  31. package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
  32. package/src/cli/assets/appRouterTs.ts +9 -0
  33. package/src/cli/assets/indexHtml.ts +2 -1
  34. package/src/cli/assets/mainBrowserTs.ts +10 -0
  35. package/src/cli/commands/CoreCommands.ts +6 -5
  36. package/src/cli/commands/DrizzleCommands.ts +65 -57
  37. package/src/cli/commands/VerifyCommands.ts +1 -1
  38. package/src/cli/services/ProjectUtils.ts +44 -38
  39. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  40. package/src/retry/descriptors/$retry.ts +5 -3
  41. package/src/server/providers/NodeHttpServerProvider.ts +1 -1
  42. package/src/vite/helpers/boot.ts +3 -3
  43. package/dist/api-files/index.cjs +0 -1293
  44. package/dist/api-files/index.cjs.map +0 -1
  45. package/dist/api-files/index.d.cts +0 -829
  46. package/dist/api-jobs/index.cjs +0 -274
  47. package/dist/api-jobs/index.cjs.map +0 -1
  48. package/dist/api-jobs/index.d.cts +0 -654
  49. package/dist/api-notifications/index.cjs +0 -380
  50. package/dist/api-notifications/index.cjs.map +0 -1
  51. package/dist/api-notifications/index.d.cts +0 -289
  52. package/dist/api-parameters/index.cjs +0 -66
  53. package/dist/api-parameters/index.cjs.map +0 -1
  54. package/dist/api-parameters/index.d.cts +0 -84
  55. package/dist/api-users/index.cjs +0 -6009
  56. package/dist/api-users/index.cjs.map +0 -1
  57. package/dist/api-users/index.d.cts +0 -4740
  58. package/dist/api-verifications/index.cjs +0 -407
  59. package/dist/api-verifications/index.cjs.map +0 -1
  60. package/dist/api-verifications/index.d.cts +0 -207
  61. package/dist/batch/index.cjs +0 -408
  62. package/dist/batch/index.cjs.map +0 -1
  63. package/dist/batch/index.d.cts +0 -330
  64. package/dist/bin/index.cjs +0 -17
  65. package/dist/bin/index.cjs.map +0 -1
  66. package/dist/bin/index.d.cts +0 -1
  67. package/dist/bucket/index.cjs +0 -303
  68. package/dist/bucket/index.cjs.map +0 -1
  69. package/dist/bucket/index.d.cts +0 -355
  70. package/dist/cache/index.cjs +0 -241
  71. package/dist/cache/index.cjs.map +0 -1
  72. package/dist/cache/index.d.cts +0 -202
  73. package/dist/cache-redis/index.cjs +0 -84
  74. package/dist/cache-redis/index.cjs.map +0 -1
  75. package/dist/cache-redis/index.d.cts +0 -40
  76. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  77. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  78. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  79. package/dist/cli/index.cjs +0 -1241
  80. package/dist/cli/index.cjs.map +0 -1
  81. package/dist/cli/index.d.cts +0 -422
  82. package/dist/command/index.cjs +0 -693
  83. package/dist/command/index.cjs.map +0 -1
  84. package/dist/command/index.d.cts +0 -340
  85. package/dist/core/index.cjs +0 -2264
  86. package/dist/core/index.cjs.map +0 -1
  87. package/dist/core/index.d.cts +0 -1927
  88. package/dist/datetime/index.cjs +0 -318
  89. package/dist/datetime/index.cjs.map +0 -1
  90. package/dist/datetime/index.d.cts +0 -145
  91. package/dist/email/index.cjs +0 -10874
  92. package/dist/email/index.cjs.map +0 -1
  93. package/dist/email/index.d.cts +0 -186
  94. package/dist/fake/index.cjs +0 -34641
  95. package/dist/fake/index.cjs.map +0 -1
  96. package/dist/fake/index.d.cts +0 -74
  97. package/dist/file/index.cjs +0 -1212
  98. package/dist/file/index.cjs.map +0 -1
  99. package/dist/file/index.d.cts +0 -698
  100. package/dist/lock/index.cjs +0 -226
  101. package/dist/lock/index.cjs.map +0 -1
  102. package/dist/lock/index.d.cts +0 -361
  103. package/dist/lock-redis/index.cjs +0 -113
  104. package/dist/lock-redis/index.cjs.map +0 -1
  105. package/dist/lock-redis/index.d.cts +0 -24
  106. package/dist/logger/index.cjs +0 -521
  107. package/dist/logger/index.cjs.map +0 -1
  108. package/dist/logger/index.d.cts +0 -281
  109. package/dist/orm/index.cjs +0 -2986
  110. package/dist/orm/index.cjs.map +0 -1
  111. package/dist/orm/index.d.cts +0 -2213
  112. package/dist/queue/index.cjs +0 -1044
  113. package/dist/queue/index.cjs.map +0 -1
  114. package/dist/queue/index.d.cts +0 -1265
  115. package/dist/queue-redis/index.cjs +0 -873
  116. package/dist/queue-redis/index.cjs.map +0 -1
  117. package/dist/queue-redis/index.d.cts +0 -82
  118. package/dist/redis/index.cjs +0 -153
  119. package/dist/redis/index.cjs.map +0 -1
  120. package/dist/redis/index.d.cts +0 -82
  121. package/dist/retry/index.cjs +0 -146
  122. package/dist/retry/index.cjs.map +0 -1
  123. package/dist/retry/index.d.cts +0 -172
  124. package/dist/router/index.cjs +0 -111
  125. package/dist/router/index.cjs.map +0 -1
  126. package/dist/router/index.d.cts +0 -46
  127. package/dist/scheduler/index.cjs +0 -576
  128. package/dist/scheduler/index.cjs.map +0 -1
  129. package/dist/scheduler/index.d.cts +0 -145
  130. package/dist/security/index.cjs +0 -2402
  131. package/dist/security/index.cjs.map +0 -1
  132. package/dist/security/index.d.cts +0 -598
  133. package/dist/server/index.cjs +0 -1680
  134. package/dist/server/index.cjs.map +0 -1
  135. package/dist/server/index.d.cts +0 -810
  136. package/dist/server-auth/index.cjs +0 -3146
  137. package/dist/server-auth/index.cjs.map +0 -1
  138. package/dist/server-auth/index.d.cts +0 -1164
  139. package/dist/server-cache/index.cjs +0 -252
  140. package/dist/server-cache/index.cjs.map +0 -1
  141. package/dist/server-cache/index.d.cts +0 -164
  142. package/dist/server-compress/index.cjs +0 -141
  143. package/dist/server-compress/index.cjs.map +0 -1
  144. package/dist/server-compress/index.d.cts +0 -38
  145. package/dist/server-cookies/index.cjs +0 -234
  146. package/dist/server-cookies/index.cjs.map +0 -1
  147. package/dist/server-cookies/index.d.cts +0 -144
  148. package/dist/server-cors/index.cjs +0 -201
  149. package/dist/server-cors/index.cjs.map +0 -1
  150. package/dist/server-cors/index.d.cts +0 -140
  151. package/dist/server-health/index.cjs +0 -62
  152. package/dist/server-health/index.cjs.map +0 -1
  153. package/dist/server-health/index.d.cts +0 -58
  154. package/dist/server-helmet/index.cjs +0 -131
  155. package/dist/server-helmet/index.cjs.map +0 -1
  156. package/dist/server-helmet/index.d.cts +0 -97
  157. package/dist/server-links/index.cjs +0 -992
  158. package/dist/server-links/index.cjs.map +0 -1
  159. package/dist/server-links/index.d.cts +0 -513
  160. package/dist/server-metrics/index.cjs +0 -4535
  161. package/dist/server-metrics/index.cjs.map +0 -1
  162. package/dist/server-metrics/index.d.cts +0 -35
  163. package/dist/server-multipart/index.cjs +0 -237
  164. package/dist/server-multipart/index.cjs.map +0 -1
  165. package/dist/server-multipart/index.d.cts +0 -50
  166. package/dist/server-proxy/index.cjs +0 -186
  167. package/dist/server-proxy/index.cjs.map +0 -1
  168. package/dist/server-proxy/index.d.cts +0 -234
  169. package/dist/server-rate-limit/index.cjs +0 -241
  170. package/dist/server-rate-limit/index.cjs.map +0 -1
  171. package/dist/server-rate-limit/index.d.cts +0 -183
  172. package/dist/server-security/index.cjs +0 -316
  173. package/dist/server-security/index.cjs.map +0 -1
  174. package/dist/server-security/index.d.cts +0 -173
  175. package/dist/server-static/index.cjs +0 -170
  176. package/dist/server-static/index.cjs.map +0 -1
  177. package/dist/server-static/index.d.cts +0 -121
  178. package/dist/server-swagger/index.cjs +0 -1021
  179. package/dist/server-swagger/index.cjs.map +0 -1
  180. package/dist/server-swagger/index.d.cts +0 -382
  181. package/dist/sms/index.cjs +0 -221
  182. package/dist/sms/index.cjs.map +0 -1
  183. package/dist/sms/index.d.cts +0 -130
  184. package/dist/thread/index.cjs +0 -350
  185. package/dist/thread/index.cjs.map +0 -1
  186. package/dist/thread/index.d.cts +0 -260
  187. package/dist/topic/index.cjs +0 -282
  188. package/dist/topic/index.cjs.map +0 -1
  189. package/dist/topic/index.d.cts +0 -523
  190. package/dist/topic-redis/index.cjs +0 -71
  191. package/dist/topic-redis/index.cjs.map +0 -1
  192. package/dist/topic-redis/index.d.cts +0 -42
  193. package/dist/vite/index.cjs +0 -1077
  194. package/dist/vite/index.cjs.map +0 -1
  195. package/dist/vite/index.d.cts +0 -542
  196. package/dist/websocket/index.cjs +0 -1117
  197. package/dist/websocket/index.cjs.map +0 -1
  198. package/dist/websocket/index.d.cts +0 -861
@@ -1,513 +0,0 @@
1
- import * as alepha3 from "alepha";
2
- import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
3
- import { ServiceAccountDescriptor, UserAccount, UserAccountToken } from "alepha/security";
4
- import * as alepha_server0 from "alepha/server";
5
- import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchOptions, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequest, ServerRequestConfigEntry, ServerResponseBody, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
6
- import * as alepha_logger0 from "alepha/logger";
7
- import * as alepha_retry0 from "alepha/retry";
8
-
9
- //#region src/server-security/providers/ServerBasicAuthProvider.d.ts
10
- interface BasicAuthOptions {
11
- username: string;
12
- password: string;
13
- }
14
- //#endregion
15
- //#region src/server-security/providers/ServerSecurityProvider.d.ts
16
-
17
- type ServerRouteSecure = {
18
- realm?: string;
19
- basic?: BasicAuthOptions;
20
- };
21
- //#endregion
22
- //#region src/server-security/index.d.ts
23
- declare module "alepha" {
24
- interface State {
25
- /**
26
- * Real (or fake) user account, used for internal actions.
27
- *
28
- * If you define this, you assume that all actions are executed by this user by default.
29
- * > To force a different user, you need to pass it explicitly in the options.
30
- */
31
- "alepha.server.security.system.user"?: UserAccountToken;
32
- /**
33
- * The authenticated user account attached to the server request state.
34
- *
35
- * @internal
36
- */
37
- "alepha.server.request.user"?: UserAccount;
38
- }
39
- }
40
- declare module "alepha/server" {
41
- interface ServerRequest<TConfig> {
42
- user?: UserAccountToken;
43
- }
44
- interface ServerActionRequest<TConfig> {
45
- user: UserAccountToken;
46
- }
47
- interface ServerRoute {
48
- /**
49
- * If true, the route will be protected by the security provider.
50
- * All actions are secure by default, but you can disable it for specific actions.
51
- */
52
- secure?: boolean | ServerRouteSecure;
53
- }
54
- interface ClientRequestOptions extends FetchOptions {
55
- /**
56
- * Forward user from the previous request.
57
- * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
58
- * If "context", use the user from the current context (e.g. request).
59
- *
60
- * @default "system" if provided, else "context" if available.
61
- */
62
- user?: UserAccountToken | "system" | "context";
63
- }
64
- }
65
- /**
66
- * Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
67
- *
68
- * By default, all $action will be guarded by a permission check.
69
- *
70
- * @see {@link ServerSecurityProvider}
71
- * @module alepha.server.security
72
- */
73
- //#endregion
74
- //#region src/server-links/schemas/apiLinksResponseSchema.d.ts
75
- declare const apiLinkSchema: alepha3.TObject<{
76
- name: alepha3.TString;
77
- group: alepha3.TOptional<alepha3.TString>;
78
- path: alepha3.TString;
79
- method: alepha3.TOptional<alepha3.TString>;
80
- requestBodyType: alepha3.TOptional<alepha3.TString>;
81
- service: alepha3.TOptional<alepha3.TString>;
82
- }>;
83
- declare const apiLinksResponseSchema: alepha3.TObject<{
84
- prefix: alepha3.TOptional<alepha3.TString>;
85
- links: alepha3.TArray<alepha3.TObject<{
86
- name: alepha3.TString;
87
- group: alepha3.TOptional<alepha3.TString>;
88
- path: alepha3.TString;
89
- method: alepha3.TOptional<alepha3.TString>;
90
- requestBodyType: alepha3.TOptional<alepha3.TString>;
91
- service: alepha3.TOptional<alepha3.TString>;
92
- }>>;
93
- }>;
94
- type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
95
- type ApiLink = Static<typeof apiLinkSchema>;
96
- //#endregion
97
- //#region src/server-links/providers/LinkProvider.d.ts
98
- /**
99
- * Browser, SSR friendly, service to handle links.
100
- */
101
- declare class LinkProvider {
102
- static path: {
103
- apiLinks: string;
104
- apiSchema: string;
105
- };
106
- protected readonly log: alepha_logger0.Logger;
107
- protected readonly alepha: Alepha;
108
- protected readonly httpClient: HttpClient;
109
- protected serverLinks: Array<HttpClientLink>;
110
- /**
111
- * Get applicative links registered on the server.
112
- * This does not include lazy-loaded remote links.
113
- */
114
- getServerLinks(): HttpClientLink[];
115
- /**
116
- * Register a new link for the application.
117
- */
118
- registerLink(link: HttpClientLink): void;
119
- get links(): HttpClientLink[];
120
- /**
121
- * Force browser to refresh links from the server.
122
- */
123
- fetchLinks(): Promise<HttpClientLink[]>;
124
- /**
125
- * Create a virtual client that can be used to call actions.
126
- *
127
- * Use js Proxy under the hood.
128
- */
129
- client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
130
- /**
131
- * Check if a link with the given name exists.
132
- * @param name
133
- */
134
- can(name: string): boolean;
135
- /**
136
- * Resolve a link by its name and call it.
137
- * - If link is local, it will call the local handler.
138
- * - If link is remote, it will make a fetch request to the remote server.
139
- */
140
- follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
141
- protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
142
- protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
143
- protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
144
- }
145
- interface HttpClientLink extends ApiLink {
146
- secured?: boolean | ServerRouteSecure;
147
- prefix?: string;
148
- host?: string;
149
- service?: string;
150
- schema?: RequestConfigSchema;
151
- handler?: (request: ServerRequest, options: ClientRequestOptions) => Async<ServerResponseBody>;
152
- }
153
- interface ClientScope {
154
- group?: string;
155
- service?: string;
156
- hostname?: string;
157
- }
158
- type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
159
- interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
160
- (config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
161
- can: () => boolean;
162
- }
163
- //#endregion
164
- //#region src/server-links/descriptors/$client.d.ts
165
- /**
166
- * Create a new client.
167
- */
168
- declare const $client: {
169
- <T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
170
- [KIND]: string;
171
- };
172
- //#endregion
173
- //#region src/server-proxy/descriptors/$proxy.d.ts
174
- type ProxyDescriptorOptions = {
175
- /**
176
- * Path pattern to match for proxying requests.
177
- *
178
- * Supports wildcards and path parameters:
179
- * - `/api/*` - Matches all paths starting with `/api/`
180
- * - `/api/v1/*` - Matches all paths starting with `/api/v1/`
181
- * - `/users/:id` - Matches `/users/123`, `/users/abc`, etc.
182
- *
183
- * @example "/api/*"
184
- * @example "/secure/admin/*"
185
- * @example "/users/:id/posts"
186
- */
187
- path: string;
188
- /**
189
- * Target URL to which matching requests should be forwarded.
190
- *
191
- * Can be either:
192
- * - **Static string**: A fixed URL like `"https://api.example.com"`
193
- * - **Dynamic function**: A function that returns the URL, enabling runtime target resolution
194
- *
195
- * The target URL will be combined with the remaining path from the original request.
196
- *
197
- * @example "https://api.example.com"
198
- * @example () => process.env.API_URL || "http://localhost:3001"
199
- */
200
- target: string | (() => string);
201
- /**
202
- * Whether this proxy is disabled.
203
- *
204
- * When `true`, requests matching the path will not be proxied and will be handled
205
- * by other routes or return 404. Useful for feature toggles or conditional proxying.
206
- *
207
- * @default false
208
- * @example !process.env.ENABLE_PROXY
209
- */
210
- disabled?: boolean;
211
- /**
212
- * Hook called before forwarding the request to the target server.
213
- *
214
- * Use this to:
215
- * - Add authentication headers
216
- * - Modify request headers or body
217
- * - Add request tracking/logging
218
- * - Transform the request before forwarding
219
- *
220
- * @param request - The original incoming server request
221
- * @param proxyRequest - The request that will be sent to the target (modifiable)
222
- *
223
- * @example
224
- * ```ts
225
- * beforeRequest: async (request, proxyRequest) => {
226
- * proxyRequest.headers = {
227
- * ...proxyRequest.headers,
228
- * 'Authorization': `Bearer ${await getToken()}`,
229
- * 'X-Request-ID': generateRequestId()
230
- * };
231
- * }
232
- * ```
233
- */
234
- beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
235
- /**
236
- * Hook called after receiving the response from the target server.
237
- *
238
- * Use this to:
239
- * - Log response details for monitoring
240
- * - Add custom headers to the response
241
- * - Transform response data
242
- * - Handle error responses
243
- *
244
- * @param request - The original incoming server request
245
- * @param proxyResponse - The response received from the target server
246
- *
247
- * @example
248
- * ```ts
249
- * afterResponse: async (request, proxyResponse) => {
250
- * console.log(`Proxy ${request.method} ${request.url} -> ${proxyResponse.status}`);
251
- *
252
- * if (!proxyResponse.ok) {
253
- * await logError(`Proxy error: ${proxyResponse.status}`, { request, response: proxyResponse });
254
- * }
255
- * }
256
- * ```
257
- */
258
- afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
259
- /**
260
- * Function to rewrite the URL before sending to the target server.
261
- *
262
- * Use this to:
263
- * - Remove or add path prefixes
264
- * - Transform path parameters
265
- * - Modify query parameters
266
- * - Change the URL structure entirely
267
- *
268
- * The function receives a mutable URL object and should modify it in-place.
269
- *
270
- * @param url - The URL object to modify (mutable)
271
- *
272
- * @example
273
- * ```ts
274
- * // Remove /api prefix when forwarding
275
- * rewrite: (url) => {
276
- * url.pathname = url.pathname.replace('/api', '');
277
- * }
278
- * ```
279
- *
280
- * @example
281
- * ```ts
282
- * // Add version prefix
283
- * rewrite: (url) => {
284
- * url.pathname = `/v2${url.pathname}`;
285
- * }
286
- * ```
287
- */
288
- rewrite?: (url: URL) => void;
289
- };
290
- //#endregion
291
- //#region src/server-proxy/providers/ServerProxyProvider.d.ts
292
- declare class ServerProxyProvider {
293
- protected readonly log: alepha_logger0.Logger;
294
- protected readonly routerProvider: ServerRouterProvider;
295
- protected readonly alepha: Alepha;
296
- protected readonly configure: alepha3.HookDescriptor<"configure">;
297
- createProxy(options: ProxyDescriptorOptions): void;
298
- createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
299
- private getRawRequestBody;
300
- }
301
- //#endregion
302
- //#region src/server-links/descriptors/$remote.d.ts
303
- /**
304
- * $remote is a descriptor that allows you to define remote service access.
305
- *
306
- * Use it only when you have 2 or more services that need to communicate with each other.
307
- *
308
- * All remote services can be exposed as actions, ... or not.
309
- *
310
- * You can add a service account if you want to use a security layer.
311
- */
312
- declare const $remote: {
313
- (options: RemoteDescriptorOptions): RemoteDescriptor;
314
- [KIND]: typeof RemoteDescriptor;
315
- };
316
- interface RemoteDescriptorOptions {
317
- /**
318
- * The URL of the remote service.
319
- * You can use a function to generate the URL dynamically.
320
- * You probably should use $env(env) to get the URL from the environment.
321
- *
322
- * @example
323
- * ```ts
324
- * import { $remote } from "alepha/server";
325
- * import { $inject, t } from "alepha";
326
- *
327
- * class App {
328
- * env = $env(t.object({
329
- * REMOTE_URL: t.text({default: "http://localhost:3000"}),
330
- * }));
331
- * remote = $remote({
332
- * url: this.env.REMOTE_URL,
333
- * });
334
- * }
335
- * ```
336
- */
337
- url: string | (() => string);
338
- /**
339
- * The name of the remote service.
340
- *
341
- * @default Member of the class containing the remote service.
342
- */
343
- name?: string;
344
- /**
345
- * If true, all methods of the remote service will be exposed as actions in this context.
346
- * > Note: Proxy will never use the service account, it just... proxies the request.
347
- */
348
- proxy?: boolean | Partial<ProxyDescriptorOptions & {
349
- /**
350
- * If true, the remote service won't be available internally, only through the proxy.
351
- */
352
- noInternal: boolean;
353
- }>;
354
- /**
355
- * For communication between the server and the remote service with a security layer.
356
- * This will be used for internal communication and will not be exposed to the client.
357
- */
358
- serviceAccount?: ServiceAccountDescriptor;
359
- }
360
- declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
361
- get name(): string;
362
- }
363
- //#endregion
364
- //#region src/server-links/providers/RemoteDescriptorProvider.d.ts
365
- declare class RemoteDescriptorProvider {
366
- protected readonly env: {
367
- SERVER_API_PREFIX: string;
368
- };
369
- protected readonly alepha: Alepha;
370
- protected readonly proxyProvider: ServerProxyProvider;
371
- protected readonly linkProvider: LinkProvider;
372
- protected readonly remotes: Array<ServerRemote>;
373
- protected readonly log: alepha_logger0.Logger;
374
- getRemotes(): ServerRemote[];
375
- readonly configure: alepha3.HookDescriptor<"configure">;
376
- readonly start: alepha3.HookDescriptor<"start">;
377
- registerRemote(value: RemoteDescriptor): Promise<void>;
378
- protected readonly fetchLinks: alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
379
- }
380
- interface FetchLinksOptions {
381
- /**
382
- * Name of the remote service.
383
- */
384
- service: string;
385
- /**
386
- * URL to fetch links from.
387
- */
388
- url: string;
389
- /**
390
- * Authorization header containing access token.
391
- */
392
- authorization?: string;
393
- }
394
- interface ServerRemote {
395
- /**
396
- * URL of the remote service.
397
- */
398
- url: string;
399
- /**
400
- * Name of the remote service.
401
- */
402
- name: string;
403
- /**
404
- * Expose links as endpoint. It's not only internal.
405
- */
406
- proxy: boolean;
407
- /**
408
- * It's only used inside the application.
409
- */
410
- internal: boolean;
411
- /**
412
- * Links fetcher.
413
- */
414
- links: (args: {
415
- authorization?: string;
416
- }) => Promise<ApiLinksResponse>;
417
- /**
418
- * Fetches schema for the remote service.
419
- */
420
- schema: (args: {
421
- name: string;
422
- authorization?: string;
423
- }) => Promise<any>;
424
- /**
425
- * Force a default access token provider when not provided.
426
- */
427
- serviceAccount?: ServiceAccountDescriptor;
428
- /**
429
- * Prefix for the remote service links.
430
- */
431
- prefix: string;
432
- }
433
- //#endregion
434
- //#region src/server-links/providers/ServerLinksProvider.d.ts
435
- declare class ServerLinksProvider {
436
- protected readonly env: {
437
- SERVER_API_PREFIX: string;
438
- };
439
- protected readonly alepha: Alepha;
440
- protected readonly linkProvider: LinkProvider;
441
- protected readonly remoteProvider: RemoteDescriptorProvider;
442
- protected readonly serverTimingProvider: ServerTimingProvider;
443
- get prefix(): string;
444
- readonly onRoute: alepha3.HookDescriptor<"configure">;
445
- /**
446
- * First API - Get all API links for the user.
447
- *
448
- * This is based on the user's permissions.
449
- */
450
- readonly links: alepha_server0.RouteDescriptor<{
451
- response: alepha3.TObject<{
452
- prefix: alepha3.TOptional<alepha3.TString>;
453
- links: alepha3.TArray<alepha3.TObject<{
454
- name: alepha3.TString;
455
- group: alepha3.TOptional<alepha3.TString>;
456
- path: alepha3.TString;
457
- method: alepha3.TOptional<alepha3.TString>;
458
- requestBodyType: alepha3.TOptional<alepha3.TString>;
459
- service: alepha3.TOptional<alepha3.TString>;
460
- }>>;
461
- }>;
462
- }>;
463
- /**
464
- * Second API - Get schema for a specific API link.
465
- *
466
- * Note: Body/Response schema are not included in `links` API because it's TOO BIG.
467
- * I mean for 150+ links, you got 50ms of serialization time.
468
- */
469
- readonly schema: alepha_server0.RouteDescriptor<{
470
- params: alepha3.TObject<{
471
- name: alepha3.TString;
472
- }>;
473
- response: alepha3.TRecord<string, alepha3.TAny>;
474
- }>;
475
- getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
476
- /**
477
- * Retrieves API links for the user based on their permissions.
478
- * Will check on local links and remote links.
479
- */
480
- getUserApiLinks(options: GetApiLinksOptions): Promise<ApiLinksResponse>;
481
- }
482
- interface GetApiLinksOptions {
483
- user?: UserAccountToken;
484
- authorization?: string;
485
- }
486
- //#endregion
487
- //#region src/server-links/index.d.ts
488
- declare module "alepha" {
489
- interface State {
490
- /**
491
- * API links attached to the server request state.
492
- *
493
- * @see {@link ApiLinksResponse}
494
- * @internal
495
- */
496
- "alepha.server.request.apiLinks"?: ApiLinksResponse;
497
- }
498
- }
499
- /**
500
- * Provides server-side link management and remote capabilities for client-server interactions.
501
- *
502
- * The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
503
- * facilitating seamless API endpoint management and client-server communication. It integrates with server
504
- * security features to ensure safe and controlled access to resources.
505
- *
506
- * @see {@link $remote}
507
- * @see {@link $client}
508
- * @module alepha.server.links
509
- */
510
- declare const AlephaServerLinks: alepha3.Service<alepha3.Module>;
511
- //#endregion
512
- export { $client, $remote, AlephaServerLinks, ApiLink, ApiLinksResponse, ClientScope, FetchLinksOptions, GetApiLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction, apiLinkSchema, apiLinksResponseSchema };
513
- //# sourceMappingURL=index.d.cts.map