@alepha/react 0.12.1 → 0.13.1
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/dist/auth/index.browser.js +4 -1642
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +4 -1642
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.d.ts +83 -83
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.js +3 -1642
- package/dist/form/index.js.map +1 -1
- package/dist/head/index.browser.js +3 -1654
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +149 -885
- package/dist/head/index.js +4 -1654
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/index.js +3 -1653
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.d.ts +159 -3
- package/dist/websocket/index.js +2 -1654
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -15
- package/dist/auth/chunk-DhGyd7sr.js +0 -28
- package/dist/auth/index.cjs +0 -1800
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.d.cts +0 -1274
- package/dist/core/chunk-DhGyd7sr.js +0 -28
- package/dist/core/index.cjs +0 -2087
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -2763
- package/dist/form/chunk-DhGyd7sr.js +0 -28
- package/dist/form/index.cjs +0 -2074
- package/dist/form/index.cjs.map +0 -1
- package/dist/form/index.d.cts +0 -419
- package/dist/head/chunk-DhGyd7sr.js +0 -28
- package/dist/head/index.cjs +0 -1912
- package/dist/head/index.cjs.map +0 -1
- package/dist/head/index.d.cts +0 -1801
- package/dist/i18n/chunk-DhGyd7sr.js +0 -28
- package/dist/i18n/index.cjs +0 -1899
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -437
- package/dist/websocket/index.cjs +0 -1787
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -118
- package/src/i18n/README.md +0 -76
package/dist/head/index.d.ts
CHANGED
|
@@ -1,23 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "react/jsx-runtime";
|
|
1
|
+
import { PageConfigSchema, PageRoute, ReactRouterState, TPropsDefault, TPropsParentDefault } from "@alepha/react";
|
|
2
|
+
import * as alepha53 from "alepha";
|
|
3
|
+
import { Alepha, AlephaError, Async, Descriptor, FileLike, InstantiableClass, KIND, LogLevel, LoggerInterface, Static, StreamLike, TArray, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
5
4
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
6
5
|
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
7
6
|
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
8
7
|
import { Readable } from "node:stream";
|
|
9
8
|
import { ReadableStream } from "node:stream/web";
|
|
10
9
|
|
|
10
|
+
//#region src/head/interfaces/Head.d.ts
|
|
11
|
+
interface Head extends SimpleHead {
|
|
12
|
+
description?: string;
|
|
13
|
+
keywords?: string[];
|
|
14
|
+
author?: string;
|
|
15
|
+
robots?: string;
|
|
16
|
+
themeColor?: string;
|
|
17
|
+
viewport?: string | {
|
|
18
|
+
width?: string;
|
|
19
|
+
height?: string;
|
|
20
|
+
initialScale?: string;
|
|
21
|
+
maximumScale?: string;
|
|
22
|
+
userScalable?: "no" | "yes" | "0" | "1";
|
|
23
|
+
interactiveWidget?: "resizes-visual" | "resizes-content" | "overlays-content";
|
|
24
|
+
};
|
|
25
|
+
og?: {
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
image?: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
type?: string;
|
|
31
|
+
};
|
|
32
|
+
twitter?: {
|
|
33
|
+
card?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
image?: string;
|
|
37
|
+
site?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface SimpleHead {
|
|
41
|
+
title?: string;
|
|
42
|
+
titleSeparator?: string;
|
|
43
|
+
htmlAttributes?: Record<string, string>;
|
|
44
|
+
bodyAttributes?: Record<string, string>;
|
|
45
|
+
meta?: Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
content: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/head/providers/HeadProvider.d.ts
|
|
52
|
+
declare class HeadProvider {
|
|
53
|
+
global?: Head | (() => Head);
|
|
54
|
+
protected getGlobalHead(): Head | undefined;
|
|
55
|
+
fillHead(state: ReactRouterState): void;
|
|
56
|
+
protected fillHeadByPage(page: PageRoute, state: ReactRouterState, props: Record<string, any>): void;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/head/descriptors/$head.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Set global `<head>` options for the application.
|
|
62
|
+
*/
|
|
63
|
+
declare const $head: {
|
|
64
|
+
(options: HeadDescriptorOptions): HeadDescriptor;
|
|
65
|
+
[KIND]: typeof HeadDescriptor;
|
|
66
|
+
};
|
|
67
|
+
type HeadDescriptorOptions = Head | (() => Head);
|
|
68
|
+
declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
|
|
69
|
+
protected readonly provider: HeadProvider;
|
|
70
|
+
protected onInit(): void;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/head/hooks/useHead.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* ```tsx
|
|
76
|
+
* const App = () => {
|
|
77
|
+
* const [head, setHead] = useHead({
|
|
78
|
+
* // will set the document title on the first render
|
|
79
|
+
* title: "My App",
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* return (
|
|
83
|
+
* // This will update the document title when the button is clicked
|
|
84
|
+
* <button onClick={() => setHead({ title: "Change Title" })}>
|
|
85
|
+
* Change Title {head.title}
|
|
86
|
+
* </button>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const useHead: (options?: UseHeadOptions) => UseHeadReturn;
|
|
92
|
+
type UseHeadOptions = Head | ((previous?: Head) => Head);
|
|
93
|
+
type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void];
|
|
94
|
+
//#endregion
|
|
11
95
|
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
12
|
-
declare const logEntrySchema:
|
|
13
|
-
level:
|
|
14
|
-
message:
|
|
15
|
-
service:
|
|
16
|
-
module:
|
|
17
|
-
context:
|
|
18
|
-
app:
|
|
19
|
-
data:
|
|
20
|
-
timestamp:
|
|
96
|
+
declare const logEntrySchema: alepha53.TObject<{
|
|
97
|
+
level: alepha53.TUnsafe<"TRACE" | "SILENT" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
98
|
+
message: alepha53.TString;
|
|
99
|
+
service: alepha53.TString;
|
|
100
|
+
module: alepha53.TString;
|
|
101
|
+
context: alepha53.TOptional<alepha53.TString>;
|
|
102
|
+
app: alepha53.TOptional<alepha53.TString>;
|
|
103
|
+
data: alepha53.TOptional<alepha53.TAny>;
|
|
104
|
+
timestamp: alepha53.TNumber;
|
|
21
105
|
}>;
|
|
22
106
|
type LogEntry = Static<typeof logEntrySchema>;
|
|
23
107
|
//#endregion
|
|
@@ -32,8 +116,8 @@ declare class DateTimeProvider {
|
|
|
32
116
|
protected readonly timeouts: Timeout[];
|
|
33
117
|
protected readonly intervals: Interval[];
|
|
34
118
|
constructor();
|
|
35
|
-
protected readonly onStart:
|
|
36
|
-
protected readonly onStop:
|
|
119
|
+
protected readonly onStart: alepha53.HookDescriptor<"start">;
|
|
120
|
+
protected readonly onStop: alepha53.HookDescriptor<"stop">;
|
|
37
121
|
setLocale(locale: string): void;
|
|
38
122
|
isDateTime(value: unknown): value is DateTime;
|
|
39
123
|
/**
|
|
@@ -100,7 +184,7 @@ declare class DateTimeProvider {
|
|
|
100
184
|
/**
|
|
101
185
|
* Run a function with a deadline.
|
|
102
186
|
*/
|
|
103
|
-
deadline<T
|
|
187
|
+
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
104
188
|
/**
|
|
105
189
|
* Add time to the current date.
|
|
106
190
|
*/
|
|
@@ -165,7 +249,7 @@ declare class Logger implements LoggerInterface {
|
|
|
165
249
|
}
|
|
166
250
|
//#endregion
|
|
167
251
|
//#region ../alepha/src/logger/index.d.ts
|
|
168
|
-
declare const envSchema$
|
|
252
|
+
declare const envSchema$2: alepha53.TObject<{
|
|
169
253
|
/**
|
|
170
254
|
* Default log level for the application.
|
|
171
255
|
*
|
|
@@ -182,17 +266,17 @@ declare const envSchema$6: alepha93.TObject<{
|
|
|
182
266
|
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
183
267
|
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
184
268
|
*/
|
|
185
|
-
LOG_LEVEL:
|
|
269
|
+
LOG_LEVEL: alepha53.TOptional<alepha53.TString>;
|
|
186
270
|
/**
|
|
187
271
|
* Built-in log formats.
|
|
188
272
|
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
189
273
|
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
190
274
|
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
191
275
|
*/
|
|
192
|
-
LOG_FORMAT:
|
|
276
|
+
LOG_FORMAT: alepha53.TOptional<alepha53.TUnsafe<"json" | "pretty" | "raw">>;
|
|
193
277
|
}>;
|
|
194
278
|
declare module "alepha" {
|
|
195
|
-
interface Env extends Partial<Static<typeof envSchema$
|
|
279
|
+
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
196
280
|
interface State {
|
|
197
281
|
/**
|
|
198
282
|
* Current log level for the application or specific modules.
|
|
@@ -212,19 +296,19 @@ declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "
|
|
|
212
296
|
type RouteMethod = (typeof routeMethods)[number];
|
|
213
297
|
//#endregion
|
|
214
298
|
//#region ../alepha/src/router/providers/RouterProvider.d.ts
|
|
215
|
-
declare abstract class RouterProvider<T
|
|
299
|
+
declare abstract class RouterProvider<T extends Route = Route> {
|
|
216
300
|
protected routePathRegex: RegExp;
|
|
217
|
-
protected tree: Tree<T
|
|
218
|
-
protected cache: Map<string, RouteMatch<T
|
|
219
|
-
match(path: string): RouteMatch<T
|
|
301
|
+
protected tree: Tree<T>;
|
|
302
|
+
protected cache: Map<string, RouteMatch<T>>;
|
|
303
|
+
match(path: string): RouteMatch<T>;
|
|
220
304
|
protected test(path: string): void;
|
|
221
|
-
protected push(route: T
|
|
222
|
-
protected createRouteMatch(path: string): RouteMatch<T
|
|
223
|
-
protected mapParams(match: RouteMatch<T
|
|
305
|
+
protected push(route: T): void;
|
|
306
|
+
protected createRouteMatch(path: string): RouteMatch<T>;
|
|
307
|
+
protected mapParams(match: RouteMatch<T>): RouteMatch<T>;
|
|
224
308
|
protected createParts(path: string): string[];
|
|
225
309
|
}
|
|
226
|
-
interface RouteMatch<T
|
|
227
|
-
route?: T
|
|
310
|
+
interface RouteMatch<T extends Route> {
|
|
311
|
+
route?: T;
|
|
228
312
|
params?: Record<string, string>;
|
|
229
313
|
}
|
|
230
314
|
interface Route {
|
|
@@ -238,20 +322,20 @@ interface Route {
|
|
|
238
322
|
*/
|
|
239
323
|
mapParams?: Record<string, string>;
|
|
240
324
|
}
|
|
241
|
-
interface Tree<T
|
|
242
|
-
route?: T
|
|
325
|
+
interface Tree<T extends Route> {
|
|
326
|
+
route?: T;
|
|
243
327
|
children: {
|
|
244
|
-
[key: string]: Tree<T
|
|
328
|
+
[key: string]: Tree<T>;
|
|
245
329
|
};
|
|
246
330
|
param?: {
|
|
247
|
-
route?: T
|
|
331
|
+
route?: T;
|
|
248
332
|
name: string;
|
|
249
333
|
children: {
|
|
250
|
-
[key: string]: Tree<T
|
|
334
|
+
[key: string]: Tree<T>;
|
|
251
335
|
};
|
|
252
336
|
};
|
|
253
337
|
wildcard?: {
|
|
254
|
-
route: T
|
|
338
|
+
route: T;
|
|
255
339
|
};
|
|
256
340
|
}
|
|
257
341
|
//#endregion
|
|
@@ -440,8 +524,8 @@ declare class ServerTimingProvider {
|
|
|
440
524
|
prefix: string;
|
|
441
525
|
disabled: boolean;
|
|
442
526
|
};
|
|
443
|
-
readonly onRequest:
|
|
444
|
-
readonly onResponse:
|
|
527
|
+
readonly onRequest: alepha53.HookDescriptor<"server:onRequest">;
|
|
528
|
+
readonly onResponse: alepha53.HookDescriptor<"server:onResponse">;
|
|
445
529
|
protected get handlerName(): string;
|
|
446
530
|
beginTiming(name: string): void;
|
|
447
531
|
endTiming(name: string): void;
|
|
@@ -505,11 +589,11 @@ declare class ServerProvider {
|
|
|
505
589
|
/**
|
|
506
590
|
* When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
|
|
507
591
|
*/
|
|
508
|
-
protected readonly onNodeRequest:
|
|
592
|
+
protected readonly onNodeRequest: alepha53.HookDescriptor<"node:request">;
|
|
509
593
|
/**
|
|
510
594
|
* When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
|
|
511
595
|
*/
|
|
512
|
-
protected readonly onWebRequest:
|
|
596
|
+
protected readonly onWebRequest: alepha53.HookDescriptor<"web:request">;
|
|
513
597
|
/**
|
|
514
598
|
* Handle Node.js HTTP request event.
|
|
515
599
|
*
|
|
@@ -643,7 +727,7 @@ declare class HttpClient {
|
|
|
643
727
|
readonly cache: CacheDescriptorFn<HttpClientCache, any[]>;
|
|
644
728
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
645
729
|
fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
|
|
646
|
-
fetch<T
|
|
730
|
+
fetch<T extends TSchema>(url: string, request?: RequestInitWithOptions<T>): Promise<FetchResponse<Static<T>>>;
|
|
647
731
|
protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
|
|
648
732
|
protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
|
|
649
733
|
protected responseData(response: Response, options: FetchOptions): Promise<any>;
|
|
@@ -660,7 +744,7 @@ declare class HttpClient {
|
|
|
660
744
|
};
|
|
661
745
|
}, args?: ServerRequestConfigEntry): string;
|
|
662
746
|
}
|
|
663
|
-
interface FetchOptions<T
|
|
747
|
+
interface FetchOptions<T extends TSchema = TSchema> {
|
|
664
748
|
/**
|
|
665
749
|
* Key to identify the request in the pending requests.
|
|
666
750
|
*/
|
|
@@ -669,16 +753,16 @@ interface FetchOptions<T$1 extends TSchema = TSchema> {
|
|
|
669
753
|
* The schema to validate the response against.
|
|
670
754
|
*/
|
|
671
755
|
schema?: {
|
|
672
|
-
response?: T
|
|
756
|
+
response?: T;
|
|
673
757
|
};
|
|
674
758
|
/**
|
|
675
759
|
* Built-in cache options.
|
|
676
760
|
*/
|
|
677
761
|
localCache?: boolean | number | DurationLike;
|
|
678
762
|
}
|
|
679
|
-
type RequestInitWithOptions<T
|
|
680
|
-
interface FetchResponse<T
|
|
681
|
-
data: T
|
|
763
|
+
type RequestInitWithOptions<T extends TSchema = TSchema> = RequestInit & FetchOptions<T>;
|
|
764
|
+
interface FetchResponse<T = any> {
|
|
765
|
+
data: T;
|
|
682
766
|
status: number;
|
|
683
767
|
statusText: string;
|
|
684
768
|
headers: Headers;
|
|
@@ -816,7 +900,7 @@ declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Desc
|
|
|
816
900
|
*/
|
|
817
901
|
fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
|
|
818
902
|
}
|
|
819
|
-
type ClientRequestEntry<TConfig extends RequestConfigSchema, T
|
|
903
|
+
type ClientRequestEntry<TConfig extends RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
820
904
|
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
|
|
821
905
|
body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
|
|
822
906
|
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
|
|
@@ -844,15 +928,15 @@ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSche
|
|
|
844
928
|
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
845
929
|
//#endregion
|
|
846
930
|
//#region ../alepha/src/server/schemas/errorSchema.d.ts
|
|
847
|
-
declare const errorSchema:
|
|
848
|
-
error:
|
|
849
|
-
status:
|
|
850
|
-
message:
|
|
851
|
-
details:
|
|
852
|
-
requestId:
|
|
853
|
-
cause:
|
|
854
|
-
name:
|
|
855
|
-
message:
|
|
931
|
+
declare const errorSchema: alepha53.TObject<{
|
|
932
|
+
error: alepha53.TString;
|
|
933
|
+
status: alepha53.TInteger;
|
|
934
|
+
message: alepha53.TString;
|
|
935
|
+
details: alepha53.TOptional<alepha53.TString>;
|
|
936
|
+
requestId: alepha53.TOptional<alepha53.TString>;
|
|
937
|
+
cause: alepha53.TOptional<alepha53.TObject<{
|
|
938
|
+
name: alepha53.TString;
|
|
939
|
+
message: alepha53.TString;
|
|
856
940
|
}>>;
|
|
857
941
|
}>;
|
|
858
942
|
type ErrorSchema = Static<typeof errorSchema>;
|
|
@@ -877,21 +961,21 @@ interface HttpErrorLike extends Error {
|
|
|
877
961
|
}
|
|
878
962
|
//#endregion
|
|
879
963
|
//#region ../alepha/src/server/providers/BunHttpServerProvider.d.ts
|
|
880
|
-
declare const envSchema$
|
|
881
|
-
SERVER_PORT:
|
|
882
|
-
SERVER_HOST:
|
|
964
|
+
declare const envSchema$1: alepha53.TObject<{
|
|
965
|
+
SERVER_PORT: alepha53.TInteger;
|
|
966
|
+
SERVER_HOST: alepha53.TString;
|
|
883
967
|
}>;
|
|
884
968
|
declare module "alepha" {
|
|
885
|
-
interface Env extends Partial<Static<typeof envSchema$
|
|
969
|
+
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
886
970
|
}
|
|
887
971
|
//#endregion
|
|
888
972
|
//#region ../alepha/src/server/providers/NodeHttpServerProvider.d.ts
|
|
889
|
-
declare const envSchema
|
|
890
|
-
SERVER_PORT:
|
|
891
|
-
SERVER_HOST:
|
|
973
|
+
declare const envSchema: alepha53.TObject<{
|
|
974
|
+
SERVER_PORT: alepha53.TInteger;
|
|
975
|
+
SERVER_HOST: alepha53.TString;
|
|
892
976
|
}>;
|
|
893
977
|
declare module "alepha" {
|
|
894
|
-
interface Env extends Partial<Static<typeof envSchema
|
|
978
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
895
979
|
}
|
|
896
980
|
//#endregion
|
|
897
981
|
//#region ../alepha/src/server/index.d.ts
|
|
@@ -950,831 +1034,11 @@ declare module "alepha" {
|
|
|
950
1034
|
}
|
|
951
1035
|
}
|
|
952
1036
|
//#endregion
|
|
953
|
-
//#region ../alepha/src/server-cache/providers/ServerCacheProvider.d.ts
|
|
954
|
-
declare module "alepha/server" {
|
|
955
|
-
interface ServerRoute {
|
|
956
|
-
/**
|
|
957
|
-
* Enable caching for this route.
|
|
958
|
-
* - If true: enables both store and etag
|
|
959
|
-
* - If object: fine-grained control over store, etag, and cache-control headers
|
|
960
|
-
*
|
|
961
|
-
* @default false
|
|
962
|
-
*/
|
|
963
|
-
cache?: ServerRouteCache;
|
|
964
|
-
}
|
|
965
|
-
interface ActionDescriptor<TConfig extends RequestConfigSchema> {
|
|
966
|
-
invalidate: () => Promise<void>;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
type ServerRouteCache =
|
|
970
|
-
/**
|
|
971
|
-
* If true, enables caching with:
|
|
972
|
-
* - store: true
|
|
973
|
-
* - etag: true
|
|
974
|
-
*/
|
|
975
|
-
boolean
|
|
976
|
-
/**
|
|
977
|
-
* Object configuration for fine-grained cache control.
|
|
978
|
-
*
|
|
979
|
-
* If empty, no caching will be applied.
|
|
980
|
-
*/ | {
|
|
981
|
-
/**
|
|
982
|
-
* If true, enables storing cached responses. (in-memory, Redis, @see alepha/cache for other providers)
|
|
983
|
-
* If a DurationLike is provided, it will be used as the TTL for the cache.
|
|
984
|
-
* If CacheDescriptorOptions is provided, it will be used to configure the cache storage.
|
|
985
|
-
*
|
|
986
|
-
* @default false
|
|
987
|
-
*/
|
|
988
|
-
store?: true | DurationLike | CacheDescriptorOptions;
|
|
989
|
-
/**
|
|
990
|
-
* If true, enables ETag support for the cached responses.
|
|
991
|
-
*/
|
|
992
|
-
etag?: true;
|
|
993
|
-
/**
|
|
994
|
-
* - If true, sets Cache-Control to "public, max-age=300" (5 minutes).
|
|
995
|
-
* - If string, sets Cache-Control to the provided value directly.
|
|
996
|
-
* - If object, configures Cache-Control directives.
|
|
997
|
-
*/
|
|
998
|
-
control?: true
|
|
999
|
-
/**
|
|
1000
|
-
* If string, sets Cache-Control to the provided value directly.
|
|
1001
|
-
*/ | string
|
|
1002
|
-
/**
|
|
1003
|
-
* If object, configures Cache-Control directives.
|
|
1004
|
-
*/ | {
|
|
1005
|
-
/**
|
|
1006
|
-
* Indicates that the response may be cached by any cache.
|
|
1007
|
-
*/
|
|
1008
|
-
public?: boolean;
|
|
1009
|
-
/**
|
|
1010
|
-
* Indicates that the response is intended for a single user and must not be stored by a shared cache.
|
|
1011
|
-
*/
|
|
1012
|
-
private?: boolean;
|
|
1013
|
-
/**
|
|
1014
|
-
* Forces caches to submit the request to the origin server for validation before releasing a cached copy.
|
|
1015
|
-
*/
|
|
1016
|
-
noCache?: boolean;
|
|
1017
|
-
/**
|
|
1018
|
-
* Instructs caches not to store the response.
|
|
1019
|
-
*/
|
|
1020
|
-
noStore?: boolean;
|
|
1021
|
-
/**
|
|
1022
|
-
* Maximum amount of time a resource is considered fresh.
|
|
1023
|
-
* Can be specified as a number (seconds) or as a DurationLike object.
|
|
1024
|
-
*
|
|
1025
|
-
* @example 300 // 5 minutes in seconds
|
|
1026
|
-
* @example { minutes: 5 } // 5 minutes
|
|
1027
|
-
* @example { hours: 1 } // 1 hour
|
|
1028
|
-
*/
|
|
1029
|
-
maxAge?: number | DurationLike;
|
|
1030
|
-
/**
|
|
1031
|
-
* Overrides max-age for shared caches (e.g., CDNs).
|
|
1032
|
-
* Can be specified as a number (seconds) or as a DurationLike object.
|
|
1033
|
-
*/
|
|
1034
|
-
sMaxAge?: number | DurationLike;
|
|
1035
|
-
/**
|
|
1036
|
-
* Indicates that once a resource becomes stale, caches must not use it without successful validation.
|
|
1037
|
-
*/
|
|
1038
|
-
mustRevalidate?: boolean;
|
|
1039
|
-
/**
|
|
1040
|
-
* Similar to must-revalidate, but only for shared caches.
|
|
1041
|
-
*/
|
|
1042
|
-
proxyRevalidate?: boolean;
|
|
1043
|
-
/**
|
|
1044
|
-
* Indicates that the response can be stored but must be revalidated before each use.
|
|
1045
|
-
*/
|
|
1046
|
-
immutable?: boolean;
|
|
1047
|
-
};
|
|
1048
|
-
};
|
|
1049
|
-
//#endregion
|
|
1050
|
-
//#region src/core/components/ClientOnly.d.ts
|
|
1051
|
-
interface ClientOnlyProps {
|
|
1052
|
-
fallback?: ReactNode;
|
|
1053
|
-
disabled?: boolean;
|
|
1054
|
-
}
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region src/core/errors/Redirection.d.ts
|
|
1057
|
-
/**
|
|
1058
|
-
* Used for Redirection during the page loading.
|
|
1059
|
-
*
|
|
1060
|
-
* Depends on the context, it can be thrown or just returned.
|
|
1061
|
-
*/
|
|
1062
|
-
declare class Redirection extends Error {
|
|
1063
|
-
readonly redirect: string;
|
|
1064
|
-
constructor(redirect: string);
|
|
1065
|
-
}
|
|
1066
|
-
//#endregion
|
|
1067
|
-
//#region src/core/providers/ReactPageProvider.d.ts
|
|
1068
|
-
declare const envSchema$3: alepha93.TObject<{
|
|
1069
|
-
REACT_STRICT_MODE: alepha93.TBoolean;
|
|
1070
|
-
}>;
|
|
1071
|
-
declare module "alepha" {
|
|
1072
|
-
interface Env extends Partial<Static<typeof envSchema$3>> {}
|
|
1073
|
-
}
|
|
1074
|
-
interface PageRouteEntry extends Omit<PageDescriptorOptions, "children" | "parent"> {
|
|
1075
|
-
children?: PageRouteEntry[];
|
|
1076
|
-
}
|
|
1077
|
-
interface PageRoute extends PageRouteEntry {
|
|
1078
|
-
type: "page";
|
|
1079
|
-
name: string;
|
|
1080
|
-
parent?: PageRoute;
|
|
1081
|
-
match: string;
|
|
1082
|
-
}
|
|
1083
|
-
interface Layer {
|
|
1084
|
-
config?: {
|
|
1085
|
-
query?: Record<string, any>;
|
|
1086
|
-
params?: Record<string, any>;
|
|
1087
|
-
context?: Record<string, any>;
|
|
1088
|
-
};
|
|
1089
|
-
name: string;
|
|
1090
|
-
props?: Record<string, any>;
|
|
1091
|
-
error?: Error;
|
|
1092
|
-
part?: string;
|
|
1093
|
-
element: ReactNode;
|
|
1094
|
-
index: number;
|
|
1095
|
-
path: string;
|
|
1096
|
-
route?: PageRoute;
|
|
1097
|
-
cache?: boolean;
|
|
1098
|
-
}
|
|
1099
|
-
type PreviousLayerData = Omit<Layer, "element" | "index" | "path">;
|
|
1100
|
-
interface ReactRouterState {
|
|
1101
|
-
/**
|
|
1102
|
-
* Stack of layers for the current page.
|
|
1103
|
-
*/
|
|
1104
|
-
layers: Array<Layer>;
|
|
1105
|
-
/**
|
|
1106
|
-
* URL of the current page.
|
|
1107
|
-
*/
|
|
1108
|
-
url: URL;
|
|
1109
|
-
/**
|
|
1110
|
-
* Error handler for the current page.
|
|
1111
|
-
*/
|
|
1112
|
-
onError: ErrorHandler;
|
|
1113
|
-
/**
|
|
1114
|
-
* Params extracted from the URL for the current page.
|
|
1115
|
-
*/
|
|
1116
|
-
params: Record<string, any>;
|
|
1117
|
-
/**
|
|
1118
|
-
* Query parameters extracted from the URL for the current page.
|
|
1119
|
-
*/
|
|
1120
|
-
query: Record<string, string>;
|
|
1121
|
-
/**
|
|
1122
|
-
* Optional meta information associated with the current page.
|
|
1123
|
-
*/
|
|
1124
|
-
meta: Record<string, any>;
|
|
1125
|
-
}
|
|
1126
|
-
//#endregion
|
|
1127
|
-
//#region src/core/services/ReactPageService.d.ts
|
|
1128
|
-
declare class ReactPageService {
|
|
1129
|
-
fetch(pathname: string, options?: PageDescriptorRenderOptions): Promise<{
|
|
1130
|
-
html: string;
|
|
1131
|
-
response: Response;
|
|
1132
|
-
}>;
|
|
1133
|
-
render(name: string, options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
|
|
1134
|
-
}
|
|
1135
|
-
//#endregion
|
|
1136
|
-
//#region src/core/descriptors/$page.d.ts
|
|
1137
|
-
interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
1138
|
-
/**
|
|
1139
|
-
* Identifier name for the page. Must be unique.
|
|
1140
|
-
*
|
|
1141
|
-
* @default Descriptor key
|
|
1142
|
-
*/
|
|
1143
|
-
name?: string;
|
|
1144
|
-
/**
|
|
1145
|
-
* Add a pathname to the page.
|
|
1146
|
-
*
|
|
1147
|
-
* Pathname can contain parameters, like `/post/:slug`.
|
|
1148
|
-
*
|
|
1149
|
-
* @default ""
|
|
1150
|
-
*/
|
|
1151
|
-
path?: string;
|
|
1152
|
-
/**
|
|
1153
|
-
* Add an input schema to define:
|
|
1154
|
-
* - `params`: parameters from the pathname.
|
|
1155
|
-
* - `query`: query parameters from the URL.
|
|
1156
|
-
*/
|
|
1157
|
-
schema?: TConfig;
|
|
1158
|
-
/**
|
|
1159
|
-
* Load data before rendering the page.
|
|
1160
|
-
*
|
|
1161
|
-
* This function receives
|
|
1162
|
-
* - the request context and
|
|
1163
|
-
* - the parent props (if page has a parent)
|
|
1164
|
-
*
|
|
1165
|
-
* In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
|
|
1166
|
-
*
|
|
1167
|
-
* Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.
|
|
1168
|
-
* It's common to throw a `NotFoundError` to display a 404 page.
|
|
1169
|
-
*
|
|
1170
|
-
* RedirectError can be thrown to redirect the user to another page.
|
|
1171
|
-
*/
|
|
1172
|
-
resolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
|
|
1173
|
-
/**
|
|
1174
|
-
* The component to render when the page is loaded.
|
|
1175
|
-
*
|
|
1176
|
-
* If `lazy` is defined, this will be ignored.
|
|
1177
|
-
* Prefer using `lazy` to improve the initial loading time.
|
|
1178
|
-
*/
|
|
1179
|
-
component?: FC<TProps & TPropsParent>;
|
|
1180
|
-
/**
|
|
1181
|
-
* Lazy load the component when the page is loaded.
|
|
1182
|
-
*
|
|
1183
|
-
* It's recommended to use this for components to improve the initial loading time
|
|
1184
|
-
* and enable code-splitting.
|
|
1185
|
-
*/
|
|
1186
|
-
lazy?: () => Promise<{
|
|
1187
|
-
default: FC<TProps & TPropsParent>;
|
|
1188
|
-
}>;
|
|
1189
|
-
/**
|
|
1190
|
-
* Attach child pages to create nested routes.
|
|
1191
|
-
* This will make the page a parent route.
|
|
1192
|
-
*/
|
|
1193
|
-
children?: Array<PageDescriptor> | (() => Array<PageDescriptor>);
|
|
1194
|
-
/**
|
|
1195
|
-
* Define a parent page for nested routing.
|
|
1196
|
-
*/
|
|
1197
|
-
parent?: PageDescriptor<PageConfigSchema, TPropsParent, any>;
|
|
1198
|
-
can?: () => boolean;
|
|
1199
|
-
/**
|
|
1200
|
-
* Catch any error from the `resolve` function or during `rendering`.
|
|
1201
|
-
*
|
|
1202
|
-
* Expected to return one of the following:
|
|
1203
|
-
* - a ReactNode to render an error page
|
|
1204
|
-
* - a Redirection to redirect the user
|
|
1205
|
-
* - undefined to let the error propagate
|
|
1206
|
-
*
|
|
1207
|
-
* If not defined, the error will be thrown and handled by the server or client error handler.
|
|
1208
|
-
* If a leaf $page does not define an error handler, the error can be caught by parent pages.
|
|
1209
|
-
*
|
|
1210
|
-
* @example Catch a 404 from API and render a custom not found component:
|
|
1211
|
-
* ```ts
|
|
1212
|
-
* resolve: async ({ params, query }) => {
|
|
1213
|
-
* api.fetch("/api/resource", { params, query });
|
|
1214
|
-
* },
|
|
1215
|
-
* errorHandler: (error, context) => {
|
|
1216
|
-
* if (HttpError.is(error, 404)) {
|
|
1217
|
-
* return <ResourceNotFound />;
|
|
1218
|
-
* }
|
|
1219
|
-
* }
|
|
1220
|
-
* ```
|
|
1221
|
-
*
|
|
1222
|
-
* @example Catch an 401 error and redirect the user to the login page:
|
|
1223
|
-
* ```ts
|
|
1224
|
-
* resolve: async ({ params, query }) => {
|
|
1225
|
-
* // but the user is not authenticated
|
|
1226
|
-
* api.fetch("/api/resource", { params, query });
|
|
1227
|
-
* },
|
|
1228
|
-
* errorHandler: (error, context) => {
|
|
1229
|
-
* if (HttpError.is(error, 401)) {
|
|
1230
|
-
* // throwing a Redirection is also valid!
|
|
1231
|
-
* return new Redirection("/login");
|
|
1232
|
-
* }
|
|
1233
|
-
* }
|
|
1234
|
-
* ```
|
|
1235
|
-
*/
|
|
1236
|
-
errorHandler?: ErrorHandler;
|
|
1237
|
-
/**
|
|
1238
|
-
* If true, the page will be considered as a static page, immutable and cacheable.
|
|
1239
|
-
* Replace boolean by an object to define static entries. (e.g. list of params/query)
|
|
1240
|
-
*
|
|
1241
|
-
* Browser-side: it only works with `alepha/vite`, which can pre-render the page at build time.
|
|
1242
|
-
*
|
|
1243
|
-
* Server-side: It will act as timeless cached page. You can use `cache` to configure the cache behavior.
|
|
1244
|
-
*/
|
|
1245
|
-
static?: boolean | {
|
|
1246
|
-
entries?: Array<Partial<PageRequestConfig<TConfig>>>;
|
|
1247
|
-
};
|
|
1248
|
-
cache?: ServerRouteCache;
|
|
1249
|
-
/**
|
|
1250
|
-
* If true, force the page to be rendered only on the client-side (browser).
|
|
1251
|
-
* It uses the `<ClientOnly/>` component to render the page.
|
|
1252
|
-
*/
|
|
1253
|
-
client?: boolean | ClientOnlyProps;
|
|
1254
|
-
/**
|
|
1255
|
-
* Called before the server response is sent to the client. (server only)
|
|
1256
|
-
*/
|
|
1257
|
-
onServerResponse?: (request: ServerRequest) => unknown;
|
|
1258
|
-
/**
|
|
1259
|
-
* Called when user leaves the page. (browser only)
|
|
1260
|
-
*/
|
|
1261
|
-
onLeave?: () => void;
|
|
1262
|
-
/**
|
|
1263
|
-
* @experimental
|
|
1264
|
-
*
|
|
1265
|
-
* Add a css animation when the page is loaded or unloaded.
|
|
1266
|
-
* It uses CSS animations, so you need to define the keyframes in your CSS.
|
|
1267
|
-
*
|
|
1268
|
-
* @example Simple animation name
|
|
1269
|
-
* ```ts
|
|
1270
|
-
* animation: "fadeIn"
|
|
1271
|
-
* ```
|
|
1272
|
-
*
|
|
1273
|
-
* CSS example:
|
|
1274
|
-
* ```css
|
|
1275
|
-
* @keyframes fadeIn {
|
|
1276
|
-
* from { opacity: 0; }
|
|
1277
|
-
* to { opacity: 1; }
|
|
1278
|
-
* }
|
|
1279
|
-
* ```
|
|
1280
|
-
*
|
|
1281
|
-
* @example Detailed animation
|
|
1282
|
-
* ```ts
|
|
1283
|
-
* animation: {
|
|
1284
|
-
* enter: { name: "fadeIn", duration: 300 },
|
|
1285
|
-
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
1286
|
-
* }
|
|
1287
|
-
* ```
|
|
1288
|
-
*
|
|
1289
|
-
* @example Only exit animation
|
|
1290
|
-
* ```ts
|
|
1291
|
-
* animation: {
|
|
1292
|
-
* exit: "fadeOut"
|
|
1293
|
-
* }
|
|
1294
|
-
* ```
|
|
1295
|
-
*
|
|
1296
|
-
* @example With custom timing function
|
|
1297
|
-
* ```ts
|
|
1298
|
-
* animation: {
|
|
1299
|
-
* enter: { name: "fadeIn", duration: 300, timing: "cubic-bezier(0.4, 0, 0.2, 1)" },
|
|
1300
|
-
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
1301
|
-
* }
|
|
1302
|
-
* ```
|
|
1303
|
-
*/
|
|
1304
|
-
animation?: PageAnimation;
|
|
1305
|
-
}
|
|
1306
|
-
type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
|
|
1307
|
-
declare class PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {
|
|
1308
|
-
protected readonly reactPageService: ReactPageService;
|
|
1309
|
-
protected onInit(): void;
|
|
1310
|
-
get name(): string;
|
|
1311
|
-
/**
|
|
1312
|
-
* For testing or build purposes.
|
|
1313
|
-
*
|
|
1314
|
-
* This will render the page (HTML layout included or not) and return the HTML + context.
|
|
1315
|
-
* Only valid for server-side rendering, it will throw an error if called on the client-side.
|
|
1316
|
-
*/
|
|
1317
|
-
render(options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
|
|
1318
|
-
fetch(options?: PageDescriptorRenderOptions): Promise<{
|
|
1319
|
-
html: string;
|
|
1320
|
-
response: Response;
|
|
1321
|
-
}>;
|
|
1322
|
-
match(url: string): boolean;
|
|
1323
|
-
pathname(config: any): string;
|
|
1324
|
-
}
|
|
1325
|
-
interface PageConfigSchema {
|
|
1326
|
-
query?: TSchema;
|
|
1327
|
-
params?: TSchema;
|
|
1328
|
-
}
|
|
1329
|
-
type TPropsDefault = any;
|
|
1330
|
-
type TPropsParentDefault = {};
|
|
1331
|
-
interface PageDescriptorRenderOptions {
|
|
1332
|
-
params?: Record<string, string>;
|
|
1333
|
-
query?: Record<string, string>;
|
|
1334
|
-
/**
|
|
1335
|
-
* If true, the HTML layout will be included in the response.
|
|
1336
|
-
* If false, only the page content will be returned.
|
|
1337
|
-
*
|
|
1338
|
-
* @default true
|
|
1339
|
-
*/
|
|
1340
|
-
html?: boolean;
|
|
1341
|
-
hydration?: boolean;
|
|
1342
|
-
}
|
|
1343
|
-
interface PageDescriptorRenderResult {
|
|
1344
|
-
html: string;
|
|
1345
|
-
state: ReactRouterState;
|
|
1346
|
-
redirect?: string;
|
|
1347
|
-
}
|
|
1348
|
-
interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
|
|
1349
|
-
params: TConfig["params"] extends TSchema ? Static<TConfig["params"]> : Record<string, string>;
|
|
1350
|
-
query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
|
|
1351
|
-
}
|
|
1352
|
-
type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & Omit<ReactRouterState, "layers" | "onError">;
|
|
1353
|
-
type PageAnimation = PageAnimationObject | ((state: ReactRouterState) => PageAnimationObject | undefined);
|
|
1354
|
-
type PageAnimationObject = CssAnimationName | {
|
|
1355
|
-
enter?: CssAnimation | CssAnimationName;
|
|
1356
|
-
exit?: CssAnimation | CssAnimationName;
|
|
1357
|
-
};
|
|
1358
|
-
type CssAnimationName = string;
|
|
1359
|
-
type CssAnimation = {
|
|
1360
|
-
name: string;
|
|
1361
|
-
duration?: number;
|
|
1362
|
-
timing?: string;
|
|
1363
|
-
};
|
|
1364
|
-
//#endregion
|
|
1365
|
-
//#region ../alepha/src/security/schemas/userAccountInfoSchema.d.ts
|
|
1366
|
-
declare const userAccountInfoSchema: alepha93.TObject<{
|
|
1367
|
-
id: alepha93.TString;
|
|
1368
|
-
name: alepha93.TOptional<alepha93.TString>;
|
|
1369
|
-
email: alepha93.TOptional<alepha93.TString>;
|
|
1370
|
-
username: alepha93.TOptional<alepha93.TString>;
|
|
1371
|
-
picture: alepha93.TOptional<alepha93.TString>;
|
|
1372
|
-
sessionId: alepha93.TOptional<alepha93.TString>;
|
|
1373
|
-
organizations: alepha93.TOptional<alepha93.TArray<alepha93.TString>>;
|
|
1374
|
-
roles: alepha93.TOptional<alepha93.TArray<alepha93.TString>>;
|
|
1375
|
-
}>;
|
|
1376
|
-
type UserAccount = Static<typeof userAccountInfoSchema>;
|
|
1377
|
-
//#endregion
|
|
1378
|
-
//#region ../alepha/src/security/interfaces/UserAccountToken.d.ts
|
|
1379
|
-
/**
|
|
1380
|
-
* Add contextual metadata to a user account info.
|
|
1381
|
-
* E.g. UserAccountToken is a UserAccountInfo during a request.
|
|
1382
|
-
*/
|
|
1383
|
-
interface UserAccountToken extends UserAccount {
|
|
1384
|
-
/**
|
|
1385
|
-
* Access token for the user.
|
|
1386
|
-
*/
|
|
1387
|
-
token?: string;
|
|
1388
|
-
/**
|
|
1389
|
-
* Realm name of the user.
|
|
1390
|
-
*/
|
|
1391
|
-
realm?: string;
|
|
1392
|
-
/**
|
|
1393
|
-
* Is user dedicated to his own resources for this scope ?
|
|
1394
|
-
* Mostly, Admin is false and Customer is true.
|
|
1395
|
-
*/
|
|
1396
|
-
ownership?: string | boolean;
|
|
1397
|
-
}
|
|
1398
|
-
//#endregion
|
|
1399
|
-
//#region ../alepha/src/security/providers/SecurityProvider.d.ts
|
|
1400
|
-
declare const envSchema$2: alepha93.TObject<{
|
|
1401
|
-
APP_SECRET: alepha93.TString;
|
|
1402
|
-
}>;
|
|
1403
|
-
declare module "alepha" {
|
|
1404
|
-
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
1405
|
-
}
|
|
1406
|
-
//#endregion
|
|
1407
|
-
//#region ../alepha/src/security/index.d.ts
|
|
1408
|
-
declare module "alepha" {
|
|
1409
|
-
interface Hooks {
|
|
1410
|
-
"security:user:created": {
|
|
1411
|
-
realm: string;
|
|
1412
|
-
user: UserAccount;
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
/**
|
|
1417
|
-
* Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
|
|
1418
|
-
*
|
|
1419
|
-
* The security module enables building secure applications using descriptors like `$realm`, `$role`, and `$permission`
|
|
1420
|
-
* on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
|
|
1421
|
-
* integration with various authentication providers and user management systems.
|
|
1422
|
-
*
|
|
1423
|
-
* @see {@link $realm}
|
|
1424
|
-
* @see {@link $role}
|
|
1425
|
-
* @see {@link $permission}
|
|
1426
|
-
* @module alepha.security
|
|
1427
|
-
*/
|
|
1428
|
-
//#endregion
|
|
1429
|
-
//#region ../alepha/src/server-security/providers/ServerBasicAuthProvider.d.ts
|
|
1430
|
-
interface BasicAuthOptions {
|
|
1431
|
-
username: string;
|
|
1432
|
-
password: string;
|
|
1433
|
-
}
|
|
1434
|
-
//#endregion
|
|
1435
|
-
//#region ../alepha/src/server-security/providers/ServerSecurityProvider.d.ts
|
|
1436
|
-
type ServerRouteSecure = {
|
|
1437
|
-
realm?: string;
|
|
1438
|
-
basic?: BasicAuthOptions;
|
|
1439
|
-
};
|
|
1440
|
-
//#endregion
|
|
1441
|
-
//#region ../alepha/src/server-security/index.d.ts
|
|
1442
|
-
declare module "alepha" {
|
|
1443
|
-
interface State {
|
|
1444
|
-
/**
|
|
1445
|
-
* Real (or fake) user account, used for internal actions.
|
|
1446
|
-
*
|
|
1447
|
-
* If you define this, you assume that all actions are executed by this user by default.
|
|
1448
|
-
* > To force a different user, you need to pass it explicitly in the options.
|
|
1449
|
-
*/
|
|
1450
|
-
"alepha.server.security.system.user"?: UserAccountToken;
|
|
1451
|
-
/**
|
|
1452
|
-
* The authenticated user account attached to the server request state.
|
|
1453
|
-
*
|
|
1454
|
-
* @internal
|
|
1455
|
-
*/
|
|
1456
|
-
"alepha.server.request.user"?: UserAccount;
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
declare module "alepha/server" {
|
|
1460
|
-
interface ServerRequest<TConfig> {
|
|
1461
|
-
user?: UserAccountToken;
|
|
1462
|
-
}
|
|
1463
|
-
interface ServerActionRequest<TConfig> {
|
|
1464
|
-
user: UserAccountToken;
|
|
1465
|
-
}
|
|
1466
|
-
interface ServerRoute {
|
|
1467
|
-
/**
|
|
1468
|
-
* If true, the route will be protected by the security provider.
|
|
1469
|
-
* All actions are secure by default, but you can disable it for specific actions.
|
|
1470
|
-
*/
|
|
1471
|
-
secure?: boolean | ServerRouteSecure;
|
|
1472
|
-
}
|
|
1473
|
-
interface ClientRequestOptions extends FetchOptions {
|
|
1474
|
-
/**
|
|
1475
|
-
* Forward user from the previous request.
|
|
1476
|
-
* If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
|
|
1477
|
-
* If "context", use the user from the current context (e.g. request).
|
|
1478
|
-
*
|
|
1479
|
-
* @default "system" if provided, else "context" if available.
|
|
1480
|
-
*/
|
|
1481
|
-
user?: UserAccountToken | "system" | "context";
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
|
|
1486
|
-
*
|
|
1487
|
-
* By default, all $action will be guarded by a permission check.
|
|
1488
|
-
*
|
|
1489
|
-
* @see {@link ServerSecurityProvider}
|
|
1490
|
-
* @module alepha.server.security
|
|
1491
|
-
*/
|
|
1492
|
-
//#endregion
|
|
1493
|
-
//#region ../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
|
|
1494
|
-
declare const apiLinksResponseSchema: alepha93.TObject<{
|
|
1495
|
-
prefix: alepha93.TOptional<alepha93.TString>;
|
|
1496
|
-
links: alepha93.TArray<alepha93.TObject<{
|
|
1497
|
-
name: alepha93.TString;
|
|
1498
|
-
group: alepha93.TOptional<alepha93.TString>;
|
|
1499
|
-
path: alepha93.TString;
|
|
1500
|
-
method: alepha93.TOptional<alepha93.TString>;
|
|
1501
|
-
requestBodyType: alepha93.TOptional<alepha93.TString>;
|
|
1502
|
-
service: alepha93.TOptional<alepha93.TString>;
|
|
1503
|
-
}>>;
|
|
1504
|
-
}>;
|
|
1505
|
-
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
1506
|
-
//#endregion
|
|
1507
|
-
//#region ../alepha/src/server-links/index.d.ts
|
|
1508
|
-
declare module "alepha" {
|
|
1509
|
-
interface State {
|
|
1510
|
-
/**
|
|
1511
|
-
* API links attached to the server request state.
|
|
1512
|
-
*
|
|
1513
|
-
* @see {@link ApiLinksResponse}
|
|
1514
|
-
* @internal
|
|
1515
|
-
*/
|
|
1516
|
-
"alepha.server.request.apiLinks"?: ApiLinksResponse;
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
/**
|
|
1520
|
-
* Provides server-side link management and remote capabilities for client-server interactions.
|
|
1521
|
-
*
|
|
1522
|
-
* The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
|
|
1523
|
-
* facilitating seamless API endpoint management and client-server communication. It integrates with server
|
|
1524
|
-
* security features to ensure safe and controlled access to resources.
|
|
1525
|
-
*
|
|
1526
|
-
* @see {@link $remote}
|
|
1527
|
-
* @see {@link $client}
|
|
1528
|
-
* @module alepha.server.links
|
|
1529
|
-
*/
|
|
1530
|
-
//#endregion
|
|
1531
|
-
//#region src/core/providers/ReactBrowserProvider.d.ts
|
|
1532
|
-
declare const envSchema$1: alepha93.TObject<{
|
|
1533
|
-
REACT_ROOT_ID: alepha93.TString;
|
|
1534
|
-
}>;
|
|
1535
|
-
declare module "alepha" {
|
|
1536
|
-
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
1537
|
-
}
|
|
1538
|
-
/**
|
|
1539
|
-
* React browser renderer configuration atom
|
|
1540
|
-
*/
|
|
1541
|
-
declare const reactBrowserOptions: alepha93.Atom<alepha93.TObject<{
|
|
1542
|
-
scrollRestoration: alepha93.TUnsafe<"top" | "manual">;
|
|
1543
|
-
}>, "alepha.react.browser.options">;
|
|
1544
|
-
type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
|
|
1545
|
-
declare module "alepha" {
|
|
1546
|
-
interface State {
|
|
1547
|
-
[reactBrowserOptions.key]: ReactBrowserRendererOptions;
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
type ReactHydrationState = {
|
|
1551
|
-
layers?: Array<PreviousLayerData>;
|
|
1552
|
-
} & {
|
|
1553
|
-
[key: string]: any;
|
|
1554
|
-
};
|
|
1555
|
-
//#endregion
|
|
1556
|
-
//#region src/core/providers/ReactServerProvider.d.ts
|
|
1557
|
-
declare const envSchema: alepha93.TObject<{
|
|
1558
|
-
REACT_SSR_ENABLED: alepha93.TOptional<alepha93.TBoolean>;
|
|
1559
|
-
REACT_ROOT_ID: alepha93.TString;
|
|
1560
|
-
REACT_SERVER_TEMPLATE: alepha93.TOptional<alepha93.TString>;
|
|
1561
|
-
}>;
|
|
1562
|
-
declare module "alepha" {
|
|
1563
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1564
|
-
interface State {
|
|
1565
|
-
"alepha.react.server.ssr"?: boolean;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* React server provider configuration atom
|
|
1570
|
-
*/
|
|
1571
|
-
declare const reactServerOptions: alepha93.Atom<alepha93.TObject<{
|
|
1572
|
-
publicDir: alepha93.TString;
|
|
1573
|
-
staticServer: alepha93.TObject<{
|
|
1574
|
-
disabled: alepha93.TBoolean;
|
|
1575
|
-
path: alepha93.TString;
|
|
1576
|
-
}>;
|
|
1577
|
-
}>, "alepha.react.server.options">;
|
|
1578
|
-
type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
|
|
1579
|
-
declare module "alepha" {
|
|
1580
|
-
interface State {
|
|
1581
|
-
[reactServerOptions.key]: ReactServerProviderOptions;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
//#endregion
|
|
1585
|
-
//#region src/core/index.d.ts
|
|
1586
|
-
declare module "alepha" {
|
|
1587
|
-
interface State {
|
|
1588
|
-
"alepha.react.router.state"?: ReactRouterState;
|
|
1589
|
-
}
|
|
1590
|
-
interface Hooks {
|
|
1591
|
-
/**
|
|
1592
|
-
* Fires when the React application is starting to be rendered on the server.
|
|
1593
|
-
*/
|
|
1594
|
-
"react:server:render:begin": {
|
|
1595
|
-
request?: ServerRequest;
|
|
1596
|
-
state: ReactRouterState;
|
|
1597
|
-
};
|
|
1598
|
-
/**
|
|
1599
|
-
* Fires when the React application has been rendered on the server.
|
|
1600
|
-
*/
|
|
1601
|
-
"react:server:render:end": {
|
|
1602
|
-
request?: ServerRequest;
|
|
1603
|
-
state: ReactRouterState;
|
|
1604
|
-
html: string;
|
|
1605
|
-
};
|
|
1606
|
-
/**
|
|
1607
|
-
* Fires when the React application is being rendered on the browser.
|
|
1608
|
-
*/
|
|
1609
|
-
"react:browser:render": {
|
|
1610
|
-
root: HTMLElement;
|
|
1611
|
-
element: ReactNode;
|
|
1612
|
-
state: ReactRouterState;
|
|
1613
|
-
hydration?: ReactHydrationState;
|
|
1614
|
-
};
|
|
1615
|
-
/**
|
|
1616
|
-
* Fires when a user action is starting.
|
|
1617
|
-
* Action can be a form submission, a route transition, or a custom action.
|
|
1618
|
-
*/
|
|
1619
|
-
"react:action:begin": {
|
|
1620
|
-
type: string;
|
|
1621
|
-
id?: string;
|
|
1622
|
-
};
|
|
1623
|
-
/**
|
|
1624
|
-
* Fires when a user action has succeeded.
|
|
1625
|
-
* Action can be a form submission, a route transition, or a custom action.
|
|
1626
|
-
*/
|
|
1627
|
-
"react:action:success": {
|
|
1628
|
-
type: string;
|
|
1629
|
-
id?: string;
|
|
1630
|
-
};
|
|
1631
|
-
/**
|
|
1632
|
-
* Fires when a user action has failed.
|
|
1633
|
-
* Action can be a form submission, a route transition, or a custom action.
|
|
1634
|
-
*/
|
|
1635
|
-
"react:action:error": {
|
|
1636
|
-
type: string;
|
|
1637
|
-
id?: string;
|
|
1638
|
-
error: Error;
|
|
1639
|
-
};
|
|
1640
|
-
/**
|
|
1641
|
-
* Fires when a user action has completed, regardless of success or failure.
|
|
1642
|
-
* Action can be a form submission, a route transition, or a custom action.
|
|
1643
|
-
*/
|
|
1644
|
-
"react:action:end": {
|
|
1645
|
-
type: string;
|
|
1646
|
-
id?: string;
|
|
1647
|
-
};
|
|
1648
|
-
/**
|
|
1649
|
-
* Fires when a route transition is starting.
|
|
1650
|
-
*/
|
|
1651
|
-
"react:transition:begin": {
|
|
1652
|
-
previous: ReactRouterState;
|
|
1653
|
-
state: ReactRouterState;
|
|
1654
|
-
animation?: PageAnimation;
|
|
1655
|
-
};
|
|
1656
|
-
/**
|
|
1657
|
-
* Fires when a route transition has succeeded.
|
|
1658
|
-
*/
|
|
1659
|
-
"react:transition:success": {
|
|
1660
|
-
state: ReactRouterState;
|
|
1661
|
-
};
|
|
1662
|
-
/**
|
|
1663
|
-
* Fires when a route transition has failed.
|
|
1664
|
-
*/
|
|
1665
|
-
"react:transition:error": {
|
|
1666
|
-
state: ReactRouterState;
|
|
1667
|
-
error: Error;
|
|
1668
|
-
};
|
|
1669
|
-
/**
|
|
1670
|
-
* Fires when a route transition has completed, regardless of success or failure.
|
|
1671
|
-
*/
|
|
1672
|
-
"react:transition:end": {
|
|
1673
|
-
state: ReactRouterState;
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.
|
|
1679
|
-
*
|
|
1680
|
-
* The React module enables building modern React applications using the `$page` descriptor on class properties.
|
|
1681
|
-
* It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full
|
|
1682
|
-
* type safety and schema validation for route parameters and data.
|
|
1683
|
-
*
|
|
1684
|
-
* @see {@link $page}
|
|
1685
|
-
* @module alepha.react
|
|
1686
|
-
*/
|
|
1687
|
-
//#endregion
|
|
1688
|
-
//#region src/head/interfaces/Head.d.ts
|
|
1689
|
-
interface Head extends SimpleHead {
|
|
1690
|
-
description?: string;
|
|
1691
|
-
keywords?: string[];
|
|
1692
|
-
author?: string;
|
|
1693
|
-
robots?: string;
|
|
1694
|
-
themeColor?: string;
|
|
1695
|
-
viewport?: string | {
|
|
1696
|
-
width?: string;
|
|
1697
|
-
height?: string;
|
|
1698
|
-
initialScale?: string;
|
|
1699
|
-
maximumScale?: string;
|
|
1700
|
-
userScalable?: "no" | "yes" | "0" | "1";
|
|
1701
|
-
interactiveWidget?: "resizes-visual" | "resizes-content" | "overlays-content";
|
|
1702
|
-
};
|
|
1703
|
-
og?: {
|
|
1704
|
-
title?: string;
|
|
1705
|
-
description?: string;
|
|
1706
|
-
image?: string;
|
|
1707
|
-
url?: string;
|
|
1708
|
-
type?: string;
|
|
1709
|
-
};
|
|
1710
|
-
twitter?: {
|
|
1711
|
-
card?: string;
|
|
1712
|
-
title?: string;
|
|
1713
|
-
description?: string;
|
|
1714
|
-
image?: string;
|
|
1715
|
-
site?: string;
|
|
1716
|
-
};
|
|
1717
|
-
}
|
|
1718
|
-
interface SimpleHead {
|
|
1719
|
-
title?: string;
|
|
1720
|
-
titleSeparator?: string;
|
|
1721
|
-
htmlAttributes?: Record<string, string>;
|
|
1722
|
-
bodyAttributes?: Record<string, string>;
|
|
1723
|
-
meta?: Array<{
|
|
1724
|
-
name: string;
|
|
1725
|
-
content: string;
|
|
1726
|
-
}>;
|
|
1727
|
-
}
|
|
1728
|
-
//#endregion
|
|
1729
|
-
//#region src/head/providers/HeadProvider.d.ts
|
|
1730
|
-
declare class HeadProvider {
|
|
1731
|
-
global?: Head | (() => Head);
|
|
1732
|
-
protected getGlobalHead(): Head | undefined;
|
|
1733
|
-
fillHead(state: ReactRouterState): void;
|
|
1734
|
-
protected fillHeadByPage(page: PageRoute, state: ReactRouterState, props: Record<string, any>): void;
|
|
1735
|
-
}
|
|
1736
|
-
//#endregion
|
|
1737
|
-
//#region src/head/descriptors/$head.d.ts
|
|
1738
|
-
/**
|
|
1739
|
-
* Set global `<head>` options for the application.
|
|
1740
|
-
*/
|
|
1741
|
-
declare const $head: {
|
|
1742
|
-
(options: HeadDescriptorOptions): HeadDescriptor;
|
|
1743
|
-
[KIND]: typeof HeadDescriptor;
|
|
1744
|
-
};
|
|
1745
|
-
type HeadDescriptorOptions = Head | (() => Head);
|
|
1746
|
-
declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
|
|
1747
|
-
protected readonly provider: HeadProvider;
|
|
1748
|
-
protected onInit(): void;
|
|
1749
|
-
}
|
|
1750
|
-
//#endregion
|
|
1751
|
-
//#region src/head/hooks/useHead.d.ts
|
|
1752
|
-
/**
|
|
1753
|
-
* ```tsx
|
|
1754
|
-
* const App = () => {
|
|
1755
|
-
* const [head, setHead] = useHead({
|
|
1756
|
-
* // will set the document title on the first render
|
|
1757
|
-
* title: "My App",
|
|
1758
|
-
* });
|
|
1759
|
-
*
|
|
1760
|
-
* return (
|
|
1761
|
-
* // This will update the document title when the button is clicked
|
|
1762
|
-
* <button onClick={() => setHead({ title: "Change Title" })}>
|
|
1763
|
-
* Change Title {head.title}
|
|
1764
|
-
* </button>
|
|
1765
|
-
* );
|
|
1766
|
-
* }
|
|
1767
|
-
* ```
|
|
1768
|
-
*/
|
|
1769
|
-
declare const useHead: (options?: UseHeadOptions) => UseHeadReturn;
|
|
1770
|
-
type UseHeadOptions = Head | ((previous?: Head) => Head);
|
|
1771
|
-
type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void];
|
|
1772
|
-
//#endregion
|
|
1773
1037
|
//#region src/head/providers/ServerHeadProvider.d.ts
|
|
1774
1038
|
declare class ServerHeadProvider {
|
|
1775
1039
|
protected readonly headProvider: HeadProvider;
|
|
1776
1040
|
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
1777
|
-
protected readonly onServerRenderEnd:
|
|
1041
|
+
protected readonly onServerRenderEnd: alepha53.HookDescriptor<"react:server:render:end">;
|
|
1778
1042
|
renderHead(template: string, head: SimpleHead): string;
|
|
1779
1043
|
protected mergeAttributes(existing: string, attrs: Record<string, string>): string;
|
|
1780
1044
|
protected parseAttributes(attrStr: string): Record<string, string>;
|
|
@@ -1796,7 +1060,7 @@ declare module "@alepha/react" {
|
|
|
1796
1060
|
* @see {@link ServerHeadProvider}
|
|
1797
1061
|
* @module alepha.react.head
|
|
1798
1062
|
*/
|
|
1799
|
-
declare const AlephaReactHead:
|
|
1063
|
+
declare const AlephaReactHead: alepha53.Service<alepha53.Module>;
|
|
1800
1064
|
//#endregion
|
|
1801
1065
|
export { $head, AlephaReactHead, Head, HeadDescriptor, HeadDescriptorOptions, ServerHeadProvider, SimpleHead, UseHeadOptions, UseHeadReturn, useHead };
|
|
1802
1066
|
//# sourceMappingURL=index.d.ts.map
|