alepha 0.6.9 → 0.7.0
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/cache.d.ts +1 -0
- package/core.d.ts +57 -58
- package/lock.d.ts +2 -1
- package/package.json +27 -21
- package/postgres.d.ts +236 -46
- package/queue.d.ts +1 -0
- package/react/auth.d.ts +29 -28
- package/react.d.ts +80 -52
- package/redis.d.ts +2 -1
- package/security.d.ts +25 -18
- package/server/metrics.d.ts +1 -1
- package/server/proxy.d.ts +1 -34
- package/server/static.d.ts +5 -0
- package/server/swagger.d.ts +1 -0
- package/server.d.ts +438 -192
- package/topic.d.ts +1 -0
- package/vite.d.ts +11 -1
package/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _alepha_core from '@alepha/core';
|
|
2
2
|
import { Alepha, Static as Static$1, TSchema as TSchema$1, KIND, OPTIONS, Async, Class, TObject as TObject$1 } from '@alepha/core';
|
|
3
3
|
import * as _alepha_server from '@alepha/server';
|
|
4
|
-
import { HttpClientLink, HttpClient, ServerRouterProvider, ServerHandler, ServerRequest } from '@alepha/server';
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
4
|
+
import { HttpClientLink, HttpClient, ApiLinksResponse, ServerRouterProvider, ServerHandler, ServerRequest } from '@alepha/server';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import React__default, { ReactNode, FC, AnchorHTMLAttributes, PropsWithChildren, ErrorInfo } from 'react';
|
|
7
7
|
import { Root } from 'react-dom/client';
|
|
8
8
|
import { RouterProvider, Route } from '@alepha/router';
|
|
9
9
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -156,7 +156,7 @@ declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
|
156
156
|
add(entry: PageRouteEntry): void;
|
|
157
157
|
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
158
158
|
transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
|
|
159
|
-
root(state: RouterState, context
|
|
159
|
+
root(state: RouterState, context: PageReactContext): ReactNode;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
declare const envSchema$1: _alepha_core.TObject<{
|
|
@@ -193,10 +193,7 @@ declare class ReactBrowserProvider {
|
|
|
193
193
|
protected render(options?: {
|
|
194
194
|
url?: string;
|
|
195
195
|
previous?: PreviousLayerData[];
|
|
196
|
-
}): Promise<
|
|
197
|
-
url: string;
|
|
198
|
-
head: Head;
|
|
199
|
-
}>;
|
|
196
|
+
}): Promise<RouterRenderResult>;
|
|
200
197
|
/**
|
|
201
198
|
* Get embedded layers from the server.
|
|
202
199
|
*
|
|
@@ -218,6 +215,7 @@ declare class ReactBrowserProvider {
|
|
|
218
215
|
interface RouterGoOptions {
|
|
219
216
|
replace?: boolean;
|
|
220
217
|
match?: TransitionOptions;
|
|
218
|
+
params?: Record<string, string>;
|
|
221
219
|
}
|
|
222
220
|
interface ReactHydrationState {
|
|
223
221
|
layers?: PreviousLayerData[];
|
|
@@ -265,28 +263,16 @@ declare class RouterHookApi {
|
|
|
265
263
|
createHref(pathname: HrefLike, layer?: {
|
|
266
264
|
path: string;
|
|
267
265
|
}): string;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* @param options
|
|
272
|
-
*/
|
|
273
|
-
go(path: HrefLike, options?: RouterGoOptions): Promise<void>;
|
|
274
|
-
/**
|
|
275
|
-
*
|
|
276
|
-
* @param path
|
|
277
|
-
*/
|
|
278
|
-
createAnchorProps(path: string): AnchorProps;
|
|
266
|
+
go(path: string, options?: RouterGoOptions): Promise<void>;
|
|
267
|
+
go<T extends object>(path: keyof VirtualRouter<T>, options?: RouterGoOptions): Promise<void>;
|
|
268
|
+
anchor(path: string): AnchorProps;
|
|
279
269
|
/**
|
|
280
270
|
* Set query params.
|
|
281
271
|
*
|
|
282
272
|
* @param record
|
|
283
273
|
* @param options
|
|
284
274
|
*/
|
|
285
|
-
setQueryParams(record: Record<string, any
|
|
286
|
-
/**
|
|
287
|
-
* If true, this will merge current query params with the new ones.
|
|
288
|
-
*/
|
|
289
|
-
merge?: boolean;
|
|
275
|
+
setQueryParams(record: Record<string, any> | ((queryParams: Record<string, any>) => Record<string, any>), options?: {
|
|
290
276
|
/**
|
|
291
277
|
* If true, this will add a new entry to the history stack.
|
|
292
278
|
*/
|
|
@@ -299,6 +285,9 @@ type HrefLike = string | {
|
|
|
299
285
|
name?: string;
|
|
300
286
|
};
|
|
301
287
|
};
|
|
288
|
+
type VirtualRouter<T> = {
|
|
289
|
+
[K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K];
|
|
290
|
+
};
|
|
302
291
|
|
|
303
292
|
declare const KEY = "PAGE";
|
|
304
293
|
interface PageConfigSchema {
|
|
@@ -324,10 +313,7 @@ interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSch
|
|
|
324
313
|
};
|
|
325
314
|
can?: () => boolean;
|
|
326
315
|
head?: Head | ((props: TProps, previous?: Head) => Head);
|
|
327
|
-
errorHandler?:
|
|
328
|
-
error: Error;
|
|
329
|
-
url: string;
|
|
330
|
-
}>;
|
|
316
|
+
errorHandler?: (error: Error) => ReactNode;
|
|
331
317
|
}
|
|
332
318
|
interface PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
333
319
|
[KIND]: typeof KEY;
|
|
@@ -361,11 +347,7 @@ interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema>
|
|
|
361
347
|
params: TConfig["params"] extends TSchema$1 ? Static$1<TConfig["params"]> : Record<string, string>;
|
|
362
348
|
query: TConfig["query"] extends TSchema$1 ? Static$1<TConfig["query"]> : Record<string, string>;
|
|
363
349
|
}
|
|
364
|
-
type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent &
|
|
365
|
-
interface PageResolveContext {
|
|
366
|
-
url: URL;
|
|
367
|
-
head: Head;
|
|
368
|
-
}
|
|
350
|
+
type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;
|
|
369
351
|
|
|
370
352
|
declare class PageDescriptorProvider {
|
|
371
353
|
protected readonly log: _alepha_core.Logger;
|
|
@@ -373,12 +355,9 @@ declare class PageDescriptorProvider {
|
|
|
373
355
|
protected readonly pages: PageRoute[];
|
|
374
356
|
getPages(): PageRoute[];
|
|
375
357
|
page(name: string): PageRoute;
|
|
376
|
-
root(state: RouterState, context
|
|
358
|
+
root(state: RouterState, context: PageReactContext): ReactNode;
|
|
377
359
|
createLayers(route: PageRoute, request: PageRequest): Promise<CreateLayersResult>;
|
|
378
|
-
protected getErrorHandler(route: PageRoute):
|
|
379
|
-
error: Error;
|
|
380
|
-
url: string;
|
|
381
|
-
}> | undefined;
|
|
360
|
+
protected getErrorHandler(route: PageRoute): ((error: Error) => ReactNode) | undefined;
|
|
382
361
|
protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
|
|
383
362
|
protected fillHead(page: PageRoute, ctx: PageRequest, props: Record<string, any>): void;
|
|
384
363
|
renderError(e: Error): ReactNode;
|
|
@@ -429,14 +408,13 @@ interface Layer {
|
|
|
429
408
|
}
|
|
430
409
|
type PreviousLayerData = Omit<Layer, "element">;
|
|
431
410
|
interface AnchorProps {
|
|
432
|
-
href
|
|
433
|
-
onClick
|
|
411
|
+
href: string;
|
|
412
|
+
onClick: (ev: any) => any;
|
|
434
413
|
}
|
|
435
414
|
interface RouterState {
|
|
436
415
|
pathname: string;
|
|
437
416
|
search: string;
|
|
438
417
|
layers: Array<Layer>;
|
|
439
|
-
head: Head;
|
|
440
418
|
}
|
|
441
419
|
interface TransitionOptions {
|
|
442
420
|
state?: RouterState;
|
|
@@ -450,23 +428,27 @@ interface RouterStackItem {
|
|
|
450
428
|
error?: Error;
|
|
451
429
|
}
|
|
452
430
|
interface RouterRenderResult {
|
|
431
|
+
state: RouterState;
|
|
432
|
+
context: PageReactContext;
|
|
453
433
|
redirect?: string;
|
|
454
|
-
layers: Layer[];
|
|
455
|
-
head: Head;
|
|
456
|
-
element: ReactNode;
|
|
457
434
|
}
|
|
458
435
|
interface PageRequest extends PageReactContext {
|
|
459
|
-
url: URL;
|
|
460
436
|
params: Record<string, any>;
|
|
461
437
|
query: Record<string, string>;
|
|
462
|
-
head: Head;
|
|
463
438
|
previous?: PreviousLayerData[];
|
|
464
439
|
}
|
|
465
440
|
interface CreateLayersResult extends RouterState {
|
|
466
441
|
redirect?: string;
|
|
467
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* It's like RouterState, but publicly available in React context.
|
|
445
|
+
* This is where we store all plugin data!
|
|
446
|
+
*/
|
|
468
447
|
interface PageReactContext {
|
|
469
|
-
|
|
448
|
+
url: URL;
|
|
449
|
+
head: Head;
|
|
450
|
+
onError: (error: Error) => ReactNode;
|
|
451
|
+
links?: ApiLinksResponse;
|
|
470
452
|
}
|
|
471
453
|
|
|
472
454
|
interface NestedViewProps {
|
|
@@ -478,26 +460,65 @@ interface NestedViewProps {
|
|
|
478
460
|
* @param props
|
|
479
461
|
* @constructor
|
|
480
462
|
*/
|
|
481
|
-
declare const NestedView: (props: NestedViewProps) =>
|
|
463
|
+
declare const NestedView: (props: NestedViewProps) => react_jsx_runtime.JSX.Element;
|
|
482
464
|
|
|
483
465
|
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
484
466
|
to: string | PageDescriptor;
|
|
485
|
-
children?:
|
|
467
|
+
children?: React__default.ReactNode;
|
|
486
468
|
}
|
|
487
469
|
declare const Link: (props: LinkProps) => react_jsx_runtime.JSX.Element | null;
|
|
488
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Props for the ErrorBoundary component.
|
|
473
|
+
*/
|
|
474
|
+
interface ErrorBoundaryProps {
|
|
475
|
+
/**
|
|
476
|
+
* Fallback React node to render when an error is caught.
|
|
477
|
+
* If not provided, a default error message will be shown.
|
|
478
|
+
*/
|
|
479
|
+
fallback: (error: Error) => ReactNode;
|
|
480
|
+
/**
|
|
481
|
+
* Optional callback that receives the error and error info.
|
|
482
|
+
* Use this to log errors to a monitoring service.
|
|
483
|
+
*/
|
|
484
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* State of the ErrorBoundary component.
|
|
488
|
+
*/
|
|
489
|
+
interface ErrorBoundaryState {
|
|
490
|
+
error?: Error;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* A reusable error boundary for catching rendering errors
|
|
494
|
+
* in any part of the React component tree.
|
|
495
|
+
*/
|
|
496
|
+
declare class ErrorBoundary extends React__default.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
|
|
497
|
+
constructor(props: ErrorBoundaryProps);
|
|
498
|
+
/**
|
|
499
|
+
* Update state so the next render shows the fallback UI.
|
|
500
|
+
*/
|
|
501
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
502
|
+
/**
|
|
503
|
+
* Lifecycle method called when an error is caught.
|
|
504
|
+
* You can log the error or perform side effects here.
|
|
505
|
+
*/
|
|
506
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
507
|
+
render(): ReactNode;
|
|
508
|
+
}
|
|
509
|
+
|
|
489
510
|
interface RouterContextValue {
|
|
490
511
|
alepha: Alepha;
|
|
491
512
|
state: RouterState;
|
|
492
513
|
context: PageReactContext;
|
|
493
514
|
}
|
|
494
|
-
declare const RouterContext:
|
|
515
|
+
declare const RouterContext: React.Context<RouterContextValue | undefined>;
|
|
495
516
|
|
|
496
517
|
interface RouterLayerContextValue {
|
|
497
518
|
index: number;
|
|
498
519
|
path: string;
|
|
499
520
|
}
|
|
500
|
-
declare const RouterLayerContext:
|
|
521
|
+
declare const RouterLayerContext: React.Context<RouterLayerContextValue | undefined>;
|
|
501
522
|
|
|
502
523
|
declare const useInject: <T extends object>(clazz: Class<T>) => T;
|
|
503
524
|
|
|
@@ -574,6 +595,9 @@ declare class ReactServerProvider {
|
|
|
574
595
|
protected getPublicDirectory(): string;
|
|
575
596
|
protected configureStaticServer(root: string): Promise<void>;
|
|
576
597
|
protected configureVite(): Promise<void>;
|
|
598
|
+
/**
|
|
599
|
+
* For testing purposes, creates a render function that can be used.
|
|
600
|
+
*/
|
|
577
601
|
protected createRenderFunction(name: string): (options?: {
|
|
578
602
|
params?: Record<string, string>;
|
|
579
603
|
query?: Record<string, string>;
|
|
@@ -587,6 +611,7 @@ declare class ReactServerProvider {
|
|
|
587
611
|
declare module "@alepha/core" {
|
|
588
612
|
interface Hooks {
|
|
589
613
|
"react:browser:render": {
|
|
614
|
+
state: RouterState;
|
|
590
615
|
context: PageReactContext;
|
|
591
616
|
hydration?: ReactHydrationState;
|
|
592
617
|
};
|
|
@@ -596,6 +621,7 @@ declare module "@alepha/core" {
|
|
|
596
621
|
};
|
|
597
622
|
"react:transition:begin": {
|
|
598
623
|
state: RouterState;
|
|
624
|
+
context: PageReactContext;
|
|
599
625
|
};
|
|
600
626
|
"react:transition:success": {
|
|
601
627
|
state: RouterState;
|
|
@@ -603,9 +629,11 @@ declare module "@alepha/core" {
|
|
|
603
629
|
"react:transition:error": {
|
|
604
630
|
error: Error;
|
|
605
631
|
state: RouterState;
|
|
632
|
+
context: PageReactContext;
|
|
606
633
|
};
|
|
607
634
|
"react:transition:end": {
|
|
608
635
|
state: RouterState;
|
|
636
|
+
context: PageReactContext;
|
|
609
637
|
};
|
|
610
638
|
}
|
|
611
639
|
}
|
|
@@ -614,4 +642,4 @@ declare class ReactModule {
|
|
|
614
642
|
constructor();
|
|
615
643
|
}
|
|
616
644
|
|
|
617
|
-
export { $page, type AnchorProps, type CreateLayersResult, type Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type
|
|
645
|
+
export { $page, type AnchorProps, type CreateLayersResult, ErrorBoundary, type Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, type ReactHydrationState, ReactModule, ReactServerProvider, RedirectionError, RouterContext, type RouterContextValue, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterRenderResult, type RouterStackItem, type RouterState, type TPropsDefault, type TPropsParentDefault, type TransitionOptions, type UseActiveHook, type UseQueryParamsHookOptions, type VirtualRouter, envSchema, isPageRoute, useActive, useApi, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
|
package/redis.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _alepha_core from '@alepha/core';
|
|
2
2
|
import { Static, Alepha } from '@alepha/core';
|
|
3
3
|
import * as Redis from 'ioredis';
|
|
4
|
-
import Redis__default from 'ioredis';
|
|
4
|
+
import Redis__default, { RedisOptions } from 'ioredis';
|
|
5
5
|
|
|
6
6
|
/** Symbol key applied to readonly types */
|
|
7
7
|
declare const ReadonlyKind: unique symbol;
|
|
@@ -110,6 +110,7 @@ declare class RedisProvider {
|
|
|
110
110
|
* Close the connection to the Redis server.
|
|
111
111
|
*/
|
|
112
112
|
close(): Promise<void>;
|
|
113
|
+
duplicate(options?: Partial<RedisOptions>): RedisClient;
|
|
113
114
|
/**
|
|
114
115
|
* Redis subscriber client factory method.
|
|
115
116
|
*/
|
package/security.d.ts
CHANGED
|
@@ -601,24 +601,31 @@ declare const $role: {
|
|
|
601
601
|
* @param options
|
|
602
602
|
*/
|
|
603
603
|
declare const $serviceAccount: (options: ServiceAccountDescriptorOptions) => ServiceAccountDescriptor;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
604
|
+
type ServiceAccountDescriptorOptions = {
|
|
605
|
+
oauth2: {
|
|
606
|
+
/**
|
|
607
|
+
* Get Token URL.
|
|
608
|
+
*/
|
|
609
|
+
url: string;
|
|
610
|
+
/**
|
|
611
|
+
* Client ID.
|
|
612
|
+
*/
|
|
613
|
+
clientId: string;
|
|
614
|
+
/**
|
|
615
|
+
* Client Secret.
|
|
616
|
+
*/
|
|
617
|
+
clientSecret: string;
|
|
618
|
+
/**
|
|
619
|
+
* Scopes to request.
|
|
620
|
+
*/
|
|
621
|
+
scope?: string;
|
|
622
|
+
};
|
|
623
|
+
} | {
|
|
624
|
+
jwt: {
|
|
625
|
+
secret: string;
|
|
626
|
+
roles?: string[];
|
|
627
|
+
};
|
|
628
|
+
};
|
|
622
629
|
interface ServiceAccountDescriptor {
|
|
623
630
|
options: ServiceAccountDescriptorOptions;
|
|
624
631
|
store: ServiceAccountStore;
|
package/server/metrics.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare class ServerMetricsProvider {
|
|
|
6
6
|
private memoryUsage;
|
|
7
7
|
private gcDuration;
|
|
8
8
|
private heapUsage;
|
|
9
|
-
readonly metrics: _alepha_server.
|
|
9
|
+
readonly metrics: _alepha_server.ActionDescriptor<_alepha_server.RequestConfigSchema>;
|
|
10
10
|
constructor();
|
|
11
11
|
private collectMetrics;
|
|
12
12
|
}
|
package/server/proxy.d.ts
CHANGED
|
@@ -1,34 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Async, KIND, OPTIONS, Alepha } from '@alepha/core';
|
|
3
|
-
import { ServerRequest, ServerRouterProvider } from '@alepha/server';
|
|
4
|
-
|
|
5
|
-
type ProxyDescriptorOptions = {
|
|
6
|
-
path: string;
|
|
7
|
-
target: string;
|
|
8
|
-
beforeRequest?: (request: ServerRequest, proxyRequest: RequestInit) => Async<void>;
|
|
9
|
-
afterResponse?: (request: ServerRequest, proxyResponse: Response) => Async<void>;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
};
|
|
12
|
-
interface ProxyDescriptor {
|
|
13
|
-
[KIND]: "PROXY";
|
|
14
|
-
[OPTIONS]: ProxyDescriptorOptions;
|
|
15
|
-
}
|
|
16
|
-
declare const $proxy: {
|
|
17
|
-
(options: ProxyDescriptorOptions): ProxyDescriptor;
|
|
18
|
-
[KIND]: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
declare class ServerProxyProvider {
|
|
22
|
-
protected readonly routerProvider: ServerRouterProvider;
|
|
23
|
-
protected readonly alepha: Alepha;
|
|
24
|
-
readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
25
|
-
proxy(options: ProxyDescriptorOptions): Promise<void>;
|
|
26
|
-
private getRawRequestBody;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare class ServerProxyModule {
|
|
30
|
-
protected readonly alepha: Alepha;
|
|
31
|
-
constructor();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { $proxy, type ProxyDescriptor, type ProxyDescriptorOptions, ServerProxyModule, ServerProxyProvider };
|
|
1
|
+
export * from '@alepha/server-proxy';
|
package/server/static.d.ts
CHANGED
|
@@ -35,6 +35,11 @@ interface ServeDescriptorOptions {
|
|
|
35
35
|
* @default true
|
|
36
36
|
*/
|
|
37
37
|
indexFallback?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Force all requests "not found" to be served with the index.html file.
|
|
40
|
+
* This is useful for single-page applications (SPAs) that use client-side only routing.
|
|
41
|
+
*/
|
|
42
|
+
historyApiFallback?: boolean;
|
|
38
43
|
/**
|
|
39
44
|
* Optional name of the descriptor.
|
|
40
45
|
* This is used for logging and debugging purposes.
|