alepha 0.8.0 → 0.9.0

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.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
package/react.d.ts CHANGED
@@ -1,18 +1,20 @@
1
- import * as _alepha_core11 from "alepha";
2
- import * as _alepha_core18 from "alepha";
3
- import * as _alepha_core16 from "alepha";
4
- import * as _alepha_core1 from "alepha";
5
- import { Alepha, Async, KIND, Module, OPTIONS, Service, Static, TObject, TSchema } from "alepha";
1
+ import * as _alepha_core8 from "alepha";
2
+ import * as _alepha_core14 from "alepha";
3
+ import * as _alepha_core12 from "alepha";
4
+ import * as _alepha_core0$1 from "alepha";
5
+ import * as _alepha_core0 from "alepha";
6
+ import { Alepha, Async, Descriptor, KIND, Service, Static, TObject, TSchema } from "alepha";
6
7
  import { ApiLinksResponse, ServerHandler, ServerRequest, ServerRouterProvider, ServerTimingProvider } from "alepha/server";
7
8
  import { ServerRouteCache } from "alepha/server/cache";
8
9
  import { ClientScope, HttpVirtualClient, LinkProvider } from "alepha/server/links";
9
- import * as react23 from "react";
10
- import * as react24 from "react";
10
+ import * as react0$1 from "react";
11
+ import * as react0 from "react";
11
12
  import React, { AnchorHTMLAttributes, ErrorInfo, FC, PropsWithChildren, ReactNode } from "react";
12
- import * as react_jsx_runtime22 from "react/jsx-runtime";
13
- import * as react_jsx_runtime20 from "react/jsx-runtime";
14
- import { ServerStaticProvider } from "alepha/server/static";
13
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
14
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
15
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
15
16
  import { Route, RouterProvider } from "alepha/router";
17
+ import { ServerStaticProvider } from "alepha/server/static";
16
18
  import { Root } from "react-dom/client";
17
19
 
18
20
  //#region src/components/ClientOnly.d.ts
