alepha 0.9.0 → 0.9.2
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/command.d.ts +29 -3
- package/core.d.ts +17 -11
- package/lock.d.ts +7 -7
- package/package.json +54 -40
- package/postgres.d.ts +4 -4
- package/react/form.cjs +8 -0
- package/react/form.d.ts +117 -0
- package/react/form.js +1 -0
- package/react/i18n.cjs +8 -0
- package/react/i18n.d.ts +73 -0
- package/react/i18n.js +1 -0
- package/react.d.ts +56 -32
- package/server/links.d.ts +6 -5
- package/server/security.d.ts +3 -1
- package/server.d.ts +45 -44
package/command.d.ts
CHANGED
|
@@ -14,9 +14,20 @@ interface Timer {
|
|
|
14
14
|
name: string;
|
|
15
15
|
duration: string;
|
|
16
16
|
}
|
|
17
|
+
interface RunOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Rename the command for logging purposes.
|
|
20
|
+
*/
|
|
21
|
+
alias?: string;
|
|
22
|
+
/**
|
|
23
|
+
* If true, the command will not be logged.
|
|
24
|
+
*/
|
|
25
|
+
silent?: boolean;
|
|
26
|
+
}
|
|
17
27
|
interface RunnerMethod {
|
|
18
|
-
(cmd: string | Array<string | Task>, fn?: () => any): Promise<string>;
|
|
19
|
-
rm: (glob: string | string[]) => Promise<string>;
|
|
28
|
+
(cmd: string | Array<string | Task>, fn?: () => any, options?: RunOptions): Promise<string>;
|
|
29
|
+
rm: (glob: string | string[], options?: RunOptions) => Promise<string>;
|
|
30
|
+
cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
|
|
20
31
|
}
|
|
21
32
|
declare class Runner {
|
|
22
33
|
protected readonly log: Logger;
|
|
@@ -24,6 +35,7 @@ declare class Runner {
|
|
|
24
35
|
protected readonly startTime: number;
|
|
25
36
|
readonly run: RunnerMethod;
|
|
26
37
|
constructor(log: Logger);
|
|
38
|
+
protected createRunMethod(): RunnerMethod;
|
|
27
39
|
protected exec(cmd: string): Promise<string>;
|
|
28
40
|
/**
|
|
29
41
|
* Executes one or more tasks.
|
|
@@ -73,6 +85,10 @@ interface CommandDescriptorOptions<T extends TObject> {
|
|
|
73
85
|
* A TypeBox object schema defining the flags for the command.
|
|
74
86
|
*/
|
|
75
87
|
flags?: T;
|
|
88
|
+
/**
|
|
89
|
+
* If false, skip summary message at the end of the command execution.
|
|
90
|
+
*/
|
|
91
|
+
summary?: boolean;
|
|
76
92
|
}
|
|
77
93
|
declare class CommandDescriptor<T extends TObject = TObject> extends Descriptor<CommandDescriptorOptions<T>> {
|
|
78
94
|
readonly flags: TObject<{}>;
|
|
@@ -140,8 +156,18 @@ declare class CliProvider {
|
|
|
140
156
|
* @module alepha.command
|
|
141
157
|
*/
|
|
142
158
|
declare const AlephaCommand: _alepha_core0.ModuleDescriptor;
|
|
159
|
+
declare module "@sinclair/typebox" {
|
|
160
|
+
interface StringOptions {
|
|
161
|
+
/**
|
|
162
|
+
* Additional aliases for the flags.
|
|
163
|
+
*
|
|
164
|
+
* @module alepha.command
|
|
165
|
+
*/
|
|
166
|
+
aliases?: string[];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
143
169
|
//# sourceMappingURL=index.d.ts.map
|
|
144
170
|
|
|
145
171
|
//#endregion
|
|
146
|
-
export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, Runner, RunnerMethod, Task };
|
|
172
|
+
export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
|
|
147
173
|
//# sourceMappingURL=index.d.ts.map
|
package/core.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ declare class AlsProvider {
|
|
|
137
137
|
constructor();
|
|
138
138
|
createContextId(): string;
|
|
139
139
|
run<R>(callback: () => R, data?: Record<string, any>): R;
|
|
140
|
+
exists(): boolean;
|
|
140
141
|
get<T>(key: string): T | undefined;
|
|
141
142
|
set<T>(key: string, value: T): void;
|
|
142
143
|
}
|
|
@@ -495,7 +496,10 @@ declare class Alepha {
|
|
|
495
496
|
* Modules are used to group services and provide a way to register them in the container.
|
|
496
497
|
*/
|
|
497
498
|
protected modules: Array<ModuleDefinition>;
|
|
498
|
-
protected substitutions: Map<Service,
|
|
499
|
+
protected substitutions: Map<Service, {
|
|
500
|
+
use: Service;
|
|
501
|
+
module?: ModuleDefinition;
|
|
502
|
+
}>;
|
|
499
503
|
protected configurations: Map<Service, object>;
|
|
500
504
|
protected descriptorRegistry: Map<Service<Descriptor<{}>>, Descriptor<{}>[]>;
|
|
501
505
|
/**
|
|
@@ -629,10 +633,12 @@ declare class Alepha {
|
|
|
629
633
|
* > It's useful for testing or for providing different implementations of a service.
|
|
630
634
|
* > If you are interested in configuring a service, use Alepha#configure() instead.
|
|
631
635
|
*
|
|
632
|
-
* @param
|
|
636
|
+
* @param serviceEntry - The service to register in the container.
|
|
633
637
|
* @return Current instance of Alepha.
|
|
634
638
|
*/
|
|
635
|
-
with<T extends object>(
|
|
639
|
+
with<T extends object>(serviceEntry: ServiceEntry<T> | {
|
|
640
|
+
default: ServiceEntry<T>;
|
|
641
|
+
}): this;
|
|
636
642
|
/**
|
|
637
643
|
* Get the instance of the specified service and apply some changes, depending on the options.
|
|
638
644
|
* - If the service is already registered, it will return the existing instance. (except if `skipCache` is true)
|
|
@@ -814,14 +820,6 @@ interface Env extends LoggerEnv {
|
|
|
814
820
|
* Optional root module name.
|
|
815
821
|
*/
|
|
816
822
|
MODULE_NAME?: string;
|
|
817
|
-
/**
|
|
818
|
-
* If true, the container will not automatically register the default providers based on the descriptors.
|
|
819
|
-
*
|
|
820
|
-
* It means that you have to alepha.with(ServiceModule) manually. No magic.
|
|
821
|
-
*
|
|
822
|
-
* @default false
|
|
823
|
-
*/
|
|
824
|
-
EXPLICIT_PROVIDERS?: boolean;
|
|
825
823
|
}
|
|
826
824
|
interface State {
|
|
827
825
|
log: Logger;
|
|
@@ -1436,6 +1434,14 @@ declare function isEmail(value: string): boolean;
|
|
|
1436
1434
|
//# sourceMappingURL=TypeProvider.d.ts.map
|
|
1437
1435
|
//#endregion
|
|
1438
1436
|
//#region src/index.d.ts
|
|
1437
|
+
declare global {
|
|
1438
|
+
interface ImportMetaEnv {
|
|
1439
|
+
SSR: boolean;
|
|
1440
|
+
}
|
|
1441
|
+
interface ImportMeta {
|
|
1442
|
+
readonly env: ImportMetaEnv;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1439
1445
|
/**
|
|
1440
1446
|
*
|
|
1441
1447
|
*/
|
package/lock.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as _alepha_core1 from "alepha";
|
|
2
1
|
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core5 from "alepha";
|
|
3
3
|
import * as _alepha_core0 from "alepha";
|
|
4
4
|
import { AsyncFn, Descriptor, KIND, Static } from "alepha";
|
|
5
5
|
import * as _alepha_topic0 from "alepha/topic";
|
|
@@ -89,14 +89,14 @@ interface LockDescriptorOptions<TFunc extends AsyncFn> {
|
|
|
89
89
|
*/
|
|
90
90
|
gracePeriod?: ((...args: Parameters<TFunc>) => DurationLike | undefined) | DurationLike;
|
|
91
91
|
}
|
|
92
|
-
declare const envSchema:
|
|
93
|
-
LOCK_PREFIX_KEY:
|
|
92
|
+
declare const envSchema: _alepha_core0$1.TObject<{
|
|
93
|
+
LOCK_PREFIX_KEY: _alepha_core0$1.TString;
|
|
94
94
|
}>;
|
|
95
95
|
declare module "alepha" {
|
|
96
96
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
97
97
|
}
|
|
98
98
|
declare class LockDescriptor<TFunc extends AsyncFn> extends Descriptor<LockDescriptorOptions<TFunc>> {
|
|
99
|
-
protected readonly log:
|
|
99
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
100
100
|
protected readonly provider: LockProvider;
|
|
101
101
|
protected readonly env: {
|
|
102
102
|
LOCK_PREFIX_KEY: string;
|
|
@@ -105,8 +105,8 @@ declare class LockDescriptor<TFunc extends AsyncFn> extends Descriptor<LockDescr
|
|
|
105
105
|
protected readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
106
106
|
readonly maxDuration: dayjs_plugin_duration0.Duration;
|
|
107
107
|
protected readonly topicLockEnd: _alepha_topic0.TopicDescriptor<{
|
|
108
|
-
payload:
|
|
109
|
-
name:
|
|
108
|
+
payload: _alepha_core0$1.TObject<{
|
|
109
|
+
name: _alepha_core0$1.TString;
|
|
110
110
|
}>;
|
|
111
111
|
}>;
|
|
112
112
|
run(...args: Parameters<TFunc>): Promise<void>;
|
|
@@ -137,7 +137,7 @@ declare abstract class LockTopicProvider extends TopicProvider {}
|
|
|
137
137
|
*/
|
|
138
138
|
declare class MemoryLockProvider implements LockProvider {
|
|
139
139
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
140
|
-
protected readonly log:
|
|
140
|
+
protected readonly log: _alepha_core5.Logger;
|
|
141
141
|
/**
|
|
142
142
|
* The in-memory store.
|
|
143
143
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alepha",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -15,45 +15,47 @@
|
|
|
15
15
|
"main": "./core.js",
|
|
16
16
|
"types": "./core.d.ts",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alepha/batch": "0.9.
|
|
19
|
-
"@alepha/bucket": "0.9.
|
|
20
|
-
"@alepha/cache": "0.9.
|
|
21
|
-
"@alepha/cache-redis": "0.9.
|
|
22
|
-
"@alepha/command": "0.9.
|
|
23
|
-
"@alepha/core": "0.9.
|
|
24
|
-
"@alepha/datetime": "0.9.
|
|
25
|
-
"@alepha/file": "0.9.
|
|
26
|
-
"@alepha/lock": "0.9.
|
|
27
|
-
"@alepha/lock-redis": "0.9.
|
|
28
|
-
"@alepha/postgres": "0.9.
|
|
29
|
-
"@alepha/queue": "0.9.
|
|
30
|
-
"@alepha/queue-redis": "0.9.
|
|
31
|
-
"@alepha/react": "0.9.
|
|
32
|
-
"@alepha/react-auth": "0.9.
|
|
33
|
-
"@alepha/react-
|
|
34
|
-
"@alepha/
|
|
35
|
-
"@alepha/
|
|
36
|
-
"@alepha/
|
|
37
|
-
"@alepha/
|
|
38
|
-
"@alepha/
|
|
39
|
-
"@alepha/
|
|
40
|
-
"@alepha/
|
|
41
|
-
"@alepha/server
|
|
42
|
-
"@alepha/server-
|
|
43
|
-
"@alepha/server-
|
|
44
|
-
"@alepha/server-
|
|
45
|
-
"@alepha/server-
|
|
46
|
-
"@alepha/server-
|
|
47
|
-
"@alepha/server-
|
|
48
|
-
"@alepha/server-
|
|
49
|
-
"@alepha/server-
|
|
50
|
-
"@alepha/server-
|
|
51
|
-
"@alepha/server-
|
|
52
|
-
"@alepha/server-
|
|
53
|
-
"@alepha/
|
|
54
|
-
"@alepha/
|
|
55
|
-
"@alepha/
|
|
56
|
-
"@alepha/
|
|
18
|
+
"@alepha/batch": "0.9.2",
|
|
19
|
+
"@alepha/bucket": "0.9.2",
|
|
20
|
+
"@alepha/cache": "0.9.2",
|
|
21
|
+
"@alepha/cache-redis": "0.9.2",
|
|
22
|
+
"@alepha/command": "0.9.2",
|
|
23
|
+
"@alepha/core": "0.9.2",
|
|
24
|
+
"@alepha/datetime": "0.9.2",
|
|
25
|
+
"@alepha/file": "0.9.2",
|
|
26
|
+
"@alepha/lock": "0.9.2",
|
|
27
|
+
"@alepha/lock-redis": "0.9.2",
|
|
28
|
+
"@alepha/postgres": "0.9.2",
|
|
29
|
+
"@alepha/queue": "0.9.2",
|
|
30
|
+
"@alepha/queue-redis": "0.9.2",
|
|
31
|
+
"@alepha/react": "0.9.2",
|
|
32
|
+
"@alepha/react-auth": "0.9.2",
|
|
33
|
+
"@alepha/react-form": "0.9.2",
|
|
34
|
+
"@alepha/react-head": "0.9.2",
|
|
35
|
+
"@alepha/react-i18n": "0.9.2",
|
|
36
|
+
"@alepha/redis": "0.9.2",
|
|
37
|
+
"@alepha/retry": "0.9.2",
|
|
38
|
+
"@alepha/router": "0.9.2",
|
|
39
|
+
"@alepha/scheduler": "0.9.2",
|
|
40
|
+
"@alepha/security": "0.9.2",
|
|
41
|
+
"@alepha/server": "0.9.2",
|
|
42
|
+
"@alepha/server-cache": "0.9.2",
|
|
43
|
+
"@alepha/server-compress": "0.9.2",
|
|
44
|
+
"@alepha/server-cookies": "0.9.2",
|
|
45
|
+
"@alepha/server-cors": "0.9.2",
|
|
46
|
+
"@alepha/server-health": "0.9.2",
|
|
47
|
+
"@alepha/server-helmet": "0.9.2",
|
|
48
|
+
"@alepha/server-links": "0.9.2",
|
|
49
|
+
"@alepha/server-metrics": "0.9.2",
|
|
50
|
+
"@alepha/server-multipart": "0.9.2",
|
|
51
|
+
"@alepha/server-proxy": "0.9.2",
|
|
52
|
+
"@alepha/server-security": "0.9.2",
|
|
53
|
+
"@alepha/server-static": "0.9.2",
|
|
54
|
+
"@alepha/server-swagger": "0.9.2",
|
|
55
|
+
"@alepha/testing": "0.9.2",
|
|
56
|
+
"@alepha/topic": "0.9.2",
|
|
57
|
+
"@alepha/topic-redis": "0.9.2",
|
|
58
|
+
"@alepha/vite": "0.9.2"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
61
|
"tsdown": "^0.13.0"
|
|
@@ -147,11 +149,21 @@
|
|
|
147
149
|
"require": "./react/auth.cjs",
|
|
148
150
|
"types": "./react/auth.d.ts"
|
|
149
151
|
},
|
|
152
|
+
"./react/form": {
|
|
153
|
+
"import": "./react/form.js",
|
|
154
|
+
"require": "./react/form.cjs",
|
|
155
|
+
"types": "./react/form.d.ts"
|
|
156
|
+
},
|
|
150
157
|
"./react/head": {
|
|
151
158
|
"import": "./react/head.js",
|
|
152
159
|
"require": "./react/head.cjs",
|
|
153
160
|
"types": "./react/head.d.ts"
|
|
154
161
|
},
|
|
162
|
+
"./react/i18n": {
|
|
163
|
+
"import": "./react/i18n.js",
|
|
164
|
+
"require": "./react/i18n.cjs",
|
|
165
|
+
"types": "./react/i18n.d.ts"
|
|
166
|
+
},
|
|
155
167
|
"./redis": {
|
|
156
168
|
"import": "./redis.js",
|
|
157
169
|
"require": "./redis.cjs",
|
|
@@ -285,7 +297,9 @@
|
|
|
285
297
|
"queue-redis",
|
|
286
298
|
"react",
|
|
287
299
|
"react-auth",
|
|
300
|
+
"react-form",
|
|
288
301
|
"react-head",
|
|
302
|
+
"react-i18n",
|
|
289
303
|
"redis",
|
|
290
304
|
"retry",
|
|
291
305
|
"router",
|
package/postgres.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
|
18
18
|
import postgres from "postgres";
|
|
19
19
|
import * as _alepha_retry0 from "alepha/retry";
|
|
20
20
|
import * as _sinclair_typebox9 from "@sinclair/typebox";
|
|
21
|
+
import * as _sinclair_typebox16 from "@sinclair/typebox";
|
|
21
22
|
import * as _sinclair_typebox17 from "@sinclair/typebox";
|
|
22
23
|
import * as _sinclair_typebox18 from "@sinclair/typebox";
|
|
23
|
-
import * as _sinclair_typebox16 from "@sinclair/typebox";
|
|
24
24
|
import * as _sinclair_typebox6 from "@sinclair/typebox";
|
|
25
25
|
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
26
26
|
import { Evaluate, IntegerOptions, Kind, NumberOptions, ObjectOptions, OptionalKind, Static as Static$1, StringOptions, TAdditionalProperties, TArray, TBoolean, TInteger, TIntersect, TObject as TObject$1, TOptional, TOptionalWithFlag, TPick, TProperties, TReadonly, TRecord, TSchema as TSchema$2 } from "@sinclair/typebox";
|
|
@@ -1398,7 +1398,7 @@ declare class NodePostgresProvider extends PostgresProvider {
|
|
|
1398
1398
|
type PgAttr<T extends TSchema$1, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K] };
|
|
1399
1399
|
//#endregion
|
|
1400
1400
|
//#region src/schemas/createdAtSchema.d.ts
|
|
1401
|
-
declare const createdAtSchema: PgAttr<PgAttr<
|
|
1401
|
+
declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox16.TString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>;
|
|
1402
1402
|
//# sourceMappingURL=createdAtSchema.d.ts.map
|
|
1403
1403
|
|
|
1404
1404
|
//#endregion
|
|
@@ -1406,11 +1406,11 @@ declare const createdAtSchema: PgAttr<PgAttr<_sinclair_typebox17.TString, typeof
|
|
|
1406
1406
|
/**
|
|
1407
1407
|
* @deprecated Use `pg.primaryKey()` instead.
|
|
1408
1408
|
*/
|
|
1409
|
-
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<
|
|
1409
|
+
declare const legacyIdSchema: PgAttr<PgAttr<PgAttr<_sinclair_typebox17.TInteger, typeof PG_PRIMARY_KEY>, typeof PG_SERIAL>, typeof PG_DEFAULT>;
|
|
1410
1410
|
//# sourceMappingURL=legacyIdSchema.d.ts.map
|
|
1411
1411
|
//#endregion
|
|
1412
1412
|
//#region src/schemas/updatedAtSchema.d.ts
|
|
1413
|
-
declare const updatedAtSchema: PgAttr<PgAttr<
|
|
1413
|
+
declare const updatedAtSchema: PgAttr<PgAttr<_sinclair_typebox18.TString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>;
|
|
1414
1414
|
//# sourceMappingURL=updatedAtSchema.d.ts.map
|
|
1415
1415
|
|
|
1416
1416
|
//#endregion
|
package/react/form.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var m = require('@alepha/react-form');
|
|
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/form.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as _alepha_core0 from "alepha";
|
|
2
|
+
import { Static, TObject, TSchema } from "alepha";
|
|
3
|
+
import { InputHTMLAttributes } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/useForm.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Custom hook to create a form with validation and field management.
|
|
9
|
+
* This hook uses TypeBox schemas to define the structure and validation rules for the form.
|
|
10
|
+
* It provides a way to handle form submission, field creation, and value management.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { t } from "alepha";
|
|
15
|
+
*
|
|
16
|
+
* const form = useForm({
|
|
17
|
+
* schema: t.object({
|
|
18
|
+
* username: t.string(),
|
|
19
|
+
* password: t.string(),
|
|
20
|
+
* }),
|
|
21
|
+
* handler: (values) => {
|
|
22
|
+
* console.log("Form submitted with values:", values);
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* return (
|
|
27
|
+
* <form onSubmit={form.onSubmit}>
|
|
28
|
+
* <input {...form.input("username")} />
|
|
29
|
+
* <input {...form.input("password")} />
|
|
30
|
+
* <button type="submit">Submit</button>
|
|
31
|
+
* </form>
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const useForm: <T extends TObject>(options: UseFormOptions<T>) => UseFormReturn<T>;
|
|
36
|
+
declare const getValueFromInput: (input: FormDataEntryValue, schema: TSchema) => any;
|
|
37
|
+
declare const valueToInputEntry: (value: any) => string | number;
|
|
38
|
+
type UseFormOptions<T extends TObject> = {
|
|
39
|
+
/**
|
|
40
|
+
* The schema defining the structure and validation rules for the form.
|
|
41
|
+
* This should be a TypeBox schema object.
|
|
42
|
+
*/
|
|
43
|
+
schema: T;
|
|
44
|
+
/**
|
|
45
|
+
* Callback function to handle form submission.
|
|
46
|
+
* This function will receive the parsed and validated form values.
|
|
47
|
+
*/
|
|
48
|
+
handler: (values: Static<T>, args: {
|
|
49
|
+
form: HTMLFormElement;
|
|
50
|
+
}) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Optional callback to handle changes in form values.
|
|
53
|
+
* This can be used to update state or perform side effects when values change.
|
|
54
|
+
*/
|
|
55
|
+
onValuesChange?: (values: Static<T>, previous: Static<T>) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Optional initial values for the form fields.
|
|
58
|
+
* This can be used to pre-populate the form with existing data.
|
|
59
|
+
*/
|
|
60
|
+
initialValues?: Static<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Optional function to create custom field attributes.
|
|
63
|
+
* This can be used to add custom validation, styles, or other attributes.
|
|
64
|
+
*/
|
|
65
|
+
onCreateField?: (name: keyof Static<T> & string, schema: TSchema) => InputHTMLAttributes<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* If defined, this will generate a unique ID for each field, prefixed with this string.
|
|
68
|
+
*
|
|
69
|
+
* > "username" with id="form-123" will become "form-123-username".
|
|
70
|
+
*
|
|
71
|
+
* If omitted, IDs will not be generated.
|
|
72
|
+
*/
|
|
73
|
+
id?: string;
|
|
74
|
+
};
|
|
75
|
+
type UseFormReturn<T extends TObject> = {
|
|
76
|
+
/**
|
|
77
|
+
* Function to handle form submission.
|
|
78
|
+
* This should be attached to the form's onSubmit event.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* const form = useForm();
|
|
83
|
+
*
|
|
84
|
+
* return <form onSubmit={form.onSubmit}></form>;
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
onSubmit?: (event: FormEventLike) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Creates an input field for the specified schema property.
|
|
90
|
+
*/
|
|
91
|
+
input: SchemaToInput<T>;
|
|
92
|
+
};
|
|
93
|
+
type SchemaToInput<T extends TObject> = { [K in keyof T["properties"]]: T["properties"][K] extends TObject ? SchemaToInput<T["properties"][K]> : InputHTMLAttributes<unknown> };
|
|
94
|
+
interface FormEventLike {
|
|
95
|
+
currentTarget: HTMLFormElement;
|
|
96
|
+
preventDefault: () => void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=useForm.d.ts.map
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/index.d.ts
|
|
101
|
+
/**
|
|
102
|
+
* React hooks for managing forms in Alepha applications.
|
|
103
|
+
*
|
|
104
|
+
* This module provides a set of hooks to simplify form handling, validation, and submission in React applications built with Alepha.
|
|
105
|
+
*
|
|
106
|
+
* It includes:
|
|
107
|
+
* - `useForm`: A hook for managing form state, validation, and submission.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link useForm}
|
|
110
|
+
* @module alepha.react.form
|
|
111
|
+
*/
|
|
112
|
+
declare const AlephaReactForm: _alepha_core0.ModuleDescriptor;
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { AlephaReactForm, FormEventLike, SchemaToInput, UseFormOptions, UseFormReturn, getValueFromInput, useForm, valueToInputEntry };
|
|
117
|
+
//# sourceMappingURL=index.d.ts.map
|
package/react/form.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/react-form'
|
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,73 @@
|
|
|
1
|
+
import * as _alepha_core0$1 from "alepha";
|
|
2
|
+
import * as _alepha_core0 from "alepha";
|
|
3
|
+
import { Alepha, Descriptor, KIND } from "alepha";
|
|
4
|
+
|
|
5
|
+
//#region src/providers/I18nProvider.d.ts
|
|
6
|
+
declare class I18nProvider {
|
|
7
|
+
logger: _alepha_core0$1.Logger;
|
|
8
|
+
alepha: Alepha;
|
|
9
|
+
registry: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
lang: string;
|
|
12
|
+
loader: () => Promise<Record<string, string>>;
|
|
13
|
+
translations: Record<string, string>;
|
|
14
|
+
}>;
|
|
15
|
+
options: {
|
|
16
|
+
fallbackLang: string;
|
|
17
|
+
};
|
|
18
|
+
onRender: _alepha_core0$1.HookDescriptor<"server:onRequest">;
|
|
19
|
+
onStart: _alepha_core0$1.HookDescriptor<"start">;
|
|
20
|
+
setLang(lang: string): Promise<void>;
|
|
21
|
+
get lang(): string;
|
|
22
|
+
translate: (key: string) => string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/descriptors/$dictionary.d.ts
|
|
27
|
+
declare const $dictionary: {
|
|
28
|
+
<T extends Record<string, string>>(options: DictionaryDescriptorOptions<T>): DictionaryDescriptor<T>;
|
|
29
|
+
[KIND]: typeof DictionaryDescriptor;
|
|
30
|
+
};
|
|
31
|
+
interface DictionaryDescriptorOptions<T extends Record<string, string>> {
|
|
32
|
+
lang?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
lazy: () => Promise<{
|
|
35
|
+
default: T;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
declare class DictionaryDescriptor<T extends Record<string, string>> extends Descriptor<DictionaryDescriptorOptions<T>> {
|
|
39
|
+
protected provider: I18nProvider;
|
|
40
|
+
protected onInit(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=$dictionary.d.ts.map
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/hooks/useI18n.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Hook to access the i18n service.
|
|
47
|
+
*/
|
|
48
|
+
declare const useI18n: <S extends object, K extends keyof ServiceDictionary<S>>() => {
|
|
49
|
+
lang: string;
|
|
50
|
+
setLang: (lang: string) => Promise<void>;
|
|
51
|
+
tr: (key: keyof ServiceDictionary<S>[K]) => string;
|
|
52
|
+
};
|
|
53
|
+
type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never };
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/index.d.ts
|
|
56
|
+
declare module "alepha" {
|
|
57
|
+
interface State {
|
|
58
|
+
"react.i18n.lang"?: string;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add i18n support to your Alepha React application. SSR and CSR compatible.
|
|
63
|
+
*
|
|
64
|
+
* It supports lazy loading of translations and provides a context to access the current language.
|
|
65
|
+
*
|
|
66
|
+
* @module alepha.react.i18n
|
|
67
|
+
*/
|
|
68
|
+
declare const AlephaReactI18n: _alepha_core0.ModuleDescriptor;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nProvider, useI18n };
|
|
73
|
+
//# sourceMappingURL=index.d.ts.map
|
package/react/i18n.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@alepha/react-i18n'
|
package/react.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as _alepha_core12 from "alepha";
|
|
1
|
+
import * as _alepha_core2 from "alepha";
|
|
2
|
+
import * as _alepha_core16 from "alepha";
|
|
4
3
|
import * as _alepha_core0$1 from "alepha";
|
|
4
|
+
import * as _alepha_core6 from "alepha";
|
|
5
5
|
import * as _alepha_core0 from "alepha";
|
|
6
|
-
import { Alepha, Async, Descriptor, KIND, Service, Static, TObject, TSchema } from "alepha";
|
|
7
|
-
import { ApiLinksResponse, ServerHandler, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
|
|
6
|
+
import { Alepha, Async, Descriptor, KIND, Service, State, Static, TObject, TSchema } from "alepha";
|
|
7
|
+
import { ApiLinksResponse, RequestConfigSchema, ServerHandler, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
|
|
8
8
|
import { ServerRouteCache } from "alepha/server/cache";
|
|
9
|
-
import { ClientScope, HttpVirtualClient, LinkProvider } from "alepha/server/links";
|
|
9
|
+
import { ClientScope, HttpVirtualClient, LinkProvider, VirtualAction } from "alepha/server/links";
|
|
10
10
|
import * as react0$1 from "react";
|
|
11
11
|
import * as react0 from "react";
|
|
12
|
+
import * as react1 from "react";
|
|
12
13
|
import React, { AnchorHTMLAttributes, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
|
|
13
|
-
import * as
|
|
14
|
+
import * as react_jsx_runtime0$1 from "react/jsx-runtime";
|
|
14
15
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
15
|
-
import * as
|
|
16
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
16
17
|
import { Route, RouterProvider } from "alepha/router";
|
|
17
18
|
import { ServerStaticProvider } from "alepha/server/static";
|
|
18
19
|
import { Root } from "react-dom/client";
|
|
@@ -157,14 +158,14 @@ type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsPare
|
|
|
157
158
|
//# sourceMappingURL=$page.d.ts.map
|
|
158
159
|
//#endregion
|
|
159
160
|
//#region src/providers/PageDescriptorProvider.d.ts
|
|
160
|
-
declare const envSchema$1:
|
|
161
|
-
REACT_STRICT_MODE:
|
|
161
|
+
declare const envSchema$1: _alepha_core2.TObject<{
|
|
162
|
+
REACT_STRICT_MODE: _alepha_core2.TBoolean;
|
|
162
163
|
}>;
|
|
163
164
|
declare module "alepha" {
|
|
164
165
|
interface Env extends Partial<Static<typeof envSchema$1>> {}
|
|
165
166
|
}
|
|
166
167
|
declare class PageDescriptorProvider {
|
|
167
|
-
protected readonly log:
|
|
168
|
+
protected readonly log: _alepha_core2.Logger;
|
|
168
169
|
protected readonly env: {
|
|
169
170
|
REACT_STRICT_MODE: boolean;
|
|
170
171
|
};
|
|
@@ -189,7 +190,7 @@ declare class PageDescriptorProvider {
|
|
|
189
190
|
}, params?: Record<string, any>): string;
|
|
190
191
|
compile(path: string, params?: Record<string, string>): string;
|
|
191
192
|
protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
|
|
192
|
-
protected readonly configure:
|
|
193
|
+
protected readonly configure: _alepha_core2.HookDescriptor<"configure">;
|
|
193
194
|
protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
|
|
194
195
|
add(entry: PageRouteEntry): void;
|
|
195
196
|
protected createMatch(page: PageRoute): string;
|
|
@@ -272,11 +273,11 @@ interface BrowserRoute extends Route {
|
|
|
272
273
|
page: PageRoute;
|
|
273
274
|
}
|
|
274
275
|
declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
275
|
-
protected readonly log:
|
|
276
|
+
protected readonly log: _alepha_core16.Logger;
|
|
276
277
|
protected readonly alepha: Alepha;
|
|
277
278
|
protected readonly pageDescriptorProvider: PageDescriptorProvider;
|
|
278
279
|
add(entry: PageRouteEntry): void;
|
|
279
|
-
protected readonly configure:
|
|
280
|
+
protected readonly configure: _alepha_core16.HookDescriptor<"configure">;
|
|
280
281
|
transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
|
|
281
282
|
root(state: RouterState, context: PageReactContext): ReactNode;
|
|
282
283
|
}
|
|
@@ -284,7 +285,7 @@ declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
|
|
|
284
285
|
//#endregion
|
|
285
286
|
//#region src/providers/ReactBrowserProvider.d.ts
|
|
286
287
|
declare class ReactBrowserProvider {
|
|
287
|
-
protected readonly log:
|
|
288
|
+
protected readonly log: _alepha_core0$1.Logger;
|
|
288
289
|
protected readonly client: LinkProvider;
|
|
289
290
|
protected readonly alepha: Alepha;
|
|
290
291
|
protected readonly router: BrowserRouterProvider;
|
|
@@ -308,7 +309,7 @@ declare class ReactBrowserProvider {
|
|
|
308
309
|
* Get embedded layers from the server.
|
|
309
310
|
*/
|
|
310
311
|
protected getHydrationState(): ReactHydrationState | undefined;
|
|
311
|
-
readonly ready:
|
|
312
|
+
readonly ready: _alepha_core0$1.HookDescriptor<"ready">;
|
|
312
313
|
}
|
|
313
314
|
interface RouterGoOptions {
|
|
314
315
|
replace?: boolean;
|
|
@@ -366,7 +367,7 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
366
367
|
to: string | PageDescriptor;
|
|
367
368
|
children?: React.ReactNode;
|
|
368
369
|
}
|
|
369
|
-
declare const Link: (props: LinkProps) =>
|
|
370
|
+
declare const Link: (props: LinkProps) => react_jsx_runtime0$1.JSX.Element | null;
|
|
370
371
|
//#endregion
|
|
371
372
|
//#region src/components/NestedView.d.ts
|
|
372
373
|
interface NestedViewProps {
|
|
@@ -396,16 +397,19 @@ interface NestedViewProps {
|
|
|
396
397
|
declare const NestedView: (props: NestedViewProps) => react_jsx_runtime0.JSX.Element;
|
|
397
398
|
//#endregion
|
|
398
399
|
//#region src/components/NotFound.d.ts
|
|
399
|
-
declare function NotFoundPage():
|
|
400
|
+
declare function NotFoundPage(): react_jsx_runtime1.JSX.Element;
|
|
400
401
|
//# sourceMappingURL=NotFound.d.ts.map
|
|
401
402
|
//#endregion
|
|
403
|
+
//#region src/contexts/AlephaContext.d.ts
|
|
404
|
+
declare const AlephaContext: react0$1.Context<Alepha | undefined>;
|
|
405
|
+
//# sourceMappingURL=AlephaContext.d.ts.map
|
|
406
|
+
//#endregion
|
|
402
407
|
//#region src/contexts/RouterContext.d.ts
|
|
403
408
|
interface RouterContextValue {
|
|
404
|
-
alepha: Alepha;
|
|
405
409
|
state: RouterState;
|
|
406
410
|
context: PageReactContext;
|
|
407
411
|
}
|
|
408
|
-
declare const RouterContext: react0
|
|
412
|
+
declare const RouterContext: react0.Context<RouterContextValue | undefined>;
|
|
409
413
|
//# sourceMappingURL=RouterContext.d.ts.map
|
|
410
414
|
//#endregion
|
|
411
415
|
//#region src/contexts/RouterLayerContext.d.ts
|
|
@@ -413,7 +417,7 @@ interface RouterLayerContextValue {
|
|
|
413
417
|
index: number;
|
|
414
418
|
path: string;
|
|
415
419
|
}
|
|
416
|
-
declare const RouterLayerContext:
|
|
420
|
+
declare const RouterLayerContext: react1.Context<RouterLayerContextValue | undefined>;
|
|
417
421
|
//# sourceMappingURL=RouterLayerContext.d.ts.map
|
|
418
422
|
//#endregion
|
|
419
423
|
//#region src/hooks/RouterHookApi.d.ts
|
|
@@ -501,7 +505,7 @@ declare const useClient: <T extends object>(_scope?: ClientScope) => HttpVirtual
|
|
|
501
505
|
//# sourceMappingURL=useClient.d.ts.map
|
|
502
506
|
//#endregion
|
|
503
507
|
//#region src/hooks/useInject.d.ts
|
|
504
|
-
declare const useInject: <T extends object>(
|
|
508
|
+
declare const useInject: <T extends object>(service: Service<T>) => T;
|
|
505
509
|
//# sourceMappingURL=useInject.d.ts.map
|
|
506
510
|
//#endregion
|
|
507
511
|
//#region src/hooks/useQueryParams.d.ts
|
|
@@ -535,24 +539,43 @@ declare const useRouterEvents: (opts?: {
|
|
|
535
539
|
//#region src/hooks/useRouterState.d.ts
|
|
536
540
|
declare const useRouterState: () => RouterState;
|
|
537
541
|
//# sourceMappingURL=useRouterState.d.ts.map
|
|
538
|
-
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/hooks/useSchema.d.ts
|
|
544
|
+
declare const useSchema: <TConfig extends RequestConfigSchema>(action: VirtualAction<TConfig>) => UseSchemaReturn<TConfig>;
|
|
545
|
+
type UseSchemaReturn<TConfig extends RequestConfigSchema> = TConfig & {
|
|
546
|
+
loading: boolean;
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Get an action schema during server-side rendering (SSR) or client-side rendering (CSR).
|
|
550
|
+
*/
|
|
551
|
+
declare const ssrSchemaLoading: (alepha: Alepha, name: string) => RequestConfigSchema | {
|
|
552
|
+
loading: boolean;
|
|
553
|
+
};
|
|
554
|
+
//# sourceMappingURL=useSchema.d.ts.map
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/hooks/useStore.d.ts
|
|
557
|
+
/**
|
|
558
|
+
* Hook to access and mutate the Alepha state.
|
|
559
|
+
*/
|
|
560
|
+
declare const useStore: <Key extends keyof State>(key: Key) => [State[Key], (value: State[Key]) => void];
|
|
561
|
+
//# sourceMappingURL=useStore.d.ts.map
|
|
539
562
|
//#endregion
|
|
540
563
|
//#region src/providers/ReactServerProvider.d.ts
|
|
541
|
-
declare const envSchema:
|
|
542
|
-
REACT_SERVER_DIST:
|
|
543
|
-
REACT_SERVER_PREFIX:
|
|
544
|
-
REACT_SSR_ENABLED:
|
|
545
|
-
REACT_ROOT_ID:
|
|
564
|
+
declare const envSchema: _alepha_core6.TObject<{
|
|
565
|
+
REACT_SERVER_DIST: _alepha_core6.TString;
|
|
566
|
+
REACT_SERVER_PREFIX: _alepha_core6.TString;
|
|
567
|
+
REACT_SSR_ENABLED: _alepha_core6.TOptional<_alepha_core6.TBoolean>;
|
|
568
|
+
REACT_ROOT_ID: _alepha_core6.TString;
|
|
569
|
+
REACT_SERVER_TEMPLATE: _alepha_core6.TOptional<_alepha_core6.TString>;
|
|
546
570
|
}>;
|
|
547
571
|
declare module "alepha" {
|
|
548
572
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
549
573
|
interface State {
|
|
550
|
-
"react.server.template"?: string;
|
|
551
574
|
"react.server.ssr"?: boolean;
|
|
552
575
|
}
|
|
553
576
|
}
|
|
554
577
|
declare class ReactServerProvider {
|
|
555
|
-
protected readonly log:
|
|
578
|
+
protected readonly log: _alepha_core6.Logger;
|
|
556
579
|
protected readonly alepha: Alepha;
|
|
557
580
|
protected readonly pageDescriptorProvider: PageDescriptorProvider;
|
|
558
581
|
protected readonly serverStaticProvider: ServerStaticProvider;
|
|
@@ -560,12 +583,13 @@ declare class ReactServerProvider {
|
|
|
560
583
|
protected readonly serverTimingProvider: ServerTimingProvider;
|
|
561
584
|
protected readonly env: {
|
|
562
585
|
REACT_SSR_ENABLED?: boolean | undefined;
|
|
586
|
+
REACT_SERVER_TEMPLATE?: string | undefined;
|
|
563
587
|
REACT_SERVER_DIST: string;
|
|
564
588
|
REACT_SERVER_PREFIX: string;
|
|
565
589
|
REACT_ROOT_ID: string;
|
|
566
590
|
};
|
|
567
591
|
protected readonly ROOT_DIV_REGEX: RegExp;
|
|
568
|
-
readonly onConfigure:
|
|
592
|
+
readonly onConfigure: _alepha_core6.HookDescriptor<"configure">;
|
|
569
593
|
get template(): string;
|
|
570
594
|
protected registerPages(templateLoader: TemplateLoader): Promise<void>;
|
|
571
595
|
protected getPublicDirectory(): string;
|
|
@@ -646,5 +670,5 @@ declare const AlephaReact: _alepha_core0.ModuleDescriptor;
|
|
|
646
670
|
//# sourceMappingURL=index.d.ts.map
|
|
647
671
|
|
|
648
672
|
//#endregion
|
|
649
|
-
export { $page, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, HrefLike, Layer, Link, NestedView, NotFoundPage as NotFound, PageConfigSchema, PageDescriptor, PageDescriptorOptions, PageDescriptorProvider, PageDescriptorRenderOptions, PageDescriptorRenderResult, PageReactContext, PageRequest, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactHydrationState, ReactServerProvider, RedirectionError, RouterContext, RouterContextValue, RouterGoOptions, RouterHookApi, RouterLayerContext, RouterLayerContextValue, RouterRenderResult, RouterStackItem, RouterState, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseQueryParamsHookOptions, VirtualRouter, isPageRoute, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
|
|
673
|
+
export { $page, AlephaContext, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, HrefLike, Layer, Link, NestedView, NotFoundPage as NotFound, PageConfigSchema, PageDescriptor, PageDescriptorOptions, PageDescriptorProvider, PageDescriptorRenderOptions, PageDescriptorRenderResult, PageReactContext, PageRequest, PageRequestConfig, PageResolve, PageRoute, PageRouteEntry, PreviousLayerData, ReactBrowserProvider, ReactHydrationState, ReactServerProvider, RedirectionError, RouterContext, RouterContextValue, RouterGoOptions, RouterHookApi, RouterLayerContext, RouterLayerContextValue, RouterRenderResult, RouterStackItem, RouterState, TPropsDefault, TPropsParentDefault, TransitionOptions, UseActiveHook, UseQueryParamsHookOptions, UseSchemaReturn, VirtualRouter, isPageRoute, ssrSchemaLoading, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState, useSchema, useStore };
|
|
650
674
|
//# sourceMappingURL=index.d.ts.map
|
package/server/links.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ declare class LinkProvider {
|
|
|
19
19
|
pushLink(link: HttpClientLink): void;
|
|
20
20
|
getLinks(force?: boolean): Promise<HttpClientLink[]>;
|
|
21
21
|
client<T extends object>(scope?: ClientScope): HttpVirtualClient<T>;
|
|
22
|
+
protected createVirtualAction<T extends RequestConfigSchema>(name: string, scope?: ClientScope): VirtualAction<T>;
|
|
22
23
|
/**
|
|
23
24
|
* Resolve a link by its name and call it.
|
|
24
25
|
* - If link is local, it will call the local handler.
|
|
@@ -41,11 +42,11 @@ interface ClientScope {
|
|
|
41
42
|
group?: string;
|
|
42
43
|
service?: string;
|
|
43
44
|
}
|
|
44
|
-
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ?
|
|
45
|
-
|
|
45
|
+
type HttpVirtualClient<T> = { [K in keyof T as T[K] extends ActionDescriptor<RequestConfigSchema> ? K : never]: T[K] extends ActionDescriptor<infer Schema> ? VirtualAction<Schema> : never };
|
|
46
|
+
interface VirtualAction<T extends RequestConfigSchema> extends Pick<ActionDescriptor<T>, "name" | "run" | "fetch"> {
|
|
47
|
+
(config?: ClientRequestEntry<T>, opts?: ClientRequestOptions): Promise<ClientRequestResponse<T>>;
|
|
46
48
|
can: () => boolean;
|
|
47
|
-
|
|
48
|
-
} : never };
|
|
49
|
+
}
|
|
49
50
|
//# sourceMappingURL=LinkProvider.d.ts.map
|
|
50
51
|
//#endregion
|
|
51
52
|
//#region src/descriptors/$client.d.ts
|
|
@@ -198,5 +199,5 @@ declare const AlephaServerLinks: _alepha_core0.ModuleDescriptor;
|
|
|
198
199
|
//# sourceMappingURL=index.d.ts.map
|
|
199
200
|
|
|
200
201
|
//#endregion
|
|
201
|
-
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote };
|
|
202
|
+
export { $client, $remote, AlephaServerLinks, ClientScope, FetchLinksOptions, GetLinksOptions, HttpClientLink, HttpVirtualClient, LinkProvider, RemoteDescriptor, RemoteDescriptorOptions, RemoteDescriptorProvider, ServerLinksProvider, ServerRemote, VirtualAction };
|
|
202
203
|
//# sourceMappingURL=index.d.ts.map
|
package/server/security.d.ts
CHANGED
|
@@ -62,7 +62,9 @@ declare module "alepha/server" {
|
|
|
62
62
|
* If true, the route will be protected by the security provider.
|
|
63
63
|
* All actions are secure by default, but you can disable it for specific actions.
|
|
64
64
|
*/
|
|
65
|
-
secure?: boolean
|
|
65
|
+
secure?: boolean | {
|
|
66
|
+
optional?: boolean;
|
|
67
|
+
};
|
|
66
68
|
}
|
|
67
69
|
interface ClientRequestOptions extends FetchOptions {
|
|
68
70
|
/**
|
package/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import * as _alepha_core0$1 from "alepha";
|
|
3
|
-
import * as
|
|
4
|
-
import * as _alepha_core13 from "alepha";
|
|
5
|
-
import * as _alepha_core12 from "alepha";
|
|
3
|
+
import * as _alepha_core6 from "alepha";
|
|
6
4
|
import * as _alepha_core2 from "alepha";
|
|
5
|
+
import * as _alepha_core13 from "alepha";
|
|
6
|
+
import * as _alepha_core14 from "alepha";
|
|
7
7
|
import * as _alepha_core0 from "alepha";
|
|
8
8
|
import { Alepha, Async, Descriptor, FileLike, KIND, Static, StreamLike, TObject, TSchema } from "alepha";
|
|
9
9
|
import { Readable } from "node:stream";
|
|
@@ -11,9 +11,9 @@ import { ReadableStream } from "node:stream/web";
|
|
|
11
11
|
import { Route, RouterProvider } from "alepha/router";
|
|
12
12
|
import * as _alepha_cache0 from "alepha/cache";
|
|
13
13
|
import { IncomingMessage, ServerResponse as ServerResponse$1 } from "node:http";
|
|
14
|
-
import { DurationLike } from "alepha/datetime";
|
|
14
|
+
import { DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
15
|
+
import * as _sinclair_typebox17 from "@sinclair/typebox";
|
|
15
16
|
import * as _sinclair_typebox7 from "@sinclair/typebox";
|
|
16
|
-
import * as _sinclair_typebox33 from "@sinclair/typebox";
|
|
17
17
|
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
18
18
|
import * as http0 from "http";
|
|
19
19
|
|
|
@@ -470,23 +470,23 @@ declare const isMultipart: (options: {
|
|
|
470
470
|
//# sourceMappingURL=isMultipart.d.ts.map
|
|
471
471
|
//#endregion
|
|
472
472
|
//#region src/schemas/apiLinksResponseSchema.d.ts
|
|
473
|
-
declare const apiLinkSchema:
|
|
474
|
-
name:
|
|
475
|
-
path:
|
|
476
|
-
method:
|
|
477
|
-
group:
|
|
478
|
-
requestBodyType:
|
|
479
|
-
service:
|
|
473
|
+
declare const apiLinkSchema: _sinclair_typebox17.TObject<{
|
|
474
|
+
name: _sinclair_typebox17.TString;
|
|
475
|
+
path: _sinclair_typebox17.TString;
|
|
476
|
+
method: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
477
|
+
group: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
478
|
+
requestBodyType: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
479
|
+
service: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
480
480
|
}>;
|
|
481
|
-
declare const apiLinksResponseSchema:
|
|
482
|
-
prefix:
|
|
483
|
-
links:
|
|
484
|
-
name:
|
|
485
|
-
path:
|
|
486
|
-
method:
|
|
487
|
-
group:
|
|
488
|
-
requestBodyType:
|
|
489
|
-
service:
|
|
481
|
+
declare const apiLinksResponseSchema: _sinclair_typebox17.TObject<{
|
|
482
|
+
prefix: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
483
|
+
links: _sinclair_typebox17.TArray<_sinclair_typebox17.TObject<{
|
|
484
|
+
name: _sinclair_typebox17.TString;
|
|
485
|
+
path: _sinclair_typebox17.TString;
|
|
486
|
+
method: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
487
|
+
group: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
488
|
+
requestBodyType: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
489
|
+
service: _sinclair_typebox17.TOptional<_sinclair_typebox17.TString>;
|
|
490
490
|
}>>;
|
|
491
491
|
}>;
|
|
492
492
|
type ApiLinksResponse = Static<typeof apiLinksResponseSchema>;
|
|
@@ -494,14 +494,14 @@ type ApiLink = Static<typeof apiLinkSchema>;
|
|
|
494
494
|
//# sourceMappingURL=apiLinksResponseSchema.d.ts.map
|
|
495
495
|
//#endregion
|
|
496
496
|
//#region src/schemas/errorSchema.d.ts
|
|
497
|
-
declare const errorSchema:
|
|
498
|
-
error:
|
|
499
|
-
status:
|
|
500
|
-
message:
|
|
501
|
-
details:
|
|
502
|
-
cause:
|
|
503
|
-
name:
|
|
504
|
-
message:
|
|
497
|
+
declare const errorSchema: _sinclair_typebox7.TObject<{
|
|
498
|
+
error: _sinclair_typebox7.TString;
|
|
499
|
+
status: _sinclair_typebox7.TNumber;
|
|
500
|
+
message: _sinclair_typebox7.TString;
|
|
501
|
+
details: _sinclair_typebox7.TOptional<_sinclair_typebox7.TString>;
|
|
502
|
+
cause: _sinclair_typebox7.TOptional<_sinclair_typebox7.TObject<{
|
|
503
|
+
name: _sinclair_typebox7.TString;
|
|
504
|
+
message: _sinclair_typebox7.TString;
|
|
505
505
|
}>>;
|
|
506
506
|
}>;
|
|
507
507
|
//# sourceMappingURL=errorSchema.d.ts.map
|
|
@@ -516,40 +516,41 @@ type Ok = Static<typeof okSchema>;
|
|
|
516
516
|
//# sourceMappingURL=okSchema.d.ts.map
|
|
517
517
|
//#endregion
|
|
518
518
|
//#region src/providers/NodeHttpServerProvider.d.ts
|
|
519
|
-
declare const envSchema:
|
|
520
|
-
SERVER_PORT:
|
|
521
|
-
SERVER_HOST:
|
|
519
|
+
declare const envSchema: _alepha_core6.TObject<{
|
|
520
|
+
SERVER_PORT: _alepha_core6.TNumber;
|
|
521
|
+
SERVER_HOST: _alepha_core6.TString;
|
|
522
522
|
}>;
|
|
523
523
|
declare module "alepha" {
|
|
524
524
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
525
525
|
}
|
|
526
526
|
declare class NodeHttpServerProvider extends ServerProvider {
|
|
527
527
|
protected readonly alepha: Alepha;
|
|
528
|
-
protected readonly
|
|
528
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
529
|
+
protected readonly log: _alepha_core6.Logger;
|
|
529
530
|
protected readonly env: {
|
|
530
531
|
SERVER_PORT: number;
|
|
531
532
|
SERVER_HOST: string;
|
|
532
533
|
};
|
|
533
534
|
protected readonly router: ServerRouterProvider;
|
|
534
535
|
protected readonly server: http0.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
535
|
-
protected readonly onNodeRequest:
|
|
536
|
+
protected readonly onNodeRequest: _alepha_core6.HookDescriptor<"node:request">;
|
|
536
537
|
handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
|
|
537
538
|
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
538
539
|
getProtocol(req: IncomingMessage): "http" | "https";
|
|
539
540
|
get hostname(): string;
|
|
540
|
-
readonly start:
|
|
541
|
-
protected readonly stop:
|
|
541
|
+
readonly start: _alepha_core6.HookDescriptor<"start">;
|
|
542
|
+
protected readonly stop: _alepha_core6.HookDescriptor<"stop">;
|
|
542
543
|
protected listen(): Promise<void>;
|
|
543
544
|
protected close(): Promise<void>;
|
|
544
545
|
}
|
|
545
546
|
//#endregion
|
|
546
547
|
//#region src/providers/ServerLoggerProvider.d.ts
|
|
547
548
|
declare class ServerLoggerProvider {
|
|
548
|
-
protected readonly log:
|
|
549
|
+
protected readonly log: _alepha_core2.Logger;
|
|
549
550
|
protected readonly alepha: Alepha;
|
|
550
|
-
readonly onRequest:
|
|
551
|
-
readonly onError:
|
|
552
|
-
readonly onResponse:
|
|
551
|
+
readonly onRequest: _alepha_core2.HookDescriptor<"server:onRequest">;
|
|
552
|
+
readonly onError: _alepha_core2.HookDescriptor<"server:onError">;
|
|
553
|
+
readonly onResponse: _alepha_core2.HookDescriptor<"server:onResponse">;
|
|
553
554
|
}
|
|
554
555
|
//# sourceMappingURL=ServerLoggerProvider.d.ts.map
|
|
555
556
|
//#endregion
|
|
@@ -563,17 +564,17 @@ declare class ServerLoggerProvider {
|
|
|
563
564
|
*/
|
|
564
565
|
declare class ServerNotReadyProvider {
|
|
565
566
|
protected readonly alepha: Alepha;
|
|
566
|
-
readonly onRequest:
|
|
567
|
+
readonly onRequest: _alepha_core13.HookDescriptor<"server:onRequest">;
|
|
567
568
|
}
|
|
568
569
|
//# sourceMappingURL=ServerNotReadyProvider.d.ts.map
|
|
569
570
|
//#endregion
|
|
570
571
|
//#region src/providers/ServerTimingProvider.d.ts
|
|
571
572
|
type TimingMap = Record<string, [number, number]>;
|
|
572
573
|
declare class ServerTimingProvider {
|
|
573
|
-
protected readonly log:
|
|
574
|
+
protected readonly log: _alepha_core14.Logger;
|
|
574
575
|
protected readonly alepha: Alepha;
|
|
575
|
-
readonly onRequest:
|
|
576
|
-
readonly onResponse:
|
|
576
|
+
readonly onRequest: _alepha_core14.HookDescriptor<"server:onRequest">;
|
|
577
|
+
readonly onResponse: _alepha_core14.HookDescriptor<"server:onResponse">;
|
|
577
578
|
protected get handlerName(): string;
|
|
578
579
|
beginTiming(name: string): void;
|
|
579
580
|
endTiming(name: string): void;
|