alepha 0.8.1 → 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.
package/react.d.ts CHANGED
@@ -1,19 +1,20 @@
1
- import * as _alepha_core11 from "alepha";
2
- import * as _alepha_core24 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 react20 from "react";
10
- import * as react23 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_runtime18 from "react/jsx-runtime";
13
- import * as react_jsx_runtime21 from "react/jsx-runtime";
14
- import * as react_jsx_runtime22 from "react/jsx-runtime";
15
- 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";
16
16
  import { Route, RouterProvider } from "alepha/router";
17
+ import { ServerStaticProvider } from "alepha/server/static";
17
18
  import { Root } from "react-dom/client";
18
19
 
19
20
  //#region src/components/ClientOnly.d.ts
@@ -34,20 +35,13 @@ interface ClientOnlyProps {
34
35
  declare const ClientOnly: (props: PropsWithChildren<ClientOnlyProps>) => ReactNode;
35
36
  //#endregion
36
37
  //#region src/descriptors/$page.d.ts
37
- declare const KEY = "PAGE";
38
38
  /**
39
39
  * Main descriptor for defining a React route in the application.
40
40
  */
41
41
  declare const $page: {
42
42
  <TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = any, TPropsParent extends object = TPropsParentDefault>(options: PageDescriptorOptions<TConfig, TProps, TPropsParent>): PageDescriptor<TConfig, TProps, TPropsParent>;
43
- [KIND]: string;
43
+ [KIND]: typeof PageDescriptor;
44
44
  };
45
- interface PageConfigSchema {
46
- query?: TSchema;
47
- params?: TSchema;
48
- }
49
- type TPropsDefault = any;
50
- type TPropsParentDefault = {};
51
45
  interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
52
46
  /**
53
47
  * Name your page.
@@ -111,14 +105,8 @@ interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSch
111
105
  *
112
106
  * If you still want to render at this pathname, add a child page with an empty path.
113
107
  */
114
- children?: Array<{
115
- [OPTIONS]: PageDescriptorOptions;
116
- }> | (() => Array<{
117
- [OPTIONS]: PageDescriptorOptions;
118
- }>);
119
- parent?: {
120
- [OPTIONS]: PageDescriptorOptions<PageConfigSchema, TPropsParent>;
121
- };
108
+ children?: Array<PageDescriptor> | (() => Array<PageDescriptor>);
109
+ parent?: PageDescriptor<PageConfigSchema, TPropsParent>;
122
110
  can?: () => boolean;
123
111
  errorHandler?: (error: Error) => ReactNode;
124
112
  /**
@@ -137,15 +125,20 @@ interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSch
137
125
  afterHandler?: (request: ServerRequest) => any;
138
126
  cache?: ServerRouteCache;
139
127
  }
140
- interface PageDescriptor<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
141
- [KIND]: typeof KEY;
142
- [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;
143
130
  /**
144
131
  * For testing or build purposes, this will render the page (with or without the HTML layout) and return the HTML and context.
145
132
  * Only valid for server-side rendering, it will throw an error if called on the client-side.
146
133
  */
147
- render: (options?: PageDescriptorRenderOptions) => Promise<PageDescriptorRenderResult>;
134
+ render(options?: PageDescriptorRenderOptions): Promise<PageDescriptorRenderResult>;
135
+ }
136
+ interface PageConfigSchema {
137
+ query?: TSchema;
138
+ params?: TSchema;
148
139
  }
140
+ type TPropsDefault = any;
141
+ type TPropsParentDefault = {};
149
142
  interface PageDescriptorRenderOptions {
150
143
  params?: Record<string, string>;
151
144
  query?: Record<string, string>;
@@ -161,16 +154,17 @@ interface PageRequestConfig<TConfig extends PageConfigSchema = PageConfigSchema>
161
154
  query: TConfig["query"] extends TSchema ? Static<TConfig["query"]> : Record<string, string>;
162
155
  }
163
156
  type PageResolve<TConfig extends PageConfigSchema = PageConfigSchema, TPropsParent extends object = TPropsParentDefault> = PageRequestConfig<TConfig> & TPropsParent & PageReactContext;
