alepha 0.7.4 → 0.7.6

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 (99) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +44 -21
  3. package/cache/redis.cjs +4 -8
  4. package/cache/redis.d.ts +30 -91
  5. package/cache/redis.js +1 -1
  6. package/cache.cjs +4 -8
  7. package/cache.d.ts +190 -259
  8. package/cache.js +1 -1
  9. package/core.cjs +4 -8
  10. package/core.d.ts +950 -925
  11. package/core.js +1 -1
  12. package/datetime.cjs +4 -8
  13. package/datetime.d.ts +151 -140
  14. package/datetime.js +1 -1
  15. package/lock/redis.cjs +7 -49
  16. package/lock/redis.d.ts +17 -14
  17. package/lock/redis.js +1 -47
  18. package/lock.cjs +4 -8
  19. package/lock.d.ts +117 -170
  20. package/lock.js +1 -1
  21. package/package.json +70 -40
  22. package/postgres.cjs +4 -8
  23. package/postgres.d.ts +1314 -4400
  24. package/postgres.js +1 -1
  25. package/queue/redis.cjs +8 -0
  26. package/queue/redis.d.ts +31 -0
  27. package/queue/redis.js +1 -0
  28. package/queue.cjs +4 -8
  29. package/queue.d.ts +162 -205
  30. package/queue.js +1 -1
  31. package/react/auth.cjs +4 -8
  32. package/react/auth.d.ts +167 -280
  33. package/react/auth.js +1 -1
  34. package/react.cjs +4 -8
  35. package/react.d.ts +530 -570
  36. package/react.js +1 -1
  37. package/redis.cjs +4 -8
  38. package/redis.d.ts +59 -132
  39. package/redis.js +1 -1
  40. package/retry.cjs +4 -8
  41. package/retry.d.ts +34 -31
  42. package/retry.js +1 -1
  43. package/scheduler.cjs +4 -8
  44. package/scheduler.d.ts +128 -155
  45. package/scheduler.js +1 -1
  46. package/security.cjs +4 -8
  47. package/security.d.ts +472 -595
  48. package/security.js +1 -1
  49. package/server/cache.cjs +4 -8
  50. package/server/cache.d.ts +73 -39
  51. package/server/cache.js +1 -1
  52. package/server/cookies.cjs +4 -8
  53. package/server/cookies.d.ts +46 -41
  54. package/server/cookies.js +1 -1
  55. package/server/static.cjs +4 -8
  56. package/server/static.d.ts +98 -95
  57. package/server/static.js +1 -1
  58. package/server/swagger.cjs +4 -8
  59. package/server/swagger.d.ts +106 -92
  60. package/server/swagger.js +1 -1
  61. package/server.cjs +4 -8
  62. package/server.d.ts +754 -1025
  63. package/server.js +1 -1
  64. package/testing.cjs +8 -0
  65. package/testing.d.ts +1 -0
  66. package/testing.js +1 -0
  67. package/topic/redis.cjs +8 -0
  68. package/topic/redis.d.ts +45 -0
  69. package/topic/redis.js +1 -0
  70. package/topic.cjs +4 -8
  71. package/topic.d.ts +171 -163
  72. package/topic.js +1 -1
  73. package/vite.cjs +4 -8
  74. package/vite.d.ts +91 -84
  75. package/vite.js +1 -1
  76. package/assets/logo.png +0 -0
  77. package/src/cache/redis.ts +0 -1
  78. package/src/cache.ts +0 -1
  79. package/src/core.ts +0 -1
  80. package/src/datetime.ts +0 -1
  81. package/src/lock/redis.ts +0 -1
  82. package/src/lock.ts +0 -1
  83. package/src/postgres.ts +0 -1
  84. package/src/queue/redis.ts +0 -1
  85. package/src/queue.ts +0 -1
  86. package/src/react/auth.ts +0 -1
  87. package/src/react.ts +0 -1
  88. package/src/redis.ts +0 -1
  89. package/src/retry.ts +0 -1
  90. package/src/scheduler.ts +0 -1
  91. package/src/security.ts +0 -1
  92. package/src/server/cache.ts +0 -1
  93. package/src/server/cookies.ts +0 -1
  94. package/src/server/static.ts +0 -1
  95. package/src/server/swagger.ts +0 -1
  96. package/src/server.ts +0 -1
  97. package/src/topic/redis.ts +0 -1
  98. package/src/topic.ts +0 -1
  99. package/src/vite.ts +0 -1
package/server.d.ts CHANGED
@@ -1,795 +1,476 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Static as Static$1, TObject as TObject$1, TSchema as TSchema$2, Async, StreamLike, Alepha, FileLike, OPTIONS, KIND, Module } from '@alepha/core';
3
- export { KIND } from '@alepha/core';
4
- import { UserAccountToken, Permission, ServiceAccountDescriptor as ServiceAccountDescriptor$1, SecurityProvider, JwtProvider } from '@alepha/security';
5
- import { IncomingMessage, ServerResponse as ServerResponse$1 } from 'node:http';
6
- import { Readable } from 'node:stream';
7
- import { ReadableStream } from 'node:stream/web';
8
- import { Route, RouterProvider } from '@alepha/router';
9
- import * as _alepha_cache from '@alepha/cache';
10
- import { DurationLike, DateTimeProvider } from '@alepha/datetime';
11
- import * as _alepha_retry from '@alepha/retry';
12
- import { BusboyConfig } from '@fastify/busboy';
13
- import * as http from 'http';
14
-
15
- /** Symbol key applied to readonly types */
16
- declare const ReadonlyKind$1: unique symbol;
17
- /** Symbol key applied to optional types */
18
- declare const OptionalKind$1: unique symbol;
19
- /** Symbol key applied to types */
20
- declare const Hint$1: unique symbol;
21
- /** Symbol key applied to types */
22
- declare const Kind$1: unique symbol;
23
-
24
- interface TAny extends TSchema$1 {
25
- [Kind$1]: 'Any';
26
- static: any;
27
- }
28
-
29
- type TReadonly<T extends TSchema$1> = T & {
30
- [ReadonlyKind$1]: 'Readonly';
31
- };
32
-
33
- type UnionStatic<T extends TSchema$1[], P extends unknown[]> = {
34
- [K in keyof T]: T[K] extends TSchema$1 ? Static<T[K], P> : never;
35
- }[number];
36
- interface TUnion<T extends TSchema$1[] = TSchema$1[]> extends TSchema$1 {
37
- [Kind$1]: 'Union';
38
- static: UnionStatic<T, this['params']>;
39
- anyOf: T;
40
- }
41
-
42
- type StringFormatOption$1 = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
43
- type StringContentEncodingOption$1 = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
44
- interface StringOptions$1 extends SchemaOptions$1 {
45
- /** The maximum string length */
46
- maxLength?: number;
47
- /** The minimum string length */
48
- minLength?: number;
49
- /** A regular expression pattern this string should match */
50
- pattern?: string;
51
- /** A format this string should match */
52
- format?: StringFormatOption$1;
53
- /** The content encoding for this string */
54
- contentEncoding?: StringContentEncodingOption$1;
55
- /** The content media type for this string */
56
- contentMediaType?: string;
57
- }
58
- interface TString$1 extends TSchema$1, StringOptions$1 {
59
- [Kind$1]: 'String';
60
- static: string;
61
- type: 'string';
62
- }
63
-
64
- interface TBoolean extends TSchema$1 {
65
- [Kind$1]: 'Boolean';
66
- static: boolean;
67
- type: 'boolean';
68
- }
69
-
70
- interface NumberOptions extends SchemaOptions$1 {
71
- exclusiveMaximum?: number;
72
- exclusiveMinimum?: number;
73
- maximum?: number;
74
- minimum?: number;
75
- multipleOf?: number;
76
- }
77
- interface TNumber extends TSchema$1, NumberOptions {
78
- [Kind$1]: 'Number';
79
- static: number;
80
- type: 'number';
81
- }
82
-
83
- interface IntegerOptions extends SchemaOptions$1 {
84
- exclusiveMaximum?: number;
85
- exclusiveMinimum?: number;
86
- maximum?: number;
87
- minimum?: number;
88
- multipleOf?: number;
89
- }
90
- interface TInteger extends TSchema$1, IntegerOptions {
91
- [Kind$1]: 'Integer';
92
- static: number;
93
- type: 'integer';
94
- }
95
-
96
- type TOptional<T extends TSchema$1> = T & {
97
- [OptionalKind$1]: 'Optional';
98
- };
99
-
100
- type RecordStatic<Key extends TSchema$1, Type extends TSchema$1, P extends unknown[]> = (Evaluate<{
101
- [_ in Assert<Static<Key>, PropertyKey>]: Static<Type, P>;
102
- }>);
103
- interface TRecord<Key extends TSchema$1 = TSchema$1, Type extends TSchema$1 = TSchema$1> extends TSchema$1 {
104
- [Kind$1]: 'Record';
105
- static: RecordStatic<Key, Type, this['params']>;
106
- type: 'object';
107
- patternProperties: {
108
- [pattern: string]: Type;
109
- };
110
- additionalProperties: TAdditionalProperties;
111
- }
112
-
113
- /** Creates a static type from a TypeBox type */
114
- type Static<Type extends TSchema$1, Params extends unknown[] = [], Result = (Type & {
115
- params: Params;
116
- })['static']> = Result;
117
-
118
- type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
119
- [K in keyof T]: T[K] extends TReadonly<TSchema$1> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
120
- }[keyof T];
121
- type ReadonlyPropertyKeys<T extends TProperties> = {
122
- [K in keyof T]: T[K] extends TReadonly<TSchema$1> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
123
- }[keyof T];
124
- type OptionalPropertyKeys<T extends TProperties> = {
125
- [K in keyof T]: T[K] extends TOptional<TSchema$1> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
126
- }[keyof T];
127
- type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
128
- type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
129
- type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
130
- [K in keyof T]: Static<T[K], P>;
131
- }>;
132
- type TPropertyKey = string | number;
133
- type TProperties = Record<TPropertyKey, TSchema$1>;
134
- type TAdditionalProperties = undefined | TSchema$1 | boolean;
135
- interface ObjectOptions extends SchemaOptions$1 {
136
- /** Additional property constraints for this object */
137
- additionalProperties?: TAdditionalProperties;
138
- /** The minimum number of properties allowed on this object */
139
- minProperties?: number;
140
- /** The maximum number of properties allowed on this object */
141
- maxProperties?: number;
142
- }
143
- interface TObject<T extends TProperties = TProperties> extends TSchema$1, ObjectOptions {
144
- [Kind$1]: 'Object';
145
- static: ObjectStatic<T, this['params']>;
146
- additionalProperties?: TAdditionalProperties;
147
- type: 'object';
148
- properties: T;
149
- required?: string[];
150
- }
151
-
152
- type Assert<T, E> = T extends E ? T : never;
153
- type Evaluate<T> = T extends infer O ? {
154
- [K in keyof O]: O[K];
155
- } : never;
156
- type Ensure<T> = T extends infer U ? U : never;
157
-
158
- interface ArrayOptions extends SchemaOptions$1 {
159
- /** The minimum number of items in this array */
160
- minItems?: number;
161
- /** The maximum number of items in this array */
162
- maxItems?: number;
163
- /** Should this schema contain unique items */
164
- uniqueItems?: boolean;
165
- /** A schema for which some elements should match */
166
- contains?: TSchema$1;
167
- /** A minimum number of contains schema matches */
168
- minContains?: number;
169
- /** A maximum number of contains schema matches */
170
- maxContains?: number;
171
- }
172
- type ArrayStatic<T extends TSchema$1, P extends unknown[]> = Ensure<Static<T, P>[]>;
173
- interface TArray<T extends TSchema$1 = TSchema$1> extends TSchema$1, ArrayOptions {
174
- [Kind$1]: 'Array';
175
- static: ArrayStatic<T, this['params']>;
176
- type: 'array';
177
- items: T;
178
- }
179
-
180
- interface SchemaOptions$1 {
181
- $schema?: string;
182
- /** Id for this schema */
183
- $id?: string;
184
- /** Title of this schema */
185
- title?: string;
186
- /** Description of this schema */
187
- description?: string;
188
- /** Default value for this schema */
189
- default?: any;
190
- /** Example values matching this schema */
191
- examples?: any;
192
- /** Optional annotation for readOnly */
193
- readOnly?: boolean;
194
- /** Optional annotation for writeOnly */
195
- writeOnly?: boolean;
196
- [prop: string]: any;
197
- }
198
- interface TKind$1 {
199
- [Kind$1]: string;
200
- }
201
- interface TSchema$1 extends TKind$1, SchemaOptions$1 {
202
- [ReadonlyKind$1]?: string;
203
- [OptionalKind$1]?: string;
204
- [Hint$1]?: string;
205
- params: unknown[];
206
- static: unknown;
207
- }
208
-
1
+ import * as _alepha_core5 from "@alepha/core";
2
+ import * as _alepha_core57 from "@alepha/core";
3
+ import * as _alepha_core61 from "@alepha/core";
4
+ import * as _alepha_core109 from "@alepha/core";
5
+ import * as _alepha_core43 from "@alepha/core";
6
+ import * as _alepha_core47 from "@alepha/core";
7
+ import * as _alepha_core49 from "@alepha/core";
8
+ import * as _alepha_core50 from "@alepha/core";
9
+ import * as _alepha_core54 from "@alepha/core";
10
+ import * as _alepha_core103 from "@alepha/core";
11
+ import * as _alepha_core3 from "@alepha/core";
12
+ import { Alepha, Async, FileLike, KIND, KIND as KIND$1, Module, OPTIONS, Static, StreamLike, TObject, TSchema } from "@alepha/core";
13
+ import { JwtProvider, Permission, SecurityProvider, ServiceAccountDescriptor, UserAccountToken } from "@alepha/security";
14
+ import { DateTimeProvider, DurationLike } from "@alepha/datetime";
15
+ import * as _alepha_cache6 from "@alepha/cache";
16
+ import * as _alepha_retry112 from "@alepha/retry";
17
+ import { Readable } from "node:stream";
18
+ import { ReadableStream } from "node:stream/web";
19
+ import { Route, RouterProvider } from "@alepha/router";
20
+ import { BusboyConfig } from "@fastify/busboy";
21
+ import { IncomingMessage, ServerResponse as ServerResponse$1 } from "node:http";
22
+ import * as _sinclair_typebox65 from "@sinclair/typebox";
23
+ import * as _sinclair_typebox15 from "@sinclair/typebox";
24
+ import * as _sinclair_typebox59 from "@sinclair/typebox";
25
+ import * as _sinclair_typebox21 from "@sinclair/typebox";
26
+ import * as _sinclair_typebox101 from "@sinclair/typebox";
27
+ import * as _sinclair_typebox91 from "@sinclair/typebox";
28
+ import * as _sinclair_typebox7 from "@sinclair/typebox";
29
+ import * as _sinclair_typebox1 from "@sinclair/typebox";
30
+ import * as http106 from "http";
31
+
32
+ //#region src/constants/routeMethods.d.ts
209
33
  declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
