alepha 0.10.2 → 0.10.4
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 +16 -18
- package/api/files.cjs +8 -0
- package/api/files.d.ts +203 -0
- package/api/files.js +1 -0
- package/api/jobs.cjs +8 -0
- package/api/jobs.d.ts +276 -0
- package/api/jobs.js +1 -0
- package/api/users.cjs +8 -0
- package/api/users.d.ts +394 -0
- package/api/users.js +1 -0
- package/batch.d.ts +14 -14
- package/cache/redis.d.ts +1 -0
- package/cache.d.ts +5 -0
- package/command.d.ts +6 -6
- package/core.d.ts +58 -10
- package/datetime.d.ts +0 -2
- package/devtools.cjs +8 -0
- package/devtools.d.ts +368 -0
- package/devtools.js +1 -0
- package/email.d.ts +15 -15
- package/logger.d.ts +44 -29
- package/package.json +71 -43
- package/postgres.d.ts +121 -327
- package/queue.d.ts +21 -21
- package/react/form.d.ts +3 -3
- package/react.d.ts +11 -6
- package/scheduler.d.ts +22 -2
- package/security.d.ts +15 -6
- package/server/cookies.d.ts +2 -12
- package/server/links.d.ts +30 -30
- package/server.d.ts +50 -50
- package/topic.d.ts +26 -161
package/queue.d.ts
CHANGED
|
@@ -157,9 +157,9 @@ interface NextMessage {
|
|
|
157
157
|
* const emailQueue = $queue({
|
|
158
158
|
* name: "email-notifications",
|
|
159
159
|
* schema: t.object({
|
|
160
|
-
* to: t.
|
|
161
|
-
* subject: t.
|
|
162
|
-
* body: t.
|
|
160
|
+
* to: t.text(),
|
|
161
|
+
* subject: t.text(),
|
|
162
|
+
* body: t.text(),
|
|
163
163
|
* priority: t.optional(t.enum(["high", "normal"]))
|
|
164
164
|
* }),
|
|
165
165
|
* handler: async (message) => {
|
|
@@ -183,7 +183,7 @@ interface NextMessage {
|
|
|
183
183
|
* name: "image-processing",
|
|
184
184
|
* provider: RedisQueueProvider,
|
|
185
185
|
* schema: t.object({
|
|
186
|
-
* imageId: t.
|
|
186
|
+
* imageId: t.text(),
|
|
187
187
|
* operations: t.array(t.enum(["resize", "compress", "thumbnail"]))
|
|
188
188
|
* }),
|
|
189
189
|
* handler: async (message) => {
|
|
@@ -208,7 +208,7 @@ interface NextMessage {
|
|
|
208
208
|
* provider: "memory",
|
|
209
209
|
* schema: t.object({
|
|
210
210
|
* taskType: t.enum(["cleanup", "backup", "report"]),
|
|
211
|
-
* data: t.record(t.
|
|
211
|
+
* data: t.record(t.text(), t.any())
|
|
212
212
|
* }),
|
|
213
213
|
* handler: async (message) => {
|
|
214
214
|
* switch (message.payload.taskType) {
|
|
@@ -299,9 +299,9 @@ interface QueueDescriptorOptions<T extends TSchema> {
|
|
|
299
299
|
* @example
|
|
300
300
|
* ```ts
|
|
301
301
|
* t.object({
|
|
302
|
-
* userId: t.
|
|
302
|
+
* userId: t.text(),
|
|
303
303
|
* action: t.enum(["create", "update"]),
|
|
304
|
-
* data: t.record(t.
|
|
304
|
+
* data: t.record(t.text(), t.any()),
|
|
305
305
|
* timestamp: t.optional(t.number())
|
|
306
306
|
* })
|
|
307
307
|
* ```
|
|
@@ -404,10 +404,10 @@ interface QueueMessage<T extends TSchema> {
|
|
|
404
404
|
* emailQueue = $queue({
|
|
405
405
|
* name: "emails",
|
|
406
406
|
* schema: t.object({
|
|
407
|
-
* to: t.
|
|
408
|
-
* subject: t.
|
|
409
|
-
* body: t.
|
|
410
|
-
* template: t.optional(t.
|
|
407
|
+
* to: t.text(),
|
|
408
|
+
* subject: t.text(),
|
|
409
|
+
* body: t.text(),
|
|
410
|
+
* template: t.optional(t.text())
|
|
411
411
|
* })
|
|
412
412
|
* });
|
|
413
413
|
*
|
|
@@ -447,9 +447,9 @@ interface QueueMessage<T extends TSchema> {
|
|
|
447
447
|
* name: "notifications",
|
|
448
448
|
* schema: t.object({
|
|
449
449
|
* type: t.enum(["email", "sms", "push"]),
|
|
450
|
-
* recipient: t.
|
|
451
|
-
* message: t.
|
|
452
|
-
* metadata: t.optional(t.record(t.
|
|
450
|
+
* recipient: t.text(),
|
|
451
|
+
* message: t.text(),
|
|
452
|
+
* metadata: t.optional(t.record(t.text(), t.any()))
|
|
453
453
|
* })
|
|
454
454
|
* });
|
|
455
455
|
*
|
|
@@ -503,10 +503,10 @@ interface QueueMessage<T extends TSchema> {
|
|
|
503
503
|
* orderQueue = $queue({
|
|
504
504
|
* name: "order-processing",
|
|
505
505
|
* schema: t.object({
|
|
506
|
-
* orderId: t.
|
|
507
|
-
* customerId: t.
|
|
506
|
+
* orderId: t.text(),
|
|
507
|
+
* customerId: t.text(),
|
|
508
508
|
* items: t.array(t.object({
|
|
509
|
-
* productId: t.
|
|
509
|
+
* productId: t.text(),
|
|
510
510
|
* quantity: t.number(),
|
|
511
511
|
* price: t.number()
|
|
512
512
|
* }))
|
|
@@ -566,10 +566,10 @@ interface QueueMessage<T extends TSchema> {
|
|
|
566
566
|
* dataQueue = $queue({
|
|
567
567
|
* name: "data-processing",
|
|
568
568
|
* schema: t.object({
|
|
569
|
-
* batchId: t.
|
|
569
|
+
* batchId: t.text(),
|
|
570
570
|
* records: t.array(t.object({
|
|
571
|
-
* id: t.
|
|
572
|
-
* data: t.record(t.
|
|
571
|
+
* id: t.text(),
|
|
572
|
+
* data: t.record(t.text(), t.any())
|
|
573
573
|
* })),
|
|
574
574
|
* processingOptions: t.object({
|
|
575
575
|
* validateData: t.boolean(),
|
|
@@ -652,7 +652,7 @@ interface ConsumerDescriptorOptions<T extends TSchema> {
|
|
|
652
652
|
* // First, define a queue
|
|
653
653
|
* emailQueue = $queue({
|
|
654
654
|
* name: "emails",
|
|
655
|
-
* schema: t.object({ to: t.
|
|
655
|
+
* schema: t.object({ to: t.text(), subject: t.text() })
|
|
656
656
|
* });
|
|
657
657
|
*
|
|
658
658
|
* // Then, create a consumer for that queue
|
package/react/form.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ type FormCtrlOptions<T extends TObject> = {
|
|
|
65
65
|
* Optional initial values for the form fields.
|
|
66
66
|
* This can be used to pre-populate the form with existing data.
|
|
67
67
|
*/
|
|
68
|
-
initialValues?: Static<T
|
|
68
|
+
initialValues?: Partial<Static<T>>;
|
|
69
69
|
/**
|
|
70
70
|
* Optional function to create custom field attributes.
|
|
71
71
|
* This can be used to add custom validation, styles, or other attributes.
|
|
@@ -106,8 +106,8 @@ declare const FormState: <T extends TObject>(props: {
|
|
|
106
106
|
*
|
|
107
107
|
* const form = useForm({
|
|
108
108
|
* schema: t.object({
|
|
109
|
-
* username: t.
|
|
110
|
-
* password: t.
|
|
109
|
+
* username: t.text(),
|
|
110
|
+
* password: t.text(),
|
|
111
111
|
* }),
|
|
112
112
|
* handler: (values) => {
|
|
113
113
|
* console.log("Form submitted with values:", values);
|
package/react.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ClientScope, HttpVirtualClient, LinkProvider, VirtualAction } from "ale
|
|
|
6
6
|
import * as _alepha_logger0 from "alepha/logger";
|
|
7
7
|
import * as react0 from "react";
|
|
8
8
|
import React, { AnchorHTMLAttributes, CSSProperties, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
10
10
|
import { ServerStaticProvider } from "alepha/server/static";
|
|
11
11
|
import { DateTimeProvider } from "alepha/datetime";
|
|
12
12
|
import { Route, RouterProvider } from "alepha/router";
|
|
@@ -210,7 +210,7 @@ interface CreateLayersResult {
|
|
|
210
210
|
* path: "/users/:id",
|
|
211
211
|
* schema: {
|
|
212
212
|
* params: t.object({ id: t.int() }),
|
|
213
|
-
* query: t.object({ tab: t.optional(t.
|
|
213
|
+
* query: t.object({ tab: t.optional(t.text()) })
|
|
214
214
|
* },
|
|
215
215
|
* resolve: async ({ params }) => {
|
|
216
216
|
* const user = await userApi.getUser(params.id);
|
|
@@ -619,25 +619,25 @@ interface ErrorViewerProps {
|
|
|
619
619
|
declare const ErrorViewer: ({
|
|
620
620
|
error,
|
|
621
621
|
alepha
|
|
622
|
-
}: ErrorViewerProps) =>
|
|
622
|
+
}: ErrorViewerProps) => react_jsx_runtime1.JSX.Element;
|
|
623
623
|
//#endregion
|
|
624
624
|
//#region src/components/Link.d.ts
|
|
625
625
|
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
626
626
|
href: string;
|
|
627
627
|
}
|
|
628
|
-
declare const Link: (props: LinkProps) =>
|
|
628
|
+
declare const Link: (props: LinkProps) => react_jsx_runtime1.JSX.Element;
|
|
629
629
|
//#endregion
|
|
630
630
|
//#region src/components/NestedView.d.ts
|
|
631
631
|
interface NestedViewProps {
|
|
632
632
|
children?: ReactNode;
|
|
633
633
|
errorBoundary?: false | ((error: Error) => ReactNode);
|
|
634
634
|
}
|
|
635
|
-
declare const _default: react0.MemoExoticComponent<(props: NestedViewProps) =>
|
|
635
|
+
declare const _default: react0.MemoExoticComponent<(props: NestedViewProps) => react_jsx_runtime1.JSX.Element>;
|
|
636
636
|
//#endregion
|
|
637
637
|
//#region src/components/NotFound.d.ts
|
|
638
638
|
declare function NotFoundPage(props: {
|
|
639
639
|
style?: CSSProperties;
|
|
640
|
-
}):
|
|
640
|
+
}): react_jsx_runtime1.JSX.Element;
|
|
641
641
|
//#endregion
|
|
642
642
|
//#region src/contexts/AlephaContext.d.ts
|
|
643
643
|
declare const AlephaContext: react0.Context<Alepha | undefined>;
|
|
@@ -713,6 +713,11 @@ declare class ReactRouter<T extends object> {
|
|
|
713
713
|
params?: Record<string, any>;
|
|
714
714
|
query?: Record<string, any>;
|
|
715
715
|
}): string;
|
|
716
|
+
/**
|
|
717
|
+
* Reload the current page.
|
|
718
|
+
* This is equivalent to calling `go()` with the current pathname and search.
|
|
719
|
+
*/
|
|
720
|
+
reload(): Promise<void>;
|
|
716
721
|
getURL(): URL;
|
|
717
722
|
get location(): Location;
|
|
718
723
|
get current(): ReactRouterState;
|
package/scheduler.d.ts
CHANGED
|
@@ -95,14 +95,34 @@ declare class SchedulerDescriptor extends Descriptor<SchedulerDescriptorOptions>
|
|
|
95
95
|
protected onInit(): void;
|
|
96
96
|
trigger(): Promise<void>;
|
|
97
97
|
protected schedulerLock: _alepha_lock0.LockDescriptor<(args: SchedulerHandlerArguments) => Promise<void>>;
|
|
98
|
-
protected prefix(key: string): string;
|
|
99
|
-
protected getLockGracePeriod(options: SchedulerDescriptorOptions): number;
|
|
100
98
|
}
|
|
101
99
|
interface SchedulerHandlerArguments {
|
|
102
100
|
now: DateTime;
|
|
103
101
|
}
|
|
104
102
|
//#endregion
|
|
105
103
|
//#region src/index.d.ts
|
|
104
|
+
declare module "alepha" {
|
|
105
|
+
interface Hooks {
|
|
106
|
+
"scheduler:begin": {
|
|
107
|
+
name: string;
|
|
108
|
+
now: DateTime;
|
|
109
|
+
context: string;
|
|
110
|
+
};
|
|
111
|
+
"scheduler:success": {
|
|
112
|
+
name: string;
|
|
113
|
+
context: string;
|
|
114
|
+
};
|
|
115
|
+
"scheduler:error": {
|
|
116
|
+
name: string;
|
|
117
|
+
error: Error;
|
|
118
|
+
context: string;
|
|
119
|
+
};
|
|
120
|
+
"scheduler:end": {
|
|
121
|
+
name: string;
|
|
122
|
+
context: string;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
106
126
|
/**
|
|
107
127
|
* Generic interface for scheduling tasks.
|
|
108
128
|
*
|
package/security.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
4
4
|
import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
|
|
5
5
|
import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
|
|
6
6
|
import * as typebox0 from "typebox";
|
|
@@ -68,7 +68,7 @@ type Role = Static<typeof roleSchema>;
|
|
|
68
68
|
* Provides utilities for working with JSON Web Tokens (JWT).
|
|
69
69
|
*/
|
|
70
70
|
declare class JwtProvider {
|
|
71
|
-
protected readonly log:
|
|
71
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
72
72
|
protected readonly keystore: KeyLoaderHolder[];
|
|
73
73
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
74
74
|
protected readonly encoder: TextEncoder;
|
|
@@ -131,7 +131,7 @@ interface JwtParseResult {
|
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/providers/SecurityProvider.d.ts
|
|
133
133
|
declare const envSchema: _alepha_core1.TObject<{
|
|
134
|
-
|
|
134
|
+
APP_SECRET: _alepha_core1.TString;
|
|
135
135
|
}>;
|
|
136
136
|
declare module "alepha" {
|
|
137
137
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -140,12 +140,13 @@ declare class SecurityProvider {
|
|
|
140
140
|
protected readonly UNKNOWN_USER_NAME = "Anonymous User";
|
|
141
141
|
protected readonly PERMISSION_REGEXP: RegExp;
|
|
142
142
|
protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
|
|
143
|
-
protected readonly log:
|
|
143
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
144
144
|
protected readonly jwt: JwtProvider;
|
|
145
145
|
protected readonly env: {
|
|
146
|
-
|
|
146
|
+
APP_SECRET: string;
|
|
147
147
|
};
|
|
148
148
|
protected readonly alepha: Alepha;
|
|
149
|
+
get secretKey(): string;
|
|
149
150
|
/**
|
|
150
151
|
* The permissions configured for the security provider.
|
|
151
152
|
*/
|
|
@@ -318,6 +319,7 @@ declare class PermissionDescriptor extends Descriptor<PermissionDescriptorOption
|
|
|
318
319
|
protected readonly securityProvider: SecurityProvider;
|
|
319
320
|
get name(): string;
|
|
320
321
|
get group(): string;
|
|
322
|
+
toString(): string;
|
|
321
323
|
protected onInit(): void;
|
|
322
324
|
/**
|
|
323
325
|
* Check if the user has the permission.
|
|
@@ -347,6 +349,9 @@ type RealmDescriptorOptions = {
|
|
|
347
349
|
* All roles available in the realm. Role is a string (role name) or a Role object (embedded role).
|
|
348
350
|
*/
|
|
349
351
|
roles?: Array<string | Role>;
|
|
352
|
+
/**
|
|
353
|
+
* Realm settings.
|
|
354
|
+
*/
|
|
350
355
|
settings?: RealmSettings;
|
|
351
356
|
/**
|
|
352
357
|
* Parse the JWT payload to create a user account info.
|
|
@@ -397,7 +402,7 @@ declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
|
|
|
397
402
|
protected readonly securityProvider: SecurityProvider;
|
|
398
403
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
399
404
|
protected readonly jwt: JwtProvider;
|
|
400
|
-
protected readonly log:
|
|
405
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
401
406
|
get name(): string;
|
|
402
407
|
get accessTokenExpiration(): Duration;
|
|
403
408
|
get refreshTokenExpiration(): Duration;
|
|
@@ -464,6 +469,7 @@ interface RoleDescriptorOptions {
|
|
|
464
469
|
permissions?: Array<string | {
|
|
465
470
|
name: string;
|
|
466
471
|
ownership?: boolean;
|
|
472
|
+
exclude?: string[];
|
|
467
473
|
}>;
|
|
468
474
|
}
|
|
469
475
|
declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
|
|
@@ -474,6 +480,8 @@ declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
|
|
|
474
480
|
* Get the realm of the role.
|
|
475
481
|
*/
|
|
476
482
|
get realm(): string | RealmDescriptor | undefined;
|
|
483
|
+
can(permission: string | PermissionDescriptor): boolean;
|
|
484
|
+
check(permission: string | PermissionDescriptor): SecurityCheckResult;
|
|
477
485
|
}
|
|
478
486
|
//#endregion
|
|
479
487
|
//#region src/descriptors/$serviceAccount.d.ts
|
|
@@ -550,6 +558,7 @@ declare class SecurityError extends Error {
|
|
|
550
558
|
declare class CryptoProvider {
|
|
551
559
|
hashPassword(password: string): Promise<string>;
|
|
552
560
|
verifyPassword(password: string, stored: string): Promise<boolean>;
|
|
561
|
+
randomUUID(): string;
|
|
553
562
|
}
|
|
554
563
|
//#endregion
|
|
555
564
|
//#region src/index.d.ts
|
package/server/cookies.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as _alepha_core1 from "alepha";
|
|
|
2
2
|
import { Alepha, Descriptor, KIND, Static, TSchema } from "alepha";
|
|
3
3
|
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
4
4
|
import * as _alepha_logger0 from "alepha/logger";
|
|
5
|
+
import { SecurityProvider } from "alepha/security";
|
|
5
6
|
|
|
6
7
|
//#region src/services/CookieParser.d.ts
|
|
7
8
|
declare class CookieParser {
|
|
@@ -11,23 +12,12 @@ declare class CookieParser {
|
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
14
|
//#region src/providers/ServerCookiesProvider.d.ts
|
|
14
|
-
declare const envSchema: _alepha_core1.TObject<{
|
|
15
|
-
/**
|
|
16
|
-
* A 32-byte secret key used for cookie encryption and signing. MUST be set for `encrypt` or `sign` to work.
|
|
17
|
-
*/
|
|
18
|
-
COOKIE_SECRET: _alepha_core1.TOptional<_alepha_core1.TString>;
|
|
19
|
-
}>;
|
|
20
|
-
declare module "alepha" {
|
|
21
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
22
|
-
}
|
|
23
15
|
declare class ServerCookiesProvider {
|
|
24
16
|
protected readonly alepha: Alepha;
|
|
25
17
|
protected readonly log: _alepha_logger0.Logger;
|
|
26
|
-
protected readonly env: {
|
|
27
|
-
COOKIE_SECRET?: string | undefined;
|
|
28
|
-
};
|
|
29
18
|
protected readonly cookieParser: CookieParser;
|
|
30
19
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
20
|
+
protected readonly securityProvider: SecurityProvider;
|
|
31
21
|
protected readonly ALGORITHM = "aes-256-gcm";
|
|
32
22
|
protected readonly IV_LENGTH = 16;
|
|
33
23
|
protected readonly AUTH_TAG_LENGTH = 16;
|
package/server/links.d.ts
CHANGED
|
@@ -7,26 +7,26 @@ import * as _alepha_logger0 from "alepha/logger";
|
|
|
7
7
|
import * as _alepha_retry0 from "alepha/retry";
|
|
8
8
|
import { ProxyDescriptorOptions, ServerProxyProvider } from "alepha/server/proxy";
|
|
9
9
|
import { ServiceAccountDescriptor, UserAccountToken } from "alepha/security";
|
|
10
|
-
import * as
|
|
10
|
+
import * as typebox18 from "typebox";
|
|
11
11
|
|
|
12
12
|
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
13
|
-
declare const apiLinkSchema:
|
|
14
|
-
name:
|
|
15
|
-
group:
|
|
16
|
-
path:
|
|
17
|
-
method:
|
|
18
|
-
requestBodyType:
|
|
19
|
-
service:
|
|
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
20
|
}>;
|
|
21
|
-
declare const apiLinksResponseSchema:
|
|
22
|
-
prefix:
|
|
23
|
-
links:
|
|
24
|
-
name:
|
|
25
|
-
group:
|
|
26
|
-
path:
|
|
27
|
-
method:
|
|
28
|
-
requestBodyType:
|
|
29
|
-
service:
|
|
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
30
|
}>>;
|
|
31
31
|
}>;
|
|
32
32
|
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
@@ -135,7 +135,7 @@ interface RemoteDescriptorOptions {
|
|
|
135
135
|
*
|
|
136
136
|
* class App {
|
|
137
137
|
* env = $env(t.object({
|
|
138
|
-
* REMOTE_URL: t.
|
|
138
|
+
* REMOTE_URL: t.text({default: "http://localhost:3000"}),
|
|
139
139
|
* }));
|
|
140
140
|
* remote = $remote({
|
|
141
141
|
* url: this.env.REMOTE_URL,
|
|
@@ -257,15 +257,15 @@ declare class ServerLinksProvider {
|
|
|
257
257
|
* This is based on the user's permissions.
|
|
258
258
|
*/
|
|
259
259
|
readonly links: _alepha_server0.RouteDescriptor<{
|
|
260
|
-
response:
|
|
261
|
-
prefix:
|
|
262
|
-
links:
|
|
263
|
-
name:
|
|
264
|
-
group:
|
|
265
|
-
path:
|
|
266
|
-
method:
|
|
267
|
-
requestBodyType:
|
|
268
|
-
service:
|
|
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
269
|
}>>;
|
|
270
270
|
}>;
|
|
271
271
|
}>;
|
|
@@ -276,10 +276,10 @@ declare class ServerLinksProvider {
|
|
|
276
276
|
* I mean for 150+ links, you got 50ms of serialization time.
|
|
277
277
|
*/
|
|
278
278
|
readonly schema: _alepha_server0.RouteDescriptor<{
|
|
279
|
-
params:
|
|
280
|
-
name:
|
|
279
|
+
params: typebox18.TObject<{
|
|
280
|
+
name: typebox18.TString;
|
|
281
281
|
}>;
|
|
282
|
-
response:
|
|
282
|
+
response: typebox18.TRecord<string, typebox18.TAny>;
|
|
283
283
|
}>;
|
|
284
284
|
getSchemaByName(name: string, options?: GetApiLinksOptions): Promise<RequestConfigSchema>;
|
|
285
285
|
/**
|
package/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core11 from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, Descriptor, FileLike, KIND, Static, StreamLike, TArray, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_logger3 from "alepha/logger";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { ReadableStream } from "node:stream/web";
|
|
6
6
|
import { Route, RouterProvider } from "alepha/router";
|
|
@@ -46,7 +46,7 @@ declare class ServerReply {
|
|
|
46
46
|
interface UserAgentInfo {
|
|
47
47
|
os: "Windows" | "Android" | "Ubuntu" | "MacOS" | "iOS" | "Linux" | "FreeBSD" | "OpenBSD" | "ChromeOS" | "BlackBerry" | "Symbian" | "Windows Phone";
|
|
48
48
|
browser: "Chrome" | "Firefox" | "Safari" | "Edge" | "Opera" | "Internet Explorer" | "Brave" | "Vivaldi" | "Samsung Browser" | "UC Browser" | "Yandex";
|
|
49
|
-
device: "
|
|
49
|
+
device: "MOBILE" | "DESKTOP" | "TABLET";
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Simple User-Agent parser to detect OS, browser, and device type.
|
|
@@ -72,7 +72,7 @@ interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfi
|
|
|
72
72
|
body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
|
|
73
73
|
headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
|
|
74
74
|
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
|
|
75
|
-
query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string,
|
|
75
|
+
query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
|
|
76
76
|
}
|
|
77
77
|
type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
|
|
78
78
|
interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
|
|
@@ -176,13 +176,13 @@ declare class ServerRequestParser {
|
|
|
176
176
|
//#region src/providers/ServerTimingProvider.d.ts
|
|
177
177
|
type TimingMap = Record<string, [number, number]>;
|
|
178
178
|
declare class ServerTimingProvider {
|
|
179
|
-
protected readonly log:
|
|
179
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
180
180
|
protected readonly alepha: Alepha;
|
|
181
181
|
options: {
|
|
182
182
|
disabled: boolean;
|
|
183
183
|
};
|
|
184
|
-
readonly onRequest:
|
|
185
|
-
readonly onResponse:
|
|
184
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
185
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
186
186
|
protected get handlerName(): string;
|
|
187
187
|
beginTiming(name: string): void;
|
|
188
188
|
endTiming(name: string): void;
|
|
@@ -222,7 +222,7 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
|
|
|
222
222
|
//#endregion
|
|
223
223
|
//#region src/services/HttpClient.d.ts
|
|
224
224
|
declare class HttpClient {
|
|
225
|
-
protected readonly log:
|
|
225
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
226
226
|
protected readonly alepha: Alepha;
|
|
227
227
|
readonly cache: _alepha_cache0.CacheDescriptorFn<HttpClientCache, any[]>;
|
|
228
228
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
@@ -342,13 +342,13 @@ interface HttpAction {
|
|
|
342
342
|
* query: t.object({
|
|
343
343
|
* page: t.optional(t.number({ default: 1 })),
|
|
344
344
|
* limit: t.optional(t.number({ default: 10, maximum: 100 })),
|
|
345
|
-
* search: t.optional(t.
|
|
345
|
+
* search: t.optional(t.text())
|
|
346
346
|
* }),
|
|
347
347
|
* response: t.object({
|
|
348
348
|
* users: t.array(t.object({
|
|
349
|
-
* id: t.
|
|
350
|
-
* name: t.
|
|
351
|
-
* email: t.
|
|
349
|
+
* id: t.text(),
|
|
350
|
+
* name: t.text(),
|
|
351
|
+
* email: t.text(),
|
|
352
352
|
* createdAt: t.datetime()
|
|
353
353
|
* })),
|
|
354
354
|
* total: t.number(),
|
|
@@ -373,16 +373,16 @@ interface HttpAction {
|
|
|
373
373
|
* description: "Create a new user account",
|
|
374
374
|
* schema: {
|
|
375
375
|
* body: t.object({
|
|
376
|
-
* name: t.
|
|
377
|
-
* email: t.
|
|
378
|
-
* password: t.
|
|
376
|
+
* name: t.text({ minLength: 2, maxLength: 100 }),
|
|
377
|
+
* email: t.text({ format: "email" }),
|
|
378
|
+
* password: t.text({ minLength: 8 }),
|
|
379
379
|
* role: t.optional(t.enum(["user", "admin"]))
|
|
380
380
|
* }),
|
|
381
381
|
* response: t.object({
|
|
382
|
-
* id: t.
|
|
383
|
-
* name: t.
|
|
384
|
-
* email: t.
|
|
385
|
-
* role: t.
|
|
382
|
+
* id: t.text(),
|
|
383
|
+
* name: t.text(),
|
|
384
|
+
* email: t.text(),
|
|
385
|
+
* role: t.text(),
|
|
386
386
|
* createdAt: t.datetime()
|
|
387
387
|
* })
|
|
388
388
|
* },
|
|
@@ -409,17 +409,17 @@ interface HttpAction {
|
|
|
409
409
|
* description: "Retrieve user by ID",
|
|
410
410
|
* schema: {
|
|
411
411
|
* params: t.object({
|
|
412
|
-
* id: t.
|
|
412
|
+
* id: t.text()
|
|
413
413
|
* }),
|
|
414
414
|
* response: t.object({
|
|
415
|
-
* id: t.
|
|
416
|
-
* name: t.
|
|
417
|
-
* email: t.
|
|
418
|
-
* role: t.
|
|
415
|
+
* id: t.text(),
|
|
416
|
+
* name: t.text(),
|
|
417
|
+
* email: t.text(),
|
|
418
|
+
* role: t.text(),
|
|
419
419
|
* profile: t.optional(t.object({
|
|
420
|
-
* bio: t.
|
|
421
|
-
* avatar: t.
|
|
422
|
-
* location: t.
|
|
420
|
+
* bio: t.text(),
|
|
421
|
+
* avatar: t.text({ format: "uri" }),
|
|
422
|
+
* location: t.text()
|
|
423
423
|
* }))
|
|
424
424
|
* })
|
|
425
425
|
* },
|
|
@@ -437,20 +437,20 @@ interface HttpAction {
|
|
|
437
437
|
* path: "/users/:id",
|
|
438
438
|
* description: "Update user information",
|
|
439
439
|
* schema: {
|
|
440
|
-
* params: t.object({ id: t.
|
|
440
|
+
* params: t.object({ id: t.text() }),
|
|
441
441
|
* body: t.object({
|
|
442
|
-
* name: t.optional(t.
|
|
443
|
-
* email: t.optional(t.
|
|
442
|
+
* name: t.optional(t.text({ minLength: 2 })),
|
|
443
|
+
* email: t.optional(t.text({ format: "email" })),
|
|
444
444
|
* profile: t.optional(t.object({
|
|
445
|
-
* bio: t.optional(t.
|
|
446
|
-
* avatar: t.optional(t.
|
|
447
|
-
* location: t.optional(t.
|
|
445
|
+
* bio: t.optional(t.text()),
|
|
446
|
+
* avatar: t.optional(t.text({ format: "uri" })),
|
|
447
|
+
* location: t.optional(t.text())
|
|
448
448
|
* }))
|
|
449
449
|
* }),
|
|
450
450
|
* response: t.object({
|
|
451
|
-
* id: t.
|
|
452
|
-
* name: t.
|
|
453
|
-
* email: t.
|
|
451
|
+
* id: t.text(),
|
|
452
|
+
* name: t.text(),
|
|
453
|
+
* email: t.text(),
|
|
454
454
|
* updatedAt: t.datetime()
|
|
455
455
|
* })
|
|
456
456
|
* },
|
|
@@ -541,7 +541,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
|
|
|
541
541
|
handler: ServerActionHandler<TConfig>;
|
|
542
542
|
}
|
|
543
543
|
declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
|
|
544
|
-
protected readonly log:
|
|
544
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
545
545
|
protected readonly env: {
|
|
546
546
|
SERVER_API_PREFIX: string;
|
|
547
547
|
};
|
|
@@ -713,9 +713,9 @@ declare const okSchema: typebox0.TObject<{
|
|
|
713
713
|
type Ok = Static<typeof okSchema>;
|
|
714
714
|
//#endregion
|
|
715
715
|
//#region src/providers/NodeHttpServerProvider.d.ts
|
|
716
|
-
declare const envSchema:
|
|
717
|
-
SERVER_PORT:
|
|
718
|
-
SERVER_HOST:
|
|
716
|
+
declare const envSchema: _alepha_core11.TObject<{
|
|
717
|
+
SERVER_PORT: _alepha_core11.TInteger;
|
|
718
|
+
SERVER_HOST: _alepha_core11.TString;
|
|
719
719
|
}>;
|
|
720
720
|
declare module "alepha" {
|
|
721
721
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -723,31 +723,31 @@ declare module "alepha" {
|
|
|
723
723
|
declare class NodeHttpServerProvider extends ServerProvider {
|
|
724
724
|
protected readonly alepha: Alepha;
|
|
725
725
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
726
|
-
protected readonly log:
|
|
726
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
727
727
|
protected readonly env: {
|
|
728
728
|
SERVER_PORT: number;
|
|
729
729
|
SERVER_HOST: string;
|
|
730
730
|
};
|
|
731
731
|
protected readonly router: ServerRouterProvider;
|
|
732
732
|
protected readonly server: http0.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
733
|
-
protected readonly onNodeRequest:
|
|
733
|
+
protected readonly onNodeRequest: _alepha_core11.HookDescriptor<"node:request">;
|
|
734
734
|
handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
|
|
735
735
|
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
736
736
|
getProtocol(req: IncomingMessage): "http" | "https";
|
|
737
737
|
get hostname(): string;
|
|
738
|
-
readonly start:
|
|
739
|
-
protected readonly stop:
|
|
738
|
+
readonly start: _alepha_core11.HookDescriptor<"start">;
|
|
739
|
+
protected readonly stop: _alepha_core11.HookDescriptor<"stop">;
|
|
740
740
|
protected listen(): Promise<void>;
|
|
741
741
|
protected close(): Promise<void>;
|
|
742
742
|
}
|
|
743
743
|
//#endregion
|
|
744
744
|
//#region src/providers/ServerLoggerProvider.d.ts
|
|
745
745
|
declare class ServerLoggerProvider {
|
|
746
|
-
protected readonly log:
|
|
746
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
747
747
|
protected readonly alepha: Alepha;
|
|
748
|
-
readonly onRequest:
|
|
749
|
-
readonly onError:
|
|
750
|
-
readonly onResponse:
|
|
748
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
749
|
+
readonly onError: _alepha_core11.HookDescriptor<"server:onError">;
|
|
750
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
751
751
|
}
|
|
752
752
|
//#endregion
|
|
753
753
|
//#region src/providers/ServerNotReadyProvider.d.ts
|
|
@@ -760,7 +760,7 @@ declare class ServerLoggerProvider {
|
|
|
760
760
|
*/
|
|
761
761
|
declare class ServerNotReadyProvider {
|
|
762
762
|
protected readonly alepha: Alepha;
|
|
763
|
-
readonly onRequest:
|
|
763
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
764
764
|
}
|
|
765
765
|
//#endregion
|
|
766
766
|
//#region src/index.d.ts
|
|
@@ -828,7 +828,7 @@ declare module "alepha" {
|
|
|
828
828
|
* @see {@link $action}
|
|
829
829
|
* @module alepha.server
|
|
830
830
|
*/
|
|
831
|
-
declare const AlephaServer:
|
|
831
|
+
declare const AlephaServer: _alepha_core11.Service<_alepha_core11.Module<{}>>;
|
|
832
832
|
//#endregion
|
|
833
833
|
export { $action, $route, ActionDescriptor, ActionDescriptorFn, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, ErrorSchema, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionHandler, ServerActionRequest, ServerHandler, ServerLoggerProvider, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteMatcher, ServerRouteRequestHandler, ServerRouterProvider, ServerTimingProvider, TRequestBody, TResponseBody, UnauthorizedError, ValidationError, errorNameByStatus, errorSchema, isHttpError, isMultipart, okSchema, routeMethods };
|
|
834
834
|
//# sourceMappingURL=index.d.ts.map
|