157
+ //# sourceMappingURL=$page.d.ts.map
164
158
  //#endregion
165
159
  //#region src/providers/PageDescriptorProvider.d.ts
166
- declare const envSchema$1: _alepha_core11.TObject<{
167
- REACT_STRICT_MODE: _alepha_core11.TBoolean;
160
+ declare const envSchema$1: _alepha_core8.TObject<{
161
+ REACT_STRICT_MODE: _alepha_core8.TBoolean;
168
162
  }>;
169
163
  declare module "alepha" {
170
164
  interface Env extends Partial<Static<typeof envSchema$1>> {}
171
165
  }
172
166
  declare class PageDescriptorProvider {
173
- protected readonly log: _alepha_core11.Logger;
167
+ protected readonly log: _alepha_core8.Logger;
174
168
  protected readonly env: {
175
169
  REACT_STRICT_MODE: boolean;
176
170
  };
@@ -195,14 +189,8 @@ declare class PageDescriptorProvider {
195
189
  }, params?: Record<string, any>): string;
196
190
  compile(path: string, params?: Record<string, string>): string;
197
191
  protected renderView(index: number, path: string, view: ReactNode | undefined, page: PageRoute): ReactNode;
198
- protected readonly configure: _alepha_core11.HookDescriptor<"configure">;
199
- protected map(pages: Array<{
200
- value: {
201
- [OPTIONS]: PageDescriptorOptions;
202
- };
203
- }>, target: {
204
- [OPTIONS]: PageDescriptorOptions;
205
- }): PageRouteEntry;
192
+ protected readonly configure: _alepha_core8.HookDescriptor<"configure">;
193
+ protected map(pages: Array<PageDescriptor>, target: PageDescriptor): PageRouteEntry;
206
194
  add(entry: PageRouteEntry): void;
207
195
  protected createMatch(page: PageRoute): string;
208
196
  protected _next: number;
@@ -284,11 +272,11 @@ interface BrowserRoute extends Route {
284
272
  page: PageRoute;
285
273
  }
286
274
  declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
287
- protected readonly log: _alepha_core24.Logger;
275
+ protected readonly log: _alepha_core14.Logger;
288
276
  protected readonly alepha: Alepha;
289
277
  protected readonly pageDescriptorProvider: PageDescriptorProvider;
290
278
  add(entry: PageRouteEntry): void;
291
- protected readonly configure: _alepha_core24.HookDescriptor<"configure">;
279
+ protected readonly configure: _alepha_core14.HookDescriptor<"configure">;
292
280
  transition(url: URL, options?: TransitionOptions): Promise<RouterRenderResult>;
293
281
  root(state: RouterState, context: PageReactContext): ReactNode;
294
282
  }