210
34
  type RouteMethod = (typeof routeMethods)[number];
211
-
212
- declare const envSchema$4: TObject$1<{
213
- SERVER_ALS_ENABLED: TBoolean;
214
- }>;
215
- declare module "alepha" {
216
- interface Env extends Partial<Static$1<typeof envSchema$4>> {
217
- }
218
- }
219
- /**
220
- * Main router for all routes on the server side.
221
- *
222
- * Remember:
223
- * - $route => generic route
224
- * - $action => action route (for API calls)
225
- * - $page => React route (for SSR)
226
- */
227
- declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler> {
228
- protected readonly alepha: Alepha;
229
- protected readonly env: {
230
- SERVER_ALS_ENABLED: boolean;
231
- };
232
- createRequestId(): string;
233
- route<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): Promise<void>;
234
- onRequest(route: ServerRoute, rawRequest: ServerRawRequest, responseType: ResponseType, withAls: boolean): Promise<ServerResponse>;
235
- protected processRequest(request: ServerRequest, route: ServerRoute, responseType: ResponseType, withAls: boolean): Promise<{
236
- status: number;
237
- headers: Record<string, string> & {
238
- "set-cookie"?: string[];
239
- };
240
- body: any;
241
- }>;
242
- protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseType: ResponseType, withAls: boolean): Promise<void>;
243
- protected getResponseType(schema?: RequestConfigSchema): ResponseType;
244
- protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
245
- validateRequest(route: {
246
- schema?: RequestConfigSchema;
247
- }, request: ServerRequestConfig): void;
248
- serializeResponse(route: ServerRoute, reply: ServerReply, responseType: ResponseType): void;
249
- }
35
+ //#endregion
36
+ //#region src/interfaces/index.d.ts
250
37
  interface RequestConfigSchema {
251
- body?: TSchema$2;
252
- params?: TObject$1;
253
- query?: TObject$1;
254
- headers?: TObject$1;
255
- response?: TSchema$2;
38
+ body?: TSchema;
39
+ params?: TObject;
40
+ query?: TObject;
41
+ headers?: TObject;
42
+ response?: TSchema;
256
43
  }
257
44
  interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
258
- body: TConfig["body"] extends TSchema$2 ? Static$1<TConfig["body"]> : any;
259
- headers: TConfig["headers"] extends TObject$1 ? Static$1<TConfig["headers"]> : Record<string, string>;
260
- params: TConfig["params"] extends TObject$1 ? Static$1<TConfig["params"]> : Record<string, string>;
261
- query: TConfig["query"] extends TObject$1 ? Static$1<TConfig["query"]> : Record<string, string>;
45
+ body: TConfig["body"] extends TSchema ? Static<TConfig["body"]> : any;
46
+ headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
47
+ params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
48
+ query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, string>;
262
49
  }
263
50
  type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
264
51
  interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
265
- method: RouteMethod;
266
- url: URL;
267
- metadata: Record<string, any>;
268
- reply: ServerReply;
269
- raw: {
270
- node?: {
271
- req: IncomingMessage;
272
- res: ServerResponse$1;
273
- };
52
+ method: RouteMethod;
53
+ url: URL;
54
+ metadata: Record<string, any>;
55
+ reply: ServerReply;
56
+ raw: {
57
+ node?: {
58
+ req: IncomingMessage;
59
+ res: ServerResponse$1;
274
60
  };
275
- user: UserAccountToken;
61
+ };
62
+ user: UserAccountToken;
276
63
  }
277
64
  interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
278
- method?: RouteMethod;
279
- handler: ServerHandler<TConfig>;
280
- schema?: TConfig;
281
- /**
282
- * @see ServerLoggerProvider
283
- */
284
- silent?: boolean;
285
- /**
286
- * @see ServerSecurityProvider
287
- */
288
- secure?: ServerRouteSecure;
289
- }
290
- type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : ResponseBodyType;
291
- type ResponseType = "json" | "text" | "void" | "file" | "any";
65
+ method?: RouteMethod;
66
+ handler: ServerHandler<TConfig>;
67
+ schema?: TConfig;
68
+ /**
69
+ * @see ServerLoggerProvider
70
+ */
71
+ silent?: boolean;
72
+ /**
73
+ * @see ServerSecurityProvider
74
+ */
75
+ secure?: ServerRouteSecure;
76
+ }
77
+ type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : ResponseBodyType;
78
+ type ResponseKind = "json" | "text" | "void" | "file" | "any";
292
79
  type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
293
80
  type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
294
81
  type ServerMiddlewareHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig> | undefined>;
295
82
  interface ServerReply {
296
- headers: Record<string, string> & {
297
- "set-cookie"?: string[];
298
- };
299
- status?: number;
300
- body?: any;
301
- redirect(url: string): void;
83
+ headers: Record<string, string> & {
84
+ "set-cookie"?: string[];
85
+ };
86
+ status?: number;
87
+ body?: any;
88
+ redirect(url: string): void;
302
89
  }
303
90
  interface ServerResponse {
304
- body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
305
- headers: Record<string, string>;
306
- status: number;
91
+ body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
92
+ headers: Record<string, string>;
93
+ status: number;
307
94
  }
308
95
  interface ServerRouteWithHandler extends Route {
309
- handler: (request: ServerRawRequest) => Promise<ServerResponse>;
96
+ handler: (request: ServerRawRequest) => Promise<ServerResponse>;
310
97
  }
