@alepha/ui 0.11.12 → 0.12.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/README.md +2 -30
- package/dist/admin/AdminFiles-BM6_7_5A.cjs +4 -0
- package/dist/admin/AdminFiles-BaCIMeNt.js +4 -0
- package/dist/admin/AdminFiles-CllAxb1B.js +117 -0
- package/dist/admin/AdminFiles-CllAxb1B.js.map +1 -0
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs +122 -0
- package/dist/admin/AdminFiles-DC3T8uWZ.cjs.map +1 -0
- package/dist/admin/AdminJobs-BXkFtlVo.js +125 -0
- package/dist/admin/AdminJobs-BXkFtlVo.js.map +1 -0
- package/dist/admin/AdminJobs-C428qrNQ.cjs +130 -0
- package/dist/admin/AdminJobs-C428qrNQ.cjs.map +1 -0
- package/dist/admin/AdminJobs-DCPPaJ4i.cjs +4 -0
- package/dist/admin/AdminJobs-yC6DarGO.js +4 -0
- package/dist/admin/AdminLayout-Bqo4cd33.cjs +4 -0
- package/dist/admin/AdminLayout-CQpxfko6.js +4 -0
- package/dist/admin/AdminLayout-CiLlywAQ.cjs +93 -0
- package/dist/admin/AdminLayout-CiLlywAQ.cjs.map +1 -0
- package/dist/admin/AdminLayout-CtkVYk-u.js +88 -0
- package/dist/admin/AdminLayout-CtkVYk-u.js.map +1 -0
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs +44 -0
- package/dist/admin/AdminNotifications-DNUeJ-PW.cjs.map +1 -0
- package/dist/admin/AdminNotifications-DaMu1AQ4.js +4 -0
- package/dist/admin/AdminNotifications-DnnulNNV.js +40 -0
- package/dist/admin/AdminNotifications-DnnulNNV.js.map +1 -0
- package/dist/admin/AdminNotifications-ihgbKVCx.cjs +4 -0
- package/dist/admin/AdminParameters-B3hvpLpu.js +40 -0
- package/dist/admin/AdminParameters-B3hvpLpu.js.map +1 -0
- package/dist/admin/AdminParameters-U4lU1rUF.cjs +4 -0
- package/dist/admin/AdminParameters-gdf7036N.cjs +44 -0
- package/dist/admin/AdminParameters-gdf7036N.cjs.map +1 -0
- package/dist/admin/AdminParameters-prMcCgxf.js +4 -0
- package/dist/admin/AdminSessions-BF_P4lHs.cjs +128 -0
- package/dist/admin/AdminSessions-BF_P4lHs.cjs.map +1 -0
- package/dist/admin/AdminSessions-CATIU61I.cjs +4 -0
- package/dist/admin/AdminSessions-DqOXOpYR.js +4 -0
- package/dist/admin/AdminSessions-Pjdz-iZx.js +123 -0
- package/dist/admin/AdminSessions-Pjdz-iZx.js.map +1 -0
- package/dist/admin/AdminUsers-BgTL-zSY.js +4 -0
- package/dist/admin/AdminUsers-C1HsrRxn.js +104 -0
- package/dist/admin/AdminUsers-C1HsrRxn.js.map +1 -0
- package/dist/admin/AdminUsers-HqvxwNGZ.cjs +4 -0
- package/dist/admin/AdminUsers-M2uEQbp5.cjs +109 -0
- package/dist/admin/AdminUsers-M2uEQbp5.cjs.map +1 -0
- package/dist/admin/AdminVerifications-BVssbtfU.cjs +44 -0
- package/dist/admin/AdminVerifications-BVssbtfU.cjs.map +1 -0
- package/dist/admin/AdminVerifications-Df6DRgNo.js +4 -0
- package/dist/admin/AdminVerifications-DxAtcYUR.cjs +4 -0
- package/dist/admin/AdminVerifications-VMpm30mS.js +40 -0
- package/dist/admin/AdminVerifications-VMpm30mS.js.map +1 -0
- package/dist/admin/core-CzO6aavT.js +2507 -0
- package/dist/admin/core-CzO6aavT.js.map +1 -0
- package/dist/{index.cjs → admin/core-aFtK4l9I.cjs} +287 -204
- package/dist/admin/core-aFtK4l9I.cjs.map +1 -0
- package/dist/admin/index.cjs +87 -0
- package/dist/admin/index.cjs.map +1 -0
- package/dist/admin/index.d.cts +1739 -0
- package/dist/admin/index.d.ts +1745 -0
- package/dist/admin/index.js +78 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/auth/IconGoogle-B17BTQyD.cjs +69 -0
- package/dist/auth/IconGoogle-B17BTQyD.cjs.map +1 -0
- package/dist/auth/IconGoogle-Bfmuv9Rv.js +58 -0
- package/dist/auth/IconGoogle-Bfmuv9Rv.js.map +1 -0
- package/dist/auth/Login-BTBmbnWl.cjs +181 -0
- package/dist/auth/Login-BTBmbnWl.cjs.map +1 -0
- package/dist/auth/Login-BcQOtG3v.js +5 -0
- package/dist/auth/Login-Btmd70Um.cjs +5 -0
- package/dist/auth/Login-JeXFsUf5.js +176 -0
- package/dist/auth/Login-JeXFsUf5.js.map +1 -0
- package/dist/auth/Register-CPQnvXCZ.js +318 -0
- package/dist/auth/Register-CPQnvXCZ.js.map +1 -0
- package/dist/auth/Register-CbesZal3.cjs +5 -0
- package/dist/auth/Register-DpI_JdyO.js +5 -0
- package/dist/auth/Register-HP3rP71B.cjs +323 -0
- package/dist/auth/Register-HP3rP71B.cjs.map +1 -0
- package/dist/auth/ResetPassword-B-tkzV7g.cjs +248 -0
- package/dist/auth/ResetPassword-B-tkzV7g.cjs.map +1 -0
- package/dist/auth/ResetPassword-BlK3xEpU.js +4 -0
- package/dist/auth/ResetPassword-BzUjGG_-.js +243 -0
- package/dist/auth/ResetPassword-BzUjGG_-.js.map +1 -0
- package/dist/auth/ResetPassword-W3xjOnWy.cjs +4 -0
- package/dist/auth/chunk-DhGyd7sr.js +28 -0
- package/dist/auth/core-D1MHij1j.js +1795 -0
- package/dist/auth/core-D1MHij1j.js.map +1 -0
- package/dist/auth/core-rDZ9d92K.cjs +1824 -0
- package/dist/auth/core-rDZ9d92K.cjs.map +1 -0
- package/dist/auth/index.cjs +211 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +6265 -0
- package/dist/auth/index.d.ts +6274 -0
- package/dist/auth/index.js +206 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/core/index.cjs +2620 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +2737 -0
- package/dist/core/index.d.ts +2743 -0
- package/dist/{index.js → core/index.js} +298 -126
- package/dist/core/index.js.map +1 -0
- package/package.json +32 -14
- package/src/admin/AdminRouter.ts +58 -0
- package/src/admin/components/AdminFiles.tsx +117 -0
- package/src/admin/components/AdminJobs.tsx +158 -0
- package/src/admin/components/AdminLayout.tsx +114 -0
- package/src/admin/components/AdminNotifications.tsx +20 -0
- package/src/admin/components/AdminParameters.tsx +24 -0
- package/src/admin/components/AdminSessions.tsx +159 -0
- package/src/admin/components/AdminUsers.tsx +137 -0
- package/src/admin/components/AdminVerifications.tsx +25 -0
- package/src/admin/index.ts +29 -0
- package/src/auth/AuthI18n.ts +118 -0
- package/src/auth/AuthRouter.ts +53 -0
- package/src/auth/components/Login.tsx +193 -0
- package/src/auth/components/Register.tsx +421 -0
- package/src/auth/components/ResetPassword.tsx +259 -0
- package/src/auth/components/buttons/UserButton.tsx +118 -0
- package/src/auth/components/icons/IconGithub.tsx +21 -0
- package/src/auth/components/icons/IconGoogle.tsx +30 -0
- package/src/auth/index.ts +27 -0
- package/src/{RootRouter.ts → core/RootRouter.ts} +2 -1
- package/src/{components → core/components}/buttons/ActionButton.tsx +49 -6
- package/src/core/components/buttons/ClipboardButton.tsx +56 -0
- package/src/{components → core/components}/buttons/DarkModeButton.tsx +7 -8
- package/src/{components → core/components}/buttons/LanguageButton.tsx +2 -2
- package/src/{components → core/components}/buttons/OmnibarButton.tsx +1 -1
- package/src/{components → core/components}/dialogs/AlertDialog.tsx +1 -1
- package/src/{components → core/components}/dialogs/ConfirmDialog.tsx +1 -1
- package/src/{components → core/components}/dialogs/PromptDialog.tsx +1 -1
- package/src/{components → core/components}/form/Control.tsx +1 -0
- package/src/{components → core/components}/layout/AdminShell.tsx +38 -7
- package/src/{components → core/components}/layout/AlephaMantineProvider.tsx +12 -8
- package/src/{components → core/components}/layout/AppBar.tsx +1 -1
- package/src/{components → core/components}/layout/Omnibar.tsx +1 -1
- package/src/{components → core/components}/layout/Sidebar.tsx +29 -26
- package/src/{components → core/components}/table/DataTable.tsx +1 -1
- package/src/{constants → core/constants}/ui.ts +9 -0
- package/src/{index.ts → core/index.ts} +3 -0
- package/src/{services → core/services}/DialogService.tsx +3 -3
- package/src/{services → core/services}/ToastService.tsx +3 -1
- package/src/{utils → core/utils}/extractSchemaFields.ts +2 -8
- package/src/{utils → core/utils}/icons.tsx +5 -15
- package/src/{utils → core/utils}/parseInput.ts +34 -26
- package/dist/AlephaMantineProvider-CGpgWDt8.cjs +0 -3
- package/dist/AlephaMantineProvider-D8cHYAge.js +0 -152
- package/dist/AlephaMantineProvider-D8cHYAge.js.map +0 -1
- package/dist/AlephaMantineProvider-DuvZFAuk.cjs +0 -175
- package/dist/AlephaMantineProvider-DuvZFAuk.cjs.map +0 -1
- package/dist/AlephaMantineProvider-twBqV4IO.js +0 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -821
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -821
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- /package/src/{components → core/components}/buttons/BurgerButton.tsx +0 -0
- /package/src/{components → core/components}/buttons/ToggleSidebarButton.tsx +0 -0
- /package/src/{components → core/components}/data/JsonViewer.tsx +0 -0
- /package/src/{components → core/components}/form/ControlDate.tsx +0 -0
- /package/src/{components → core/components}/form/ControlNumber.tsx +0 -0
- /package/src/{components → core/components}/form/ControlQueryBuilder.tsx +0 -0
- /package/src/{components → core/components}/form/ControlSelect.tsx +0 -0
- /package/src/{components → core/components}/form/TypeForm.tsx +0 -0
- /package/src/{hooks → core/hooks}/useDialog.ts +0 -0
- /package/src/{hooks → core/hooks}/useToast.ts +0 -0
- /package/src/{utils → core/utils}/string.ts +0 -0
|
@@ -0,0 +1,2743 @@
|
|
|
1
|
+
import * as alepha79 from "alepha";
|
|
2
|
+
import { Alepha, AlephaError, Async, Descriptor, FileLike, InstantiableClass, LogLevel, LoggerInterface, Page, PageMetadata, Static, StreamLike, TArray, TFile, TObject, TProperties, TRecord, TSchema, TStream, TString, TVoid, TypeBoxError } from "alepha";
|
|
3
|
+
import { AnchorProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarProps, AppShellProps, AutocompleteProps, BurgerProps, ButtonProps, ColorInputProps, ColorSchemeScriptProps, FileInputProps, Flex, FlexProps, MantineBreakpoint, MantineProviderProps, MantineSize, MenuProps, MenuTargetProps, ModalProps, MultiSelectProps, NumberInputProps, PasswordInputProps, SegmentedControlProps, SelectProps, SliderProps, SwitchProps, TableProps, TableTrProps, TagsInputProps, Text, TextInputProps, TextareaProps, ThemeIconProps, TooltipProps } from "@mantine/core";
|
|
4
|
+
import { ModalsProviderProps } from "@mantine/modals";
|
|
5
|
+
import * as _mantine_notifications0 from "@mantine/notifications";
|
|
6
|
+
import { NotificationData, NotificationsProps } from "@mantine/notifications";
|
|
7
|
+
import { NavigationProgressProps } from "@mantine/nprogress";
|
|
8
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
9
|
+
import { ComponentType, FC, InputHTMLAttributes, ReactElement, ReactNode } from "react";
|
|
10
|
+
import { DateInputProps, DateTimePickerProps, TimeInputProps } from "@mantine/dates";
|
|
11
|
+
import "dayjs/plugin/relativeTime.js";
|
|
12
|
+
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
13
|
+
import "dayjs/plugin/utc.js";
|
|
14
|
+
import "dayjs/plugin/timezone.js";
|
|
15
|
+
import "dayjs/plugin/localizedFormat.js";
|
|
16
|
+
import "dayjs/locale/ar.js";
|
|
17
|
+
import "dayjs/locale/fr.js";
|
|
18
|
+
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
19
|
+
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
20
|
+
import { Readable } from "node:stream";
|
|
21
|
+
import { ReadableStream } from "node:stream/web";
|
|
22
|
+
|
|
23
|
+
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
24
|
+
declare const logEntrySchema: alepha79.TObject<{
|
|
25
|
+
level: alepha79.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
26
|
+
message: alepha79.TString;
|
|
27
|
+
service: alepha79.TString;
|
|
28
|
+
module: alepha79.TString;
|
|
29
|
+
context: alepha79.TOptional<alepha79.TString>;
|
|
30
|
+
app: alepha79.TOptional<alepha79.TString>;
|
|
31
|
+
data: alepha79.TOptional<alepha79.TAny>;
|
|
32
|
+
timestamp: alepha79.TNumber;
|
|
33
|
+
}>;
|
|
34
|
+
type LogEntry = Static<typeof logEntrySchema>;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
37
|
+
type DateTime = DayjsApi.Dayjs;
|
|
38
|
+
type Duration = dayjsDuration.Duration;
|
|
39
|
+
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
40
|
+
declare class DateTimeProvider {
|
|
41
|
+
static PLUGINS: Array<PluginFunc<any>>;
|
|
42
|
+
protected alepha: Alepha;
|
|
43
|
+
protected ref: DateTime | null;
|
|
44
|
+
protected readonly timeouts: Timeout[];
|
|
45
|
+
protected readonly intervals: Interval[];
|
|
46
|
+
constructor();
|
|
47
|
+
protected readonly onStart: alepha79.HookDescriptor<"start">;
|
|
48
|
+
protected readonly onStop: alepha79.HookDescriptor<"stop">;
|
|
49
|
+
setLocale(locale: string): void;
|
|
50
|
+
isDateTime(value: unknown): value is DateTime;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new UTC DateTime instance.
|
|
53
|
+
*/
|
|
54
|
+
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new DateTime instance.
|
|
57
|
+
*/
|
|
58
|
+
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
59
|
+
/**
|
|
60
|
+
* Get the current date as a string.
|
|
61
|
+
*/
|
|
62
|
+
toISOString(date?: Date | string | DateTime): string;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current date.
|
|
65
|
+
*/
|
|
66
|
+
now(): DateTime;
|
|
67
|
+
/**
|
|
68
|
+
* Get the current date as a string.
|
|
69
|
+
*
|
|
70
|
+
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
71
|
+
*/
|
|
72
|
+
nowISOString(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get the current date as milliseconds since epoch.
|
|
75
|
+
*
|
|
76
|
+
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
77
|
+
*/
|
|
78
|
+
nowMillis(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Get the current date as a string.
|
|
81
|
+
*
|
|
82
|
+
* @protected
|
|
83
|
+
*/
|
|
84
|
+
protected getCurrentDate(): DateTime;
|
|
85
|
+
/**
|
|
86
|
+
* Create a new Duration instance.
|
|
87
|
+
*/
|
|
88
|
+
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
89
|
+
isDurationLike(value: unknown): value is DurationLike;
|
|
90
|
+
/**
|
|
91
|
+
* Return a promise that resolves after the next tick.
|
|
92
|
+
* It uses `setTimeout` with 0 ms delay.
|
|
93
|
+
*/
|
|
94
|
+
tick(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Wait for a certain duration.
|
|
97
|
+
*
|
|
98
|
+
* You can clear the timeout by using the `AbortSignal` API.
|
|
99
|
+
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
100
|
+
*/
|
|
101
|
+
wait(duration: DurationLike, options?: {
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
now?: number;
|
|
104
|
+
}): Promise<void>;
|
|
105
|
+
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
106
|
+
/**
|
|
107
|
+
* Run a callback after a certain duration.
|
|
108
|
+
*/
|
|
109
|
+
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
110
|
+
clearTimeout(timeout: Timeout): void;
|
|
111
|
+
clearInterval(interval: Interval): void;
|
|
112
|
+
/**
|
|
113
|
+
* Run a function with a deadline.
|
|
114
|
+
*/
|
|
115
|
+
deadline<T$1>(fn: (signal: AbortSignal) => Promise<T$1>, duration: DurationLike): Promise<T$1>;
|
|
116
|
+
/**
|
|
117
|
+
* Add time to the current date.
|
|
118
|
+
*/
|
|
119
|
+
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Stop the time.
|
|
122
|
+
*/
|
|
123
|
+
pause(): DateTime;
|
|
124
|
+
/**
|
|
125
|
+
* Reset the reference date.
|
|
126
|
+
*/
|
|
127
|
+
reset(): void;
|
|
128
|
+
}
|
|
129
|
+
interface Interval {
|
|
130
|
+
timer?: any;
|
|
131
|
+
duration: number;
|
|
132
|
+
run: () => unknown;
|
|
133
|
+
}
|
|
134
|
+
interface Timeout {
|
|
135
|
+
now: number;
|
|
136
|
+
timer?: any;
|
|
137
|
+
duration: number;
|
|
138
|
+
callback: () => void;
|
|
139
|
+
clear: () => void;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
143
|
+
declare abstract class LogDestinationProvider {
|
|
144
|
+
abstract write(message: string, entry: LogEntry): void;
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
148
|
+
declare abstract class LogFormatterProvider {
|
|
149
|
+
abstract format(entry: LogEntry): string;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
153
|
+
declare class Logger implements LoggerInterface {
|
|
154
|
+
protected readonly alepha: Alepha;
|
|
155
|
+
protected readonly formatter: LogFormatterProvider;
|
|
156
|
+
protected readonly destination: LogDestinationProvider;
|
|
157
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
158
|
+
protected readonly levels: Record<string, number>;
|
|
159
|
+
protected readonly service: string;
|
|
160
|
+
protected readonly module: string;
|
|
161
|
+
protected readonly app?: string;
|
|
162
|
+
protected appLogLevel: string;
|
|
163
|
+
protected logLevel: LogLevel;
|
|
164
|
+
constructor(service: string, module: string);
|
|
165
|
+
get context(): string | undefined;
|
|
166
|
+
get level(): string;
|
|
167
|
+
parseLevel(level: string, app: string): LogLevel;
|
|
168
|
+
private matchesPattern;
|
|
169
|
+
asLogLevel(something: string): LogLevel;
|
|
170
|
+
error(message: string, data?: unknown): void;
|
|
171
|
+
warn(message: string, data?: unknown): void;
|
|
172
|
+
info(message: string, data?: unknown): void;
|
|
173
|
+
debug(message: string, data?: unknown): void;
|
|
174
|
+
trace(message: string, data?: unknown): void;
|
|
175
|
+
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
176
|
+
protected emit(entry: LogEntry, message?: string): void;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../alepha/src/logger/index.d.ts
|
|
180
|
+
declare const envSchema$6: alepha79.TObject<{
|
|
181
|
+
/**
|
|
182
|
+
* Default log level for the application.
|
|
183
|
+
*
|
|
184
|
+
* Default by environment:
|
|
185
|
+
* - dev = info
|
|
186
|
+
* - prod = info
|
|
187
|
+
* - test = error
|
|
188
|
+
*
|
|
189
|
+
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
190
|
+
*
|
|
191
|
+
* Level can be set for a specific module:
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
195
|
+
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
196
|
+
*/
|
|
197
|
+
LOG_LEVEL: alepha79.TOptional<alepha79.TString>;
|
|
198
|
+
/**
|
|
199
|
+
* Built-in log formats.
|
|
200
|
+
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
201
|
+
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
202
|
+
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
203
|
+
*/
|
|
204
|
+
LOG_FORMAT: alepha79.TOptional<alepha79.TUnsafe<"json" | "pretty" | "raw">>;
|
|
205
|
+
}>;
|
|
206
|
+
declare module "alepha" {
|
|
207
|
+
interface Env extends Partial<Static<typeof envSchema$6>> {}
|
|
208
|
+
interface State {
|
|
209
|
+
/**
|
|
210
|
+
* Current log level for the application or specific modules.
|
|
211
|
+
*/
|
|
212
|
+
"alepha.logger.level"?: string;
|
|
213
|
+
}
|
|
214
|
+
interface Hooks {
|
|
215
|
+
log: {
|
|
216
|
+
message?: string;
|
|
217
|
+
entry: LogEntry;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region ../react/src/form/services/FormModel.d.ts
|
|
223
|
+
/**
|
|
224
|
+
* FormModel is a dynamic form handler that generates form inputs based on a provided TypeBox schema.
|
|
225
|
+
* It manages form state, handles input changes, and processes form submissions with validation.
|
|
226
|
+
*
|
|
227
|
+
* It means to be injected and used within React components to provide a structured way to create and manage forms.
|
|
228
|
+
*
|
|
229
|
+
* @see {@link useForm}
|
|
230
|
+
*/
|
|
231
|
+
declare class FormModel<T$1 extends TObject> {
|
|
232
|
+
readonly id: string;
|
|
233
|
+
readonly options: FormCtrlOptions<T$1>;
|
|
234
|
+
protected readonly log: Logger;
|
|
235
|
+
protected readonly alepha: Alepha;
|
|
236
|
+
protected readonly values: Record<string, any>;
|
|
237
|
+
protected submitInProgress: boolean;
|
|
238
|
+
input: SchemaToInput<T$1>;
|
|
239
|
+
get submitting(): boolean;
|
|
240
|
+
constructor(id: string, options: FormCtrlOptions<T$1>);
|
|
241
|
+
get element(): HTMLFormElement;
|
|
242
|
+
get currentValues(): Record<string, any>;
|
|
243
|
+
get props(): {
|
|
244
|
+
id: string;
|
|
245
|
+
noValidate: boolean;
|
|
246
|
+
onSubmit: (ev?: FormEventLike) => void;
|
|
247
|
+
onReset: (event: FormEventLike) => Promise<void>;
|
|
248
|
+
};
|
|
249
|
+
readonly reset: (event: FormEventLike) => Promise<void>;
|
|
250
|
+
readonly submit: () => Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Restructures flat keys like "address.city" into nested objects like { address: { city: ... } }
|
|
253
|
+
* Values are already typed from onChange, so no conversion is needed.
|
|
254
|
+
*/
|
|
255
|
+
protected restructureValues(store: Record<string, any>): Record<string, any>;
|
|
256
|
+
/**
|
|
257
|
+
* Helper to restructure a flat key like "address.city" into nested object structure.
|
|
258
|
+
* The value is already typed, so we just assign it to the nested path.
|
|
259
|
+
*/
|
|
260
|
+
protected restructureNestedValue(values: Record<string, any>, key: string, value: any): void;
|
|
261
|
+
protected createProxyFromSchema<T$1 extends TObject>(options: FormCtrlOptions<T$1>, schema: TSchema, context: {
|
|
262
|
+
parent: string;
|
|
263
|
+
store: Record<string, any>;
|
|
264
|
+
}): SchemaToInput<T$1>;
|
|
265
|
+
protected createInputFromSchema<T$1 extends TObject>(name: keyof Static<T$1> & string, options: FormCtrlOptions<T$1>, schema: TObject, required: boolean, context: {
|
|
266
|
+
parent: string;
|
|
267
|
+
store: Record<string, any>;
|
|
268
|
+
}): InputField;
|
|
269
|
+
/**
|
|
270
|
+
* Convert an input value to the correct type based on the schema.
|
|
271
|
+
* Handles raw DOM values (strings, booleans from checkboxes, Files, etc.)
|
|
272
|
+
*/
|
|
273
|
+
protected getValueFromInput(input: any, schema: TSchema): any;
|
|
274
|
+
protected valueToInputEntry(value: any): string | number | boolean;
|
|
275
|
+
}
|
|
276
|
+
type SchemaToInput<T$1 extends TObject> = { [K in keyof T$1["properties"]]: T$1["properties"][K] extends TObject ? SchemaToInput<T$1["properties"][K]> : InputField };
|
|
277
|
+
interface FormEventLike {
|
|
278
|
+
preventDefault?: () => void;
|
|
279
|
+
stopPropagation?: () => void;
|
|
280
|
+
}
|
|
281
|
+
interface InputField {
|
|
282
|
+
path: string;
|
|
283
|
+
required: boolean;
|
|
284
|
+
props: InputHTMLAttributesLike;
|
|
285
|
+
schema: TSchema;
|
|
286
|
+
set: (value: any) => void;
|
|
287
|
+
form: FormModel<any>;
|
|
288
|
+
}
|
|
289
|
+
type InputHTMLAttributesLike = Pick<InputHTMLAttributes<unknown>, "id" | "name" | "type" | "value" | "defaultValue" | "required" | "maxLength" | "minLength" | "aria-label" | "autoComplete"> & {
|
|
290
|
+
value?: any;
|
|
291
|
+
defaultValue?: any;
|
|
292
|
+
onChange?: (event: any) => void;
|
|
293
|
+
};
|
|
294
|
+
type FormCtrlOptions<T$1 extends TObject> = {
|
|
295
|
+
/**
|
|
296
|
+
* The schema defining the structure and validation rules for the form.
|
|
297
|
+
* This should be a TypeBox schema object.
|
|
298
|
+
*/
|
|
299
|
+
schema: T$1;
|
|
300
|
+
/**
|
|
301
|
+
* Callback function to handle form submission.
|
|
302
|
+
* This function will receive the parsed and validated form values.
|
|
303
|
+
*/
|
|
304
|
+
handler: (values: Static<T$1>, args: {
|
|
305
|
+
form: HTMLFormElement;
|
|
306
|
+
}) => unknown;
|
|
307
|
+
/**
|
|
308
|
+
* Optional initial values for the form fields.
|
|
309
|
+
* This can be used to pre-populate the form with existing data.
|
|
310
|
+
*/
|
|
311
|
+
initialValues?: Partial<Static<T$1>>;
|
|
312
|
+
/**
|
|
313
|
+
* Optional function to create custom field attributes.
|
|
314
|
+
* This can be used to add custom validation, styles, or other attributes.
|
|
315
|
+
*/
|
|
316
|
+
onCreateField?: (name: keyof Static<T$1> & string, schema: TSchema) => InputHTMLAttributes<unknown>;
|
|
317
|
+
/**
|
|
318
|
+
* If defined, this will generate a unique ID for each field, prefixed with this string.
|
|
319
|
+
*
|
|
320
|
+
* > "username" with id="form-123" will become "form-123-username".
|
|
321
|
+
*
|
|
322
|
+
* If omitted, IDs will not be generated.
|
|
323
|
+
*/
|
|
324
|
+
id?: string;
|
|
325
|
+
onError?: (error: Error, args: {
|
|
326
|
+
form: HTMLFormElement;
|
|
327
|
+
}) => void;
|
|
328
|
+
onChange?: (key: string, value: any, store: Record<string, any>) => void;
|
|
329
|
+
onReset?: () => void;
|
|
330
|
+
};
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region ../react/src/form/index.d.ts
|
|
333
|
+
declare module "alepha" {
|
|
334
|
+
interface Hooks {
|
|
335
|
+
"form:change": {
|
|
336
|
+
id: string;
|
|
337
|
+
path: string;
|
|
338
|
+
value: any;
|
|
339
|
+
};
|
|
340
|
+
"form:reset": {
|
|
341
|
+
id: string;
|
|
342
|
+
values: Record<string, any>;
|
|
343
|
+
};
|
|
344
|
+
"form:submit:begin": {
|
|
345
|
+
id: string;
|
|
346
|
+
};
|
|
347
|
+
"form:submit:success": {
|
|
348
|
+
id: string;
|
|
349
|
+
values: Record<string, any>;
|
|
350
|
+
};
|
|
351
|
+
"form:submit:error": {
|
|
352
|
+
id: string;
|
|
353
|
+
error: Error;
|
|
354
|
+
};
|
|
355
|
+
"form:submit:end": {
|
|
356
|
+
id: string;
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* React hooks for managing forms in Alepha applications.
|
|
362
|
+
*
|
|
363
|
+
* This module provides a set of hooks to simplify form handling, validation, and submission in React applications built with Alepha.
|
|
364
|
+
*
|
|
365
|
+
* It includes:
|
|
366
|
+
* - `useForm`: A hook for managing form state, validation, and submission.
|
|
367
|
+
*
|
|
368
|
+
* @see {@link useForm}
|
|
369
|
+
* @module alepha.react.form
|
|
370
|
+
*/
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/core/utils/parseInput.d.ts
|
|
373
|
+
interface GenericControlProps {
|
|
374
|
+
input: InputField;
|
|
375
|
+
title?: string;
|
|
376
|
+
description?: string;
|
|
377
|
+
icon?: ReactElement | ((props: {
|
|
378
|
+
size: number;
|
|
379
|
+
}) => ReactNode);
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/core/components/form/ControlNumber.d.ts
|
|
383
|
+
interface ControlNumberProps extends GenericControlProps {
|
|
384
|
+
numberInputProps?: Partial<NumberInputProps>;
|
|
385
|
+
sliderProps?: Partial<SliderProps>;
|
|
386
|
+
}
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/core/components/form/ControlSelect.d.ts
|
|
389
|
+
type SelectValueLabel = string | {
|
|
390
|
+
value: string;
|
|
391
|
+
label: string;
|
|
392
|
+
icon?: string;
|
|
393
|
+
};
|
|
394
|
+
interface ControlSelectProps extends GenericControlProps {
|
|
395
|
+
select?: boolean | SelectProps;
|
|
396
|
+
multi?: boolean | MultiSelectProps;
|
|
397
|
+
tags?: boolean | TagsInputProps;
|
|
398
|
+
autocomplete?: boolean | AutocompleteProps;
|
|
399
|
+
segmented?: boolean | Partial<SegmentedControlProps>;
|
|
400
|
+
loader?: () => Promise<SelectValueLabel[]>;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* ControlSelect component for handling Select, MultiSelect, and TagsInput.
|
|
404
|
+
*
|
|
405
|
+
* Features:
|
|
406
|
+
* - Basic Select with enum support
|
|
407
|
+
* - MultiSelect for array of enums
|
|
408
|
+
* - TagsInput for array of strings (no enum)
|
|
409
|
+
* - Future: Lazy loading
|
|
410
|
+
* - Future: Searchable/filterable options
|
|
411
|
+
* - Future: Custom option rendering
|
|
412
|
+
*
|
|
413
|
+
* Automatically detects enum values and array types from schema.
|
|
414
|
+
*/
|
|
415
|
+
declare const ControlSelect: (props: ControlSelectProps) => react_jsx_runtime4.JSX.Element | null;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/core/components/form/Control.d.ts
|
|
418
|
+
interface ControlProps extends GenericControlProps {
|
|
419
|
+
text?: TextInputProps;
|
|
420
|
+
area?: boolean | TextareaProps;
|
|
421
|
+
select?: boolean | Partial<ControlSelectProps>;
|
|
422
|
+
password?: boolean | PasswordInputProps;
|
|
423
|
+
switch?: boolean | SwitchProps;
|
|
424
|
+
number?: boolean | Partial<ControlNumberProps>;
|
|
425
|
+
file?: boolean | FileInputProps;
|
|
426
|
+
color?: boolean | ColorInputProps;
|
|
427
|
+
date?: boolean | DateInputProps;
|
|
428
|
+
datetime?: boolean | DateTimePickerProps;
|
|
429
|
+
time?: boolean | TimeInputProps;
|
|
430
|
+
query?: any;
|
|
431
|
+
custom?: ComponentType<CustomControlProps>;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Generic form control that renders the appropriate input based on the schema and props.
|
|
435
|
+
*
|
|
436
|
+
* Supports:
|
|
437
|
+
* - TextInput (with format detection: email, url, tel)
|
|
438
|
+
* - Textarea
|
|
439
|
+
* - NumberInput (for number/integer types)
|
|
440
|
+
* - FileInput
|
|
441
|
+
* - ColorInput (for color format)
|
|
442
|
+
* - Select (for enum types)
|
|
443
|
+
* - Autocomplete
|
|
444
|
+
* - PasswordInput
|
|
445
|
+
* - Switch (for boolean types)
|
|
446
|
+
* - SegmentedControl (for enum types)
|
|
447
|
+
* - DateInput (for date format)
|
|
448
|
+
* - DateTimePicker (for date-time format)
|
|
449
|
+
* - TimeInput (for time format)
|
|
450
|
+
* - QueryBuilder (for building type-safe queries with autocomplete)
|
|
451
|
+
* - Custom component
|
|
452
|
+
*
|
|
453
|
+
* Automatically handles labels, descriptions, error messages, required state, and default icons.
|
|
454
|
+
*/
|
|
455
|
+
declare const Control: (_props: ControlProps) => react_jsx_runtime4.JSX.Element | null;
|
|
456
|
+
type CustomControlProps = {
|
|
457
|
+
defaultValue: any;
|
|
458
|
+
onChange: (value: any) => void;
|
|
459
|
+
};
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region ../alepha/src/server/constants/routeMethods.d.ts
|
|
462
|
+
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
463
|
+
type RouteMethod = (typeof routeMethods)[number];
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region ../alepha/src/router/providers/RouterProvider.d.ts
|
|
466
|
+
declare abstract class RouterProvider<T$1 extends Route = Route> {
|
|
467
|
+
protected routePathRegex: RegExp;
|
|
468
|
+
protected tree: Tree<T$1>;
|
|
469
|
+
protected cache: Map<string, RouteMatch<T$1>>;
|
|
470
|
+
match(path: string): RouteMatch<T$1>;
|
|
471
|
+
protected test(path: string): void;
|
|
472
|
+
protected push(route: T$1): void;
|
|
473
|
+
protected createRouteMatch(path: string): RouteMatch<T$1>;
|
|
474
|
+
protected mapParams(match: RouteMatch<T$1>): RouteMatch<T$1>;
|
|
475
|
+
protected createParts(path: string): string[];
|
|
476
|
+
}
|
|
477
|
+
interface RouteMatch<T$1 extends Route> {
|
|
478
|
+
route?: T$1;
|
|
479
|
+
params?: Record<string, string>;
|
|
480
|
+
}
|
|
481
|
+
interface Route {
|
|
482
|
+
path: string;
|
|
483
|
+
/**
|
|
484
|
+
* Rename a param in the route.
|
|
485
|
+
* This is automatically filled when you have scenarios like:
|
|
486
|
+
* `/customers/:id` and `/customers/:userId/payments`
|
|
487
|
+
*
|
|
488
|
+
* In this case, `:id` will be renamed to `:userId` in the second route.
|
|
489
|
+
*/
|
|
490
|
+
mapParams?: Record<string, string>;
|
|
491
|
+
}
|
|
492
|
+
interface Tree<T$1 extends Route> {
|
|
493
|
+
route?: T$1;
|
|
494
|
+
children: {
|
|
495
|
+
[key: string]: Tree<T$1>;
|
|
496
|
+
};
|
|
497
|
+
param?: {
|
|
498
|
+
route?: T$1;
|
|
499
|
+
name: string;
|
|
500
|
+
children: {
|
|
501
|
+
[key: string]: Tree<T$1>;
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
wildcard?: {
|
|
505
|
+
route: T$1;
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region ../alepha/src/server/helpers/ServerReply.d.ts
|
|
510
|
+
/**
|
|
511
|
+
* Helper for building server replies.
|
|
512
|
+
*/
|
|
513
|
+
declare class ServerReply {
|
|
514
|
+
headers: Record<string, string> & {
|
|
515
|
+
"set-cookie"?: string[];
|
|
516
|
+
};
|
|
517
|
+
status?: number;
|
|
518
|
+
body?: any;
|
|
519
|
+
/**
|
|
520
|
+
* Redirect to a given URL with optional status code (default 302).
|
|
521
|
+
*/
|
|
522
|
+
redirect(url: string, status?: number): void;
|
|
523
|
+
/**
|
|
524
|
+
* Set the response status code.
|
|
525
|
+
*/
|
|
526
|
+
setStatus(status: number): this;
|
|
527
|
+
/**
|
|
528
|
+
* Set a response header.
|
|
529
|
+
*/
|
|
530
|
+
setHeader(name: string, value: string): this;
|
|
531
|
+
/**
|
|
532
|
+
* Set the response body.
|
|
533
|
+
*/
|
|
534
|
+
setBody(body: any): this;
|
|
535
|
+
}
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region ../alepha/src/server/services/UserAgentParser.d.ts
|
|
538
|
+
interface UserAgentInfo {
|
|
539
|
+
os: "Windows" | "Android" | "Ubuntu" | "MacOS" | "iOS" | "Linux" | "FreeBSD" | "OpenBSD" | "ChromeOS" | "BlackBerry" | "Symbian" | "Windows Phone";
|
|
540
|
+
browser: "Chrome" | "Firefox" | "Safari" | "Edge" | "Opera" | "Internet Explorer" | "Brave" | "Vivaldi" | "Samsung Browser" | "UC Browser" | "Yandex";
|
|
541
|
+
device: "MOBILE" | "DESKTOP" | "TABLET";
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Simple User-Agent parser to detect OS, browser, and device type.
|
|
545
|
+
* This parser is not exhaustive and may not cover all edge cases.
|
|
546
|
+
*
|
|
547
|
+
* Use result for non
|
|
548
|
+
*/
|
|
549
|
+
declare class UserAgentParser {
|
|
550
|
+
parse(userAgent?: string): UserAgentInfo;
|
|
551
|
+
}
|
|
552
|
+
//#endregion
|
|
553
|
+
//#region ../alepha/src/server/interfaces/ServerRequest.d.ts
|
|
554
|
+
type TRequestBody = TObject | TString | TArray | TRecord | TStream;
|
|
555
|
+
type TResponseBody = TObject | TString | TRecord | TFile | TArray | TStream | TVoid;
|
|
556
|
+
interface RequestConfigSchema {
|
|
557
|
+
body?: TRequestBody;
|
|
558
|
+
params?: TObject;
|
|
559
|
+
query?: TObject;
|
|
560
|
+
headers?: TObject;
|
|
561
|
+
response?: TResponseBody;
|
|
562
|
+
}
|
|
563
|
+
interface ServerRequestConfig<TConfig extends RequestConfigSchema = RequestConfigSchema> {
|
|
564
|
+
body: TConfig["body"] extends TRequestBody ? Static<TConfig["body"]> : any;
|
|
565
|
+
headers: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : Record<string, string>;
|
|
566
|
+
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : Record<string, string>;
|
|
567
|
+
query: TConfig["query"] extends TObject ? Static<TConfig["query"]> : Record<string, any>;
|
|
568
|
+
}
|
|
569
|
+
type ServerRequestConfigEntry<TConfig extends RequestConfigSchema = RequestConfigSchema> = Partial<ServerRequestConfig<TConfig>>;
|
|
570
|
+
interface ServerRequest<TConfig extends RequestConfigSchema = RequestConfigSchema> extends ServerRequestConfig<TConfig> {
|
|
571
|
+
/**
|
|
572
|
+
* HTTP method used for this request.
|
|
573
|
+
*/
|
|
574
|
+
method: RouteMethod;
|
|
575
|
+
/**
|
|
576
|
+
* Full request URL.
|
|
577
|
+
*/
|
|
578
|
+
url: URL;
|
|
579
|
+
/**
|
|
580
|
+
* Unique request ID assigned to this request.
|
|
581
|
+
*/
|
|
582
|
+
requestId: string;
|
|
583
|
+
/**
|
|
584
|
+
* Client IP address.
|
|
585
|
+
* Will parse `X-Forwarded-For` header if present.
|
|
586
|
+
*/
|
|
587
|
+
ip?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Value of the `Host` header sent by the client.
|
|
590
|
+
*/
|
|
591
|
+
host?: string;
|
|
592
|
+
/**
|
|
593
|
+
* Browser user agent information.
|
|
594
|
+
* Information are not guaranteed to be accurate. Use with caution.
|
|
595
|
+
*
|
|
596
|
+
* @see {@link UserAgentParser}
|
|
597
|
+
*/
|
|
598
|
+
userAgent: UserAgentInfo;
|
|
599
|
+
/**
|
|
600
|
+
* Arbitrary metadata attached to the request. Can be used by middlewares to store information.
|
|
601
|
+
*/
|
|
602
|
+
metadata: Record<string, any>;
|
|
603
|
+
/**
|
|
604
|
+
* Reply object to be used to send response.
|
|
605
|
+
*/
|
|
606
|
+
reply: ServerReply;
|
|
607
|
+
/**
|
|
608
|
+
* The raw underlying request object (Web Request).
|
|
609
|
+
*/
|
|
610
|
+
raw: ServerRawRequest;
|
|
611
|
+
}
|
|
612
|
+
interface ServerRoute<TConfig extends RequestConfigSchema = RequestConfigSchema> extends Route {
|
|
613
|
+
/**
|
|
614
|
+
* Handler function for this route.
|
|
615
|
+
*/
|
|
616
|
+
handler: ServerHandler<TConfig>;
|
|
617
|
+
/**
|
|
618
|
+
* HTTP method for this route.
|
|
619
|
+
*/
|
|
620
|
+
method?: RouteMethod;
|
|
621
|
+
/**
|
|
622
|
+
* Request/response schema for this route.
|
|
623
|
+
*
|
|
624
|
+
* Request schema contains:
|
|
625
|
+
* - body, for POST/PUT/PATCH requests
|
|
626
|
+
* - params, for URL parameters (e.g. /user/:id)
|
|
627
|
+
* - query, for URL query parameters (e.g. /user?id=123)
|
|
628
|
+
* - headers, for HTTP headers
|
|
629
|
+
*
|
|
630
|
+
* Response schema contains:
|
|
631
|
+
* - response
|
|
632
|
+
*
|
|
633
|
+
* Response schema is used to validate and serialize the response sent by the handler.
|
|
634
|
+
*/
|
|
635
|
+
schema?: TConfig;
|
|
636
|
+
/**
|
|
637
|
+
* @see ServerLoggerProvider
|
|
638
|
+
*/
|
|
639
|
+
silent?: boolean;
|
|
640
|
+
}
|
|
641
|
+
type ServerResponseBody<TConfig extends RequestConfigSchema = RequestConfigSchema> = TConfig["response"] extends TResponseBody ? Static<TConfig["response"]> : ResponseBodyType;
|
|
642
|
+
type ResponseKind = "json" | "text" | "void" | "file" | "any";
|
|
643
|
+
type ResponseBodyType = string | Buffer | StreamLike | undefined | null | void;
|
|
644
|
+
type ServerHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
645
|
+
interface ServerResponse$1 {
|
|
646
|
+
body: string | Buffer | ArrayBuffer | Readable | ReadableStream;
|
|
647
|
+
headers: Record<string, string>;
|
|
648
|
+
status: number;
|
|
649
|
+
}
|
|
650
|
+
type ServerRouteRequestHandler = (request: ServerRequestData) => Promise<ServerResponse$1>;
|
|
651
|
+
interface ServerRouteMatcher extends Route {
|
|
652
|
+
handler: ServerRouteRequestHandler;
|
|
653
|
+
}
|
|
654
|
+
interface ServerRequestData {
|
|
655
|
+
method: RouteMethod;
|
|
656
|
+
url: URL;
|
|
657
|
+
headers: Record<string, string>;
|
|
658
|
+
query: Record<string, string>;
|
|
659
|
+
params: Record<string, string>;
|
|
660
|
+
raw: ServerRawRequest;
|
|
661
|
+
}
|
|
662
|
+
interface ServerRawRequest {
|
|
663
|
+
node?: NodeRequestEvent;
|
|
664
|
+
web?: WebRequestEvent;
|
|
665
|
+
}
|
|
666
|
+
interface NodeRequestEvent {
|
|
667
|
+
req: IncomingMessage;
|
|
668
|
+
res: ServerResponse;
|
|
669
|
+
}
|
|
670
|
+
interface WebRequestEvent {
|
|
671
|
+
req: Request;
|
|
672
|
+
res?: Response;
|
|
673
|
+
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region ../alepha/src/server/services/ServerRequestParser.d.ts
|
|
676
|
+
declare class ServerRequestParser {
|
|
677
|
+
protected readonly alepha: Alepha;
|
|
678
|
+
protected readonly userAgentParser: UserAgentParser;
|
|
679
|
+
createServerRequest(rawRequest: ServerRequestData): ServerRequest;
|
|
680
|
+
getRequestId(request: ServerRequestData): string | undefined;
|
|
681
|
+
getRequestUserAgent(request: ServerRequestData): UserAgentInfo;
|
|
682
|
+
getRequestIp(request: ServerRequestData): string | undefined;
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region ../alepha/src/server/providers/ServerTimingProvider.d.ts
|
|
686
|
+
type TimingMap = Record<string, [number, number]>;
|
|
687
|
+
declare class ServerTimingProvider {
|
|
688
|
+
protected readonly log: Logger;
|
|
689
|
+
protected readonly alepha: Alepha;
|
|
690
|
+
options: {
|
|
691
|
+
prefix: string;
|
|
692
|
+
disabled: boolean;
|
|
693
|
+
};
|
|
694
|
+
readonly onRequest: alepha79.HookDescriptor<"server:onRequest">;
|
|
695
|
+
readonly onResponse: alepha79.HookDescriptor<"server:onResponse">;
|
|
696
|
+
protected get handlerName(): string;
|
|
697
|
+
beginTiming(name: string): void;
|
|
698
|
+
endTiming(name: string): void;
|
|
699
|
+
protected setDuration(name: string, timing: TimingMap): void;
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region ../alepha/src/server/providers/ServerRouterProvider.d.ts
|
|
703
|
+
/**
|
|
704
|
+
* Main router for all routes on the server side.
|
|
705
|
+
*
|
|
706
|
+
* - $route => generic route
|
|
707
|
+
* - $action => action route (for API calls)
|
|
708
|
+
* - $page => React route (for SSR)
|
|
709
|
+
*/
|
|
710
|
+
declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
|
|
711
|
+
protected readonly log: Logger;
|
|
712
|
+
protected readonly alepha: Alepha;
|
|
713
|
+
protected readonly routes: ServerRoute[];
|
|
714
|
+
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
715
|
+
protected readonly serverRequestParser: ServerRequestParser;
|
|
716
|
+
/**
|
|
717
|
+
* Get all registered routes, optionally filtered by a pattern.
|
|
718
|
+
*
|
|
719
|
+
* Pattern accept simple wildcard '*' at the end.
|
|
720
|
+
* Example: '/api/*' will match all routes starting with '/api/' but '/api/' will match only that exact route.
|
|
721
|
+
*/
|
|
722
|
+
getRoutes(pattern?: string): ServerRoute[];
|
|
723
|
+
createRoute<TConfig extends RequestConfigSchema = RequestConfigSchema>(route: ServerRoute<TConfig>): void;
|
|
724
|
+
protected getContextId(headers: Record<string, string>): string;
|
|
725
|
+
protected processRequest(request: ServerRequest, route: ServerRoute, responseKind: ResponseKind): Promise<{
|
|
726
|
+
status: number;
|
|
727
|
+
headers: Record<string, string> & {
|
|
728
|
+
"set-cookie"?: string[];
|
|
729
|
+
};
|
|
730
|
+
body: any;
|
|
731
|
+
}>;
|
|
732
|
+
protected runRouteHandler(route: ServerRoute, request: ServerRequest, responseKind: ResponseKind): Promise<void>;
|
|
733
|
+
serializeResponse(route: ServerRoute, reply: ServerReply, responseKind: ResponseKind): void;
|
|
734
|
+
protected getResponseType(schema?: RequestConfigSchema): ResponseKind;
|
|
735
|
+
protected errorHandler(route: ServerRoute, request: ServerRequest, error: Error): Promise<void>;
|
|
736
|
+
validateRequest(route: {
|
|
737
|
+
schema?: RequestConfigSchema;
|
|
738
|
+
}, request: ServerRequestConfig): void;
|
|
739
|
+
}
|
|
740
|
+
//#endregion
|
|
741
|
+
//#region ../alepha/src/server/providers/ServerProvider.d.ts
|
|
742
|
+
/**
|
|
743
|
+
* Base server provider to handle incoming requests and route them.
|
|
744
|
+
*
|
|
745
|
+
* This is the default implementation for serverless environments.
|
|
746
|
+
*
|
|
747
|
+
* ServerProvider supports both Node.js HTTP requests and Web (Fetch API) requests.
|
|
748
|
+
*/
|
|
749
|
+
declare class ServerProvider {
|
|
750
|
+
protected readonly log: Logger;
|
|
751
|
+
protected readonly alepha: Alepha;
|
|
752
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
753
|
+
protected readonly router: ServerRouterProvider;
|
|
754
|
+
protected readonly internalServerErrorMessage = "Internal Server Error";
|
|
755
|
+
get hostname(): string;
|
|
756
|
+
/**
|
|
757
|
+
* When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
|
|
758
|
+
*/
|
|
759
|
+
protected readonly onNodeRequest: alepha79.HookDescriptor<"node:request">;
|
|
760
|
+
/**
|
|
761
|
+
* When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
|
|
762
|
+
*/
|
|
763
|
+
protected readonly onWebRequest: alepha79.HookDescriptor<"web:request">;
|
|
764
|
+
/**
|
|
765
|
+
* Handle Node.js HTTP request event.
|
|
766
|
+
*
|
|
767
|
+
* Technically, we just convert Node.js request to Web Standard Request.
|
|
768
|
+
*/
|
|
769
|
+
handleNodeRequest(nodeRequestEvent: NodeRequestEvent): Promise<void>;
|
|
770
|
+
/**
|
|
771
|
+
* Handle Web (Fetch API) request event.
|
|
772
|
+
*/
|
|
773
|
+
handleWebRequest(ev: WebRequestEvent): Promise<void>;
|
|
774
|
+
/**
|
|
775
|
+
* Helper for Vite development mode to let Vite handle (or not) 404.
|
|
776
|
+
*/
|
|
777
|
+
protected isViteNotFound(url?: string, route?: Route, params?: Record<string, string>): boolean;
|
|
778
|
+
}
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region ../alepha/src/cache/providers/CacheProvider.d.ts
|
|
781
|
+
/**
|
|
782
|
+
* Cache provider interface.
|
|
783
|
+
*
|
|
784
|
+
* All methods are asynchronous and return promises.
|
|
785
|
+
* Values are stored as Uint8Array.
|
|
786
|
+
*/
|
|
787
|
+
declare abstract class CacheProvider {
|
|
788
|
+
/**
|
|
789
|
+
* Get the value of a key.
|
|
790
|
+
*
|
|
791
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
792
|
+
* @param key The key of the value to get.
|
|
793
|
+
*
|
|
794
|
+
* @return The value of the key, or undefined if the key does not exist.
|
|
795
|
+
*/
|
|
796
|
+
abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
797
|
+
/**
|
|
798
|
+
* Set the string value of a key.
|
|
799
|
+
*
|
|
800
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
801
|
+
* @param key The key of the value to set.
|
|
802
|
+
* @param value The value to set.
|
|
803
|
+
* @param ttl The time-to-live of the key, in milliseconds.
|
|
804
|
+
*
|
|
805
|
+
* @return The value of the key.
|
|
806
|
+
*/
|
|
807
|
+
abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
|
|
808
|
+
/**
|
|
809
|
+
* Remove the specified keys.
|
|
810
|
+
*
|
|
811
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
812
|
+
* @param keys The keys to delete.
|
|
813
|
+
*/
|
|
814
|
+
abstract del(name: string, ...keys: string[]): Promise<void>;
|
|
815
|
+
abstract has(name: string, key: string): Promise<boolean>;
|
|
816
|
+
abstract keys(name: string, filter?: string): Promise<string[]>;
|
|
817
|
+
/**
|
|
818
|
+
* Remove all keys from all cache names.
|
|
819
|
+
*/
|
|
820
|
+
abstract clear(): Promise<void>;
|
|
821
|
+
}
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region ../alepha/src/cache/descriptors/$cache.d.ts
|
|
824
|
+
interface CacheDescriptorOptions<TReturn = any, TParameter extends any[] = any[]> {
|
|
825
|
+
/**
|
|
826
|
+
* The cache name. This is useful for invalidating multiple caches at once.
|
|
827
|
+
*
|
|
828
|
+
* Store key as `cache:$name:$key`.
|
|
829
|
+
*
|
|
830
|
+
* @default Name of the key of the class.
|
|
831
|
+
*/
|
|
832
|
+
name?: string;
|
|
833
|
+
/**
|
|
834
|
+
* Function which returns cached data.
|
|
835
|
+
*/
|
|
836
|
+
handler?: (...args: TParameter) => TReturn;
|
|
837
|
+
/**
|
|
838
|
+
* The key generator for the cache.
|
|
839
|
+
* If not provided, the arguments will be json.stringify().
|
|
840
|
+
*/
|
|
841
|
+
key?: (...args: TParameter) => string;
|
|
842
|
+
/**
|
|
843
|
+
* The store provider for the cache.
|
|
844
|
+
* If not provided, the default store provider will be used.
|
|
845
|
+
*/
|
|
846
|
+
provider?: InstantiableClass<CacheProvider> | "memory";
|
|
847
|
+
/**
|
|
848
|
+
* The time-to-live for the cache in seconds.
|
|
849
|
+
* Set 0 to skip expiration.
|
|
850
|
+
*
|
|
851
|
+
* @default 300 (5 minutes).
|
|
852
|
+
*/
|
|
853
|
+
ttl?: DurationLike;
|
|
854
|
+
/**
|
|
855
|
+
* If the cache is disabled.
|
|
856
|
+
*/
|
|
857
|
+
disabled?: boolean;
|
|
858
|
+
}
|
|
859
|
+
declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> extends Descriptor<CacheDescriptorOptions<TReturn, TParameter>> {
|
|
860
|
+
protected readonly env: {
|
|
861
|
+
CACHE_ENABLED: boolean;
|
|
862
|
+
CACHE_DEFAULT_TTL: number;
|
|
863
|
+
};
|
|
864
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
865
|
+
protected readonly provider: CacheProvider;
|
|
866
|
+
protected encoder: TextEncoder;
|
|
867
|
+
protected decoder: TextDecoder;
|
|
868
|
+
protected codes: {
|
|
869
|
+
BINARY: number;
|
|
870
|
+
JSON: number;
|
|
871
|
+
STRING: number;
|
|
872
|
+
};
|
|
873
|
+
get container(): string;
|
|
874
|
+
run(...args: TParameter): Promise<TReturn>;
|
|
875
|
+
key(...args: TParameter): string;
|
|
876
|
+
invalidate(...keys: string[]): Promise<void>;
|
|
877
|
+
set(key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
|
|
878
|
+
get(key: string): Promise<TReturn | undefined>;
|
|
879
|
+
protected serialize<TReturn>(value: TReturn): Uint8Array;
|
|
880
|
+
protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
|
|
881
|
+
protected $provider(): CacheProvider;
|
|
882
|
+
}
|
|
883
|
+
interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> extends CacheDescriptor<TReturn, TParameter> {
|
|
884
|
+
/**
|
|
885
|
+
* Run the cache descriptor with the provided arguments.
|
|
886
|
+
*/
|
|
887
|
+
(...args: TParameter): Promise<TReturn>;
|
|
888
|
+
}
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region ../alepha/src/server/services/HttpClient.d.ts
|
|
891
|
+
declare class HttpClient {
|
|
892
|
+
protected readonly log: Logger;
|
|
893
|
+
protected readonly alepha: Alepha;
|
|
894
|
+
readonly cache: CacheDescriptorFn<HttpClientCache, any[]>;
|
|
895
|
+
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
896
|
+
fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
|
|
897
|
+
fetch<T$1 extends TSchema>(url: string, request?: RequestInitWithOptions<T$1>): Promise<FetchResponse<Static<T$1>>>;
|
|
898
|
+
protected url(host: string, action: HttpAction, args: ServerRequestConfigEntry): string;
|
|
899
|
+
protected body(init: RequestInit, headers: Record<string, string>, action: HttpAction, args?: ServerRequestConfigEntry): Promise<void>;
|
|
900
|
+
protected responseData(response: Response, options: FetchOptions): Promise<any>;
|
|
901
|
+
protected isMaybeFile(response: Response): boolean;
|
|
902
|
+
protected createFileLike(response: Response, defaultFileName?: string): FileLike;
|
|
903
|
+
pathVariables(url: string, action: {
|
|
904
|
+
schema?: {
|
|
905
|
+
params?: TObject;
|
|
906
|
+
};
|
|
907
|
+
}, args?: ServerRequestConfigEntry): string;
|
|
908
|
+
queryParams(url: string, action: {
|
|
909
|
+
schema?: {
|
|
910
|
+
query?: TObject;
|
|
911
|
+
};
|
|
912
|
+
}, args?: ServerRequestConfigEntry): string;
|
|
913
|
+
}
|
|
914
|
+
interface FetchOptions<T$1 extends TSchema = TSchema> {
|
|
915
|
+
/**
|
|
916
|
+
* Key to identify the request in the pending requests.
|
|
917
|
+
*/
|
|
918
|
+
key?: string;
|
|
919
|
+
/**
|
|
920
|
+
* The schema to validate the response against.
|
|
921
|
+
*/
|
|
922
|
+
schema?: {
|
|
923
|
+
response?: T$1;
|
|
924
|
+
};
|
|
925
|
+
/**
|
|
926
|
+
* Built-in cache options.
|
|
927
|
+
*/
|
|
928
|
+
localCache?: boolean | number | DurationLike;
|
|
929
|
+
}
|
|
930
|
+
type RequestInitWithOptions<T$1 extends TSchema = TSchema> = RequestInit & FetchOptions<T$1>;
|
|
931
|
+
interface FetchResponse<T$1 = any> {
|
|
932
|
+
data: T$1;
|
|
933
|
+
status: number;
|
|
934
|
+
statusText: string;
|
|
935
|
+
headers: Headers;
|
|
936
|
+
raw?: Response;
|
|
937
|
+
}
|
|
938
|
+
type HttpClientPendingRequests = Record<string, Promise<any> | undefined>;
|
|
939
|
+
interface HttpClientCache {
|
|
940
|
+
data: any;
|
|
941
|
+
etag?: string;
|
|
942
|
+
}
|
|
943
|
+
interface FetchActionArgs {
|
|
944
|
+
action: HttpAction;
|
|
945
|
+
host?: string;
|
|
946
|
+
config?: ServerRequestConfigEntry;
|
|
947
|
+
options?: ClientRequestOptions;
|
|
948
|
+
}
|
|
949
|
+
interface HttpAction {
|
|
950
|
+
method?: string;
|
|
951
|
+
prefix?: string;
|
|
952
|
+
path: string;
|
|
953
|
+
requestBodyType?: string;
|
|
954
|
+
schema?: {
|
|
955
|
+
params?: TObject;
|
|
956
|
+
query?: TObject;
|
|
957
|
+
body?: TRequestBody;
|
|
958
|
+
response?: TResponseBody;
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region ../alepha/src/server/descriptors/$action.d.ts
|
|
963
|
+
interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
|
|
964
|
+
/**
|
|
965
|
+
* Name of the action.
|
|
966
|
+
*
|
|
967
|
+
* - It will be used to generate the route path if `path` is not provided.
|
|
968
|
+
* - It will be used to generate the permission name if `security` is enabled.
|
|
969
|
+
*/
|
|
970
|
+
name?: string;
|
|
971
|
+
/**
|
|
972
|
+
* Group actions together.
|
|
973
|
+
*
|
|
974
|
+
* - If not provided, the service name containing the route will be used.
|
|
975
|
+
* - It will be used as Tag for documentation purposes.
|
|
976
|
+
* - It will be used for permission name generation if `security` is enabled.
|
|
977
|
+
*
|
|
978
|
+
* @example
|
|
979
|
+
* ```ts
|
|
980
|
+
* // group = "MyController"
|
|
981
|
+
* class MyController {
|
|
982
|
+
* hello = $action({ handler: () => "Hello World" });
|
|
983
|
+
* }
|
|
984
|
+
*
|
|
985
|
+
* // group = "users"
|
|
986
|
+
* class MyOtherController {
|
|
987
|
+
* group = "users";
|
|
988
|
+
* a1 = $action({ handler: () => "Action 1", group: this.group });
|
|
989
|
+
* a2 = $action({ handler: () => "Action 2", group: this.group });
|
|
990
|
+
* }
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
group?: string;
|
|
994
|
+
/**
|
|
995
|
+
* Pathname of the route. If not provided, property key is used.
|
|
996
|
+
*/
|
|
997
|
+
path?: string;
|
|
998
|
+
/**
|
|
999
|
+
* The route method.
|
|
1000
|
+
*
|
|
1001
|
+
* - If not provided, it will be set to "GET" by default.
|
|
1002
|
+
* - If not provider and a body is provided, it will be set to "POST".
|
|
1003
|
+
*
|
|
1004
|
+
* Wildcard methods are not supported for now. (e.g. "ALL", "ANY", etc.)
|
|
1005
|
+
*/
|
|
1006
|
+
method?: RouteMethod;
|
|
1007
|
+
/**
|
|
1008
|
+
* The config schema of the route.
|
|
1009
|
+
* - body: The request body schema.
|
|
1010
|
+
* - params: Path variables schema.
|
|
1011
|
+
* - query: The request query-params schema.
|
|
1012
|
+
* - response: The response schema.
|
|
1013
|
+
*/
|
|
1014
|
+
schema?: TConfig;
|
|
1015
|
+
/**
|
|
1016
|
+
* A short description of the action. Used for documentation purposes.
|
|
1017
|
+
*/
|
|
1018
|
+
description?: string;
|
|
1019
|
+
/**
|
|
1020
|
+
* Disable the route. Useful with env variables do disable one specific route.
|
|
1021
|
+
* Route won't be available in the API but can still be called locally!
|
|
1022
|
+
*/
|
|
1023
|
+
disabled?: boolean;
|
|
1024
|
+
/**
|
|
1025
|
+
* Main route handler. This is where the route logic is implemented.
|
|
1026
|
+
*/
|
|
1027
|
+
handler: ServerActionHandler<TConfig>;
|
|
1028
|
+
}
|
|
1029
|
+
declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
|
|
1030
|
+
protected readonly log: Logger;
|
|
1031
|
+
protected readonly env: {
|
|
1032
|
+
SERVER_API_PREFIX: string;
|
|
1033
|
+
};
|
|
1034
|
+
protected readonly httpClient: HttpClient;
|
|
1035
|
+
protected readonly serverProvider: ServerProvider;
|
|
1036
|
+
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
1037
|
+
protected onInit(): void;
|
|
1038
|
+
get prefix(): string;
|
|
1039
|
+
get route(): ServerRoute;
|
|
1040
|
+
/**
|
|
1041
|
+
* Returns the name of the action.
|
|
1042
|
+
*/
|
|
1043
|
+
get name(): string;
|
|
1044
|
+
/**
|
|
1045
|
+
* Returns the group of the action. (e.g. "orders", "admin", etc.)
|
|
1046
|
+
*/
|
|
1047
|
+
get group(): string;
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns the HTTP method of the action.
|
|
1050
|
+
*/
|
|
1051
|
+
get method(): RouteMethod;
|
|
1052
|
+
/**
|
|
1053
|
+
* Returns the path of the action.
|
|
1054
|
+
*
|
|
1055
|
+
* Path is prefixed by `/api` by default.
|
|
1056
|
+
*/
|
|
1057
|
+
get path(): string;
|
|
1058
|
+
get schema(): TConfig | undefined;
|
|
1059
|
+
getBodyContentType(): string | undefined;
|
|
1060
|
+
/**
|
|
1061
|
+
* Call the action handler directly.
|
|
1062
|
+
* There is no HTTP layer involved.
|
|
1063
|
+
*/
|
|
1064
|
+
run(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Works like `run`, but always fetches (http request) the route.
|
|
1067
|
+
*/
|
|
1068
|
+
fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
|
|
1069
|
+
}
|
|
1070
|
+
type ClientRequestEntry<TConfig extends RequestConfigSchema, T$1 = ClientRequestEntryContainer<TConfig>> = { [K in keyof T$1 as T$1[K] extends undefined ? never : K]: T$1[K] };
|
|
1071
|
+
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
|
|
1072
|
+
body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
|
|
1073
|
+
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
|
|
1074
|
+
headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
|
|
1075
|
+
query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
|
|
1076
|
+
};
|
|
1077
|
+
interface ClientRequestOptions extends FetchOptions {
|
|
1078
|
+
/**
|
|
1079
|
+
* Standard request fetch options.
|
|
1080
|
+
*/
|
|
1081
|
+
request?: RequestInit;
|
|
1082
|
+
}
|
|
1083
|
+
type ClientRequestResponse<TConfig extends RequestConfigSchema> = TConfig["response"] extends TSchema ? Static<TConfig["response"]> : any;
|
|
1084
|
+
/**
|
|
1085
|
+
* Specific handler for server actions.
|
|
1086
|
+
*/
|
|
1087
|
+
type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSchema> = (request: ServerActionRequest<TConfig>) => Async<ServerResponseBody<TConfig>>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Server Action Request Interface
|
|
1090
|
+
*
|
|
1091
|
+
* Can be extended with module augmentation to add custom properties (like `user` in Server Security).
|
|
1092
|
+
*
|
|
1093
|
+
* This is NOT Server Request, but a specific type for actions.
|
|
1094
|
+
*/
|
|
1095
|
+
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region ../alepha/src/server/schemas/errorSchema.d.ts
|
|
1098
|
+
declare const errorSchema: alepha79.TObject<{
|
|
1099
|
+
error: alepha79.TString;
|
|
1100
|
+
status: alepha79.TInteger;
|
|
1101
|
+
message: alepha79.TString;
|
|
1102
|
+
details: alepha79.TOptional<alepha79.TString>;
|
|
1103
|
+
requestId: alepha79.TOptional<alepha79.TString>;
|
|
1104
|
+
cause: alepha79.TOptional<alepha79.TObject<{
|
|
1105
|
+
name: alepha79.TString;
|
|
1106
|
+
message: alepha79.TString;
|
|
1107
|
+
}>>;
|
|
1108
|
+
}>;
|
|
1109
|
+
type ErrorSchema = Static<typeof errorSchema>;
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region ../alepha/src/server/errors/HttpError.d.ts
|
|
1112
|
+
declare class HttpError extends AlephaError {
|
|
1113
|
+
name: string;
|
|
1114
|
+
static is: (error: unknown, status?: number) => error is HttpErrorLike;
|
|
1115
|
+
static toJSON(error: HttpError): ErrorSchema;
|
|
1116
|
+
readonly error: string;
|
|
1117
|
+
readonly status: number;
|
|
1118
|
+
readonly requestId?: string;
|
|
1119
|
+
readonly details?: string;
|
|
1120
|
+
readonly reason?: {
|
|
1121
|
+
name: string;
|
|
1122
|
+
message: string;
|
|
1123
|
+
};
|
|
1124
|
+
constructor(options: Partial<ErrorSchema>, cause?: unknown);
|
|
1125
|
+
}
|
|
1126
|
+
interface HttpErrorLike extends Error {
|
|
1127
|
+
status: number;
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region ../alepha/src/server/providers/BunHttpServerProvider.d.ts
|
|
1131
|
+
declare const envSchema$5: alepha79.TObject<{
|
|
1132
|
+
SERVER_PORT: alepha79.TInteger;
|
|
1133
|
+
SERVER_HOST: alepha79.TString;
|
|
1134
|
+
}>;
|
|
1135
|
+
declare module "alepha" {
|
|
1136
|
+
interface Env extends Partial<Static<typeof envSchema$5>> {}
|
|
1137
|
+
}
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region ../alepha/src/server/providers/NodeHttpServerProvider.d.ts
|
|
1140
|
+
declare const envSchema$4: alepha79.TObject<{
|
|
1141
|
+
SERVER_PORT: alepha79.TInteger;
|
|
1142
|
+
SERVER_HOST: alepha79.TString;
|
|
1143
|
+
}>;
|
|
1144
|
+
declare module "alepha" {
|
|
1145
|
+
interface Env extends Partial<Static<typeof envSchema$4>> {}
|
|
1146
|
+
}
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region ../alepha/src/server/index.d.ts
|
|
1149
|
+
declare module "alepha" {
|
|
1150
|
+
interface State {
|
|
1151
|
+
"alepha.node.server"?: Server;
|
|
1152
|
+
}
|
|
1153
|
+
interface Hooks {
|
|
1154
|
+
"action:onRequest": {
|
|
1155
|
+
action: ActionDescriptor<RequestConfigSchema>;
|
|
1156
|
+
request: ServerRequest;
|
|
1157
|
+
options: ClientRequestOptions;
|
|
1158
|
+
};
|
|
1159
|
+
"action:onResponse": {
|
|
1160
|
+
action: ActionDescriptor<RequestConfigSchema>;
|
|
1161
|
+
request: ServerRequest;
|
|
1162
|
+
options: ClientRequestOptions;
|
|
1163
|
+
response: any;
|
|
1164
|
+
};
|
|
1165
|
+
"server:onRequest": {
|
|
1166
|
+
route: ServerRoute;
|
|
1167
|
+
request: ServerRequest;
|
|
1168
|
+
};
|
|
1169
|
+
"server:onError": {
|
|
1170
|
+
route: ServerRoute;
|
|
1171
|
+
request: ServerRequest;
|
|
1172
|
+
error: Error;
|
|
1173
|
+
};
|
|
1174
|
+
"server:onSend": {
|
|
1175
|
+
route: ServerRoute;
|
|
1176
|
+
request: ServerRequest;
|
|
1177
|
+
};
|
|
1178
|
+
"server:onResponse": {
|
|
1179
|
+
route: ServerRoute;
|
|
1180
|
+
request: ServerRequest;
|
|
1181
|
+
response: ServerResponse$1;
|
|
1182
|
+
};
|
|
1183
|
+
"client:onRequest": {
|
|
1184
|
+
route: HttpAction;
|
|
1185
|
+
config: ServerRequestConfigEntry;
|
|
1186
|
+
options: ClientRequestOptions;
|
|
1187
|
+
headers: Record<string, string>;
|
|
1188
|
+
request: RequestInit;
|
|
1189
|
+
};
|
|
1190
|
+
"client:beforeFetch": {
|
|
1191
|
+
url: string;
|
|
1192
|
+
options: FetchOptions;
|
|
1193
|
+
request: RequestInit;
|
|
1194
|
+
};
|
|
1195
|
+
"client:onError": {
|
|
1196
|
+
route?: HttpAction;
|
|
1197
|
+
error: HttpError;
|
|
1198
|
+
};
|
|
1199
|
+
"node:request": NodeRequestEvent;
|
|
1200
|
+
"web:request": WebRequestEvent;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region ../alepha/src/server-cache/providers/ServerCacheProvider.d.ts
|
|
1205
|
+
declare module "alepha/server" {
|
|
1206
|
+
interface ServerRoute {
|
|
1207
|
+
/**
|
|
1208
|
+
* Enable caching for this route.
|
|
1209
|
+
* - If true: enables both store and etag
|
|
1210
|
+
* - If object: fine-grained control over store, etag, and cache-control headers
|
|
1211
|
+
*
|
|
1212
|
+
* @default false
|
|
1213
|
+
*/
|
|
1214
|
+
cache?: ServerRouteCache;
|
|
1215
|
+
}
|
|
1216
|
+
interface ActionDescriptor<TConfig extends RequestConfigSchema> {
|
|
1217
|
+
invalidate: () => Promise<void>;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
type ServerRouteCache =
|
|
1221
|
+
/**
|
|
1222
|
+
* If true, enables caching with:
|
|
1223
|
+
* - store: true
|
|
1224
|
+
* - etag: true
|
|
1225
|
+
*/
|
|
1226
|
+
boolean
|
|
1227
|
+
/**
|
|
1228
|
+
* Object configuration for fine-grained cache control.
|
|
1229
|
+
*
|
|
1230
|
+
* If empty, no caching will be applied.
|
|
1231
|
+
*/ | {
|
|
1232
|
+
/**
|
|
1233
|
+
* If true, enables storing cached responses. (in-memory, Redis, @see alepha/cache for other providers)
|
|
1234
|
+
* If a DurationLike is provided, it will be used as the TTL for the cache.
|
|
1235
|
+
* If CacheDescriptorOptions is provided, it will be used to configure the cache storage.
|
|
1236
|
+
*
|
|
1237
|
+
* @default false
|
|
1238
|
+
*/
|
|
1239
|
+
store?: true | DurationLike | CacheDescriptorOptions;
|
|
1240
|
+
/**
|
|
1241
|
+
* If true, enables ETag support for the cached responses.
|
|
1242
|
+
*/
|
|
1243
|
+
etag?: true;
|
|
1244
|
+
/**
|
|
1245
|
+
* - If true, sets Cache-Control to "public, max-age=300" (5 minutes).
|
|
1246
|
+
* - If string, sets Cache-Control to the provided value directly.
|
|
1247
|
+
* - If object, configures Cache-Control directives.
|
|
1248
|
+
*/
|
|
1249
|
+
control?: true
|
|
1250
|
+
/**
|
|
1251
|
+
* If string, sets Cache-Control to the provided value directly.
|
|
1252
|
+
*/ | string
|
|
1253
|
+
/**
|
|
1254
|
+
* If object, configures Cache-Control directives.
|
|
1255
|
+
*/ | {
|
|
1256
|
+
/**
|
|
1257
|
+
* Indicates that the response may be cached by any cache.
|
|
1258
|
+
*/
|
|
1259
|
+
public?: boolean;
|
|
1260
|
+
/**
|
|
1261
|
+
* Indicates that the response is intended for a single user and must not be stored by a shared cache.
|
|
1262
|
+
*/
|
|
1263
|
+
private?: boolean;
|
|
1264
|
+
/**
|
|
1265
|
+
* Forces caches to submit the request to the origin server for validation before releasing a cached copy.
|
|
1266
|
+
*/
|
|
1267
|
+
noCache?: boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Instructs caches not to store the response.
|
|
1270
|
+
*/
|
|
1271
|
+
noStore?: boolean;
|
|
1272
|
+
/**
|
|
1273
|
+
* Maximum amount of time a resource is considered fresh.
|
|
1274
|
+
* Can be specified as a number (seconds) or as a DurationLike object.
|
|
1275
|
+
*
|
|
1276
|
+
* @example 300 // 5 minutes in seconds
|
|
1277
|
+
* @example { minutes: 5 } // 5 minutes
|
|
1278
|
+
* @example { hours: 1 } // 1 hour
|
|
1279
|
+
*/
|
|
1280
|
+
maxAge?: number | DurationLike;
|
|
1281
|
+
/**
|
|
1282
|
+
* Overrides max-age for shared caches (e.g., CDNs).
|
|
1283
|
+
* Can be specified as a number (seconds) or as a DurationLike object.
|
|
1284
|
+
*/
|
|
1285
|
+
sMaxAge?: number | DurationLike;
|
|
1286
|
+
/**
|
|
1287
|
+
* Indicates that once a resource becomes stale, caches must not use it without successful validation.
|
|
1288
|
+
*/
|
|
1289
|
+
mustRevalidate?: boolean;
|
|
1290
|
+
/**
|
|
1291
|
+
* Similar to must-revalidate, but only for shared caches.
|
|
1292
|
+
*/
|
|
1293
|
+
proxyRevalidate?: boolean;
|
|
1294
|
+
/**
|
|
1295
|
+
* Indicates that the response can be stored but must be revalidated before each use.
|
|
1296
|
+
*/
|
|
1297
|
+
immutable?: boolean;
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
//#endregion
|
|
1301
|
+
//#region ../react/src/core/components/ClientOnly.d.ts
|
|
1302
|
+
interface ClientOnlyProps {
|
|
1303
|
+
fallback?: ReactNode;
|
|
1304
|
+
disabled?: boolean;
|
|
1305
|
+
}
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region ../react/src/core/errors/Redirection.d.ts
|
|
1308
|
+
/**
|
|
1309
|
+
* Used for Redirection during the page loading.
|
|
1310
|
+
*
|
|
1311
|
+
* Depends on the context, it can be thrown or just returned.
|
|
1312
|
+
*/
|
|
1313
|
+
declare class Redirection extends Error {
|
|
1314
|
+
readonly redirect: string;
|
|
1315
|
+
constructor(redirect: string);
|
|
1316
|
+
}
|
|
1317
|
+
//#endregion
|
|
1318
|
+
//#region ../react/src/core/providers/ReactPageProvider.d.ts
|
|
1319
|
+
declare const envSchema$3: alepha79.TObject<{
|
|
1320
|
+
REACT_STRICT_MODE: alepha79.TBoolean;
|
|
1321
|
+
}>;
|
|
1322
|
+
declare module "alepha" {
|
|
1323
|
+
interface Env extends Partial<Static<typeof envSchema$3>> {}
|
|
1324
|
+
}
|
|
1325
|
+
interface PageRouteEntry extends Omit<PageDescriptorOptions, "children" | "parent"> {
|
|
1326
|
+
children?: PageRouteEntry[];
|
|
1327
|
+
}
|
|
1328
|
+
interface PageRoute extends PageRouteEntry {
|
|
1329
|
+
type: "page";
|
|
1330
|
+
name: string;
|
|
1331
|
+
parent?: PageRoute;
|
|
1332
|
+
match: string;
|
|
1333
|
+
}
|
|
1334
|
+
interface Layer {
|
|
1335
|
+
config?: {
|
|
1336
|
+
query?: Record<string, any>;
|
|
1337
|
+
params?: Record<string, any>;
|
|
1338
|
+
context?: Record<string, any>;
|
|
1339
|
+
};
|
|
1340
|
+
name: string;
|
|
1341
|
+
props?: Record<string, any>;
|
|
1342
|
+
error?: Error;
|
|
1343
|
+
part?: string;
|
|
1344
|
+
element: ReactNode;
|
|
1345
|
+
index: number;
|
|
1346
|
+
path: string;
|
|
1347
|
+
route?: PageRoute;
|
|
1348
|
+
cache?: boolean;
|
|
1349
|
+
}
|
|
1350
|
+
type PreviousLayerData = Omit<Layer, "element" | "index" | "path">;
|
|
1351
|
+
interface ReactRouterState {
|
|
1352
|
+
/**
|
|
1353
|
+
* Stack of layers for the current page.
|
|
1354
|
+
*/
|
|
1355
|
+
layers: Array<Layer>;
|
|
1356
|
+
/**
|
|
1357
|
+
* URL of the current page.
|
|
1358
|
+
*/
|
|
1359
|
+
url: URL;
|
|
1360
|
+
/**
|
|
1361
|
+
* Error handler for the current page.
|
|
1362
|
+
*/
|
|
1363
|
+
onError: ErrorHandler;
|
|
1364
|
+
/**
|
|
1365
|
+
* Params extracted from the URL for the current page.
|
|
1366
|
+
*/
|
|
1367
|
+
params: Record<string, any>;
|
|
1368
|
+
/**
|
|
1369
|
+
* Query parameters extracted from the URL for the current page.
|
|
1370
|
+
*/
|
|
1371
|
+
query: Record<string, string>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Optional meta information associated with the current page.
|
|
1374
|
+
*/
|
|
1375
|
+
meta: Record<string, any>;
|
|
1376
|
+
}
|
|
1377
|
+
interface TransitionOptions {
|
|
1378
|
+
previous?: PreviousLayerData[];
|
|
1379
|
+
}
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region ../react/src/core/services/ReactPageService.d.ts
|
|
1382
|
+
declare class ReactPageService {
|
|
1383
|
+
fetch(pathname: string, options?: PageDescriptorRenderOptions): Promise<{
|
|
1384
|
+
html: string;
|
|
1385
|
+
response: Response;
|
|
1386
|
+
}>;
|
|
1387
|
+
render(name: string, options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
|
|
1388
|
+
}
|
|
1389
|
+
//#endregion
|
|
1390
|
+
//#region ../react/src/core/descriptors/$page.d.ts
|
|
1391
|
+
interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
1392
|
+
/**
|
|
1393
|
+
* Identifier name for the page. Must be unique.
|
|
1394
|
+
*
|
|
1395
|
+
* @default Descriptor key
|
|
1396
|
+
*/
|
|
1397
|
+
name?: string;
|
|
1398
|
+
/**
|
|
1399
|
+
* Add a pathname to the page.
|
|
1400
|
+
*
|
|
1401
|
+
* Pathname can contain parameters, like `/post/:slug`.
|
|
1402
|
+
*
|
|
1403
|
+
* @default ""
|
|
1404
|
+
*/
|
|
1405
|
+
path?: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* Add an input schema to define:
|
|
1408
|
+
* - `params`: parameters from the pathname.
|
|
1409
|
+
* - `query`: query parameters from the URL.
|
|
1410
|
+
*/
|
|
1411
|
+
schema?: TConfig;
|
|
1412
|
+
/**
|
|
1413
|
+
* Load data before rendering the page.
|
|
1414
|
+
*
|
|
1415
|
+
* This function receives
|
|
1416
|
+
* - the request context and
|
|
1417
|
+
* - the parent props (if page has a parent)
|
|
1418
|
+
*
|
|
1419
|
+
* In SSR, the returned data will be serialized and sent to the client, then reused during the client-side hydration.
|
|
1420
|
+
*
|
|
1421
|
+
* Resolve can be stopped by throwing an error, which will be handled by the `errorHandler` function.
|
|
1422
|
+
* It's common to throw a `NotFoundError` to display a 404 page.
|
|
1423
|
+
*
|
|
1424
|
+
* RedirectError can be thrown to redirect the user to another page.
|
|
1425
|
+
*/
|
|
1426
|
+
resolve?: (context: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
|
|
1427
|
+
/**
|
|
1428
|
+
* The component to render when the page is loaded.
|
|
1429
|
+
*
|
|
1430
|
+
* If `lazy` is defined, this will be ignored.
|
|
1431
|
+
* Prefer using `lazy` to improve the initial loading time.
|
|
1432
|
+
*/
|
|
1433
|
+
component?: FC<TProps & TPropsParent>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Lazy load the component when the page is loaded.
|
|
1436
|
+
*
|
|
1437
|
+
* It's recommended to use this for components to improve the initial loading time
|
|
1438
|
+
* and enable code-splitting.
|
|
1439
|
+
*/
|
|
1440
|
+
lazy?: () => Promise<{
|
|
1441
|
+
default: FC<TProps & TPropsParent>;
|
|
1442
|
+
}>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Attach child pages to create nested routes.
|
|
1445
|
+
* This will make the page a parent route.
|
|
1446
|
+
*/
|
|
1447
|
+
children?: Array<PageDescriptor> | (() => Array<PageDescriptor>);
|
|
1448
|
+
/**
|
|
1449
|
+
* Define a parent page for nested routing.
|
|
1450
|
+
*/
|
|
1451
|
+
parent?: PageDescriptor<PageConfigSchema, TPropsParent, any>;
|
|
1452
|
+
can?: () => boolean;
|
|
1453
|
+
/**
|
|
1454
|
+
* Catch any error from the `resolve` function or during `rendering`.
|
|
1455
|
+
*
|
|
1456
|
+
* Expected to return one of the following:
|
|
1457
|
+
* - a ReactNode to render an error page
|
|
1458
|
+
* - a Redirection to redirect the user
|
|
1459
|
+
* - undefined to let the error propagate
|
|
1460
|
+
*
|
|
1461
|
+
* If not defined, the error will be thrown and handled by the server or client error handler.
|
|
1462
|
+
* If a leaf $page does not define an error handler, the error can be caught by parent pages.
|
|
1463
|
+
*
|
|
1464
|
+
* @example Catch a 404 from API and render a custom not found component:
|
|
1465
|
+
* ```ts
|
|
1466
|
+
* resolve: async ({ params, query }) => {
|
|
1467
|
+
* api.fetch("/api/resource", { params, query });
|
|
1468
|
+
* },
|
|
1469
|
+
* errorHandler: (error, context) => {
|
|
1470
|
+
* if (HttpError.is(error, 404)) {
|
|
1471
|
+
* return <ResourceNotFound />;
|
|
1472
|
+
* }
|
|
1473
|
+
* }
|
|
1474
|
+
* ```
|
|
1475
|
+
*
|
|
1476
|
+
* @example Catch an 401 error and redirect the user to the login page:
|
|
1477
|
+
* ```ts
|
|
1478
|
+
* resolve: async ({ params, query }) => {
|
|
1479
|
+
* // but the user is not authenticated
|
|
1480
|
+
* api.fetch("/api/resource", { params, query });
|
|
1481
|
+
* },
|
|
1482
|
+
* errorHandler: (error, context) => {
|
|
1483
|
+
* if (HttpError.is(error, 401)) {
|
|
1484
|
+
* // throwing a Redirection is also valid!
|
|
1485
|
+
* return new Redirection("/login");
|
|
1486
|
+
* }
|
|
1487
|
+
* }
|
|
1488
|
+
* ```
|
|
1489
|
+
*/
|
|
1490
|
+
errorHandler?: ErrorHandler;
|
|
1491
|
+
/**
|
|
1492
|
+
* If true, the page will be considered as a static page, immutable and cacheable.
|
|
1493
|
+
* Replace boolean by an object to define static entries. (e.g. list of params/query)
|
|
1494
|
+
*
|
|
1495
|
+
* Browser-side: it only works with `alepha/vite`, which can pre-render the page at build time.
|
|
1496
|
+
*
|
|
1497
|
+
* Server-side: It will act as timeless cached page. You can use `cache` to configure the cache behavior.
|
|
1498
|
+
*/
|
|
1499
|
+
static?: boolean | {
|
|
1500
|
+
entries?: Array<Partial<PageRequestConfig<TConfig>>>;
|
|
1501
|
+
};
|
|
1502
|
+
cache?: ServerRouteCache;
|
|
1503
|
+
/**
|
|
1504
|
+
* If true, force the page to be rendered only on the client-side (browser).
|
|
1505
|
+
* It uses the `<ClientOnly/>` component to render the page.
|
|
1506
|
+
*/
|
|
1507
|
+
client?: boolean | ClientOnlyProps;
|
|
1508
|
+
/**
|
|
1509
|
+
* Called before the server response is sent to the client. (server only)
|
|
1510
|
+
*/
|
|
1511
|
+
onServerResponse?: (request: ServerRequest) => unknown;
|
|
1512
|
+
/**
|
|
1513
|
+
* Called when user leaves the page. (browser only)
|
|
1514
|
+
*/
|
|
1515
|
+
onLeave?: () => void;
|
|
1516
|
+
/**
|
|
1517
|
+
* @experimental
|
|
1518
|
+
*
|
|
1519
|
+
* Add a css animation when the page is loaded or unloaded.
|
|
1520
|
+
* It uses CSS animations, so you need to define the keyframes in your CSS.
|
|
1521
|
+
*
|
|
1522
|
+
* @example Simple animation name
|
|
1523
|
+
* ```ts
|
|
1524
|
+
* animation: "fadeIn"
|
|
1525
|
+
* ```
|
|
1526
|
+
*
|
|
1527
|
+
* CSS example:
|
|
1528
|
+
* ```css
|
|
1529
|
+
* @keyframes fadeIn {
|
|
1530
|
+
* from { opacity: 0; }
|
|
1531
|
+
* to { opacity: 1; }
|
|
1532
|
+
* }
|
|
1533
|
+
* ```
|
|
1534
|
+
*
|
|
1535
|
+
* @example Detailed animation
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* animation: {
|
|
1538
|
+
* enter: { name: "fadeIn", duration: 300 },
|
|
1539
|
+
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
1540
|
+
* }
|
|
1541
|
+
* ```
|
|
1542
|
+
*
|
|
1543
|
+
* @example Only exit animation
|
|
1544
|
+
* ```ts
|
|
1545
|
+
* animation: {
|
|
1546
|
+
* exit: "fadeOut"
|
|
1547
|
+
* }
|
|
1548
|
+
* ```
|
|
1549
|
+
*
|
|
1550
|
+
* @example With custom timing function
|
|
1551
|
+
* ```ts
|
|
1552
|
+
* animation: {
|
|
1553
|
+
* enter: { name: "fadeIn", duration: 300, timing: "cubic-bezier(0.4, 0, 0.2, 1)" },
|
|
1554
|
+
* exit: { name: "fadeOut", duration: 200, timing: "ease-in-out" },
|
|
1555
|
+
* }
|
|
1556
|
+
* ```
|
|
1557
|
+
*/
|
|
1558
|
+
animation?: PageAnimation;
|
|
1559
|
+
}
|
|
1560
|
+
type ErrorHandler = (error: Error, state: ReactRouterState) => ReactNode | Redirection | undefined;
|
|
1561
|
+
declare class PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {
|
|
1562
|
+
protected readonly reactPageService: ReactPageService;
|
|
1563
|
+
protected onInit(): void;
|
|
1564
|
+
get name(): string;
|
|
1565
|
+
/**
|
|
1566
|
+
* For testing or build purposes.
|
|
1567
|
+
*
|
|
1568
|
+
* This will render the page (HTML layout included or not) and return the HTML + context.
|
|
1569
|
+
* Only valid for server-side rendering, it will throw an error if called on the client-side.
|
|
1570
|
+
*/
|
|
1571
|
+
render(options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
|
|
1572
|
+
fetch(options?: PageDescriptorRenderOptions): Promise<{
|
|
1573
|
+
html: string;
|
|
1574
|
+
response: Response;
|
|
1575
|
+
}>;
|
|
1576
|
+
match(url: string): boolean;
|
|
1577
|
+
pathname(config: any): string;
|
|
1578
|
+
}
|
|
1579
|
+
interface PageConfigSchema {
|
|
1580
|
+
query?: TSchema;
|
|
1581
|
+
params?: TSchema;
|
|
1582
|
+
}
|
|
1583
|
+
type TPropsDefault = any;
|
|
1584
|
+
type TPropsParentDefault = {};
|
|
1585
|
+
interface PageDescriptorRenderOptions {
|
|
1586
|
+
params?: Record<string, string>;
|
|
1587
|
+
query?: Record<string, string>;
|
|
1588
|
+
/**
|
|
1589
|
+
* If true, the HTML layout will be included in the response.
|
|
1590
|
+
* If false, only the page content will be returned.
|
|
1591
|
+
*
|
|
1592
|
+
* @default true
|
|
1593
|
+
*/
|
|
1594
|
+
html?: boolean;
|
|
1595
|
+
hydration?: boolean;
|
|
1596
|
+
}
|
|
1597
|
+
interface PageDescriptorRenderResult {
|
|
1598
|
+
html: string;
|
|
1599
|
+
state: ReactRouterState;
|
|
1600
|
+
redirect?: string;
|
|
1601
|
+
}
|
|
1602
|
+
interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
|
|
1603
|
+
params: TConfig["params"] extends TSchema ? Static<TConfig["params"]> : Record<string, string>;
|
|
1604
|
+
query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
|
|
1605
|
+
}
|
|
1606
|
+
type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & Omit<ReactRouterState, "layers" | "onError">;
|
|
1607
|
+
type PageAnimation = PageAnimationObject | ((state: ReactRouterState) => PageAnimationObject | undefined);
|
|
1608
|
+
type PageAnimationObject = CssAnimationName | {
|
|
1609
|
+
enter?: CssAnimation | CssAnimationName;
|
|
1610
|
+
exit?: CssAnimation | CssAnimationName;
|
|
1611
|
+
};
|
|
1612
|
+
type CssAnimationName = string;
|
|
1613
|
+
type CssAnimation = {
|
|
1614
|
+
name: string;
|
|
1615
|
+
duration?: number;
|
|
1616
|
+
timing?: string;
|
|
1617
|
+
};
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region ../alepha/src/security/schemas/userAccountInfoSchema.d.ts
|
|
1620
|
+
declare const userAccountInfoSchema: alepha79.TObject<{
|
|
1621
|
+
id: alepha79.TString;
|
|
1622
|
+
name: alepha79.TOptional<alepha79.TString>;
|
|
1623
|
+
email: alepha79.TOptional<alepha79.TString>;
|
|
1624
|
+
username: alepha79.TOptional<alepha79.TString>;
|
|
1625
|
+
picture: alepha79.TOptional<alepha79.TString>;
|
|
1626
|
+
sessionId: alepha79.TOptional<alepha79.TString>;
|
|
1627
|
+
organizations: alepha79.TOptional<alepha79.TArray<alepha79.TString>>;
|
|
1628
|
+
roles: alepha79.TOptional<alepha79.TArray<alepha79.TString>>;
|
|
1629
|
+
}>;
|
|
1630
|
+
type UserAccount = Static<typeof userAccountInfoSchema>;
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region ../alepha/src/security/interfaces/UserAccountToken.d.ts
|
|
1633
|
+
/**
|
|
1634
|
+
* Add contextual metadata to a user account info.
|
|
1635
|
+
* E.g. UserAccountToken is a UserAccountInfo during a request.
|
|
1636
|
+
*/
|
|
1637
|
+
interface UserAccountToken extends UserAccount {
|
|
1638
|
+
/**
|
|
1639
|
+
* Access token for the user.
|
|
1640
|
+
*/
|
|
1641
|
+
token?: string;
|
|
1642
|
+
/**
|
|
1643
|
+
* Realm name of the user.
|
|
1644
|
+
*/
|
|
1645
|
+
realm?: string;
|
|
1646
|
+
/**
|
|
1647
|
+
* Is user dedicated to his own resources for this scope ?
|
|
1648
|
+
* Mostly, Admin is false and Customer is true.
|
|
1649
|
+
*/
|
|
1650
|
+
ownership?: string | boolean;
|
|
1651
|
+
}
|
|
1652
|
+
//#endregion
|
|
1653
|
+
//#region ../alepha/src/security/providers/SecurityProvider.d.ts
|
|
1654
|
+
declare const envSchema$2: alepha79.TObject<{
|
|
1655
|
+
APP_SECRET: alepha79.TString;
|
|
1656
|
+
}>;
|
|
1657
|
+
declare module "alepha" {
|
|
1658
|
+
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
1659
|
+
}
|
|
1660
|
+
//#endregion
|
|
1661
|
+
//#region ../alepha/src/security/index.d.ts
|
|
1662
|
+
declare module "alepha" {
|
|
1663
|
+
interface Hooks {
|
|
1664
|
+
"security:user:created": {
|
|
1665
|
+
realm: string;
|
|
1666
|
+
user: UserAccount;
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
|
|
1672
|
+
*
|
|
1673
|
+
* The security module enables building secure applications using descriptors like `$realm`, `$role`, and `$permission`
|
|
1674
|
+
* on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
|
|
1675
|
+
* integration with various authentication providers and user management systems.
|
|
1676
|
+
*
|
|
1677
|
+
* @see {@link $realm}
|
|
1678
|
+
* @see {@link $role}
|
|
1679
|
+
* @see {@link $permission}
|
|
1680
|
+
* @module alepha.security
|
|
1681
|
+
*/
|
|
1682
|
+
//#endregion
|
|
1683
|
+
//#region ../alepha/src/server-security/providers/ServerBasicAuthProvider.d.ts
|
|
1684
|
+
interface BasicAuthOptions {
|
|
1685
|
+
username: string;
|
|
1686
|
+
password: string;
|
|
1687
|
+
}
|
|
1688
|
+
//#endregion
|
|
1689
|
+
//#region ../alepha/src/server-security/providers/ServerSecurityProvider.d.ts
|
|
1690
|
+
type ServerRouteSecure = {
|
|
1691
|
+
realm?: string;
|
|
1692
|
+
basic?: BasicAuthOptions;
|
|
1693
|
+
};
|
|
1694
|
+
//#endregion
|
|
1695
|
+
//#region ../alepha/src/server-security/index.d.ts
|
|
1696
|
+
declare module "alepha" {
|
|
1697
|
+
interface State {
|
|
1698
|
+
/**
|
|
1699
|
+
* Real (or fake) user account, used for internal actions.
|
|
1700
|
+
*
|
|
1701
|
+
* If you define this, you assume that all actions are executed by this user by default.
|
|
1702
|
+
* > To force a different user, you need to pass it explicitly in the options.
|
|
1703
|
+
*/
|
|
1704
|
+
"alepha.server.security.system.user"?: UserAccountToken;
|
|
1705
|
+
/**
|
|
1706
|
+
* The authenticated user account attached to the server request state.
|
|
1707
|
+
*
|
|
1708
|
+
* @internal
|
|
1709
|
+
*/
|
|
1710
|
+
"alepha.server.request.user"?: UserAccount;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
declare module "alepha/server" {
|
|
1714
|
+
interface ServerRequest<TConfig> {
|
|
1715
|
+
user?: UserAccountToken;
|
|
1716
|
+
}
|
|
1717
|
+
interface ServerActionRequest<TConfig> {
|
|
1718
|
+
user: UserAccountToken;
|
|
1719
|
+
}
|
|
1720
|
+
interface ServerRoute {
|
|
1721
|
+
/**
|
|
1722
|
+
* If true, the route will be protected by the security provider.
|
|
1723
|
+
* All actions are secure by default, but you can disable it for specific actions.
|
|
1724
|
+
*/
|
|
1725
|
+
secure?: boolean | ServerRouteSecure;
|
|
1726
|
+
}
|
|
1727
|
+
interface ClientRequestOptions extends FetchOptions {
|
|
1728
|
+
/**
|
|
1729
|
+
* Forward user from the previous request.
|
|
1730
|
+
* If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
|
|
1731
|
+
* If "context", use the user from the current context (e.g. request).
|
|
1732
|
+
*
|
|
1733
|
+
* @default "system" if provided, else "context" if available.
|
|
1734
|
+
*/
|
|
1735
|
+
user?: UserAccountToken | "system" | "context";
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Plugin for Alepha Server that provides security features. Based on the Alepha Security module.
|
|
1740
|
+
*
|
|
1741
|
+
* By default, all $action will be guarded by a permission check.
|
|
1742
|
+
*
|
|
1743
|
+
* @see {@link ServerSecurityProvider}
|
|
1744
|
+
* @module alepha.server.security
|
|
1745
|
+
*/
|
|
1746
|
+
//#endregion
|
|
1747
|
+
//#region ../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
|
|
1748
|
+
declare const apiLinksResponseSchema: alepha79.TObject<{
|
|
1749
|
+
prefix: alepha79.TOptional<alepha79.TString>;
|
|
1750
|
+
links: alepha79.TArray<alepha79.TObject<{
|
|
1751
|
+
name: alepha79.TString;
|
|
1752
|
+
group: alepha79.TOptional<alepha79.TString>;
|
|
1753
|
+
path: alepha79.TString;
|
|
1754
|
+
method: alepha79.TOptional<alepha79.TString>;
|
|
1755
|
+
requestBodyType: alepha79.TOptional<alepha79.TString>;
|
|
1756
|
+
service: alepha79.TOptional<alepha79.TString>;
|
|
1757
|
+
}>>;
|
|
1758
|
+
}>;
|
|
1759
|
+
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
1760
|
+
//#endregion
|
|
1761
|
+
//#region ../alepha/src/server-links/index.d.ts
|
|
1762
|
+
declare module "alepha" {
|
|
1763
|
+
interface State {
|
|
1764
|
+
/**
|
|
1765
|
+
* API links attached to the server request state.
|
|
1766
|
+
*
|
|
1767
|
+
* @see {@link ApiLinksResponse}
|
|
1768
|
+
* @internal
|
|
1769
|
+
*/
|
|
1770
|
+
"alepha.server.request.apiLinks"?: ApiLinksResponse;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Provides server-side link management and remote capabilities for client-server interactions.
|
|
1775
|
+
*
|
|
1776
|
+
* The server-links module enables declarative link definitions using `$remote` and `$client` descriptors,
|
|
1777
|
+
* facilitating seamless API endpoint management and client-server communication. It integrates with server
|
|
1778
|
+
* security features to ensure safe and controlled access to resources.
|
|
1779
|
+
*
|
|
1780
|
+
* @see {@link $remote}
|
|
1781
|
+
* @see {@link $client}
|
|
1782
|
+
* @module alepha.server.links
|
|
1783
|
+
*/
|
|
1784
|
+
//#endregion
|
|
1785
|
+
//#region ../react/src/core/providers/ReactBrowserProvider.d.ts
|
|
1786
|
+
declare const envSchema$1: alepha79.TObject<{
|
|
1787
|
+
REACT_ROOT_ID: alepha79.TString;
|
|
1788
|
+
}>;
|
|
1789
|
+
declare module "alepha" {
|
|
1790
|
+
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* React browser renderer configuration atom
|
|
1794
|
+
*/
|
|
1795
|
+
declare const reactBrowserOptions: alepha79.Atom<alepha79.TObject<{
|
|
1796
|
+
scrollRestoration: alepha79.TUnsafe<"top" | "manual">;
|
|
1797
|
+
}>, "alepha.react.browser.options">;
|
|
1798
|
+
type ReactBrowserRendererOptions = Static<typeof reactBrowserOptions.schema>;
|
|
1799
|
+
declare module "alepha" {
|
|
1800
|
+
interface State {
|
|
1801
|
+
[reactBrowserOptions.key]: ReactBrowserRendererOptions;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
interface RouterGoOptions {
|
|
1805
|
+
replace?: boolean;
|
|
1806
|
+
match?: TransitionOptions;
|
|
1807
|
+
params?: Record<string, string>;
|
|
1808
|
+
query?: Record<string, string>;
|
|
1809
|
+
meta?: Record<string, any>;
|
|
1810
|
+
/**
|
|
1811
|
+
* Recreate the whole page, ignoring the current state.
|
|
1812
|
+
*/
|
|
1813
|
+
force?: boolean;
|
|
1814
|
+
}
|
|
1815
|
+
type ReactHydrationState = {
|
|
1816
|
+
layers?: Array<PreviousLayerData>;
|
|
1817
|
+
} & {
|
|
1818
|
+
[key: string]: any;
|
|
1819
|
+
};
|
|
1820
|
+
//#endregion
|
|
1821
|
+
//#region ../react/src/core/hooks/useAction.d.ts
|
|
1822
|
+
interface UseActionReturn<Args extends any[], Result> {
|
|
1823
|
+
/**
|
|
1824
|
+
* Execute the action with the provided arguments.
|
|
1825
|
+
*
|
|
1826
|
+
* @example
|
|
1827
|
+
* ```tsx
|
|
1828
|
+
* const action = useAction({ handler: async (data) => { ... } }, []);
|
|
1829
|
+
* action.run(data);
|
|
1830
|
+
* ```
|
|
1831
|
+
*/
|
|
1832
|
+
run: (...args: Args) => Promise<Result | undefined>;
|
|
1833
|
+
/**
|
|
1834
|
+
* Loading state - true when action is executing.
|
|
1835
|
+
*/
|
|
1836
|
+
loading: boolean;
|
|
1837
|
+
/**
|
|
1838
|
+
* Error state - contains error if action failed, undefined otherwise.
|
|
1839
|
+
*/
|
|
1840
|
+
error?: Error;
|
|
1841
|
+
/**
|
|
1842
|
+
* Cancel any pending debounced action or abort the current in-flight request.
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```tsx
|
|
1846
|
+
* const action = useAction({ ... }, []);
|
|
1847
|
+
*
|
|
1848
|
+
* <button onClick={action.cancel} disabled={!action.loading}>
|
|
1849
|
+
* Cancel
|
|
1850
|
+
* </button>
|
|
1851
|
+
* ```
|
|
1852
|
+
*/
|
|
1853
|
+
cancel: () => void;
|
|
1854
|
+
}
|
|
1855
|
+
//#endregion
|
|
1856
|
+
//#region ../react/src/core/hooks/useActive.d.ts
|
|
1857
|
+
interface UseActiveOptions {
|
|
1858
|
+
href: string;
|
|
1859
|
+
startWith?: boolean;
|
|
1860
|
+
}
|
|
1861
|
+
//#endregion
|
|
1862
|
+
//#region ../react/src/core/providers/ReactServerProvider.d.ts
|
|
1863
|
+
declare const envSchema: alepha79.TObject<{
|
|
1864
|
+
REACT_SSR_ENABLED: alepha79.TOptional<alepha79.TBoolean>;
|
|
1865
|
+
REACT_ROOT_ID: alepha79.TString;
|
|
1866
|
+
REACT_SERVER_TEMPLATE: alepha79.TOptional<alepha79.TString>;
|
|
1867
|
+
}>;
|
|
1868
|
+
declare module "alepha" {
|
|
1869
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1870
|
+
interface State {
|
|
1871
|
+
"alepha.react.server.ssr"?: boolean;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* React server provider configuration atom
|
|
1876
|
+
*/
|
|
1877
|
+
declare const reactServerOptions: alepha79.Atom<alepha79.TObject<{
|
|
1878
|
+
publicDir: alepha79.TString;
|
|
1879
|
+
staticServer: alepha79.TObject<{
|
|
1880
|
+
disabled: alepha79.TBoolean;
|
|
1881
|
+
path: alepha79.TString;
|
|
1882
|
+
}>;
|
|
1883
|
+
}>, "alepha.react.server.options">;
|
|
1884
|
+
type ReactServerProviderOptions = Static<typeof reactServerOptions.schema>;
|
|
1885
|
+
declare module "alepha" {
|
|
1886
|
+
interface State {
|
|
1887
|
+
[reactServerOptions.key]: ReactServerProviderOptions;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
//#endregion
|
|
1891
|
+
//#region ../react/src/core/index.d.ts
|
|
1892
|
+
declare module "alepha" {
|
|
1893
|
+
interface State {
|
|
1894
|
+
"alepha.react.router.state"?: ReactRouterState;
|
|
1895
|
+
}
|
|
1896
|
+
interface Hooks {
|
|
1897
|
+
/**
|
|
1898
|
+
* Fires when the React application is starting to be rendered on the server.
|
|
1899
|
+
*/
|
|
1900
|
+
"react:server:render:begin": {
|
|
1901
|
+
request?: ServerRequest;
|
|
1902
|
+
state: ReactRouterState;
|
|
1903
|
+
};
|
|
1904
|
+
/**
|
|
1905
|
+
* Fires when the React application has been rendered on the server.
|
|
1906
|
+
*/
|
|
1907
|
+
"react:server:render:end": {
|
|
1908
|
+
request?: ServerRequest;
|
|
1909
|
+
state: ReactRouterState;
|
|
1910
|
+
html: string;
|
|
1911
|
+
};
|
|
1912
|
+
/**
|
|
1913
|
+
* Fires when the React application is being rendered on the browser.
|
|
1914
|
+
*/
|
|
1915
|
+
"react:browser:render": {
|
|
1916
|
+
root: HTMLElement;
|
|
1917
|
+
element: ReactNode;
|
|
1918
|
+
state: ReactRouterState;
|
|
1919
|
+
hydration?: ReactHydrationState;
|
|
1920
|
+
};
|
|
1921
|
+
/**
|
|
1922
|
+
* Fires when a user action is starting.
|
|
1923
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
1924
|
+
*/
|
|
1925
|
+
"react:action:begin": {
|
|
1926
|
+
type: string;
|
|
1927
|
+
id?: string;
|
|
1928
|
+
};
|
|
1929
|
+
/**
|
|
1930
|
+
* Fires when a user action has succeeded.
|
|
1931
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
1932
|
+
*/
|
|
1933
|
+
"react:action:success": {
|
|
1934
|
+
type: string;
|
|
1935
|
+
id?: string;
|
|
1936
|
+
};
|
|
1937
|
+
/**
|
|
1938
|
+
* Fires when a user action has failed.
|
|
1939
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
1940
|
+
*/
|
|
1941
|
+
"react:action:error": {
|
|
1942
|
+
type: string;
|
|
1943
|
+
id?: string;
|
|
1944
|
+
error: Error;
|
|
1945
|
+
};
|
|
1946
|
+
/**
|
|
1947
|
+
* Fires when a user action has completed, regardless of success or failure.
|
|
1948
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
1949
|
+
*/
|
|
1950
|
+
"react:action:end": {
|
|
1951
|
+
type: string;
|
|
1952
|
+
id?: string;
|
|
1953
|
+
};
|
|
1954
|
+
/**
|
|
1955
|
+
* Fires when a route transition is starting.
|
|
1956
|
+
*/
|
|
1957
|
+
"react:transition:begin": {
|
|
1958
|
+
previous: ReactRouterState;
|
|
1959
|
+
state: ReactRouterState;
|
|
1960
|
+
animation?: PageAnimation;
|
|
1961
|
+
};
|
|
1962
|
+
/**
|
|
1963
|
+
* Fires when a route transition has succeeded.
|
|
1964
|
+
*/
|
|
1965
|
+
"react:transition:success": {
|
|
1966
|
+
state: ReactRouterState;
|
|
1967
|
+
};
|
|
1968
|
+
/**
|
|
1969
|
+
* Fires when a route transition has failed.
|
|
1970
|
+
*/
|
|
1971
|
+
"react:transition:error": {
|
|
1972
|
+
state: ReactRouterState;
|
|
1973
|
+
error: Error;
|
|
1974
|
+
};
|
|
1975
|
+
/**
|
|
1976
|
+
* Fires when a route transition has completed, regardless of success or failure.
|
|
1977
|
+
*/
|
|
1978
|
+
"react:transition:end": {
|
|
1979
|
+
state: ReactRouterState;
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.
|
|
1985
|
+
*
|
|
1986
|
+
* The React module enables building modern React applications using the `$page` descriptor on class properties.
|
|
1987
|
+
* It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full
|
|
1988
|
+
* type safety and schema validation for route parameters and data.
|
|
1989
|
+
*
|
|
1990
|
+
* @see {@link $page}
|
|
1991
|
+
* @module alepha.react
|
|
1992
|
+
*/
|
|
1993
|
+
//#endregion
|
|
1994
|
+
//#region src/core/components/buttons/ActionButton.d.ts
|
|
1995
|
+
interface ActionMenuItem {
|
|
1996
|
+
/**
|
|
1997
|
+
* Menu item type
|
|
1998
|
+
*/
|
|
1999
|
+
type?: "item" | "divider" | "label";
|
|
2000
|
+
/**
|
|
2001
|
+
* Label text for the menu item
|
|
2002
|
+
*/
|
|
2003
|
+
label?: string | ReactNode;
|
|
2004
|
+
/**
|
|
2005
|
+
* Icon element to display before the label
|
|
2006
|
+
*/
|
|
2007
|
+
icon?: ReactNode;
|
|
2008
|
+
/**
|
|
2009
|
+
* Click handler for menu items
|
|
2010
|
+
*/
|
|
2011
|
+
onClick?: () => void;
|
|
2012
|
+
/**
|
|
2013
|
+
* Href for navigation menu items
|
|
2014
|
+
*/
|
|
2015
|
+
href?: string;
|
|
2016
|
+
/**
|
|
2017
|
+
* Color for the menu item (e.g., "red" for danger actions)
|
|
2018
|
+
*/
|
|
2019
|
+
color?: string;
|
|
2020
|
+
/**
|
|
2021
|
+
* Nested submenu items
|
|
2022
|
+
*/
|
|
2023
|
+
children?: ActionMenuItem[];
|
|
2024
|
+
/**
|
|
2025
|
+
* Whether the menu item is active
|
|
2026
|
+
*/
|
|
2027
|
+
active?: boolean;
|
|
2028
|
+
}
|
|
2029
|
+
interface ActionMenuConfig {
|
|
2030
|
+
/**
|
|
2031
|
+
* Array of menu items to display
|
|
2032
|
+
*/
|
|
2033
|
+
items: ActionMenuItem[];
|
|
2034
|
+
/**
|
|
2035
|
+
* Menu position relative to the button
|
|
2036
|
+
*/
|
|
2037
|
+
position?: "bottom" | "bottom-start" | "bottom-end" | "top" | "top-start" | "top-end" | "left" | "right";
|
|
2038
|
+
/**
|
|
2039
|
+
* Menu width
|
|
2040
|
+
*/
|
|
2041
|
+
width?: number | string;
|
|
2042
|
+
/**
|
|
2043
|
+
* Menu shadow
|
|
2044
|
+
*/
|
|
2045
|
+
shadow?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
2046
|
+
on?: "hover" | "click";
|
|
2047
|
+
targetProps?: MenuTargetProps;
|
|
2048
|
+
menuProps?: MenuProps;
|
|
2049
|
+
}
|
|
2050
|
+
interface ActionCommonProps extends ButtonProps {
|
|
2051
|
+
children?: ReactNode;
|
|
2052
|
+
textVisibleFrom?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
2053
|
+
/**
|
|
2054
|
+
* Tooltip to display on hover. Can be a string for simple tooltips
|
|
2055
|
+
* or a TooltipProps object for advanced configuration.
|
|
2056
|
+
*/
|
|
2057
|
+
tooltip?: string | TooltipProps;
|
|
2058
|
+
/**
|
|
2059
|
+
* Menu configuration. When provided, the action will display a dropdown menu.
|
|
2060
|
+
*/
|
|
2061
|
+
menu?: ActionMenuConfig;
|
|
2062
|
+
/**
|
|
2063
|
+
* If set, a confirmation dialog will be shown before performing the action.
|
|
2064
|
+
* If `true`, a default title and message will be used.
|
|
2065
|
+
* If a string, it will be used as the message with a default title.
|
|
2066
|
+
* If an object, it can contain `title` and `message` properties to customize the dialog.
|
|
2067
|
+
*/
|
|
2068
|
+
confirm?: boolean | string | {
|
|
2069
|
+
title?: string;
|
|
2070
|
+
message: string;
|
|
2071
|
+
};
|
|
2072
|
+
/**
|
|
2073
|
+
* Icon to display on the left side of the button.
|
|
2074
|
+
* If no children are provided, the button will be styled as an icon-only button.
|
|
2075
|
+
*/
|
|
2076
|
+
icon?: ReactNode | ComponentType;
|
|
2077
|
+
/**
|
|
2078
|
+
* Additional props to pass to the ThemeIcon wrapping the icon.
|
|
2079
|
+
*/
|
|
2080
|
+
themeIconProps?: ThemeIconProps;
|
|
2081
|
+
}
|
|
2082
|
+
type ActionProps = ActionCommonProps & (ActionNavigationButtonProps | ActionClickButtonProps | ActionSubmitButtonProps | ActionHookButtonProps | {});
|
|
2083
|
+
declare const ActionButton: (_props: ActionProps) => react_jsx_runtime4.JSX.Element;
|
|
2084
|
+
interface ActionSubmitButtonProps extends ButtonProps {
|
|
2085
|
+
form: FormModel<any>;
|
|
2086
|
+
type?: "submit" | "reset";
|
|
2087
|
+
}
|
|
2088
|
+
interface ActionHookButtonProps extends ButtonProps {
|
|
2089
|
+
action: UseActionReturn<any[], any>;
|
|
2090
|
+
}
|
|
2091
|
+
interface ActionClickButtonProps extends ButtonProps {
|
|
2092
|
+
onClick: (e: any) => any;
|
|
2093
|
+
}
|
|
2094
|
+
interface ActionNavigationButtonProps extends ButtonProps {
|
|
2095
|
+
href: string;
|
|
2096
|
+
active?: Partial<UseActiveOptions> | false;
|
|
2097
|
+
routerGoOptions?: RouterGoOptions;
|
|
2098
|
+
classNameActive?: string;
|
|
2099
|
+
variantActive?: ButtonProps["variant"];
|
|
2100
|
+
target?: string;
|
|
2101
|
+
anchorProps?: AnchorProps;
|
|
2102
|
+
}
|
|
2103
|
+
//#endregion
|
|
2104
|
+
//#region src/core/components/buttons/BurgerButton.d.ts
|
|
2105
|
+
interface BurgerButtonProps extends BurgerProps {}
|
|
2106
|
+
declare const BurgerButton: (props: BurgerButtonProps) => react_jsx_runtime4.JSX.Element;
|
|
2107
|
+
//#endregion
|
|
2108
|
+
//#region src/core/components/buttons/ClipboardButton.d.ts
|
|
2109
|
+
interface ClipboardButtonProps extends Omit<ActionCommonProps, "onClick" | "icon"> {
|
|
2110
|
+
/**
|
|
2111
|
+
* The value to copy to the clipboard
|
|
2112
|
+
*/
|
|
2113
|
+
value: string;
|
|
2114
|
+
/**
|
|
2115
|
+
* Timeout in ms to show the "Copied" state (default: 2000)
|
|
2116
|
+
*/
|
|
2117
|
+
timeout?: number;
|
|
2118
|
+
/**
|
|
2119
|
+
* Label to show in tooltip when not copied (default: "Copy")
|
|
2120
|
+
*/
|
|
2121
|
+
copyLabel?: string;
|
|
2122
|
+
/**
|
|
2123
|
+
* Label to show in tooltip when copied (default: "Copied")
|
|
2124
|
+
*/
|
|
2125
|
+
copiedLabel?: string;
|
|
2126
|
+
}
|
|
2127
|
+
declare const ClipboardButton: (props: ClipboardButtonProps) => react_jsx_runtime4.JSX.Element;
|
|
2128
|
+
//#endregion
|
|
2129
|
+
//#region src/core/components/buttons/DarkModeButton.d.ts
|
|
2130
|
+
interface DarkModeButtonProps {
|
|
2131
|
+
mode?: "minimal" | "segmented";
|
|
2132
|
+
size?: MantineBreakpoint;
|
|
2133
|
+
variant?: "filled" | "light" | "outline" | "default" | "subtle" | "transparent";
|
|
2134
|
+
fullWidth?: boolean;
|
|
2135
|
+
segmentedProps?: Partial<SegmentedControlProps>;
|
|
2136
|
+
actionProps?: Partial<ActionProps>;
|
|
2137
|
+
}
|
|
2138
|
+
declare const DarkModeButton: (props: DarkModeButtonProps) => react_jsx_runtime4.JSX.Element;
|
|
2139
|
+
//#endregion
|
|
2140
|
+
//#region src/core/components/buttons/LanguageButton.d.ts
|
|
2141
|
+
interface LanguageButtonProps {
|
|
2142
|
+
languages?: string[];
|
|
2143
|
+
actionProps?: ActionProps;
|
|
2144
|
+
}
|
|
2145
|
+
declare const LanguageButton: (props: LanguageButtonProps) => react_jsx_runtime4.JSX.Element;
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region src/core/components/buttons/OmnibarButton.d.ts
|
|
2148
|
+
interface OmnibarButtonProps {
|
|
2149
|
+
actionProps?: ActionProps;
|
|
2150
|
+
collapsed?: boolean;
|
|
2151
|
+
}
|
|
2152
|
+
declare const OmnibarButton: (props: OmnibarButtonProps) => react_jsx_runtime4.JSX.Element;
|
|
2153
|
+
//#endregion
|
|
2154
|
+
//#region src/core/components/data/JsonViewer.d.ts
|
|
2155
|
+
interface JsonViewerProps {
|
|
2156
|
+
data: any;
|
|
2157
|
+
defaultExpanded?: boolean;
|
|
2158
|
+
maxDepth?: number;
|
|
2159
|
+
copyable?: boolean;
|
|
2160
|
+
size?: MantineSize;
|
|
2161
|
+
}
|
|
2162
|
+
declare const JsonViewer: ({
|
|
2163
|
+
data,
|
|
2164
|
+
defaultExpanded,
|
|
2165
|
+
maxDepth,
|
|
2166
|
+
copyable,
|
|
2167
|
+
size
|
|
2168
|
+
}: JsonViewerProps) => react_jsx_runtime4.JSX.Element;
|
|
2169
|
+
//#endregion
|
|
2170
|
+
//#region src/core/services/DialogService.d.ts
|
|
2171
|
+
interface BaseDialogOptions extends Partial<ModalProps> {
|
|
2172
|
+
title?: ReactNode;
|
|
2173
|
+
message?: ReactNode;
|
|
2174
|
+
content?: any;
|
|
2175
|
+
}
|
|
2176
|
+
interface AlertDialogOptions extends BaseDialogOptions {
|
|
2177
|
+
okLabel?: string;
|
|
2178
|
+
}
|
|
2179
|
+
interface ConfirmDialogOptions extends BaseDialogOptions {
|
|
2180
|
+
confirmLabel?: string;
|
|
2181
|
+
cancelLabel?: string;
|
|
2182
|
+
confirmColor?: string;
|
|
2183
|
+
}
|
|
2184
|
+
interface PromptDialogOptions extends BaseDialogOptions {
|
|
2185
|
+
placeholder?: string;
|
|
2186
|
+
defaultValue?: string;
|
|
2187
|
+
label?: string;
|
|
2188
|
+
required?: boolean;
|
|
2189
|
+
submitLabel?: string;
|
|
2190
|
+
cancelLabel?: string;
|
|
2191
|
+
}
|
|
2192
|
+
interface AlertDialogProps {
|
|
2193
|
+
options?: AlertDialogOptions;
|
|
2194
|
+
onClose: () => void;
|
|
2195
|
+
}
|
|
2196
|
+
interface ConfirmDialogProps {
|
|
2197
|
+
options?: ConfirmDialogOptions;
|
|
2198
|
+
onConfirm: (confirmed: boolean) => void;
|
|
2199
|
+
}
|
|
2200
|
+
interface PromptDialogProps {
|
|
2201
|
+
options?: PromptDialogOptions;
|
|
2202
|
+
onSubmit: (value: string | null) => void;
|
|
2203
|
+
}
|
|
2204
|
+
interface DialogServiceOptions {
|
|
2205
|
+
default?: Partial<BaseDialogOptions>;
|
|
2206
|
+
}
|
|
2207
|
+
declare class DialogService {
|
|
2208
|
+
readonly options: DialogServiceOptions;
|
|
2209
|
+
/**
|
|
2210
|
+
* Show an alert dialog with a message
|
|
2211
|
+
*/
|
|
2212
|
+
alert(options?: AlertDialogOptions): Promise<void>;
|
|
2213
|
+
/**
|
|
2214
|
+
* Show a confirmation dialog that returns a promise
|
|
2215
|
+
*/
|
|
2216
|
+
confirm(options?: ConfirmDialogOptions): Promise<boolean>;
|
|
2217
|
+
/**
|
|
2218
|
+
* Show a prompt dialog to get user input
|
|
2219
|
+
*/
|
|
2220
|
+
prompt(options?: PromptDialogOptions): Promise<string | null>;
|
|
2221
|
+
/**
|
|
2222
|
+
* Open a custom dialog with provided content
|
|
2223
|
+
*/
|
|
2224
|
+
open(options?: BaseDialogOptions): string;
|
|
2225
|
+
/**
|
|
2226
|
+
* Close the currently open dialog or a specific dialog by ID
|
|
2227
|
+
*/
|
|
2228
|
+
close(modalId?: string): void;
|
|
2229
|
+
/**
|
|
2230
|
+
* Show a JSON editor/viewer dialog
|
|
2231
|
+
*/
|
|
2232
|
+
json(data?: any, options?: BaseDialogOptions): void;
|
|
2233
|
+
/**
|
|
2234
|
+
* Show a form dialog for structured input
|
|
2235
|
+
*/
|
|
2236
|
+
form(options?: BaseDialogOptions): Promise<any>;
|
|
2237
|
+
/**
|
|
2238
|
+
* Show a loading/progress dialog with optional progress percentage
|
|
2239
|
+
*/
|
|
2240
|
+
loading(options?: BaseDialogOptions & {
|
|
2241
|
+
progress?: number;
|
|
2242
|
+
}): void;
|
|
2243
|
+
/**
|
|
2244
|
+
* Show an image viewer/gallery dialog
|
|
2245
|
+
*/
|
|
2246
|
+
image(src: string | string[], options?: BaseDialogOptions): void;
|
|
2247
|
+
}
|
|
2248
|
+
//#endregion
|
|
2249
|
+
//#region src/core/components/dialogs/AlertDialog.d.ts
|
|
2250
|
+
declare const AlertDialog: ({
|
|
2251
|
+
options,
|
|
2252
|
+
onClose
|
|
2253
|
+
}: AlertDialogProps) => react_jsx_runtime4.JSX.Element;
|
|
2254
|
+
//#endregion
|
|
2255
|
+
//#region src/core/components/dialogs/ConfirmDialog.d.ts
|
|
2256
|
+
declare const ConfirmDialog: ({
|
|
2257
|
+
options,
|
|
2258
|
+
onConfirm
|
|
2259
|
+
}: ConfirmDialogProps) => react_jsx_runtime4.JSX.Element;
|
|
2260
|
+
//#endregion
|
|
2261
|
+
//#region src/core/components/dialogs/PromptDialog.d.ts
|
|
2262
|
+
declare const PromptDialog: ({
|
|
2263
|
+
options,
|
|
2264
|
+
onSubmit
|
|
2265
|
+
}: PromptDialogProps) => react_jsx_runtime4.JSX.Element;
|
|
2266
|
+
//#endregion
|
|
2267
|
+
//#region src/core/components/form/ControlDate.d.ts
|
|
2268
|
+
interface ControlDateProps extends GenericControlProps {
|
|
2269
|
+
date?: boolean | DateInputProps;
|
|
2270
|
+
datetime?: boolean | DateTimePickerProps;
|
|
2271
|
+
time?: boolean | TimeInputProps;
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* ControlDate component for handling date, datetime, and time inputs.
|
|
2275
|
+
*
|
|
2276
|
+
* Features:
|
|
2277
|
+
* - DateInput for date format
|
|
2278
|
+
* - DateTimePicker for date-time format
|
|
2279
|
+
* - TimeInput for time format
|
|
2280
|
+
*
|
|
2281
|
+
* Automatically detects date formats from schema and renders appropriate picker.
|
|
2282
|
+
*/
|
|
2283
|
+
declare const ControlDate: (props: ControlDateProps) => react_jsx_runtime4.JSX.Element | null;
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/core/components/form/ControlQueryBuilder.d.ts
|
|
2286
|
+
interface ControlQueryBuilderProps extends Omit<TextInputProps, "value" | "onChange"> {
|
|
2287
|
+
schema?: TObject;
|
|
2288
|
+
value?: string;
|
|
2289
|
+
onChange?: (value: string) => void;
|
|
2290
|
+
placeholder?: string;
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Query builder with text input and help popover.
|
|
2294
|
+
* Generates query strings for parseQueryString syntax.
|
|
2295
|
+
*/
|
|
2296
|
+
declare const ControlQueryBuilder: ({
|
|
2297
|
+
schema,
|
|
2298
|
+
value,
|
|
2299
|
+
onChange,
|
|
2300
|
+
placeholder,
|
|
2301
|
+
...textInputProps
|
|
2302
|
+
}: ControlQueryBuilderProps) => react_jsx_runtime4.JSX.Element;
|
|
2303
|
+
//#endregion
|
|
2304
|
+
//#region src/core/components/form/TypeForm.d.ts
|
|
2305
|
+
interface TypeFormProps<T$1 extends TObject> {
|
|
2306
|
+
form: FormModel<T$1>;
|
|
2307
|
+
columns?: number | {
|
|
2308
|
+
base?: number;
|
|
2309
|
+
xs?: number;
|
|
2310
|
+
sm?: number;
|
|
2311
|
+
md?: number;
|
|
2312
|
+
lg?: number;
|
|
2313
|
+
xl?: number;
|
|
2314
|
+
};
|
|
2315
|
+
schema?: TObject;
|
|
2316
|
+
children?: (input: FormModel<T$1>["input"]) => ReactNode;
|
|
2317
|
+
controlProps?: Partial<Omit<ControlProps, "input">>;
|
|
2318
|
+
skipFormElement?: boolean;
|
|
2319
|
+
skipSubmitButton?: boolean;
|
|
2320
|
+
submitButtonProps?: Partial<Omit<ActionSubmitButtonProps, "form">>;
|
|
2321
|
+
resetButtonProps?: Partial<Omit<ActionSubmitButtonProps, "form">>;
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* TypeForm component that automatically renders all form inputs based on schema.
|
|
2325
|
+
* Uses the Control component to render individual fields and Mantine Grid for responsive layout.
|
|
2326
|
+
*
|
|
2327
|
+
* @example
|
|
2328
|
+
* ```tsx
|
|
2329
|
+
* import { t } from "alepha";
|
|
2330
|
+
* import { useForm } from "@alepha/react/form";
|
|
2331
|
+
* import { TypeForm } from "@alepha/ui";
|
|
2332
|
+
*
|
|
2333
|
+
* const form = useForm({
|
|
2334
|
+
* schema: t.object({
|
|
2335
|
+
* username: t.text(),
|
|
2336
|
+
* email: t.text(),
|
|
2337
|
+
* age: t.integer(),
|
|
2338
|
+
* subscribe: t.boolean(),
|
|
2339
|
+
* }),
|
|
2340
|
+
* handler: (values) => {
|
|
2341
|
+
* console.log(values);
|
|
2342
|
+
* },
|
|
2343
|
+
* });
|
|
2344
|
+
*
|
|
2345
|
+
* return <TypeForm form={form} columns={2} />;
|
|
2346
|
+
* ```
|
|
2347
|
+
*/
|
|
2348
|
+
declare const TypeForm: <T$1 extends TObject>(props: TypeFormProps<T$1>) => react_jsx_runtime4.JSX.Element | null;
|
|
2349
|
+
//#endregion
|
|
2350
|
+
//#region src/core/components/layout/AppBar.d.ts
|
|
2351
|
+
type AppBarItem = AppBarElement | AppBarBurger | AppBarDark | AppBarSearch | AppBarLang | AppBarSpacer | AppBarDivider;
|
|
2352
|
+
interface AppBarElement {
|
|
2353
|
+
position: "left" | "center" | "right";
|
|
2354
|
+
element: ReactNode;
|
|
2355
|
+
}
|
|
2356
|
+
interface AppBarBurger {
|
|
2357
|
+
position: "left" | "center" | "right";
|
|
2358
|
+
type: "burger";
|
|
2359
|
+
}
|
|
2360
|
+
interface AppBarDark {
|
|
2361
|
+
position: "left" | "center" | "right";
|
|
2362
|
+
type: "dark";
|
|
2363
|
+
props?: DarkModeButtonProps;
|
|
2364
|
+
}
|
|
2365
|
+
interface AppBarSearch {
|
|
2366
|
+
position: "left" | "center" | "right";
|
|
2367
|
+
type: "search";
|
|
2368
|
+
props?: OmnibarButtonProps;
|
|
2369
|
+
}
|
|
2370
|
+
interface AppBarLang {
|
|
2371
|
+
position: "left" | "center" | "right";
|
|
2372
|
+
type: "lang";
|
|
2373
|
+
props?: LanguageButtonProps;
|
|
2374
|
+
}
|
|
2375
|
+
interface AppBarSpacer {
|
|
2376
|
+
position: "left" | "center" | "right";
|
|
2377
|
+
type: "spacer";
|
|
2378
|
+
}
|
|
2379
|
+
interface AppBarDivider {
|
|
2380
|
+
position: "left" | "center" | "right";
|
|
2381
|
+
type: "divider";
|
|
2382
|
+
}
|
|
2383
|
+
interface AppBarProps {
|
|
2384
|
+
flexProps?: FlexProps;
|
|
2385
|
+
items?: AppBarItem[];
|
|
2386
|
+
}
|
|
2387
|
+
declare const AppBar: (props: AppBarProps) => react_jsx_runtime4.JSX.Element;
|
|
2388
|
+
//#endregion
|
|
2389
|
+
//#region src/core/components/layout/Sidebar.d.ts
|
|
2390
|
+
interface SidebarProps {
|
|
2391
|
+
menu?: SidebarNode[];
|
|
2392
|
+
top?: SidebarNode[];
|
|
2393
|
+
bottom?: SidebarNode[];
|
|
2394
|
+
onItemClick?: (item: SidebarMenuItem) => void;
|
|
2395
|
+
onSearchClick?: () => void;
|
|
2396
|
+
theme?: SidebarTheme;
|
|
2397
|
+
flexProps?: Partial<FlexProps>;
|
|
2398
|
+
collapsed?: boolean;
|
|
2399
|
+
gap?: MantineBreakpoint;
|
|
2400
|
+
hide?: {
|
|
2401
|
+
paths?: string[];
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
declare const Sidebar: (props: SidebarProps) => react_jsx_runtime4.JSX.Element;
|
|
2405
|
+
interface SidebarItemProps {
|
|
2406
|
+
item: SidebarMenuItem;
|
|
2407
|
+
level: number;
|
|
2408
|
+
onItemClick?: (item: SidebarMenuItem) => void;
|
|
2409
|
+
theme: SidebarTheme;
|
|
2410
|
+
}
|
|
2411
|
+
interface SidebarItemProps {
|
|
2412
|
+
item: SidebarMenuItem;
|
|
2413
|
+
level: number;
|
|
2414
|
+
onItemClick?: (item: SidebarMenuItem) => void;
|
|
2415
|
+
theme: SidebarTheme;
|
|
2416
|
+
}
|
|
2417
|
+
type SidebarNode = SidebarMenuItem | SidebarSpacer | SidebarDivider | SidebarSearch | SidebarElement | SidebarSection;
|
|
2418
|
+
interface SidebarAbstractItem {
|
|
2419
|
+
position?: "top" | "bottom";
|
|
2420
|
+
}
|
|
2421
|
+
interface SidebarElement extends SidebarAbstractItem {
|
|
2422
|
+
element: ReactNode;
|
|
2423
|
+
}
|
|
2424
|
+
interface SidebarSpacer extends SidebarAbstractItem {
|
|
2425
|
+
type: "spacer";
|
|
2426
|
+
}
|
|
2427
|
+
interface SidebarDivider extends SidebarAbstractItem {
|
|
2428
|
+
type: "divider";
|
|
2429
|
+
}
|
|
2430
|
+
interface SidebarSearch extends SidebarAbstractItem {
|
|
2431
|
+
type: "search";
|
|
2432
|
+
}
|
|
2433
|
+
interface SidebarSection extends SidebarAbstractItem {
|
|
2434
|
+
type: "section";
|
|
2435
|
+
label: string;
|
|
2436
|
+
icon?: ReactNode | ComponentType;
|
|
2437
|
+
}
|
|
2438
|
+
interface SidebarMenuItem extends SidebarAbstractItem {
|
|
2439
|
+
label: string | ReactNode;
|
|
2440
|
+
description?: string;
|
|
2441
|
+
icon?: ReactNode | ComponentType;
|
|
2442
|
+
href?: string;
|
|
2443
|
+
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
2444
|
+
activeStartsWith?: boolean;
|
|
2445
|
+
onClick?: () => void;
|
|
2446
|
+
children?: SidebarMenuItem[];
|
|
2447
|
+
rightSection?: ReactNode;
|
|
2448
|
+
theme?: SidebarButtonTheme;
|
|
2449
|
+
actionProps?: ActionProps;
|
|
2450
|
+
}
|
|
2451
|
+
interface SidebarButtonTheme {
|
|
2452
|
+
radius?: MantineBreakpoint;
|
|
2453
|
+
size?: MantineBreakpoint;
|
|
2454
|
+
}
|
|
2455
|
+
interface SidebarTheme {
|
|
2456
|
+
button?: SidebarButtonTheme;
|
|
2457
|
+
search?: SidebarButtonTheme;
|
|
2458
|
+
}
|
|
2459
|
+
//#endregion
|
|
2460
|
+
//#region src/core/components/layout/AdminShell.d.ts
|
|
2461
|
+
interface AdminShellProps {
|
|
2462
|
+
appShellProps?: Partial<AppShellProps>;
|
|
2463
|
+
appShellMainProps?: Partial<AppShellMainProps>;
|
|
2464
|
+
appShellHeaderProps?: Partial<AppShellHeaderProps>;
|
|
2465
|
+
appShellNavbarProps?: Partial<AppShellNavbarProps>;
|
|
2466
|
+
appShellFooterProps?: Partial<AppShellFooterProps>;
|
|
2467
|
+
sidebarProps?: Partial<SidebarProps>;
|
|
2468
|
+
appBarProps?: Partial<AppBarProps>;
|
|
2469
|
+
header?: ReactNode;
|
|
2470
|
+
footer?: ReactNode;
|
|
2471
|
+
children?: ReactNode;
|
|
2472
|
+
noSidebarWhen?: {
|
|
2473
|
+
/**
|
|
2474
|
+
* Paths where the sidebar should be hidden.
|
|
2475
|
+
*/
|
|
2476
|
+
paths?: string[];
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
declare module "alepha" {
|
|
2480
|
+
interface State {
|
|
2481
|
+
/**
|
|
2482
|
+
* Whether the sidebar is opened or closed.
|
|
2483
|
+
*/
|
|
2484
|
+
"alepha.ui.sidebar.opened"?: boolean;
|
|
2485
|
+
/**
|
|
2486
|
+
* Whether the sidebar is collapsed (narrow) or expanded (wide).
|
|
2487
|
+
*/
|
|
2488
|
+
"alepha.ui.sidebar.collapsed"?: boolean;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
declare const AdminShell: (props: AdminShellProps) => react_jsx_runtime4.JSX.Element;
|
|
2492
|
+
//#endregion
|
|
2493
|
+
//#region src/core/components/layout/Omnibar.d.ts
|
|
2494
|
+
interface OmnibarProps {
|
|
2495
|
+
shortcut?: string | string[];
|
|
2496
|
+
searchPlaceholder?: string;
|
|
2497
|
+
nothingFound?: ReactNode;
|
|
2498
|
+
}
|
|
2499
|
+
declare const Omnibar: (props: OmnibarProps) => react_jsx_runtime4.JSX.Element;
|
|
2500
|
+
//#endregion
|
|
2501
|
+
//#region src/core/components/layout/AlephaMantineProvider.d.ts
|
|
2502
|
+
interface AlephaMantineProviderProps {
|
|
2503
|
+
children?: ReactNode;
|
|
2504
|
+
mantine?: MantineProviderProps;
|
|
2505
|
+
colorSchemeScript?: ColorSchemeScriptProps;
|
|
2506
|
+
navigationProgress?: NavigationProgressProps;
|
|
2507
|
+
notifications?: NotificationsProps;
|
|
2508
|
+
modals?: ModalsProviderProps;
|
|
2509
|
+
omnibar?: OmnibarProps;
|
|
2510
|
+
}
|
|
2511
|
+
declare const AlephaMantineProvider: (props: AlephaMantineProviderProps) => react_jsx_runtime4.JSX.Element;
|
|
2512
|
+
//#endregion
|
|
2513
|
+
//#region src/core/components/table/DataTable.d.ts
|
|
2514
|
+
interface DataTableColumnContext<Filters extends TObject> {
|
|
2515
|
+
index: number;
|
|
2516
|
+
form: FormModel<Filters>;
|
|
2517
|
+
alepha: Alepha;
|
|
2518
|
+
}
|
|
2519
|
+
interface DataTableColumn<T$1 extends object, Filters extends TObject> {
|
|
2520
|
+
label: string;
|
|
2521
|
+
value: (item: T$1, ctx: DataTableColumnContext<Filters>) => ReactNode;
|
|
2522
|
+
fit?: boolean;
|
|
2523
|
+
}
|
|
2524
|
+
type MaybePage<T$1> = Omit<Page<T$1>, "page"> & {
|
|
2525
|
+
page?: Partial<PageMetadata>;
|
|
2526
|
+
};
|
|
2527
|
+
interface DataTableSubmitContext<T$1 extends object> {
|
|
2528
|
+
items: T$1[];
|
|
2529
|
+
}
|
|
2530
|
+
interface DataTableProps<T$1 extends object, Filters extends TObject> {
|
|
2531
|
+
/**
|
|
2532
|
+
* The items to display in the table. Can be a static page of items or a function that returns a promise resolving to a page of items.
|
|
2533
|
+
*/
|
|
2534
|
+
items: MaybePage<T$1> | ((filters: Static<Filters> & {
|
|
2535
|
+
page: number;
|
|
2536
|
+
size: number;
|
|
2537
|
+
sort?: string;
|
|
2538
|
+
}, ctx: DataTableSubmitContext<T$1>) => Async<MaybePage<T$1>>);
|
|
2539
|
+
/**
|
|
2540
|
+
* The columns to display in the table. Each column is defined by a key and a DataTableColumn object.
|
|
2541
|
+
*/
|
|
2542
|
+
columns: {
|
|
2543
|
+
[key: string]: DataTableColumn<T$1, Filters>;
|
|
2544
|
+
};
|
|
2545
|
+
defaultSize?: number;
|
|
2546
|
+
typeFormProps?: Partial<Omit<TypeFormProps<Filters>, "form">>;
|
|
2547
|
+
onFilterChange?: (key: string, value: unknown, form: FormModel<Filters>) => void;
|
|
2548
|
+
/**
|
|
2549
|
+
* Optional filters to apply to the data.
|
|
2550
|
+
*/
|
|
2551
|
+
filters?: TObject;
|
|
2552
|
+
panel?: (item: T$1) => ReactNode;
|
|
2553
|
+
canPanel?: (item: T$1) => boolean;
|
|
2554
|
+
submitOnInit?: boolean;
|
|
2555
|
+
submitEvery?: DurationLike;
|
|
2556
|
+
withLineNumbers?: boolean;
|
|
2557
|
+
withCheckbox?: boolean;
|
|
2558
|
+
checkboxActions?: any[];
|
|
2559
|
+
actions?: any[];
|
|
2560
|
+
/**
|
|
2561
|
+
* Enable infinity scroll mode. When true, pagination controls are hidden and new items are loaded automatically when scrolling to the bottom.
|
|
2562
|
+
*/
|
|
2563
|
+
infinityScroll?: boolean;
|
|
2564
|
+
/**
|
|
2565
|
+
* Props to pass to the Mantine Table component.
|
|
2566
|
+
*/
|
|
2567
|
+
tableProps?: TableProps;
|
|
2568
|
+
/**
|
|
2569
|
+
* Function to generate props for each table row based on the item.
|
|
2570
|
+
*/
|
|
2571
|
+
tableTrProps?: (item: T$1) => TableTrProps;
|
|
2572
|
+
}
|
|
2573
|
+
declare const DataTable: <T$1 extends object, Filters extends TObject>(props: DataTableProps<T$1, Filters>) => react_jsx_runtime4.JSX.Element;
|
|
2574
|
+
//#endregion
|
|
2575
|
+
//#region src/core/constants/ui.d.ts
|
|
2576
|
+
declare const ui: {
|
|
2577
|
+
colors: {
|
|
2578
|
+
transparent: string;
|
|
2579
|
+
background: string;
|
|
2580
|
+
surface: string;
|
|
2581
|
+
elevated: string;
|
|
2582
|
+
border: string;
|
|
2583
|
+
};
|
|
2584
|
+
sizes: {
|
|
2585
|
+
icon: {
|
|
2586
|
+
xs: number;
|
|
2587
|
+
sm: number;
|
|
2588
|
+
md: number;
|
|
2589
|
+
lg: number;
|
|
2590
|
+
xl: number;
|
|
2591
|
+
};
|
|
2592
|
+
};
|
|
2593
|
+
};
|
|
2594
|
+
//#endregion
|
|
2595
|
+
//#region src/core/hooks/useDialog.d.ts
|
|
2596
|
+
/**
|
|
2597
|
+
* Use this hook to access the Dialog Service for showing various dialog types.
|
|
2598
|
+
*
|
|
2599
|
+
* @example
|
|
2600
|
+
* ```tsx
|
|
2601
|
+
* const dialog = useDialog();
|
|
2602
|
+
* await dialog.alert({ title: "Alert", message: "This is an alert message" });
|
|
2603
|
+
* const confirmed = await dialog.confirm({ title: "Confirm", message: "Are you sure?" });
|
|
2604
|
+
* const input = await dialog.prompt({ title: "Input", message: "Enter your name:" });
|
|
2605
|
+
* ```
|
|
2606
|
+
*/
|
|
2607
|
+
declare const useDialog: () => DialogService;
|
|
2608
|
+
//#endregion
|
|
2609
|
+
//#region src/core/services/ToastService.d.ts
|
|
2610
|
+
interface ToastServiceOptions {
|
|
2611
|
+
default?: Partial<NotificationData>;
|
|
2612
|
+
}
|
|
2613
|
+
declare class ToastService {
|
|
2614
|
+
protected readonly raw: {
|
|
2615
|
+
readonly show: typeof _mantine_notifications0.showNotification;
|
|
2616
|
+
readonly hide: typeof _mantine_notifications0.hideNotification;
|
|
2617
|
+
readonly update: typeof _mantine_notifications0.updateNotification;
|
|
2618
|
+
readonly clean: typeof _mantine_notifications0.cleanNotifications;
|
|
2619
|
+
readonly cleanQueue: typeof _mantine_notifications0.cleanNotificationsQueue;
|
|
2620
|
+
readonly updateState: typeof _mantine_notifications0.updateNotificationsState;
|
|
2621
|
+
};
|
|
2622
|
+
readonly options: ToastServiceOptions;
|
|
2623
|
+
show(options: NotificationData): void;
|
|
2624
|
+
info(options: Partial<NotificationData> | string): void;
|
|
2625
|
+
success(options: Partial<NotificationData> | string): void;
|
|
2626
|
+
warning(options: Partial<NotificationData> | string): void;
|
|
2627
|
+
danger(options: Partial<NotificationData> | string): void;
|
|
2628
|
+
}
|
|
2629
|
+
//#endregion
|
|
2630
|
+
//#region src/core/hooks/useToast.d.ts
|
|
2631
|
+
/**
|
|
2632
|
+
* Use this hook to access the Toast Service for showing notifications.
|
|
2633
|
+
*
|
|
2634
|
+
* @example
|
|
2635
|
+
* ```tsx
|
|
2636
|
+
* const toast = useToast();
|
|
2637
|
+
* toast.success({ message: "Operation completed successfully!" });
|
|
2638
|
+
* toast.error({ title: "Error", message: "Something went wrong" });
|
|
2639
|
+
* ```
|
|
2640
|
+
*/
|
|
2641
|
+
declare const useToast: () => ToastService;
|
|
2642
|
+
//#endregion
|
|
2643
|
+
//#region src/core/RootRouter.d.ts
|
|
2644
|
+
declare class RootRouter {
|
|
2645
|
+
readonly root: PageDescriptor<PageConfigSchema, any, TPropsParentDefault>;
|
|
2646
|
+
}
|
|
2647
|
+
//#endregion
|
|
2648
|
+
//#region src/core/utils/extractSchemaFields.d.ts
|
|
2649
|
+
interface SchemaField {
|
|
2650
|
+
name: string;
|
|
2651
|
+
path: string;
|
|
2652
|
+
type: string;
|
|
2653
|
+
enum?: readonly any[];
|
|
2654
|
+
format?: string;
|
|
2655
|
+
description?: string;
|
|
2656
|
+
nested?: SchemaField[];
|
|
2657
|
+
}
|
|
2658
|
+
/**
|
|
2659
|
+
* Extract field information from a TypeBox schema for query building.
|
|
2660
|
+
* Supports nested objects and provides field metadata for autocomplete.
|
|
2661
|
+
*/
|
|
2662
|
+
declare function extractSchemaFields(schema: TObject | TProperties, prefix?: string): SchemaField[];
|
|
2663
|
+
/**
|
|
2664
|
+
* Get suggested operators based on field type
|
|
2665
|
+
*/
|
|
2666
|
+
declare function getOperatorsForField(field: SchemaField): string[];
|
|
2667
|
+
/**
|
|
2668
|
+
* Get operator symbol and description
|
|
2669
|
+
*/
|
|
2670
|
+
declare const OPERATOR_INFO: Record<string, {
|
|
2671
|
+
symbol: string;
|
|
2672
|
+
label: string;
|
|
2673
|
+
example: string;
|
|
2674
|
+
}>;
|
|
2675
|
+
//#endregion
|
|
2676
|
+
//#region src/core/utils/icons.d.ts
|
|
2677
|
+
type IconSize = keyof typeof ui.sizes.icon;
|
|
2678
|
+
/**
|
|
2679
|
+
* Get the default icon for an input based on its type, format, or name.
|
|
2680
|
+
*/
|
|
2681
|
+
declare const getDefaultIcon: (params: {
|
|
2682
|
+
type?: string;
|
|
2683
|
+
format?: string;
|
|
2684
|
+
name?: string;
|
|
2685
|
+
isEnum?: boolean;
|
|
2686
|
+
isArray?: boolean;
|
|
2687
|
+
size?: IconSize;
|
|
2688
|
+
}) => ReactElement;
|
|
2689
|
+
//#endregion
|
|
2690
|
+
//#region src/core/utils/string.d.ts
|
|
2691
|
+
/**
|
|
2692
|
+
* Capitalizes the first letter of a string.
|
|
2693
|
+
*
|
|
2694
|
+
* @example
|
|
2695
|
+
* capitalize("hello") // "Hello"
|
|
2696
|
+
*/
|
|
2697
|
+
declare const capitalize: (str: string) => string;
|
|
2698
|
+
/**
|
|
2699
|
+
* Converts a path or identifier string into a pretty display name.
|
|
2700
|
+
* Removes slashes and capitalizes the first letter.
|
|
2701
|
+
*
|
|
2702
|
+
* @example
|
|
2703
|
+
* prettyName("/userName") // "UserName"
|
|
2704
|
+
* prettyName("email") // "Email"
|
|
2705
|
+
*/
|
|
2706
|
+
declare const prettyName: (name: string) => string;
|
|
2707
|
+
//#endregion
|
|
2708
|
+
//#region src/core/index.d.ts
|
|
2709
|
+
declare module "typebox" {
|
|
2710
|
+
interface TSchemaOptions {
|
|
2711
|
+
$control?: Omit<ControlProps, "input">;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
declare module "@alepha/react" {
|
|
2715
|
+
interface PageDescriptorOptions {
|
|
2716
|
+
/**
|
|
2717
|
+
* Human-readable title for the page.
|
|
2718
|
+
* - for Sidebar navigation
|
|
2719
|
+
* - for Omnibar navigation
|
|
2720
|
+
* (soon)
|
|
2721
|
+
* - for Breadcrumbs
|
|
2722
|
+
* - for document title (with AlephaReactHead)
|
|
2723
|
+
*/
|
|
2724
|
+
label?: string;
|
|
2725
|
+
/**
|
|
2726
|
+
* Optional description of the page.
|
|
2727
|
+
*/
|
|
2728
|
+
description?: string;
|
|
2729
|
+
/**
|
|
2730
|
+
* Optional icon for the page.
|
|
2731
|
+
*/
|
|
2732
|
+
icon?: ReactNode;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Mantine
|
|
2737
|
+
*
|
|
2738
|
+
* @module alepha.ui
|
|
2739
|
+
*/
|
|
2740
|
+
declare const AlephaUI: alepha79.Service<alepha79.Module>;
|
|
2741
|
+
//#endregion
|
|
2742
|
+
export { ActionButton, type ActionClickButtonProps, type ActionCommonProps, type ActionMenuConfig, type ActionMenuItem, type ActionNavigationButtonProps, type ActionProps, type ActionSubmitButtonProps, AdminShell, type AdminShellProps, AlephaMantineProvider, AlephaUI, AlertDialog, type AlertDialogOptions, type AlertDialogProps, AppBar, type AppBarBurger, type AppBarDark, type AppBarDivider, type AppBarElement, type AppBarItem, type AppBarLang, type AppBarProps, type AppBarSearch, type AppBarSpacer, type BaseDialogOptions, BurgerButton, ClipboardButton, type ClipboardButtonProps, ConfirmDialog, type ConfirmDialogOptions, type ConfirmDialogProps, Control, ControlDate, ControlQueryBuilder, ControlSelect, DarkModeButton, DataTable, type DataTableColumn, type DataTableProps, DialogService, Flex, IconSize, JsonViewer, LanguageButton, OPERATOR_INFO, Omnibar, OmnibarButton, PromptDialog, type PromptDialogOptions, type PromptDialogProps, RootRouter, SchemaField, Sidebar, type SidebarAbstractItem, type SidebarButtonTheme, type SidebarDivider, type SidebarElement, type SidebarItemProps, type SidebarMenuItem, type SidebarNode, type SidebarProps, type SidebarSearch, type SidebarSection, type SidebarSpacer, type SidebarTheme, Text, ToastService, TypeForm, capitalize, extractSchemaFields, getDefaultIcon, getOperatorsForField, prettyName, ui, useDialog, useToast };
|
|
2743
|
+
//# sourceMappingURL=index.d.ts.map
|