alepha 0.10.3 → 0.10.5
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 +10 -22
- package/api/files.cjs +8 -0
- package/api/files.d.ts +201 -0
- package/api/files.js +1 -0
- package/api/jobs.cjs +8 -0
- package/api/jobs.d.ts +274 -0
- package/api/jobs.js +1 -0
- package/api/users.cjs +8 -0
- package/api/users.d.ts +395 -0
- package/api/users.js +1 -0
- package/batch.d.ts +14 -14
- package/bucket.d.ts +81 -4
- 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 +134 -320
- package/queue.d.ts +21 -21
- package/react/auth.d.ts +5 -0
- package/react/form.d.ts +2 -2
- package/react.d.ts +27 -27
- package/scheduler.d.ts +22 -2
- package/security.d.ts +12 -4
- package/server/links.d.ts +6 -6
- package/server.d.ts +30 -30
- 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/auth.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ declare class ReactAuth {
|
|
|
43
43
|
};
|
|
44
44
|
protected readonly onBeginTransition: _alepha_core4.HookDescriptor<"react:transition:begin">;
|
|
45
45
|
protected readonly onFetchRequest: _alepha_core4.HookDescriptor<"client:onRequest">;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current authenticated user.
|
|
48
|
+
*
|
|
49
|
+
* Alias for `alepha.state.get("user")`
|
|
50
|
+
*/
|
|
46
51
|
get user(): UserAccountToken | undefined;
|
|
47
52
|
ping(): Promise<{
|
|
48
53
|
name?: string | undefined;
|
package/react/form.d.ts
CHANGED
|
@@ -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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core10 from "alepha";
|
|
2
2
|
import { Alepha, Async, Descriptor, Hooks, KIND, Service, State, Static, TObject, TSchema } from "alepha";
|
|
3
3
|
import { RequestConfigSchema, ServerHandler, ServerProvider, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
|
|
4
4
|
import { ServerRouteCache } from "alepha/server/cache";
|
|
5
5
|
import { ClientScope, HttpVirtualClient, LinkProvider, VirtualAction } from "alepha/server/links";
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
6
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
7
|
+
import * as react1 from "react";
|
|
8
8
|
import React, { AnchorHTMLAttributes, CSSProperties, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
|
|
9
9
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
10
10
|
import { ServerStaticProvider } from "alepha/server/static";
|
|
@@ -40,14 +40,14 @@ declare class Redirection extends Error {
|
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/providers/ReactPageProvider.d.ts
|
|
43
|
-
declare const envSchema$2:
|
|
44
|
-
REACT_STRICT_MODE:
|
|
43
|
+
declare const envSchema$2: _alepha_core10.TObject<{
|
|
44
|
+
REACT_STRICT_MODE: _alepha_core10.TBoolean;
|
|
45
45
|
}>;
|
|
46
46
|
declare module "alepha" {
|
|
47
47
|
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
48
48
|
}
|
|
49
49
|
declare class ReactPageProvider {
|
|
50
|
-
protected readonly log:
|
|
50
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
51
51
|
protected readonly env: {
|
|
52
52
|
REACT_STRICT_MODE: boolean;
|
|
53
53
|
};
|
|
@@ -83,7 +83,7 @@ declare class ReactPageProvider {
|
|
|
83
83
|
}, params?: Record<string, any>): string;
|
|
84
84
|
compile(path: string, params?: Record<string, string>): string;
|
|
85
85
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
86
|
-
protected readonly configure:
|
|
86
|
+
protected readonly configure: _alepha_core10.HookDescriptor<"configure">;
|
|
87
87
|
protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
|
|
88
88
|
add(entry: PageRouteEntry): void;
|
|
89
89
|
protected createMatch(page: PageRoute): string;
|
|
@@ -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);
|
|
@@ -489,18 +489,18 @@ interface BrowserRoute extends Route {
|
|
|
489
489
|
page: PageRoute;
|
|
490
490
|
}
|
|
491
491
|
declare class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
492
|
-
protected readonly log:
|
|
492
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
493
493
|
protected readonly alepha: Alepha;
|
|
494
494
|
protected readonly pageApi: ReactPageProvider;
|
|
495
495
|
add(entry: PageRouteEntry): void;
|
|
496
|
-
protected readonly configure:
|
|
496
|
+
protected readonly configure: _alepha_core10.HookDescriptor<"configure">;
|
|
497
497
|
transition(url: URL, previous?: PreviousLayerData[], meta?: {}): Promise<string | void>;
|
|
498
498
|
root(state: ReactRouterState): ReactNode;
|
|
499
499
|
}
|
|
500
500
|
//#endregion
|
|
501
501
|
//#region src/providers/ReactBrowserProvider.d.ts
|
|
502
|
-
declare const envSchema$1:
|
|
503
|
-
REACT_ROOT_ID:
|
|
502
|
+
declare const envSchema$1: _alepha_core10.TObject<{
|
|
503
|
+
REACT_ROOT_ID: _alepha_core10.TString;
|
|
504
504
|
}>;
|
|
505
505
|
declare module "alepha" {
|
|
506
506
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
@@ -512,7 +512,7 @@ declare class ReactBrowserProvider {
|
|
|
512
512
|
protected readonly env: {
|
|
513
513
|
REACT_ROOT_ID: string;
|
|
514
514
|
};
|
|
515
|
-
protected readonly log:
|
|
515
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
516
516
|
protected readonly client: LinkProvider;
|
|
517
517
|
protected readonly alepha: Alepha;
|
|
518
518
|
protected readonly router: ReactBrowserRouterProvider;
|
|
@@ -546,8 +546,8 @@ declare class ReactBrowserProvider {
|
|
|
546
546
|
* Get embedded layers from the server.
|
|
547
547
|
*/
|
|
548
548
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
549
|
-
protected readonly onTransitionEnd:
|
|
550
|
-
readonly ready:
|
|
549
|
+
protected readonly onTransitionEnd: _alepha_core10.HookDescriptor<"react:transition:end">;
|
|
550
|
+
readonly ready: _alepha_core10.HookDescriptor<"ready">;
|
|
551
551
|
}
|
|
552
552
|
interface RouterGoOptions {
|
|
553
553
|
replace?: boolean;
|
|
@@ -632,7 +632,7 @@ interface NestedViewProps {
|
|
|
632
632
|
children?: ReactNode;
|
|
633
633
|
errorBoundary?: false | ((error: Error) => ReactNode);
|
|
634
634
|
}
|
|
635
|
-
declare const _default:
|
|
635
|
+
declare const _default: react1.MemoExoticComponent<(props: NestedViewProps) => react_jsx_runtime0.JSX.Element>;
|
|
636
636
|
//#endregion
|
|
637
637
|
//#region src/components/NotFound.d.ts
|
|
638
638
|
declare function NotFoundPage(props: {
|
|
@@ -640,14 +640,14 @@ declare function NotFoundPage(props: {
|
|
|
640
640
|
}): react_jsx_runtime0.JSX.Element;
|
|
641
641
|
//#endregion
|
|
642
642
|
//#region src/contexts/AlephaContext.d.ts
|
|
643
|
-
declare const AlephaContext:
|
|
643
|
+
declare const AlephaContext: react1.Context<Alepha | undefined>;
|
|
644
644
|
//#endregion
|
|
645
645
|
//#region src/contexts/RouterLayerContext.d.ts
|
|
646
646
|
interface RouterLayerContextValue {
|
|
647
647
|
index: number;
|
|
648
648
|
path: string;
|
|
649
649
|
}
|
|
650
|
-
declare const RouterLayerContext:
|
|
650
|
+
declare const RouterLayerContext: react1.Context<RouterLayerContextValue | undefined>;
|
|
651
651
|
//#endregion
|
|
652
652
|
//#region src/hooks/useActive.d.ts
|
|
653
653
|
interface UseActiveOptions {
|
|
@@ -800,12 +800,12 @@ declare const ssrSchemaLoading: (alepha: Alepha, name: string) => RequestConfigS
|
|
|
800
800
|
declare const useStore: <Key extends keyof State>(key: Key, defaultValue?: State[Key]) => [State[Key], (value: State[Key]) => void];
|
|
801
801
|
//#endregion
|
|
802
802
|
//#region src/providers/ReactServerProvider.d.ts
|
|
803
|
-
declare const envSchema:
|
|
804
|
-
REACT_SERVER_DIST:
|
|
805
|
-
REACT_SERVER_PREFIX:
|
|
806
|
-
REACT_SSR_ENABLED:
|
|
807
|
-
REACT_ROOT_ID:
|
|
808
|
-
REACT_SERVER_TEMPLATE:
|
|
803
|
+
declare const envSchema: _alepha_core10.TObject<{
|
|
804
|
+
REACT_SERVER_DIST: _alepha_core10.TString;
|
|
805
|
+
REACT_SERVER_PREFIX: _alepha_core10.TString;
|
|
806
|
+
REACT_SSR_ENABLED: _alepha_core10.TOptional<_alepha_core10.TBoolean>;
|
|
807
|
+
REACT_ROOT_ID: _alepha_core10.TString;
|
|
808
|
+
REACT_SERVER_TEMPLATE: _alepha_core10.TOptional<_alepha_core10.TString>;
|
|
809
809
|
}>;
|
|
810
810
|
declare module "alepha" {
|
|
811
811
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -814,7 +814,7 @@ declare module "alepha" {
|
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
816
|
declare class ReactServerProvider {
|
|
817
|
-
protected readonly log:
|
|
817
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
818
818
|
protected readonly alepha: Alepha;
|
|
819
819
|
protected readonly pageApi: ReactPageProvider;
|
|
820
820
|
protected readonly serverProvider: ServerProvider;
|
|
@@ -830,7 +830,7 @@ declare class ReactServerProvider {
|
|
|
830
830
|
};
|
|
831
831
|
protected readonly ROOT_DIV_REGEX: RegExp;
|
|
832
832
|
protected preprocessedTemplate: PreprocessedTemplate | null;
|
|
833
|
-
readonly onConfigure:
|
|
833
|
+
readonly onConfigure: _alepha_core10.HookDescriptor<"configure">;
|
|
834
834
|
get template(): string;
|
|
835
835
|
protected registerPages(templateLoader: TemplateLoader): Promise<void>;
|
|
836
836
|
protected getPublicDirectory(): string;
|
|
@@ -903,7 +903,7 @@ declare module "alepha" {
|
|
|
903
903
|
* @see {@link $page}
|
|
904
904
|
* @module alepha.react
|
|
905
905
|
*/
|
|
906
|
-
declare const AlephaReact:
|
|
906
|
+
declare const AlephaReact: _alepha_core10.Service<_alepha_core10.Module<{}>>;
|
|
907
907
|
//#endregion
|
|
908
908
|
export { $page, AlephaContext, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, ErrorHandler, ErrorViewer, Layer, Link, LinkProps, _default as NestedView, NotFoundPage as NotFound, PageAnimation, PageConfigSchema, PageDescriptor, PageDescriptorOptions, PageDescriptorRenderOptions, PageDescriptorRenderResult, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactBrowserRendererOptions, ReactHydrationState, ReactPageProvider, ReactRouter, ReactRouterState, ReactServerProvider, Redirection, RouterGoOptions, RouterLayerContext, RouterLayerContextValue, RouterRenderOptions, RouterStackItem, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseActiveOptions, UseQueryParamsHookOptions, UseSchemaReturn, VirtualRouter, isPageRoute, ssrSchemaLoading, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState, useSchema, useStore };
|
|
909
909
|
//# sourceMappingURL=index.d.ts.map
|
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;
|
|
@@ -140,7 +140,7 @@ 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;
|
|
@@ -319,6 +319,7 @@ declare class PermissionDescriptor extends Descriptor<PermissionDescriptorOption
|
|
|
319
319
|
protected readonly securityProvider: SecurityProvider;
|
|
320
320
|
get name(): string;
|
|
321
321
|
get group(): string;
|
|
322
|
+
toString(): string;
|
|
322
323
|
protected onInit(): void;
|
|
323
324
|
/**
|
|
324
325
|
* Check if the user has the permission.
|
|
@@ -348,6 +349,9 @@ type RealmDescriptorOptions = {
|
|
|
348
349
|
* All roles available in the realm. Role is a string (role name) or a Role object (embedded role).
|
|
349
350
|
*/
|
|
350
351
|
roles?: Array<string | Role>;
|
|
352
|
+
/**
|
|
353
|
+
* Realm settings.
|
|
354
|
+
*/
|
|
351
355
|
settings?: RealmSettings;
|
|
352
356
|
/**
|
|
353
357
|
* Parse the JWT payload to create a user account info.
|
|
@@ -398,7 +402,7 @@ declare class RealmDescriptor extends Descriptor<RealmDescriptorOptions> {
|
|
|
398
402
|
protected readonly securityProvider: SecurityProvider;
|
|
399
403
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
400
404
|
protected readonly jwt: JwtProvider;
|
|
401
|
-
protected readonly log:
|
|
405
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
402
406
|
get name(): string;
|
|
403
407
|
get accessTokenExpiration(): Duration;
|
|
404
408
|
get refreshTokenExpiration(): Duration;
|
|
@@ -465,6 +469,7 @@ interface RoleDescriptorOptions {
|
|
|
465
469
|
permissions?: Array<string | {
|
|
466
470
|
name: string;
|
|
467
471
|
ownership?: boolean;
|
|
472
|
+
exclude?: string[];
|
|
468
473
|
}>;
|
|
469
474
|
}
|
|
470
475
|
declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
|
|
@@ -475,6 +480,8 @@ declare class RoleDescriptor extends Descriptor<RoleDescriptorOptions> {
|
|
|
475
480
|
* Get the realm of the role.
|
|
476
481
|
*/
|
|
477
482
|
get realm(): string | RealmDescriptor | undefined;
|
|
483
|
+
can(permission: string | PermissionDescriptor): boolean;
|
|
484
|
+
check(permission: string | PermissionDescriptor): SecurityCheckResult;
|
|
478
485
|
}
|
|
479
486
|
//#endregion
|
|
480
487
|
//#region src/descriptors/$serviceAccount.d.ts
|
|
@@ -551,6 +558,7 @@ declare class SecurityError extends Error {
|
|
|
551
558
|
declare class CryptoProvider {
|
|
552
559
|
hashPassword(password: string): Promise<string>;
|
|
553
560
|
verifyPassword(password: string, stored: string): Promise<boolean>;
|
|
561
|
+
randomUUID(): string;
|
|
554
562
|
}
|
|
555
563
|
//#endregion
|
|
556
564
|
//#region src/index.d.ts
|
package/server/links.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "alepha/server/security";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _alepha_core2 from "alepha";
|
|
3
3
|
import { Alepha, Descriptor, KIND, Static } from "alepha";
|
|
4
4
|
import * as _alepha_server0 from "alepha/server";
|
|
5
5
|
import { ActionDescriptor, ClientRequestEntry, ClientRequestOptions, ClientRequestResponse, FetchResponse, HttpClient, RequestConfigSchema, ServerHandler, ServerRequestConfigEntry, ServerTimingProvider } from "alepha/server";
|
|
@@ -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,
|
|
@@ -181,8 +181,8 @@ declare class RemoteDescriptorProvider {
|
|
|
181
181
|
protected readonly remotes: Array<ServerRemote>;
|
|
182
182
|
protected readonly log: _alepha_logger0.Logger;
|
|
183
183
|
getRemotes(): ServerRemote[];
|
|
184
|
-
readonly configure:
|
|
185
|
-
readonly start:
|
|
184
|
+
readonly configure: _alepha_core2.HookDescriptor<"configure">;
|
|
185
|
+
readonly start: _alepha_core2.HookDescriptor<"start">;
|
|
186
186
|
registerRemote(value: RemoteDescriptor): Promise<void>;
|
|
187
187
|
protected readonly fetchLinks: _alepha_retry0.RetryDescriptorFn<(opts: FetchLinksOptions) => Promise<ApiLinksResponse>>;
|
|
188
188
|
}
|
|
@@ -250,7 +250,7 @@ declare class ServerLinksProvider {
|
|
|
250
250
|
protected readonly remoteProvider: RemoteDescriptorProvider;
|
|
251
251
|
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
252
252
|
get prefix(): string;
|
|
253
|
-
readonly onRoute:
|
|
253
|
+
readonly onRoute: _alepha_core2.HookDescriptor<"configure">;
|
|
254
254
|
/**
|
|
255
255
|
* First API - Get all API links for the user.
|
|
256
256
|
*
|
|
@@ -310,7 +310,7 @@ declare module "alepha" {
|
|
|
310
310
|
* @see {@link $client}
|
|
311
311
|
* @module alepha.server.links
|
|
312
312
|
*/
|
|
313
|
-
declare const AlephaServerLinks:
|
|
313
|
+
declare const AlephaServerLinks: _alepha_core2.Service<_alepha_core2.Module<{}>>;
|
|
314
314
|
//#endregion
|
|
315
315
|
export { $client, $remote, AlephaServerLinks, ApiLink, ApiLinksResponse, ClientScope, FetchLinksOptions, GetApiLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction, apiLinkSchema, apiLinksResponseSchema };
|
|
316
316
|
//# sourceMappingURL=index.d.ts.map
|
package/server.d.ts
CHANGED
|
@@ -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> {
|
|
@@ -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
|
* },
|