311
98
  interface ServerRawRequest {
312
- method: RouteMethod;
313
- url: URL;
314
- headers: Record<string, string>;
315
- query: Record<string, string>;
316
- params: Record<string, string>;
317
- raw: {
318
- node?: {
319
- req: IncomingMessage;
320
- res: ServerResponse$1;
321
- };
99
+ method: RouteMethod;
100
+ url: URL;
101
+ headers: Record<string, string>;
102
+ query: Record<string, string>;
103
+ params: Record<string, string>;
104
+ raw: {
105
+ node?: {
106
+ req: IncomingMessage;
107
+ res: ServerResponse$1;
322
108
  };
109
+ };
323
110
  }
324
111
  type ServerRouteSecure = boolean | {
325
- permissions?: string[];
326
- roles?: string[];
327
- realms?: string[];
328
- organizations?: string[];
112
+ permissions?: string[];
113
+ roles?: string[];
114
+ realms?: string[];
115
+ organizations?: string[];
329
116
  };
330
-
117
+ //#endregion
118
+ //#region src/helpers/ActionDescriptorHelper.d.ts
331
119
  declare class ActionDescriptorHelper {
332
- name(options: ActionDescriptorOptions, _instance: any, key: string): string;
333
- path(options: ActionDescriptorOptions, _instance: any, key: string): string;
334
- link(options: ActionDescriptorOptions, instance: any, key: string, prefix?: string): HttpClientLink;
335
- method(options: {
336
- method?: string;
337
- schema?: any;
338
- }): RouteMethod;
339
- permission(options: ActionDescriptorOptions, instance: any, key: string): Permission;
340
- group(options: ActionDescriptorOptions, instance: any): string;
341
- isMultipart(options: {
342
- schema?: RequestConfigSchema;
343
- }): boolean;
344
- bodyContentType(options: ActionDescriptorOptions): string | undefined;
345
- protected short(name: string): string;
346
- fetchLinks(_url: string): void;
347
- }
348
-
349
- declare const apiLinkSchema: TObject<{
350
- name: TString$1;
351
- path: TString$1;
352
- method: TOptional<TString$1>;
353
- group: TOptional<TString$1>;
354
- requestBodyType: TOptional<TString$1>;
355
- service: TOptional<TString$1>;
120
+ name(options: ActionDescriptorOptions, _instance: any, key: string): string;
121
+ path(options: ActionDescriptorOptions, _instance: any, key: string): string;
122
+ link(options: ActionDescriptorOptions, instance: any, key: string, prefix?: string): HttpClientLink;
123
+ method(options: {
124
+ method?: string;
125
+ schema?: any;
126
+ }): RouteMethod;
127
+ permission(options: ActionDescriptorOptions, instance: any, key: string): Permission;
128
+ group(options: ActionDescriptorOptions, instance: any): string;
129
+ isMultipart(options: {
130
+ schema?: RequestConfigSchema;
131
+ }): boolean;
132
+ bodyContentType(options: ActionDescriptorOptions): string | undefined;
133
+ protected short(name: string): string;
134
+ fetchLinks(_url: string): void;
135
+ }
136
+ //#endregion
137
+ //#region src/schemas/apiLinksResponseSchema.d.ts
138
+ declare const apiLinkSchema: _sinclair_typebox65.TObject<{
139
+ name: _sinclair_typebox65.TString;
140
+ path: _sinclair_typebox65.TString;
141
+ method: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
142
+ group: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
143
+ requestBodyType: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
144
+ service: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
356
145
  }>;
357
- declare const apiLinksResponseSchema: TObject<{
358
- prefix: TOptional<TString$1>;
359
- links: TArray<TObject<{
360
- name: TString$1;
361
- path: TString$1;
362
- method: TOptional<TString$1>;
363
- group: TOptional<TString$1>;
364
- requestBodyType: TOptional<TString$1>;
365
- service: TOptional<TString$1>;
366
- }>>;
146
+ declare const apiLinksResponseSchema: _sinclair_typebox65.TObject<{
147
+ prefix: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
148
+ links: _sinclair_typebox65.TArray<_sinclair_typebox65.TObject<{
149
+ name: _sinclair_typebox65.TString;
150
+ path: _sinclair_typebox65.TString;
151
+ method: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
152
+ group: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
153
+ requestBodyType: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
154
+ service: _sinclair_typebox65.TOptional<_sinclair_typebox65.TString>;
155
+ }>>;
367
156
  }>;
368
- type ApiLinksResponse = Static$1<typeof apiLinksResponseSchema>;
369
- type ApiLink = Static$1<typeof apiLinkSchema>;
370
-
157
+ type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
158
+ type ApiLink = Static<typeof apiLinkSchema>;
159
+ //#endregion
160
+ //#region src/services/HttpClient.d.ts
371
161
  declare class HttpClient {
372
- protected readonly log: _alepha_core.Logger;
373
- protected readonly alepha: Alepha;
374
- protected readonly helper: ActionDescriptorHelper;
375
- readonly cache: _alepha_cache.CacheDescriptor<HttpClientCache, any[]>;
376
- protected readonly pendingRequests: HttpClientPendingRequests;
377
- readonly URL_LINKS = "/api/_links";
378
- links?: Array<HttpClientLink>;
379
- pushLink(link: HttpClientLink): void;
380
- clear(): Promise<void>;
381
- fetch<T>(url: string, request?: RequestInit, options?: FetchRunOptions): Promise<FetchResponse<T>>;
382
- json<T = any>(url: string, options?: RequestInit): Promise<T>;
383
- protected url(host: string, link: HttpClientLink, args: ServerRequestConfigEntry): string;
384
- protected body(init: RequestInit, headers: Record<string, string>, link: HttpClientLink, args?: ServerRequestConfigEntry): Promise<void>;
385
- protected responseData(response: Response, options: FetchRunOptions): Promise<any>;
386
- protected isMaybeFile(response: Response): boolean;
387
- protected createFileLike(response: Response, defaultFileName?: string): FileLike;
388
- protected pathVariables(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
389
- protected queryParams(url: string, action: {
390
- schema?: {
391
- query?: TObject$1;
392
- };
393
- }, args?: ServerRequestConfigEntry): string;
394
- /**
395
- * Transform a link into a fetch-request then call fetch().
396
- */
397
- fetchLink(args: FetchLinkArgs): Promise<FetchResponse>;
398
- /**
399
- * Create a proxy client.
400
- * This allows to call actions as methods, e.g. `client.actionName()`.
401
- */
402
- of<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
403
- protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
404
- /**
405
- * Resolve a link by its name and call it.
406
- * - If link is local, it will call the local handler.
407
- * - If link is remote, it will make a fetch request to the remote server.
408
- */
409
- follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
410
- protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
411
- can(name: string): boolean;
412
- getLinks(force?: boolean): Promise<HttpClientLink[]>;
162
+ protected readonly log: _alepha_core5.Logger;
163
+ protected readonly alepha: Alepha;
164
+ protected readonly helper: ActionDescriptorHelper;
165
+ readonly cache: _alepha_cache6.CacheDescriptor<HttpClientCache, any[]>;
166
+ protected readonly pendingRequests: HttpClientPendingRequests;
167
+ readonly URL_LINKS = "/api/_links";
168
+ links?: Array<HttpClientLink>;
169
+ pushLink(link: HttpClientLink): void;
170
+ clear(): Promise<void>;
171
+ fetch<T>(url: string, request?: RequestInit, options?: FetchRunOptions): Promise<FetchResponse<T>>;
172
+ json<T = any>(url: string, options?: RequestInit): Promise<T>;
173
+ protected url(host: string, link: HttpClientLink, args: ServerRequestConfigEntry): string;
174
+ protected body(init: RequestInit, headers: Record<string, string>, link: HttpClientLink, args?: ServerRequestConfigEntry): Promise<void>;
175
+ protected responseData(response: Response, options: FetchRunOptions): Promise<any>;
176
+ protected isMaybeFile(response: Response): boolean;
177
+ protected createFileLike(response: Response, defaultFileName?: string): FileLike;
178
+ protected pathVariables(url: string, action: HttpClientLink, args?: ServerRequestConfigEntry): string;
179
+ protected queryParams(url: string, action: {
180
+ schema?: {
181
+ query?: TObject;
182
+ };
183
+ }, args?: ServerRequestConfigEntry): string;
184
+ /**
185
+ * Transform a link into a fetch-request then call fetch().
186
+ */
187
+ fetchLink(args: FetchLinkArgs): Promise<FetchResponse>;
188
+ /**
189
+ * Create a proxy client.
190
+ * This allows to call actions as methods, e.g. `client.actionName()`.
191
+ */
192
+ of<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
193
+ protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
194
+ /**
195
+ * Resolve a link by its name and call it.
196
+ * - If link is local, it will call the local handler.
197
+ * - If link is remote, it will make a fetch request to the remote server.
198
+ */
199
+ follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
200
+ protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
201
+ can(name: string): boolean;
202
+ getLinks(force?: boolean): Promise<HttpClientLink[]>;
413
203
  }
414
204
  type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
415
205
  interface FetchFactoryAdditionalOptions {
416
- host?: string | (() => string);
206
+ host?: string | (() => string);
417
207
  }
418
208
  interface FetchRunOptions {
419
- /**
420
- * Key to identify the request in the pending requests.
421
- */
422
- key?: string;
423
- /**
424
- * The schema to validate the response against.
425
- */
426
- schema?: TSchema$2;
427
- /**
428
- * Built-in cache options.
429
- */
430
- cache?: boolean | number | DurationLike;
209
+ /**
210
+ * Key to identify the request in the pending requests.
211
+ */
212
+ key?: string;
213
+ /**
214
+ * The schema to validate the response against.
215
+ */
216
+ schema?: TSchema;
217
+ /**
218
+ * Built-in cache options.
219
+ */
220
+ cache?: boolean | number | DurationLike;
431
221
  }
432
222
  interface HttpClientLink extends ApiLink {
433
- secured?: boolean;
434
- prefix?: string;
435
- host?: string;
436
- service?: string;
437
- schema?: RequestConfigSchema;
438
- handler?: ServerHandler;
223
+ secured?: boolean;
224
+ prefix?: string;
225
+ host?: string;
226
+ service?: string;
227
+ schema?: RequestConfigSchema;
228
+ handler?: ServerHandler;
439
229
  }
440
230
  interface ClientScope {
441
- group?: string;
442
- service?: string;
231
+ group?: string;
232
+ service?: string;
443
233
  }
444
- type HttpVirtualClient<T> = {
445
- [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
446
- can: () => boolean;
447
- schema: Schema;
448
- } : never;
449
- };
234
+ type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? T[K] & {
235
+ can: () => boolean;
236
+ schema: Schema;
237
+ } : never };
450
238
  interface HttpClientCache {
451
- data: any;
452
- etag?: string;
239
+ data: any;
240
+ etag?: string;
453
241
  }
454
242
  interface FetchResponse<T = any> {
455
- data: T;
456
- status: number;
457
- statusText: string;
458
- headers: Headers;
459
- raw?: Response;
243
+ data: T;
244
+ status: number;
245
+ statusText: string;
246
+ headers: Headers;
247
+ raw?: Response;
460
248
  }
461
249
  interface FetchLinkArgs {
462
- link: HttpClientLink;
463
- host?: string;
464
- config?: ServerRequestConfigEntry;
465
- options?: ClientRequestOptions;
250
+ link: HttpClientLink;
251
+ host?: string;
252
+ config?: ServerRequestConfigEntry;
253
+ options?: ClientRequestOptions;
466
254
  }
467
-
255
+ //#endregion
256
+ //#region src/descriptors/$action.d.ts
468
257
  declare const KEY$2 = "ACTION";
469
258
  interface ActionDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema"> {
470
- /**
471
- * Name the route.
472
- */
473
- name?: string;
474
- /**
475
- * Namespace of the route, used for grouping.
476
- *
477
- * @default Class name containing the route.
478
- */
479
- group?: string;
480
- /**
481
- * If false, disabled the security check for this route.
482
- *
483
- * @default true when SecurityModule is enabled, false otherwise.
484
- * @deprecated
485
- */
486
- security?: boolean;
487
- /**
488
- * Pathname of the route.
489
- */
490
- path?: string;
491
- /**
492
- * Inherit options from another route.
493
- */
494
- use?: {
495
- [OPTIONS]: ActionDescriptorOptions<TConfig>;
496
- };
497
- /**
498
- * The route method.
499
- *
500
- * @default "GET" or "POST" when schema body is defined.
501
- */
502
- method?: RouteMethod;
503
- /**
504
- * The config schema of the route.
505
- * - body: The request body schema.
506
- * - params: Path variables schema.
507
- * - query: The request query-params schema.
508
- * - response: The response schema.
509
- */
510
- schema?: TConfig;
511
- /**
512
- * Short description of the route.
513
- */
514
- summary?: string;
515
- /**
516
- * Long description of the route.
517
- */
518
- description?: string;
519
- /**
520
- * Disable the route. Useful with env variables do disable one specific route.
521
- */
522
- disabled?: boolean;
523
- /**
524
- * Mark the route as private.
525
- * - It won't be exposed in the API documentation.
526
- * - It won't be exposed in _links.
527
- */
528
- internal?: boolean;
529
- /**
530
- * Main route handler. This is where the route logic is implemented.
531
- */
532
- handler?: ServerHandler<TConfig>;
259
+ /**
260
+ * Name the route.
261
+ */
262
+ name?: string;
263
+ /**
264
+ * Namespace of the route, used for grouping.
265
+ *
266
+ * @default Class name containing the route.
267
+ */
268
+ group?: string;
269
+ /**
270
+ * If false, disabled the security check for this route.
271
+ *
272
+ * @default true when SecurityModule is enabled, false otherwise.
273
+ * @deprecated
274
+ */
275
+ security?: boolean;
276
+ /**
277
+ * Pathname of the route.
278
+ */
279
+ path?: string;
280
+ /**
281
+ * Inherit options from another route.
282
+ */
283
+ use?: {
284
+ [OPTIONS]: ActionDescriptorOptions<TConfig>;
285
+ };
286
+ /**
287
+ * The route method.
288
+ *
289
+ * @default "GET" or "POST" when schema body is defined.
290
+ */
291
+ method?: RouteMethod;
292
+ /**
293
+ * The config schema of the route.
294
+ * - body: The request body schema.
295
+ * - params: Path variables schema.
296
+ * - query: The request query-params schema.
297
+ * - response: The response schema.
298
+ */
299
+ schema?: TConfig;
300
+ /**
301
+ * Short description of the route.
302
+ */
303
+ summary?: string;
304
+ /**
305
+ * Long description of the route.
306
+ */
307
+ description?: string;
308
+ /**
309
+ * Disable the route. Useful with env variables do disable one specific route.
310
+ */
311
+ disabled?: boolean;
312
+ /**
313
+ * Mark the route as private.
314
+ * - It won't be exposed in the API documentation.
315
+ * - It won't be exposed in _links.
316
+ */
317
+ internal?: boolean;
318
+ /**
319
+ * Main route handler. This is where the route logic is implemented.
320
+ */
321
+ handler?: ServerHandler<TConfig>;
533
322
  }
534
323
  interface ActionDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> {
535
- [KIND]: typeof KEY$2;
536
- [OPTIONS]: ActionDescriptorOptions<TConfig>;
537
- /**
538
- * Fetch or just call local route when available.
539
- */
540
- (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
541
- /**
542
- * Just fetch the route. Skip any local route.
543
- */
544
- fetch: (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions) => Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
545
- /**
546
- * Name of the permission required to access this route.
547
- */
548
- permission: () => string;
324
+ [KIND$1]: typeof KEY$2;
325
+ [OPTIONS]: ActionDescriptorOptions<TConfig>;
326
+ /**
327
+ * Fetch or just call local route when available.
328
+ */
329
+ (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
330
+ /**
331
+ * Just fetch the route. Skip any local route.
332
+ */
333
+ fetch: (config?: ClientRequestEntry<TConfig>, opts?: ClientRequestOptions) => Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
334
+ /**
335
+ * Name of the permission required to access this route.
336
+ */
337
+ permission: () => string;
549
338
  }
550
339
  declare const $action: {
551
- <TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
552
- [KIND]: string;
553
- };
554
- type ClientRequestEntry<TConfig extends RequestConfigSchema = RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = {
555
- [K in keyof T as T[K] extends undefined ? never : K]: T[K];
340
+ <TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptor<TConfig>;
341
+ [KIND$1]: string;
556
342
  };
343
+ type ClientRequestEntry<TConfig extends RequestConfigSchema = RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
557
344
  type ClientRequestEntryContainer<TConfig extends RequestConfigSchema = RequestConfigSchema> = {
558
- body: TConfig["body"] extends TSchema$2 ? Static$1<TConfig["body"]> : undefined;
559
- params: TConfig["params"] extends TSchema$2 ? Static$1<TConfig["params"]> : undefined;
560
- headers?: TConfig["headers"] extends TSchema$2 ? Static$1<TConfig["headers"]> : undefined;
561
- query?: TConfig["query"] extends TSchema$2 ? Partial<Static$1<TConfig["query"]>> : undefined;
345
+ body: TConfig["body"] extends TSchema ? Static<TConfig["body"]> : undefined;
346
+ params: TConfig["params"] extends TSchema ? Static<TConfig["params"]> : undefined;
347
+ headers?: TConfig["headers"] extends TSchema ? Static<TConfig["headers"]> : undefined;
348
+ query?: TConfig["query"] extends TSchema ? Partial<Static<TConfig["query"]>> : undefined;
562
349
  };
563
350
  interface ClientRequestOptions extends FetchRunOptions {
564
- /**
565
- * Forward user from the previous request.
566
- * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
567
- * If "context", use the user from the current context (e.g. request).
568
- *
569
- * @default "system" is provided, else "context" is used.
570
- */
571
- user?: UserAccountToken | "system" | "context";
572
- /**
573
- * Standard request fetch options.
574
- */
575
- request?: RequestInit;
576
- }
577
- type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema$2 ? Static$1<TConfig["response"]> : any;
578
-
351
+ /**
352
+ * Forward user from the previous request.
353
+ * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
354
+ * If "context", use the user from the current context (e.g. request).
355
+ *
356
+ * @default "system" is provided, else "context" is used.
357
+ */
358
+ user?: UserAccountToken | "system" | "context";
359
+ /**
360
+ * Standard request fetch options.
361
+ */
362
+ request?: RequestInit;
363
+ }
364
+ type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
365
+ //#endregion
366
+ //#region src/errors/HttpError.d.ts
579
367
  declare class HttpError extends Error {
580
- static toJSON(error: HttpError): {
581
- status: number;
582
- error: string | undefined;
583
- message: string;
584
- cause: {
585
- name: string;
586
- message: string;
587
- };
588
- } | {
589
- status: number;
590
- error: string | undefined;
591
- message: string;
592
- cause?: undefined;
593
- };
594
- readonly status: number;
595
- readonly error?: string;
596
- readonly reason?: {
597
- name: string;
598
- message: string;
368
+ static toJSON(error: HttpError): {
369
+ status: number;
370
+ error: string | undefined;
371
+ message: string;
372
+ cause: {
373
+ name: string;
374
+ message: string;
599
375
  };
600
- constructor(options: {
601
- error?: string;
602
- message: string;
603
- status: number;
604
- cause?: {
605
- name: string;
606
- message: string;
607
- } | unknown;
608
- }, cause?: unknown);
376
+ } | {
377
+ status: number;
378
+ error: string | undefined;
379
+ message: string;
380
+ cause?: undefined;
381
+ };
382
+ readonly status: number;
383
+ readonly error?: string;
384
+ readonly reason?: {
385
+ name: string;
386
+ message: string;
387
+ };
388
+ constructor(options: {
389
+ error?: string;
390
+ message: string;
391
+ status: number;
392
+ cause?: {
393
+ name: string;
394
+ message: string;
395
+ } | unknown;
396
+ }, cause?: unknown);
609
397
  }
610
398
  declare const errorNameByStatus: Record<number, string>;
611
399
  declare const isHttpError: (error: unknown) => error is HttpErrorLike;
612
400
  interface HttpErrorLike extends Error {
613
- status: number;
401
+ status: number;
614
402
  }
615
-
403
+ //#endregion
404
+ //#region src/descriptors/$client.d.ts
616
405
  declare const $client: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
617
-
406
+ //#endregion
407
+ //#region src/descriptors/$proxy.d.ts
618
408
  type ProxyDescriptorOptions = {
619
- path: string;
620
- target: string;
621
- disabled?: boolean;
622
- beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
623
- afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
624
- rewrite?: (url: URL) => void;
409
+ path: string;
410
+ target: string;
411
+ disabled?: boolean;
412
+ beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
413
+ afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
414
+ rewrite?: (url: URL) => void;
625
415
  };
626
416
  interface ProxyDescriptor {
627
- [KIND]: "PROXY";
628
- [OPTIONS]: ProxyDescriptorOptions;
417
+ [KIND$1]: "PROXY";
418
+ [OPTIONS]: ProxyDescriptorOptions;
629
419
  }
630
420
  declare const $proxy: {
631
- (options: ProxyDescriptorOptions): ProxyDescriptor;
632
- [KIND]: string;
421
+ (options: ProxyDescriptorOptions): ProxyDescriptor;
422
+ [KIND$1]: string;
633
423
  };
634
-
635
- /**
636
- * Represents a User Account extracted from JWT.
637
- */
638
- interface UserAccountInfo {
639
- /**
640
- * ID of user account. Based on JWT.sub.
641
- */
642
- id: string;
643
- /**
644
- * Represents the roles assigned to a user.
645
- */
646
- roles?: string[];
647
- /**
648
- * User full name, if available.
649
- */
650
- name?: string;
651
- /**
652
- * User email, if available.
653
- */
654
- email?: string;
655
- /**
656
- * User profile picture URL, if available.
657
- */
658
- picture?: string;
659
- /**
660
- * Organization ID, if available.
661
- */
662
- organization?: string;
663
- }
664
-
665
- /** Symbol key applied to readonly types */
666
- declare const ReadonlyKind: unique symbol;
667
- /** Symbol key applied to optional types */
668
- declare const OptionalKind: unique symbol;
669
- /** Symbol key applied to types */
670
- declare const Hint: unique symbol;
671
- /** Symbol key applied to types */
672
- declare const Kind: unique symbol;
673
-
674
- type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
675
- type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
676
- interface StringOptions extends SchemaOptions {
677
- /** The maximum string length */
678
- maxLength?: number;
679
- /** The minimum string length */
680
- minLength?: number;
681
- /** A regular expression pattern this string should match */
682
- pattern?: string;
683
- /** A format this string should match */
684
- format?: StringFormatOption;
685
- /** The content encoding for this string */
686
- contentEncoding?: StringContentEncodingOption;
687
- /** The content media type for this string */
688
- contentMediaType?: string;
689
- }
690
- interface TString extends TSchema, StringOptions {
691
- [Kind]: 'String';
692
- static: string;
693
- type: 'string';
694
- }
695
-
696
- interface SchemaOptions {
697
- $schema?: string;
698
- /** Id for this schema */
699
- $id?: string;
700
- /** Title of this schema */
701
- title?: string;
702
- /** Description of this schema */
703
- description?: string;
704
- /** Default value for this schema */
705
- default?: any;
706
- /** Example values matching this schema */
707
- examples?: any;
708
- /** Optional annotation for readOnly */
709
- readOnly?: boolean;
710
- /** Optional annotation for writeOnly */
711
- writeOnly?: boolean;
712
- [prop: string]: any;
713
- }
714
- interface TKind {
715
- [Kind]: string;
716
- }
717
- interface TSchema extends TKind, SchemaOptions {
718
- [ReadonlyKind]?: string;
719
- [OptionalKind]?: string;
720
- [Hint]?: string;
721
- params: unknown[];
722
- static: unknown;
723
- }
724
-
725
- declare const envSchema$3: _alepha_core.TObject<{
726
- SECURITY_SECRET_KEY: TString;
727
- }>;
728
- interface ServiceAccountDescriptor {
729
- token: () => Promise<string>;
730
- }
731
- declare module "alepha/core" {
732
- interface Env extends Partial<Static$1<typeof envSchema$3>> {
733
- }
734
- }
735
-
736
- declare module "@alepha/core" {
737
- interface Hooks {
738
- "security:user:created": {
739
- realm: string;
740
- user: UserAccountInfo;
741
- };
742
- }
743
- }
744
-
424
+ //#endregion
425
+ //#region src/descriptors/$remote.d.ts
745
426
  declare const KEY$1 = "REMOTE";
746
427
  interface RemoteDescriptorOptions {
747
- /**
748
- * The URL of the remote service.
749
- * You can use a function to generate the URL dynamically.
750
- * You probably should use $inject(env) to get the URL from the environment.
751
- *
752
- * @example
753
- * ```ts
754
- * import { $remote } from "@alepha/server";
755
- * import { $inject, t } from "@alepha/core";
756
- *
757
- * class App {
758
- * env = $inject(t.object({
759
- * REMOTE_URL: t.string({default: "http://localhost:3000"}),
760
- * }));
761
- * remote = $remote({
762
- * url: this.env.REMOTE_URL,
763
- * });
764
- * }
765
- * ```
766
- */
767
- url: string | (() => string);
768
- /**
769
- * The name of the remote service.
770
- *
771
- * @default Member of the class containing the remote service.
772
- */
773
- name?: string;
774
- /**
775
- * If true, all methods of the remote service will be exposed as actions in this context.
776
- * > Note: Proxy will never use the service account, it just... proxies the request.
777
- */
778
- proxy?: boolean | Partial<ProxyDescriptorOptions & {
779
- /**
780
- * If true, the remote service won't be available internally, only through the proxy.
781
- */
782
- noInternal: boolean;
783
- }>;
784
- /**
785
- * For communication between the server and the remote service with a security layer.
786
- * This will be used for internal communication and will not be exposed to the client.
787
- */
788
- serviceAccount?: ServiceAccountDescriptor;
428
+ /**
429
+ * The URL of the remote service.
430
+ * You can use a function to generate the URL dynamically.
431
+ * You probably should use $inject(env) to get the URL from the environment.
432
+ *
433
+ * @example
434
+ * ```ts
435
+ * import { $remote } from "@alepha/server";
436
+ * import { $inject, t } from "@alepha/core";
437
+ *
438
+ * class App {
439
+ * env = $inject(t.object({
440
+ * REMOTE_URL: t.string({default: "http://localhost:3000"}),
441
+ * }));
442
+ * remote = $remote({
443
+ * url: this.env.REMOTE_URL,
444
+ * });
445
+ * }
446
+ * ```
447
+ */
448
+ url: string | (() => string);
449
+ /**
450
+ * The name of the remote service.
451
+ *
452
+ * @default Member of the class containing the remote service.
453
+ */
454
+ name?: string;
455
+ /**
456
+ * If true, all methods of the remote service will be exposed as actions in this context.
457
+ * > Note: Proxy will never use the service account, it just... proxies the request.
458
+ */
459
+ proxy?: boolean | Partial<ProxyDescriptorOptions & {
460
+ /**
461
+ * If true, the remote service won't be available internally, only through the proxy.
462
+ */
463
+ noInternal: boolean;
464
+ }>;
465
+ /**
466
+ * For communication between the server and the remote service with a security layer.
467
+ * This will be used for internal communication and will not be exposed to the client.
468
+ */
469
+ serviceAccount?: ServiceAccountDescriptor;
789
470
  }
790
471
  interface RemoteDescriptor {
791
- [KIND]: typeof KEY$1;
792
- [OPTIONS]: RemoteDescriptorOptions;
472
+ [KIND$1]: typeof KEY$1;
473
+ [OPTIONS]: RemoteDescriptorOptions;
793
474
  }
794
475
  /**
795
476
  * $remote is a descriptor that allows you to define a remote service access.
@@ -801,242 +482,285 @@ interface RemoteDescriptor {
801
482
  * You can add a service account if you want to use a security layer.
802
483
  */
803
484
  declare const $remote: {
804
- (options: RemoteDescriptorOptions): RemoteDescriptor;
805
- [KIND]: string;
485
+ (options: RemoteDescriptorOptions): RemoteDescriptor;
486
+ [KIND$1]: string;
806
487
  };
807
-
488
+ //#endregion
489
+ //#region src/descriptors/$route.d.ts
808
490
  declare const KEY = "ROUTE";
809
- interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {
810
- }
491
+ interface RouteDescriptorOptions<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {}
811
492
  type RouteDescriptor<TConfig extends RequestConfigSchema = RequestConfigSchema> = {
812
- [KIND]: typeof KEY;
813
- [OPTIONS]: RouteDescriptorOptions<TConfig>;
493
+ [KIND$1]: typeof KEY;
494
+ [OPTIONS]: RouteDescriptorOptions<TConfig>;
814
495
  };
815
496
  declare const $route: {
816
- <TConfig extends RequestConfigSchema = RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
817
- [KIND]: string;
497
+ <TConfig extends RequestConfigSchema = RequestConfigSchema>(options: RouteDescriptorOptions<TConfig>): RouteDescriptor<TConfig>;
498
+ [KIND$1]: string;
818
499
  };
819
-
500
+ //#endregion
501
+ //#region src/errors/BadRequestError.d.ts
820
502
  declare class BadRequestError extends HttpError {
821
- constructor(message?: string, cause?: unknown);
503
+ constructor(message?: string, cause?: unknown);
822
504
  }
823
-
505
+ //#endregion
506
+ //#region src/errors/ConflictError.d.ts
824
507
  declare class ConflictError extends HttpError {
825
- constructor(message?: string, cause?: unknown);
508
+ constructor(message?: string, cause?: unknown);
826
509
  }
827
-
510
+ //#endregion
511
+ //#region src/errors/ForbiddenError.d.ts
828
512
  declare class ForbiddenError extends HttpError {
829
- constructor(message?: string, cause?: unknown);
513
+ constructor(message?: string, cause?: unknown);
830
514
  }
831
-
515
+ //#endregion
516
+ //#region src/errors/NotFoundError.d.ts
832
517
  declare class NotFoundError extends HttpError {
833
- constructor(message?: string, cause?: unknown);
518
+ constructor(message?: string, cause?: unknown);
834
519
  }
835
-
520
+ //#endregion
521
+ //#region src/errors/UnauthorizedError.d.ts
836
522
  declare class UnauthorizedError extends HttpError {
837
- constructor(message?: string, cause?: unknown);
523
+ constructor(message?: string, cause?: unknown);
838
524
  }
839
-
525
+ //#endregion
526
+ //#region src/errors/ValidationError.d.ts
840
527
  declare class ValidationError extends HttpError {
841
- constructor(message?: string, cause?: unknown);
528
+ constructor(message?: string, cause?: unknown);
842
529
  }
843
-
530
+ //#endregion
531
+ //#region src/providers/features/ServerHealthProvider.d.ts
844
532
  /**
845
533
  * Register `/health` endpoint.
846
534
  *
847
535
  * - Provides basic health information about the server.
848
536
  */
849
537
  declare class ServerHealthProvider {
850
- protected readonly dateTimeProvider: DateTimeProvider;
851
- protected readonly alepha: Alepha;
852
- readonly health: RouteDescriptor<{
853
- response: TObject<{
854
- message: TString$1;
855
- uptime: TNumber;
856
- date: TString$1;
857
- ready: TBoolean;
858
- }>;
538
+ protected readonly dateTimeProvider: DateTimeProvider;
539
+ protected readonly alepha: Alepha;
540
+ readonly health: RouteDescriptor<{
541
+ response: _sinclair_typebox15.TObject<{
542
+ message: _sinclair_typebox15.TString;
543
+ uptime: _sinclair_typebox15.TNumber;
544
+ date: _sinclair_typebox15.TString;
545
+ ready: _sinclair_typebox15.TBoolean;
859
546
  }>;
547
+ }>;
860
548
  }
861
-
862
- declare class ProxyDescriptorProvider {
863
- protected readonly log: _alepha_core.Logger;
864
- protected readonly routerProvider: ServerRouterProvider;
865
- protected readonly alepha: Alepha;
866
- readonly configure: _alepha_core.HookDescriptor<"configure">;
867
- createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
868
- proxy(options: ProxyDescriptorOptions): Promise<void>;
869
- private getRawRequestBody;
549
+ //#endregion
550
+ //#region src/providers/ServerRouterProvider.d.ts
551
+ /**
552
+ * Main router for all routes on the server side.
553
+ *
554
+ * - $route => generic route
555
+ * - $action => action route (for API calls)
556
+ * - $page => React route (for SSR)
557
+ */
558
+ declare class ServerRouterProvider extends RouterProvider<ServerRouteWithHandler> {
559
+ protected readonly alepha: Alepha;
560
+ createRequestId(): string;
561
+ route<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): Promise<void>;
562
+ onRequest(route: ServerRoute, rawRequest: ServerRawRequest, responseKind: ResponseKind): Promise<ServerResponse>;
563
+ protected processRequest(request: ServerRequest, route: ServerRoute, responseKind: ResponseKind): Promise<{
564
+ status: number;
565
+ headers: Record<string, string> & {
566
+ "set-cookie"?: string[];
567
+ };
568
+ body: any;
569
+ }>;
570
+ protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseKind: ResponseKind): Promise<void>;
571
+ protected getResponseType(schema?: RequestConfigSchema): ResponseKind;
572
+ protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
573
+ validateRequest(route: {
574
+ schema?: RequestConfigSchema;
575
+ }, request: ServerRequestConfig): void;
576
+ serializeResponse(route: ServerRoute, reply: ServerReply, responseKind: ResponseKind): void;
870
577
  }
871
-
578
+ //#endregion
579
+ //#region src/providers/ProxyDescriptorProvider.d.ts
580
+ declare class ProxyDescriptorProvider {
581
+ protected readonly log: _alepha_core57.Logger;
582
+ protected readonly routerProvider: ServerRouterProvider;
583
+ protected readonly alepha: Alepha;
584
+ readonly configure: _alepha_core57.HookDescriptor<"configure">;
585
+ createProxyHandler(options: Omit<ProxyDescriptorOptions, "path">): ServerHandler;
586
+ proxy(options: ProxyDescriptorOptions): Promise<void>;
587
+ private getRawRequestBody;
588
+ }
589
+ //#endregion
590
+ //#region src/providers/platforms/ServerProvider.d.ts
872
591
  declare class ServerProvider {
873
- constructor();
874
- get hostname(): string;
875
- }
876
-
877
- declare const envSchema$2: _alepha_core.TObject<{
878
- SERVER_API_PREFIX: TString$1;
879
- SERVER_SECURITY_ENABLED: TBoolean;
592
+ constructor();
593
+ get hostname(): string;
594
+ }
595
+ //#endregion
596
+ //#region src/providers/ServerActionDescriptorProvider.d.ts
597
+ declare const envSchema$2: _alepha_core61.TObject<{
598
+ SERVER_API_PREFIX: _sinclair_typebox59.TString;
599
+ SERVER_SECURITY_ENABLED: _sinclair_typebox59.TBoolean;
880
600
  }>;
881
- declare module "@alepha/core" {
882
- interface Env extends Partial<Static$1<typeof envSchema$2>> {
883
- }
884
- interface State {
885
- /**
886
- * Real (or fake) user account, used for internal actions.
887
- * If you define this, you assume that all actions are executed by this user by default.
888
- * And to force a different user, you need to pass it explicitly in the options.
889
- */
890
- "ServerSecurityProvider.localSystemUser"?: UserAccountToken;
891
- }
892
- }
893
- declare class ServerActionDescriptorProvider {
894
- protected readonly log: _alepha_core.Logger;
895
- protected readonly alepha: Alepha;
896
- protected readonly env: {
897
- SERVER_API_PREFIX: string;
898
- SERVER_SECURITY_ENABLED: boolean;
899
- };
900
- protected readonly client: HttpClient;
901
- protected readonly serverProvider: ServerProvider;
902
- protected readonly helper: ActionDescriptorHelper;
903
- protected readonly routerProvider: ServerRouterProvider;
904
- protected readonly actions: ServerRouteAction[];
905
- getActions(): ServerRouteAction<RequestConfigSchema>[];
906
- getPrefix(): string;
907
- readonly configure: _alepha_core.HookDescriptor<"configure">;
908
- registerAction(value: ActionDescriptor, key: string, instance: any, prefix?: string): Promise<void>;
909
- /**
910
- * Check a mock function for the specified route.
911
- *
912
- * This is mostly used for testing purposes.
913
- */
914
- protected createLocalFunction(action: ActionDescriptorOptions, permission: Permission): (config?: ServerRequestConfigEntry, options?: ClientRequestOptions) => Promise<any>;
601
+ declare module "alepha" {
602
+ interface Env extends Partial<Static<typeof envSchema$2>> {}
603
+ interface State {
915
604
  /**
916
- * Get the user account token for a local action call.
917
- * It will check the options, context, and system user.
605
+ * Real (or fake) user account, used for internal actions.
606
+ * If you define this, you assume that all actions are executed by this user by default.
607
+ * And to force a different user, you need to pass it explicitly in the options.
918
608
  */
919
- protected getUserFromLocalFunctionContext(options: {
920
- user?: UserAccountToken | "system" | "context";
921
- }, permission: Permission, isRouteSecure: boolean): UserAccountToken | undefined;
609
+ "ServerSecurityProvider.localSystemUser"?: UserAccountToken;
610
+ }
611
+ }
612
+ declare class ServerActionDescriptorProvider {
613
+ protected readonly log: _alepha_core61.Logger;
614
+ protected readonly alepha: Alepha;
615
+ protected readonly env: {
616
+ SERVER_API_PREFIX: string;
617
+ SERVER_SECURITY_ENABLED: boolean;
618
+ };
619
+ protected readonly client: HttpClient;
620
+ protected readonly serverProvider: ServerProvider;
621
+ protected readonly helper: ActionDescriptorHelper;
622
+ protected readonly routerProvider: ServerRouterProvider;
623
+ protected readonly actions: ServerRouteAction[];
624
+ getActions(): ServerRouteAction<RequestConfigSchema>[];
625
+ getPrefix(): string;
626
+ readonly configure: _alepha_core61.HookDescriptor<"configure">;
627
+ registerAction(value: ActionDescriptor, key: string, instance: any, prefix?: string): Promise<void>;
628
+ /**
629
+ * Check a mock function for the specified route.
630
+ *
631
+ * This is mostly used for testing purposes.
632
+ */
633
+ protected createLocalFunction(action: ActionDescriptorOptions, permission: Permission): (config?: ServerRequestConfigEntry, options?: ClientRequestOptions) => Promise<any>;
634
+ /**
635
+ * Get the user account token for a local action call.
636
+ * It will check the options, context, and system user.
637
+ */
638
+ protected getUserFromLocalFunctionContext(options: {
639
+ user?: UserAccountToken | "system" | "context";
640
+ }, permission: Permission, isRouteSecure: boolean): UserAccountToken | undefined;
922
641
  }
923
642
  declare const isServerAction: (value: any) => value is ServerRouteAction;
924
643
  interface ServerRemote {
925
- url: string;
644
+ url: string;
645
+ name: string;
646
+ proxy: boolean;
647
+ internal: boolean;
648
+ links: (args: {
649
+ authorization?: string;
650
+ }) => Promise<ApiLinksResponse>;
651
+ schema: (args: {
926
652
  name: string;
927
- proxy: boolean;
928
- internal: boolean;
929
- links: (args: {
930
- authorization?: string;
931
- }) => Promise<ApiLinksResponse>;
932
- schema: (args: {
933
- name: string;
934
- authorization?: string;
935
- }) => Promise<any>;
936
- serviceAccount?: ServiceAccountDescriptor$1;
937
- prefix: string;
653
+ authorization?: string;
654
+ }) => Promise<any>;
655
+ serviceAccount?: ServiceAccountDescriptor;
656
+ prefix: string;
938
657
  }
939
658
  interface ServerRouteAction<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRoute<TConfig> {
940
- prefix: string;
941
- method: RouteMethod;
942
- name: string;
943
- group: string;
944
- permission: Permission;
945
- options: ActionDescriptorOptions;
946
- }
947
-
659
+ prefix: string;
660
+ method: RouteMethod;
661
+ name: string;
662
+ group: string;
663
+ permission: Permission;
664
+ options: ActionDescriptorOptions;
665
+ }
666
+ //#endregion
667
+ //#region src/providers/RemoteDescriptorProvider.d.ts
948
668
  declare class RemoteDescriptorProvider {
949
- static path: {
950
- apiLinks: string;
951
- };
952
- protected readonly alepha: Alepha;
953
- protected readonly client: HttpClient;
954
- protected readonly proxyProvider: ProxyDescriptorProvider;
955
- protected readonly remotes: Array<ServerRemote>;
956
- protected readonly log: _alepha_core.Logger;
957
- getRemotes(): ServerRemote[];
958
- readonly configure: _alepha_core.HookDescriptor<"configure">;
959
- readonly start: _alepha_core.HookDescriptor<"start">;
960
- registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
961
- protected readonly fetchLinks: _alepha_retry.RetryDescriptor<(opts: {
962
- service: string;
963
- url: string;
964
- authorization?: string;
965
- }) => Promise<{
966
- prefix?: string | undefined;
967
- links: {
968
- method?: string | undefined;
969
- group?: string | undefined;
970
- requestBodyType?: string | undefined;
971
- service?: string | undefined;
972
- path: string;
973
- name: string;
974
- }[];
975
- }>>;
976
- }
977
-
669
+ static path: {
670
+ apiLinks: string;
671
+ };
672
+ protected readonly alepha: Alepha;
673
+ protected readonly client: HttpClient;
674
+ protected readonly proxyProvider: ProxyDescriptorProvider;
675
+ protected readonly remotes: Array<ServerRemote>;
676
+ protected readonly log: _alepha_core109.Logger;
677
+ getRemotes(): ServerRemote[];
678
+ readonly configure: _alepha_core109.HookDescriptor<"configure">;
679
+ readonly start: _alepha_core109.HookDescriptor<"start">;
680
+ registerRemote(value: RemoteDescriptor, key: string): Promise<void>;
681
+ protected readonly fetchLinks: _alepha_retry112.RetryDescriptor<(opts: {
682
+ service: string;
683
+ url: string;
684
+ authorization?: string;
685
+ }) => Promise<{
686
+ prefix?: string | undefined;
687
+ links: {
688
+ method?: string | undefined;
689
+ group?: string | undefined;
690
+ requestBodyType?: string | undefined;
691
+ service?: string | undefined;
692
+ name: string;
693
+ path: string;
694
+ }[];
695
+ }>>;
696
+ }
697
+ //#endregion
698
+ //#region src/providers/features/ServerLinksProvider.d.ts
978
699
  declare class ServerLinksProvider {
979
- protected readonly alepha: Alepha;
980
- protected readonly client: HttpClient;
981
- protected readonly remoteProvider: RemoteDescriptorProvider;
982
- protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
983
- readonly links: RouteDescriptor<{
984
- response: TObject<{
985
- prefix: TOptional<TString$1>;
986
- links: TArray<TObject<{
987
- name: TString$1;
988
- path: TString$1;
989
- method: TOptional<TString$1>;
990
- group: TOptional<TString$1>;
991
- requestBodyType: TOptional<TString$1>;
992
- service: TOptional<TString$1>;
993
- }>>;
994
- }>;
700
+ protected readonly alepha: Alepha;
701
+ protected readonly client: HttpClient;
702
+ protected readonly remoteProvider: RemoteDescriptorProvider;
703
+ protected readonly serverActionDescriptorProvider: ServerActionDescriptorProvider;
704
+ readonly links: RouteDescriptor<{
705
+ response: _sinclair_typebox21.TObject<{
706
+ prefix: _sinclair_typebox21.TOptional<_sinclair_typebox21.TString>;
707
+ links: _sinclair_typebox21.TArray<_sinclair_typebox21.TObject<{
708
+ name: _sinclair_typebox21.TString;
709
+ path: _sinclair_typebox21.TString;
710
+ method: _sinclair_typebox21.TOptional<_sinclair_typebox21.TString>;
711
+ group: _sinclair_typebox21.TOptional<_sinclair_typebox21.TString>;
712
+ requestBodyType: _sinclair_typebox21.TOptional<_sinclair_typebox21.TString>;
713
+ service: _sinclair_typebox21.TOptional<_sinclair_typebox21.TString>;
714
+ }>>;
995
715
  }>;
996
- readonly schema: RouteDescriptor<{
997
- params: TObject<{
998
- name: TString$1;
999
- }>;
1000
- response: TRecord<TString$1, TAny>;
716
+ }>;
717
+ readonly schema: RouteDescriptor<{
718
+ params: _sinclair_typebox21.TObject<{
719
+ name: _sinclair_typebox21.TString;
1001
720
  }>;
1002
- getLinks(options: {
1003
- user?: UserAccountToken;
1004
- authorization?: string;
1005
- }): Promise<ApiLinksResponse>;
1006
- }
1007
-
721
+ response: _sinclair_typebox21.TRecord<_sinclair_typebox21.TString, _sinclair_typebox21.TAny>;
722
+ }>;
723
+ getLinks(options: {
724
+ user?: UserAccountToken;
725
+ authorization?: string;
726
+ }): Promise<ApiLinksResponse>;
727
+ }
728
+ //#endregion
729
+ //#region src/providers/features/ServerLoggerProvider.d.ts
1008
730
  declare class ServerLoggerProvider {
1009
- protected readonly log: _alepha_core.Logger;
1010
- protected readonly alepha: Alepha;
1011
- readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1012
- readonly onError: _alepha_core.HookDescriptor<"server:onError">;
1013
- readonly onResponse: _alepha_core.HookDescriptor<"server:onResponse">;
1014
- }
1015
-
731
+ protected readonly log: _alepha_core43.Logger;
732
+ protected readonly alepha: Alepha;
733
+ readonly onRequest: _alepha_core43.HookDescriptor<"server:onRequest">;
734
+ readonly onError: _alepha_core43.HookDescriptor<"server:onError">;
735
+ readonly onResponse: _alepha_core43.HookDescriptor<"server:onResponse">;
736
+ }
737
+ //#endregion
738
+ //#region src/providers/features/ServerMultipartProvider.d.ts
1016
739
  declare class ServerMultipartProvider {
1017
- protected readonly helper: ActionDescriptorHelper;
1018
- protected readonly alepha: Alepha;
1019
- readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1020
- readonly onSend: _alepha_core.HookDescriptor<"server:onResponse">;
1021
- handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
1022
- body: Record<string, any>;
1023
- cleanup: () => Promise<void>;
1024
- }>;
1025
- parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
740
+ protected readonly helper: ActionDescriptorHelper;
741
+ protected readonly alepha: Alepha;
742
+ readonly onRequest: _alepha_core47.HookDescriptor<"server:onRequest">;
743
+ readonly onSend: _alepha_core47.HookDescriptor<"server:onResponse">;
744
+ handleMultipartBodyFromNode(route: ServerRoute, stream: IncomingMessage): Promise<{
745
+ body: Record<string, any>;
746
+ cleanup: () => Promise<void>;
747
+ }>;
748
+ parseMultipart(req: IncomingMessage, config?: Omit<BusboyConfig, "headers">): Promise<MultipartResult>;
1026
749
  }
1027
750
  interface MultipartResult {
1028
- fields: Record<string, string | string[]>;
1029
- files: Record<string, HybridFile>;
751
+ fields: Record<string, string | string[]>;
752
+ files: Record<string, HybridFile>;
1030
753
  }
1031
754
  interface HybridFile extends FileLike {
1032
- cleanup(): Promise<void>;
1033
- _state: {
1034
- cleanup: boolean;
1035
- size: number;
1036
- tmpPath: string;
1037
- };
1038
- }
1039
-
755
+ cleanup(): Promise<void>;
756
+ _state: {
757
+ cleanup: boolean;
758
+ size: number;
759
+ tmpPath: string;
760
+ };
761
+ }
762
+ //#endregion
763
+ //#region src/providers/features/ServerNotReadyProvider.d.ts
1040
764
  /**
1041
765
  * On every request, this provider checks if the server is ready.
1042
766
  *
@@ -1045,134 +769,139 @@ interface HybridFile extends FileLike {
1045
769
  * The response also includes a `Retry-After` header indicating that the client should retry after 5 seconds.
1046
770
  */
