alepha 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/batch.d.ts +3 -6
- package/bucket.d.ts +7 -14
- package/cache/redis.d.ts +7 -7
- package/cache.d.ts +2 -6
- package/command.d.ts +11 -11
- package/core.d.ts +99 -254
- package/datetime.d.ts +3 -7
- package/file.d.ts +0 -3
- package/lock/redis.d.ts +2 -5
- package/lock.d.ts +8 -15
- package/logger.cjs +8 -0
- package/logger.d.ts +222 -0
- package/logger.js +1 -0
- package/package.json +50 -42
- package/postgres.d.ts +192 -271
- package/queue/redis.d.ts +0 -2
- package/queue.d.ts +11 -19
- package/react/auth.d.ts +217 -134
- package/react/form.d.ts +113 -72
- package/react/head.d.ts +7 -14
- package/react/i18n.d.ts +23 -28
- package/react.d.ts +274 -256
- package/redis.d.ts +12 -12
- package/retry.d.ts +0 -4
- package/router.d.ts +0 -1
- package/scheduler.d.ts +9 -13
- package/security.d.ts +68 -86
- package/server/cache.d.ts +3 -5
- package/server/compress.d.ts +0 -3
- package/server/cookies.d.ts +4 -7
- package/server/cors.d.ts +1 -5
- package/server/health.d.ts +0 -3
- package/server/helmet.d.ts +28 -28
- package/server/links.d.ts +144 -42
- package/server/metrics.d.ts +1 -5
- package/server/multipart.d.ts +0 -2
- package/server/proxy.d.ts +3 -7
- package/server/security.d.ts +6 -7
- package/server/static.d.ts +4 -8
- package/server/swagger.d.ts +2 -6
- package/server.d.ts +72 -96
- package/topic/redis.d.ts +3 -6
- package/topic.d.ts +5 -13
- package/vite.d.ts +5 -7
package/react/form.d.ts
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
import * as _alepha_core0 from "alepha";
|
|
2
|
-
import { Static, TObject, TSchema } from "alepha";
|
|
3
|
-
import { InputHTMLAttributes } from "react";
|
|
2
|
+
import { Alepha, Static, TObject, TSchema } from "alepha";
|
|
3
|
+
import { InputHTMLAttributes, ReactNode } from "react";
|
|
4
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
4
5
|
|
|
5
|
-
//#region src/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
//#region src/services/FormModel.d.ts
|
|
7
|
+
declare class FormModel<T extends TObject> {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
protected readonly options: FormCtrlOptions<T>;
|
|
10
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
11
|
+
protected readonly alepha: Alepha;
|
|
12
|
+
protected readonly values: Record<string, any>;
|
|
13
|
+
input: SchemaToInput<T>;
|
|
14
|
+
constructor(id: string, options: FormCtrlOptions<T>);
|
|
15
|
+
readonly onSubmit: (event: FormEventLike) => Promise<void>;
|
|
16
|
+
protected parseValuesFromFormElement<T extends TObject>(options: FormCtrlOptions<T>, store: Record<string, any>): Record<string, any>;
|
|
17
|
+
protected getValueFromInputObject<T extends TObject>(options: FormCtrlOptions<T>, values: Record<string, any>, key: string, value: FormDataEntryValue): void;
|
|
18
|
+
protected createProxyFromSchema<T extends TObject>(options: FormCtrlOptions<T>, schema: TSchema, context: {
|
|
19
|
+
parent: string;
|
|
20
|
+
store: Record<string, any>;
|
|
21
|
+
}): SchemaToInput<T>;
|
|
22
|
+
protected createInputFromSchema<T extends TObject>(name: keyof Static<T> & string, options: FormCtrlOptions<T>, schema: TSchema, context: {
|
|
23
|
+
parent: string;
|
|
24
|
+
store: Record<string, any>;
|
|
25
|
+
}): InputField;
|
|
26
|
+
protected getValueFromInput(input: FormDataEntryValue, schema: TSchema): any;
|
|
27
|
+
protected valueToInputEntry(value: any): string | number | boolean;
|
|
28
|
+
}
|
|
29
|
+
type SchemaToInput<T extends TObject> = { [K in keyof T["properties"]]: T["properties"][K] extends TObject ? SchemaToInput<T["properties"][K]> : InputField };
|
|
30
|
+
interface FormEventLike {
|
|
31
|
+
currentTarget: HTMLFormElement;
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
stopPropagation: () => void;
|
|
34
|
+
}
|
|
35
|
+
interface InputField {
|
|
36
|
+
path: string;
|
|
37
|
+
props: InputHTMLAttributesLike;
|
|
38
|
+
schema: TSchema;
|
|
39
|
+
set: (value: any) => void;
|
|
40
|
+
}
|
|
41
|
+
type InputHTMLAttributesLike = Pick<InputHTMLAttributes<unknown>, "id" | "name" | "type" | "value" | "defaultValue" | "required" | "maxLength" | "minLength" | "aria-label"> & {
|
|
42
|
+
value?: any;
|
|
43
|
+
defaultValue?: any;
|
|
44
|
+
onChange?: (event: any) => void;
|
|
45
|
+
};
|
|
46
|
+
type FormCtrlOptions<T extends TObject> = {
|
|
39
47
|
/**
|
|
40
48
|
* The schema defining the structure and validation rules for the form.
|
|
41
49
|
* This should be a TypeBox schema object.
|
|
@@ -71,42 +79,77 @@ type UseFormOptions<T extends TObject> = {
|
|
|
71
79
|
}) => void;
|
|
72
80
|
onChange?: (key: string, value: any, store: Record<string, any>) => void;
|
|
73
81
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/components/FormState.d.ts
|
|
84
|
+
declare const FormState: <T extends TObject>(props: {
|
|
85
|
+
form: FormModel<T>;
|
|
86
|
+
children: (state: {
|
|
87
|
+
loading: boolean;
|
|
88
|
+
dirty: boolean;
|
|
89
|
+
}) => ReactNode;
|
|
90
|
+
}) => ReactNode;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/hooks/useForm.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* Custom hook to create a form with validation and field management.
|
|
95
|
+
* This hook uses TypeBox schemas to define the structure and validation rules for the form.
|
|
96
|
+
* It provides a way to handle form submission, field creation, and value management.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* import { t } from "alepha";
|
|
101
|
+
*
|
|
102
|
+
* const form = useForm({
|
|
103
|
+
* schema: t.object({
|
|
104
|
+
* username: t.string(),
|
|
105
|
+
* password: t.string(),
|
|
106
|
+
* }),
|
|
107
|
+
* handler: (values) => {
|
|
108
|
+
* console.log("Form submitted with values:", values);
|
|
109
|
+
* },
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* return (
|
|
113
|
+
* <form onSubmit={form.onSubmit}>
|
|
114
|
+
* <input {...form.input("username")} />
|
|
115
|
+
* <input {...form.input("password")} />
|
|
116
|
+
* <button type="submit">Submit</button>
|
|
117
|
+
* </form>
|
|
118
|
+
* );
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
declare const useForm: <T extends TObject>(options: FormCtrlOptions<T>) => FormModel<T>;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/hooks/useFormState.d.ts
|
|
124
|
+
interface UseFormStateReturn<T extends TObject> {
|
|
125
|
+
loading: boolean;
|
|
126
|
+
dirty: boolean;
|
|
127
|
+
values?: T;
|
|
128
|
+
error?: Error;
|
|
102
129
|
}
|
|
103
|
-
|
|
104
|
-
value?: any;
|
|
105
|
-
defaultValue?: any;
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=useForm.d.ts.map
|
|
130
|
+
declare const useFormState: <T extends TObject>(form: FormModel<T>) => UseFormStateReturn<T>;
|
|
108
131
|
//#endregion
|
|
109
132
|
//#region src/index.d.ts
|
|
133
|
+
declare module "alepha" {
|
|
134
|
+
interface Hooks {
|
|
135
|
+
"form:change": {
|
|
136
|
+
id: string;
|
|
137
|
+
};
|
|
138
|
+
"form:submit:begin": {
|
|
139
|
+
id: string;
|
|
140
|
+
};
|
|
141
|
+
"form:submit:success": {
|
|
142
|
+
id: string;
|
|
143
|
+
};
|
|
144
|
+
"form:submit:error": {
|
|
145
|
+
id: string;
|
|
146
|
+
error: Error;
|
|
147
|
+
};
|
|
148
|
+
"form:submit:end": {
|
|
149
|
+
id: string;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
110
153
|
/**
|
|
111
154
|
* React hooks for managing forms in Alepha applications.
|
|
112
155
|
*
|
|
@@ -119,8 +162,6 @@ type InputHTMLAttributesLike = Pick<InputHTMLAttributes<unknown>, "id" | "name"
|
|
|
119
162
|
* @module alepha.react.form
|
|
120
163
|
*/
|
|
121
164
|
declare const AlephaReactForm: _alepha_core0.Service<_alepha_core0.Module>;
|
|
122
|
-
//# sourceMappingURL=index.d.ts.map
|
|
123
|
-
|
|
124
165
|
//#endregion
|
|
125
|
-
export { AlephaReactForm, FormEventLike,
|
|
166
|
+
export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
|
|
126
167
|
//# sourceMappingURL=index.d.ts.map
|
package/react/head.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
|
-
import * as _alepha_core0 from "alepha";
|
|
3
2
|
import { Descriptor, KIND } from "alepha";
|
|
4
|
-
import { PageConfigSchema,
|
|
3
|
+
import { PageConfigSchema, PageRoute, ReactRouterState, TPropsDefault, TPropsParentDefault } from "alepha/react";
|
|
4
|
+
import { ServerTimingProvider } from "alepha/server";
|
|
5
5
|
|
|
6
6
|
//#region src/interfaces/Head.d.ts
|
|
7
7
|
interface Head extends SimpleHead {
|
|
@@ -43,16 +43,14 @@ interface SimpleHead {
|
|
|
43
43
|
content: string;
|
|
44
44
|
}>;
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=Head.d.ts.map
|
|
47
46
|
//#endregion
|
|
48
47
|
//#region src/providers/HeadProvider.d.ts
|
|
49
48
|
declare class HeadProvider {
|
|
50
49
|
global?: Head | (() => Head);
|
|
51
50
|
protected getGlobalHead(): Head | undefined;
|
|
52
|
-
fillHead(state:
|
|
53
|
-
protected fillHeadByPage(page: PageRoute,
|
|
51
|
+
fillHead(state: ReactRouterState): void;
|
|
52
|
+
protected fillHeadByPage(page: PageRoute, state: ReactRouterState, props: Record<string, any>): void;
|
|
54
53
|
}
|
|
55
|
-
//# sourceMappingURL=HeadProvider.d.ts.map
|
|
56
54
|
//#endregion
|
|
57
55
|
//#region src/descriptors/$head.d.ts
|
|
58
56
|
/**
|
|
@@ -67,8 +65,6 @@ declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
|
|
|
67
65
|
protected readonly provider: HeadProvider;
|
|
68
66
|
protected onInit(): void;
|
|
69
67
|
}
|
|
70
|
-
//# sourceMappingURL=$head.d.ts.map
|
|
71
|
-
|
|
72
68
|
//#endregion
|
|
73
69
|
//#region src/hooks/useHead.d.ts
|
|
74
70
|
/**
|
|
@@ -91,25 +87,24 @@ declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
|
|
|
91
87
|
declare const useHead: (options?: UseHeadOptions) => void;
|
|
92
88
|
type UseHeadOptions = Head | ((previous?: Head) => Head);
|
|
93
89
|
type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void];
|
|
94
|
-
//# sourceMappingURL=useHead.d.ts.map
|
|
95
90
|
//#endregion
|
|
96
91
|
//#region src/providers/ServerHeadProvider.d.ts
|
|
97
92
|
declare class ServerHeadProvider {
|
|
98
93
|
protected readonly headProvider: HeadProvider;
|
|
94
|
+
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
99
95
|
protected readonly onServerRenderEnd: _alepha_core1.HookDescriptor<"react:server:render:end">;
|
|
100
96
|
renderHead(template: string, head: SimpleHead): string;
|
|
101
97
|
protected mergeAttributes(existing: string, attrs: Record<string, string>): string;
|
|
102
98
|
protected parseAttributes(attrStr: string): Record<string, string>;
|
|
103
99
|
protected escapeHtml(str: string): string;
|
|
104
100
|
}
|
|
105
|
-
//# sourceMappingURL=ServerHeadProvider.d.ts.map
|
|
106
101
|
//#endregion
|
|
107
102
|
//#region src/index.d.ts
|
|
108
103
|
declare module "alepha/react" {
|
|
109
104
|
interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
|
|
110
105
|
head?: Head | ((props: TProps, previous?: Head) => Head);
|
|
111
106
|
}
|
|
112
|
-
interface
|
|
107
|
+
interface ReactRouterState {
|
|
113
108
|
head: Head;
|
|
114
109
|
}
|
|
115
110
|
}
|
|
@@ -119,9 +114,7 @@ declare module "alepha/react" {
|
|
|
119
114
|
* @see {@link ServerHeadProvider}
|
|
120
115
|
* @module alepha.react.head
|
|
121
116
|
*/
|
|
122
|
-
declare const AlephaReactHead:
|
|
123
|
-
//# sourceMappingURL=index.d.ts.map
|
|
124
|
-
|
|
117
|
+
declare const AlephaReactHead: _alepha_core1.Service<_alepha_core1.Module>;
|
|
125
118
|
//#endregion
|
|
126
119
|
export { $head, AlephaReactHead, Head, HeadDescriptor, HeadDescriptorOptions, ServerHeadProvider, SimpleHead, UseHeadOptions, UseHeadReturn, useHead };
|
|
127
120
|
//# sourceMappingURL=index.d.ts.map
|
package/react/i18n.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
|
-
import * as _alepha_core0 from "alepha";
|
|
3
2
|
import { Alepha, Descriptor, KIND } from "alepha";
|
|
3
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
4
4
|
import * as _alepha_server_cookies0 from "alepha/server/cookies";
|
|
5
5
|
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
6
6
|
|
|
7
|
+
//#region src/hooks/useI18n.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access the i18n service.
|
|
10
|
+
*/
|
|
11
|
+
declare const useI18n: <S extends object, K extends keyof ServiceDictionary<S>>() => I18nProvider<object, never>;
|
|
12
|
+
type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never };
|
|
13
|
+
//#endregion
|
|
7
14
|
//#region src/providers/I18nProvider.d.ts
|
|
8
|
-
declare class I18nProvider {
|
|
9
|
-
logger:
|
|
10
|
-
alepha: Alepha;
|
|
11
|
-
cookie: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox0.TString>;
|
|
12
|
-
registry: Array<{
|
|
15
|
+
declare class I18nProvider<S extends object, K extends keyof ServiceDictionary<S>> {
|
|
16
|
+
protected logger: _alepha_logger0.Logger;
|
|
17
|
+
protected alepha: Alepha;
|
|
18
|
+
protected cookie: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox0.TString>;
|
|
19
|
+
readonly registry: Array<{
|
|
13
20
|
name: string;
|
|
14
21
|
lang: string;
|
|
15
22
|
loader: () => Promise<Record<string, string>>;
|
|
@@ -18,16 +25,20 @@ declare class I18nProvider {
|
|
|
18
25
|
options: {
|
|
19
26
|
fallbackLang: string;
|
|
20
27
|
};
|
|
28
|
+
numberFormat: {
|
|
29
|
+
format: (value: number) => string;
|
|
30
|
+
};
|
|
21
31
|
get languages(): string[];
|
|
22
|
-
onRender: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
23
|
-
onStart: _alepha_core1.HookDescriptor<"start">;
|
|
32
|
+
protected readonly onRender: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
33
|
+
protected readonly onStart: _alepha_core1.HookDescriptor<"start">;
|
|
34
|
+
protected createFormatters(): void;
|
|
24
35
|
setLang(lang: string): Promise<void>;
|
|
36
|
+
protected readonly mutate: _alepha_core1.HookDescriptor<"state:mutate">;
|
|
25
37
|
get lang(): string;
|
|
26
38
|
translate: (key: string, args?: string[]) => string;
|
|
39
|
+
readonly tr: (key: keyof ServiceDictionary<S>[K] | string, args?: string[]) => string;
|
|
27
40
|
protected render(item: string, args: string[]): string;
|
|
28
41
|
}
|
|
29
|
-
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
30
|
-
|
|
31
42
|
//#endregion
|
|
32
43
|
//#region src/descriptors/$dictionary.d.ts
|
|
33
44
|
/**
|
|
@@ -73,23 +84,9 @@ interface DictionaryDescriptorOptions<T extends Record<string, string>> {
|
|
|
73
84
|
}>;
|
|
74
85
|
}
|
|
75
86
|
declare class DictionaryDescriptor<T extends Record<string, string>> extends Descriptor<DictionaryDescriptorOptions<T>> {
|
|
76
|
-
protected provider: I18nProvider
|
|
87
|
+
protected provider: I18nProvider<object, never>;
|
|
77
88
|
protected onInit(): void;
|
|
78
89
|
}
|
|
79
|
-
//# sourceMappingURL=$dictionary.d.ts.map
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/hooks/useI18n.d.ts
|
|
82
|
-
/**
|
|
83
|
-
* Hook to access the i18n service.
|
|
84
|
-
*/
|
|
85
|
-
declare const useI18n: <S extends object, K extends keyof ServiceDictionary<S>>() => {
|
|
86
|
-
lang: string;
|
|
87
|
-
setLang: (lang: string) => Promise<void>;
|
|
88
|
-
tr: (key: keyof ServiceDictionary<S>[K] | string, args?: string[]) => string;
|
|
89
|
-
languages: string[];
|
|
90
|
-
};
|
|
91
|
-
type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never };
|
|
92
|
-
//# sourceMappingURL=useI18n.d.ts.map
|
|
93
90
|
//#endregion
|
|
94
91
|
//#region src/index.d.ts
|
|
95
92
|
declare module "alepha" {
|
|
@@ -104,9 +101,7 @@ declare module "alepha" {
|
|
|
104
101
|
*
|
|
105
102
|
* @module alepha.react.i18n
|
|
106
103
|
*/
|
|
107
|
-
declare const AlephaReactI18n:
|
|
108
|
-
//# sourceMappingURL=index.d.ts.map
|
|
109
|
-
|
|
104
|
+
declare const AlephaReactI18n: _alepha_core1.Service<_alepha_core1.Module>;
|
|
110
105
|
//#endregion
|
|
111
106
|
export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nProvider, ServiceDictionary, useI18n };
|
|
112
107
|
//# sourceMappingURL=index.d.ts.map
|