@alepha/react 0.13.1 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.browser.js +10 -5
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +401 -330
- package/dist/auth/index.js +12 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.browser.js +50 -28
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +382 -344
- package/dist/core/index.js +65 -37
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +381 -0
- package/dist/core/index.native.js.map +1 -0
- package/dist/form/index.d.ts +2 -2
- package/dist/head/index.browser.js +28 -17
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +270 -267
- package/dist/head/index.js +29 -17
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/index.d.ts +20 -20
- package/dist/i18n/index.js +12 -12
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/dist/websocket/index.js.map +1 -1
- package/package.json +21 -12
- package/src/auth/index.ts +1 -1
- package/src/auth/providers/ReactAuthProvider.ts +1 -1
- package/src/auth/services/ReactAuth.ts +15 -5
- package/src/core/components/NestedView.tsx +6 -2
- package/src/core/components/NotFound.tsx +10 -6
- package/src/core/hooks/useStore.ts +4 -4
- package/src/core/index.browser.ts +2 -2
- package/src/core/index.native.ts +1 -1
- package/src/core/index.shared-router.ts +1 -1
- package/src/core/index.ts +3 -3
- package/src/core/{descriptors → primitives}/$page.ts +20 -20
- package/src/core/providers/ReactBrowserProvider.ts +2 -2
- package/src/core/providers/ReactBrowserRouterProvider.ts +3 -2
- package/src/core/providers/ReactPageProvider.ts +28 -11
- package/src/core/providers/ReactServerProvider.ts +34 -23
- package/src/core/services/ReactPageServerService.ts +6 -6
- package/src/core/services/ReactPageService.ts +6 -6
- package/src/core/services/ReactRouter.ts +19 -3
- package/src/head/index.browser.ts +3 -3
- package/src/head/index.ts +4 -4
- package/src/head/interfaces/Head.ts +1 -0
- package/src/head/{descriptors → primitives}/$head.ts +10 -7
- package/src/head/providers/BrowserHeadProvider.ts +13 -0
- package/src/head/providers/HeadProvider.ts +11 -9
- package/src/head/providers/ServerHeadProvider.ts +6 -0
- package/src/i18n/hooks/useI18n.ts +2 -2
- package/src/i18n/index.ts +3 -3
- package/src/i18n/{descriptors → primitives}/$dictionary.ts +8 -8
- package/src/i18n/providers/I18nProvider.ts +5 -5
- package/src/websocket/hooks/useRoom.tsx +3 -3
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,256 +1,57 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Alepha, AlephaError, Async,
|
|
3
|
-
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
4
|
-
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
1
|
+
import * as alepha4 from "alepha";
|
|
2
|
+
import { Alepha, AlephaError, Async, FileLike, InstantiableClass, LogLevel, LoggerInterface, Primitive, Static, StreamLike, TArray, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
5
3
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
6
4
|
import { Readable } from "node:stream";
|
|
7
5
|
import { ReadableStream } from "node:stream/web";
|
|
6
|
+
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
7
|
+
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
8
8
|
|
|
9
9
|
//#region ../alepha/src/security/schemas/userAccountInfoSchema.d.ts
|
|
10
|
-
declare const userAccountInfoSchema:
|
|
11
|
-
id:
|
|
12
|
-
name:
|
|
13
|
-
email:
|
|
14
|
-
username:
|
|
15
|
-
picture:
|
|
16
|
-
sessionId:
|
|
17
|
-
organizations:
|
|
18
|
-
roles:
|
|
10
|
+
declare const userAccountInfoSchema: alepha4.TObject<{
|
|
11
|
+
id: alepha4.TString;
|
|
12
|
+
name: alepha4.TOptional<alepha4.TString>;
|
|
13
|
+
email: alepha4.TOptional<alepha4.TString>;
|
|
14
|
+
username: alepha4.TOptional<alepha4.TString>;
|
|
15
|
+
picture: alepha4.TOptional<alepha4.TString>;
|
|
16
|
+
sessionId: alepha4.TOptional<alepha4.TString>;
|
|
17
|
+
organizations: alepha4.TOptional<alepha4.TArray<alepha4.TString>>;
|
|
18
|
+
roles: alepha4.TOptional<alepha4.TArray<alepha4.TString>>;
|
|
19
19
|
}>;
|
|
20
20
|
type UserAccount = Static<typeof userAccountInfoSchema>;
|
|
21
21
|
//#endregion
|
|
22
|
-
//#region ../alepha/src/
|
|
23
|
-
declare const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
type LogEntry = Static<typeof logEntrySchema>;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
36
|
-
type DateTime = DayjsApi.Dayjs;
|
|
37
|
-
type Duration = dayjsDuration.Duration;
|
|
38
|
-
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
39
|
-
declare class DateTimeProvider {
|
|
40
|
-
static PLUGINS: Array<PluginFunc<any>>;
|
|
41
|
-
protected alepha: Alepha;
|
|
42
|
-
protected ref: DateTime | null;
|
|
43
|
-
protected readonly timeouts: Timeout[];
|
|
44
|
-
protected readonly intervals: Interval[];
|
|
45
|
-
constructor();
|
|
46
|
-
protected readonly onStart: alepha18.HookDescriptor<"start">;
|
|
47
|
-
protected readonly onStop: alepha18.HookDescriptor<"stop">;
|
|
48
|
-
setLocale(locale: string): void;
|
|
49
|
-
isDateTime(value: unknown): value is DateTime;
|
|
50
|
-
/**
|
|
51
|
-
* Create a new UTC DateTime instance.
|
|
52
|
-
*/
|
|
53
|
-
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
54
|
-
/**
|
|
55
|
-
* Create a new DateTime instance.
|
|
56
|
-
*/
|
|
57
|
-
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
58
|
-
/**
|
|
59
|
-
* Get the current date as a string.
|
|
60
|
-
*/
|
|
61
|
-
toISOString(date?: Date | string | DateTime): string;
|
|
62
|
-
/**
|
|
63
|
-
* Get the current date.
|
|
64
|
-
*/
|
|
65
|
-
now(): DateTime;
|
|
66
|
-
/**
|
|
67
|
-
* Get the current date as a string.
|
|
68
|
-
*
|
|
69
|
-
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
70
|
-
*/
|
|
71
|
-
nowISOString(): string;
|
|
72
|
-
/**
|
|
73
|
-
* Get the current date as milliseconds since epoch.
|
|
74
|
-
*
|
|
75
|
-
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
76
|
-
*/
|
|
77
|
-
nowMillis(): number;
|
|
78
|
-
/**
|
|
79
|
-
* Get the current date as a string.
|
|
80
|
-
*
|
|
81
|
-
* @protected
|
|
82
|
-
*/
|
|
83
|
-
protected getCurrentDate(): DateTime;
|
|
84
|
-
/**
|
|
85
|
-
* Create a new Duration instance.
|
|
86
|
-
*/
|
|
87
|
-
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
88
|
-
isDurationLike(value: unknown): value is DurationLike;
|
|
89
|
-
/**
|
|
90
|
-
* Return a promise that resolves after the next tick.
|
|
91
|
-
* It uses `setTimeout` with 0 ms delay.
|
|
92
|
-
*/
|
|
93
|
-
tick(): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* Wait for a certain duration.
|
|
96
|
-
*
|
|
97
|
-
* You can clear the timeout by using the `AbortSignal` API.
|
|
98
|
-
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
99
|
-
*/
|
|
100
|
-
wait(duration: DurationLike, options?: {
|
|
101
|
-
signal?: AbortSignal;
|
|
102
|
-
now?: number;
|
|
103
|
-
}): Promise<void>;
|
|
104
|
-
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
105
|
-
/**
|
|
106
|
-
* Run a callback after a certain duration.
|
|
107
|
-
*/
|
|
108
|
-
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
109
|
-
clearTimeout(timeout: Timeout): void;
|
|
110
|
-
clearInterval(interval: Interval): void;
|
|
111
|
-
/**
|
|
112
|
-
* Run a function with a deadline.
|
|
113
|
-
*/
|
|
114
|
-
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
115
|
-
/**
|
|
116
|
-
* Add time to the current date.
|
|
117
|
-
*/
|
|
118
|
-
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* Stop the time.
|
|
121
|
-
*/
|
|
122
|
-
pause(): DateTime;
|
|
123
|
-
/**
|
|
124
|
-
* Reset the reference date.
|
|
125
|
-
*/
|
|
126
|
-
reset(): void;
|
|
127
|
-
}
|
|
128
|
-
interface Interval {
|
|
129
|
-
timer?: any;
|
|
130
|
-
duration: number;
|
|
131
|
-
run: () => unknown;
|
|
132
|
-
}
|
|
133
|
-
interface Timeout {
|
|
134
|
-
now: number;
|
|
135
|
-
timer?: any;
|
|
136
|
-
duration: number;
|
|
137
|
-
callback: () => void;
|
|
138
|
-
clear: () => void;
|
|
139
|
-
}
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
142
|
-
declare abstract class LogDestinationProvider {
|
|
143
|
-
abstract write(message: string, entry: LogEntry): void;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
147
|
-
declare abstract class LogFormatterProvider {
|
|
148
|
-
abstract format(entry: LogEntry): string;
|
|
149
|
-
}
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
152
|
-
declare class Logger implements LoggerInterface {
|
|
153
|
-
protected readonly alepha: Alepha;
|
|
154
|
-
protected readonly formatter: LogFormatterProvider;
|
|
155
|
-
protected readonly destination: LogDestinationProvider;
|
|
156
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
157
|
-
protected readonly levels: Record<string, number>;
|
|
158
|
-
protected readonly service: string;
|
|
159
|
-
protected readonly module: string;
|
|
160
|
-
protected readonly app?: string;
|
|
161
|
-
protected appLogLevel: string;
|
|
162
|
-
protected logLevel: LogLevel;
|
|
163
|
-
constructor(service: string, module: string);
|
|
164
|
-
get context(): string | undefined;
|
|
165
|
-
get level(): string;
|
|
166
|
-
parseLevel(level: string, app: string): LogLevel;
|
|
167
|
-
private matchesPattern;
|
|
168
|
-
asLogLevel(something: string): LogLevel;
|
|
169
|
-
error(message: string, data?: unknown): void;
|
|
170
|
-
warn(message: string, data?: unknown): void;
|
|
171
|
-
info(message: string, data?: unknown): void;
|
|
172
|
-
debug(message: string, data?: unknown): void;
|
|
173
|
-
trace(message: string, data?: unknown): void;
|
|
174
|
-
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
175
|
-
protected emit(entry: LogEntry, message?: string): void;
|
|
176
|
-
}
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region ../alepha/src/logger/index.d.ts
|
|
179
|
-
declare const envSchema$3: alepha18.TObject<{
|
|
180
|
-
/**
|
|
181
|
-
* Default log level for the application.
|
|
182
|
-
*
|
|
183
|
-
* Default by environment:
|
|
184
|
-
* - dev = info
|
|
185
|
-
* - prod = info
|
|
186
|
-
* - test = error
|
|
187
|
-
*
|
|
188
|
-
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
189
|
-
*
|
|
190
|
-
* Level can be set for a specific module:
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
194
|
-
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
195
|
-
*/
|
|
196
|
-
LOG_LEVEL: alepha18.TOptional<alepha18.TString>;
|
|
197
|
-
/**
|
|
198
|
-
* Built-in log formats.
|
|
199
|
-
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
200
|
-
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
201
|
-
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
202
|
-
*/
|
|
203
|
-
LOG_FORMAT: alepha18.TOptional<alepha18.TUnsafe<"json" | "pretty" | "raw">>;
|
|
22
|
+
//#region ../alepha/src/server/schemas/errorSchema.d.ts
|
|
23
|
+
declare const errorSchema: alepha4.TObject<{
|
|
24
|
+
error: alepha4.TString;
|
|
25
|
+
status: alepha4.TInteger;
|
|
26
|
+
message: alepha4.TString;
|
|
27
|
+
details: alepha4.TOptional<alepha4.TString>;
|
|
28
|
+
requestId: alepha4.TOptional<alepha4.TString>;
|
|
29
|
+
cause: alepha4.TOptional<alepha4.TObject<{
|
|
30
|
+
name: alepha4.TString;
|
|
31
|
+
message: alepha4.TString;
|
|
32
|
+
}>>;
|
|
204
33
|
}>;
|
|
205
|
-
|
|
206
|
-
interface Env extends Partial<Static<typeof envSchema$3>> {}
|
|
207
|
-
interface State {
|
|
208
|
-
/**
|
|
209
|
-
* Current log level for the application or specific modules.
|
|
210
|
-
*/
|
|
211
|
-
"alepha.logger.level"?: string;
|
|
212
|
-
}
|
|
213
|
-
interface Hooks {
|
|
214
|
-
log: {
|
|
215
|
-
message?: string;
|
|
216
|
-
entry: LogEntry;
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
34
|
+
type ErrorSchema = Static<typeof errorSchema>;
|
|
220
35
|
//#endregion
|
|
221
|
-
//#region ../alepha/src/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Is user dedicated to his own resources for this scope ?
|
|
237
|
-
* Mostly, Admin is false and Customer is true.
|
|
238
|
-
*/
|
|
239
|
-
ownership?: string | boolean;
|
|
36
|
+
//#region ../alepha/src/server/errors/HttpError.d.ts
|
|
37
|
+
declare class HttpError extends AlephaError {
|
|
38
|
+
name: string;
|
|
39
|
+
static is: (error: unknown, status?: number) => error is HttpErrorLike;
|
|
40
|
+
static toJSON(error: HttpError): ErrorSchema;
|
|
41
|
+
readonly error: string;
|
|
42
|
+
readonly status: number;
|
|
43
|
+
readonly requestId?: string;
|
|
44
|
+
readonly details?: string;
|
|
45
|
+
readonly reason?: {
|
|
46
|
+
name: string;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
constructor(options: Partial<ErrorSchema>, cause?: unknown);
|
|
240
50
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
declare const envSchema$2: alepha18.TObject<{
|
|
244
|
-
APP_SECRET: alepha18.TString;
|
|
245
|
-
}>;
|
|
246
|
-
declare module "alepha" {
|
|
247
|
-
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
51
|
+
interface HttpErrorLike extends Error {
|
|
52
|
+
status: number;
|
|
248
53
|
}
|
|
249
54
|
//#endregion
|
|
250
|
-
//#region ../alepha/src/server/constants/routeMethods.d.ts
|
|
251
|
-
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
252
|
-
type RouteMethod = (typeof routeMethods)[number];
|
|
253
|
-
//#endregion
|
|
254
55
|
//#region ../alepha/src/router/providers/RouterProvider.d.ts
|
|
255
56
|
declare abstract class RouterProvider<T extends Route = Route> {
|
|
256
57
|
protected routePathRegex: RegExp;
|
|
@@ -295,6 +96,10 @@ interface Tree<T extends Route> {
|
|
|
295
96
|
};
|
|
296
97
|
}
|
|
297
98
|
//#endregion
|
|
99
|
+
//#region ../alepha/src/server/constants/routeMethods.d.ts
|
|
100
|
+
declare const routeMethods: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE"];
|
|
101
|
+
type RouteMethod = (typeof routeMethods)[number];
|
|
102
|
+
//#endregion
|
|
298
103
|
//#region ../alepha/src/server/helpers/ServerReply.d.ts
|
|
299
104
|
/**
|
|
300
105
|
* Helper for building server replies.
|
|
@@ -461,6 +266,205 @@ interface WebRequestEvent {
|
|
|
461
266
|
res?: Response;
|
|
462
267
|
}
|
|
463
268
|
//#endregion
|
|
269
|
+
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
270
|
+
declare const logEntrySchema: alepha4.TObject<{
|
|
271
|
+
level: alepha4.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
272
|
+
message: alepha4.TString;
|
|
273
|
+
service: alepha4.TString;
|
|
274
|
+
module: alepha4.TString;
|
|
275
|
+
context: alepha4.TOptional<alepha4.TString>;
|
|
276
|
+
app: alepha4.TOptional<alepha4.TString>;
|
|
277
|
+
data: alepha4.TOptional<alepha4.TAny>;
|
|
278
|
+
timestamp: alepha4.TNumber;
|
|
279
|
+
}>;
|
|
280
|
+
type LogEntry = Static<typeof logEntrySchema>;
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
283
|
+
type DateTime = DayjsApi.Dayjs;
|
|
284
|
+
type Duration = dayjsDuration.Duration;
|
|
285
|
+
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
286
|
+
declare class DateTimeProvider {
|
|
287
|
+
static PLUGINS: Array<PluginFunc<any>>;
|
|
288
|
+
protected alepha: Alepha;
|
|
289
|
+
protected ref: DateTime | null;
|
|
290
|
+
protected readonly timeouts: Timeout[];
|
|
291
|
+
protected readonly intervals: Interval[];
|
|
292
|
+
constructor();
|
|
293
|
+
protected readonly onStart: alepha4.HookPrimitive<"start">;
|
|
294
|
+
protected readonly onStop: alepha4.HookPrimitive<"stop">;
|
|
295
|
+
setLocale(locale: string): void;
|
|
296
|
+
isDateTime(value: unknown): value is DateTime;
|
|
297
|
+
/**
|
|
298
|
+
* Create a new UTC DateTime instance.
|
|
299
|
+
*/
|
|
300
|
+
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
301
|
+
/**
|
|
302
|
+
* Create a new DateTime instance.
|
|
303
|
+
*/
|
|
304
|
+
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
305
|
+
/**
|
|
306
|
+
* Get the current date as a string.
|
|
307
|
+
*/
|
|
308
|
+
toISOString(date?: Date | string | DateTime): string;
|
|
309
|
+
/**
|
|
310
|
+
* Get the current date.
|
|
311
|
+
*/
|
|
312
|
+
now(): DateTime;
|
|
313
|
+
/**
|
|
314
|
+
* Get the current date as a string.
|
|
315
|
+
*
|
|
316
|
+
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
317
|
+
*/
|
|
318
|
+
nowISOString(): string;
|
|
319
|
+
/**
|
|
320
|
+
* Get the current date as milliseconds since epoch.
|
|
321
|
+
*
|
|
322
|
+
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
323
|
+
*/
|
|
324
|
+
nowMillis(): number;
|
|
325
|
+
/**
|
|
326
|
+
* Get the current date as a string.
|
|
327
|
+
*
|
|
328
|
+
* @protected
|
|
329
|
+
*/
|
|
330
|
+
protected getCurrentDate(): DateTime;
|
|
331
|
+
/**
|
|
332
|
+
* Create a new Duration instance.
|
|
333
|
+
*/
|
|
334
|
+
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
335
|
+
isDurationLike(value: unknown): value is DurationLike;
|
|
336
|
+
/**
|
|
337
|
+
* Return a promise that resolves after the next tick.
|
|
338
|
+
* It uses `setTimeout` with 0 ms delay.
|
|
339
|
+
*/
|
|
340
|
+
tick(): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Wait for a certain duration.
|
|
343
|
+
*
|
|
344
|
+
* You can clear the timeout by using the `AbortSignal` API.
|
|
345
|
+
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
346
|
+
*/
|
|
347
|
+
wait(duration: DurationLike, options?: {
|
|
348
|
+
signal?: AbortSignal;
|
|
349
|
+
now?: number;
|
|
350
|
+
}): Promise<void>;
|
|
351
|
+
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
352
|
+
/**
|
|
353
|
+
* Run a callback after a certain duration.
|
|
354
|
+
*/
|
|
355
|
+
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
356
|
+
clearTimeout(timeout: Timeout): void;
|
|
357
|
+
clearInterval(interval: Interval): void;
|
|
358
|
+
/**
|
|
359
|
+
* Run a function with a deadline.
|
|
360
|
+
*/
|
|
361
|
+
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
362
|
+
/**
|
|
363
|
+
* Add time to the current date.
|
|
364
|
+
*/
|
|
365
|
+
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Stop the time.
|
|
368
|
+
*/
|
|
369
|
+
pause(): DateTime;
|
|
370
|
+
/**
|
|
371
|
+
* Reset the reference date.
|
|
372
|
+
*/
|
|
373
|
+
reset(): void;
|
|
374
|
+
}
|
|
375
|
+
interface Interval {
|
|
376
|
+
timer?: any;
|
|
377
|
+
duration: number;
|
|
378
|
+
run: () => unknown;
|
|
379
|
+
}
|
|
380
|
+
interface Timeout {
|
|
381
|
+
now: number;
|
|
382
|
+
timer?: any;
|
|
383
|
+
duration: number;
|
|
384
|
+
callback: () => void;
|
|
385
|
+
clear: () => void;
|
|
386
|
+
}
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
389
|
+
declare abstract class LogDestinationProvider {
|
|
390
|
+
abstract write(message: string, entry: LogEntry): void;
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
394
|
+
declare abstract class LogFormatterProvider {
|
|
395
|
+
abstract format(entry: LogEntry): string;
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
399
|
+
declare class Logger implements LoggerInterface {
|
|
400
|
+
protected readonly alepha: Alepha;
|
|
401
|
+
protected readonly formatter: LogFormatterProvider;
|
|
402
|
+
protected readonly destination: LogDestinationProvider;
|
|
403
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
404
|
+
protected readonly levels: Record<string, number>;
|
|
405
|
+
protected readonly service: string;
|
|
406
|
+
protected readonly module: string;
|
|
407
|
+
protected readonly app?: string;
|
|
408
|
+
protected appLogLevel: string;
|
|
409
|
+
protected logLevel: LogLevel;
|
|
410
|
+
constructor(service: string, module: string);
|
|
411
|
+
get context(): string | undefined;
|
|
412
|
+
get level(): string;
|
|
413
|
+
parseLevel(level: string, app: string): LogLevel;
|
|
414
|
+
private matchesPattern;
|
|
415
|
+
asLogLevel(something: string): LogLevel;
|
|
416
|
+
error(message: string, data?: unknown): void;
|
|
417
|
+
warn(message: string, data?: unknown): void;
|
|
418
|
+
info(message: string, data?: unknown): void;
|
|
419
|
+
debug(message: string, data?: unknown): void;
|
|
420
|
+
trace(message: string, data?: unknown): void;
|
|
421
|
+
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
422
|
+
protected emit(entry: LogEntry, message?: string): void;
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region ../alepha/src/logger/index.d.ts
|
|
426
|
+
declare const envSchema$3: alepha4.TObject<{
|
|
427
|
+
/**
|
|
428
|
+
* Default log level for the application.
|
|
429
|
+
*
|
|
430
|
+
* Default by environment:
|
|
431
|
+
* - dev = info
|
|
432
|
+
* - prod = info
|
|
433
|
+
* - test = error
|
|
434
|
+
*
|
|
435
|
+
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
436
|
+
*
|
|
437
|
+
* Level can be set for a specific module:
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
441
|
+
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
442
|
+
*/
|
|
443
|
+
LOG_LEVEL: alepha4.TOptional<alepha4.TString>;
|
|
444
|
+
/**
|
|
445
|
+
* Built-in log formats.
|
|
446
|
+
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
447
|
+
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
448
|
+
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
449
|
+
*/
|
|
450
|
+
LOG_FORMAT: alepha4.TOptional<alepha4.TUnsafe<"json" | "pretty" | "raw">>;
|
|
451
|
+
}>;
|
|
452
|
+
declare module "alepha" {
|
|
453
|
+
interface Env extends Partial<Static<typeof envSchema$3>> {}
|
|
454
|
+
interface State {
|
|
455
|
+
/**
|
|
456
|
+
* Current log level for the application or specific modules.
|
|
457
|
+
*/
|
|
458
|
+
"alepha.logger.level"?: string;
|
|
459
|
+
}
|
|
460
|
+
interface Hooks {
|
|
461
|
+
log: {
|
|
462
|
+
message?: string;
|
|
463
|
+
entry: LogEntry;
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
464
468
|
//#region ../alepha/src/server/services/ServerRequestParser.d.ts
|
|
465
469
|
declare class ServerRequestParser {
|
|
466
470
|
protected readonly alepha: Alepha;
|
|
@@ -480,8 +484,8 @@ declare class ServerTimingProvider {
|
|
|
480
484
|
prefix: string;
|
|
481
485
|
disabled: boolean;
|
|
482
486
|
};
|
|
483
|
-
readonly onRequest:
|
|
484
|
-
readonly onResponse:
|
|
487
|
+
readonly onRequest: alepha4.HookPrimitive<"server:onRequest">;
|
|
488
|
+
readonly onResponse: alepha4.HookPrimitive<"server:onResponse">;
|
|
485
489
|
protected get handlerName(): string;
|
|
486
490
|
beginTiming(name: string): void;
|
|
487
491
|
endTiming(name: string): void;
|
|
@@ -545,11 +549,11 @@ declare class ServerProvider {
|
|
|
545
549
|
/**
|
|
546
550
|
* When a Node.js HTTP request is received from outside. (Vercel, AWS Lambda, etc.)
|
|
547
551
|
*/
|
|
548
|
-
protected readonly onNodeRequest:
|
|
552
|
+
protected readonly onNodeRequest: alepha4.HookPrimitive<"node:request">;
|
|
549
553
|
/**
|
|
550
554
|
* When a Web (Fetch API) request is received from outside. (Netlify, Cloudflare Workers, etc.)
|
|
551
555
|
*/
|
|
552
|
-
protected readonly onWebRequest:
|
|
556
|
+
protected readonly onWebRequest: alepha4.HookPrimitive<"web:request">;
|
|
553
557
|
/**
|
|
554
558
|
* Handle Node.js HTTP request event.
|
|
555
559
|
*
|
|
@@ -609,8 +613,8 @@ declare abstract class CacheProvider {
|
|
|
609
613
|
abstract clear(): Promise<void>;
|
|
610
614
|
}
|
|
611
615
|
//#endregion
|
|
612
|
-
//#region ../alepha/src/cache/
|
|
613
|
-
interface
|
|
616
|
+
//#region ../alepha/src/cache/primitives/$cache.d.ts
|
|
617
|
+
interface CachePrimitiveOptions<TReturn = any, TParameter extends any[] = any[]> {
|
|
614
618
|
/**
|
|
615
619
|
* The cache name. This is useful for invalidating multiple caches at once.
|
|
616
620
|
*
|
|
@@ -645,7 +649,7 @@ interface CacheDescriptorOptions<TReturn = any, TParameter extends any[] = any[]
|
|
|
645
649
|
*/
|
|
646
650
|
disabled?: boolean;
|
|
647
651
|
}
|
|
648
|
-
declare class
|
|
652
|
+
declare class CachePrimitive<TReturn = any, TParameter extends any[] = any[]> extends Primitive<CachePrimitiveOptions<TReturn, TParameter>> {
|
|
649
653
|
protected readonly env: {
|
|
650
654
|
CACHE_ENABLED: boolean;
|
|
651
655
|
CACHE_DEFAULT_TTL: number;
|
|
@@ -669,9 +673,9 @@ declare class CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> e
|
|
|
669
673
|
protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
|
|
670
674
|
protected $provider(): CacheProvider;
|
|
671
675
|
}
|
|
672
|
-
interface
|
|
676
|
+
interface CachePrimitiveFn<TReturn = any, TParameter extends any[] = any[]> extends CachePrimitive<TReturn, TParameter> {
|
|
673
677
|
/**
|
|
674
|
-
* Run the cache
|
|
678
|
+
* Run the cache primitive with the provided arguments.
|
|
675
679
|
*/
|
|
676
680
|
(...args: TParameter): Promise<TReturn>;
|
|
677
681
|
}
|
|
@@ -680,7 +684,7 @@ interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> ext
|
|
|
680
684
|
declare class HttpClient {
|
|
681
685
|
protected readonly log: Logger;
|
|
682
686
|
protected readonly alepha: Alepha;
|
|
683
|
-
readonly cache:
|
|
687
|
+
readonly cache: CachePrimitiveFn<HttpClientCache, any[]>;
|
|
684
688
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
685
689
|
fetchAction(args: FetchActionArgs): Promise<FetchResponse>;
|
|
686
690
|
fetch<T extends TSchema>(url: string, request?: RequestInitWithOptions<T>): Promise<FetchResponse<Static<T>>>;
|
|
@@ -748,8 +752,8 @@ interface HttpAction {
|
|
|
748
752
|
};
|
|
749
753
|
}
|
|
750
754
|
//#endregion
|
|
751
|
-
//#region ../alepha/src/server/
|
|
752
|
-
interface
|
|
755
|
+
//#region ../alepha/src/server/primitives/$action.d.ts
|
|
756
|
+
interface ActionPrimitiveOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
|
|
753
757
|
/**
|
|
754
758
|
* Name of the action.
|
|
755
759
|
*
|
|
@@ -815,7 +819,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
|
|
|
815
819
|
*/
|
|
816
820
|
handler: ServerActionHandler<TConfig>;
|
|
817
821
|
}
|
|
818
|
-
declare class
|
|
822
|
+
declare class ActionPrimitive<TConfig extends RequestConfigSchema> extends Primitive<ActionPrimitiveOptions<TConfig>> {
|
|
819
823
|
protected readonly log: Logger;
|
|
820
824
|
protected readonly env: {
|
|
821
825
|
SERVER_API_PREFIX: string;
|
|
@@ -883,55 +887,22 @@ type ServerActionHandler<TConfig extends RequestConfigSchema = RequestConfigSche
|
|
|
883
887
|
*/
|
|
884
888
|
interface ServerActionRequest<TConfig extends RequestConfigSchema> extends ServerRequest<TConfig> {}
|
|
885
889
|
//#endregion
|
|
886
|
-
//#region ../alepha/src/server/schemas/errorSchema.d.ts
|
|
887
|
-
declare const errorSchema: alepha18.TObject<{
|
|
888
|
-
error: alepha18.TString;
|
|
889
|
-
status: alepha18.TInteger;
|
|
890
|
-
message: alepha18.TString;
|
|
891
|
-
details: alepha18.TOptional<alepha18.TString>;
|
|
892
|
-
requestId: alepha18.TOptional<alepha18.TString>;
|
|
893
|
-
cause: alepha18.TOptional<alepha18.TObject<{
|
|
894
|
-
name: alepha18.TString;
|
|
895
|
-
message: alepha18.TString;
|
|
896
|
-
}>>;
|
|
897
|
-
}>;
|
|
898
|
-
type ErrorSchema = Static<typeof errorSchema>;
|
|
899
|
-
//#endregion
|
|
900
|
-
//#region ../alepha/src/server/errors/HttpError.d.ts
|
|
901
|
-
declare class HttpError extends AlephaError {
|
|
902
|
-
name: string;
|
|
903
|
-
static is: (error: unknown, status?: number) => error is HttpErrorLike;
|
|
904
|
-
static toJSON(error: HttpError): ErrorSchema;
|
|
905
|
-
readonly error: string;
|
|
906
|
-
readonly status: number;
|
|
907
|
-
readonly requestId?: string;
|
|
908
|
-
readonly details?: string;
|
|
909
|
-
readonly reason?: {
|
|
910
|
-
name: string;
|
|
911
|
-
message: string;
|
|
912
|
-
};
|
|
913
|
-
constructor(options: Partial<ErrorSchema>, cause?: unknown);
|
|
914
|
-
}
|
|
915
|
-
interface HttpErrorLike extends Error {
|
|
916
|
-
status: number;
|
|
917
|
-
}
|
|
918
|
-
//#endregion
|
|
919
890
|
//#region ../alepha/src/server/providers/BunHttpServerProvider.d.ts
|
|
920
|
-
declare const envSchema$
|
|
921
|
-
SERVER_PORT:
|
|
922
|
-
SERVER_HOST:
|
|
891
|
+
declare const envSchema$2: alepha4.TObject<{
|
|
892
|
+
SERVER_PORT: alepha4.TInteger;
|
|
893
|
+
SERVER_HOST: alepha4.TString;
|
|
923
894
|
}>;
|
|
924
895
|
declare module "alepha" {
|
|
925
|
-
interface Env extends Partial<Static<typeof envSchema$
|
|
896
|
+
interface Env extends Partial<Static<typeof envSchema$2>> {}
|
|
926
897
|
}
|
|
927
898
|
//#endregion
|
|
928
899
|
//#region ../alepha/src/server/providers/NodeHttpServerProvider.d.ts
|
|
929
|
-
declare const envSchema:
|
|
930
|
-
SERVER_PORT:
|
|
931
|
-
SERVER_HOST:
|
|
900
|
+
declare const envSchema$1: alepha4.TObject<{
|
|
901
|
+
SERVER_PORT: alepha4.TInteger;
|
|
902
|
+
SERVER_HOST: alepha4.TString;
|
|
932
903
|
}>;
|
|
933
904
|
declare module "alepha" {
|
|
934
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
905
|
+
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
935
906
|
}
|
|
936
907
|
//#endregion
|
|
937
908
|
//#region ../alepha/src/server/index.d.ts
|
|
@@ -941,12 +912,12 @@ declare module "alepha" {
|
|
|
941
912
|
}
|
|
942
913
|
interface Hooks {
|
|
943
914
|
"action:onRequest": {
|
|
944
|
-
action:
|
|
915
|
+
action: ActionPrimitive<RequestConfigSchema>;
|
|
945
916
|
request: ServerRequest;
|
|
946
917
|
options: ClientRequestOptions;
|
|
947
918
|
};
|
|
948
919
|
"action:onResponse": {
|
|
949
|
-
action:
|
|
920
|
+
action: ActionPrimitive<RequestConfigSchema>;
|
|
950
921
|
request: ServerRequest;
|
|
951
922
|
options: ClientRequestOptions;
|
|
952
923
|
response: any;
|
|
@@ -990,6 +961,35 @@ declare module "alepha" {
|
|
|
990
961
|
}
|
|
991
962
|
}
|
|
992
963
|
//#endregion
|
|
964
|
+
//#region ../alepha/src/security/interfaces/UserAccountToken.d.ts
|
|
965
|
+
/**
|
|
966
|
+
* Add contextual metadata to a user account info.
|
|
967
|
+
* E.g. UserAccountToken is a UserAccountInfo during a request.
|
|
968
|
+
*/
|
|
969
|
+
interface UserAccountToken extends UserAccount {
|
|
970
|
+
/**
|
|
971
|
+
* Access token for the user.
|
|
972
|
+
*/
|
|
973
|
+
token?: string;
|
|
974
|
+
/**
|
|
975
|
+
* Realm name of the user.
|
|
976
|
+
*/
|
|
977
|
+
realm?: string;
|
|
978
|
+
/**
|
|
979
|
+
* Is user dedicated to his own resources for this scope ?
|
|
980
|
+
* Mostly, Admin is false and Customer is true.
|
|
981
|
+
*/
|
|
982
|
+
ownership?: string | boolean;
|
|
983
|
+
}
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region ../alepha/src/security/providers/SecurityProvider.d.ts
|
|
986
|
+
declare const envSchema: alepha4.TObject<{
|
|
987
|
+
APP_SECRET: alepha4.TString;
|
|
988
|
+
}>;
|
|
989
|
+
declare module "alepha" {
|
|
990
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
991
|
+
}
|
|
992
|
+
//#endregion
|
|
993
993
|
//#region ../alepha/src/security/index.d.ts
|
|
994
994
|
declare module "alepha" {
|
|
995
995
|
interface Hooks {
|
|
@@ -1002,7 +1002,7 @@ declare module "alepha" {
|
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
|
|
1004
1004
|
*
|
|
1005
|
-
* The security module enables building secure applications using
|
|
1005
|
+
* The security module enables building secure applications using primitives like `$realm`, `$role`, and `$permission`
|
|
1006
1006
|
* on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
|
|
1007
1007
|
* integration with various authentication providers and user management systems.
|
|
1008
1008
|
*
|
|
@@ -1077,22 +1077,91 @@ declare module "alepha/server" {
|
|
|
1077
1077
|
*/
|
|
1078
1078
|
//#endregion
|
|
1079
1079
|
//#region ../alepha/src/server-links/schemas/apiLinksResponseSchema.d.ts
|
|
1080
|
-
declare const
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1080
|
+
declare const apiLinkSchema: alepha4.TObject<{
|
|
1081
|
+
name: alepha4.TString;
|
|
1082
|
+
group: alepha4.TOptional<alepha4.TString>;
|
|
1083
|
+
path: alepha4.TString;
|
|
1084
|
+
method: alepha4.TOptional<alepha4.TString>;
|
|
1085
|
+
requestBodyType: alepha4.TOptional<alepha4.TString>;
|
|
1086
|
+
service: alepha4.TOptional<alepha4.TString>;
|
|
1087
|
+
}>;
|
|
1088
|
+
declare const apiLinksResponseSchema: alepha4.TObject<{
|
|
1089
|
+
prefix: alepha4.TOptional<alepha4.TString>;
|
|
1090
|
+
links: alepha4.TArray<alepha4.TObject<{
|
|
1091
|
+
name: alepha4.TString;
|
|
1092
|
+
group: alepha4.TOptional<alepha4.TString>;
|
|
1093
|
+
path: alepha4.TString;
|
|
1094
|
+
method: alepha4.TOptional<alepha4.TString>;
|
|
1095
|
+
requestBodyType: alepha4.TOptional<alepha4.TString>;
|
|
1096
|
+
service: alepha4.TOptional<alepha4.TString>;
|
|
1089
1097
|
}>>;
|
|
1090
1098
|
}>;
|
|
1091
1099
|
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
1100
|
+
type ApiLink = Static<typeof apiLinkSchema>;
|
|
1092
1101
|
//#endregion
|
|
1093
1102
|
//#region ../alepha/src/server-links/providers/LinkProvider.d.ts
|
|
1094
|
-
|
|
1095
|
-
|
|
1103
|
+
/**
|
|
1104
|
+
* Browser, SSR friendly, service to handle links.
|
|
1105
|
+
*/
|
|
1106
|
+
declare class LinkProvider {
|
|
1107
|
+
static path: {
|
|
1108
|
+
apiLinks: string;
|
|
1109
|
+
apiSchema: string;
|
|
1110
|
+
};
|
|
1111
|
+
protected readonly log: Logger;
|
|
1112
|
+
protected readonly alepha: Alepha;
|
|
1113
|
+
protected readonly httpClient: HttpClient;
|
|
1114
|
+
protected serverLinks: Array<HttpClientLink>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Get applicative links registered on the server.
|
|
1117
|
+
* This does not include lazy-loaded remote links.
|
|
1118
|
+
*/
|
|
1119
|
+
getServerLinks(): HttpClientLink[];
|
|
1120
|
+
/**
|
|
1121
|
+
* Register a new link for the application.
|
|
1122
|
+
*/
|
|
1123
|
+
registerLink(link: HttpClientLink): void;
|
|
1124
|
+
get links(): HttpClientLink[];
|
|
1125
|
+
/**
|
|
1126
|
+
* Force browser to refresh links from the server.
|
|
1127
|
+
*/
|
|
1128
|
+
fetchLinks(): Promise<HttpClientLink[]>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Create a virtual client that can be used to call actions.
|
|
1131
|
+
*
|
|
1132
|
+
* Use js Proxy under the hood.
|
|
1133
|
+
*/
|
|
1134
|
+
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Check if a link with the given name exists.
|
|
1137
|
+
* @param name
|
|
1138
|
+
*/
|
|
1139
|
+
can(name: string): boolean;
|
|
1140
|
+
/**
|
|
1141
|
+
* Resolve a link by its name and call it.
|
|
1142
|
+
* - If link is local, it will call the local handler.
|
|
1143
|
+
* - If link is remote, it will make a fetch request to the remote server.
|
|
1144
|
+
*/
|
|
1145
|
+
follow(name: string, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions & ClientScope): Promise<any>;
|
|
1146
|
+
protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
|
|
1147
|
+
protected followRemote(link: HttpClientLink, config?: Partial<ServerRequestConfigEntry>, options?: ClientRequestOptions): Promise<FetchResponse>;
|
|
1148
|
+
protected getLinkByName(name: string, options?: ClientScope): Promise<HttpClientLink>;
|
|
1149
|
+
}
|
|
1150
|
+
interface HttpClientLink extends ApiLink {
|
|
1151
|
+
secured?: boolean | ServerRouteSecure;
|
|
1152
|
+
prefix?: string;
|
|
1153
|
+
host?: string;
|
|
1154
|
+
service?: string;
|
|
1155
|
+
schema?: RequestConfigSchema;
|
|
1156
|
+
handler?: (request: ServerRequest, options: ClientRequestOptions) => Async<ServerResponseBody>;
|
|
1157
|
+
}
|
|
1158
|
+
interface ClientScope {
|
|
1159
|
+
group?: string;
|
|
1160
|
+
service?: string;
|
|
1161
|
+
hostname?: string;
|
|
1162
|
+
}
|
|
1163
|
+
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionPrimitive<RequestConfigSchema> ? K : never]: T[K] extends ActionPrimitive<infer Schema> ? VirtualAction<Schema> : never };
|
|
1164
|
+
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionPrimitive<T>, "name" | "run" | "fetch"> {
|
|
1096
1165
|
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
1097
1166
|
can: () => boolean;
|
|
1098
1167
|
}
|
|
@@ -1112,7 +1181,7 @@ declare module "alepha" {
|
|
|
1112
1181
|
/**
|
|
1113
1182
|
* Provides server-side link management and remote capabilities for client-server interactions.
|
|
1114
1183
|
*
|
|
1115
|
-
* The server-links module enables declarative link definitions using `$remote` and `$client`
|
|
1184
|
+
* The server-links module enables declarative link definitions using `$remote` and `$client` primitives,
|
|
1116
1185
|
* facilitating seamless API endpoint management and client-server communication. It integrates with server
|
|
1117
1186
|
* security features to ensure safe and controlled access to resources.
|
|
1118
1187
|
*
|
|
@@ -1143,7 +1212,21 @@ declare const useAuth: <T extends object = any>() => {
|
|
|
1143
1212
|
can: <Api extends object = any>(name: keyof HttpVirtualClient<Api>) => boolean;
|
|
1144
1213
|
};
|
|
1145
1214
|
//#endregion
|
|
1146
|
-
//#region ../alepha/src/server-
|
|
1215
|
+
//#region ../alepha/src/server-auth/schemas/tokensSchema.d.ts
|
|
1216
|
+
declare const tokensSchema: alepha4.TObject<{
|
|
1217
|
+
provider: alepha4.TString;
|
|
1218
|
+
access_token: alepha4.TString;
|
|
1219
|
+
issued_at: alepha4.TNumber;
|
|
1220
|
+
expires_in: alepha4.TOptional<alepha4.TNumber>;
|
|
1221
|
+
refresh_token: alepha4.TOptional<alepha4.TString>;
|
|
1222
|
+
refresh_token_expires_in: alepha4.TOptional<alepha4.TNumber>;
|
|
1223
|
+
refresh_expires_in: alepha4.TOptional<alepha4.TNumber>;
|
|
1224
|
+
id_token: alepha4.TOptional<alepha4.TString>;
|
|
1225
|
+
scope: alepha4.TOptional<alepha4.TString>;
|
|
1226
|
+
}>;
|
|
1227
|
+
type Tokens = Static<typeof tokensSchema>;
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region ../alepha/src/server-cookies/primitives/$cookie.d.ts
|
|
1147
1230
|
interface Cookies {
|
|
1148
1231
|
req: Record<string, string>;
|
|
1149
1232
|
res: Record<string, Cookie | null>;
|
|
@@ -1165,9 +1248,9 @@ declare module "alepha/server" {
|
|
|
1165
1248
|
}
|
|
1166
1249
|
}
|
|
1167
1250
|
/**
|
|
1168
|
-
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie
|
|
1251
|
+
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie primitives.
|
|
1169
1252
|
*
|
|
1170
|
-
* The server-cookies module enables declarative cookie handling using the `$cookie`
|
|
1253
|
+
* The server-cookies module enables declarative cookie handling using the `$cookie` primitive on class properties.
|
|
1171
1254
|
* It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
|
|
1172
1255
|
* for managing user sessions, preferences, and authentication tokens.
|
|
1173
1256
|
*
|
|
@@ -1175,20 +1258,6 @@ declare module "alepha/server" {
|
|
|
1175
1258
|
* @module alepha.server.cookies
|
|
1176
1259
|
*/
|
|
1177
1260
|
//#endregion
|
|
1178
|
-
//#region ../alepha/src/server-auth/schemas/tokensSchema.d.ts
|
|
1179
|
-
declare const tokensSchema: alepha18.TObject<{
|
|
1180
|
-
provider: alepha18.TString;
|
|
1181
|
-
access_token: alepha18.TString;
|
|
1182
|
-
issued_at: alepha18.TNumber;
|
|
1183
|
-
expires_in: alepha18.TOptional<alepha18.TNumber>;
|
|
1184
|
-
refresh_token: alepha18.TOptional<alepha18.TString>;
|
|
1185
|
-
refresh_token_expires_in: alepha18.TOptional<alepha18.TNumber>;
|
|
1186
|
-
refresh_expires_in: alepha18.TOptional<alepha18.TNumber>;
|
|
1187
|
-
id_token: alepha18.TOptional<alepha18.TString>;
|
|
1188
|
-
scope: alepha18.TOptional<alepha18.TString>;
|
|
1189
|
-
}>;
|
|
1190
|
-
type Tokens = Static<typeof tokensSchema>;
|
|
1191
|
-
//#endregion
|
|
1192
1261
|
//#region ../alepha/src/server-auth/index.d.ts
|
|
1193
1262
|
declare module "alepha" {
|
|
1194
1263
|
interface State {
|
|
@@ -1222,8 +1291,9 @@ declare class ReactAuth {
|
|
|
1222
1291
|
protected readonly log: Logger;
|
|
1223
1292
|
protected readonly alepha: Alepha;
|
|
1224
1293
|
protected readonly httpClient: HttpClient;
|
|
1225
|
-
protected readonly
|
|
1226
|
-
protected readonly
|
|
1294
|
+
protected readonly linkProvider: LinkProvider;
|
|
1295
|
+
protected readonly onBeginTransition: alepha4.HookPrimitive<"react:transition:begin">;
|
|
1296
|
+
protected readonly onFetchRequest: alepha4.HookPrimitive<"client:onRequest">;
|
|
1227
1297
|
/**
|
|
1228
1298
|
* Get the current authenticated user.
|
|
1229
1299
|
*
|
|
@@ -1240,6 +1310,7 @@ declare class ReactAuth {
|
|
|
1240
1310
|
roles?: string[] | undefined;
|
|
1241
1311
|
id: string;
|
|
1242
1312
|
} | undefined>;
|
|
1313
|
+
can(action: string): boolean;
|
|
1243
1314
|
login(provider: string, options: {
|
|
1244
1315
|
hostname?: string;
|
|
1245
1316
|
username?: string;
|
|
@@ -1253,7 +1324,7 @@ declare class ReactAuth {
|
|
|
1253
1324
|
//#region src/auth/providers/ReactAuthProvider.d.ts
|
|
1254
1325
|
declare class ReactAuthProvider {
|
|
1255
1326
|
protected readonly alepha: Alepha;
|
|
1256
|
-
readonly onRender:
|
|
1327
|
+
readonly onRender: alepha4.HookPrimitive<"react:server:render:begin">;
|
|
1257
1328
|
}
|
|
1258
1329
|
//#endregion
|
|
1259
1330
|
//#region src/auth/index.d.ts
|
|
@@ -1268,7 +1339,7 @@ declare module "@alepha/react" {
|
|
|
1268
1339
|
* @see {@link ReactAuthProvider}
|
|
1269
1340
|
* @module alepha.react.auth
|
|
1270
1341
|
*/
|
|
1271
|
-
declare const AlephaReactAuth:
|
|
1342
|
+
declare const AlephaReactAuth: alepha4.Service<alepha4.Module>;
|
|
1272
1343
|
//#endregion
|
|
1273
1344
|
export { AlephaReactAuth, ReactAuth, ReactAuthProvider, useAuth };
|
|
1274
1345
|
//# sourceMappingURL=index.d.ts.map
|