1047
771
  declare class ServerNotReadyProvider {
1048
- protected readonly alepha: Alepha;
1049
- readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
772
+ protected readonly alepha: Alepha;
773
+ readonly onRequest: _alepha_core49.HookDescriptor<"server:onRequest">;
1050
774
  }
1051
-
775
+ //#endregion
776
+ //#region src/providers/features/ServerSecurityProvider.d.ts
1052
777
  declare class ServerSecurityProvider {
1053
- protected readonly log: _alepha_core.Logger;
1054
- protected readonly securityProvider: SecurityProvider;
1055
- protected readonly jwtProvider: JwtProvider;
1056
- protected readonly alepha: Alepha;
1057
- readonly onClientRequest: _alepha_core.HookDescriptor<"client:onRequest">;
1058
- protected readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1059
- protected readonly onRoute: _alepha_core.HookDescriptor<"server:onRoute">;
1060
- }
1061
-
778
+ protected readonly log: _alepha_core50.Logger;
779
+ protected readonly securityProvider: SecurityProvider;
780
+ protected readonly jwtProvider: JwtProvider;
781
+ protected readonly alepha: Alepha;
782
+ readonly onClientRequest: _alepha_core50.HookDescriptor<"client:onRequest">;
783
+ protected readonly onRequest: _alepha_core50.HookDescriptor<"server:onRequest">;
784
+ protected readonly onRoute: _alepha_core50.HookDescriptor<"server:onRoute">;
785
+ }
786
+ //#endregion
787
+ //#region src/providers/features/ServerTimingProvider.d.ts
1062
788
  type TimingMap = Record<string, [number, number]>;
