alepha 0.7.3 → 0.7.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/queue.d.ts CHANGED
@@ -1,83 +1,38 @@
1
1
  import * as _alepha_core from '@alepha/core';
2
- import { TSchema as TSchema$1, KIND, OPTIONS, Static, Alepha } from '@alepha/core';
2
+ import { TSchema as TSchema$1, KIND, OPTIONS, Static, Alepha, Module } from '@alepha/core';
3
3
  import { DateTimeProvider } from '@alepha/datetime';
4
- import { RedisProvider } from '@alepha/redis';
5
4
 
6
- /** Symbol key applied to readonly types */
7
- declare const ReadonlyKind: unique symbol;
8
- /** Symbol key applied to optional types */
9
- declare const OptionalKind: unique symbol;
10
- /** Symbol key applied to types */
11
- declare const Hint: unique symbol;
12
- /** Symbol key applied to types */
13
- declare const Kind: unique symbol;
14
-
15
- interface TUnsafe<T> extends TSchema {
16
- [Kind]: string;
17
- static: T;
18
- }
19
-
20
- interface NumberOptions extends SchemaOptions {
21
- exclusiveMaximum?: number;
22
- exclusiveMinimum?: number;
23
- maximum?: number;
24
- minimum?: number;
25
- multipleOf?: number;
26
- }
27
- interface TNumber extends TSchema, NumberOptions {
28
- [Kind]: 'Number';
29
- static: number;
30
- type: 'number';
31
- }
32
-
33
- interface SchemaOptions {
34
- $schema?: string;
35
- /** Id for this schema */
36
- $id?: string;
37
- /** Title of this schema */
38
- title?: string;
39
- /** Description of this schema */
40
- description?: string;
41
- /** Default value for this schema */
42
- default?: any;
43
- /** Example values matching this schema */
44
- examples?: any;
45
- /** Optional annotation for readOnly */
46
- readOnly?: boolean;
47
- /** Optional annotation for writeOnly */
48
- writeOnly?: boolean;
49
- [prop: string]: any;
50
- }
51
- interface TKind {
52
- [Kind]: string;
53
- }
54
- interface TSchema extends TKind, SchemaOptions {
55
- [ReadonlyKind]?: string;
56
- [OptionalKind]?: string;
57
- [Hint]?: string;
58
- params: unknown[];
59
- static: unknown;
60
- }
61
-
62
- declare class QueueProvider {
63
- constructor();
5
+ /**
6
+ * Minimalist Queue interface.
7
+ *
8
+ * Will be probably enhanced in the future to support more advanced features. But for now, it's enough!
9
+ */
10
+ declare abstract class QueueProvider {
64
11
  /**
65
12
  * Push a message to the queue.
66
13
  *
67
- * @param queue - The queue name.
68
- * @param message - The message to push.
14
+ * @param queue Name of the queue to push the message to.
15
+ * @param message String message to be pushed to the queue. Buffer messages are not supported for now.
69
16
  */
70
- push(_queue: string, _message: string): Promise<void>;
17
+ abstract push(queue: string, message: string): Promise<void>;
71
18
  /**
72
19
  * Pop a message from the queue.
73
20
  *
74
- * @param queue - The queue name.
75
- * @returns The message popped.
21
+ * @param queue Name of the queue to pop the message from.
22
+ *
23
+ * @returns The message popped or `undefined` if the queue is empty.
76
24
  */
77
- pop(_queue: string): Promise<string | undefined>;
25
+ abstract pop(queue: string): Promise<string | undefined>;
78
26
  }
79
27
 
80
28
  declare const KEY$1 = "QUEUE";
29
+ /**
30
+ * Queue descriptor.
31
+ */
32
+ declare const $queue: {
33
+ <T extends QueueMessageSchema>(options: QueueDescriptorOptions<T>): QueueDescriptor<T>;
34
+ [KIND]: string;
35
+ };
81
36
  interface QueueMessageSchema {
82
37
  headers?: TSchema$1;
83
38
  payload: TSchema$1;
@@ -98,18 +53,15 @@ interface QueueDescriptor<T extends QueueMessageSchema = QueueMessageSchema> {
98
53
  provider(): QueueProvider;
99
54
  push(...payload: Array<Static<T["payload"]>>): Promise<void>;
100
55
  }
56
+
57
+ declare const KEY = "CONSUMER";
101
58
  /**
102
- * Queue descriptor.
103
- *
104
- * @param options - The queue options.
105
- * @returns The descriptor value.
59
+ * Consumer descriptor.
106
60
  */
107
- declare const $queue: {
108
- <T extends QueueMessageSchema>(options: QueueDescriptorOptions<T>): QueueDescriptor<T>;
61
+ declare const $consumer: {
62
+ <T extends QueueMessageSchema>(options: ConsumerDescriptorOptions<T>): ConsumerDescriptor<T>;
109
63
  [KIND]: string;
110
64
  };
111
-
112
- declare const KEY = "CONSUMER";
113
65
  interface ConsumerDescriptorOptions<T extends QueueMessageSchema = QueueMessageSchema> {
114
66
  queue: QueueDescriptor<T>;
115
67
  handler: (message: {
@@ -122,44 +74,66 @@ interface ConsumerDescriptor<T extends QueueMessageSchema = QueueMessageSchema>
122
74
  queue(): QueueDescriptor<T>;
123
75
  stop(): Promise<void>;
124
76
  }
125
- /**
126
- * Consumer descriptor.
127
- *
128
- * @param options - The consumer options.
129
- * @returns The descriptor value.
130
- */
131
- declare const $consumer: {
132
- <T extends QueueMessageSchema>(options: ConsumerDescriptorOptions<T>): ConsumerDescriptor<T>;
133
- [KIND]: string;
134
- };
135
77
 
136
78
  declare class MemoryQueueProvider implements QueueProvider {
137
- /**
138
- * The in-memory queue list.
139
- */
140
- protected queueList: Record<string, string[]>;
141
79
  protected readonly log: _alepha_core.Logger;
142
- /**
143
- * Push a message to a queue.
144
- * The message is added to the end of the queue.
145
- * The queue is created if it does not exist.
146
- *
147
- * @param queue - The queue to push to.
148
- * @param messages The messages to push.
149
- */
80
+ protected queueList: Record<string, string[]>;
150
81
  push(queue: string, ...messages: string[]): Promise<void>;
151
- /**
152
- * Pop a message from a queue.
153
- * The message is removed from the queue.
154
- * If the queue is empty, this method will return undefined.
155
- *
156
- * @param queue - The queue to pop from.
157
- * @returns The message that was popped from the queue.
158
- */
159
82
  pop(queue: string): Promise<string | undefined>;
160
83
  }
161
84
 
162
- declare const envSchema$1: _alepha_core.TObject<{
85
+ /** Symbol key applied to readonly types */
86
+ declare const ReadonlyKind: unique symbol;
87
+ /** Symbol key applied to optional types */
88
+ declare const OptionalKind: unique symbol;
89
+ /** Symbol key applied to types */
90
+ declare const Hint: unique symbol;
91
+ /** Symbol key applied to types */
92
+ declare const Kind: unique symbol;
93
+
94
+ interface NumberOptions extends SchemaOptions {
95
+ exclusiveMaximum?: number;
96
+ exclusiveMinimum?: number;
97
+ maximum?: number;
98
+ minimum?: number;
99
+ multipleOf?: number;
100
+ }
101
+ interface TNumber extends TSchema, NumberOptions {
102
+ [Kind]: 'Number';
103
+ static: number;
104
+ type: 'number';
105
+ }
106
+
107
+ interface SchemaOptions {
108
+ $schema?: string;
109
+ /** Id for this schema */
110
+ $id?: string;
111
+ /** Title of this schema */
112
+ title?: string;
113
+ /** Description of this schema */
114
+ description?: string;
115
+ /** Default value for this schema */
116
+ default?: any;
117
+ /** Example values matching this schema */
118
+ examples?: any;
119
+ /** Optional annotation for readOnly */
120
+ readOnly?: boolean;
121
+ /** Optional annotation for writeOnly */
122
+ writeOnly?: boolean;
123
+ [prop: string]: any;
124
+ }
125
+ interface TKind {
126
+ [Kind]: string;
127
+ }
128
+ interface TSchema extends TKind, SchemaOptions {
129
+ [ReadonlyKind]?: string;
130
+ [OptionalKind]?: string;
131
+ [Hint]?: string;
132
+ params: unknown[];
133
+ static: unknown;
134
+ }
135
+
136
+ declare const envSchema: _alepha_core.TObject<{
163
137
  /**
164
138
  * The interval in milliseconds to wait before checking for new messages.
165
139
  */
@@ -175,7 +149,7 @@ declare const envSchema$1: _alepha_core.TObject<{
175
149
  QUEUE_WORKER_CONCURRENCY: TNumber;
176
150
  }>;
177
151
  declare module "alepha" {
178
- interface Env extends Partial<Static<typeof envSchema$1>> {
152
+ interface Env extends Partial<Static<typeof envSchema>> {
179
153
  }
180
154
  }
181
155
  interface QueueDescriptorProviderState {
@@ -217,90 +191,63 @@ declare class QueueDescriptorProvider {
217
191
  protected processQueueDescriptors(): void;
218
192
  /**
219
193
  * Process the consumer descriptors.
220
- *
221
- * @protected
222
194
  */
223
195
  protected processConsumerDescriptors(): void;
196
+ /**
197
+ * Get the provider for the queue.
198
+ */
199
+ protected provider(options: QueueDescriptorOptions<any>): QueueProvider;
200
+ /**
201
+ * Push an item to the queue.
202
+ */
203
+ protected push<T extends QueueMessageSchema>(queue: QueueDescriptor<T>, ...payloads: Array<Static<T["payload"]>>): Promise<void>;
224
204
  /**
225
205
  * Start the workers.
226
- *
227
- * @param consumers
228
- * @protected
206
+ * This method will create an endless loop that will check for new messages!
229
207
  */
230
208
  protected startWorkers(consumers: Array<ConsumerDescriptorOptions>): void;
231
209
  /**
232
- * Wait for the next message.
210
+ * Wait for the next message, where `n` is the worker number.
233
211
  *
234
- * @param n
235
- * @protected
212
+ * This method will wait for a certain amount of time, increasing the wait time again if no message is found.
236
213
  */
237
214
  protected waitForNextMessage(n: number): Promise<void>;
238
215
  /**
239
216
  * Get the next message.
240
- *
241
- * @param consumers
242
- * @protected
243
217
  */
244
218
  protected getNextMessage(consumers: Array<ConsumerDescriptorOptions>): Promise<undefined | {
245
- message: any;
246
219
  consumer: ConsumerDescriptorOptions;
220
+ message: string;
247
221
  }>;
248
222
  /**
249
223
  * Process a message from a queue.
250
- *
251
- * @param response
252
- * @protected
253
224
  */
254
225
  protected processMessage(response: {
255
226
  message: any;
256
227
  consumer: ConsumerDescriptorOptions;
257
228
  }): Promise<void>;
258
229
  /**
259
- * Stop the workers
230
+ * Stop the workers.
260
231
  *
261
- * @protected
232
+ * This method will stop the workers and wait for them to finish processing.
262
233
  */
263
234
  protected stopWorkers(): Promise<void>;
264
- /**
265
- * Get the provider for the queue.
266
- *
267
- * @param options - The queue options.
268
- * @protected
269
- */
270
- protected provider(options: QueueDescriptorOptions<any>): QueueProvider;
271
- /**
272
- * Push an item to the queue.
273
- *
274
- * @param queue
275
- * @param payloads
276
- * @protected
277
- */
278
- protected push<T extends QueueMessageSchema>(queue: QueueDescriptor<T>, ...payloads: Array<Static<T["payload"]>>): Promise<void>;
279
- }
280
-
281
- declare class RedisQueueProvider implements QueueProvider {
282
- protected readonly env: {
283
- REDIS_QUEUE_PREFIX: string;
284
- };
285
- protected readonly redisProvider: RedisProvider;
286
- prefix(queue: string): string;
287
- push(queue: string, message: string): Promise<void>;
288
- pop(queue: string): Promise<string | undefined>;
289
235
  }
290
236
 
291
- declare const envSchema: _alepha_core.TObject<{
292
- QUEUE_PROVIDER: TUnsafe<"memory" | "redis">;
293
- }>;
294
- declare module "alepha/core" {
295
- interface Env extends Partial<Static<typeof envSchema>> {
296
- }
297
- }
298
- declare class QueueModule {
299
- protected readonly alepha: Alepha;
300
- protected readonly env: {
301
- QUEUE_PROVIDER: "memory" | "redis";
302
- };
303
- constructor();
237
+ /**
238
+ * Alepha Queue Module
239
+ *
240
+ * Generic interface for queueing.
241
+ * Gives you the ability to create queues and consumers.
242
+ * This module provides only a memory implementation of the queue provider.
243
+ *
244
+ * @see {@link $queue}
245
+ * @see {@link $consumer}
246
+ * @module alepha.queue
247
+ */
248
+ declare class AlephaQueue implements Module {
249
+ readonly name = "alepha.queue";
250
+ readonly $services: (alepha: Alepha) => Alepha;
304
251
  }
305
252
 
306
- export { $consumer, $queue, type ConsumerDescriptor, type ConsumerDescriptorOptions, MemoryQueueProvider, type QueueDescriptor, type QueueDescriptorOptions, QueueDescriptorProvider, type QueueDescriptorProviderState, type QueueMessageSchema, QueueModule, QueueProvider, RedisQueueProvider };
253
+ export { $consumer, $queue, AlephaQueue, type ConsumerDescriptor, type ConsumerDescriptorOptions, MemoryQueueProvider, type QueueDescriptor, type QueueDescriptorOptions, QueueDescriptorProvider, type QueueDescriptorProviderState, type QueueMessageSchema, QueueProvider };
package/react/auth.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _alepha_core from '@alepha/core';
2
- import { Async, KIND, OPTIONS, Alepha } from '@alepha/core';
2
+ import { Async, KIND, OPTIONS, Alepha, Module } from '@alepha/core';
3
3
  import { UserAccountToken } from '@alepha/security';
4
4
  import * as _alepha_server from '@alepha/server';
5
5
  import { HttpVirtualClient, HttpClient } from '@alepha/server';
@@ -300,9 +300,17 @@ declare module "alepha/react" {
300
300
  user?: ReactUser;
301
301
  }
302
302
  }
303
- declare class ReactAuthModule {
304
- protected readonly alepha: Alepha;
305
- constructor();
303
+ /**
304
+ * Alepha React Authentication Module
305
+ *
306
+ * The ReactAuthModule provides authentication services for React applications.
307
+ *
308
+ * @see {@link ReactAuthProvider}
309
+ * @module alepha.react.auth
310
+ */
311
+ declare class AlephaReactAuth implements Module {
312
+ readonly name = "alepha.react.auth";
313
+ readonly $services: (alepha: Alepha) => void;
306
314
  }
307
315
 
308
- export { $auth, type AccessToken, type AuthDescriptor, type AuthDescriptorOptions, type AuthHook, type AuthProvider, ReactAuth, ReactAuthModule, ReactAuthProvider, type ReactUser, type SessionTokens, useAuth };
316
+ export { $auth, type AccessToken, AlephaReactAuth, type AuthDescriptor, type AuthDescriptorOptions, type AuthHook, type AuthProvider, ReactAuth, ReactAuthProvider, type ReactUser, type SessionTokens, useAuth };
package/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _alepha_core from '@alepha/core';
2
- import { TSchema as TSchema$1, KIND, OPTIONS, Static as Static$1, Async, Alepha, Service, TObject as TObject$1 } from '@alepha/core';
2
+ import { TSchema as TSchema$1, KIND, OPTIONS, Static, Async, Alepha, Service, TObject, Module } from '@alepha/core';
3
3
  import { ServerRoute, ServerRequest, ApiLinksResponse, HttpClient, ClientScope, HttpVirtualClient, ServerRouterProvider, ServerTimingProvider, ServerHandler } from '@alepha/server';
4
4
  import * as React from 'react';
5
5
  import React__default, { PropsWithChildren, ReactNode, FC, ErrorInfo, AnchorHTMLAttributes } from 'react';
@@ -17,10 +17,6 @@ declare const Hint: unique symbol;
17
17
  /** Symbol key applied to types */
18
18
  declare const Kind: unique symbol;
19
19
 
20
- type TReadonly<T extends TSchema> = T & {
21
- [ReadonlyKind]: 'Readonly';
22
- };
23
-
24
20
  type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
25
21
  type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
26
22
  interface StringOptions extends SchemaOptions {
@@ -53,49 +49,6 @@ type TOptional<T extends TSchema> = T & {
53
49
  [OptionalKind]: 'Optional';
54
50
  };
55
51
 
56
- /** Creates a static type from a TypeBox type */
57
- type Static<Type extends TSchema, Params extends unknown[] = [], Result = (Type & {
58
- params: Params;
59
- })['static']> = Result;
60
-
61
- type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
62
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
63
- }[keyof T];
64
- type ReadonlyPropertyKeys<T extends TProperties> = {
65
- [K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? never : K) : never;
66
- }[keyof T];
67
- type OptionalPropertyKeys<T extends TProperties> = {
68
- [K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
69
- }[keyof T];
70
- type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
71
- type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
72
- type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
73
- [K in keyof T]: Static<T[K], P>;
74
- }>;
75
- type TPropertyKey = string | number;
76
- type TProperties = Record<TPropertyKey, TSchema>;
77
- type TAdditionalProperties = undefined | TSchema | boolean;
78
- interface ObjectOptions extends SchemaOptions {
79
- /** Additional property constraints for this object */
80
- additionalProperties?: TAdditionalProperties;
81
- /** The minimum number of properties allowed on this object */
82
- minProperties?: number;
83
- /** The maximum number of properties allowed on this object */
84
- maxProperties?: number;
85
- }
86
- interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
87
- [Kind]: 'Object';
88
- static: ObjectStatic<T, this['params']>;
89
- additionalProperties?: TAdditionalProperties;
90
- type: 'object';
91
- properties: T;
92
- required?: string[];
93
- }
94
-
95
- type Evaluate<T> = T extends infer O ? {
96
- [K in keyof O]: O[K];
97
- } : never;
98
-
99
52
  interface SchemaOptions {
100
53
  $schema?: string;
101
54
  /** Id for this schema */
@@ -292,8 +245,8 @@ interface Head$1 {
292
245
  };
293
246
  }
294
247
  interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema> {
295
- params: TConfig["params"] extends TSchema$1 ? Static$1<TConfig["params"]> : Record<string, string>;
296
- query: TConfig["query"] extends TSchema$1 ? Static$1<TConfig["query"]> : Record<string, string>;
248
+ params: TConfig["params"] extends TSchema$1 ? Static<TConfig["params"]> : Record<string, string>;
249
+ query: TConfig["query"] extends TSchema$1 ? Static<TConfig["query"]> : Record<string, string>;
297
250
  }
298
251
  type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;
299
252
 
@@ -301,7 +254,7 @@ declare const envSchema$1: _alepha_core.TObject<{
301
254
  REACT_STRICT_MODE: TBoolean;
302
255
  }>;
303
256
  declare module "alepha" {
304
- interface Env extends Partial<Static$1<typeof envSchema$1>> {
257
+ interface Env extends Partial<Static<typeof envSchema$1>> {
305
258
  }
306
259
  }
307
260
  declare class PageDescriptorProvider {
@@ -647,7 +600,7 @@ interface UseQueryParamsHookOptions {
647
600
  key?: string;
648
601
  push?: boolean;
649
602
  }
650
- declare const useQueryParams: <T extends TObject$1>(schema: T, options?: UseQueryParamsHookOptions) => [Static$1<T>, (data: Static$1<T>) => void];
603
+ declare const useQueryParams: <T extends TObject>(schema: T, options?: UseQueryParamsHookOptions) => [Static<T>, (data: Static<T>) => void];
651
604
 
652
605
  declare const useRouter: () => RouterHookApi;
653
606
 
@@ -666,14 +619,14 @@ declare const useRouterEvents: (opts?: {
666
619
 
667
620
  declare const useRouterState: () => RouterState;
668
621
 
669
- declare const envSchema: TObject<{
622
+ declare const envSchema: _alepha_core.TObject<{
670
623
  REACT_SERVER_DIST: TString;
671
624
  REACT_SERVER_PREFIX: TString;
672
625
  REACT_SSR_ENABLED: TOptional<TBoolean>;
673
626
  REACT_ROOT_ID: TString;
674
627
  }>;
675
628
  declare module "alepha/core" {
676
- interface Env extends Partial<Static$1<typeof envSchema>> {
629
+ interface Env extends Partial<Static<typeof envSchema>> {
677
630
  }
678
631
  interface State {
679
632
  "ReactServerProvider.template"?: string;
@@ -748,9 +701,18 @@ declare module "@alepha/core" {
748
701
  };
749
702
  }
750
703
  }
751
- declare class ReactModule {
752
- protected readonly alepha: Alepha;
753
- constructor();
704
+ /**
705
+ * Alepha React Module
706
+ *
707
+ * Alepha React Module contains a router for client-side navigation and server-side rendering.
708
+ * Routes can be defined using the `$page` descriptor.
709
+ *
710
+ * @see {@link $page}
711
+ * @module alepha.react
712
+ */
713
+ declare class AlephaReact implements Module {
714
+ readonly name = "alepha.react";
715
+ readonly $services: (alepha: Alepha) => Alepha;
754
716
  }
755
717
 
756
- export { $page, type AnchorProps, ClientOnly, type CreateLayersResult, ErrorBoundary, type Head$1 as Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageDescriptorRenderOptions, type PageDescriptorRenderResult, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, type ReactHydrationState, ReactModule, ReactServerProvider, RedirectionError, RouterContext, type RouterContextValue, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterRenderResult, type RouterStackItem, type RouterState, type TPropsDefault, type TPropsParentDefault, type TransitionOptions, type UseActiveHook, type UseQueryParamsHookOptions, type VirtualRouter, envSchema, isPageRoute, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
718
+ export { $page, AlephaReact, type AnchorProps, ClientOnly, type CreateLayersResult, ErrorBoundary, type Head$1 as Head, type HrefLike, type Layer, Link, NestedView, type PageConfigSchema, type PageDescriptor, type PageDescriptorOptions, PageDescriptorProvider, type PageDescriptorRenderOptions, type PageDescriptorRenderResult, type PageReactContext, type PageRequest, type PageRequestConfig, type PageResolve, type PageRoute, type PageRouteEntry, type PreviousLayerData, ReactBrowserProvider, type ReactHydrationState, ReactServerProvider, RedirectionError, RouterContext, type RouterContextValue, type RouterGoOptions, RouterHookApi, RouterLayerContext, type RouterLayerContextValue, type RouterRenderResult, type RouterStackItem, type RouterState, type TPropsDefault, type TPropsParentDefault, type TransitionOptions, type UseActiveHook, type UseQueryParamsHookOptions, type VirtualRouter, isPageRoute, useActive, useAlepha, useClient, useInject, useQueryParams, useRouter, useRouterEvents, useRouterState };
package/redis.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import * as _redis_client from '@redis/client';
2
- import { createClient, SetOptions } from '@redis/client';
3
1
  import * as _alepha_core from '@alepha/core';
4
2
  import { Static, Alepha } from '@alepha/core';
3
+ import { RedisClientType, createClient, SetOptions } from '@redis/client';
5
4
 
6
5
  /** Symbol key applied to readonly types */
7
6
  declare const ReadonlyKind: unique symbol;
@@ -89,7 +88,9 @@ declare module "alepha" {
89
88
  interface Env extends Partial<Static<typeof envSchema>> {
90
89
  }
91
90
  }
92
- type RedisClient = ReturnType<typeof createClient>;
91
+ type RedisClient = RedisClientType<{}, {}, {}, 3, {
92
+ 36: BufferConstructor;
93
+ }>;
93
94
  type RedisClientOptions = Parameters<typeof createClient>[0];
94
95
  type RedisSetOptions = SetOptions;
95
96
  declare class RedisProvider {
@@ -100,7 +101,7 @@ declare class RedisProvider {
100
101
  REDIS_PORT: number;
101
102
  REDIS_HOST: string;
102
103
  };
103
- protected readonly client: _redis_client.RedisClientType<_redis_client.RedisModules, _redis_client.RedisFunctions, _redis_client.RedisScripts, _redis_client.RespVersions, _redis_client.TypeMapping>;
104
+ protected readonly client: RedisClient;
104
105
  get publisher(): RedisClient;
105
106
  protected readonly start: _alepha_core.HookDescriptor<"start">;
106
107
  protected readonly stop: _alepha_core.HookDescriptor<"stop">;
@@ -113,6 +114,11 @@ declare class RedisProvider {
113
114
  */
114
115
  close(): Promise<void>;
115
116
  duplicate(options?: Partial<RedisClientOptions>): RedisClient;
117
+ get(key: string): Promise<Buffer | undefined>;
118
+ set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
119
+ has(key: string): Promise<boolean>;
120
+ keys(pattern: string): Promise<string[]>;
121
+ del(keys: string[]): Promise<void>;
116
122
  /**
117
123
  * Redis subscriber client factory method.
118
124
  */
@@ -123,7 +129,7 @@ declare class RedisSubscriberProvider {
123
129
  protected readonly log: _alepha_core.Logger;
124
130
  protected readonly alepha: Alepha;
125
131
  protected readonly redisProvider: RedisProvider;
126
- protected readonly client: _redis_client.RedisClientType<_redis_client.RedisModules, _redis_client.RedisFunctions, _redis_client.RedisScripts, _redis_client.RespVersions, _redis_client.TypeMapping>;
132
+ protected readonly client: RedisClient;
127
133
  get subscriber(): RedisClient;
128
134
  protected readonly start: _alepha_core.HookDescriptor<"start">;
129
135
  protected readonly stop: _alepha_core.HookDescriptor<"stop">;
package/retry.d.ts CHANGED
@@ -1,5 +1,35 @@
1
1
  import { MaybePromise } from '@alepha/core';
2
2
 
3
+ /**
4
+ * `$retry` creates a retry descriptor.
5
+ *
6
+ * It will retry the given function up to `max` times with a delay of `delay` milliseconds between attempts.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { $retry } from "@alepha/core";
11
+ *
12
+ * class MyService {
13
+ * fetchData = $retry({
14
+ * max: 5, // maximum number of attempts
15
+ * delay: 1000, // ms
16
+ * when: (error) => error.message.includes("Network Error"),
17
+ * handler: async (url: string) => {
18
+ * const response = await fetch(url);
19
+ * if (!response.ok) {
20
+ * throw new Error(`Failed to fetch: ${response.statusText}`);
21
+ * }
22
+ * return response.json();
23
+ * },
24
+ * onError: (error, attempt, url) => {
25
+ * // error happened, log it or handle it
26
+ * console.error(`Attempt ${attempt} failed for ${url}:`, error);
27
+ * },
28
+ * });
29
+ * }
30
+ * ```
31
+ */
32
+ declare const $retry: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>) => RetryDescriptor<T>;
3
33
  /**
4
34
  * Retry Descriptor options.
5
35
  */
@@ -34,35 +64,5 @@ interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
34
64
  onError?: (error: Error, attempt: number, ...parameters: Parameters<T>) => void;
35
65
  }
36
66
  type RetryDescriptor<T extends (...args: any[]) => any> = (...parameters: Parameters<T>) => MaybePromise<ReturnType<T>>;
37
- /**
38
- * `$retry` creates a retry descriptor.
39
- *
40
- * It will retry the given function up to `max` times with a delay of `delay` milliseconds between attempts.
41
- *
42
- * @example
43
- * ```ts
44
- * import { $retry } from "@alepha/core";
45
- *
46
- * class MyService {
47
- * fetchData = $retry({
48
- * max: 5, // maximum number of attempts
49
- * delay: 1000, // ms
50
- * when: (error) => error.message.includes("Network Error"),
51
- * handler: async (url: string) => {
52
- * const response = await fetch(url);
53
- * if (!response.ok) {
54
- * throw new Error(`Failed to fetch: ${response.statusText}`);
55
- * }
56
- * return response.json();
57
- * },
58
- * onError: (error, attempt, url) => {
59
- * // error happened, log it or handle it
60
- * console.error(`Attempt ${attempt} failed for ${url}:`, error);
61
- * },
62
- * });
63
- * }
64
- * ```
65
- */
66
- declare const $retry: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>) => RetryDescriptor<T>;
67
67
 
68
68
  export { $retry, type RetryDescriptor, type RetryDescriptorOptions };