@@ -33,13 +35,13 @@ interface ClientOnlyProps {
33
35
  declare const ClientOnly: (props: PropsWithChildren<ClientOnlyProps>) => ReactNode;
34
36
  //#endregion
35
37
  //#region src/descriptors/$page.d.ts
36
- declare const KEY = "PAGE";
37
- interface PageConfigSchema {
38
- query?: TSchema;
39
- params?: TSchema;
40
- }
41
- type TPropsDefault = any;
42
- type TPropsParentDefault = {};
38
+ /**
39
+ * Main descriptor for defining a React route in the application.
40
+ */
41
+ declare const $page: {
42
+ <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
43
+ [KIND]: typeof PageDescriptor;
44
+ };
43
45
  interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
44
46
  /**
45
47
  * Name your page.
@@ -103,14 +105,8 @@ interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSch
103
105
  *
104
106
  * If you still want to render at this pathname, add a child page with an empty path.
105
107
  */
106
- children?: Array<{
107
- [OPTIONS]: PageDescriptorOptions;
108
- }> | (() => Array<{
109
- [OPTIONS]: PageDescriptorOptions;
110
- }>);
111
- parent?: {
112
- [OPTIONS]: PageDescriptorOptions<PageConfigSchema, TPropsParent>;
113
- };
108
+ children?: Array<PageDescriptor> | (() => Array<PageDescriptor>);
109
+ parent?: PageDescriptor<PageConfigSchema, TPropsParent>;
114
110
  can?: () => boolean;
115
111
  errorHandler?: (error: Error) => ReactNode;
116
112
  /**
@@ -129,22 +125,20 @@ interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSch
129
125
  afterHandler?: (request: ServerRequest) => any;
130
126
  cache?: ServerRouteCache;
131
127
  }
132
- interface PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
133
- [KIND]: typeof KEY;
134
- [OPTIONS]: PageDescriptorOptions<TConfig, TProps, TPropsParent>;
128
+ declare class PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {
129
+ get name(): string;
135
130
  /**
136
131
  * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.
137
132
  * Only valid for server-side rendering, it will throw an error if called on the client-side.
138
133
  */
139
- render: (options?: PageDescriptorRenderOptions) => Promise<PageDescriptorRenderResult>;
134
+ render(options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
140
135
  }
141
- /**
142
- * Main descriptor for defining a React route in the application.
143
- */
144
- declare const $page: {
145
- <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
146
- [KIND]: string;
147
- };
136
+ interface PageConfigSchema {
137
+ query?: TSchema;
138
+ params?: TSchema;
139
+ }
140
+ type TPropsDefault = any;
141
+ type TPropsParentDefault = {};
148
142
  interface PageDescriptorRenderOptions {
149
143
  params?: Record<string, string>;
150
144
  query?: Record<string, string>;
@@ -160,16 +154,17 @@ interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema>
160
154
  query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
161
155
  }
162
156
  type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;
157
+ //# sourceMappingURL=$page.d.ts.map
163
158
  //#endregion
164
159
  //#region src/providers/PageDescriptorProvider.d.ts
165
- declare const envSchema$1: _alepha_core11.TObject<{
166
- REACT_STRICT_MODE: _alepha_core11.TBoolean;
160
+ declare const envSchema$1: _alepha_core8.TObject<{
161
+ REACT_STRICT_MODE: _alepha_core8.TBoolean;
167
162
  }>;
168
163
  declare module "alepha" {
169
164
  interface Env extends Partial<Static<typeof envSchema$1>> {}
170
165
  }
171
166
  declare class PageDescriptorProvider {
172
- protected readonly log: _alepha_core11.Logger;
167
+ protected readonly log: _alepha_core8.Logger;
173
168
  protected readonly env: {
174
169
  REACT_STRICT_MODE: boolean;
175
170
  };
@@ -194,14 +189,8 @@ declare class PageDescriptorProvider {
194
189
  }, params?: Record<string, any>): string;
195
190
  compile(path: string, params?: Record<string, string>): string;
196
191
  protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
197
- protected readonly configure: _alepha_core11.HookDescriptor<"configure">;
198
- protected map(pages: Array<{
199
- value: {
200
- [OPTIONS]: PageDescriptorOptions;
201
- };
202
- }>, target: {
203
- [OPTIONS]: PageDescriptorOptions;
204
- }): PageRouteEntry;
192
+ protected readonly configure: _alepha_core8.HookDescriptor<"configure">;
193
+ protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
205
194
  add(entry: PageRouteEntry): void;
206
195
  protected createMatch(page: PageRoute): string;
207
196
  protected _next: number;
@@ -231,6 +220,7 @@ interface Layer {
231
220
  index: number;
232
221
  path: string;
233
222
  route?: PageRoute;
223
+ cache?: boolean;
234
224
  }
235
225
  type PreviousLayerData = Omit<Layer, "element" | "index" | "path">;
236
226
  interface AnchorProps {
@@ -252,6 +242,7 @@ interface RouterStackItem {
252
242
  config?: Record<string, any>;
253
243
  props?: Record<string, any>;
254
244
  error?: Error;
245
+ cache?: boolean;
255
246
  }
256
247
  interface RouterRenderResult {
257
248
  state: RouterState;
@@ -281,11 +272,11 @@ interface BrowserRoute extends Route {
281
272
  page: PageRoute;
282
273
  }
283
274
  declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
284
- protected readonly log: _alepha_core18.Logger;
275
+ protected readonly log: _alepha_core14.Logger;
285
276
  protected readonly alepha: Alepha;
286
277
  protected readonly pageDescriptorProvider: PageDescriptorProvider;
287
278
  add(entry: PageRouteEntry): void;
288
- protected readonly configure: _alepha_core18.HookDescriptor<"configure">;
279
+ protected readonly configure: _alepha_core14.HookDescriptor<"configure">;
289
280
  transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
290
281
  root(state: RouterState, context: PageReactContext): ReactNode;
291
282
  }
@@ -293,7 +284,7 @@ declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
293
284
  //#endregion
294
285
  //#region src/providers/ReactBrowserProvider.d.ts
295
286
  declare class ReactBrowserProvider {
296
- protected readonly log: _alepha_core16.Logger;
287
+ protected readonly log: _alepha_core12.Logger;
297
288
  protected readonly client: LinkProvider;
298
289
  protected readonly alepha: Alepha;
299
290
  protected readonly router: BrowserRouterProvider;
@@ -304,7 +295,9 @@ declare class ReactBrowserProvider {
304
295
  state: RouterState;
305
296
  get document(): Document;
306
297
  get history(): History;
298
+ get location(): Location;
307
299
  get url(): string;
300
+ pushState(url: string, replace?: boolean): void;
308
301
  invalidate(props?: Record<string, any>): Promise<void>;
309
302
  go(url: string, options?: RouterGoOptions): Promise<void>;
310
303
  protected render(options?: {
@@ -315,7 +308,7 @@ declare class ReactBrowserProvider {
315
308
  * Get embedded layers from the server.
316
309
  */
317
310
  protected getHydrationState(): ReactHydrationState | undefined;
318
- readonly ready: _alepha_core16.HookDescriptor<"ready">;
311
+ readonly ready: _alepha_core12.HookDescriptor<"ready">;
319
312
  }
320
313
  interface RouterGoOptions {
321
314
  replace?: boolean;
@@ -373,7 +366,7 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
373
366
  to: string | PageDescriptor;
374
367
  children?: React.ReactNode;
375
368
  }
376
- declare const Link: (props: LinkProps) => react_jsx_runtime22.JSX.Element | null;
369
+ declare const Link: (props: LinkProps) => react_jsx_runtime1.JSX.Element | null;
377
370
  //#endregion
378
371
  //#region src/components/NestedView.d.ts
379
372
  interface NestedViewProps {
@@ -400,7 +393,11 @@ interface NestedViewProps {
400
393
  * }
401
394
  * ```
402
395
  */
403
- declare const NestedView: (props: NestedViewProps) => react_jsx_runtime20.JSX.Element;
396
+ declare const NestedView: (props: NestedViewProps) => react_jsx_runtime0.JSX.Element;
397
+ //#endregion
398
+ //#region src/components/NotFound.d.ts
399
+ declare function NotFoundPage(): react_jsx_runtime2.JSX.Element;
400
+ //# sourceMappingURL=NotFound.d.ts.map
404
401
  //#endregion
405
402
  //#region src/contexts/RouterContext.d.ts
406
403
  interface RouterContextValue {
@@ -408,7 +405,7 @@ interface RouterContextValue {
408
405
  state: RouterState;
409
406
  context: PageReactContext;
410
407
  }
411
- declare const RouterContext: react23.Context<RouterContextValue | undefined>;
408
+ declare const RouterContext: react0$1.Context<RouterContextValue | undefined>;
412
409
  //# sourceMappingURL=RouterContext.d.ts.map
413
410
  //#endregion
414
411
  //#region src/contexts/RouterLayerContext.d.ts
@@ -416,18 +413,21 @@ interface RouterLayerContextValue {
416
413
  index: number;
417
414
  path: string;
418
415
  }
419
- declare const RouterLayerContext: react24.Context<RouterLayerContextValue | undefined>;
416
+ declare const RouterLayerContext: react0.Context<RouterLayerContextValue | undefined>;
420
417
  //# sourceMappingURL=RouterLayerContext.d.ts.map
421
418
  //#endregion
422
419
  //#region src/hooks/RouterHookApi.d.ts
423
420
  declare class RouterHookApi {
424
421
  private readonly pages;
422
+ private readonly context;
425
423
  private readonly state;
426
424
  private readonly layer;
427
425
  private readonly browser?;
428
- constructor(pages: PageRoute[], state: RouterState, layer: {
426
+ constructor(pages: PageRoute[], context: PageReactContext, state: RouterState, layer: {
429
427
  path: string;
430
428
  }, browser?: ReactBrowserProvider | undefined);
429
+ getURL(): URL;
430
+ get location(): Location;
431
431
  get current(): RouterState;
432
432
  get pathname(): string;
433
433
  get query(): Record<string, string>;
@@ -538,21 +538,21 @@ declare const useRouterState: () => RouterState;
538
538
 
539
539
  //#endregion
540
540
  //#region src/providers/ReactServerProvider.d.ts
541
- declare const envSchema: _alepha_core1.TObject<{
542
- REACT_SERVER_DIST: _alepha_core1.TString;
543
- REACT_SERVER_PREFIX: _alepha_core1.TString;
544
- REACT_SSR_ENABLED: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
545
- REACT_ROOT_ID: _alepha_core1.TString;
541
+ declare const envSchema: _alepha_core0$1.TObject<{
542
+ REACT_SERVER_DIST: _alepha_core0$1.TString;
543
+ REACT_SERVER_PREFIX: _alepha_core0$1.TString;
544
+ REACT_SSR_ENABLED: _alepha_core0$1.TOptional<_alepha_core0$1.TBoolean>;
545
+ REACT_ROOT_ID: _alepha_core0$1.TString;
546
546
  }>;
547
547
  declare module "alepha" {
548
548
  interface Env extends Partial<Static<typeof envSchema>> {}
549
549
  interface State {
550
- "ReactServerProvider.template"?: string;
551
- "ReactServerProvider.ssr"?: boolean;
550
+ "react.server.template"?: string;
551
+ "react.server.ssr"?: boolean;
552
552
  }
553
553
  }
554
554
  declare class ReactServerProvider {
555
- protected readonly log: _alepha_core1.Logger;
555
+ protected readonly log: _alepha_core0$1.Logger;
556
556
  protected readonly alepha: Alepha;
557
557
  protected readonly pageDescriptorProvider: PageDescriptorProvider;
558
558
  protected readonly serverStaticProvider: ServerStaticProvider;
@@ -565,7 +565,7 @@ declare class ReactServerProvider {
565
565
  REACT_ROOT_ID: string;
566
566
  };
567
567
  protected readonly ROOT_DIV_REGEX: RegExp;
568
- readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
568
+ readonly onConfigure: _alepha_core0$1.HookDescriptor<"configure">;
569
569
  get template(): string;
570
570
  protected registerPages(templateLoader: TemplateLoader): Promise<void>;
571
571
  protected getPublicDirectory(): string;
@@ -633,20 +633,18 @@ declare module "alepha" {
633
633
  }
634
634
  }
635
635
  /**
636
- * Alepha React Module
636
+ * Provides full-stack React development with declarative routing, server-side rendering, and client-side hydration.
637
637
  *
638
- * Alepha React Module contains a router for client-side navigation and server-side rendering.
639
- * Routes can be defined using the `$page` descriptor.
638
+ * The React module enables building modern React applications using the `$page` descriptor on class properties.
639
+ * It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full
640
+ * type safety and schema validation for route parameters and data.
640
641
  *
641
642
  * @see {@link $page}
642
643
  * @module alepha.react
643
644
  */
644
- declare class AlephaReact implements Module {
645
- readonly name = "alepha.react";
646
- readonly $services: (alepha: Alepha) => Alepha;
647
- }
645
+ declare const AlephaReact: _alepha_core0.ModuleDescriptor;
648
646
  //# sourceMappingURL=index.d.ts.map
649
647
 
650
648
  //#endregion
651
- export { $page, AlephaReact, AnchorProps, ClientOnly, CreateLayersResult, ErrorBoundary, HrefLike, Layer, Link, NestedView, 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 };
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 };
652
650
  //# sourceMappingURL=index.d.ts.map
package/redis.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { Alepha, HookDescriptor, Logger, Static, TNumber, TObject, TOptional, TString } from "alepha";
1
+ import * as _alepha_core2 from "alepha";
2
+ import * as _alepha_core0$1 from "alepha";
3
+ import * as _alepha_core0 from "alepha";
4
+ import { Alepha, Logger, Static, TNumber, TObject, TOptional, TString } from "alepha";
2
5
  import { RedisClientType, SetOptions, createClient } from "@redis/client";
3
6
 
4
7
  //#region src/providers/RedisProvider.d.ts
@@ -15,21 +18,24 @@ type RedisClient = RedisClientType<{}, {}, {}, 3, {
15
18
  }>;
16
19
  type RedisClientOptions = Parameters<typeof createClient>[0];
17
20
  type RedisSetOptions = SetOptions;
21
+ /**
22
+ * Redis client provider.
23
+ */
18
24
  declare class RedisProvider {
19
25
  protected readonly log: Logger;
20
26
  protected readonly alepha: Alepha;
21
27
  protected readonly env: Static<typeof envSchema>;
22
28
  protected readonly client: RedisClient;
23
29
  get publisher(): RedisClient;
24
- protected readonly start: HookDescriptor<"start">;
25
- protected readonly stop: HookDescriptor<"stop">;
30
+ protected readonly start: _alepha_core2.HookDescriptor<"start">;
31
+ protected readonly stop: _alepha_core2.HookDescriptor<"stop">;
26
32
  /**
27
- * Connect to the Redis server.
28
- */
33
+ * Connect to the Redis server.
34
+ */
29
35
  connect(): Promise<void>;
30
36
  /**
31
- * Close the connection to the Redis server.
32
- */
37
+ * Close the connection to the Redis server.
38
+ */
33
39
  close(): Promise<void>;
34
40
  duplicate(options?: Partial<RedisClientOptions>): RedisClient;
35
41
  get(key: string): Promise<Buffer | undefined>;
@@ -38,8 +44,8 @@ declare class RedisProvider {
38
44
  keys(pattern: string): Promise<string[]>;
39
45
  del(keys: string[]): Promise<void>;
40
46
  /**
41
- * Redis subscriber client factory method.
42
- */
47
+ * Redis subscriber client factory method.
48
+ */
43
49
  protected createClient(): RedisClient;
44
50
  }
45
51
  //#endregion
@@ -50,15 +56,27 @@ declare class RedisSubscriberProvider {
50
56
  protected readonly redisProvider: RedisProvider;
51
57
  protected readonly client: RedisClient;
52
58
  get subscriber(): RedisClient;
53
- protected readonly start: HookDescriptor<"start">;
54
- protected readonly stop: HookDescriptor<"stop">;
59
+ protected readonly start: _alepha_core0$1.HookDescriptor<"start">;
60
+ protected readonly stop: _alepha_core0$1.HookDescriptor<"stop">;
55
61
  connect(): Promise<void>;
56
62
  close(): Promise<void>;
57
63
  /**
58
- * Redis subscriber client factory method.
59
- */
64
+ * Redis subscriber client factory method.
65
+ */
60
66
  protected createClient(): RedisClient;
61
67
  }
68
+ //# sourceMappingURL=RedisSubscriberProvider.d.ts.map
62
69
  //#endregion
63
- export { RedisClient, RedisClientOptions, RedisProvider, RedisSetOptions, RedisSubscriberProvider };
70
+ //#region src/index.d.ts
71
+ /**
72
+ * Redis client provider for Alepha applications.
73
+ *
74
+ * @see {@link RedisProvider}
75
+ * @module alepha.redis
76
+ */
77
+ declare const AlephaRedis: _alepha_core0.ModuleDescriptor;
78
+ //# sourceMappingURL=index.d.ts.map
79
+
80
+ //#endregion
81
+ export { AlephaRedis, RedisClient, RedisClientOptions, RedisProvider, RedisSetOptions, RedisSubscriberProvider };
64
82
  //# sourceMappingURL=index.d.ts.map
package/retry.d.ts CHANGED
@@ -1,91 +1,103 @@
1
- import { AlephaError, MaybePromise } from "alepha";
1
+ import { AlephaError, Descriptor, DescriptorArgs, KIND } from "alepha";
2
2
  import { DateTimeProvider, DurationLike } from "alepha/datetime";
3
3
 
4
4
  //#region src/descriptors/$retry.d.ts
5
5
 
6
- // TODO: move to RetryProvider
7
6
  /**
8
- * Creates a function that automatically retries a handler upon failure,
9
- * with support for exponential backoff, max duration, and cancellation.
10
- */
11
- declare const $retry: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>) => RetryDescriptor<T>;
12
- declare const createRetryHandler: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>, dateTimeProvider: DateTimeProvider, appAbortController?: AbortController) => RetryDescriptor<T>;
13
- // ---------------------------------------------------------------------------------------------------------------------
14
- interface RetryBackoffOptions {
15
- /**
16
- * Initial delay in milliseconds.
17
- *
18
- * @default 200
19
- */
20
- initial?: number;
21
- /**
22
- * Multiplier for each subsequent delay.
23
- *
24
- * @default 2
25
- */
26
- factor?: number;
27
- /**
28
- * Maximum delay in milliseconds.
29
- */
30
- max?: number;
31
- /**
32
- * If true, adds a random jitter to the delay to prevent thundering herd.
33
- *
34
- * @default true
35
- */
36
- jitter?: boolean;
37
- }
7
+ * Creates a function that automatically retries a handler upon failure,
8
+ * with support for exponential backoff, max duration, and cancellation.
9
+ */
10
+ declare const $retry: {
11
+ <T extends (...args: any[]) => any>(options: RetryDescriptorOptions<T>): RetryDescriptorFn<T>;
12
+ [KIND]: typeof RetryDescriptor;
13
+ };
38
14
  interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
39
15
  /**
40
- * The function to retry.
41
- */
16
+ * The function to retry.
17
+ */
42
18
  handler: T;
43
19
  /**
44
- * The maximum number of attempts.
45
- *
46
- * @default 3
47
- */
20
+ * The maximum number of attempts.
21
+ *
22
+ * @default 3
23
+ */
48
24
  max?: number;
49
25
  /**
50
- * The backoff strategy for delays between retries.
51
- * Can be a fixed number (in ms) or a configuration object for exponential backoff.
52
- *
53
- * @default { initial: 200, factor: 2, jitter: true }
54
- */
26
+ * The backoff strategy for delays between retries.
27
+ * Can be a fixed number (in ms) or a configuration object for exponential backoff.
28
+ *
29
+ * @default { initial: 200, factor: 2, jitter: true }
30
+ */
55
31
  backoff?: number | RetryBackoffOptions;
56
32
  /**
57
- * An overall time limit for all retry attempts combined.
58
- *
59
- * e.g., `[5, 'seconds']`
60
- */
33
+ * An overall time limit for all retry attempts combined.
34
+ *
35
+ * e.g., `[5, 'seconds']`
36
+ */
61
37
  maxDuration?: DurationLike;
62
38
  /**
63
- * A function that determines if a retry should be attempted based on the error.
64
- *
65
- * @default (error) => true (retries on any error)
66
- */
39
+ * A function that determines if a retry should be attempted based on the error.
40
+ *
41
+ * @default (error) => true (retries on any error)
42
+ */
67
43
  when?: (error: Error) => boolean;
68
44
  /**
69
- * A custom callback for when a retry attempt fails.
70
- * This is called before the delay.
71
- */
45
+ * A custom callback for when a retry attempt fails.
46
+ * This is called before the delay.
47
+ */
72
48
  onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;
73
49
  /**
74
- * An AbortSignal to allow for external cancellation of the retry loop.
75
- */
50
+ * An AbortSignal to allow for external cancellation of the retry loop.
51
+ */
76
52
  signal?: AbortSignal;
77
53
  }
78
- type RetryDescriptor<T extends (...args: any[]) => any> = (...parameters: Parameters<T>) => MaybePromise<ReturnType<T>>;
54
+ declare class RetryDescriptor<T extends (...args: any[]) => any> extends Descriptor<RetryDescriptorOptions<T>> {
55
+ protected readonly dateTimeProvider: DateTimeProvider;
56
+ protected appAbortController: AbortController;
57
+ constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>);
58
+ run(...args: Parameters<T>): Promise<ReturnType<T>>;
59
+ }
60
+ interface RetryDescriptorFn<T extends (...args: any[]) => any> extends RetryDescriptor<T> {
61
+ (...args: Parameters<T>): Promise<ReturnType<T>>;
62
+ }
63
+ interface RetryBackoffOptions {
64
+ /**
65
+ * Initial delay in milliseconds.
66
+ *
67
+ * @default 200
68
+ */
69
+ initial?: number;
70
+ /**
71
+ * Multiplier for each subsequent delay.
72
+ *
73
+ * @default 2
74
+ */
75
+ factor?: number;
76
+ /**
77
+ * Maximum delay in milliseconds.
78
+ */
79
+ max?: number;
80
+ /**
81
+ * If true, adds a random jitter to the delay to prevent thundering herd.
82
+ *
83
+ * @default true
84
+ */
85
+ jitter?: boolean;
86
+ }
87
+ //# sourceMappingURL=$retry.d.ts.map
79
88
  //#endregion
80
89
  //#region src/errors/RetryCancelError.d.ts
81
90
  declare class RetryCancelError extends AlephaError {
82
91
  constructor();
83
92
  }
93
+ //# sourceMappingURL=RetryCancelError.d.ts.map
84
94
  //#endregion
85
95
  //#region src/errors/RetryTimeoutError.d.ts
86
96
  declare class RetryTimeoutError extends AlephaError {
87
97
  constructor(duration: number);
88
98
  }
99
+ //# sourceMappingURL=RetryTimeoutError.d.ts.map
100
+
89
101
  //#endregion
90
- export { $retry, RetryBackoffOptions, RetryCancelError, RetryDescriptor, RetryDescriptorOptions, RetryTimeoutError, createRetryHandler };
102
+ export { $retry, RetryBackoffOptions, RetryCancelError, RetryDescriptor, RetryDescriptorFn, RetryDescriptorOptions, RetryTimeoutError };
91
103
  //# sourceMappingURL=index.d.ts.map
package/router.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/router');
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/router.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ //#region src/providers/RouterProvider.d.ts
2
+ declare abstract class RouterProvider<T extends Route = Route> {
3
+ protected routePathRegex: RegExp;
4
+ protected tree: Tree<T>;
5
+ match(path: string): RouteMatch<T>;
6
+ protected push(route: T): void;
7
+ protected createRouteMatch(path: string): RouteMatch<T>;
8
+ protected mapParams(match: RouteMatch<T>): RouteMatch<T>;
9
+ protected createParts(path: string): string[];
10
+ }
11
+ interface RouteMatch<T extends Route> {
12
+ route?: T;
13
+ params?: Record<string, string>;
14
+ }
15
+ interface Route {
16
+ path: string;
17
+ /**
18
+ * Rename a param in the route.
19
+ * This is automatically filled when you have scenarios like:
20
+ * `/customers/:id` and `/customers/:userId/payments`
21
+ *
22
+ * In this case, `:id` will be renamed to `:userId` in the second route.
23
+ */
24
+ mapParams?: Record<string, string>;
25
+ }
26
+ interface Tree<T extends Route> {
27
+ route?: T;
28
+ children: {
29
+ [key: string]: Tree<T>;
30
+ };
31
+ param?: {
32
+ route?: T;
33
+ name: string;
34
+ children: {
35
+ [key: string]: Tree<T>;
36
+ };
37
+ };
38
+ wildcard?: {
39
+ route: T;
40
+ };
41
+ }
42
+ //# sourceMappingURL=RouterProvider.d.ts.map
43
+ //#endregion
44
+ export { Route, RouteMatch, RouterProvider, Tree };
45
+ //# sourceMappingURL=index.d.ts.map
package/router.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@alepha/router'