1063
789
  declare class ServerTimingProvider {
1064
- protected readonly log: _alepha_core.Logger;
1065
- protected readonly alepha: Alepha;
1066
- readonly onRequest: _alepha_core.HookDescriptor<"server:onRequest">;
1067
- readonly onResponse: _alepha_core.HookDescriptor<"server:onResponse">;
1068
- protected get handlerName(): string;
1069
- beginTiming(name: string): void;
1070
- endTiming(name: string): void;
1071
- protected setDuration(name: string, timing: TimingMap): void;
1072
- }
1073
-
1074
- declare const envSchema$1: _alepha_core.TObject<{
1075
- SERVER_PORT: TNumber;
1076
- SERVER_HOST: TString$1;
790
+ protected readonly log: _alepha_core54.Logger;
791
+ protected readonly alepha: Alepha;
792
+ readonly onRequest: _alepha_core54.HookDescriptor<"server:onRequest">;
793
+ readonly onResponse: _alepha_core54.HookDescriptor<"server:onResponse">;
794
+ protected get handlerName(): string;
795
+ beginTiming(name: string): void;
796
+ endTiming(name: string): void;
797
+ protected setDuration(name: string, timing: TimingMap): void;
798
+ }
799
+ //#endregion
800
+ //#region src/providers/platforms/NodeHttpServerProvider.d.ts
801
+ declare const envSchema$1: _alepha_core103.TObject<{
802
+ SERVER_PORT: _sinclair_typebox101.TNumber;
803
+ SERVER_HOST: _sinclair_typebox101.TString;
1077
804
  }>;
