alepha 0.11.9 → 0.11.11
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 +61 -17
- package/dist/index.cjs +17089 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17088 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -365
- package/src/assets/biomeJson.ts +33 -0
- package/src/assets/tsconfigJson.ts +18 -0
- package/src/assets/viteConfigTs.ts +14 -0
- package/src/commands/BiomeCommands.ts +41 -0
- package/src/commands/CoreCommands.ts +169 -0
- package/src/commands/DrizzleCommands.ts +228 -0
- package/src/commands/VerifyCommands.ts +44 -0
- package/src/commands/ViteCommands.ts +119 -0
- package/src/index.ts +35 -0
- package/src/services/ProcessRunner.ts +89 -0
- package/src/services/ProjectUtils.ts +508 -0
- package/src/version.ts +7 -0
- package/api/files.cjs +0 -8
- package/api/files.d.ts +0 -438
- package/api/files.js +0 -1
- package/api/jobs.cjs +0 -8
- package/api/jobs.d.ts +0 -327
- package/api/jobs.js +0 -1
- package/api/notifications.cjs +0 -8
- package/api/notifications.d.ts +0 -263
- package/api/notifications.js +0 -1
- package/api/users.cjs +0 -8
- package/api/users.d.ts +0 -923
- package/api/users.js +0 -1
- package/api/verifications.cjs +0 -8
- package/api/verifications.d.ts +0 -1
- package/api/verifications.js +0 -1
- package/batch.cjs +0 -8
- package/batch.d.ts +0 -154
- package/batch.js +0 -1
- package/bucket.cjs +0 -8
- package/bucket.d.ts +0 -520
- package/bucket.js +0 -1
- package/cache/redis.cjs +0 -8
- package/cache/redis.d.ts +0 -40
- package/cache/redis.js +0 -1
- package/cache.cjs +0 -8
- package/cache.d.ts +0 -288
- package/cache.js +0 -1
- package/command.cjs +0 -8
- package/command.d.ts +0 -269
- package/command.js +0 -1
- package/core.cjs +0 -8
- package/core.d.ts +0 -1904
- package/core.js +0 -1
- package/datetime.cjs +0 -8
- package/datetime.d.ts +0 -144
- package/datetime.js +0 -1
- package/devtools.cjs +0 -8
- package/devtools.d.ts +0 -252
- package/devtools.js +0 -1
- package/email.cjs +0 -8
- package/email.d.ts +0 -187
- package/email.js +0 -1
- package/fake.cjs +0 -8
- package/fake.d.ts +0 -73
- package/fake.js +0 -1
- package/file.cjs +0 -8
- package/file.d.ts +0 -528
- package/file.js +0 -1
- package/lock/redis.cjs +0 -8
- package/lock/redis.d.ts +0 -24
- package/lock/redis.js +0 -1
- package/lock.cjs +0 -8
- package/lock.d.ts +0 -552
- package/lock.js +0 -1
- package/logger.cjs +0 -8
- package/logger.d.ts +0 -287
- package/logger.js +0 -1
- package/postgres.cjs +0 -8
- package/postgres.d.ts +0 -2143
- package/postgres.js +0 -1
- package/queue/redis.cjs +0 -8
- package/queue/redis.d.ts +0 -29
- package/queue/redis.js +0 -1
- package/queue.cjs +0 -8
- package/queue.d.ts +0 -760
- package/queue.js +0 -1
- package/react/auth.cjs +0 -8
- package/react/auth.d.ts +0 -504
- package/react/auth.js +0 -1
- package/react/form.cjs +0 -8
- package/react/form.d.ts +0 -211
- package/react/form.js +0 -1
- package/react/head.cjs +0 -8
- package/react/head.d.ts +0 -120
- package/react/head.js +0 -1
- package/react/i18n.cjs +0 -8
- package/react/i18n.d.ts +0 -168
- package/react/i18n.js +0 -1
- package/react.cjs +0 -8
- package/react.d.ts +0 -1263
- package/react.js +0 -1
- package/redis.cjs +0 -8
- package/redis.d.ts +0 -82
- package/redis.js +0 -1
- package/retry.cjs +0 -8
- package/retry.d.ts +0 -162
- package/retry.js +0 -1
- package/router.cjs +0 -8
- package/router.d.ts +0 -45
- package/router.js +0 -1
- package/scheduler.cjs +0 -8
- package/scheduler.d.ts +0 -145
- package/scheduler.js +0 -1
- package/security.cjs +0 -8
- package/security.d.ts +0 -586
- package/security.js +0 -1
- package/server/cache.cjs +0 -8
- package/server/cache.d.ts +0 -163
- package/server/cache.js +0 -1
- package/server/compress.cjs +0 -8
- package/server/compress.d.ts +0 -38
- package/server/compress.js +0 -1
- package/server/cookies.cjs +0 -8
- package/server/cookies.d.ts +0 -144
- package/server/cookies.js +0 -1
- package/server/cors.cjs +0 -8
- package/server/cors.d.ts +0 -45
- package/server/cors.js +0 -1
- package/server/health.cjs +0 -8
- package/server/health.d.ts +0 -58
- package/server/health.js +0 -1
- package/server/helmet.cjs +0 -8
- package/server/helmet.d.ts +0 -98
- package/server/helmet.js +0 -1
- package/server/links.cjs +0 -8
- package/server/links.d.ts +0 -322
- package/server/links.js +0 -1
- package/server/metrics.cjs +0 -8
- package/server/metrics.d.ts +0 -35
- package/server/metrics.js +0 -1
- package/server/multipart.cjs +0 -8
- package/server/multipart.d.ts +0 -42
- package/server/multipart.js +0 -1
- package/server/proxy.cjs +0 -8
- package/server/proxy.d.ts +0 -234
- package/server/proxy.js +0 -1
- package/server/security.cjs +0 -8
- package/server/security.d.ts +0 -92
- package/server/security.js +0 -1
- package/server/static.cjs +0 -8
- package/server/static.d.ts +0 -119
- package/server/static.js +0 -1
- package/server/swagger.cjs +0 -8
- package/server/swagger.d.ts +0 -161
- package/server/swagger.js +0 -1
- package/server.cjs +0 -8
- package/server.d.ts +0 -849
- package/server.js +0 -1
- package/topic/redis.cjs +0 -8
- package/topic/redis.d.ts +0 -42
- package/topic/redis.js +0 -1
- package/topic.cjs +0 -8
- package/topic.d.ts +0 -819
- package/topic.js +0 -1
- package/vite.cjs +0 -8
- package/vite.d.ts +0 -186
- package/vite.js +0 -1
package/server/links.d.ts
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import { ServerRouteSecure } from "alepha/server/security";
|
|
2
|
-
import * as _alepha_core2 from "alepha";
|
|
3
|
-
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
4
|
-
import * as _alepha_server0 from "alepha/server";
|
|
5
|
-
import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry, ServerTimingProvider } from "alepha/server";
|
|
6
|
-
import * as _alepha_logger0 from "alepha/logger";
|
|
7
|
-
import * as _alepha_retry0 from "alepha/retry";
|
|
8
|
-
import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
|
|
9
|
-
import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
10
|
-
import * as typebox18 from "typebox";
|
|
11
|
-
|
|
12
|
-
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
13
|
-
declare const apiLinkSchema: typebox18.TObject<{
|
|
14
|
-
name: typebox18.TString;
|
|
15
|
-
group: typebox18.TOptional<typebox18.TString>;
|
|
16
|
-
path: typebox18.TString;
|
|
17
|
-
method: typebox18.TOptional<typebox18.TString>;
|
|
18
|
-
requestBodyType: typebox18.TOptional<typebox18.TString>;
|
|
19
|
-
service: typebox18.TOptional<typebox18.TString>;
|
|
20
|
-
}>;
|
|
21
|
-
declare const apiLinksResponseSchema: typebox18.TObject<{
|
|
22
|
-
prefix: typebox18.TOptional<typebox18.TString>;
|
|
23
|
-
links: typebox18.TArray<typebox18.TObject<{
|
|
24
|
-
name: typebox18.TString;
|
|
25
|
-
group: typebox18.TOptional<typebox18.TString>;
|
|
26
|
-
path: typebox18.TString;
|
|
27
|
-
method: typebox18.TOptional<typebox18.TString>;
|
|
28
|
-
requestBodyType: typebox18.TOptional<typebox18.TString>;
|
|
29
|
-
service: typebox18.TOptional<typebox18.TString>;
|
|
30
|
-
}>>;
|
|
31
|
-
}>;
|
|
32
|
-
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
33
|
-
type ApiLink = Static<typeof apiLinkSchema>;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/providers/LinkProvider.d.ts
|
|
36
|
-
/**
|
|
37
|
-
* Browser, SSR friendly, service to handle links.
|
|
38
|
-
*/
|
|
39
|
-
declare class LinkProvider {
|
|
40
|
-
static path: {
|
|
41
|
-
apiLinks: string;
|
|
42
|
-
apiSchema: string;
|
|
43
|
-
};
|
|
44
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
45
|
-
protected readonly alepha: Alepha;
|
|
46
|
-
protected readonly httpClient: HttpClient;
|
|
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
|
-
*/
|
|
67
|
-
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
68
|
-
/**
|
|
69
|
-
* Check if a link with the given name exists.
|
|
70
|
-
* @param name
|
|
71
|
-
*/
|
|
72
|
-
can(name: string): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Resolve a link by its name and call it.
|
|
75
|
-
* - If link is local, it will call the local handler.
|
|
76
|
-
* - If link is remote, it will make a fetch request to the remote server.
|
|
77
|
-
*/
|
|
78
|
-
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
79
|
-
protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
|
|
80
|
-
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
81
|
-
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
82
|
-
}
|
|
83
|
-
interface HttpClientLink extends ApiLink {
|
|
84
|
-
secured?: boolean | ServerRouteSecure;
|
|
85
|
-
prefix?: string;
|
|
86
|
-
host?: string;
|
|
87
|
-
service?: string;
|
|
88
|
-
schema?: RequestConfigSchema;
|
|
89
|
-
handler?: ServerHandler;
|
|
90
|
-
}
|
|
91
|
-
interface ClientScope {
|
|
92
|
-
group?: string;
|
|
93
|
-
service?: string;
|
|
94
|
-
hostname?: string;
|
|
95
|
-
}
|
|
96
|
-
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
|
|
97
|
-
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
|
|
98
|
-
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
99
|
-
can: () => boolean;
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/descriptors/$client.d.ts
|
|
103
|
-
/**
|
|
104
|
-
* Create a new client.
|
|
105
|
-
*/
|
|
106
|
-
declare const $client: {
|
|
107
|
-
<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
108
|
-
[KIND]: string;
|
|
109
|
-
};
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/descriptors/$remote.d.ts
|
|
112
|
-
/**
|
|
113
|
-
* $remote is a descriptor that allows you to define remote service access.
|
|
114
|
-
*
|
|
115
|
-
* Use it only when you have 2 or more services that need to communicate with each other.
|
|
116
|
-
*
|
|
117
|
-
* All remote services can be exposed as actions, ... or not.
|
|
118
|
-
*
|
|
119
|
-
* You can add a service account if you want to use a security layer.
|
|
120
|
-
*/
|
|
121
|
-
declare const $remote: {
|
|
122
|
-
(options: RemoteDescriptorOptions): RemoteDescriptor;
|
|
123
|
-
[KIND]: typeof RemoteDescriptor;
|
|
124
|
-
};
|
|
125
|
-
interface RemoteDescriptorOptions {
|
|
126
|
-
/**
|
|
127
|
-
* The URL of the remote service.
|
|
128
|
-
* You can use a function to generate the URL dynamically.
|
|
129
|
-
* You probably should use $env(env) to get the URL from the environment.
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```ts
|
|
133
|
-
* import { $remote } from "alepha/server";
|
|
134
|
-
* import { $inject, t } from "alepha";
|
|
135
|
-
*
|
|
136
|
-
* class App {
|
|
137
|
-
* env = $env(t.object({
|
|
138
|
-
* REMOTE_URL: t.text({default: "http://localhost:3000"}),
|
|
139
|
-
* }));
|
|
140
|
-
* remote = $remote({
|
|
141
|
-
* url: this.env.REMOTE_URL,
|
|
142
|
-
* });
|
|
143
|
-
* }
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
url: string | (() => string);
|
|
147
|
-
/**
|
|
148
|
-
* The name of the remote service.
|
|
149
|
-
*
|
|
150
|
-
* @default Member of the class containing the remote service.
|
|
151
|
-
*/
|
|
152
|
-
name?: string;
|
|
153
|
-
/**
|
|
154
|
-
* If true, all methods of the remote service will be exposed as actions in this context.
|
|
155
|
-
* > Note: Proxy will never use the service account, it just... proxies the request.
|
|
156
|
-
*/
|
|
157
|
-
proxy?: boolean | Partial<ProxyDescriptorOptions & {
|
|
158
|
-
/**
|
|
159
|
-
* If true, the remote service won't be available internally, only through the proxy.
|
|
160
|
-
*/
|
|
161
|
-
noInternal: boolean;
|
|
162
|
-
}>;
|
|
163
|
-
/**
|
|
164
|
-
* For communication between the server and the remote service with a security layer.
|
|
165
|
-
* This will be used for internal communication and will not be exposed to the client.
|
|
166
|
-
*/
|
|
167
|
-
serviceAccount?: ServiceAccountDescriptor;
|
|
168
|
-
}
|
|
169
|
-
declare class RemoteDescriptor extends Descriptor<RemoteDescriptorOptions> {
|
|
170
|
-
get name(): string;
|
|
171
|
-
}
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/providers/RemoteDescriptorProvider.d.ts
|
|
174
|
-
declare class RemoteDescriptorProvider {
|
|
175
|
-
protected readonly env: {
|
|
176
|
-
SERVER_API_PREFIX: string;
|
|
177
|
-
};
|
|
178
|
-
protected readonly alepha: Alepha;
|
|
179
|
-
protected readonly proxyProvider: ServerProxyProvider;
|
|
180
|
-
protected readonly linkProvider: LinkProvider;
|
|
181
|
-
protected readonly remotes: Array<ServerRemote>;
|
|
182
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
183
|
-
getRemotes(): ServerRemote[];
|
|
184
|
-
readonly configure: _alepha_core2.HookDescriptor<"configure">;
|
|
185
|
-
readonly start: _alepha_core2.HookDescriptor<"start">;
|
|
186
|
-
registerRemote(value: RemoteDescriptor): Promise<void>;
|
|
187
|
-
protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
188
|
-
}
|
|
189
|
-
interface FetchLinksOptions {
|
|
190
|
-
/**
|
|
191
|
-
* Name of the remote service.
|
|
192
|
-
*/
|
|
193
|
-
service: string;
|
|
194
|
-
/**
|
|
195
|
-
* URL to fetch links from.
|
|
196
|
-
*/
|
|
197
|
-
url: string;
|
|
198
|
-
/**
|
|
199
|
-
* Authorization header containing access token.
|
|
200
|
-
*/
|
|
201
|
-
authorization?: string;
|
|
202
|
-
}
|
|
203
|
-
interface ServerRemote {
|
|
204
|
-
/**
|
|
205
|
-
* URL of the remote service.
|
|
206
|
-
*/
|
|
207
|
-
url: string;
|
|
208
|
-
/**
|
|
209
|
-
* Name of the remote service.
|
|
210
|
-
*/
|
|
211
|
-
name: string;
|
|
212
|
-
/**
|
|
213
|
-
* Expose links as endpoint. It's not only internal.
|
|
214
|
-
*/
|
|
215
|
-
proxy: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* It's only used inside the application.
|
|
218
|
-
*/
|
|
219
|
-
internal: boolean;
|
|
220
|
-
/**
|
|
221
|
-
* Links fetcher.
|
|
222
|
-
*/
|
|
223
|
-
links: (args: {
|
|
224
|
-
authorization?: string;
|
|
225
|
-
}) => Promise<ApiLinksResponse>;
|
|
226
|
-
/**
|
|
227
|
-
* Fetches schema for the remote service.
|
|
228
|
-
*/
|
|
229
|
-
schema: (args: {
|
|
230
|
-
name: string;
|
|
231
|
-
authorization?: string;
|
|
232
|
-
}) => Promise<any>;
|
|
233
|
-
/**
|
|
234
|
-
* Force a default access token provider when not provided.
|
|
235
|
-
*/
|
|
236
|
-
serviceAccount?: ServiceAccountDescriptor;
|
|
237
|
-
/**
|
|
238
|
-
* Prefix for the remote service links.
|
|
239
|
-
*/
|
|
240
|
-
prefix: string;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/providers/ServerLinksProvider.d.ts
|
|
244
|
-
declare class ServerLinksProvider {
|
|
245
|
-
protected readonly env: {
|
|
246
|
-
SERVER_API_PREFIX: string;
|
|
247
|
-
};
|
|
248
|
-
protected readonly alepha: Alepha;
|
|
249
|
-
protected readonly linkProvider: LinkProvider;
|
|
250
|
-
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
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
|
-
*/
|
|
259
|
-
readonly links: _alepha_server0.RouteDescriptor<{
|
|
260
|
-
response: typebox18.TObject<{
|
|
261
|
-
prefix: typebox18.TOptional<typebox18.TString>;
|
|
262
|
-
links: typebox18.TArray<typebox18.TObject<{
|
|
263
|
-
name: typebox18.TString;
|
|
264
|
-
group: typebox18.TOptional<typebox18.TString>;
|
|
265
|
-
path: typebox18.TString;
|
|
266
|
-
method: typebox18.TOptional<typebox18.TString>;
|
|
267
|
-
requestBodyType: typebox18.TOptional<typebox18.TString>;
|
|
268
|
-
service: typebox18.TOptional<typebox18.TString>;
|
|
269
|
-
}>>;
|
|
270
|
-
}>;
|
|
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
|
-
*/
|
|
278
|
-
readonly schema: _alepha_server0.RouteDescriptor<{
|
|
279
|
-
params: typebox18.TObject<{
|
|
280
|
-
name: typebox18.TString;
|
|
281
|
-
}>;
|
|
282
|
-
response: typebox18.TRecord<string, typebox18.TAny>;
|
|
283
|
-
}>;
|
|
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>;
|
|
290
|
-
}
|
|
291
|
-
interface GetApiLinksOptions {
|
|
292
|
-
user?: UserAccountToken;
|
|
293
|
-
authorization?: string;
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region src/index.d.ts
|
|
297
|
-
declare module "alepha" {
|
|
298
|
-
interface State {
|
|
299
|
-
/**
|
|
300
|
-
* API links attached to the server request state.
|
|
301
|
-
*
|
|
302
|
-
* @see {@link ApiLinksResponse}
|
|
303
|
-
* @internal
|
|
304
|
-
*/
|
|
305
|
-
"alepha.server.request.apiLinks"?: ApiLinksResponse;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Provides server-side link management and remote capabilities for client-server interactions.
|
|
310
|
-
*
|
|
311
|
-
* The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
|
|
312
|
-
* facilitating seamless API endpoint management and client-server communication. It integrates with server
|
|
313
|
-
* security features to ensure safe and controlled access to resources.
|
|
314
|
-
*
|
|
315
|
-
* @see {@link $remote}
|
|
316
|
-
* @see {@link $client}
|
|
317
|
-
* @module alepha.server.links
|
|
318
|
-
*/
|
|
319
|
-
declare const AlephaServerLinks: _alepha_core2.Service<_alepha_core2.Module>;
|
|
320
|
-
//#endregion
|
|
321
|
-
export { $client, $remote, AlephaServerLinks, ApiLink, ApiLinksResponse, ClientScope, FetchLinksOptions, GetApiLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction, apiLinkSchema, apiLinksResponseSchema };
|
|
322
|
-
//# sourceMappingURL=index.d.ts.map
|
package/server/links.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@alepha/server-links'
|
package/server/metrics.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var m = require('@alepha/server-metrics');
|
|
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/metrics.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as _alepha_core1 from "alepha";
|
|
2
|
-
import { Alepha } from "alepha";
|
|
3
|
-
import * as _alepha_server0 from "alepha/server";
|
|
4
|
-
import { Histogram, Registry } from "prom-client";
|
|
5
|
-
|
|
6
|
-
//#region src/providers/ServerMetricsProvider.d.ts
|
|
7
|
-
declare class ServerMetricsProvider {
|
|
8
|
-
protected readonly register: Registry;
|
|
9
|
-
protected readonly alepha: Alepha;
|
|
10
|
-
protected httpRequestDuration?: Histogram<string>;
|
|
11
|
-
readonly options: ServerMetricsProviderOptions;
|
|
12
|
-
readonly metrics: _alepha_server0.RouteDescriptor<_alepha_server0.RequestConfigSchema>;
|
|
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">;
|
|
16
|
-
}
|
|
17
|
-
interface ServerMetricsProviderOptions {
|
|
18
|
-
prefix?: string;
|
|
19
|
-
gcDurationBuckets?: number[];
|
|
20
|
-
eventLoopMonitoringPrecision?: number;
|
|
21
|
-
labels?: object;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/index.d.ts
|
|
25
|
-
/**
|
|
26
|
-
* This module provides prometheus metrics for the Alepha server.
|
|
27
|
-
* Metrics are exposed at the `/metrics` endpoint.
|
|
28
|
-
*
|
|
29
|
-
* @see {@link ServerMetricsProvider}
|
|
30
|
-
* @module alepha.server.metrics
|
|
31
|
-
*/
|
|
32
|
-
declare const AlephaServerMetrics: _alepha_core1.Service<_alepha_core1.Module>;
|
|
33
|
-
//#endregion
|
|
34
|
-
export { AlephaServerMetrics, ServerMetricsProvider, ServerMetricsProviderOptions };
|
|
35
|
-
//# sourceMappingURL=index.d.ts.map
|
package/server/metrics.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@alepha/server-metrics'
|
package/server/multipart.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var m = require('@alepha/server-multipart');
|
|
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/multipart.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as _alepha_core0 from "alepha";
|
|
2
|
-
import { Alepha, FileLike, HookDescriptor } from "alepha";
|
|
3
|
-
import { ServerRoute } from "alepha/server";
|
|
4
|
-
import { IncomingMessage } from "node:http";
|
|
5
|
-
import { BusboyConfig } from "@fastify/busboy";
|
|
6
|
-
|
|
7
|
-
//#region src/providers/ServerMultipartProvider.d.ts
|
|
8
|
-
declare class ServerMultipartProvider {
|
|
9
|
-
protected readonly alepha: Alepha;
|
|
10
|
-
readonly onRequest: HookDescriptor<"server:onRequest">;
|
|
11
|
-
readonly onSend: HookDescriptor<"server:onResponse">;
|
|
12
|
-
handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
|
|
13
|
-
body: Record<string, unknown>;
|
|
14
|
-
cleanup: () => Promise<void>;
|
|
15
|
-
}>;
|
|
16
|
-
parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
|
|
17
|
-
}
|
|
18
|
-
interface MultipartResult {
|
|
19
|
-
fields: Record<string, string | string[]>;
|
|
20
|
-
files: Record<string, HybridFile>;
|
|
21
|
-
}
|
|
22
|
-
interface HybridFile extends FileLike {
|
|
23
|
-
cleanup(): Promise<void>;
|
|
24
|
-
_state: {
|
|
25
|
-
cleanup: boolean;
|
|
26
|
-
size: number;
|
|
27
|
-
tmpPath: string;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/index.d.ts
|
|
32
|
-
/**
|
|
33
|
-
* This module provides support for handling multipart/form-data requests.
|
|
34
|
-
* It allows to parse body data containing t.file().
|
|
35
|
-
*
|
|
36
|
-
* @see {@link ServerMultipartProvider}
|
|
37
|
-
* @module alepha.server.multipart
|
|
38
|
-
*/
|
|
39
|
-
declare const AlephaServerMultipart: _alepha_core0.Service<_alepha_core0.Module>;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { AlephaServerMultipart, ServerMultipartProvider };
|
|
42
|
-
//# sourceMappingURL=index.d.ts.map
|
package/server/multipart.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@alepha/server-multipart'
|
package/server/proxy.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
});
|
package/server/proxy.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import * as _alepha_core1 from "alepha";
|
|
2
|
-
import { Alepha, Async, Descriptor, KIND } from "alepha";
|
|
3
|
-
import { ServerHandler, ServerRequest, ServerRouterProvider } from "alepha/server";
|
|
4
|
-
import * as _alepha_logger0 from "alepha/logger";
|
|
5
|
-
|
|
6
|
-
//#region src/descriptors/$proxy.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a proxy descriptor to forward requests to another server.
|
|
10
|
-
*
|
|
11
|
-
* This descriptor enables you to create reverse proxy functionality, allowing your Alepha server
|
|
12
|
-
* to forward requests to other services while maintaining a unified API surface. It's particularly
|
|
13
|
-
* useful for microservice architectures, API gateways, or when you need to aggregate multiple
|
|
14
|
-
* services behind a single endpoint.
|
|
15
|
-
*
|
|
16
|
-
* **Key Features**
|
|
17
|
-
*
|
|
18
|
-
* - **Path-based routing**: Match specific paths or patterns to proxy
|
|
19
|
-
* - **Dynamic targets**: Support both static and dynamic target resolution
|
|
20
|
-
* - **Request/Response hooks**: Modify requests before forwarding and responses after receiving
|
|
21
|
-
* - **URL rewriting**: Transform URLs before forwarding to the target
|
|
22
|
-
* - **Conditional proxying**: Enable/disable proxies based on environment or conditions
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* **Basic proxy setup:**
|
|
26
|
-
* ```ts
|
|
27
|
-
* import { $proxy } from "alepha/server-proxy";
|
|
28
|
-
*
|
|
29
|
-
* class ApiGateway {
|
|
30
|
-
* // Forward all /api/* requests to external service
|
|
31
|
-
* api = $proxy({
|
|
32
|
-
* path: "/api/*",
|
|
33
|
-
* target: "https://api.example.com"
|
|
34
|
-
* });
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* **Dynamic target with environment-based routing:**
|
|
40
|
-
* ```ts
|
|
41
|
-
* class ApiGateway {
|
|
42
|
-
* // Route to different environments based on configuration
|
|
43
|
-
* api = $proxy({
|
|
44
|
-
* path: "/api/*",
|
|
45
|
-
* target: () => process.env.NODE_ENV === "production"
|
|
46
|
-
* ? "https://api.prod.example.com"
|
|
47
|
-
* : "https://api.dev.example.com"
|
|
48
|
-
* });
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* **Advanced proxy with request/response modification:**
|
|
54
|
-
* ```ts
|
|
55
|
-
* class SecureProxy {
|
|
56
|
-
* secure = $proxy({
|
|
57
|
-
* path: "/secure/*",
|
|
58
|
-
* target: "https://secure-api.example.com",
|
|
59
|
-
* beforeRequest: async (request, proxyRequest) => {
|
|
60
|
-
* // Add authentication headers
|
|
61
|
-
* proxyRequest.headers = {
|
|
62
|
-
* ...proxyRequest.headers,
|
|
63
|
-
* 'Authorization': `Bearer ${await getServiceToken()}`,
|
|
64
|
-
* 'X-Forwarded-For': request.headers['x-forwarded-for'] || request.ip
|
|
65
|
-
* };
|
|
66
|
-
* },
|
|
67
|
-
* afterResponse: async (request, proxyResponse) => {
|
|
68
|
-
* // Log response for monitoring
|
|
69
|
-
* console.log(`Proxied ${request.url} -> ${proxyResponse.status}`);
|
|
70
|
-
* },
|
|
71
|
-
* rewrite: (url) => {
|
|
72
|
-
* // Remove /secure prefix when forwarding
|
|
73
|
-
* url.pathname = url.pathname.replace('/secure', '');
|
|
74
|
-
* }
|
|
75
|
-
* });
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* **Conditional proxy based on feature flags:**
|
|
81
|
-
* ```ts
|
|
82
|
-
* class FeatureProxy {
|
|
83
|
-
* newApi = $proxy({
|
|
84
|
-
* path: "/v2/*",
|
|
85
|
-
* target: "https://new-api.example.com",
|
|
86
|
-
* disabled: !process.env.ENABLE_V2_API // Disable if feature flag is off
|
|
87
|
-
* });
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare const $proxy: {
|
|
92
|
-
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
93
|
-
[KIND]: typeof ProxyDescriptor;
|
|
94
|
-
};
|
|
95
|
-
type ProxyDescriptorOptions = {
|
|
96
|
-
/**
|
|
97
|
-
* Path pattern to match for proxying requests.
|
|
98
|
-
*
|
|
99
|
-
* Supports wildcards and path parameters:
|
|
100
|
-
* - `/api/*` - Matches all paths starting with `/api/`
|
|
101
|
-
* - `/api/v1/*` - Matches all paths starting with `/api/v1/`
|
|
102
|
-
* - `/users/:id` - Matches `/users/123`, `/users/abc`, etc.
|
|
103
|
-
*
|
|
104
|
-
* @example "/api/*"
|
|
105
|
-
* @example "/secure/admin/*"
|
|
106
|
-
* @example "/users/:id/posts"
|
|
107
|
-
*/
|
|
108
|
-
path: string;
|
|
109
|
-
/**
|
|
110
|
-
* Target URL to which matching requests should be forwarded.
|
|
111
|
-
*
|
|
112
|
-
* Can be either:
|
|
113
|
-
* - **Static string**: A fixed URL like `"https://api.example.com"`
|
|
114
|
-
* - **Dynamic function**: A function that returns the URL, enabling runtime target resolution
|
|
115
|
-
*
|
|
116
|
-
* The target URL will be combined with the remaining path from the original request.
|
|
117
|
-
*
|
|
118
|
-
* @example "https://api.example.com"
|
|
119
|
-
* @example () => process.env.API_URL || "http://localhost:3001"
|
|
120
|
-
*/
|
|
121
|
-
target: string | (() => string);
|
|
122
|
-
/**
|
|
123
|
-
* Whether this proxy is disabled.
|
|
124
|
-
*
|
|
125
|
-
* When `true`, requests matching the path will not be proxied and will be handled
|
|
126
|
-
* by other routes or return 404. Useful for feature toggles or conditional proxying.
|
|
127
|
-
*
|
|
128
|
-
* @default false
|
|
129
|
-
* @example !process.env.ENABLE_PROXY
|
|
130
|
-
*/
|
|
131
|
-
disabled?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Hook called before forwarding the request to the target server.
|
|
134
|
-
*
|
|
135
|
-
* Use this to:
|
|
136
|
-
* - Add authentication headers
|
|
137
|
-
* - Modify request headers or body
|
|
138
|
-
* - Add request tracking/logging
|
|
139
|
-
* - Transform the request before forwarding
|
|
140
|
-
*
|
|
141
|
-
* @param request - The original incoming server request
|
|
142
|
-
* @param proxyRequest - The request that will be sent to the target (modifiable)
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```ts
|
|
146
|
-
* beforeRequest: async (request, proxyRequest) => {
|
|
147
|
-
* proxyRequest.headers = {
|
|
148
|
-
* ...proxyRequest.headers,
|
|
149
|
-
* 'Authorization': `Bearer ${await getToken()}`,
|
|
150
|
-
* 'X-Request-ID': generateRequestId()
|
|
151
|
-
* };
|
|
152
|
-
* }
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Hook called after receiving the response from the target server.
|
|
158
|
-
*
|
|
159
|
-
* Use this to:
|
|
160
|
-
* - Log response details for monitoring
|
|
161
|
-
* - Add custom headers to the response
|
|
162
|
-
* - Transform response data
|
|
163
|
-
* - Handle error responses
|
|
164
|
-
*
|
|
165
|
-
* @param request - The original incoming server request
|
|
166
|
-
* @param proxyResponse - The response received from the target server
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* ```ts
|
|
170
|
-
* afterResponse: async (request, proxyResponse) => {
|
|
171
|
-
* console.log(`Proxy ${request.method} ${request.url} -> ${proxyResponse.status}`);
|
|
172
|
-
*
|
|
173
|
-
* if (!proxyResponse.ok) {
|
|
174
|
-
* await logError(`Proxy error: ${proxyResponse.status}`, { request, response: proxyResponse });
|
|
175
|
-
* }
|
|
176
|
-
* }
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
179
|
-
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
180
|
-
/**
|
|
181
|
-
* Function to rewrite the URL before sending to the target server.
|
|
182
|
-
*
|
|
183
|
-
* Use this to:
|
|
184
|
-
* - Remove or add path prefixes
|
|
185
|
-
* - Transform path parameters
|
|
186
|
-
* - Modify query parameters
|
|
187
|
-
* - Change the URL structure entirely
|
|
188
|
-
*
|
|
189
|
-
* The function receives a mutable URL object and should modify it in-place.
|
|
190
|
-
*
|
|
191
|
-
* @param url - The URL object to modify (mutable)
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* // Remove /api prefix when forwarding
|
|
196
|
-
* rewrite: (url) => {
|
|
197
|
-
* url.pathname = url.pathname.replace('/api', '');
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```ts
|
|
203
|
-
* // Add version prefix
|
|
204
|
-
* rewrite: (url) => {
|
|
205
|
-
* url.pathname = `/v2${url.pathname}`;
|
|
206
|
-
* }
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
rewrite?: (url: URL) => void;
|
|
210
|
-
};
|
|
211
|
-
declare class ProxyDescriptor extends Descriptor<ProxyDescriptorOptions> {}
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/providers/ServerProxyProvider.d.ts
|
|
214
|
-
declare class ServerProxyProvider {
|
|
215
|
-
protected readonly log: _alepha_logger0.Logger;
|
|
216
|
-
protected readonly routerProvider: ServerRouterProvider;
|
|
217
|
-
protected readonly alepha: Alepha;
|
|
218
|
-
protected readonly configure: _alepha_core1.HookDescriptor<"configure">;
|
|
219
|
-
createProxy(options: ProxyDescriptorOptions): void;
|
|
220
|
-
createProxyHandler(target: string, options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
|
|
221
|
-
private getRawRequestBody;
|
|
222
|
-
}
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/index.d.ts
|
|
225
|
-
/**
|
|
226
|
-
* Plugin for Alepha that provides a proxy server functionality.
|
|
227
|
-
*
|
|
228
|
-
* @see {@link $proxy}
|
|
229
|
-
* @module alepha.server.proxy
|
|
230
|
-
*/
|
|
231
|
-
declare const AlephaServerProxy: _alepha_core1.Service<_alepha_core1.Module>;
|
|
232
|
-
//#endregion
|
|
233
|
-
export { $proxy, AlephaServerProxy, ProxyDescriptor, ProxyDescriptorOptions, ServerProxyProvider };
|
|
234
|
-
//# sourceMappingURL=index.d.ts.map
|
package/server/proxy.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@alepha/server-proxy'
|
package/server/security.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var m = require('@alepha/server-security');
|
|
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
|
-
});
|