alepha 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache.d.ts +353 -1
- package/core.d.ts +998 -19
- package/datetime.d.ts +167 -1
- package/lock.d.ts +280 -1
- package/package.json +36 -22
- package/postgres.d.ts +1452 -1
- package/queue.d.ts +305 -1
- package/react/auth.d.ts +300 -1
- package/react.d.ts +617 -1
- package/redis.d.ts +135 -1
- package/scheduler.d.ts +185 -1
- package/security.d.ts +651 -1
- package/server/cookies.d.ts +56 -1
- package/server/metrics.d.ts +14 -1
- package/server/proxy.d.ts +34 -1
- package/server/static.d.ts +103 -1
- package/server/swagger.d.ts +102 -1
- package/server.d.ts +879 -1
- package/topic.d.ts +301 -1
- package/vite.d.ts +80 -1
package/react.d.ts
CHANGED
|
@@ -1 +1,617 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _alepha_core from '@alepha/core';
|
|
2
|
+
import { Alepha, Static as Static$1, TSchema as TSchema$1, KIND, OPTIONS, Async, Class, TObject as TObject$1 } from '@alepha/core';
|
|
3
|
+
import * as _alepha_server from '@alepha/server';
|
|
4
|
+
import { HttpClientLink, HttpClient, ServerRouterProvider, ServerHandler, ServerRequest } from '@alepha/server';
|
|
5
|
+
import * as react from 'react';
|
|
6
|
+
import react__default, { ReactNode, FC, AnchorHTMLAttributes } from 'react';
|
|
7
|
+
import { Root } from 'react-dom/client';
|
|
8
|
+
import { RouterProvider, Route } from '@alepha/router';
|
|
9
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
10
|
+
import { ServerStaticProvider } from '@alepha/server-static';
|
|
11
|
+
|
|
12
|
+
/** Symbol key applied to readonly types */
|
|
13
|
+
declare const ReadonlyKind: unique symbol;
|
|
14
|
+
/** Symbol key applied to optional types */
|
|
15
|
+
declare const OptionalKind: unique symbol;
|
|
16
|
+
/** Symbol key applied to types */
|
|
17
|
+
declare const Hint: unique symbol;
|
|
18
|
+
/** Symbol key applied to types */
|
|
19
|
+
declare const Kind: unique symbol;
|
|
20
|
+
|
|
21
|
+
type TReadonly<T extends TSchema> = T & {
|
|
22
|
+
[ReadonlyKind]: 'Readonly';
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
|
|
26
|
+
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
27
|
+
interface StringOptions extends SchemaOptions {
|
|
28
|
+
/** The maximum string length */
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
/** The minimum string length */
|
|
31
|
+
minLength?: number;
|
|
32
|
+
/** A regular expression pattern this string should match */
|
|
33
|
+
pattern?: string;
|
|
34
|
+
/** A format this string should match */
|
|
35
|
+
format?: StringFormatOption;
|
|
36
|
+
/** The content encoding for this string */
|
|
37
|
+
contentEncoding?: StringContentEncodingOption;
|
|
38
|
+
/** The content media type for this string */
|
|
39
|
+
contentMediaType?: string;
|
|
40
|
+
}
|
|
41
|
+
interface TString extends TSchema, StringOptions {
|
|
42
|
+
[Kind]: 'String';
|
|
43
|
+
static: string;
|
|
44
|
+
type: 'string';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface TBoolean extends TSchema {
|
|
48
|
+
[Kind]: 'Boolean';
|
|
49
|
+
static: boolean;
|
|
50
|
+
type: 'boolean';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type TOptional<T extends TSchema> = T & {
|
|
54
|
+
[OptionalKind]: 'Optional';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Creates a static type from a TypeBox type */
|
|
58
|
+
type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
|
|
59
|
+
params: Params;
|
|
60
|
+
})['static']> = Result;
|
|
61
|
+
|
|
62
|
+
type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
63
|
+
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
|
|
64
|
+
}[keyof T];
|
|
65
|
+
type ReadonlyPropertyKeys<T extends TProperties> = {
|
|
66
|
+
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
|
|
67
|
+
}[keyof T];
|
|
68
|
+
type OptionalPropertyKeys<T extends TProperties> = {
|
|
69
|
+
[K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
|
|
70
|
+
}[keyof T];
|
|
71
|
+
type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
72
|
+
type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
73
|
+
type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
|
|
74
|
+
[K in keyof T]: Static<T[K], P>;
|
|
75
|
+
}>;
|
|
76
|
+
type TPropertyKey = string | number;
|
|
77
|
+
type TProperties = Record<TPropertyKey, TSchema>;
|
|
78
|
+
type TAdditionalProperties = undefined | TSchema | boolean;
|
|
79
|
+
interface ObjectOptions extends SchemaOptions {
|
|
80
|
+
/** Additional property constraints for this object */
|
|
81
|
+
additionalProperties?: TAdditionalProperties;
|
|
82
|
+
/** The minimum number of properties allowed on this object */
|
|
83
|
+
minProperties?: number;
|
|
84
|
+
/** The maximum number of properties allowed on this object */
|
|
85
|
+
maxProperties?: number;
|
|
86
|
+
}
|
|
87
|
+
interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
88
|
+
[Kind]: 'Object';
|
|
89
|
+
static: ObjectStatic<T, this['params']>;
|
|
90
|
+
additionalProperties?: TAdditionalProperties;
|
|
91
|
+
type: 'object';
|
|
92
|
+
properties: T;
|
|
93
|
+
required?: string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
type Evaluate<T> = T extends infer O ? {
|
|
97
|
+
[K in keyof O]: O[K];
|
|
98
|
+
} : never;
|
|
99
|
+
|
|
100
|
+
interface SchemaOptions {
|
|
101
|
+
$schema?: string;
|
|
102
|
+
/** Id for this schema */
|
|
103
|
+
$id?: string;
|
|
104
|
+
/** Title of this schema */
|
|
105
|
+
title?: string;
|
|
106
|
+
/** Description of this schema */
|
|
107
|
+
description?: string;
|
|
108
|
+
/** Default value for this schema */
|
|
109
|
+
default?: any;
|
|
110
|
+
/** Example values matching this schema */
|
|
111
|
+
examples?: any;
|
|
112
|
+
/** Optional annotation for readOnly */
|
|
113
|
+
readOnly?: boolean;
|
|
114
|
+
/** Optional annotation for writeOnly */
|
|
115
|
+
writeOnly?: boolean;
|
|
116
|
+
[prop: string]: any;
|
|
117
|
+
}
|
|
118
|
+
interface TKind {
|
|
119
|
+
[Kind]: string;
|
|
120
|
+
}
|
|
121
|
+
interface TSchema extends TKind, SchemaOptions {
|
|
122
|
+
[ReadonlyKind]?: string;
|
|
123
|
+
[OptionalKind]?: string;
|
|
124
|
+
[Hint]?: string;
|
|
125
|
+
params: unknown[];
|
|
126
|
+
static: unknown;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface Head$1 {
|
|
130
|
+
title?: string;
|
|
131
|
+
htmlAttributes?: Record<string, string>;
|
|
132
|
+
bodyAttributes?: Record<string, string>;
|
|
133
|
+
meta?: Array<{
|
|
134
|
+
name: string;
|
|
135
|
+
content: string;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
138
|
+
declare class ServerHeadProvider {
|
|
139
|
+
renderHead(template: string, head: Head$1): string;
|
|
140
|
+
mergeAttributes(existing: string, attrs: Record<string, string>): string;
|
|
141
|
+
parseAttributes(attrStr: string): Record<string, string>;
|
|
142
|
+
escapeHtml(str: string): string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare class BrowserHeadProvider {
|
|
146
|
+
renderHead(document: Document, head: Head$1): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface BrowserRoute extends Route {
|
|
150
|
+
page: PageRoute;
|
|
151
|
+
}
|
|
152
|
+
declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
153
|
+
protected readonly log: _alepha_core.Logger;
|
|
154
|
+
protected readonly alepha: Alepha;
|
|
155
|
+
protected readonly pageDescriptorProvider: PageDescriptorProvider;
|
|
156
|
+
add(entry: PageRouteEntry): void;
|
|
157
|
+
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
158
|
+
transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
|
|
159
|
+
root(state: RouterState, context?: PageReactContext): ReactNode;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare const envSchema$1: _alepha_core.TObject<{
|
|
163
|
+
REACT_ROOT_ID: TString;
|
|
164
|
+
}>;
|
|
165
|
+
declare module "alepha" {
|
|
166
|
+
interface Env extends Partial<Static$1<typeof envSchema$1>> {
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
declare class ReactBrowserProvider {
|
|
170
|
+
protected readonly log: _alepha_core.Logger;
|
|
171
|
+
protected readonly client: HttpClient;
|
|
172
|
+
protected readonly alepha: Alepha;
|
|
173
|
+
protected readonly router: BrowserRouterProvider;
|
|
174
|
+
protected readonly headProvider: BrowserHeadProvider;
|
|
175
|
+
protected readonly env: {
|
|
176
|
+
REACT_ROOT_ID: string;
|
|
177
|
+
};
|
|
178
|
+
protected root: Root;
|
|
179
|
+
transitioning?: {
|
|
180
|
+
to: string;
|
|
181
|
+
};
|
|
182
|
+
state: RouterState;
|
|
183
|
+
get document(): Document;
|
|
184
|
+
get history(): History;
|
|
185
|
+
get url(): string;
|
|
186
|
+
invalidate(props?: Record<string, any>): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param url
|
|
190
|
+
* @param options
|
|
191
|
+
*/
|
|
192
|
+
go(url: string, options?: RouterGoOptions): Promise<void>;
|
|
193
|
+
protected render(options?: {
|
|
194
|
+
url?: string;
|
|
195
|
+
previous?: PreviousLayerData[];
|
|
196
|
+
}): Promise<{
|
|
197
|
+
url: string;
|
|
198
|
+
head: Head;
|
|
199
|
+
}>;
|
|
200
|
+
/**
|
|
201
|
+
* Get embedded layers from the server.
|
|
202
|
+
*
|
|
203
|
+
* @protected
|
|
204
|
+
*/
|
|
205
|
+
protected getHydrationState(): ReactHydrationState | undefined;
|
|
206
|
+
/**
|
|
207
|
+
*
|
|
208
|
+
* @protected
|
|
209
|
+
*/
|
|
210
|
+
protected getRootElement(): HTMLElement;
|
|
211
|
+
/**
|
|
212
|
+
*
|
|
213
|
+
* @protected
|
|
214
|
+
*/
|
|
215
|
+
readonly ready: _alepha_core.HookDescriptor<"ready">;
|
|
216
|
+
readonly onTransitionEnd: _alepha_core.HookDescriptor<"react:transition:end">;
|
|
217
|
+
}
|
|
218
|
+
interface RouterGoOptions {
|
|
219
|
+
replace?: boolean;
|
|
220
|
+
match?: TransitionOptions;
|
|
221
|
+
}
|
|
222
|
+
interface ReactHydrationState {
|
|
223
|
+
layers?: PreviousLayerData[];
|
|
224
|
+
links?: HttpClientLink[];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare class RouterHookApi {
|
|
228
|
+
private readonly state;
|
|
229
|
+
private readonly layer;
|
|
230
|
+
private readonly browser?;
|
|
231
|
+
constructor(state: RouterState, layer: {
|
|
232
|
+
path: string;
|
|
233
|
+
}, browser?: ReactBrowserProvider | undefined);
|
|
234
|
+
/**
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
get current(): RouterState;
|
|
238
|
+
/**
|
|
239
|
+
*
|
|
240
|
+
*/
|
|
241
|
+
get pathname(): string;
|
|
242
|
+
/**
|
|
243
|
+
*
|
|
244
|
+
*/
|
|
245
|
+
get query(): Record<string, string>;
|
|
246
|
+
/**
|
|
247
|
+
*
|
|
248
|
+
*/
|
|
249
|
+
back(): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
*/
|
|
253
|
+
forward(): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
*
|
|
256
|
+
* @param props
|
|
257
|
+
*/
|
|
258
|
+
invalidate(props?: Record<string, any>): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Create a valid href for the given pathname.
|
|
261
|
+
*
|
|
262
|
+
* @param pathname
|
|
263
|
+
* @param layer
|
|
264
|
+
*/
|
|
265
|
+
createHref(pathname: HrefLike, layer?: {
|
|
266
|
+
path: string;
|
|
267
|
+
}): string;
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
* @param path
|
|
271
|
+
* @param options
|
|
272
|
+
*/
|
|
273
|
+
go(path: HrefLike, options?: RouterGoOptions): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param path
|
|
277
|
+
*/
|
|
278
|
+
createAnchorProps(path: string): AnchorProps;
|
|
279
|
+
/**
|
|
280
|
+
* Set query params.
|
|
281
|
+
*
|
|
282
|
+
* @param record
|
|
283
|
+
* @param options
|
|
284
|
+
*/
|
|
285
|
+
setQueryParams(record: Record<string, any>, options?: {
|
|
286
|
+
/**
|
|
287
|
+
* If true, this will merge current query params with the new ones.
|
|
288
|
+
*/
|
|
289
|
+
merge?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* If true, this will add a new entry to the history stack.
|
|
292
|
+
*/
|
|
293
|
+
push?: boolean;
|
|
294
|
+
}): void;
|
|
295
|
+
}
|
|
296
|
+
type HrefLike = string | {
|
|
297
|
+
options: {
|
|
298
|
+
path?: string;
|
|
299
|
+
name?: string;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
declare const KEY = "PAGE";
|
|
304
|
+
interface PageConfigSchema {
|
|
305
|
+
query?: TSchema$1;
|
|
306
|
+
params?: TSchema$1;
|
|
307
|
+
}
|
|
308
|
+
type TPropsDefault = any;
|
|
309
|
+
type TPropsParentDefault = object;
|
|
310
|
+
interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
311
|
+
name?: string;
|
|
312
|
+
path?: string;
|
|
313
|
+
schema?: TConfig;
|
|
314
|
+
resolve?: (config: PageResolve<TConfig, TPropsParent>) => Async<TProps>;
|
|
315
|
+
component?: FC<TProps & TPropsParent>;
|
|
316
|
+
lazy?: () => Promise<{
|
|
317
|
+
default: FC<TProps & TPropsParent>;
|
|
318
|
+
}>;
|
|
319
|
+
children?: Array<{
|
|
320
|
+
[OPTIONS]: PageDescriptorOptions;
|
|
321
|
+
}>;
|
|
322
|
+
parent?: {
|
|
323
|
+
[OPTIONS]: PageDescriptorOptions<any, TPropsParent>;
|
|
324
|
+
};
|
|
325
|
+
can?: () => boolean;
|
|
326
|
+
head?: Head | ((props: TProps, previous?: Head) => Head);
|
|
327
|
+
errorHandler?: FC<{
|
|
328
|
+
error: Error;
|
|
329
|
+
url: string;
|
|
330
|
+
}>;
|
|
331
|
+
}
|
|
332
|
+
interface PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
333
|
+
[KIND]: typeof KEY;
|
|
334
|
+
[OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;
|
|
335
|
+
render: (options?: {
|
|
336
|
+
params?: Record<string, string>;
|
|
337
|
+
query?: Record<string, string>;
|
|
338
|
+
}) => Promise<string>;
|
|
339
|
+
go: () => void;
|
|
340
|
+
createAnchorProps: (routerHook: RouterHookApi) => {
|
|
341
|
+
href: string;
|
|
342
|
+
onClick: () => void;
|
|
343
|
+
};
|
|
344
|
+
can: () => boolean;
|
|
345
|
+
}
|
|
346
|
+
declare const $page: {
|
|
347
|
+
<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = object>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
|
|
348
|
+
[KIND]: string;
|
|
349
|
+
};
|
|
350
|
+
interface Head {
|
|
351
|
+
title?: string;
|
|
352
|
+
titleSeparator?: string;
|
|
353
|
+
htmlAttributes?: Record<string, string>;
|
|
354
|
+
bodyAttributes?: Record<string, string>;
|
|
355
|
+
meta?: Array<{
|
|
356
|
+
name: string;
|
|
357
|
+
content: string;
|
|
358
|
+
}>;
|
|
359
|
+
}
|
|
360
|
+
interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
|
|
361
|
+
params: TConfig["params"] extends TSchema$1 ? Static$1<TConfig["params"]> : Record<string, string>;
|
|
362
|
+
query: TConfig["query"] extends TSchema$1 ? Static$1<TConfig["query"]> : Record<string, string>;
|
|
363
|
+
}
|
|
364
|
+
type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageResolveContext;
|
|
365
|
+
interface PageResolveContext {
|
|
366
|
+
url: URL;
|
|
367
|
+
head: Head;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare class PageDescriptorProvider {
|
|
371
|
+
protected readonly log: _alepha_core.Logger;
|
|
372
|
+
protected readonly alepha: Alepha;
|
|
373
|
+
protected readonly pages: PageRoute[];
|
|
374
|
+
getPages(): PageRoute[];
|
|
375
|
+
page(name: string): PageRoute;
|
|
376
|
+
root(state: RouterState, context?: PageReactContext): ReactNode;
|
|
377
|
+
createLayers(route: PageRoute, request: PageRequest): Promise<CreateLayersResult>;
|
|
378
|
+
protected getErrorHandler(route: PageRoute): react.FC<{
|
|
379
|
+
error: Error;
|
|
380
|
+
url: string;
|
|
381
|
+
}> | undefined;
|
|
382
|
+
protected createElement(page: PageRoute, props: Record<string, any>): Promise<ReactNode>;
|
|
383
|
+
protected fillHead(page: PageRoute, ctx: PageRequest, props: Record<string, any>): void;
|
|
384
|
+
renderError(e: Error): ReactNode;
|
|
385
|
+
renderEmptyView(): ReactNode;
|
|
386
|
+
href(page: {
|
|
387
|
+
options: {
|
|
388
|
+
name?: string;
|
|
389
|
+
};
|
|
390
|
+
}, params?: Record<string, any>): string;
|
|
391
|
+
compile(path: string, params?: Record<string, string>): string;
|
|
392
|
+
protected renderView(index: number, path: string, view?: ReactNode): ReactNode;
|
|
393
|
+
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
394
|
+
protected map(pages: Array<{
|
|
395
|
+
value: {
|
|
396
|
+
[OPTIONS]: PageDescriptorOptions;
|
|
397
|
+
};
|
|
398
|
+
}>, target: {
|
|
399
|
+
[OPTIONS]: PageDescriptorOptions;
|
|
400
|
+
}): PageRouteEntry;
|
|
401
|
+
add(entry: PageRouteEntry): void;
|
|
402
|
+
protected createMatch(page: PageRoute): string;
|
|
403
|
+
protected _next: number;
|
|
404
|
+
protected nextId(): string;
|
|
405
|
+
}
|
|
406
|
+
declare const isPageRoute: (it: any) => it is PageRoute;
|
|
407
|
+
interface PageRouteEntry extends Omit<PageDescriptorOptions, "children" | "parent"> {
|
|
408
|
+
children?: PageRouteEntry[];
|
|
409
|
+
}
|
|
410
|
+
interface PageRoute extends PageRouteEntry {
|
|
411
|
+
type: "page";
|
|
412
|
+
name: string;
|
|
413
|
+
parent?: PageRoute;
|
|
414
|
+
match: string;
|
|
415
|
+
}
|
|
416
|
+
interface Layer {
|
|
417
|
+
config?: {
|
|
418
|
+
query?: Record<string, any>;
|
|
419
|
+
params?: Record<string, any>;
|
|
420
|
+
context?: Record<string, any>;
|
|
421
|
+
};
|
|
422
|
+
name: string;
|
|
423
|
+
props?: Record<string, any>;
|
|
424
|
+
error?: Error;
|
|
425
|
+
part?: string;
|
|
426
|
+
element: ReactNode;
|
|
427
|
+
index: number;
|
|
428
|
+
path: string;
|
|
429
|
+
}
|
|
430
|
+
type PreviousLayerData = Omit<Layer, "element">;
|
|
431
|
+
interface AnchorProps {
|
|
432
|
+
href?: string;
|
|
433
|
+
onClick?: (ev: any) => any;
|
|
434
|
+
}
|
|
435
|
+
interface RouterState {
|
|
436
|
+
pathname: string;
|
|
437
|
+
search: string;
|
|
438
|
+
layers: Array<Layer>;
|
|
439
|
+
head: Head;
|
|
440
|
+
}
|
|
441
|
+
interface TransitionOptions {
|
|
442
|
+
state?: RouterState;
|
|
443
|
+
previous?: PreviousLayerData[];
|
|
444
|
+
context?: PageReactContext;
|
|
445
|
+
}
|
|
446
|
+
interface RouterStackItem {
|
|
447
|
+
route: PageRoute;
|
|
448
|
+
config?: Record<string, any>;
|
|
449
|
+
props?: Record<string, any>;
|
|
450
|
+
error?: Error;
|
|
451
|
+
}
|
|
452
|
+
interface RouterRenderResult {
|
|
453
|
+
redirect?: string;
|
|
454
|
+
layers: Layer[];
|
|
455
|
+
head: Head;
|
|
456
|
+
element: ReactNode;
|
|
457
|
+
}
|
|
458
|
+
interface PageRequest extends PageReactContext {
|
|
459
|
+
url: URL;
|
|
460
|
+
params: Record<string, any>;
|
|
461
|
+
query: Record<string, string>;
|
|
462
|
+
head: Head;
|
|
463
|
+
previous?: PreviousLayerData[];
|
|
464
|
+
}
|
|
465
|
+
interface CreateLayersResult extends RouterState {
|
|
466
|
+
redirect?: string;
|
|
467
|
+
}
|
|
468
|
+
interface PageReactContext {
|
|
469
|
+
links?: HttpClientLink[];
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface NestedViewProps {
|
|
473
|
+
children?: ReactNode;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Nested view component
|
|
477
|
+
*
|
|
478
|
+
* @param props
|
|
479
|
+
* @constructor
|
|
480
|
+
*/
|
|
481
|
+
declare const NestedView: (props: NestedViewProps) => string | number | bigint | boolean | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
482
|
+
|
|
483
|
+
interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
484
|
+
to: string | PageDescriptor;
|
|
485
|
+
children?: react__default.ReactNode;
|
|
486
|
+
}
|
|
487
|
+
declare const Link: (props: LinkProps) => react_jsx_runtime.JSX.Element | null;
|
|
488
|
+
|
|
489
|
+
interface RouterContextValue {
|
|
490
|
+
alepha: Alepha;
|
|
491
|
+
state: RouterState;
|
|
492
|
+
context: PageReactContext;
|
|
493
|
+
}
|
|
494
|
+
declare const RouterContext: react.Context<RouterContextValue | undefined>;
|
|
495
|
+
|
|
496
|
+
interface RouterLayerContextValue {
|
|
497
|
+
index: number;
|
|
498
|
+
path: string;
|
|
499
|
+
}
|
|
500
|
+
declare const RouterLayerContext: react.Context<RouterLayerContextValue | undefined>;
|
|
501
|
+
|
|
502
|
+
declare const useInject: <T extends object>(clazz: Class<T>) => T;
|
|
503
|
+
|
|
504
|
+
declare const useClient: () => HttpClient;
|
|
505
|
+
declare const useApi: <T extends object>() => _alepha_server.HttpVirtualClient<T>;
|
|
506
|
+
|
|
507
|
+
interface UseQueryParamsHookOptions {
|
|
508
|
+
format?: "base64" | "querystring";
|
|
509
|
+
key?: string;
|
|
510
|
+
push?: boolean;
|
|
511
|
+
}
|
|
512
|
+
declare const useQueryParams: <T extends TObject$1>(schema: T, options?: UseQueryParamsHookOptions) => [Static$1<T>, (data: Static$1<T>) => void];
|
|
513
|
+
|
|
514
|
+
declare const useRouter: () => RouterHookApi;
|
|
515
|
+
|
|
516
|
+
declare const useRouterEvents: (opts?: {
|
|
517
|
+
onBegin?: (ev: {
|
|
518
|
+
state: RouterState;
|
|
519
|
+
}) => void;
|
|
520
|
+
onEnd?: (ev: {
|
|
521
|
+
state: RouterState;
|
|
522
|
+
}) => void;
|
|
523
|
+
onError?: (ev: {
|
|
524
|
+
state: RouterState;
|
|
525
|
+
error: Error;
|
|
526
|
+
}) => void;
|
|
527
|
+
}, deps?: any[]) => void;
|
|
528
|
+
|
|
529
|
+
declare const useRouterState: () => RouterState;
|
|
530
|
+
|
|
531
|
+
declare const useActive: (path: HrefLike) => UseActiveHook;
|
|
532
|
+
interface UseActiveHook {
|
|
533
|
+
isActive: boolean;
|
|
534
|
+
anchorProps: AnchorProps;
|
|
535
|
+
isPending: boolean;
|
|
536
|
+
name?: string;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
declare class RedirectionError extends Error {
|
|
540
|
+
readonly page: HrefLike;
|
|
541
|
+
constructor(page: HrefLike);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
declare const envSchema: TObject<{
|
|
545
|
+
REACT_SERVER_DIST: TString;
|
|
546
|
+
REACT_SERVER_PREFIX: TString;
|
|
547
|
+
REACT_SSR_ENABLED: TBoolean;
|
|
548
|
+
REACT_ROOT_ID: TString;
|
|
549
|
+
}>;
|
|
550
|
+
declare module "alepha/core" {
|
|
551
|
+
interface Env extends Partial<Static$1<typeof envSchema>> {
|
|
552
|
+
}
|
|
553
|
+
interface State {
|
|
554
|
+
"ReactServerProvider.template"?: string;
|
|
555
|
+
"ReactServerProvider.ssr"?: boolean;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
declare class ReactServerProvider {
|
|
559
|
+
protected readonly log: _alepha_core.Logger;
|
|
560
|
+
protected readonly alepha: Alepha;
|
|
561
|
+
protected readonly pageDescriptorProvider: PageDescriptorProvider;
|
|
562
|
+
protected readonly serverStaticProvider: ServerStaticProvider;
|
|
563
|
+
protected readonly serverRouterProvider: ServerRouterProvider;
|
|
564
|
+
protected readonly headProvider: ServerHeadProvider;
|
|
565
|
+
protected readonly env: {
|
|
566
|
+
REACT_ROOT_ID: string;
|
|
567
|
+
REACT_SERVER_DIST: string;
|
|
568
|
+
REACT_SERVER_PREFIX: string;
|
|
569
|
+
REACT_SSR_ENABLED: boolean;
|
|
570
|
+
};
|
|
571
|
+
protected readonly ROOT_DIV_REGEX: RegExp;
|
|
572
|
+
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
573
|
+
protected registerPages(templateLoader: () => Promise<string | undefined>): Promise<void>;
|
|
574
|
+
protected getPublicDirectory(): string;
|
|
575
|
+
protected configureStaticServer(root: string): Promise<void>;
|
|
576
|
+
protected configureVite(): Promise<void>;
|
|
577
|
+
protected createRenderFunction(name: string): (options?: {
|
|
578
|
+
params?: Record<string, string>;
|
|
579
|
+
query?: Record<string, string>;
|
|
580
|
+
}) => Promise<string>;
|
|
581
|
+
protected createHandler(page: PageRoute, templateLoader: () => Promise<string | undefined>): ServerHandler;
|
|
582
|
+
fillTemplate(response: {
|
|
583
|
+
html: string;
|
|
584
|
+
}, app: string, script: string): void;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
declare module "@alepha/core" {
|
|
588
|
+
interface Hooks {
|
|
589
|
+
"react:browser:render": {
|
|
590
|
+
context: PageReactContext;
|
|
591
|
+
hydration?: ReactHydrationState;
|
|
592
|
+
};
|
|
593
|
+
"react:server:render": {
|
|
594
|
+
request: ServerRequest;
|
|
595
|
+
pageRequest: PageRequest;
|
|
596
|
+
};
|
|
597
|
+
"react:transition:begin": {
|
|
598
|
+
state: RouterState;
|
|
599
|
+
};
|
|
600
|
+
"react:transition:success": {
|
|
601
|
+
state: RouterState;
|
|
602
|
+
};
|
|
603
|
+
"react:transition:error": {
|
|
604
|
+
error: Error;
|
|
605
|
+
state: RouterState;
|
|
606
|
+
};
|
|
607
|
+
"react:transition:end": {
|
|
608
|
+
state: RouterState;
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
declare class ReactModule {
|
|
613
|
+
protected readonly alepha: Alepha;
|
|
614
|
+
constructor();
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export { $page, type AnchorProps, type CreateLayersResult, type Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type PageResolveContext, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, type ReactHydrationState, ReactModule, ReactServerProvider, RedirectionError, RouterContext, type RouterContextValue, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterRenderResult, type RouterStackItem, type RouterState, type TPropsDefault, type TPropsParentDefault, type TransitionOptions, type UseActiveHook, type UseQueryParamsHookOptions, envSchema, isPageRoute, useActive, useApi, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
|