alepha 0.10.0 → 0.10.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/README.md +189 -5
- package/batch.d.ts +2 -2
- package/bucket.d.ts +1 -1
- package/cache/redis.d.ts +1 -1
- package/cache.d.ts +1 -1
- package/command.d.ts +48 -9
- package/core.d.ts +20 -11
- package/datetime.d.ts +3 -2
- package/email.d.ts +6 -6
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +1 -1
- package/logger.d.ts +1 -1
- package/package.json +44 -44
- package/postgres.d.ts +77 -382
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +1 -1
- package/react/auth.d.ts +1 -1
- package/react/form.d.ts +1 -1
- package/react/head.d.ts +1 -1
- package/react/i18n.d.ts +1 -1
- package/react.d.ts +28 -28
- package/redis.d.ts +1 -1
- package/scheduler.d.ts +1 -1
- package/security.d.ts +5 -5
- package/server/cache.d.ts +1 -1
- package/server/compress.d.ts +5 -5
- package/server/cookies.d.ts +1 -1
- package/server/cors.d.ts +1 -1
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +1 -1
- package/server/links.d.ts +1 -1
- package/server/metrics.d.ts +1 -1
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +1 -1
- package/server/security.d.ts +1 -1
- package/server/static.d.ts +1 -1
- package/server/swagger.d.ts +14 -1
- package/server.d.ts +35 -390
- package/topic/redis.d.ts +1 -1
- package/topic.d.ts +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
Alepha
|
|
11
11
|
</h1>
|
|
12
12
|
<p style="max-width: 512px">
|
|
13
|
-
🚧
|
|
14
13
|
</p>
|
|
15
14
|
<a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/v/alepha.svg" alt="npm"/></a>
|
|
16
15
|
<a href="https://www.npmjs.com/package/alepha"><img src="https://img.shields.io/npm/l/alepha.svg" alt="npm"/></a>
|
|
@@ -19,17 +18,25 @@ Alepha
|
|
|
19
18
|
<a href="https://github.com/feunard/alepha"><img src="https://img.shields.io/github/stars/feunard/alepha.svg?style=social" alt="GitHub stars"/></a>
|
|
20
19
|
</div>
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
A convention-driven TypeScript framework for building type-safe full-stack applications.
|
|
23
22
|
|
|
24
|
-
##
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @alepha/cli create my-app
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or manually:
|
|
25
30
|
|
|
26
31
|
```bash
|
|
27
32
|
npm install alepha
|
|
28
33
|
```
|
|
29
34
|
|
|
30
|
-
##
|
|
35
|
+
## What is this?
|
|
36
|
+
|
|
37
|
+
Alepha is an opinionated framework that handles everything from database to frontend.
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
It uses a descriptor-based architecture (`$action`, `$page`, `$repository`, etc.) and enforces type safety across the entire stack.
|
|
33
40
|
|
|
34
41
|
```ts
|
|
35
42
|
import { run } from "alepha";
|
|
@@ -45,3 +52,180 @@ run(App);
|
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
👉 For more information, please visit the [documentation](https://feunard.github.io/alepha/).
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### Type-safe API endpoint
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// app.ts
|
|
62
|
+
import { run, t } from "alepha";
|
|
63
|
+
import { $action } from "alepha/server";
|
|
64
|
+
import { $swagger } from "alepha/server/swagger";
|
|
65
|
+
|
|
66
|
+
class Api {
|
|
67
|
+
docs = $swagger({
|
|
68
|
+
info: {
|
|
69
|
+
title: "My API",
|
|
70
|
+
version: "1.0.0",
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
sayHello = $action({
|
|
75
|
+
path: "/hello/:name",
|
|
76
|
+
schema: {
|
|
77
|
+
params: t.object({
|
|
78
|
+
name: t.string()
|
|
79
|
+
}),
|
|
80
|
+
response: t.object({
|
|
81
|
+
message: t.string(),
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
handler: async ({ params }) => {
|
|
85
|
+
return { message: `Hello ${params.name} !` };
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
run(Api);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
node app.ts
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Database with Drizzle ORM
|
|
98
|
+
|
|
99
|
+
Drizzle ORM is a type-safe ORM for TypeScript, bundled inside Alepha.
|
|
100
|
+
|
|
101
|
+
Drizzle Kit CLI is required as dev dependencies:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install -D drizzle-kit
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// app.ts
|
|
109
|
+
import { $hook, run, t } from "alepha";
|
|
110
|
+
import { $entity, $repository, pg } from "alepha/postgres";
|
|
111
|
+
import { $logger } from "alepha/logger";
|
|
112
|
+
|
|
113
|
+
export const users = $entity({
|
|
114
|
+
name: "users",
|
|
115
|
+
schema: t.object({
|
|
116
|
+
id: pg.primaryKey(),
|
|
117
|
+
name: t.string(),
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class Db {
|
|
123
|
+
log = $logger();
|
|
124
|
+
users = $repository(users);
|
|
125
|
+
|
|
126
|
+
ready = $hook({
|
|
127
|
+
on: "ready",
|
|
128
|
+
handler: async () => {
|
|
129
|
+
await this.users.create({
|
|
130
|
+
name: "John Doe",
|
|
131
|
+
})
|
|
132
|
+
this.log.info("Users:", await this.users.find())
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
run(Db)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
node app.ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### React SSR Page
|
|
145
|
+
|
|
146
|
+
Alepha has built-in React **CSR** & **SSR** support.
|
|
147
|
+
|
|
148
|
+
[React](https://react.dev) is required as a `dependency`:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm install react react-dom
|
|
152
|
+
npm install -D @types/react
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
// app.tsx
|
|
157
|
+
import { run, t } from "alepha";
|
|
158
|
+
import { $page } from "alepha/react";
|
|
159
|
+
import { useState } from "react";
|
|
160
|
+
|
|
161
|
+
const Hello = (props: { start: number }) => {
|
|
162
|
+
const [ count, setCount ] = useState(props.start);
|
|
163
|
+
return <button onClick={() => setCount(count + 1)}>Clicked: {count}</button>
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class HomePage {
|
|
167
|
+
index = $page({
|
|
168
|
+
schema: {
|
|
169
|
+
query: t.object({
|
|
170
|
+
s: t.number({ default: 0 }),
|
|
171
|
+
})
|
|
172
|
+
},
|
|
173
|
+
component: Hello,
|
|
174
|
+
resolve: (req) => {
|
|
175
|
+
return { start: req.query.s };
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
run(HomePage);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
[Vite](https://vite.dev) is required as a `devDependencies`:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm install -D vite
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
// vite.config.ts
|
|
191
|
+
import { viteAlepha } from "alepha/vite";
|
|
192
|
+
import { defineConfig } from "vite";
|
|
193
|
+
|
|
194
|
+
export default defineConfig({
|
|
195
|
+
plugins: [
|
|
196
|
+
viteAlepha()
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<!-- index.html -->
|
|
203
|
+
<!DOCTYPE html>
|
|
204
|
+
<html lang="en">
|
|
205
|
+
<head>
|
|
206
|
+
<meta charset="UTF-8">
|
|
207
|
+
<title>App</title>
|
|
208
|
+
</head>
|
|
209
|
+
<body>
|
|
210
|
+
<script type="module" src="app.tsx"></script>
|
|
211
|
+
</body>
|
|
212
|
+
</html>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
npx vite
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Core Concepts
|
|
220
|
+
|
|
221
|
+
- **Descriptors**: Define your app logic with `$action`, `$page`, `$repository`, `$cache`, `$email`, etc.
|
|
222
|
+
- **Type Safety**: TypeBox schemas validate data from DB to API to frontend
|
|
223
|
+
- **DI Container**: Built-in dependency injection using `$inject()`
|
|
224
|
+
- **Convention over Config**: Minimal boilerplate, sensible defaults
|
|
225
|
+
- **Full-Stack**: React SSR, Vite, class-based router with type-safe routing
|
|
226
|
+
|
|
227
|
+
Plenty of other features are available, please check the [documentation](https://feunard.github.io/alepha/).
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT
|
package/batch.d.ts
CHANGED
|
@@ -533,7 +533,7 @@ declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends De
|
|
|
533
533
|
protected readonly dateTime: DateTimeProvider;
|
|
534
534
|
protected readonly partitions: Map<any, any>;
|
|
535
535
|
protected activeHandlers: PromiseWithResolvers<void>[];
|
|
536
|
-
protected retry: _alepha_retry0.RetryDescriptorFn<(items: typebox0.StaticType<"Encode", {}, {}, TItem>[]) => TResponse>;
|
|
536
|
+
protected retry: _alepha_retry0.RetryDescriptorFn<(items: typebox0.StaticType<[], "Encode", {}, {}, TItem>[]) => TResponse>;
|
|
537
537
|
/**
|
|
538
538
|
* Pushes an item into the batch. The item will be processed
|
|
539
539
|
* asynchronously with other items when the batch is flushed.
|
|
@@ -579,7 +579,7 @@ declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends De
|
|
|
579
579
|
* @see {@link $batch}
|
|
580
580
|
* @module alepha.batch
|
|
581
581
|
*/
|
|
582
|
-
declare const AlephaBatch: _alepha_core1.Service<_alepha_core1.Module
|
|
582
|
+
declare const AlephaBatch: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
583
583
|
//#endregion
|
|
584
584
|
export { $batch, AlephaBatch, BatchDescriptor, BatchDescriptorOptions };
|
|
585
585
|
//# sourceMappingURL=index.d.ts.map
|
package/bucket.d.ts
CHANGED
|
@@ -618,7 +618,7 @@ declare module "alepha" {
|
|
|
618
618
|
* @see {@link FileStorageProvider}
|
|
619
619
|
* @module alepha.bucket
|
|
620
620
|
*/
|
|
621
|
-
declare const AlephaBucket: _alepha_core1.Service<_alepha_core1.Module
|
|
621
|
+
declare const AlephaBucket: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
622
622
|
//#endregion
|
|
623
623
|
export { $bucket, AlephaBucket, BucketDescriptor, BucketDescriptorOptions, BucketFileOptions, FileNotFoundError, FileStorageProvider, LocalFileStorageProvider, MemoryFileStorageProvider, fileMetadataSchema };
|
|
624
624
|
//# sourceMappingURL=index.d.ts.map
|
package/cache/redis.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare class RedisCacheProvider implements CacheProvider {
|
|
|
33
33
|
* @see {@link RedisCacheProvider}
|
|
34
34
|
* @module alepha.cache.redis
|
|
35
35
|
*/
|
|
36
|
-
declare const AlephaCacheRedis: _alepha_core1.Service<_alepha_core1.Module
|
|
36
|
+
declare const AlephaCacheRedis: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
37
37
|
//#endregion
|
|
38
38
|
export { AlephaCacheRedis, RedisCacheProvider };
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
package/cache.d.ts
CHANGED
|
@@ -277,7 +277,7 @@ declare class MemoryCacheProvider implements CacheProvider {
|
|
|
277
277
|
* @see {@link CacheProvider}
|
|
278
278
|
* @module alepha.cache
|
|
279
279
|
*/
|
|
280
|
-
declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module
|
|
280
|
+
declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module<{}>>;
|
|
281
281
|
//#endregion
|
|
282
282
|
export { $cache, AlephaCache, CacheDescriptor, CacheDescriptorFn, CacheDescriptorOptions, CacheProvider, MemoryCacheProvider };
|
|
283
283
|
//# sourceMappingURL=index.d.ts.map
|
package/command.d.ts
CHANGED
|
@@ -1,10 +1,51 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
|
-
import { Alepha, AlephaError, Async, Descriptor, KIND, Static, TObject, TSchema } from "alepha";
|
|
2
|
+
import { Alepha, AlephaError, Async, Descriptor, KIND, Static, TObject, TSchema, TString } from "alepha";
|
|
3
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
3
4
|
import * as fs from "node:fs/promises";
|
|
4
5
|
import { glob } from "node:fs/promises";
|
|
5
|
-
import * as
|
|
6
|
+
import * as readline_promises0 from "readline/promises";
|
|
6
7
|
import * as typebox0 from "typebox";
|
|
7
8
|
|
|
9
|
+
//#region src/helpers/Asker.d.ts
|
|
10
|
+
interface AskOptions<T extends TSchema = TString> {
|
|
11
|
+
/**
|
|
12
|
+
* Response schema expected.
|
|
13
|
+
*
|
|
14
|
+
* Recommended schemas:
|
|
15
|
+
* - t.string() - for free text input
|
|
16
|
+
* - t.number() - for numeric input
|
|
17
|
+
* - t.boolean() - for yes/no input (accepts "true", "false", "1", "0")
|
|
18
|
+
* - t.enum(["option1", "option2"]) - for predefined options
|
|
19
|
+
*
|
|
20
|
+
* You can use schema.default to provide a default value.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* ask("What is your name?", { schema: t.string({ default: "John Doe" }) })
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @default TString
|
|
28
|
+
*/
|
|
29
|
+
schema?: T;
|
|
30
|
+
/**
|
|
31
|
+
* Custom validation function.
|
|
32
|
+
* Throws an AlephaError in case of validation failure.
|
|
33
|
+
*/
|
|
34
|
+
validate?: (value: Static<T>) => void;
|
|
35
|
+
}
|
|
36
|
+
interface AskMethod {
|
|
37
|
+
<T extends TSchema = TString>(question: string, options?: AskOptions<T>): Promise<Static<T>>;
|
|
38
|
+
}
|
|
39
|
+
declare class Asker {
|
|
40
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
41
|
+
readonly ask: AskMethod;
|
|
42
|
+
protected readonly alepha: Alepha;
|
|
43
|
+
constructor();
|
|
44
|
+
protected createAskMethod(): AskMethod;
|
|
45
|
+
protected prompt<T extends TSchema = TString>(question: string, options: AskOptions<T>): Promise<Static<T>>;
|
|
46
|
+
protected createPromptInterface(): readline_promises0.Interface;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
8
49
|
//#region src/helpers/Runner.d.ts
|
|
9
50
|
type Task = {
|
|
10
51
|
name: string;
|
|
@@ -19,13 +60,9 @@ interface RunOptions {
|
|
|
19
60
|
* Rename the command for logging purposes.
|
|
20
61
|
*/
|
|
21
62
|
alias?: string;
|
|
22
|
-
/**
|
|
23
|
-
* If true, the command will not be logged.
|
|
24
|
-
*/
|
|
25
|
-
silent?: boolean;
|
|
26
63
|
}
|
|
27
64
|
interface RunnerMethod {
|
|
28
|
-
(cmd: string | Array<string | Task>,
|
|
65
|
+
(cmd: string | Task | Array<string | Task>, options?: RunOptions | (() => any)): Promise<string>;
|
|
29
66
|
rm: (glob: string | string[], options?: RunOptions) => Promise<string>;
|
|
30
67
|
cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
|
|
31
68
|
}
|
|
@@ -116,6 +153,7 @@ interface CommandHandlerArgs<T extends TObject, A extends TSchema = TSchema> {
|
|
|
116
153
|
flags: Static<T>;
|
|
117
154
|
args: A extends TSchema ? Static<A> : undefined;
|
|
118
155
|
run: RunnerMethod;
|
|
156
|
+
ask: AskMethod;
|
|
119
157
|
glob: typeof glob;
|
|
120
158
|
fs: typeof fs;
|
|
121
159
|
}
|
|
@@ -141,6 +179,7 @@ declare class CliProvider {
|
|
|
141
179
|
protected readonly alepha: Alepha;
|
|
142
180
|
protected readonly log: _alepha_logger0.Logger;
|
|
143
181
|
protected readonly runner: Runner;
|
|
182
|
+
protected readonly asker: Asker;
|
|
144
183
|
options: {
|
|
145
184
|
name: string;
|
|
146
185
|
description: string;
|
|
@@ -181,7 +220,7 @@ declare class CliProvider {
|
|
|
181
220
|
* @see {@link $command}
|
|
182
221
|
* @module alepha.command
|
|
183
222
|
*/
|
|
184
|
-
declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module
|
|
223
|
+
declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
185
224
|
declare module "typebox" {
|
|
186
225
|
interface StringOptions {
|
|
187
226
|
/**
|
|
@@ -195,5 +234,5 @@ declare module "typebox" {
|
|
|
195
234
|
//# sourceMappingURL=index.d.ts.map
|
|
196
235
|
|
|
197
236
|
//#endregion
|
|
198
|
-
export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
|
|
237
|
+
export { $command, AlephaCommand, AskMethod, AskOptions, Asker, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
|
|
199
238
|
//# sourceMappingURL=index.d.ts.map
|
package/core.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
2
2
|
import { Validator } from "typebox/compile";
|
|
3
3
|
import * as TypeBox from "typebox";
|
|
4
4
|
import { Static, Static as Static$1, StaticDecode, StaticEncode, TAny, TAny as TAny$1, TArray, TArray as TArray$1, TArrayOptions, TBigInt, TBoolean, TBoolean as TBoolean$1, TInteger, TInteger as TInteger$1, TKeysToIndexer, TNull, TNull as TNull$1, TNumber, TNumber as TNumber$1, TNumberOptions, TNumberOptions as TNumberOptions$1, TObject, TObject as TObject$1, TObjectOptions, TObjectOptions as TObjectOptions$1, TOptional, TOptionalAdd, TOptionalAdd as TOptionalAdd$1, TPick, TProperties, TProperties as TProperties$1, TRecord, TRecord as TRecord$1, TSchema, TSchema as TSchema$1, TSchemaOptions, TString, TString as TString$1, TStringOptions, TStringOptions as TStringOptions$1, TTuple, TUnion, TUnion as TUnion$1, TUnsafe, TVoid } from "typebox";
|
|
5
|
-
import
|
|
5
|
+
import TypeBoxFormat from "typebox/format";
|
|
6
6
|
import * as TypeBoxValue from "typebox/value";
|
|
7
7
|
import { Readable } from "node:stream";
|
|
8
8
|
import { ReadableStream as ReadableStream$1 } from "node:stream/web";
|
|
@@ -189,8 +189,8 @@ interface InjectOptions<T extends object = any> {
|
|
|
189
189
|
* Modules are more useful when the application grows and needs to be structured.
|
|
190
190
|
* If we speak with `$actions`, a module should be used when you have more than 30 actions in a single module.
|
|
191
191
|
*/
|
|
192
|
-
declare const $module: (options: ModuleDescriptorOptions) => Service<Module
|
|
193
|
-
interface ModuleDescriptorOptions {
|
|
192
|
+
declare const $module: <T extends object = {}>(options: ModuleDescriptorOptions<T>) => Service<Module<T>>;
|
|
193
|
+
interface ModuleDescriptorOptions<T extends object> {
|
|
194
194
|
/**
|
|
195
195
|
* Name of the module.
|
|
196
196
|
*
|
|
@@ -210,15 +210,16 @@ interface ModuleDescriptorOptions {
|
|
|
210
210
|
* You can override this behavior by providing a register function.
|
|
211
211
|
* It's useful when you want to register services conditionally or in a specific order.
|
|
212
212
|
*/
|
|
213
|
-
register?: (alepha: Alepha) => void;
|
|
213
|
+
register?: (alepha: Alepha, options: T) => void;
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
216
|
* Base class for all modules.
|
|
217
217
|
*/
|
|
218
|
-
declare abstract class Module {
|
|
219
|
-
abstract readonly
|
|
218
|
+
declare abstract class Module<T extends object = {}> {
|
|
219
|
+
abstract readonly config: ModuleDescriptorOptions<T>;
|
|
220
220
|
abstract register(alepha: Alepha): void;
|
|
221
221
|
static NAME_REGEX: RegExp;
|
|
222
|
+
options: T;
|
|
222
223
|
/**
|
|
223
224
|
* Check if a Service is a Module.
|
|
224
225
|
*/
|
|
@@ -404,6 +405,11 @@ type StreamLike = ReadableStream | ReadableStream$1 | Readable | NodeJS.Readable
|
|
|
404
405
|
type TStream = TUnsafe<StreamLike>;
|
|
405
406
|
//#endregion
|
|
406
407
|
//#region src/providers/TypeProvider.d.ts
|
|
408
|
+
declare const isUUID: typeof TypeBoxFormat.IsUuid;
|
|
409
|
+
declare const isDateTime: typeof TypeBoxFormat.IsDateTime;
|
|
410
|
+
declare const isDate: typeof TypeBoxFormat.IsDate;
|
|
411
|
+
declare const isEmail: typeof TypeBoxFormat.IsEmail;
|
|
412
|
+
declare const isURL: typeof TypeBoxFormat.IsUrl;
|
|
407
413
|
declare class TypeGuard {
|
|
408
414
|
isSchema: typeof TypeBox.IsSchema;
|
|
409
415
|
isObject: typeof TypeBox.IsObject;
|
|
@@ -438,7 +444,7 @@ declare module "typebox" {
|
|
|
438
444
|
}
|
|
439
445
|
}
|
|
440
446
|
declare class TypeProvider {
|
|
441
|
-
static format: typeof
|
|
447
|
+
static format: typeof TypeBoxFormat;
|
|
442
448
|
static isValidBigInt(value: string | number): boolean;
|
|
443
449
|
/**
|
|
444
450
|
* Default maximum length for strings.
|
|
@@ -976,11 +982,14 @@ declare class Alepha {
|
|
|
976
982
|
* > If you are interested in configuring a service, use Alepha#configure() instead.
|
|
977
983
|
*
|
|
978
984
|
* @param serviceEntry - The service to register in the container.
|
|
985
|
+
* @param configure - Optional configuration object to merge with the service's options.
|
|
979
986
|
* @return Current instance of Alepha.
|
|
980
987
|
*/
|
|
981
|
-
with<T extends
|
|
988
|
+
with<T extends {
|
|
989
|
+
options?: object;
|
|
990
|
+
} & object>(serviceEntry: ServiceEntry<T> | {
|
|
982
991
|
default: ServiceEntry<T>;
|
|
983
|
-
}): this;
|
|
992
|
+
}, configure?: Partial<T["options"]>): this;
|
|
984
993
|
/**
|
|
985
994
|
* Get an instance of the specified service from the container.
|
|
986
995
|
*
|
|
@@ -1005,7 +1014,7 @@ declare class Alepha {
|
|
|
1005
1014
|
* ```
|
|
1006
1015
|
*/
|
|
1007
1016
|
configure<T extends {
|
|
1008
|
-
options
|
|
1017
|
+
options?: object;
|
|
1009
1018
|
}>(service: Service<T>, state: Partial<T["options"]>): this;
|
|
1010
1019
|
/**
|
|
1011
1020
|
* Casts the given value to the specified schema.
|
|
@@ -1390,5 +1399,5 @@ declare global {
|
|
|
1390
1399
|
*/
|
|
1391
1400
|
declare const run: (entry: Alepha | Service | Array<Service>, opts?: RunOptions) => void;
|
|
1392
1401
|
//#endregion
|
|
1393
|
-
export { $cursor, $env, $hook, $inject, $module, AbstractClass, Alepha, AlephaError, AlephaStringOptions, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, Service, ServiceEntry, ServiceSubstitution, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, type TTuple, type TUnion, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxValue, TypeGuard, TypeProvider, WithModule, __alephaRef, createDescriptor, isFileLike, isTypeFile, run, t };
|
|
1402
|
+
export { $cursor, $env, $hook, $inject, $module, AbstractClass, Alepha, AlephaError, AlephaStringOptions, AlsProvider, AppNotStartedError, Async, AsyncFn, AsyncLocalStorageData, CircularDependencyError, ContainerLockedError, CursorDescriptor, Descriptor, DescriptorArgs, DescriptorConfig, DescriptorFactory, DescriptorFactoryLike, Env, FileLike, Hook, HookDescriptor, HookOptions, Hooks, InjectDescriptor, InjectOptions, InstantiableClass, KIND, LogLevel, LoggerInterface, MaybePromise, Module, ModuleDescriptorOptions, OPTIONS, Service, ServiceEntry, ServiceSubstitution, State, StateManager, type Static, type StaticDecode, type StaticEncode, StreamLike, type TAny, type TArray, type TBigInt, type TBoolean, TFile, type TInteger, type TKeysToIndexer, type TNull, type TNumber, type TNumberOptions, type TObject, type TObjectOptions, type TOptional, type TOptionalAdd, type TPick, type TProperties, type TRecord, type TSchema, TStream, type TString, type TStringOptions, type TTuple, type TUnion, type TVoid, TextLength, TooLateSubstitutionError, TypeBox, TypeBoxError, TypeBoxFormat, TypeBoxValue, TypeGuard, TypeProvider, WithModule, __alephaRef, createDescriptor, isDate, isDateTime, isEmail, isFileLike, isTypeFile, isURL, isUUID, run, t };
|
|
1394
1403
|
//# sourceMappingURL=index.d.ts.map
|
package/datetime.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import { Alepha, Descriptor, KIND } from "alepha";
|
|
3
|
+
import "dayjs/plugin/relativeTime.js";
|
|
4
|
+
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
3
5
|
import * as _alepha_logger0 from "alepha/logger";
|
|
4
6
|
import dayjs, { Dayjs, ManipulateType } from "dayjs";
|
|
5
|
-
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
6
7
|
|
|
7
8
|
//#region src/providers/DateTimeProvider.d.ts
|
|
8
9
|
type DateTimeApi = typeof dayjs;
|
|
@@ -131,7 +132,7 @@ declare class IntervalDescriptor extends Descriptor<IntervalDescriptorOptions> {
|
|
|
131
132
|
}
|
|
132
133
|
//#endregion
|
|
133
134
|
//#region src/index.d.ts
|
|
134
|
-
declare const AlephaDateTime: _alepha_core1.Service<_alepha_core1.Module
|
|
135
|
+
declare const AlephaDateTime: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
135
136
|
//#endregion
|
|
136
137
|
export { $interval, AlephaDateTime, DateTime, DateTimeApi, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptor, IntervalDescriptorOptions, Timeout };
|
|
137
138
|
//# sourceMappingURL=index.d.ts.map
|
package/email.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _alepha_core1 from "alepha";
|
|
2
2
|
import { Descriptor, KIND, Service, Static, TSchema } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_logger0 from "alepha/logger";
|
|
4
4
|
import { Transporter } from "nodemailer";
|
|
5
5
|
|
|
6
6
|
//#region src/providers/EmailProvider.d.ts
|
|
@@ -30,7 +30,7 @@ interface EmailRecord {
|
|
|
30
30
|
sentAt: Date;
|
|
31
31
|
}
|
|
32
32
|
declare class MemoryEmailProvider implements EmailProvider {
|
|
33
|
-
protected readonly log:
|
|
33
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
34
34
|
protected emails: EmailRecord[];
|
|
35
35
|
send(to: string, subject: string, body: string): Promise<void>;
|
|
36
36
|
/**
|
|
@@ -224,7 +224,7 @@ interface EmailDescriptorOptions<T extends TSchema> {
|
|
|
224
224
|
provider?: Service<EmailProvider> | "memory";
|
|
225
225
|
}
|
|
226
226
|
declare class EmailDescriptor<T extends TSchema> extends Descriptor<EmailDescriptorOptions<T>> {
|
|
227
|
-
protected readonly log:
|
|
227
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
228
228
|
protected readonly templateService: TemplateService;
|
|
229
229
|
readonly provider: EmailProvider | MemoryEmailProvider;
|
|
230
230
|
get name(): string;
|
|
@@ -252,7 +252,7 @@ interface LocalEmailProviderOptions {
|
|
|
252
252
|
directory?: string;
|
|
253
253
|
}
|
|
254
254
|
declare class LocalEmailProvider implements EmailProvider {
|
|
255
|
-
protected readonly log:
|
|
255
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
256
256
|
protected readonly directory: string;
|
|
257
257
|
constructor(options?: LocalEmailProviderOptions);
|
|
258
258
|
send(to: string, subject: string, body: string): Promise<void>;
|
|
@@ -292,7 +292,7 @@ declare class NodemailerEmailProvider implements EmailProvider {
|
|
|
292
292
|
EMAIL_FROM: string;
|
|
293
293
|
EMAIL_SECURE: boolean;
|
|
294
294
|
};
|
|
295
|
-
protected readonly log:
|
|
295
|
+
protected readonly log: _alepha_logger0.Logger;
|
|
296
296
|
protected transporter: Transporter;
|
|
297
297
|
protected fromAddress: string;
|
|
298
298
|
readonly options: NodemailerEmailProviderOptions;
|
|
@@ -322,7 +322,7 @@ declare class NodemailerEmailProvider implements EmailProvider {
|
|
|
322
322
|
* @see {@link EmailProvider}
|
|
323
323
|
* @module alepha.email
|
|
324
324
|
*/
|
|
325
|
-
declare const AlephaEmail: _alepha_core1.Service<_alepha_core1.Module
|
|
325
|
+
declare const AlephaEmail: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
326
326
|
//#endregion
|
|
327
327
|
export { $email, AlephaEmail, EmailDescriptor, EmailDescriptorOptions, EmailError, EmailProvider, EmailRecord, LocalEmailProvider, LocalEmailProviderOptions, MemoryEmailProvider, NodemailerEmailProvider, NodemailerEmailProviderOptions, TemplateService };
|
|
328
328
|
//# sourceMappingURL=index.d.ts.map
|
package/lock/redis.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare class RedisLockProvider implements LockProvider {
|
|
|
18
18
|
* @see {@link RedisLockProvider}
|
|
19
19
|
* @module alepha.lock.redis
|
|
20
20
|
*/
|
|
21
|
-
declare const AlephaLockRedis: _alepha_core0.Service<_alepha_core0.Module
|
|
21
|
+
declare const AlephaLockRedis: _alepha_core0.Service<_alepha_core0.Module<{}>>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { AlephaLockRedis, RedisLockProvider };
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/lock.d.ts
CHANGED
|
@@ -546,7 +546,7 @@ declare class MemoryLockProvider implements LockProvider {
|
|
|
546
546
|
* @see {@link $lock}
|
|
547
547
|
* @module alepha.lock
|
|
548
548
|
*/
|
|
549
|
-
declare const AlephaLock: _alepha_core1.Service<_alepha_core1.Module
|
|
549
|
+
declare const AlephaLock: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
550
550
|
//#endregion
|
|
551
551
|
export { $lock, AlephaLock, LockDescriptor, LockDescriptorOptions, LockProvider, LockResult, LockTopicProvider, MemoryLockProvider };
|
|
552
552
|
//# sourceMappingURL=index.d.ts.map
|
package/logger.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ declare class SimpleFormatterProvider extends LogFormatterProvider {
|
|
|
215
215
|
* - Empty parts are gracefully skipped: `LOG_LEVEL=",,debug,,"` works fine
|
|
216
216
|
* - Better error messages: "Invalid log level 'bad' for module pattern 'alepha'"
|
|
217
217
|
*/
|
|
218
|
-
declare const AlephaLogger: _alepha_core0.Service<_alepha_core0.Module
|
|
218
|
+
declare const AlephaLogger: _alepha_core0.Service<_alepha_core0.Module<{}>>;
|
|
219
219
|
declare const envSchema: _alepha_core0.TObject<{
|
|
220
220
|
/**
|
|
221
221
|
* Default log level for the application.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alepha",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -15,51 +15,51 @@
|
|
|
15
15
|
"main": "./core.js",
|
|
16
16
|
"types": "./core.d.ts",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alepha/batch": "0.10.
|
|
19
|
-
"@alepha/bucket": "0.10.
|
|
20
|
-
"@alepha/cache": "0.10.
|
|
21
|
-
"@alepha/cache-redis": "0.10.
|
|
22
|
-
"@alepha/command": "0.10.
|
|
23
|
-
"@alepha/core": "0.10.
|
|
24
|
-
"@alepha/datetime": "0.10.
|
|
25
|
-
"@alepha/email": "0.10.
|
|
26
|
-
"@alepha/file": "0.10.
|
|
27
|
-
"@alepha/lock": "0.10.
|
|
28
|
-
"@alepha/lock-redis": "0.10.
|
|
29
|
-
"@alepha/logger": "0.10.
|
|
30
|
-
"@alepha/postgres": "0.10.
|
|
31
|
-
"@alepha/queue": "0.10.
|
|
32
|
-
"@alepha/queue-redis": "0.10.
|
|
33
|
-
"@alepha/react": "0.10.
|
|
34
|
-
"@alepha/react-auth": "0.10.
|
|
35
|
-
"@alepha/react-form": "0.10.
|
|
36
|
-
"@alepha/react-head": "0.10.
|
|
37
|
-
"@alepha/react-i18n": "0.10.
|
|
38
|
-
"@alepha/redis": "0.10.
|
|
39
|
-
"@alepha/retry": "0.10.
|
|
40
|
-
"@alepha/router": "0.10.
|
|
41
|
-
"@alepha/scheduler": "0.10.
|
|
42
|
-
"@alepha/security": "0.10.
|
|
43
|
-
"@alepha/server": "0.10.
|
|
44
|
-
"@alepha/server-cache": "0.10.
|
|
45
|
-
"@alepha/server-compress": "0.10.
|
|
46
|
-
"@alepha/server-cookies": "0.10.
|
|
47
|
-
"@alepha/server-cors": "0.10.
|
|
48
|
-
"@alepha/server-health": "0.10.
|
|
49
|
-
"@alepha/server-helmet": "0.10.
|
|
50
|
-
"@alepha/server-links": "0.10.
|
|
51
|
-
"@alepha/server-metrics": "0.10.
|
|
52
|
-
"@alepha/server-multipart": "0.10.
|
|
53
|
-
"@alepha/server-proxy": "0.10.
|
|
54
|
-
"@alepha/server-security": "0.10.
|
|
55
|
-
"@alepha/server-static": "0.10.
|
|
56
|
-
"@alepha/server-swagger": "0.10.
|
|
57
|
-
"@alepha/topic": "0.10.
|
|
58
|
-
"@alepha/topic-redis": "0.10.
|
|
59
|
-
"@alepha/vite": "0.10.
|
|
18
|
+
"@alepha/batch": "0.10.2",
|
|
19
|
+
"@alepha/bucket": "0.10.2",
|
|
20
|
+
"@alepha/cache": "0.10.2",
|
|
21
|
+
"@alepha/cache-redis": "0.10.2",
|
|
22
|
+
"@alepha/command": "0.10.2",
|
|
23
|
+
"@alepha/core": "0.10.2",
|
|
24
|
+
"@alepha/datetime": "0.10.2",
|
|
25
|
+
"@alepha/email": "0.10.2",
|
|
26
|
+
"@alepha/file": "0.10.2",
|
|
27
|
+
"@alepha/lock": "0.10.2",
|
|
28
|
+
"@alepha/lock-redis": "0.10.2",
|
|
29
|
+
"@alepha/logger": "0.10.2",
|
|
30
|
+
"@alepha/postgres": "0.10.2",
|
|
31
|
+
"@alepha/queue": "0.10.2",
|
|
32
|
+
"@alepha/queue-redis": "0.10.2",
|
|
33
|
+
"@alepha/react": "0.10.2",
|
|
34
|
+
"@alepha/react-auth": "0.10.2",
|
|
35
|
+
"@alepha/react-form": "0.10.2",
|
|
36
|
+
"@alepha/react-head": "0.10.2",
|
|
37
|
+
"@alepha/react-i18n": "0.10.2",
|
|
38
|
+
"@alepha/redis": "0.10.2",
|
|
39
|
+
"@alepha/retry": "0.10.2",
|
|
40
|
+
"@alepha/router": "0.10.2",
|
|
41
|
+
"@alepha/scheduler": "0.10.2",
|
|
42
|
+
"@alepha/security": "0.10.2",
|
|
43
|
+
"@alepha/server": "0.10.2",
|
|
44
|
+
"@alepha/server-cache": "0.10.2",
|
|
45
|
+
"@alepha/server-compress": "0.10.2",
|
|
46
|
+
"@alepha/server-cookies": "0.10.2",
|
|
47
|
+
"@alepha/server-cors": "0.10.2",
|
|
48
|
+
"@alepha/server-health": "0.10.2",
|
|
49
|
+
"@alepha/server-helmet": "0.10.2",
|
|
50
|
+
"@alepha/server-links": "0.10.2",
|
|
51
|
+
"@alepha/server-metrics": "0.10.2",
|
|
52
|
+
"@alepha/server-multipart": "0.10.2",
|
|
53
|
+
"@alepha/server-proxy": "0.10.2",
|
|
54
|
+
"@alepha/server-security": "0.10.2",
|
|
55
|
+
"@alepha/server-static": "0.10.2",
|
|
56
|
+
"@alepha/server-swagger": "0.10.2",
|
|
57
|
+
"@alepha/topic": "0.10.2",
|
|
58
|
+
"@alepha/topic-redis": "0.10.2",
|
|
59
|
+
"@alepha/vite": "0.10.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"tsdown": "^0.15.
|
|
62
|
+
"tsdown": "^0.15.6"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "node build.ts"
|