@@ -296,7 +284,7 @@ declare class BrowserRouterProvider extends RouterProvider<BrowserRoute> {
296
284
  //#endregion
297
285
  //#region src/providers/ReactBrowserProvider.d.ts
298
286
  declare class ReactBrowserProvider {
299
- protected readonly log: _alepha_core16.Logger;
287
+ protected readonly log: _alepha_core12.Logger;
300
288
  protected readonly client: LinkProvider;
301
289
  protected readonly alepha: Alepha;
302
290
  protected readonly router: BrowserRouterProvider;
@@ -320,7 +308,7 @@ declare class ReactBrowserProvider {
320
308
  * Get embedded layers from the server.
321
309
  */
322
310
  protected getHydrationState(): ReactHydrationState | undefined;
323
- readonly ready: _alepha_core16.HookDescriptor<"ready">;
311
+ readonly ready: _alepha_core12.HookDescriptor<"ready">;
324
312
  }
325
313
  interface RouterGoOptions {
326
314
  replace?: boolean;
@@ -378,7 +366,7 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
378
366
  to: string | PageDescriptor;
379
367
  children?: React.ReactNode;
380
368
  }
381
- declare const Link: (props: LinkProps) => react_jsx_runtime18.JSX.Element | null;
369
+ declare const Link: (props: LinkProps) => react_jsx_runtime1.JSX.Element | null;
382
370
  //#endregion
383
371
  //#region src/components/NestedView.d.ts
384
372
  interface NestedViewProps {
@@ -405,10 +393,10 @@ interface NestedViewProps {
405
393
  * }
406
394
  * ```
407
395
  */
408
- declare const NestedView: (props: NestedViewProps) => react_jsx_runtime21.JSX.Element;
396
+ declare const NestedView: (props: NestedViewProps) => react_jsx_runtime0.JSX.Element;
409
397
  //#endregion
410
398
  //#region src/components/NotFound.d.ts
411
- declare function NotFoundPage(): react_jsx_runtime22.JSX.Element;
399
+ declare function NotFoundPage(): react_jsx_runtime2.JSX.Element;
412
400
  //# sourceMappingURL=NotFound.d.ts.map
413
401
  //#endregion
414
402
  //#region src/contexts/RouterContext.d.ts
@@ -417,7 +405,7 @@ interface RouterContextValue {
417
405
  state: RouterState;
418
406
  context: PageReactContext;
419
407
  }
420
- declare const RouterContext: react20.Context<RouterContextValue | undefined>;
408
+ declare const RouterContext: react0$1.Context<RouterContextValue | undefined>;
421
409
  //# sourceMappingURL=RouterContext.d.ts.map
422
410
  //#endregion
423
411
  //#region src/contexts/RouterLayerContext.d.ts
@@ -425,7 +413,7 @@ interface RouterLayerContextValue {
425
413
  index: number;
426
414
  path: string;
427
415
  }
428
- declare const RouterLayerContext: react23.Context<RouterLayerContextValue | undefined>;
416
+ declare const RouterLayerContext: react0.Context<RouterLayerContextValue | undefined>;
429
417
  //# sourceMappingURL=RouterLayerContext.d.ts.map
430
418
  //#endregion
431
419
  //#region src/hooks/RouterHookApi.d.ts
@@ -550,11 +538,11 @@ declare const useRouterState: () => RouterState;
550
538
 
551
539
  //#endregion
552
540
  //#region src/providers/ReactServerProvider.d.ts
553
- declare const envSchema: _alepha_core1.TObject<{
554
- REACT_SERVER_DIST: _alepha_core1.TString;
555
- REACT_SERVER_PREFIX: _alepha_core1.TString;
556
- REACT_SSR_ENABLED: _alepha_core1.TOptional<_alepha_core1.TBoolean>;
557
- 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;
558
546
  }>;
559
547
  declare module "alepha" {
560
548
  interface Env extends Partial<Static<typeof envSchema>> {}
@@ -564,7 +552,7 @@ declare module "alepha" {
564
552
  }
565
553
  }
566
554
  declare class ReactServerProvider {
567
- protected readonly log: _alepha_core1.Logger;
555
+ protected readonly log: _alepha_core0$1.Logger;
568
556
  protected readonly alepha: Alepha;
569
557
  protected readonly pageDescriptorProvider: PageDescriptorProvider;
570
558
  protected readonly serverStaticProvider: ServerStaticProvider;
@@ -577,7 +565,7 @@ declare class ReactServerProvider {
577
565
  REACT_ROOT_ID: string;
578
566
  };
579
567
  protected readonly ROOT_DIV_REGEX: RegExp;
580
- readonly onConfigure: _alepha_core1.HookDescriptor<"configure">;
568
+ readonly onConfigure: _alepha_core0$1.HookDescriptor<"configure">;
581
569
  get template(): string;
582
570
  protected registerPages(templateLoader: TemplateLoader): Promise<void>;
583
571
  protected getPublicDirectory(): string;
@@ -651,134 +639,10 @@ declare module "alepha" {
651
639
  * It delivers seamless server-side rendering, automatic code splitting, and client-side navigation with full
652
640
  * type safety and schema validation for route parameters and data.
653
641
  *
654
- * **Key Features:**
655
- * - Declarative page definition with `$page` descriptor
656
- * - Server-side rendering (SSR) with automatic hydration
657
- * - Type-safe routing with parameter validation
658
- * - Schema-based data resolution and validation
659
- * - SEO-friendly meta tag management
660
- * - Automatic code splitting and lazy loading
661
- * - Client-side navigation with browser history
662
- *
663
- * **Basic Usage:**
664
- * ```ts
665
- * import { Alepha, run, t } from "alepha";
666
- * import { AlephaReact, $page } from "alepha/react";
667
- *
668
- * class AppRoutes {
669
- * // Home page
670
- * home = $page({
671
- * path: "/",
672
- * component: () => (
673
- * <div>
674
- * <h1>Welcome to Alepha</h1>
675
- * <p>Build amazing React applications!</p>
676
- * </div>
677
- * ),
678
- * });
679
- *
680
- * // About page with meta tags
681
- * about = $page({
682
- * path: "/about",
683
- * head: {
684
- * title: "About Us",
685
- * description: "Learn more about our mission",
686
- * },
687
- * component: () => (
688
- * <div>
689
- * <h1>About Us</h1>
690
- * <p>Learn more about our mission.</p>
691
- * </div>
692
- * ),
693
- * });
694
- * }
695
- *
696
- * const alepha = Alepha.create()
697
- * .with(AlephaReact)
698
- * .with(AppRoutes);
699
- *
700
- * run(alepha);
701
- * ```
702
- *
703
- * **Dynamic Routes with Parameters:**
704
- * ```tsx
705
- * class UserRoutes {
706
- * userProfile = $page({
707
- * path: "/users/:id",
708
- * schema: {
709
- * params: t.object({
710
- * id: t.string(),
711
- * }),
712
- * },
713
- * resolve: async ({ params }) => {
714
- * // Fetch user data server-side
715
- * const user = await getUserById(params.id);
716
- * return { user };
717
- * },
718
- * head: ({ user }) => ({
719
- * title: `${user.name} - Profile`,
720
- * description: `View ${user.name}'s profile`,
721
- * }),
722
- * component: ({ user }) => (
723
- * <div>
724
- * <h1>{user.name}</h1>
725
- * <p>Email: {user.email}</p>
726
- * </div>
727
- * ),
728
- * });
729
- *
730
- * userSettings = $page({
731
- * path: "/users/:id/settings",
732
- * schema: {
733
- * params: t.object({
734
- * id: t.string(),
735
- * }),
736
- * },
737
- * component: ({ params }) => (
738
- * <UserSettings userId={params.id} />
739
- * ),
740
- * });
741
- * }
742
- * ```
743
- *
744
- * **Static Generation:**
745
- * ```tsx
746
- * class BlogRoutes {
747
- * blogPost = $page({
748
- * path: "/blog/:slug",
749
- * schema: {
750
- * params: t.object({
751
- * slug: t.string(),
752
- * }),
753
- * },
754
- * static: {
755
- * entries: [
756
- * { params: { slug: "getting-started" } },
757
- * { params: { slug: "advanced-features" } },
758
- * { params: { slug: "deployment" } },
759
- * ],
760
- * },
761
- * resolve: ({ params }) => {
762
- * const post = getBlogPost(params.slug);
763
- * return { post };
764
- * },
765
- * component: ({ post }) => (
766
- * <article>
767
- * <h1>{post.title}</h1>
768
- * <div>{post.content}</div>
769
- * </article>
770
- * ),
771
- * });
772
- * }
773
- * ```
774
- *
775
642
  * @see {@link $page}
776
643
  * @module alepha.react
777
644
  */
778
- declare class AlephaReact implements Module {
779
- readonly name = "alepha.react";
780
- readonly $services: (alepha: Alepha) => Alepha;
781
- }
645
+ declare const AlephaReact: _alepha_core0.ModuleDescriptor;
782
646
  //# sourceMappingURL=index.d.ts.map
783
647
 
784
648
  //#endregion
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
@@ -16,23 +19,23 @@ type RedisClient = RedisClientType<{}, {}, {}, 3, {
16
19
  type RedisClientOptions = Parameters<typeof createClient>[0];
17
20
  type RedisSetOptions = SetOptions;
18
21
  /**
19
- * Redis client provider.
20
- */
22
+ * Redis client provider.
23
+ */
21
24
  declare class RedisProvider {
22
25
  protected readonly log: Logger;
23
26
  protected readonly alepha: Alepha;
24
27
  protected readonly env: Static<typeof envSchema>;
25
28
  protected readonly client: RedisClient;
26
29
  get publisher(): RedisClient;
27
- protected readonly start: HookDescriptor<"start">;
28
- protected readonly stop: HookDescriptor<"stop">;
30
+ protected readonly start: _alepha_core2.HookDescriptor<"start">;
31
+ protected readonly stop: _alepha_core2.HookDescriptor<"stop">;
29
32
  /**
30
- * Connect to the Redis server.
31
- */
33
+ * Connect to the Redis server.
34
+ */
32
35
  connect(): Promise<void>;
33
36
  /**
34
- * Close the connection to the Redis server.
35
- */
37
+ * Close the connection to the Redis server.
38
+ */
36
39
  close(): Promise<void>;
37
40
  duplicate(options?: Partial<RedisClientOptions>): RedisClient;
38
41
  get(key: string): Promise<Buffer | undefined>;
@@ -41,8 +44,8 @@ declare class RedisProvider {
41
44
  keys(pattern: string): Promise<string[]>;
42
45
  del(keys: string[]): Promise<void>;
43
46
  /**
44
- * Redis subscriber client factory method.
45
- */
47
+ * Redis subscriber client factory method.
48
+ */
46
49
  protected createClient(): RedisClient;
47
50
  }
48
51
  //#endregion
@@ -53,15 +56,27 @@ declare class RedisSubscriberProvider {
53
56
  protected readonly redisProvider: RedisProvider;
54
57
  protected readonly client: RedisClient;
55
58
  get subscriber(): RedisClient;
56
- protected readonly start: HookDescriptor<"start">;
57
- protected readonly stop: HookDescriptor<"stop">;
59
+ protected readonly start: _alepha_core0$1.HookDescriptor<"start">;
60
+ protected readonly stop: _alepha_core0$1.HookDescriptor<"stop">;
58
61
  connect(): Promise<void>;
59
62
  close(): Promise<void>;
60
63
  /**
61
- * Redis subscriber client factory method.
62
- */
64
+ * Redis subscriber client factory method.
65
+ */
63
66
  protected createClient(): RedisClient;
64
67
  }
68
+ //# sourceMappingURL=RedisSubscriberProvider.d.ts.map
65
69
  //#endregion
66
- 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 };
67
82
  //# sourceMappingURL=index.d.ts.map
package/retry.d.ts CHANGED
@@ -1,92 +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
6
  /**
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: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>) => RetryDescriptor<T>;
11
- // ---------------------------------------------------------------------------------------------------------------------
12
- // TODO: move to RetryProvider
13
- declare const createRetryHandler: <T extends (...args: any[]) => any>(opts: RetryDescriptorOptions<T>, dateTimeProvider: DateTimeProvider, appAbortController?: AbortController) => RetryDescriptor<T>;
14
- // ---------------------------------------------------------------------------------------------------------------------
15
- interface RetryBackoffOptions {
16
- /**
17
- * Initial delay in milliseconds.
18
- *
19
- * @default 200
20
- */
21
- initial?: number;
22
- /**
23
- * Multiplier for each subsequent delay.
24
- *
25
- * @default 2
26
- */
27
- factor?: number;
28
- /**
29
- * Maximum delay in milliseconds.
30
- */
31
- max?: number;
32
- /**
33
- * If true, adds a random jitter to the delay to prevent thundering herd.
34
- *
35
- * @default true
36
- */
37
- jitter?: boolean;
38
- }
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
+ };
39
14
  interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
40
15
  /**
41
- * The function to retry.
42
- */
16
+ * The function to retry.
17
+ */
43
18
  handler: T;
44
19
  /**
45
- * The maximum number of attempts.
46
- *
47
- * @default 3
48
- */
20
+ * The maximum number of attempts.
21
+ *
22
+ * @default 3
23
+ */
49
24
  max?: number;
50
25
  /**
51
- * The backoff strategy for delays between retries.
52
- * Can be a fixed number (in ms) or a configuration object for exponential backoff.
53
- *
54
- * @default { initial: 200, factor: 2, jitter: true }
55
- */
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
+ */
56
31
  backoff?: number | RetryBackoffOptions;
57
32
  /**
58
- * An overall time limit for all retry attempts combined.
59
- *
60
- * e.g., `[5, 'seconds']`
61
- */
33
+ * An overall time limit for all retry attempts combined.
34
+ *
35
+ * e.g., `[5, 'seconds']`
36
+ */
62
37
  maxDuration?: DurationLike;
63
38
  /**
64
- * A function that determines if a retry should be attempted based on the error.
65
- *
66
- * @default (error) => true (retries on any error)
67
- */
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
+ */
68
43
  when?: (error: Error) => boolean;
69
44
  /**
70
- * A custom callback for when a retry attempt fails.
71
- * This is called before the delay.
72
- */
45
+ * A custom callback for when a retry attempt fails.
46
+ * This is called before the delay.
47
+ */
73
48
  onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;
74
49
  /**
75
- * An AbortSignal to allow for external cancellation of the retry loop.
76
- */
50
+ * An AbortSignal to allow for external cancellation of the retry loop.
51
+ */
77
52
  signal?: AbortSignal;
78
53
  }
79
- 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
80
88
  //#endregion
81
89
  //#region src/errors/RetryCancelError.d.ts
82
90
  declare class RetryCancelError extends AlephaError {
83
91
  constructor();
84
92
  }
93
+ //# sourceMappingURL=RetryCancelError.d.ts.map
85
94
  //#endregion
86
95
  //#region src/errors/RetryTimeoutError.d.ts
87
96
  declare class RetryTimeoutError extends AlephaError {
88
97
  constructor(duration: number);
89
98
  }
99
+ //# sourceMappingURL=RetryTimeoutError.d.ts.map
100
+
90
101
  //#endregion
91
- export { $retry, RetryBackoffOptions, RetryCancelError, RetryDescriptor, RetryDescriptorOptions, RetryTimeoutError, createRetryHandler };
102
+ export { $retry, RetryBackoffOptions, RetryCancelError, RetryDescriptor, RetryDescriptorFn, RetryDescriptorOptions, RetryTimeoutError };
92
103
  //# sourceMappingURL=index.d.ts.map
package/router.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  //#region src/providers/RouterProvider.d.ts
2
- declare class RouterProvider<T extends Route = Route> {
2
+ declare abstract class RouterProvider<T extends Route = Route> {
3
3
  protected routePathRegex: RegExp;
4
4
  protected tree: Tree<T>;
5
- readonly routes: T[];
6
- push(route: T): void;
7
5
  match(path: string): RouteMatch<T>;
6
+ protected push(route: T): void;
8
7
  protected createRouteMatch(path: string): RouteMatch<T>;
9
8
  protected mapParams(match: RouteMatch<T>): RouteMatch<T>;
10
9
  protected createParts(path: string): string[];
@@ -16,12 +15,12 @@ interface RouteMatch<T extends Route> {
16
15
  interface Route {
17
16
  path: string;
18
17
  /**
19
- * Rename a param in the route.
20
- * This is automatically filled when you have scenarios like:
21
- * `/customers/:id` and `/customers/:userId/payments`
22
- *
23
- * In this case, `:id` will be renamed to `:userId` in the second route.
24
- */
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
+ */
25
24
  mapParams?: Record<string, string>;
26
25
  }
27
26
  interface Tree<T extends Route> {
@@ -40,6 +39,7 @@ interface Tree<T extends Route> {
40
39
  route: T;
41
40
  };
42
41
  }
42
+ //# sourceMappingURL=RouterProvider.d.ts.map
43
43
  //#endregion
44
44
  export { Route, RouteMatch, RouterProvider, Tree };
45
45
  //# sourceMappingURL=index.d.ts.map