alepha 0.12.1 → 0.13.1
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/dist/api-notifications/index.d.ts +111 -111
- package/dist/api-users/index.d.ts +1240 -1240
- package/dist/api-verifications/index.d.ts +94 -94
- package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
- package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
- package/dist/cli/index.d.ts +3 -11
- package/dist/cli/index.js +106 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/email/index.js +71 -73
- package/dist/email/index.js.map +1 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/index.js.map +1 -1
- package/dist/queue/index.d.ts +4 -4
- package/dist/redis/index.d.ts +10 -10
- package/dist/retry/index.d.ts +1 -1
- package/dist/retry/index.js +2 -2
- package/dist/retry/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +6 -6
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server-auth/index.d.ts +193 -193
- package/dist/server-health/index.d.ts +17 -17
- package/dist/server-links/index.d.ts +34 -34
- package/dist/server-metrics/index.js +170 -174
- package/dist/server-metrics/index.js.map +1 -1
- package/dist/server-security/index.d.ts +9 -9
- package/dist/vite/index.js +4 -5
- package/dist/vite/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/package.json +52 -103
- package/src/cli/apps/AlephaPackageBuilderCli.ts +7 -2
- package/src/cli/assets/appRouterTs.ts +9 -0
- package/src/cli/assets/indexHtml.ts +2 -1
- package/src/cli/assets/mainBrowserTs.ts +10 -0
- package/src/cli/commands/CoreCommands.ts +6 -5
- package/src/cli/commands/DrizzleCommands.ts +65 -57
- package/src/cli/commands/VerifyCommands.ts +1 -1
- package/src/cli/services/ProjectUtils.ts +44 -38
- package/src/orm/providers/DrizzleKitProvider.ts +1 -1
- package/src/retry/descriptors/$retry.ts +5 -3
- package/src/server/providers/NodeHttpServerProvider.ts +1 -1
- package/src/vite/helpers/boot.ts +3 -3
- package/dist/api-files/index.cjs +0 -1293
- package/dist/api-files/index.cjs.map +0 -1
- package/dist/api-files/index.d.cts +0 -829
- package/dist/api-jobs/index.cjs +0 -274
- package/dist/api-jobs/index.cjs.map +0 -1
- package/dist/api-jobs/index.d.cts +0 -654
- package/dist/api-notifications/index.cjs +0 -380
- package/dist/api-notifications/index.cjs.map +0 -1
- package/dist/api-notifications/index.d.cts +0 -289
- package/dist/api-parameters/index.cjs +0 -66
- package/dist/api-parameters/index.cjs.map +0 -1
- package/dist/api-parameters/index.d.cts +0 -84
- package/dist/api-users/index.cjs +0 -6009
- package/dist/api-users/index.cjs.map +0 -1
- package/dist/api-users/index.d.cts +0 -4740
- package/dist/api-verifications/index.cjs +0 -407
- package/dist/api-verifications/index.cjs.map +0 -1
- package/dist/api-verifications/index.d.cts +0 -207
- package/dist/batch/index.cjs +0 -408
- package/dist/batch/index.cjs.map +0 -1
- package/dist/batch/index.d.cts +0 -330
- package/dist/bin/index.cjs +0 -17
- package/dist/bin/index.cjs.map +0 -1
- package/dist/bin/index.d.cts +0 -1
- package/dist/bucket/index.cjs +0 -303
- package/dist/bucket/index.cjs.map +0 -1
- package/dist/bucket/index.d.cts +0 -355
- package/dist/cache/index.cjs +0 -241
- package/dist/cache/index.cjs.map +0 -1
- package/dist/cache/index.d.cts +0 -202
- package/dist/cache-redis/index.cjs +0 -84
- package/dist/cache-redis/index.cjs.map +0 -1
- package/dist/cache-redis/index.d.cts +0 -40
- package/dist/cli/chunk-DSlc6foC.cjs +0 -43
- package/dist/cli/dist-BBPjuQ56.js +0 -2778
- package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
- package/dist/cli/index.cjs +0 -1241
- package/dist/cli/index.cjs.map +0 -1
- package/dist/cli/index.d.cts +0 -422
- package/dist/command/index.cjs +0 -693
- package/dist/command/index.cjs.map +0 -1
- package/dist/command/index.d.cts +0 -340
- package/dist/core/index.cjs +0 -2264
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -1927
- package/dist/datetime/index.cjs +0 -318
- package/dist/datetime/index.cjs.map +0 -1
- package/dist/datetime/index.d.cts +0 -145
- package/dist/email/index.cjs +0 -10874
- package/dist/email/index.cjs.map +0 -1
- package/dist/email/index.d.cts +0 -186
- package/dist/fake/index.cjs +0 -34641
- package/dist/fake/index.cjs.map +0 -1
- package/dist/fake/index.d.cts +0 -74
- package/dist/file/index.cjs +0 -1212
- package/dist/file/index.cjs.map +0 -1
- package/dist/file/index.d.cts +0 -698
- package/dist/lock/index.cjs +0 -226
- package/dist/lock/index.cjs.map +0 -1
- package/dist/lock/index.d.cts +0 -361
- package/dist/lock-redis/index.cjs +0 -113
- package/dist/lock-redis/index.cjs.map +0 -1
- package/dist/lock-redis/index.d.cts +0 -24
- package/dist/logger/index.cjs +0 -521
- package/dist/logger/index.cjs.map +0 -1
- package/dist/logger/index.d.cts +0 -281
- package/dist/orm/index.cjs +0 -2986
- package/dist/orm/index.cjs.map +0 -1
- package/dist/orm/index.d.cts +0 -2213
- package/dist/queue/index.cjs +0 -1044
- package/dist/queue/index.cjs.map +0 -1
- package/dist/queue/index.d.cts +0 -1265
- package/dist/queue-redis/index.cjs +0 -873
- package/dist/queue-redis/index.cjs.map +0 -1
- package/dist/queue-redis/index.d.cts +0 -82
- package/dist/redis/index.cjs +0 -153
- package/dist/redis/index.cjs.map +0 -1
- package/dist/redis/index.d.cts +0 -82
- package/dist/retry/index.cjs +0 -146
- package/dist/retry/index.cjs.map +0 -1
- package/dist/retry/index.d.cts +0 -172
- package/dist/router/index.cjs +0 -111
- package/dist/router/index.cjs.map +0 -1
- package/dist/router/index.d.cts +0 -46
- package/dist/scheduler/index.cjs +0 -576
- package/dist/scheduler/index.cjs.map +0 -1
- package/dist/scheduler/index.d.cts +0 -145
- package/dist/security/index.cjs +0 -2402
- package/dist/security/index.cjs.map +0 -1
- package/dist/security/index.d.cts +0 -598
- package/dist/server/index.cjs +0 -1680
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -810
- package/dist/server-auth/index.cjs +0 -3146
- package/dist/server-auth/index.cjs.map +0 -1
- package/dist/server-auth/index.d.cts +0 -1164
- package/dist/server-cache/index.cjs +0 -252
- package/dist/server-cache/index.cjs.map +0 -1
- package/dist/server-cache/index.d.cts +0 -164
- package/dist/server-compress/index.cjs +0 -141
- package/dist/server-compress/index.cjs.map +0 -1
- package/dist/server-compress/index.d.cts +0 -38
- package/dist/server-cookies/index.cjs +0 -234
- package/dist/server-cookies/index.cjs.map +0 -1
- package/dist/server-cookies/index.d.cts +0 -144
- package/dist/server-cors/index.cjs +0 -201
- package/dist/server-cors/index.cjs.map +0 -1
- package/dist/server-cors/index.d.cts +0 -140
- package/dist/server-health/index.cjs +0 -62
- package/dist/server-health/index.cjs.map +0 -1
- package/dist/server-health/index.d.cts +0 -58
- package/dist/server-helmet/index.cjs +0 -131
- package/dist/server-helmet/index.cjs.map +0 -1
- package/dist/server-helmet/index.d.cts +0 -97
- package/dist/server-links/index.cjs +0 -992
- package/dist/server-links/index.cjs.map +0 -1
- package/dist/server-links/index.d.cts +0 -513
- package/dist/server-metrics/index.cjs +0 -4535
- package/dist/server-metrics/index.cjs.map +0 -1
- package/dist/server-metrics/index.d.cts +0 -35
- package/dist/server-multipart/index.cjs +0 -237
- package/dist/server-multipart/index.cjs.map +0 -1
- package/dist/server-multipart/index.d.cts +0 -50
- package/dist/server-proxy/index.cjs +0 -186
- package/dist/server-proxy/index.cjs.map +0 -1
- package/dist/server-proxy/index.d.cts +0 -234
- package/dist/server-rate-limit/index.cjs +0 -241
- package/dist/server-rate-limit/index.cjs.map +0 -1
- package/dist/server-rate-limit/index.d.cts +0 -183
- package/dist/server-security/index.cjs +0 -316
- package/dist/server-security/index.cjs.map +0 -1
- package/dist/server-security/index.d.cts +0 -173
- package/dist/server-static/index.cjs +0 -170
- package/dist/server-static/index.cjs.map +0 -1
- package/dist/server-static/index.d.cts +0 -121
- package/dist/server-swagger/index.cjs +0 -1021
- package/dist/server-swagger/index.cjs.map +0 -1
- package/dist/server-swagger/index.d.cts +0 -382
- package/dist/sms/index.cjs +0 -221
- package/dist/sms/index.cjs.map +0 -1
- package/dist/sms/index.d.cts +0 -130
- package/dist/thread/index.cjs +0 -350
- package/dist/thread/index.cjs.map +0 -1
- package/dist/thread/index.d.cts +0 -260
- package/dist/topic/index.cjs +0 -282
- package/dist/topic/index.cjs.map +0 -1
- package/dist/topic/index.d.cts +0 -523
- package/dist/topic-redis/index.cjs +0 -71
- package/dist/topic-redis/index.cjs.map +0 -1
- package/dist/topic-redis/index.d.cts +0 -42
- package/dist/vite/index.cjs +0 -1077
- package/dist/vite/index.cjs.map +0 -1
- package/dist/vite/index.d.cts +0 -542
- package/dist/websocket/index.cjs +0 -1117
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -861
package/dist/queue/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as alepha1 from "alepha";
|
|
2
2
|
import { Alepha, Descriptor, KIND, Service, Static, TSchema } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as alepha_logger0 from "alepha/logger";
|
|
4
4
|
import { DateTimeProvider } from "alepha/datetime";
|
|
5
5
|
|
|
6
6
|
//#region src/queue/interfaces/QueueJob.d.ts
|
|
@@ -600,7 +600,7 @@ interface JobWaiter {
|
|
|
600
600
|
* - Scenarios where job persistence across restarts is not required
|
|
601
601
|
*/
|
|
602
602
|
declare class MemoryQueueProvider extends QueueProvider {
|
|
603
|
-
protected readonly log:
|
|
603
|
+
protected readonly log: alepha_logger0.Logger;
|
|
604
604
|
protected messageQueues: Record<string, string[]>;
|
|
605
605
|
protected messageWaiters: Set<MessageWaiter>;
|
|
606
606
|
protected jobs: Map<string, Map<string, QueueJob>>;
|
|
@@ -947,7 +947,7 @@ interface QueueDescriptorOptions<T extends TSchema> {
|
|
|
947
947
|
removeOnFail?: boolean | number;
|
|
948
948
|
}
|
|
949
949
|
declare class QueueDescriptor<T extends TSchema> extends Descriptor<QueueDescriptorOptions<T>> {
|
|
950
|
-
protected readonly log:
|
|
950
|
+
protected readonly log: alepha_logger0.Logger;
|
|
951
951
|
readonly provider: QueueProvider | MemoryQueueProvider;
|
|
952
952
|
/**
|
|
953
953
|
* Push one or more payloads to the queue for background processing.
|
|
@@ -1180,7 +1180,7 @@ declare module "alepha" {
|
|
|
1180
1180
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
1181
1181
|
}
|
|
1182
1182
|
declare class WorkerProvider {
|
|
1183
|
-
protected readonly log:
|
|
1183
|
+
protected readonly log: alepha_logger0.Logger;
|
|
1184
1184
|
protected readonly env: {
|
|
1185
1185
|
QUEUE_WORKER_BLOCKING_TIMEOUT: number;
|
|
1186
1186
|
QUEUE_WORKER_CONCURRENCY: number;
|
package/dist/redis/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha3 from "alepha";
|
|
2
2
|
import { Alepha, Static } from "alepha";
|
|
3
3
|
import { RedisClientType, SetOptions, createClient } from "@redis/client";
|
|
4
4
|
import * as alepha_logger0 from "alepha/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/redis/providers/RedisProvider.d.ts
|
|
7
|
-
declare const envSchema:
|
|
8
|
-
REDIS_PORT:
|
|
9
|
-
REDIS_HOST:
|
|
10
|
-
REDIS_PASSWORD:
|
|
7
|
+
declare const envSchema: alepha3.TObject<{
|
|
8
|
+
REDIS_PORT: alepha3.TInteger;
|
|
9
|
+
REDIS_HOST: alepha3.TString;
|
|
10
|
+
REDIS_PASSWORD: alepha3.TOptional<alepha3.TString>;
|
|
11
11
|
}>;
|
|
12
12
|
declare module "alepha" {
|
|
13
13
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -30,8 +30,8 @@ declare class RedisProvider {
|
|
|
30
30
|
};
|
|
31
31
|
protected readonly client: RedisClient;
|
|
32
32
|
get publisher(): RedisClient;
|
|
33
|
-
protected readonly start:
|
|
34
|
-
protected readonly stop:
|
|
33
|
+
protected readonly start: alepha3.HookDescriptor<"start">;
|
|
34
|
+
protected readonly stop: alepha3.HookDescriptor<"stop">;
|
|
35
35
|
/**
|
|
36
36
|
* Connect to the Redis server.
|
|
37
37
|
*/
|
|
@@ -59,8 +59,8 @@ declare class RedisSubscriberProvider {
|
|
|
59
59
|
protected readonly redisProvider: RedisProvider;
|
|
60
60
|
protected readonly client: RedisClient;
|
|
61
61
|
get subscriber(): RedisClient;
|
|
62
|
-
protected readonly start:
|
|
63
|
-
protected readonly stop:
|
|
62
|
+
protected readonly start: alepha3.HookDescriptor<"start">;
|
|
63
|
+
protected readonly stop: alepha3.HookDescriptor<"stop">;
|
|
64
64
|
connect(): Promise<void>;
|
|
65
65
|
close(): Promise<void>;
|
|
66
66
|
/**
|
|
@@ -76,7 +76,7 @@ declare class RedisSubscriberProvider {
|
|
|
76
76
|
* @see {@link RedisProvider}
|
|
77
77
|
* @module alepha.redis
|
|
78
78
|
*/
|
|
79
|
-
declare const AlephaRedis:
|
|
79
|
+
declare const AlephaRedis: alepha3.Service<alepha3.Module>;
|
|
80
80
|
//#endregion
|
|
81
81
|
export { AlephaRedis, RedisClient, RedisClientOptions, RedisProvider, RedisSetOptions, RedisSubscriberProvider };
|
|
82
82
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/retry/index.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
|
|
|
141
141
|
}
|
|
142
142
|
declare class RetryDescriptor<T extends (...args: any[]) => any> extends Descriptor<RetryDescriptorOptions<T>> {
|
|
143
143
|
protected readonly retryProvider: RetryProvider;
|
|
144
|
-
protected appAbortController
|
|
144
|
+
protected appAbortController?: AbortController;
|
|
145
145
|
constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>);
|
|
146
146
|
run(...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
147
147
|
}
|
package/dist/retry/index.js
CHANGED
|
@@ -108,12 +108,12 @@ var RetryDescriptor = class extends Descriptor {
|
|
|
108
108
|
appAbortController;
|
|
109
109
|
constructor(args) {
|
|
110
110
|
super(args);
|
|
111
|
-
this.appAbortController = new AbortController();
|
|
112
111
|
this.alepha.events.on("stop", () => {
|
|
113
|
-
this.appAbortController
|
|
112
|
+
this.appAbortController?.abort();
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
async run(...args) {
|
|
116
|
+
this.appAbortController ??= new AbortController();
|
|
117
117
|
return this.retryProvider.retry({
|
|
118
118
|
...this.options,
|
|
119
119
|
additionalSignal: this.appAbortController.signal
|
package/dist/retry/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["lastError: Error | undefined"],"sources":["../../src/retry/errors/RetryCancelError.ts","../../src/retry/errors/RetryTimeoutError.ts","../../src/retry/providers/RetryProvider.ts","../../src/retry/descriptors/$retry.ts","../../src/retry/index.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport class RetryCancelError extends AlephaError {\n constructor() {\n super(\"Retry operation was cancelled.\");\n this.name = \"RetryCancelError\";\n }\n}\n","import { AlephaError } from \"alepha\";\n\nexport class RetryTimeoutError extends AlephaError {\n constructor(duration: number) {\n super(`Retry operation timed out after ${duration}ms.`);\n this.name = \"RetryTimeoutError\";\n }\n}\n","import { $inject } from \"alepha\";\nimport { DateTimeProvider, type DurationLike } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { RetryCancelError } from \"../errors/RetryCancelError.ts\";\nimport { RetryTimeoutError } from \"../errors/RetryTimeoutError.ts\";\n\nexport interface RetryOptions<T extends (...args: any[]) => any> {\n /**\n * The function to retry.\n */\n handler: T;\n\n /**\n * The maximum number of attempts.\n *\n * @default 3\n */\n max?: number;\n\n /**\n * The backoff strategy for delays between retries.\n * Can be a fixed number (in ms) or a configuration object for exponential backoff.\n *\n * @default { initial: 200, factor: 2, jitter: true }\n */\n backoff?: number | RetryBackoffOptions;\n\n /**\n * An overall time limit for all retry attempts combined.\n *\n * e.g., `[5, 'seconds']`\n */\n maxDuration?: DurationLike;\n\n /**\n * A function that determines if a retry should be attempted based on the error.\n *\n * @default (error) => true (retries on any error)\n */\n when?: (error: Error) => boolean;\n\n /**\n * A custom callback for when a retry attempt fails.\n * This is called before the delay.\n */\n onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;\n\n /**\n * An AbortSignal to allow for external cancellation of the retry loop.\n */\n signal?: AbortSignal;\n\n /**\n * An additional AbortSignal to combine with the provided signal.\n * Used internally by $retry to handle app lifecycle.\n */\n additionalSignal?: AbortSignal;\n}\n\nexport interface RetryBackoffOptions {\n /**\n * Initial delay in milliseconds.\n *\n * @default 200\n */\n initial?: number;\n\n /**\n * Multiplier for each subsequent delay.\n *\n * @default 2\n */\n factor?: number;\n\n /**\n * Maximum delay in milliseconds.\n */\n max?: number;\n\n /**\n * If true, adds a random jitter to the delay to prevent thundering herd.\n *\n * @default true\n */\n jitter?: boolean;\n}\n\n/**\n * Service for executing functions with automatic retry logic.\n * Supports exponential backoff, max duration, conditional retries, and cancellation.\n */\nexport class RetryProvider {\n protected readonly log = $logger();\n protected readonly dateTime = $inject(DateTimeProvider);\n\n /**\n * Execute a function with automatic retry logic.\n */\n async retry<T extends (...args: any[]) => any>(\n options: RetryOptions<T>,\n ...args: Parameters<T>\n ): Promise<ReturnType<T>> {\n const maxAttempts = options.max ?? 3;\n const when = options.when ?? (() => true);\n const { handler, onError } = options;\n\n let lastError: Error | undefined;\n const startTime = Date.now();\n\n const maxDurationMs = options.maxDuration\n ? this.dateTime.duration(options.maxDuration).asMilliseconds()\n : Infinity;\n\n // Combine user-provided signal with additional signal (e.g., app lifecycle)\n const signals = [options.signal, options.additionalSignal].filter(Boolean);\n const onAbort = () => {\n // Always set RetryCancelError when aborted, even if another error exists\n // This ensures cancellation takes precedence over retry errors\n lastError = new RetryCancelError();\n };\n\n // Add abort listeners to all signals\n for (const signal of signals) {\n signal?.addEventListener(\"abort\", onAbort);\n }\n\n // FIX BUG #8: Create combined signal ONCE at the start instead of on each backoff\n // This prevents memory leak from creating multiple AbortSignal.any() instances\n const waitSignals = [options.signal, options.additionalSignal].filter(\n Boolean,\n ) as AbortSignal[];\n const combinedSignal =\n waitSignals.length > 0 ? AbortSignal.any(waitSignals) : undefined;\n\n try {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n // Check for cancellation\n if (signals.some((signal) => signal?.aborted)) {\n throw new RetryCancelError();\n }\n\n // Check for timeout before attempting\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n try {\n const result = await handler(...args);\n\n // Check for timeout after handler execution\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n return result;\n } catch (err) {\n lastError = err as Error;\n\n // Check for timeout after error\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n // Log the error with warning level\n this.log.warn(\"Retry attempt failed\", {\n attempt,\n maxAttempts,\n remainingAttempts: maxAttempts - attempt,\n error: lastError.message,\n errorName: lastError.name,\n });\n\n if (!(err instanceof Error) || !when(err)) {\n throw err; // don't retry if it's not an Error or `when` returns false\n }\n\n // FIX BUG #7: Call onError BEFORE checking if this is the final attempt\n // This ensures onError is called for ALL failed attempts, including the last one\n if (onError) {\n onError(err, attempt, ...args);\n }\n\n if (attempt >= maxAttempts) {\n break; // will throw lastError after the loop\n }\n\n // Calculate and wait for backoff delay\n const delay = this.calculateBackoff(attempt, options.backoff);\n if (delay > 0) {\n await this.dateTime.wait(delay, { signal: combinedSignal });\n }\n\n // Check for timeout after backoff wait before next attempt\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n }\n }\n } finally {\n // Clean up listeners to prevent memory leaks\n for (const signal of signals) {\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n\n throw lastError;\n }\n\n /**\n * Calculate the backoff delay for a given attempt.\n */\n protected calculateBackoff(\n attempt: number,\n options?: number | RetryBackoffOptions,\n ): number {\n if (typeof options === \"number\") {\n return options;\n }\n\n const initial = options?.initial ?? 200;\n const factor = options?.factor ?? 2;\n const max = options?.max ?? 10000;\n const useJitter = options?.jitter !== false;\n\n const exponential = initial * factor ** (attempt - 1);\n let delay = Math.min(exponential, max);\n\n if (useJitter) {\n // Add a random amount of jitter (e.g., up to 50% of the delay)\n delay = delay * (1 + Math.random() * 0.5);\n }\n\n return Math.floor(delay);\n }\n}\n","import {\n $inject,\n createDescriptor,\n Descriptor,\n type DescriptorArgs,\n KIND,\n} from \"alepha\";\nimport type { DurationLike } from \"alepha/datetime\";\nimport type { RetryBackoffOptions } from \"../providers/RetryProvider.ts\";\nimport { RetryProvider } from \"../providers/RetryProvider.ts\";\n\n/**\n * Creates a function that automatically retries a handler upon failure,\n * with support for exponential backoff, max duration, and cancellation.\n */\nexport const $retry = <T extends (...args: any[]) => any>(\n options: RetryDescriptorOptions<T>,\n): RetryDescriptorFn<T> => {\n const instance = createDescriptor(RetryDescriptor, options);\n const fn = (...args: Parameters<T>) => instance.run(...args);\n return Object.setPrototypeOf(fn, instance) as RetryDescriptorFn<T>;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface RetryDescriptorOptions<T extends (...args: any[]) => any> {\n /**\n * The function to retry.\n */\n handler: T;\n\n /**\n * The maximum number of attempts.\n *\n * @default 3\n */\n max?: number;\n\n /**\n * The backoff strategy for delays between retries.\n * Can be a fixed number (in ms) or a configuration object for exponential backoff.\n *\n * @default { initial: 200, factor: 2, jitter: true }\n */\n backoff?: number | RetryBackoffOptions;\n\n /**\n * An overall time limit for all retry attempts combined.\n *\n * e.g., `[5, 'seconds']`\n */\n maxDuration?: DurationLike;\n\n /**\n * A function that determines if a retry should be attempted based on the error.\n *\n * @default (error) => true (retries on any error)\n */\n when?: (error: Error) => boolean;\n\n /**\n * A custom callback for when a retry attempt fails.\n * This is called before the delay.\n */\n onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;\n\n /**\n * An AbortSignal to allow for external cancellation of the retry loop.\n */\n signal?: AbortSignal;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class RetryDescriptor<\n T extends (...args: any[]) => any,\n> extends Descriptor<RetryDescriptorOptions<T>> {\n protected readonly retryProvider = $inject(RetryProvider);\n protected appAbortController: AbortController;\n\n constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>) {\n super(args);\n\n this.appAbortController = new AbortController();\n this.alepha.events.on(\"stop\", () => {\n this.appAbortController.abort();\n });\n }\n\n async run(...args: Parameters<T>): Promise<ReturnType<T>> {\n return this.retryProvider.retry(\n {\n ...this.options,\n additionalSignal: this.appAbortController.signal,\n },\n ...args,\n );\n }\n}\n\nexport interface RetryDescriptorFn<T extends (...args: any[]) => any>\n extends RetryDescriptor<T> {\n (...args: Parameters<T>): Promise<ReturnType<T>>;\n}\n\n$retry[KIND] = RetryDescriptor;\n","import { $module } from \"alepha\";\nimport { $retry } from \"./descriptors/$retry.ts\";\nimport { RetryProvider } from \"./providers/RetryProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./descriptors/$retry.ts\";\nexport * from \"./errors/RetryCancelError.ts\";\nexport * from \"./errors/RetryTimeoutError.ts\";\nexport * from \"./providers/RetryProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Retry mechanism provider for Alepha applications.\n *\n * @see {@link RetryProvider}\n * @module alepha.retry\n */\nexport const AlephaRetry = $module({\n name: \"alepha.retry\",\n descriptors: [$retry],\n services: [RetryProvider],\n});\n"],"mappings":";;;;;AAEA,IAAa,mBAAb,cAAsC,YAAY;CAChD,cAAc;AACZ,QAAM,iCAAiC;AACvC,OAAK,OAAO;;;;;;ACHhB,IAAa,oBAAb,cAAuC,YAAY;CACjD,YAAY,U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OAAO;IAC/B;;CAGJ,MAAM,IAAI,GAAG,MAA6C;AACxD,SAAO,KAAK,cAAc,MACxB;GACE,GAAG,KAAK;GACR,kBAAkB,KAAK,mBAAmB;GAC3C,EACD,GAAG,KACJ;;;AASL,OAAO,QAAQ;;;;;;;;;;ACtFf,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa,CAAC,OAAO;CACrB,UAAU,CAAC,cAAc;CAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["lastError: Error | undefined"],"sources":["../../src/retry/errors/RetryCancelError.ts","../../src/retry/errors/RetryTimeoutError.ts","../../src/retry/providers/RetryProvider.ts","../../src/retry/descriptors/$retry.ts","../../src/retry/index.ts"],"sourcesContent":["import { AlephaError } from \"alepha\";\n\nexport class RetryCancelError extends AlephaError {\n constructor() {\n super(\"Retry operation was cancelled.\");\n this.name = \"RetryCancelError\";\n }\n}\n","import { AlephaError } from \"alepha\";\n\nexport class RetryTimeoutError extends AlephaError {\n constructor(duration: number) {\n super(`Retry operation timed out after ${duration}ms.`);\n this.name = \"RetryTimeoutError\";\n }\n}\n","import { $inject } from \"alepha\";\nimport { DateTimeProvider, type DurationLike } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { RetryCancelError } from \"../errors/RetryCancelError.ts\";\nimport { RetryTimeoutError } from \"../errors/RetryTimeoutError.ts\";\n\nexport interface RetryOptions<T extends (...args: any[]) => any> {\n /**\n * The function to retry.\n */\n handler: T;\n\n /**\n * The maximum number of attempts.\n *\n * @default 3\n */\n max?: number;\n\n /**\n * The backoff strategy for delays between retries.\n * Can be a fixed number (in ms) or a configuration object for exponential backoff.\n *\n * @default { initial: 200, factor: 2, jitter: true }\n */\n backoff?: number | RetryBackoffOptions;\n\n /**\n * An overall time limit for all retry attempts combined.\n *\n * e.g., `[5, 'seconds']`\n */\n maxDuration?: DurationLike;\n\n /**\n * A function that determines if a retry should be attempted based on the error.\n *\n * @default (error) => true (retries on any error)\n */\n when?: (error: Error) => boolean;\n\n /**\n * A custom callback for when a retry attempt fails.\n * This is called before the delay.\n */\n onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;\n\n /**\n * An AbortSignal to allow for external cancellation of the retry loop.\n */\n signal?: AbortSignal;\n\n /**\n * An additional AbortSignal to combine with the provided signal.\n * Used internally by $retry to handle app lifecycle.\n */\n additionalSignal?: AbortSignal;\n}\n\nexport interface RetryBackoffOptions {\n /**\n * Initial delay in milliseconds.\n *\n * @default 200\n */\n initial?: number;\n\n /**\n * Multiplier for each subsequent delay.\n *\n * @default 2\n */\n factor?: number;\n\n /**\n * Maximum delay in milliseconds.\n */\n max?: number;\n\n /**\n * If true, adds a random jitter to the delay to prevent thundering herd.\n *\n * @default true\n */\n jitter?: boolean;\n}\n\n/**\n * Service for executing functions with automatic retry logic.\n * Supports exponential backoff, max duration, conditional retries, and cancellation.\n */\nexport class RetryProvider {\n protected readonly log = $logger();\n protected readonly dateTime = $inject(DateTimeProvider);\n\n /**\n * Execute a function with automatic retry logic.\n */\n async retry<T extends (...args: any[]) => any>(\n options: RetryOptions<T>,\n ...args: Parameters<T>\n ): Promise<ReturnType<T>> {\n const maxAttempts = options.max ?? 3;\n const when = options.when ?? (() => true);\n const { handler, onError } = options;\n\n let lastError: Error | undefined;\n const startTime = Date.now();\n\n const maxDurationMs = options.maxDuration\n ? this.dateTime.duration(options.maxDuration).asMilliseconds()\n : Infinity;\n\n // Combine user-provided signal with additional signal (e.g., app lifecycle)\n const signals = [options.signal, options.additionalSignal].filter(Boolean);\n const onAbort = () => {\n // Always set RetryCancelError when aborted, even if another error exists\n // This ensures cancellation takes precedence over retry errors\n lastError = new RetryCancelError();\n };\n\n // Add abort listeners to all signals\n for (const signal of signals) {\n signal?.addEventListener(\"abort\", onAbort);\n }\n\n // FIX BUG #8: Create combined signal ONCE at the start instead of on each backoff\n // This prevents memory leak from creating multiple AbortSignal.any() instances\n const waitSignals = [options.signal, options.additionalSignal].filter(\n Boolean,\n ) as AbortSignal[];\n const combinedSignal =\n waitSignals.length > 0 ? AbortSignal.any(waitSignals) : undefined;\n\n try {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n // Check for cancellation\n if (signals.some((signal) => signal?.aborted)) {\n throw new RetryCancelError();\n }\n\n // Check for timeout before attempting\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n try {\n const result = await handler(...args);\n\n // Check for timeout after handler execution\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n return result;\n } catch (err) {\n lastError = err as Error;\n\n // Check for timeout after error\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n\n // Log the error with warning level\n this.log.warn(\"Retry attempt failed\", {\n attempt,\n maxAttempts,\n remainingAttempts: maxAttempts - attempt,\n error: lastError.message,\n errorName: lastError.name,\n });\n\n if (!(err instanceof Error) || !when(err)) {\n throw err; // don't retry if it's not an Error or `when` returns false\n }\n\n // FIX BUG #7: Call onError BEFORE checking if this is the final attempt\n // This ensures onError is called for ALL failed attempts, including the last one\n if (onError) {\n onError(err, attempt, ...args);\n }\n\n if (attempt >= maxAttempts) {\n break; // will throw lastError after the loop\n }\n\n // Calculate and wait for backoff delay\n const delay = this.calculateBackoff(attempt, options.backoff);\n if (delay > 0) {\n await this.dateTime.wait(delay, { signal: combinedSignal });\n }\n\n // Check for timeout after backoff wait before next attempt\n if (Date.now() - startTime >= maxDurationMs) {\n throw new RetryTimeoutError(maxDurationMs);\n }\n }\n }\n } finally {\n // Clean up listeners to prevent memory leaks\n for (const signal of signals) {\n signal?.removeEventListener(\"abort\", onAbort);\n }\n }\n\n throw lastError;\n }\n\n /**\n * Calculate the backoff delay for a given attempt.\n */\n protected calculateBackoff(\n attempt: number,\n options?: number | RetryBackoffOptions,\n ): number {\n if (typeof options === \"number\") {\n return options;\n }\n\n const initial = options?.initial ?? 200;\n const factor = options?.factor ?? 2;\n const max = options?.max ?? 10000;\n const useJitter = options?.jitter !== false;\n\n const exponential = initial * factor ** (attempt - 1);\n let delay = Math.min(exponential, max);\n\n if (useJitter) {\n // Add a random amount of jitter (e.g., up to 50% of the delay)\n delay = delay * (1 + Math.random() * 0.5);\n }\n\n return Math.floor(delay);\n }\n}\n","import {\n $inject,\n createDescriptor,\n Descriptor,\n type DescriptorArgs,\n KIND,\n} from \"alepha\";\nimport type { DurationLike } from \"alepha/datetime\";\nimport type { RetryBackoffOptions } from \"../providers/RetryProvider.ts\";\nimport { RetryProvider } from \"../providers/RetryProvider.ts\";\n\n/**\n * Creates a function that automatically retries a handler upon failure,\n * with support for exponential backoff, max duration, and cancellation.\n */\nexport const $retry = <T extends (...args: any[]) => any>(\n options: RetryDescriptorOptions<T>,\n): RetryDescriptorFn<T> => {\n const instance = createDescriptor(RetryDescriptor, options);\n const fn = (...args: Parameters<T>) => instance.run(...args);\n return Object.setPrototypeOf(fn, instance) as RetryDescriptorFn<T>;\n};\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport interface RetryDescriptorOptions<T extends (...args: any[]) => any> {\n /**\n * The function to retry.\n */\n handler: T;\n\n /**\n * The maximum number of attempts.\n *\n * @default 3\n */\n max?: number;\n\n /**\n * The backoff strategy for delays between retries.\n * Can be a fixed number (in ms) or a configuration object for exponential backoff.\n *\n * @default { initial: 200, factor: 2, jitter: true }\n */\n backoff?: number | RetryBackoffOptions;\n\n /**\n * An overall time limit for all retry attempts combined.\n *\n * e.g., `[5, 'seconds']`\n */\n maxDuration?: DurationLike;\n\n /**\n * A function that determines if a retry should be attempted based on the error.\n *\n * @default (error) => true (retries on any error)\n */\n when?: (error: Error) => boolean;\n\n /**\n * A custom callback for when a retry attempt fails.\n * This is called before the delay.\n */\n onError?: (error: Error, attempt: number, ...args: Parameters<T>) => void;\n\n /**\n * An AbortSignal to allow for external cancellation of the retry loop.\n */\n signal?: AbortSignal;\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class RetryDescriptor<\n T extends (...args: any[]) => any,\n> extends Descriptor<RetryDescriptorOptions<T>> {\n protected readonly retryProvider = $inject(RetryProvider);\n protected appAbortController?: AbortController;\n\n constructor(args: DescriptorArgs<RetryDescriptorOptions<T>>) {\n super(args);\n\n this.alepha.events.on(\"stop\", () => {\n this.appAbortController?.abort();\n });\n }\n\n async run(...args: Parameters<T>): Promise<ReturnType<T>> {\n // Nov 25: Cloudflare does not like 'new AbortController' outside main handler, we can't pre-create it in the constructor.\n this.appAbortController ??= new AbortController();\n\n return this.retryProvider.retry(\n {\n ...this.options,\n additionalSignal: this.appAbortController.signal,\n },\n ...args,\n );\n }\n}\n\nexport interface RetryDescriptorFn<T extends (...args: any[]) => any>\n extends RetryDescriptor<T> {\n (...args: Parameters<T>): Promise<ReturnType<T>>;\n}\n\n$retry[KIND] = RetryDescriptor;\n","import { $module } from \"alepha\";\nimport { $retry } from \"./descriptors/$retry.ts\";\nimport { RetryProvider } from \"./providers/RetryProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./descriptors/$retry.ts\";\nexport * from \"./errors/RetryCancelError.ts\";\nexport * from \"./errors/RetryTimeoutError.ts\";\nexport * from \"./providers/RetryProvider.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Retry mechanism provider for Alepha applications.\n *\n * @see {@link RetryProvider}\n * @module alepha.retry\n */\nexport const AlephaRetry = $module({\n name: \"alepha.retry\",\n descriptors: [$retry],\n services: [RetryProvider],\n});\n"],"mappings":";;;;;AAEA,IAAa,mBAAb,cAAsC,YAAY;CAChD,cAAc;AACZ,QAAM,iCAAiC;AACvC,OAAK,OAAO;;;;;;ACHhB,IAAa,oBAAb,cAAuC,YAAY;CACjD,YAAY,UAAkB;AAC5B,QAAM,mCAAmC,SAAS,KAAK;AACvD,OAAK,OAAO;;;;;;;;;;ACsFhB,IAAa,gBAAb,MAA2B;CACzB,AAAmB,MAAM,SAAS;CAClC,AAAmB,WAAW,QAAQ,iB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OAAO,QAAQ;;;;;;;;;;ACxFf,MAAa,cAAc,QAAQ;CACjC,MAAM;CACN,aAAa,CAAC,OAAO;CACrB,UAAU,CAAC,cAAc;CAC1B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as alepha4 from "alepha";
|
|
2
2
|
import { Alepha, Async, Descriptor, KIND, Static } from "alepha";
|
|
3
3
|
import * as alepha_lock0 from "alepha/lock";
|
|
4
4
|
import { DateTime, DateTimeProvider, DurationLike } from "alepha/datetime";
|
|
@@ -23,8 +23,8 @@ declare class CronProvider {
|
|
|
23
23
|
protected readonly log: alepha_logger0.Logger;
|
|
24
24
|
protected readonly cronJobs: Array<CronJob>;
|
|
25
25
|
getCronJobs(): Array<CronJob>;
|
|
26
|
-
protected readonly start:
|
|
27
|
-
protected readonly stop:
|
|
26
|
+
protected readonly start: alepha4.HookDescriptor<"start">;
|
|
27
|
+
protected readonly stop: alepha4.HookDescriptor<"stop">;
|
|
28
28
|
protected boot(name: string | CronJob): void;
|
|
29
29
|
abort(name: string | CronJob): void;
|
|
30
30
|
/**
|
|
@@ -87,8 +87,8 @@ type SchedulerDescriptorOptions = {
|
|
|
87
87
|
*/
|
|
88
88
|
lock?: boolean;
|
|
89
89
|
};
|
|
90
|
-
declare const envSchema:
|
|
91
|
-
SCHEDULER_PREFIX:
|
|
90
|
+
declare const envSchema: alepha4.TObject<{
|
|
91
|
+
SCHEDULER_PREFIX: alepha4.TOptional<alepha4.TString>;
|
|
92
92
|
}>;
|
|
93
93
|
declare module "alepha" {
|
|
94
94
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -139,7 +139,7 @@ declare module "alepha" {
|
|
|
139
139
|
* @see {@link $scheduler}
|
|
140
140
|
* @module alepha.scheduler
|
|
141
141
|
*/
|
|
142
|
-
declare const AlephaScheduler:
|
|
142
|
+
declare const AlephaScheduler: alepha4.Service<alepha4.Module>;
|
|
143
143
|
//#endregion
|
|
144
144
|
export { $scheduler, AlephaScheduler, CRON, CronJob, CronProvider, SchedulerDescriptor, SchedulerDescriptorOptions, SchedulerHandlerArguments };
|
|
145
145
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/server/index.js
CHANGED
|
@@ -1300,7 +1300,7 @@ var NodeHttpServerProvider = class extends ServerProvider {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
});
|
|
1302
1302
|
createHttpServer(func) {
|
|
1303
|
-
return createServer({ keepAlive:
|
|
1303
|
+
return createServer({ keepAlive: this.alepha.isProduction() }, func);
|
|
1304
1304
|
}
|
|
1305
1305
|
stop = $hook({
|
|
1306
1306
|
on: "stop",
|