@alepha/react 0.12.0 → 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/dist/auth/chunk-DhGyd7sr.js +28 -0
- package/dist/auth/index.browser.js +394 -114
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.cjs +80 -1927
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1130 -420
- package/dist/auth/index.d.ts +1130 -420
- package/dist/auth/index.js +72 -1918
- package/dist/auth/index.js.map +1 -1
- package/dist/core/chunk-DhGyd7sr.js +28 -0
- package/dist/core/index.browser.js +79 -79
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.cjs +89 -85
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1654 -154
- package/dist/core/index.d.ts +1654 -154
- package/dist/core/index.js +79 -79
- package/dist/core/index.js.map +1 -1
- package/dist/form/chunk-DhGyd7sr.js +28 -0
- package/dist/form/index.cjs +28 -8
- package/dist/form/index.cjs.map +1 -1
- package/dist/form/index.d.cts +215 -7
- package/dist/form/index.d.ts +215 -7
- package/dist/form/index.js +18 -3
- package/dist/form/index.js.map +1 -1
- package/dist/head/chunk-DhGyd7sr.js +28 -0
- package/dist/head/index.browser.js +385 -59
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.cjs +12 -8
- package/dist/head/index.cjs.map +1 -1
- package/dist/head/index.d.cts +1230 -24
- package/dist/head/index.d.ts +1230 -29
- package/dist/head/index.js +2 -2
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/chunk-DhGyd7sr.js +28 -0
- package/dist/i18n/index.cjs +33 -20
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +282 -13
- package/dist/i18n/index.d.ts +282 -13
- package/dist/i18n/index.js +23 -14
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.cjs +21 -8
- package/dist/websocket/index.cjs.map +1 -1
- package/dist/websocket/index.js +11 -2
- package/dist/websocket/index.js.map +1 -1
- package/package.json +7 -6
- package/src/auth/index.browser.ts +3 -6
- package/src/auth/index.shared.ts +0 -1
- package/src/auth/index.ts +3 -16
- package/src/auth/providers/ReactAuthProvider.ts +1 -614
- package/src/auth/services/ReactAuth.ts +6 -17
- package/src/core/descriptors/$page.ts +1 -1
- package/src/core/index.browser.ts +1 -0
- package/src/core/index.native.ts +21 -0
- package/src/core/index.shared-router.ts +15 -0
- package/src/core/index.shared.ts +0 -14
- package/src/core/index.ts +1 -0
- package/src/core/services/ReactRouter.ts +2 -2
- package/src/form/errors/FormValidationError.ts +20 -0
- package/src/form/hooks/useForm.ts +1 -1
- package/src/form/index.ts +1 -0
- package/src/head/providers/BrowserHeadProvider.ts +1 -1
- package/src/i18n/descriptors/$dictionary.ts +7 -3
- package/src/i18n/providers/I18nProvider.ts +9 -10
- package/src/websocket/hooks/useRoom.tsx +21 -2
- package/dist/auth/index.d.cts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/core/index.d.cts.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/form/index.d.cts.map +0 -1
- package/dist/form/index.d.ts.map +0 -1
- package/dist/head/index.d.cts.map +0 -1
- package/dist/head/index.d.ts.map +0 -1
- package/dist/i18n/index.d.cts.map +0 -1
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/websocket/index.d.cts.map +0 -1
- package/dist/websocket/index.d.ts.map +0 -1
- package/src/auth/descriptors/$auth.ts +0 -436
- package/src/auth/descriptors/$authApple.ts +0 -8
- package/src/auth/descriptors/$authGithub.ts +0 -81
- package/src/auth/descriptors/$authGoogle.ts +0 -38
- package/src/auth/errors/SessionExpiredError.ts +0 -6
- package/src/auth/schemas/tokenResponseSchema.ts +0 -11
- package/src/auth/schemas/tokensSchema.ts +0 -21
- package/src/auth/schemas/userinfoResponseSchema.ts +0 -10
package/dist/form/index.d.cts
CHANGED
|
@@ -1,10 +1,209 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Alepha, Static, TObject, TSchema } from "alepha";
|
|
1
|
+
import * as alepha8 from "alepha";
|
|
2
|
+
import { Alepha, LogLevel, LoggerInterface, Static, TObject, TSchema, TypeBoxError } from "alepha";
|
|
3
3
|
import { InputHTMLAttributes, ReactNode } from "react";
|
|
4
|
-
import
|
|
4
|
+
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
5
|
+
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
5
6
|
|
|
7
|
+
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
8
|
+
declare const logEntrySchema: alepha8.TObject<{
|
|
9
|
+
level: alepha8.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
10
|
+
message: alepha8.TString;
|
|
11
|
+
service: alepha8.TString;
|
|
12
|
+
module: alepha8.TString;
|
|
13
|
+
context: alepha8.TOptional<alepha8.TString>;
|
|
14
|
+
app: alepha8.TOptional<alepha8.TString>;
|
|
15
|
+
data: alepha8.TOptional<alepha8.TAny>;
|
|
16
|
+
timestamp: alepha8.TNumber;
|
|
17
|
+
}>;
|
|
18
|
+
type LogEntry = Static<typeof logEntrySchema>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
21
|
+
type DateTime = DayjsApi.Dayjs;
|
|
22
|
+
type Duration = dayjsDuration.Duration;
|
|
23
|
+
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
24
|
+
declare class DateTimeProvider {
|
|
25
|
+
static PLUGINS: Array<PluginFunc<any>>;
|
|
26
|
+
protected alepha: Alepha;
|
|
27
|
+
protected ref: DateTime | null;
|
|
28
|
+
protected readonly timeouts: Timeout[];
|
|
29
|
+
protected readonly intervals: Interval[];
|
|
30
|
+
constructor();
|
|
31
|
+
protected readonly onStart: alepha8.HookDescriptor<"start">;
|
|
32
|
+
protected readonly onStop: alepha8.HookDescriptor<"stop">;
|
|
33
|
+
setLocale(locale: string): void;
|
|
34
|
+
isDateTime(value: unknown): value is DateTime;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new UTC DateTime instance.
|
|
37
|
+
*/
|
|
38
|
+
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new DateTime instance.
|
|
41
|
+
*/
|
|
42
|
+
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
43
|
+
/**
|
|
44
|
+
* Get the current date as a string.
|
|
45
|
+
*/
|
|
46
|
+
toISOString(date?: Date | string | DateTime): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get the current date.
|
|
49
|
+
*/
|
|
50
|
+
now(): DateTime;
|
|
51
|
+
/**
|
|
52
|
+
* Get the current date as a string.
|
|
53
|
+
*
|
|
54
|
+
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
55
|
+
*/
|
|
56
|
+
nowISOString(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current date as milliseconds since epoch.
|
|
59
|
+
*
|
|
60
|
+
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
61
|
+
*/
|
|
62
|
+
nowMillis(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current date as a string.
|
|
65
|
+
*
|
|
66
|
+
* @protected
|
|
67
|
+
*/
|
|
68
|
+
protected getCurrentDate(): DateTime;
|
|
69
|
+
/**
|
|
70
|
+
* Create a new Duration instance.
|
|
71
|
+
*/
|
|
72
|
+
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
73
|
+
isDurationLike(value: unknown): value is DurationLike;
|
|
74
|
+
/**
|
|
75
|
+
* Return a promise that resolves after the next tick.
|
|
76
|
+
* It uses `setTimeout` with 0 ms delay.
|
|
77
|
+
*/
|
|
78
|
+
tick(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Wait for a certain duration.
|
|
81
|
+
*
|
|
82
|
+
* You can clear the timeout by using the `AbortSignal` API.
|
|
83
|
+
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
84
|
+
*/
|
|
85
|
+
wait(duration: DurationLike, options?: {
|
|
86
|
+
signal?: AbortSignal;
|
|
87
|
+
now?: number;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
90
|
+
/**
|
|
91
|
+
* Run a callback after a certain duration.
|
|
92
|
+
*/
|
|
93
|
+
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
94
|
+
clearTimeout(timeout: Timeout): void;
|
|
95
|
+
clearInterval(interval: Interval): void;
|
|
96
|
+
/**
|
|
97
|
+
* Run a function with a deadline.
|
|
98
|
+
*/
|
|
99
|
+
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Add time to the current date.
|
|
102
|
+
*/
|
|
103
|
+
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Stop the time.
|
|
106
|
+
*/
|
|
107
|
+
pause(): DateTime;
|
|
108
|
+
/**
|
|
109
|
+
* Reset the reference date.
|
|
110
|
+
*/
|
|
111
|
+
reset(): void;
|
|
112
|
+
}
|
|
113
|
+
interface Interval {
|
|
114
|
+
timer?: any;
|
|
115
|
+
duration: number;
|
|
116
|
+
run: () => unknown;
|
|
117
|
+
}
|
|
118
|
+
interface Timeout {
|
|
119
|
+
now: number;
|
|
120
|
+
timer?: any;
|
|
121
|
+
duration: number;
|
|
122
|
+
callback: () => void;
|
|
123
|
+
clear: () => void;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
127
|
+
declare abstract class LogDestinationProvider {
|
|
128
|
+
abstract write(message: string, entry: LogEntry): void;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
132
|
+
declare abstract class LogFormatterProvider {
|
|
133
|
+
abstract format(entry: LogEntry): string;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
137
|
+
declare class Logger implements LoggerInterface {
|
|
138
|
+
protected readonly alepha: Alepha;
|
|
139
|
+
protected readonly formatter: LogFormatterProvider;
|
|
140
|
+
protected readonly destination: LogDestinationProvider;
|
|
141
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
142
|
+
protected readonly levels: Record<string, number>;
|
|
143
|
+
protected readonly service: string;
|
|
144
|
+
protected readonly module: string;
|
|
145
|
+
protected readonly app?: string;
|
|
146
|
+
protected appLogLevel: string;
|
|
147
|
+
protected logLevel: LogLevel;
|
|
148
|
+
constructor(service: string, module: string);
|
|
149
|
+
get context(): string | undefined;
|
|
150
|
+
get level(): string;
|
|
151
|
+
parseLevel(level: string, app: string): LogLevel;
|
|
152
|
+
private matchesPattern;
|
|
153
|
+
asLogLevel(something: string): LogLevel;
|
|
154
|
+
error(message: string, data?: unknown): void;
|
|
155
|
+
warn(message: string, data?: unknown): void;
|
|
156
|
+
info(message: string, data?: unknown): void;
|
|
157
|
+
debug(message: string, data?: unknown): void;
|
|
158
|
+
trace(message: string, data?: unknown): void;
|
|
159
|
+
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
160
|
+
protected emit(entry: LogEntry, message?: string): void;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region ../alepha/src/logger/index.d.ts
|
|
164
|
+
declare const envSchema: alepha8.TObject<{
|
|
165
|
+
/**
|
|
166
|
+
* Default log level for the application.
|
|
167
|
+
*
|
|
168
|
+
* Default by environment:
|
|
169
|
+
* - dev = info
|
|
170
|
+
* - prod = info
|
|
171
|
+
* - test = error
|
|
172
|
+
*
|
|
173
|
+
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
174
|
+
*
|
|
175
|
+
* Level can be set for a specific module:
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
179
|
+
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
180
|
+
*/
|
|
181
|
+
LOG_LEVEL: alepha8.TOptional<alepha8.TString>;
|
|
182
|
+
/**
|
|
183
|
+
* Built-in log formats.
|
|
184
|
+
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
185
|
+
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
186
|
+
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
187
|
+
*/
|
|
188
|
+
LOG_FORMAT: alepha8.TOptional<alepha8.TUnsafe<"json" | "pretty" | "raw">>;
|
|
189
|
+
}>;
|
|
190
|
+
declare module "alepha" {
|
|
191
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
192
|
+
interface State {
|
|
193
|
+
/**
|
|
194
|
+
* Current log level for the application or specific modules.
|
|
195
|
+
*/
|
|
196
|
+
"alepha.logger.level"?: string;
|
|
197
|
+
}
|
|
198
|
+
interface Hooks {
|
|
199
|
+
log: {
|
|
200
|
+
message?: string;
|
|
201
|
+
entry: LogEntry;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
6
206
|
//#region src/form/services/FormModel.d.ts
|
|
7
|
-
|
|
8
207
|
/**
|
|
9
208
|
* FormModel is a dynamic form handler that generates form inputs based on a provided TypeBox schema.
|
|
10
209
|
* It manages form state, handles input changes, and processes form submissions with validation.
|
|
@@ -16,7 +215,7 @@ import * as alepha_logger0 from "alepha/logger";
|
|
|
16
215
|
declare class FormModel<T extends TObject> {
|
|
17
216
|
readonly id: string;
|
|
18
217
|
readonly options: FormCtrlOptions<T>;
|
|
19
|
-
protected readonly log:
|
|
218
|
+
protected readonly log: Logger;
|
|
20
219
|
protected readonly alepha: Alepha;
|
|
21
220
|
protected readonly values: Record<string, any>;
|
|
22
221
|
protected submitInProgress: boolean;
|
|
@@ -166,6 +365,15 @@ declare const useFormState: <T extends TObject, Keys extends keyof UseFormStateR
|
|
|
166
365
|
path: string;
|
|
167
366
|
}, _events?: Keys[]) => Pick<UseFormStateReturn, Keys>;
|
|
168
367
|
//#endregion
|
|
368
|
+
//#region src/form/errors/FormValidationError.d.ts
|
|
369
|
+
declare class FormValidationError extends TypeBoxError {
|
|
370
|
+
readonly name = "ValidationError";
|
|
371
|
+
constructor(options: {
|
|
372
|
+
message: string;
|
|
373
|
+
path: string;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
169
377
|
//#region src/form/index.d.ts
|
|
170
378
|
declare module "alepha" {
|
|
171
379
|
interface Hooks {
|
|
@@ -205,7 +413,7 @@ declare module "alepha" {
|
|
|
205
413
|
* @see {@link useForm}
|
|
206
414
|
* @module alepha.react.form
|
|
207
415
|
*/
|
|
208
|
-
declare const AlephaReactForm:
|
|
416
|
+
declare const AlephaReactForm: alepha8.Service<alepha8.Module>;
|
|
209
417
|
//#endregion
|
|
210
|
-
export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
|
|
418
|
+
export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, FormValidationError, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
|
|
211
419
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/form/index.d.ts
CHANGED
|
@@ -1,10 +1,209 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Alepha, Static, TObject, TSchema } from "alepha";
|
|
3
|
-
import * as alepha_logger0 from "alepha/logger";
|
|
1
|
+
import * as alepha8 from "alepha";
|
|
2
|
+
import { Alepha, Descriptor, KIND, LogLevel, LoggerInterface, Static, TObject, TSchema, TypeBoxError } from "alepha";
|
|
4
3
|
import { InputHTMLAttributes, ReactNode } from "react";
|
|
4
|
+
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
5
|
+
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
5
6
|
|
|
7
|
+
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
8
|
+
declare const logEntrySchema: alepha8.TObject<{
|
|
9
|
+
level: alepha8.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
10
|
+
message: alepha8.TString;
|
|
11
|
+
service: alepha8.TString;
|
|
12
|
+
module: alepha8.TString;
|
|
13
|
+
context: alepha8.TOptional<alepha8.TString>;
|
|
14
|
+
app: alepha8.TOptional<alepha8.TString>;
|
|
15
|
+
data: alepha8.TOptional<alepha8.TAny>;
|
|
16
|
+
timestamp: alepha8.TNumber;
|
|
17
|
+
}>;
|
|
18
|
+
type LogEntry = Static<typeof logEntrySchema>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
21
|
+
type DateTime = DayjsApi.Dayjs;
|
|
22
|
+
type Duration = dayjsDuration.Duration;
|
|
23
|
+
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
24
|
+
declare class DateTimeProvider {
|
|
25
|
+
static PLUGINS: Array<PluginFunc<any>>;
|
|
26
|
+
protected alepha: Alepha;
|
|
27
|
+
protected ref: DateTime | null;
|
|
28
|
+
protected readonly timeouts: Timeout[];
|
|
29
|
+
protected readonly intervals: Interval[];
|
|
30
|
+
constructor();
|
|
31
|
+
protected readonly onStart: alepha8.HookDescriptor<"start">;
|
|
32
|
+
protected readonly onStop: alepha8.HookDescriptor<"stop">;
|
|
33
|
+
setLocale(locale: string): void;
|
|
34
|
+
isDateTime(value: unknown): value is DateTime;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new UTC DateTime instance.
|
|
37
|
+
*/
|
|
38
|
+
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
39
|
+
/**
|
|
40
|
+
* Create a new DateTime instance.
|
|
41
|
+
*/
|
|
42
|
+
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
43
|
+
/**
|
|
44
|
+
* Get the current date as a string.
|
|
45
|
+
*/
|
|
46
|
+
toISOString(date?: Date | string | DateTime): string;
|
|
47
|
+
/**
|
|
48
|
+
* Get the current date.
|
|
49
|
+
*/
|
|
50
|
+
now(): DateTime;
|
|
51
|
+
/**
|
|
52
|
+
* Get the current date as a string.
|
|
53
|
+
*
|
|
54
|
+
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
55
|
+
*/
|
|
56
|
+
nowISOString(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Get the current date as milliseconds since epoch.
|
|
59
|
+
*
|
|
60
|
+
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
61
|
+
*/
|
|
62
|
+
nowMillis(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Get the current date as a string.
|
|
65
|
+
*
|
|
66
|
+
* @protected
|
|
67
|
+
*/
|
|
68
|
+
protected getCurrentDate(): DateTime;
|
|
69
|
+
/**
|
|
70
|
+
* Create a new Duration instance.
|
|
71
|
+
*/
|
|
72
|
+
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
73
|
+
isDurationLike(value: unknown): value is DurationLike;
|
|
74
|
+
/**
|
|
75
|
+
* Return a promise that resolves after the next tick.
|
|
76
|
+
* It uses `setTimeout` with 0 ms delay.
|
|
77
|
+
*/
|
|
78
|
+
tick(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Wait for a certain duration.
|
|
81
|
+
*
|
|
82
|
+
* You can clear the timeout by using the `AbortSignal` API.
|
|
83
|
+
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
84
|
+
*/
|
|
85
|
+
wait(duration: DurationLike, options?: {
|
|
86
|
+
signal?: AbortSignal;
|
|
87
|
+
now?: number;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
90
|
+
/**
|
|
91
|
+
* Run a callback after a certain duration.
|
|
92
|
+
*/
|
|
93
|
+
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
94
|
+
clearTimeout(timeout: Timeout): void;
|
|
95
|
+
clearInterval(interval: Interval): void;
|
|
96
|
+
/**
|
|
97
|
+
* Run a function with a deadline.
|
|
98
|
+
*/
|
|
99
|
+
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Add time to the current date.
|
|
102
|
+
*/
|
|
103
|
+
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Stop the time.
|
|
106
|
+
*/
|
|
107
|
+
pause(): DateTime;
|
|
108
|
+
/**
|
|
109
|
+
* Reset the reference date.
|
|
110
|
+
*/
|
|
111
|
+
reset(): void;
|
|
112
|
+
}
|
|
113
|
+
interface Interval {
|
|
114
|
+
timer?: any;
|
|
115
|
+
duration: number;
|
|
116
|
+
run: () => unknown;
|
|
117
|
+
}
|
|
118
|
+
interface Timeout {
|
|
119
|
+
now: number;
|
|
120
|
+
timer?: any;
|
|
121
|
+
duration: number;
|
|
122
|
+
callback: () => void;
|
|
123
|
+
clear: () => void;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
127
|
+
declare abstract class LogDestinationProvider {
|
|
128
|
+
abstract write(message: string, entry: LogEntry): void;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
132
|
+
declare abstract class LogFormatterProvider {
|
|
133
|
+
abstract format(entry: LogEntry): string;
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
137
|
+
declare class Logger implements LoggerInterface {
|
|
138
|
+
protected readonly alepha: Alepha;
|
|
139
|
+
protected readonly formatter: LogFormatterProvider;
|
|
140
|
+
protected readonly destination: LogDestinationProvider;
|
|
141
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
142
|
+
protected readonly levels: Record<string, number>;
|
|
143
|
+
protected readonly service: string;
|
|
144
|
+
protected readonly module: string;
|
|
145
|
+
protected readonly app?: string;
|
|
146
|
+
protected appLogLevel: string;
|
|
147
|
+
protected logLevel: LogLevel;
|
|
148
|
+
constructor(service: string, module: string);
|
|
149
|
+
get context(): string | undefined;
|
|
150
|
+
get level(): string;
|
|
151
|
+
parseLevel(level: string, app: string): LogLevel;
|
|
152
|
+
private matchesPattern;
|
|
153
|
+
asLogLevel(something: string): LogLevel;
|
|
154
|
+
error(message: string, data?: unknown): void;
|
|
155
|
+
warn(message: string, data?: unknown): void;
|
|
156
|
+
info(message: string, data?: unknown): void;
|
|
157
|
+
debug(message: string, data?: unknown): void;
|
|
158
|
+
trace(message: string, data?: unknown): void;
|
|
159
|
+
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
160
|
+
protected emit(entry: LogEntry, message?: string): void;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region ../alepha/src/logger/index.d.ts
|
|
164
|
+
declare const envSchema: alepha8.TObject<{
|
|
165
|
+
/**
|
|
166
|
+
* Default log level for the application.
|
|
167
|
+
*
|
|
168
|
+
* Default by environment:
|
|
169
|
+
* - dev = info
|
|
170
|
+
* - prod = info
|
|
171
|
+
* - test = error
|
|
172
|
+
*
|
|
173
|
+
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
174
|
+
*
|
|
175
|
+
* Level can be set for a specific module:
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
179
|
+
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
180
|
+
*/
|
|
181
|
+
LOG_LEVEL: alepha8.TOptional<alepha8.TString>;
|
|
182
|
+
/**
|
|
183
|
+
* Built-in log formats.
|
|
184
|
+
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
185
|
+
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
186
|
+
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
187
|
+
*/
|
|
188
|
+
LOG_FORMAT: alepha8.TOptional<alepha8.TUnsafe<"json" | "pretty" | "raw">>;
|
|
189
|
+
}>;
|
|
190
|
+
declare module "alepha" {
|
|
191
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
192
|
+
interface State {
|
|
193
|
+
/**
|
|
194
|
+
* Current log level for the application or specific modules.
|
|
195
|
+
*/
|
|
196
|
+
"alepha.logger.level"?: string;
|
|
197
|
+
}
|
|
198
|
+
interface Hooks {
|
|
199
|
+
log: {
|
|
200
|
+
message?: string;
|
|
201
|
+
entry: LogEntry;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
6
206
|
//#region src/form/services/FormModel.d.ts
|
|
7
|
-
|
|
8
207
|
/**
|
|
9
208
|
* FormModel is a dynamic form handler that generates form inputs based on a provided TypeBox schema.
|
|
10
209
|
* It manages form state, handles input changes, and processes form submissions with validation.
|
|
@@ -16,7 +215,7 @@ import { InputHTMLAttributes, ReactNode } from "react";
|
|
|
16
215
|
declare class FormModel<T extends TObject> {
|
|
17
216
|
readonly id: string;
|
|
18
217
|
readonly options: FormCtrlOptions<T>;
|
|
19
|
-
protected readonly log:
|
|
218
|
+
protected readonly log: Logger;
|
|
20
219
|
protected readonly alepha: Alepha;
|
|
21
220
|
protected readonly values: Record<string, any>;
|
|
22
221
|
protected submitInProgress: boolean;
|
|
@@ -166,6 +365,15 @@ declare const useFormState: <T extends TObject, Keys extends keyof UseFormStateR
|
|
|
166
365
|
path: string;
|
|
167
366
|
}, _events?: Keys[]) => Pick<UseFormStateReturn, Keys>;
|
|
168
367
|
//#endregion
|
|
368
|
+
//#region src/form/errors/FormValidationError.d.ts
|
|
369
|
+
declare class FormValidationError extends TypeBoxError {
|
|
370
|
+
readonly name = "ValidationError";
|
|
371
|
+
constructor(options: {
|
|
372
|
+
message: string;
|
|
373
|
+
path: string;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
169
377
|
//#region src/form/index.d.ts
|
|
170
378
|
declare module "alepha" {
|
|
171
379
|
interface Hooks {
|
|
@@ -205,7 +413,7 @@ declare module "alepha" {
|
|
|
205
413
|
* @see {@link useForm}
|
|
206
414
|
* @module alepha.react.form
|
|
207
415
|
*/
|
|
208
|
-
declare const AlephaReactForm:
|
|
416
|
+
declare const AlephaReactForm: alepha8.Service<alepha8.Module>;
|
|
209
417
|
//#endregion
|
|
210
|
-
export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
|
|
418
|
+
export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, FormValidationError, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
|
|
211
419
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/form/index.js
CHANGED
|
@@ -70,7 +70,7 @@ var ReactPageService = class {
|
|
|
70
70
|
* const userProfile = $page({
|
|
71
71
|
* path: "/users/:id",
|
|
72
72
|
* schema: {
|
|
73
|
-
* params: t.object({ id: t.
|
|
73
|
+
* params: t.object({ id: t.integer() }),
|
|
74
74
|
* query: t.object({ tab: t.optional(t.text()) })
|
|
75
75
|
* },
|
|
76
76
|
* resolve: async ({ params }) => {
|
|
@@ -1526,7 +1526,7 @@ var ReactRouter = class {
|
|
|
1526
1526
|
path(name, config = {}) {
|
|
1527
1527
|
return this.pageApi.pathname(name, {
|
|
1528
1528
|
params: {
|
|
1529
|
-
...this.state
|
|
1529
|
+
...this.state?.params,
|
|
1530
1530
|
...config.params
|
|
1531
1531
|
},
|
|
1532
1532
|
query: config.query
|
|
@@ -2006,6 +2006,21 @@ const useForm = (options, deps = []) => {
|
|
|
2006
2006
|
}, deps);
|
|
2007
2007
|
};
|
|
2008
2008
|
|
|
2009
|
+
//#endregion
|
|
2010
|
+
//#region src/form/errors/FormValidationError.ts
|
|
2011
|
+
var FormValidationError = class extends TypeBoxError {
|
|
2012
|
+
name = "ValidationError";
|
|
2013
|
+
constructor(options) {
|
|
2014
|
+
super({
|
|
2015
|
+
message: options.message,
|
|
2016
|
+
instancePath: options.path,
|
|
2017
|
+
schemaPath: "",
|
|
2018
|
+
keyword: "not",
|
|
2019
|
+
params: {}
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2009
2024
|
//#endregion
|
|
2010
2025
|
//#region src/form/index.ts
|
|
2011
2026
|
/**
|
|
@@ -2022,5 +2037,5 @@ const useForm = (options, deps = []) => {
|
|
|
2022
2037
|
const AlephaReactForm = $module({ name: "alepha.react.form" });
|
|
2023
2038
|
|
|
2024
2039
|
//#endregion
|
|
2025
|
-
export { AlephaReactForm, FormModel, FormState_default as FormState, useForm, useFormState };
|
|
2040
|
+
export { AlephaReactForm, FormModel, FormState_default as FormState, FormValidationError, useForm, useFormState };
|
|
2026
2041
|
//# sourceMappingURL=index.js.map
|