alepha 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,3 +45,49 @@ run(App);
45
45
  ```
46
46
 
47
47
  👉 For more information, please visit the [documentation](https://feunard.github.io/alepha/).
48
+
49
+ ## Modules
50
+
51
+ Alepha is modular, with a LOT of modules.
52
+
53
+ ### Core & Application Layer
54
+
55
+ * **Core ([@alepha/core](https://feunard.github.io/alepha/docs/alepha-core)) 📦:** The heart of the framework, providing a powerful dependency injection container, application lifecycle management, and the core descriptor system.
56
+ * **Server ([@alepha/server](https://feunard.github.io/alepha/docs/alepha-server)) 🌐:** A high-performance, minimalist HTTP server for creating type-safe REST APIs using declarative `$action` descriptors.
57
+ * **Database ([@alepha/postgres](https://feunard.github.io/alepha/docs/alepha-postgres)) 🗄️:** A powerful and type-safe ORM built on Drizzle. Define your schema with `$entity` and get fully-typed repositories with `$repository`.
58
+ * **React ([@alepha/react](https://feunard.github.io/alepha/docs/alepha-react)) ⚛️:** Build full-stack, server-side rendered React applications with a file-based routing system (`$page`) that handles data fetching, hydration, and type-safe props.
59
+
60
+ ### Backend Infrastructure & Abstractions
61
+
62
+ * **Security ([@alepha/security](https://feunard.github.io/alepha/docs/alepha-security)) 🛡️:** A complete authentication and authorization system. Manage roles (`$role`), permissions (`$permission`), JWTs, and realms (`$realm`).
63
+ * **Queue ([@alepha/queue](https://feunard.github.io/alepha/docs/alepha-queue)) ⏳:** A simple and robust interface for background job processing. Define workers with the `$queue` descriptor and integrate with backends like Redis.
64
+ * **Cache ([@alepha/cache](https://feunard.github.io/alepha/docs/alepha-cache)) ⚡:** A flexible caching layer with support for TTL, automatic function caching (`$cache`), and multiple backends like in-memory or Redis.
65
+ * **Bucket ([@alepha/bucket](https://feunard.github.io/alepha/docs/alepha-bucket)) ☁️:** A unified API for file and object storage. Abstract away the details of local, in-memory, or cloud storage providers like Azure Blob Storage.
66
+ * **Scheduler ([@alepha/scheduler](https://feunard.github.io/alepha/docs/alepha-scheduler)) ⏰:** Schedule recurring tasks using cron expressions or fixed intervals with the `$scheduler` descriptor, with built-in support for distributed locking.
67
+ * **Topic ([@alepha/topic](https://feunard.github.io/alepha/docs/alepha-topic)) 📢:** A publish-subscribe (pub/sub) messaging interface for building event-driven architectures with `$topic` and `$subscriber`.
68
+ * **Lock ([@alepha/lock](https://feunard.github.io/alepha/docs/alepha-lock)) 🔒:** A distributed locking mechanism to ensure safe concurrent access to shared resources, using Redis or other backends.
69
+
70
+ ### Server Middleware & Plugins
71
+
72
+ * **Links ([@alepha/server-links](https://feunard.github.io/alepha/docs/alepha-server-links)) 🔗:** Enables end-to-end type-safe communication between your frontend and backend, or between microservices, with the `$client` descriptor.
73
+ * **Swagger ([@alepha/server-swagger](https://feunard.github.io/alepha/docs/alepha-server-swagger)) 📜:** Automatically generate OpenAPI 3.0 documentation and a beautiful Swagger UI for all your `$action` API endpoints.
74
+ * **Helmet ([@alepha/server-helmet](https://feunard.github.io/alepha/docs/alepha-server-helmet)) 🎩:** Enhance your application's security by automatically applying essential HTTP security headers like CSP and HSTS.
75
+ * **CORS ([@alepha/server-cors](https://feunard.github.io/alepha/docs/alepha-server-cors)) ↔️:** A configurable middleware to handle Cross-Origin Resource Sharing (CORS) for your server.
76
+ * **Multipart ([@alepha/server-multipart](https://feunard.github.io/alepha/docs/alepha-server-multipart)) 📎:** Seamlessly handle `multipart/form-data` requests for file uploads.
77
+ * **Compress ([@alepha/server-compress](https://feunard.github.io/alepha/docs/alepha-server-compress)) 📦💨:** Automatically compress server responses with Gzip or Brotli to improve performance.
78
+
79
+ And more, like **Request Logging**, **Error Handling**, and **Response Caching**, cookie parsers, and more, to enhance your server's capabilities.
80
+
81
+ ### Full-Stack & React Ecosystem
82
+
83
+ * **Auth ([@alepha/react-auth](https://feunard.github.io/alepha/docs/alepha-react-auth)) 🔑:** Simplifies frontend authentication flows, providing the `useAuth` hook to manage user sessions and permissions in your React components.
84
+ * **Head ([@alepha/react-head](https://feunard.github.io/alepha/docs/alepha-react-head)) SEO:** Manage your document's `<head>` for SEO and metadata. Control titles, meta tags, and more, both on the server and client.
85
+ * **i18n ([@alepha/react-i18n](https://feunard.github.io/alepha/docs/alepha-react-i18n)) 🌍:** A complete internationalization solution for your React applications, with support for lazy-loaded translation files and the `useI18n` hook.
86
+ * **Form ([@alepha/react-form](https://feunard.github.io/alepha/docs/alepha-react-form)) 📝:** Create powerful, type-safe forms with automatic validation using the `useForm` hook, powered by your TypeBox schemas.
87
+
88
+ ### Tooling & Utilities
89
+
90
+ * **Vite ([@alepha/vite](https://feunard.github.io/alepha/docs/alepha-vite)) ✨:** A seamless Vite plugin that handles all the complex build and development server configurations for your full-stack Alepha applications.
91
+ * **Command ([@alepha/command](https://feunard.github.io/alepha/docs/alepha-command)) ⌨️:** Build powerful, type-safe command-line interfaces and scripts directly within your application using the `$command` descriptor.
92
+ * **Retry ([@alepha/retry](https://feunard.github.io/alepha/docs/alepha-retry)) 🔄:** A declarative and powerful decorator (`$retry`) for automatically retrying failed operations with exponential backoff.
93
+
package/batch.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _alepha_core1 from "alepha";
2
- import * as _alepha_core0 from "alepha";
3
2
  import { Descriptor, KIND, Static, TSchema } from "alepha";
4
3
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
4
+ import * as _alepha_logger0 from "alepha/logger";
5
5
  import * as _alepha_retry0 from "alepha/retry";
6
6
  import { RetryDescriptorOptions } from "alepha/retry";
7
7
 
@@ -52,7 +52,7 @@ interface BatchDescriptorOptions<TItem extends TSchema, TResponse = any> {
52
52
  retry?: Omit<RetryDescriptorOptions<() => Array<Static<TItem>>>, "handler">;
53
53
  }
54
54
  declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends Descriptor<BatchDescriptorOptions<TItem, TResponse>> {
55
- protected readonly log: _alepha_core1.Logger;
55
+ protected readonly log: _alepha_logger0.Logger;
56
56
  protected readonly dateTime: DateTimeProvider;
57
57
  protected readonly partitions: Map<any, any>;
58
58
  protected activeHandlers: PromiseWithResolvers<void>[];
@@ -68,7 +68,6 @@ declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends De
68
68
  protected flushPartition(partitionKey: string): Promise<void>;
69
69
  protected readonly dispose: _alepha_core1.HookDescriptor<"stop">;
70
70
  }
71
- //# sourceMappingURL=$batch.d.ts.map
72
71
  //#endregion
73
72
  //#region src/index.d.ts
74
73
  /**
@@ -105,9 +104,7 @@ declare class BatchDescriptor<TItem extends TSchema, TResponse = any> extends De
105
104
  * @see {@link $batch}
106
105
  * @module alepha.batch
107
106
  */
108
- declare const AlephaBatch: _alepha_core0.Service<_alepha_core0.Module>;
109
- //# sourceMappingURL=index.d.ts.map
110
-
107
+ declare const AlephaBatch: _alepha_core1.Service<_alepha_core1.Module>;
111
108
  //#endregion
112
109
  export { $batch, AlephaBatch, BatchDescriptor, BatchDescriptorOptions };
113
110
  //# sourceMappingURL=index.d.ts.map
package/bucket.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _alepha_core1 from "alepha";
2
- import * as _alepha_core0 from "alepha";
3
- import { Alepha, Descriptor, FileLike, KIND, Service } from "alepha";
2
+ import { Alepha, AlephaError, Descriptor, FileLike, KIND, Service } from "alepha";
4
3
  import * as fs from "node:fs";
4
+ import * as _alepha_logger0 from "alepha/logger";
5
5
  import * as _sinclair_typebox0 from "@sinclair/typebox";
6
6
 
7
7
  //#region src/providers/FileStorageProvider.d.ts
@@ -39,7 +39,6 @@ declare abstract class FileStorageProvider {
39
39
  */
40
40
  abstract delete(bucketName: string, fileId: string): Promise<void>;
41
41
  }
42
- //# sourceMappingURL=FileStorageProvider.d.ts.map
43
42
  //#endregion
44
43
  //#region src/providers/MemoryFileStorageProvider.d.ts
45
44
  declare class MemoryFileStorageProvider implements FileStorageProvider {
@@ -50,8 +49,6 @@ declare class MemoryFileStorageProvider implements FileStorageProvider {
50
49
  delete(bucketName: string, fileId: string): Promise<void>;
51
50
  protected createId(): string;
52
51
  }
53
- //# sourceMappingURL=MemoryFileStorageProvider.d.ts.map
54
-
55
52
  //#endregion
56
53
  //#region src/descriptors/$bucket.d.ts
57
54
  /**
@@ -85,7 +82,7 @@ interface BucketDescriptorOptions extends BucketFileOptions {
85
82
  name?: string;
86
83
  }
87
84
  declare class BucketDescriptor extends Descriptor<BucketDescriptorOptions> {
88
- readonly provider: MemoryFileStorageProvider | FileStorageProvider;
85
+ readonly provider: FileStorageProvider | MemoryFileStorageProvider;
89
86
  get name(): string;
90
87
  /**
91
88
  * Uploads a file to the bucket.
@@ -103,7 +100,7 @@ declare class BucketDescriptor extends Descriptor<BucketDescriptorOptions> {
103
100
  * Downloads a file from the bucket.
104
101
  */
105
102
  download(fileId: string): Promise<FileLike>;
106
- protected $provider(): MemoryFileStorageProvider | FileStorageProvider;
103
+ protected $provider(): FileStorageProvider | MemoryFileStorageProvider;
107
104
  }
108
105
  interface BucketFileOptions {
109
106
  /**
@@ -121,18 +118,17 @@ interface BucketFileOptions {
121
118
  */
122
119
  maxSize?: number;
123
120
  }
124
- //# sourceMappingURL=$bucket.d.ts.map
125
121
  //#endregion
126
122
  //#region src/errors/FileNotFoundError.d.ts
127
- declare class FileNotFoundError extends Error {
123
+ declare class FileNotFoundError extends AlephaError {
128
124
  readonly status = 404;
129
125
  }
130
- //# sourceMappingURL=FileNotFoundError.d.ts.map
131
126
  //#endregion
132
127
  //#region src/providers/LocalFileStorageProvider.d.ts
133
128
  declare class LocalFileStorageProvider implements FileStorageProvider {
134
129
  static METADATA_HEADER_LENGTH: number;
135
130
  protected readonly alepha: Alepha;
131
+ protected readonly log: _alepha_logger0.Logger;
136
132
  options: {
137
133
  storagePath: string;
138
134
  };
@@ -151,7 +147,6 @@ declare const fileMetadataSchema: _sinclair_typebox0.TObject<{
151
147
  type: _sinclair_typebox0.TString;
152
148
  size: _sinclair_typebox0.TNumber;
153
149
  }>;
154
- //# sourceMappingURL=LocalFileStorageProvider.d.ts.map
155
150
  //#endregion
156
151
  //#region src/index.d.ts
157
152
  declare module "alepha" {
@@ -186,9 +181,7 @@ declare module "alepha" {
186
181
  * @see {@link FileStorageProvider}
187
182
  * @module alepha.bucket
188
183
  */
189
- declare const AlephaBucket: _alepha_core0.Service<_alepha_core0.Module>;
190
- //# sourceMappingURL=index.d.ts.map
191
-
184
+ declare const AlephaBucket: _alepha_core1.Service<_alepha_core1.Module>;
192
185
  //#endregion
193
186
  export { $bucket, AlephaBucket, BucketDescriptor, BucketDescriptorOptions, BucketFileOptions, FileNotFoundError, FileStorageProvider, LocalFileStorageProvider, MemoryFileStorageProvider, fileMetadataSchema };
194
187
  //# sourceMappingURL=index.d.ts.map
package/cache/redis.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CacheProvider } from "alepha/cache";
2
2
  import * as _alepha_core1 from "alepha";
3
- import * as _alepha_core0 from "alepha";
4
- import { Alepha, Logger, Static } from "alepha";
3
+ import { Alepha, Static } from "alepha";
4
+ import * as _alepha_logger0 from "alepha/logger";
5
5
  import { RedisProvider } from "alepha/redis";
6
6
 
7
7
  //#region src/providers/RedisCacheProvider.d.ts
@@ -12,9 +12,11 @@ declare module "alepha" {
12
12
  interface Env extends Partial<Static<typeof envSchema>> {}
13
13
  }
14
14
  declare class RedisCacheProvider implements CacheProvider {
15
- protected readonly log: Logger;
15
+ protected readonly log: _alepha_logger0.Logger;
16
16
  protected readonly redisProvider: RedisProvider;
17
- protected readonly env: Static<typeof envSchema>;
17
+ protected readonly env: {
18
+ REDIS_CACHE_PREFIX?: string | undefined;
19
+ };
18
20
  protected readonly alepha: Alepha;
19
21
  get(name: string, key: string): Promise<Uint8Array | undefined>;
20
22
  set(name: string, key: string, value: Uint8Array | string, ttl?: number): Promise<Uint8Array>;
@@ -31,9 +33,7 @@ declare class RedisCacheProvider implements CacheProvider {
31
33
  * @see {@link RedisCacheProvider}
32
34
  * @module alepha.cache.redis
33
35
  */
34
- declare const AlephaCacheRedis: _alepha_core0.Service<_alepha_core0.Module>;
35
- //# sourceMappingURL=index.d.ts.map
36
-
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
@@ -1,7 +1,7 @@
1
- import * as _alepha_core1 from "alepha";
2
1
  import * as _alepha_core0 from "alepha";
3
2
  import { Descriptor, InstantiableClass, KIND } from "alepha";
4
3
  import { DateTimeProvider, DurationLike, Timeout } from "alepha/datetime";
4
+ import * as _alepha_logger0 from "alepha/logger";
5
5
 
6
6
  //#region src/providers/CacheProvider.d.ts
7
7
  /**
@@ -41,7 +41,6 @@ declare abstract class CacheProvider {
41
41
  abstract has(name: string, key: string): Promise<boolean>;
42
42
  abstract keys(name: string, filter?: string): Promise<string[]>;
43
43
  }
44
- //# sourceMappingURL=CacheProvider.d.ts.map
45
44
  //#endregion
46
45
  //#region src/descriptors/$cache.d.ts
47
46
  /**
@@ -116,7 +115,6 @@ interface CacheDescriptorFn<TReturn = any, TParameter extends any[] = any[]> ext
116
115
  */
117
116
  (...args: TParameter): Promise<TReturn>;
118
117
  }
119
- //# sourceMappingURL=$cache.d.ts.map
120
118
  //#endregion
121
119
  //#region src/providers/MemoryCacheProvider.d.ts
122
120
  type CacheName = string;
@@ -127,7 +125,7 @@ type CacheValue = {
127
125
  };
128
126
  declare class MemoryCacheProvider implements CacheProvider {
129
127
  protected readonly dateTimeProvider: DateTimeProvider;
130
- protected readonly log: _alepha_core1.Logger;
128
+ protected readonly log: _alepha_logger0.Logger;
131
129
  protected store: Record<CacheName, Record<CacheKey, CacheValue>>;
132
130
  get(name: string, key: string): Promise<Uint8Array | undefined>;
133
131
  set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
@@ -149,8 +147,6 @@ declare class MemoryCacheProvider implements CacheProvider {
149
147
  * @module alepha.cache
150
148
  */
151
149
  declare const AlephaCache: _alepha_core0.Service<_alepha_core0.Module>;
152
- //# sourceMappingURL=index.d.ts.map
153
-
154
150
  //#endregion
155
151
  export { $cache, AlephaCache, CacheDescriptor, CacheDescriptorFn, CacheDescriptorOptions, CacheProvider, MemoryCacheProvider };
156
152
  //# sourceMappingURL=index.d.ts.map
package/command.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _alepha_core1 from "alepha";
2
- import * as _alepha_core0 from "alepha";
3
- import { Alepha, AlephaError, Async, Descriptor, KIND, Logger, Static, TObject, TSchema } from "alepha";
2
+ import { Alepha, AlephaError, Async, Descriptor, KIND, Static, TObject, TSchema } from "alepha";
4
3
  import * as fs from "node:fs/promises";
5
4
  import { glob } from "node:fs/promises";
5
+ import * as _alepha_logger0 from "alepha/logger";
6
6
  import * as _sinclair_typebox0 from "@sinclair/typebox";
7
7
 
8
8
  //#region src/helpers/Runner.d.ts
@@ -30,11 +30,11 @@ interface RunnerMethod {
30
30
  cp: (source: string, dest: string, options?: RunOptions) => Promise<string>;
31
31
  }
32
32
  declare class Runner {
33
- protected readonly log: Logger;
33
+ protected readonly log: _alepha_logger0.Logger;
34
34
  protected readonly timers: Timer[];
35
35
  protected readonly startTime: number;
36
36
  readonly run: RunnerMethod;
37
- constructor(log: Logger);
37
+ constructor();
38
38
  protected createRunMethod(): RunnerMethod;
39
39
  protected exec(cmd: string): Promise<string>;
40
40
  /**
@@ -101,13 +101,11 @@ interface CommandHandlerArgs<T extends TObject> {
101
101
  glob: typeof glob;
102
102
  fs: typeof fs;
103
103
  }
104
- //# sourceMappingURL=$command.d.ts.map
105
104
  //#endregion
106
105
  //#region src/errors/CommandError.d.ts
107
106
  declare class CommandError extends AlephaError {
108
107
  readonly name = "CommandError";
109
108
  }
110
- //# sourceMappingURL=CommandError.d.ts.map
111
109
  //#endregion
112
110
  //#region src/providers/CliProvider.d.ts
113
111
  declare const envSchema: TObject<{
@@ -118,9 +116,13 @@ declare module "alepha" {
118
116
  interface Env extends Partial<Static<typeof envSchema>> {}
119
117
  }
120
118
  declare class CliProvider {
121
- protected readonly env: Static<typeof envSchema>;
119
+ protected readonly env: {
120
+ CLI_NAME: string;
121
+ CLI_DESCRIPTION: string;
122
+ };
122
123
  protected readonly alepha: Alepha;
123
- protected readonly log: Logger;
124
+ protected readonly log: _alepha_logger0.Logger;
125
+ protected readonly runner: Runner;
124
126
  options: {
125
127
  name: string;
126
128
  description: string;
@@ -157,7 +159,7 @@ declare class CliProvider {
157
159
  * @see {@link $command}
158
160
  * @module alepha.command
159
161
  */
160
- declare const AlephaCommand: _alepha_core0.Service<_alepha_core0.Module>;
162
+ declare const AlephaCommand: _alepha_core1.Service<_alepha_core1.Module>;
161
163
  declare module "@sinclair/typebox" {
162
164
  interface StringOptions {
163
165
  /**
@@ -168,8 +170,6 @@ declare module "@sinclair/typebox" {
168
170
  aliases?: string[];
169
171
  }
170
172
  }
171
- //# sourceMappingURL=index.d.ts.map
172
-
173
173
  //#endregion
174
174
  export { $command, AlephaCommand, CliProvider, CommandDescriptor, CommandDescriptorOptions, CommandError, CommandHandlerArgs, RunOptions, Runner, RunnerMethod, Task };
175
175
  //# sourceMappingURL=index.d.ts.map