alepha 0.9.1 → 0.9.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/batch.d.ts +4 -4
- package/bucket.d.ts +3 -3
- package/cache/redis.d.ts +4 -4
- package/cache.d.ts +3 -3
- package/command.d.ts +27 -13
- package/core.d.ts +104 -100
- package/datetime.d.ts +5 -5
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +8 -8
- package/package.json +54 -47
- package/postgres.d.ts +135 -98
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +12 -12
- package/react/auth.d.ts +342 -118
- package/{testing.cjs → react/form.cjs} +1 -1
- package/react/form.d.ts +126 -0
- package/react/form.js +1 -0
- package/react/head.d.ts +46 -8
- package/react/i18n.cjs +8 -0
- package/react/i18n.d.ts +112 -0
- package/react/i18n.js +1 -0
- package/react.d.ts +261 -164
- package/redis.d.ts +7 -7
- package/scheduler.d.ts +9 -9
- package/security.d.ts +131 -111
- package/server/cache.d.ts +10 -8
- package/server/compress.d.ts +1 -1
- package/server/cookies.d.ts +44 -15
- package/server/cors.d.ts +4 -4
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +1 -1
- package/server/links.d.ts +11 -10
- package/server/metrics.d.ts +5 -5
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +4 -4
- package/server/security.d.ts +8 -10
- package/server/static.d.ts +3 -3
- package/server/swagger.d.ts +3 -3
- package/server.d.ts +47 -39
- package/topic/redis.d.ts +4 -4
- package/topic.d.ts +5 -5
- package/vite.d.ts +55 -24
- package/testing.d.ts +0 -1
- package/testing.js +0 -1
package/react/head.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Descriptor, KIND } from "alepha";
|
|
3
4
|
import { PageConfigSchema, PageReactContext, PageRoute, RouterState, TPropsDefault, TPropsParentDefault } from "alepha/react";
|
|
4
5
|
|
|
5
6
|
//#region src/interfaces/Head.d.ts
|
|
@@ -44,21 +45,58 @@ interface SimpleHead {
|
|
|
44
45
|
}
|
|
45
46
|
//# sourceMappingURL=Head.d.ts.map
|
|
46
47
|
//#endregion
|
|
47
|
-
//#region src/hooks/useHead.d.ts
|
|
48
|
-
declare const useHead: (head?: Head | ((previous?: Head) => Head)) => void;
|
|
49
|
-
//# sourceMappingURL=useHead.d.ts.map
|
|
50
|
-
//#endregion
|
|
51
48
|
//#region src/providers/HeadProvider.d.ts
|
|
52
49
|
declare class HeadProvider {
|
|
50
|
+
global?: Head | (() => Head);
|
|
51
|
+
protected getGlobalHead(): Head | undefined;
|
|
53
52
|
fillHead(state: RouterState, context: PageReactContext): void;
|
|
54
53
|
protected fillHeadByPage(page: PageRoute, context: PageReactContext, props: Record<string, any>): void;
|
|
55
54
|
}
|
|
56
55
|
//# sourceMappingURL=HeadProvider.d.ts.map
|
|
57
56
|
//#endregion
|
|
57
|
+
//#region src/descriptors/$head.d.ts
|
|
58
|
+
/**
|
|
59
|
+
* Set global `<head>` options for the application.
|
|
60
|
+
*/
|
|
61
|
+
declare const $head: {
|
|
62
|
+
(options: HeadDescriptorOptions): HeadDescriptor;
|
|
63
|
+
[KIND]: typeof HeadDescriptor;
|
|
64
|
+
};
|
|
65
|
+
type HeadDescriptorOptions = Head | (() => Head);
|
|
66
|
+
declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
|
|
67
|
+
protected readonly provider: HeadProvider;
|
|
68
|
+
protected onInit(): void;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=$head.d.ts.map
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/hooks/useHead.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* ```tsx
|
|
76
|
+
* const App = () => {
|
|
77
|
+
* const [head, setHead] = useHead({
|
|
78
|
+
* // will set the document title on the first render
|
|
79
|
+
* title: "My App",
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* return (
|
|
83
|
+
* // This will update the document title when the button is clicked
|
|
84
|
+
* <button onClick={() => setHead({ title: "Change Title" })}>
|
|
85
|
+
* Change Title {head.title}
|
|
86
|
+
* </button>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const useHead: (options?: UseHeadOptions) => void;
|
|
92
|
+
type UseHeadOptions = Head | ((previous?: Head) => Head);
|
|
93
|
+
type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void];
|
|
94
|
+
//# sourceMappingURL=useHead.d.ts.map
|
|
95
|
+
//#endregion
|
|
58
96
|
//#region src/providers/ServerHeadProvider.d.ts
|
|
59
97
|
declare class ServerHeadProvider {
|
|
60
98
|
protected readonly headProvider: HeadProvider;
|
|
61
|
-
protected readonly onServerRenderEnd:
|
|
99
|
+
protected readonly onServerRenderEnd: _alepha_core1.HookDescriptor<"react:server:render:end">;
|
|
62
100
|
renderHead(template: string, head: SimpleHead): string;
|
|
63
101
|
protected mergeAttributes(existing: string, attrs: Record<string, string>): string;
|
|
64
102
|
protected parseAttributes(attrStr: string): Record<string, string>;
|
|
@@ -81,9 +119,9 @@ declare module "alepha/react" {
|
|
|
81
119
|
* @see {@link ServerHeadProvider}
|
|
82
120
|
* @module alepha.react.head
|
|
83
121
|
*/
|
|
84
|
-
declare const AlephaReactHead: _alepha_core0.
|
|
122
|
+
declare const AlephaReactHead: _alepha_core0.Service<_alepha_core0.Module>;
|
|
85
123
|
//# sourceMappingURL=index.d.ts.map
|
|
86
124
|
|
|
87
125
|
//#endregion
|
|
88
|
-
export { AlephaReactHead, Head, ServerHeadProvider, SimpleHead, useHead };
|
|
126
|
+
export { $head, AlephaReactHead, Head, HeadDescriptor, HeadDescriptorOptions, ServerHeadProvider, SimpleHead, UseHeadOptions, UseHeadReturn, useHead };
|
|
89
127
|
//# sourceMappingURL=index.d.ts.map
|
package/react/i18n.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/react-i18n');
|
|
3
|
+
Object.keys(m).forEach(function (k) {
|
|
4
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () { return m[k]; }
|
|
7
|
+
});
|
|
8
|
+
});
|
package/react/i18n.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as _alepha_core1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha, Descriptor, KIND } from "alepha";
|
|
4
|
+
import * as _alepha_server_cookies0 from "alepha/server/cookies";
|
|
5
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
6
|
+
|
|
7
|
+
//#region src/providers/I18nProvider.d.ts
|
|
8
|
+
declare class I18nProvider {
|
|
9
|
+
logger: _alepha_core1.Logger;
|
|
10
|
+
alepha: Alepha;
|
|
11
|
+
cookie: _alepha_server_cookies0.AbstractCookieDescriptor<_sinclair_typebox0.TString>;
|
|
12
|
+
registry: Array<{
|
|
13
|
+
name: string;
|
|
14
|
+
lang: string;
|
|
15
|
+
loader: () => Promise<Record<string, string>>;
|
|
16
|
+
translations: Record<string, string>;
|
|
17
|
+
}>;
|
|
18
|
+
options: {
|
|
19
|
+
fallbackLang: string;
|
|
20
|
+
};
|
|
21
|
+
get languages(): string[];
|
|
22
|
+
onRender: _alepha_core1.HookDescriptor<"server:onRequest">;
|
|
23
|
+
onStart: _alepha_core1.HookDescriptor<"start">;
|
|
24
|
+
setLang(lang: string): Promise<void>;
|
|
25
|
+
get lang(): string;
|
|
26
|
+
translate: (key: string, args?: string[]) => string;
|
|
27
|
+
protected render(item: string, args: string[]): string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/descriptors/$dictionary.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Register a dictionary entry for translations.
|
|
35
|
+
*
|
|
36
|
+
* It allows you to define a set of translations for a specific language.
|
|
37
|
+
* Entry can be lazy-loaded, which is useful for large dictionaries or when translations are not needed immediately.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { $dictionary } from "alepha/react/i18n";
|
|
42
|
+
*
|
|
43
|
+
* const Example = () => {
|
|
44
|
+
* const { tr } = useI18n<App, "en">();
|
|
45
|
+
* return <div>{tr("hello")}</div>; //
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* class App {
|
|
49
|
+
*
|
|
50
|
+
* en = $dictionary({
|
|
51
|
+
* // { default: { hello: "Hey" } }
|
|
52
|
+
* lazy: () => import("./translations/en.ts"),
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* home = $page({
|
|
56
|
+
* path: "/",
|
|
57
|
+
* component: Example,
|
|
58
|
+
* })
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* run(App);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare const $dictionary: {
|
|
65
|
+
<T extends Record<string, string>>(options: DictionaryDescriptorOptions<T>): DictionaryDescriptor<T>;
|
|
66
|
+
[KIND]: typeof DictionaryDescriptor;
|
|
67
|
+
};
|
|
68
|
+
interface DictionaryDescriptorOptions<T extends Record<string, string>> {
|
|
69
|
+
lang?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
lazy: () => Promise<{
|
|
72
|
+
default: T;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
declare class DictionaryDescriptor<T extends Record<string, string>> extends Descriptor<DictionaryDescriptorOptions<T>> {
|
|
76
|
+
protected provider: I18nProvider;
|
|
77
|
+
protected onInit(): void;
|
|
78
|
+
}
|
|
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
|
+
//#endregion
|
|
94
|
+
//#region src/index.d.ts
|
|
95
|
+
declare module "alepha" {
|
|
96
|
+
interface State {
|
|
97
|
+
"react.i18n.lang"?: string;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Add i18n support to your Alepha React application. SSR and CSR compatible.
|
|
102
|
+
*
|
|
103
|
+
* It supports lazy loading of translations and provides a context to access the current language.
|
|
104
|
+
*
|
|
105
|
+
* @module alepha.react.i18n
|
|
106
|
+
*/
|
|
107
|
+
declare const AlephaReactI18n: _alepha_core0.Service<_alepha_core0.Module>;
|
|
108
|
+
//# sourceMappingURL=index.d.ts.map
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nProvider, ServiceDictionary, useI18n };
|
|
112
|
+
//# sourceMappingURL=index.d.ts.map
|
package/react/i18n.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/react-i18n'
|