1078
- declare module "@alepha/core" {
1079
- interface Env extends Partial<Static$1<typeof envSchema$1>> {
1080
- }
805
+ declare module "alepha/core" {
806
+ interface Env extends Partial<Static<typeof envSchema$1>> {}
1081
807
  }
1082
808
  declare class NodeHttpServerProvider implements ServerProvider {
1083
- protected readonly alepha: Alepha;
1084
- protected readonly log: _alepha_core.Logger;
1085
- protected readonly env: {
1086
- SERVER_PORT: number;
1087
- SERVER_HOST: string;
1088
- };
1089
- protected readonly router: ServerRouterProvider;
1090
- protected readonly server: http.Server<typeof IncomingMessage, typeof ServerResponse$1>;
1091
- handle(req: IncomingMessage, res: ServerResponse$1): Promise<number | void>;
1092
- createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
1093
- getProtocol(req: IncomingMessage): "http" | "https";
1094
- shouldHaveBody(method: string): boolean;
1095
- get hostname(): string;
1096
- readonly start: _alepha_core.HookDescriptor<"start">;
1097
- protected readonly stop: _alepha_core.HookDescriptor<"stop">;
1098
- protected listen(): Promise<void>;
1099
- protected close(): Promise<void>;
1100
- }
1101
-
1102
- declare const errorSchema: TObject<{
1103
- error: TString$1;
1104
- status: TNumber;
1105
- message: TString$1;
1106
- details: TOptional<TString$1>;
1107
- cause: TOptional<TObject<{
1108
- name: TString$1;
1109
- message: TString$1;
1110
- }>>;
809
+ protected readonly alepha: Alepha;
810
+ protected readonly log: _alepha_core103.Logger;
811
+ protected readonly env: {
812
+ SERVER_PORT: number;
813
+ SERVER_HOST: string;
814
+ };
815
+ protected readonly router: ServerRouterProvider;
816
+ protected readonly server: http106.Server<typeof IncomingMessage, typeof ServerResponse$1>;
817
+ handle(req: IncomingMessage, res: ServerResponse$1): Promise<number | void>;
818
+ createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
819
+ getProtocol(req: IncomingMessage): "http" | "https";
820
+ shouldHaveBody(method: string): boolean;
821
+ get hostname(): string;
822
+ readonly start: _alepha_core103.HookDescriptor<"start">;
823
+ protected readonly stop: _alepha_core103.HookDescriptor<"stop">;
824
+ protected listen(): Promise<void>;
825
+ protected close(): Promise<void>;
826
+ }
827
+ //#endregion
828
+ //#region src/schemas/errorSchema.d.ts
829
+ declare const errorSchema: _sinclair_typebox91.TObject<{
830
+ error: _sinclair_typebox91.TString;
831
+ status: _sinclair_typebox91.TNumber;
832
+ message: _sinclair_typebox91.TString;
833
+ details: _sinclair_typebox91.TOptional<_sinclair_typebox91.TString>;
834
+ cause: _sinclair_typebox91.TOptional<_sinclair_typebox91.TObject<{
835
+ name: _sinclair_typebox91.TString;
836
+ message: _sinclair_typebox91.TString;
837
+ }>>;
1111
838
  }>;
1112
-
1113
- declare const okSchema: TObject<{
1114
- ok: TBoolean;
1115
- id: TOptional<TUnion<[TString$1, TInteger]>>;
1116
- count: TOptional<TNumber>;
1117
- }>;
1118
- type Ok = Static$1<typeof okSchema>;
1119
-
1120
- declare const envSchema: _alepha_core.TObject<{
1121
- SERVER_LINKS_ENABLED: TBoolean;
1122
- SERVER_HEALTH_ENABLED: TBoolean;
839
+ //#endregion
840
+ //#region src/schemas/okSchema.d.ts
841
+ declare const okSchema: _sinclair_typebox7.TObject<{
842
+ ok: _sinclair_typebox7.TBoolean;
843
+ id: _sinclair_typebox7.TOptional<_sinclair_typebox7.TUnion<[_sinclair_typebox7.TString, _sinclair_typebox7.TInteger]>>;
844
+ count: _sinclair_typebox7.TOptional<_sinclair_typebox7.TNumber>;
1123
845
  }>;
846
+ type Ok = Static<typeof okSchema>;
847
+ //#endregion
848
+ //#region src/index.d.ts
1124
849
  declare module "@alepha/core" {
1125
- interface Hooks {
1126
- "server:onRoute": {
1127
- route: ServerRoute;
1128
- };
1129
- "server:onRequest": {
1130
- route: ServerRoute;
1131
- request: ServerRequest;
1132
- };
1133
- "server:onError": {
1134
- route: ServerRoute;
1135
- request: ServerRequest;
1136
- error: Error;
1137
- };
1138
- "server:onSend": {
1139
- route: ServerRoute;
1140
- request: ServerRequest;
1141
- };
1142
- "server:onResponse": {
1143
- route: ServerRoute;
1144
- request: ServerRequest;
1145
- response: ServerResponse;
1146
- };
1147
- "client:onRequest": {
1148
- route: HttpClientLink;
1149
- config: ServerRequestConfigEntry;
1150
- options: ClientRequestOptions;
1151
- headers: Record<string, string>;
1152
- request: RequestInit;
1153
- };
1154
- "client:beforeFetch": {
1155
- url: string;
1156
- options: FetchRunOptions;
1157
- request: RequestInit;
1158
- };
1159
- "client:onError": {
1160
- route?: HttpClientLink;
1161
- error: HttpError;
1162
- };
1163
- }
850
+ interface Hooks {
851
+ "server:onRoute": {
852
+ route: ServerRoute;
853
+ };
854
+ "server:onRequest": {
855
+ route: ServerRoute;
856
+ request: ServerRequest;
857
+ };
858
+ "server:onError": {
859
+ route: ServerRoute;
860
+ request: ServerRequest;
861
+ error: Error;
862
+ };
863
+ "server:onSend": {
864
+ route: ServerRoute;
865
+ request: ServerRequest;
866
+ };
867
+ "server:onResponse": {
868
+ route: ServerRoute;
869
+ request: ServerRequest;
870
+ response: ServerResponse;
871
+ };
872
+ "client:onRequest": {
873
+ route: HttpClientLink;
874
+ config: ServerRequestConfigEntry;
875
+ options: ClientRequestOptions;
876
+ headers: Record<string, string>;
877
+ request: RequestInit;
878
+ };
879
+ "client:beforeFetch": {
880
+ url: string;
881
+ options: FetchRunOptions;
882
+ request: RequestInit;
883
+ };
884
+ "client:onError": {
885
+ route?: HttpClientLink;
886
+ error: HttpError;
887
+ };
888
+ }
1164
889
  }
890
+ declare const envSchema: _alepha_core3.TObject<{
891
+ SERVER_LINKS_ENABLED: _sinclair_typebox1.TBoolean;
892
+ SERVER_HEALTH_ENABLED: _sinclair_typebox1.TBoolean;
893
+ }>;
1165
894
  declare module "@alepha/core" {
1166
- interface Env extends Partial<Static$1<typeof envSchema>> {
1167
- }
895
+ interface Env extends Partial<Static<typeof envSchema>> {}
1168
896
  }
1169
897
  declare class AlephaServer implements Module {
1170
- protected readonly env: {
1171
- SERVER_LINKS_ENABLED: boolean;
1172
- SERVER_HEALTH_ENABLED: boolean;
1173
- };
1174
- readonly name = "alepha.server";
1175
- readonly $services: (alepha: Alepha) => void;
1176
- }
1177
-
1178
- export { $action, $client, $proxy, $remote, $route, type ActionDescriptor, type ActionDescriptorOptions, AlephaServer, type ApiLink, type ApiLinksResponse, BadRequestError, type ClientRequestEntry, type ClientRequestEntryContainer, type ClientRequestOptions, type ClientRequestResponse, type ClientScope, ConflictError, type FetchFactoryAdditionalOptions, type FetchLinkArgs, type FetchResponse, type FetchRunOptions, ForbiddenError, HttpClient, type HttpClientLink, type HttpClientPendingRequests, HttpError, type HttpErrorLike, type HttpVirtualClient, NodeHttpServerProvider, NotFoundError, type Ok, type ProxyDescriptor, type ProxyDescriptorOptions, ProxyDescriptorProvider, type RemoteDescriptor, type RemoteDescriptorOptions, RemoteDescriptorProvider, type RequestConfigSchema, type ResponseBodyType, type ResponseType, type RouteDescriptor, type RouteDescriptorOptions, type RouteMethod, ServerActionDescriptorProvider, type ServerHandler, ServerHealthProvider, ServerLinksProvider, ServerLoggerProvider, type ServerMiddlewareHandler, ServerMultipartProvider, ServerNotReadyProvider, ServerProvider, type ServerRawRequest, type ServerRemote, type ServerReply, type ServerRequest, type ServerRequestConfig, type ServerRequestConfigEntry, type ServerResponse, type ServerResponseBody, type ServerRoute, type ServerRouteAction, type ServerRouteSecure, type ServerRouteWithHandler, ServerRouterProvider, ServerSecurityProvider, ServerTimingProvider, UnauthorizedError, ValidationError, apiLinkSchema, apiLinksResponseSchema, errorNameByStatus, errorSchema, isHttpError, isServerAction, okSchema, routeMethods };
898
+ protected readonly env: {
899
+ SERVER_LINKS_ENABLED: boolean;
900
+ SERVER_HEALTH_ENABLED: boolean;
901
+ };
902
+ readonly name = "alepha.server";
903
+ readonly $services: (alepha: Alepha) => void;
904
+ }
905
+ //#endregion
906
+ export { $action, $client, $proxy, $remote, $route, ActionDescriptor, ActionDescriptorOptions, AlephaServer, ApiLink, ApiLinksResponse, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ClientScope, ConflictError, FetchFactoryAdditionalOptions, FetchLinkArgs, FetchResponse, FetchRunOptions, ForbiddenError, HttpClient, HttpClientLink, HttpClientPendingRequests, HttpError, HttpErrorLike, HttpVirtualClient, KIND, NodeHttpServerProvider, NotFoundError, Ok, ProxyDescriptor, ProxyDescriptorOptions, ProxyDescriptorProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionDescriptorProvider, ServerHandler, ServerHealthProvider, ServerLinksProvider, ServerLoggerProvider, ServerMiddlewareHandler, ServerMultipartProvider, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerRemote, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteAction, ServerRouteSecure, ServerRouteWithHandler, ServerRouterProvider, ServerSecurityProvider, ServerTimingProvider, UnauthorizedError, ValidationError, apiLinkSchema, apiLinksResponseSchema, errorNameByStatus, errorSchema, isHttpError, isServerAction, okSchema, routeMethods };
907
+ //# sourceMappingURL=index.d.ts.map