alepha 0.7.4 → 0.7.6

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 (99) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +44 -21
  3. package/cache/redis.cjs +4 -8
  4. package/cache/redis.d.ts +30 -91
  5. package/cache/redis.js +1 -1
  6. package/cache.cjs +4 -8
  7. package/cache.d.ts +190 -259
  8. package/cache.js +1 -1
  9. package/core.cjs +4 -8
  10. package/core.d.ts +950 -925
  11. package/core.js +1 -1
  12. package/datetime.cjs +4 -8
  13. package/datetime.d.ts +151 -140
  14. package/datetime.js +1 -1
  15. package/lock/redis.cjs +7 -49
  16. package/lock/redis.d.ts +17 -14
  17. package/lock/redis.js +1 -47
  18. package/lock.cjs +4 -8
  19. package/lock.d.ts +117 -170
  20. package/lock.js +1 -1
  21. package/package.json +70 -40
  22. package/postgres.cjs +4 -8
  23. package/postgres.d.ts +1314 -4400
  24. package/postgres.js +1 -1
  25. package/queue/redis.cjs +8 -0
  26. package/queue/redis.d.ts +31 -0
  27. package/queue/redis.js +1 -0
  28. package/queue.cjs +4 -8
  29. package/queue.d.ts +162 -205
  30. package/queue.js +1 -1
  31. package/react/auth.cjs +4 -8
  32. package/react/auth.d.ts +167 -280
  33. package/react/auth.js +1 -1
  34. package/react.cjs +4 -8
  35. package/react.d.ts +530 -570
  36. package/react.js +1 -1
  37. package/redis.cjs +4 -8
  38. package/redis.d.ts +59 -132
  39. package/redis.js +1 -1
  40. package/retry.cjs +4 -8
  41. package/retry.d.ts +34 -31
  42. package/retry.js +1 -1
  43. package/scheduler.cjs +4 -8
  44. package/scheduler.d.ts +128 -155
  45. package/scheduler.js +1 -1
  46. package/security.cjs +4 -8
  47. package/security.d.ts +472 -595
  48. package/security.js +1 -1
  49. package/server/cache.cjs +4 -8
  50. package/server/cache.d.ts +73 -39
  51. package/server/cache.js +1 -1
  52. package/server/cookies.cjs +4 -8
  53. package/server/cookies.d.ts +46 -41
  54. package/server/cookies.js +1 -1
  55. package/server/static.cjs +4 -8
  56. package/server/static.d.ts +98 -95
  57. package/server/static.js +1 -1
  58. package/server/swagger.cjs +4 -8
  59. package/server/swagger.d.ts +106 -92
  60. package/server/swagger.js +1 -1
  61. package/server.cjs +4 -8
  62. package/server.d.ts +754 -1025
  63. package/server.js +1 -1
  64. package/testing.cjs +8 -0
  65. package/testing.d.ts +1 -0
  66. package/testing.js +1 -0
  67. package/topic/redis.cjs +8 -0
  68. package/topic/redis.d.ts +45 -0
  69. package/topic/redis.js +1 -0
  70. package/topic.cjs +4 -8
  71. package/topic.d.ts +171 -163
  72. package/topic.js +1 -1
  73. package/vite.cjs +4 -8
  74. package/vite.d.ts +91 -84
  75. package/vite.js +1 -1
  76. package/assets/logo.png +0 -0
  77. package/src/cache/redis.ts +0 -1
  78. package/src/cache.ts +0 -1
  79. package/src/core.ts +0 -1
  80. package/src/datetime.ts +0 -1
  81. package/src/lock/redis.ts +0 -1
  82. package/src/lock.ts +0 -1
  83. package/src/postgres.ts +0 -1
  84. package/src/queue/redis.ts +0 -1
  85. package/src/queue.ts +0 -1
  86. package/src/react/auth.ts +0 -1
  87. package/src/react.ts +0 -1
  88. package/src/redis.ts +0 -1
  89. package/src/retry.ts +0 -1
  90. package/src/scheduler.ts +0 -1
  91. package/src/security.ts +0 -1
  92. package/src/server/cache.ts +0 -1
  93. package/src/server/cookies.ts +0 -1
  94. package/src/server/static.ts +0 -1
  95. package/src/server/swagger.ts +0 -1
  96. package/src/server.ts +0 -1
  97. package/src/topic/redis.ts +0 -1
  98. package/src/topic.ts +0 -1
  99. package/src/vite.ts +0 -1
package/react.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/react';
1
+ export * from '@alepha/react'
package/redis.cjs CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict';
2
-
3
- var redis = require('@alepha/redis');
4
-
5
-
6
-
7
- Object.keys(redis).forEach(function (k) {
2
+ var m = require('@alepha/redis');
3
+ Object.keys(m).forEach(function (k) {
8
4
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
5
  enumerable: true,
10
- get: function () { return redis[k]; }
6
+ get: function () { return m[k]; }
11
7
  });
12
- });
8
+ });
package/redis.d.ts CHANGED
@@ -1,144 +1,71 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Static, Alepha } from '@alepha/core';
3
- import { RedisClientType, createClient, SetOptions } from '@redis/client';
1
+ import * as _alepha_core7 from "@alepha/core";
2
+ import * as _alepha_core0 from "@alepha/core";
3
+ import { Alepha, Static } from "@alepha/core";
4
+ import { RedisClientType, SetOptions, createClient } from "@redis/client";
5
+ import * as _sinclair_typebox3 from "@sinclair/typebox";
4
6
 
5
- /** Symbol key applied to readonly types */
6
- declare const ReadonlyKind: unique symbol;
7
- /** Symbol key applied to optional types */
8
- declare const OptionalKind: unique symbol;
9
- /** Symbol key applied to types */
10
- declare const Hint: unique symbol;
11
- /** Symbol key applied to types */
12
- declare const Kind: unique symbol;
13
-
14
- type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
15
- type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
16
- interface StringOptions extends SchemaOptions {
17
- /** The maximum string length */
18
- maxLength?: number;
19
- /** The minimum string length */
20
- minLength?: number;
21
- /** A regular expression pattern this string should match */
22
- pattern?: string;
23
- /** A format this string should match */
24
- format?: StringFormatOption;
25
- /** The content encoding for this string */
26
- contentEncoding?: StringContentEncodingOption;
27
- /** The content media type for this string */
28
- contentMediaType?: string;
29
- }
30
- interface TString extends TSchema, StringOptions {
31
- [Kind]: 'String';
32
- static: string;
33
- type: 'string';
34
- }
35
-
36
- interface NumberOptions extends SchemaOptions {
37
- exclusiveMaximum?: number;
38
- exclusiveMinimum?: number;
39
- maximum?: number;
40
- minimum?: number;
41
- multipleOf?: number;
42
- }
43
- interface TNumber extends TSchema, NumberOptions {
44
- [Kind]: 'Number';
45
- static: number;
46
- type: 'number';
47
- }
48
-
49
- type TOptional<T extends TSchema> = T & {
50
- [OptionalKind]: 'Optional';
51
- };
52
-
53
- interface SchemaOptions {
54
- $schema?: string;
55
- /** Id for this schema */
56
- $id?: string;
57
- /** Title of this schema */
58
- title?: string;
59
- /** Description of this schema */
60
- description?: string;
61
- /** Default value for this schema */
62
- default?: any;
63
- /** Example values matching this schema */
64
- examples?: any;
65
- /** Optional annotation for readOnly */
66
- readOnly?: boolean;
67
- /** Optional annotation for writeOnly */
68
- writeOnly?: boolean;
69
- [prop: string]: any;
70
- }
71
- interface TKind {
72
- [Kind]: string;
73
- }
74
- interface TSchema extends TKind, SchemaOptions {
75
- [ReadonlyKind]?: string;
76
- [OptionalKind]?: string;
77
- [Hint]?: string;
78
- params: unknown[];
79
- static: unknown;
80
- }
81
-
82
- declare const envSchema: _alepha_core.TObject<{
83
- REDIS_PORT: TNumber;
84
- REDIS_HOST: TString;
85
- REDIS_PASSWORD: TOptional<TString>;
7
+ //#region src/providers/RedisProvider.d.ts
8
+ declare const envSchema: _alepha_core7.TObject<{
9
+ REDIS_PORT: _sinclair_typebox3.TNumber;
10
+ REDIS_HOST: _sinclair_typebox3.TString;
11
+ REDIS_PASSWORD: _sinclair_typebox3.TOptional<_sinclair_typebox3.TString>;
86
12
  }>;
87
13
  declare module "alepha" {
88
- interface Env extends Partial<Static<typeof envSchema>> {
89
- }
14
+ interface Env extends Partial<Static<typeof envSchema>> {}
90
15
  }
91
16
  type RedisClient = RedisClientType<{}, {}, {}, 3, {
92
- 36: BufferConstructor;
17
+ 36: BufferConstructor;
93
18
  }>;
94
19
  type RedisClientOptions = Parameters<typeof createClient>[0];
95
20
  type RedisSetOptions = SetOptions;
96
21
  declare class RedisProvider {
97
- protected readonly log: _alepha_core.Logger;
98
- protected readonly alepha: Alepha;
99
- protected readonly env: {
100
- REDIS_PASSWORD?: string | undefined;
101
- REDIS_PORT: number;
102
- REDIS_HOST: string;
103
- };
104
- protected readonly client: RedisClient;
105
- get publisher(): RedisClient;
106
- protected readonly start: _alepha_core.HookDescriptor<"start">;
107
- protected readonly stop: _alepha_core.HookDescriptor<"stop">;
108
- /**
109
- * Connect to the Redis server.
110
- */
111
- connect(): Promise<void>;
112
- /**
113
- * Close the connection to the Redis server.
114
- */
115
- close(): Promise<void>;
116
- duplicate(options?: Partial<RedisClientOptions>): RedisClient;
117
- get(key: string): Promise<Buffer | undefined>;
118
- set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
119
- has(key: string): Promise<boolean>;
120
- keys(pattern: string): Promise<string[]>;
121
- del(keys: string[]): Promise<void>;
122
- /**
123
- * Redis subscriber client factory method.
124
- */
125
- protected createClient(): RedisClient;
22
+ protected readonly log: _alepha_core7.Logger;
23
+ protected readonly alepha: Alepha;
24
+ protected readonly env: {
25
+ REDIS_PASSWORD?: string | undefined;
26
+ REDIS_PORT: number;
27
+ REDIS_HOST: string;
28
+ };
29
+ protected readonly client: RedisClient;
30
+ get publisher(): RedisClient;
31
+ protected readonly start: _alepha_core7.HookDescriptor<"start">;
32
+ protected readonly stop: _alepha_core7.HookDescriptor<"stop">;
33
+ /**
34
+ * Connect to the Redis server.
35
+ */
36
+ connect(): Promise<void>;
37
+ /**
38
+ * Close the connection to the Redis server.
39
+ */
40
+ close(): Promise<void>;
41
+ duplicate(options?: Partial<RedisClientOptions>): RedisClient;
42
+ get(key: string): Promise<Buffer | undefined>;
43
+ set(key: string, value: Buffer | string, options?: RedisSetOptions): Promise<Buffer>;
44
+ has(key: string): Promise<boolean>;
45
+ keys(pattern: string): Promise<string[]>;
46
+ del(keys: string[]): Promise<void>;
47
+ /**
48
+ * Redis subscriber client factory method.
49
+ */
50
+ protected createClient(): RedisClient;
126
51
  }
127
-
52
+ //#endregion
53
+ //#region src/providers/RedisSubscriberProvider.d.ts
128
54
  declare class RedisSubscriberProvider {
129
- protected readonly log: _alepha_core.Logger;
130
- protected readonly alepha: Alepha;
131
- protected readonly redisProvider: RedisProvider;
132
- protected readonly client: RedisClient;
133
- get subscriber(): RedisClient;
134
- protected readonly start: _alepha_core.HookDescriptor<"start">;
135
- protected readonly stop: _alepha_core.HookDescriptor<"stop">;
136
- connect(): Promise<void>;
137
- close(): Promise<void>;
138
- /**
139
- * Redis subscriber client factory method.
140
- */
141
- protected createClient(): RedisClient;
55
+ protected readonly log: _alepha_core0.Logger;
56
+ protected readonly alepha: Alepha;
57
+ protected readonly redisProvider: RedisProvider;
58
+ protected readonly client: RedisClient;
59
+ get subscriber(): RedisClient;
60
+ protected readonly start: _alepha_core0.HookDescriptor<"start">;
61
+ protected readonly stop: _alepha_core0.HookDescriptor<"stop">;
62
+ connect(): Promise<void>;
63
+ close(): Promise<void>;
64
+ /**
65
+ * Redis subscriber client factory method.
66
+ */
67
+ protected createClient(): RedisClient;
142
68
  }
143
-
144
- export { type RedisClient, type RedisClientOptions, RedisProvider, type RedisSetOptions, RedisSubscriberProvider };
69
+ //#endregion
70
+ export { RedisClient, RedisClientOptions, RedisProvider, RedisSetOptions, RedisSubscriberProvider };
71
+ //# sourceMappingURL=index.d.ts.map
package/redis.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/redis';
1
+ export * from '@alepha/redis'
package/retry.cjs CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict';
2
-
3
- var retry = require('@alepha/retry');
4
-
5
-
6
-
7
- Object.keys(retry).forEach(function (k) {
2
+ var m = require('@alepha/retry');
3
+ Object.keys(m).forEach(function (k) {
8
4
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
5
  enumerable: true,
10
- get: function () { return retry[k]; }
6
+ get: function () { return m[k]; }
11
7
  });
12
- });
8
+ });
package/retry.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { MaybePromise } from '@alepha/core';
1
+ import { MaybePromise } from "@alepha/core";
2
+
3
+ //#region src/descriptors/$retry.d.ts
2
4
 
3
5
  /**
4
6
  * `$retry` creates a retry descriptor.
@@ -34,35 +36,36 @@ declare const $retry: <T extends (...args: any[]) => any>(opts: RetryDescriptorO
34
36
  * Retry Descriptor options.
35
37
  */
36
38
  interface RetryDescriptorOptions<T extends (...args: any[]) => any> {
37
- /**
38
- * Maximum number of attempts.
39
- *
40
- * @default 3
41
- */
42
- max?: number;
43
- /**
44
- * Delay in milliseconds.
45
- *
46
- * @default 0
47
- */
48
- delay?: number;
49
- /**
50
- * Optional condition to determine when to retry.
51
- */
52
- when?: (error: Error) => boolean;
53
- /**
54
- * The function to retry.
55
- */
56
- handler: T;
57
- /**
58
- * Optional error handler.
59
- *
60
- * This will be called when an error occurs.
61
- *
62
- * @default undefined
63
- */
64
- onError?: (error: Error, attempt: number, ...parameters: Parameters<T>) => void;
39
+ /**
40
+ * Maximum number of attempts.
41
+ *
42
+ * @default 3
43
+ */
44
+ max?: number;
45
+ /**
46
+ * Delay in milliseconds.
47
+ *
48
+ * @default 0
49
+ */
50
+ delay?: number;
51
+ /**
52
+ * Optional condition to determine when to retry.
53
+ */
54
+ when?: (error: Error) => boolean;
55
+ /**
56
+ * The function to retry.
57
+ */
58
+ handler: T;
59
+ /**
60
+ * Optional error handler.
61
+ *
62
+ * This will be called when an error occurs.
63
+ *
64
+ * @default undefined
65
+ */
66
+ onError?: (error: Error, attempt: number, ...parameters: Parameters<T>) => void;
65
67
  }
66
68
  type RetryDescriptor<T extends (...args: any[]) => any> = (...parameters: Parameters<T>) => MaybePromise<ReturnType<T>>;
67
-
68
- export { $retry, type RetryDescriptor, type RetryDescriptorOptions };
69
+ //#endregion
70
+ export { $retry, RetryDescriptor, RetryDescriptorOptions };
71
+ //# sourceMappingURL=index.d.ts.map
package/retry.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/retry';
1
+ export * from '@alepha/retry'
package/scheduler.cjs CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict';
2
-
3
- var scheduler = require('@alepha/scheduler');
4
-
5
-
6
-
7
- Object.keys(scheduler).forEach(function (k) {
2
+ var m = require('@alepha/scheduler');
3
+ Object.keys(m).forEach(function (k) {
8
4
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
5
  enumerable: true,
10
- get: function () { return scheduler[k]; }
6
+ get: function () { return m[k]; }
11
7
  });
12
- });
8
+ });
package/scheduler.d.ts CHANGED
@@ -1,176 +1,148 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Async, KIND, OPTIONS, Static, Alepha } from '@alepha/core';
3
- import { DurationLike, DateTimeProvider, Interval } from '@alepha/datetime';
4
- import * as _alepha_lock from '@alepha/lock';
5
- import { ScheduledTask } from 'node-cron';
1
+ import * as _alepha_core9 from "@alepha/core";
2
+ import * as _alepha_core2 from "@alepha/core";
3
+ import { Alepha, Async, KIND, OPTIONS, Static } from "@alepha/core";
4
+ import * as _alepha_lock8 from "@alepha/lock";
5
+ import { DateTime, DateTimeProvider, DurationLike, Interval } from "@alepha/datetime";
6
+ import { Cron } from "cron-schedule";
7
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
8
+ import * as dayjs10 from "dayjs";
6
9
 
10
+ //#region src/descriptors/$scheduler.d.ts
7
11
  declare const KEY = "SCHEDULER";
8
12
  /**
9
13
  * Scheduler descriptor.
10
14
  */
11
15
  declare const $scheduler: {
12
- (options: SchedulerDescriptorOptions): SchedulerDescriptor;
13
- [KIND]: string;
16
+ (options: SchedulerDescriptorOptions): SchedulerDescriptor;
17
+ [KIND]: string;
14
18
  };
15
19
  declare const isScheduler: (value: any) => value is SchedulerDescriptor;
16
20
  type SchedulerDescriptorOptions = {
17
- /**
18
- * Function to run on schedule.
19
- */
20
- handler: () => Async<void>;
21
- /**
22
- * Name of the scheduler. Defaults to the function name.
23
- */
24
- name?: string;
25
- /**
26
- * Optional description of the scheduler.
27
- */
28
- description?: string;
29
- /**
30
- * Cron expression or interval to run the scheduler.
31
- */
32
- cron?: string;
33
- /**
34
- * Cron expression or interval to run the scheduler.
35
- */
36
- interval?: DurationLike;
37
- /**
38
- * If true, the scheduler will be locked and only one instance will run at a time.
39
- * Defaults to true.
40
- */
41
- lock?: boolean;
21
+ /**
22
+ * Function to run on schedule.
23
+ */
24
+ handler: (args: SchedulerHandlerArguments) => Async<void>;
25
+ /**
26
+ * Name of the scheduler. Defaults to the function name.
27
+ */
28
+ name?: string;
29
+ /**
30
+ * Optional description of the scheduler.
31
+ */
32
+ description?: string;
33
+ /**
34
+ * Cron expression or interval to run the scheduler.
35
+ */
36
+ cron?: string;
37
+ /**
38
+ * Cron expression or interval to run the scheduler.
39
+ */
40
+ interval?: DurationLike;
41
+ /**
42
+ * If true, the scheduler will be locked and only one instance will run at a time.
43
+ * You probably need to import {@link AlephaLockRedis} for distributed locking.
44
+ *
45
+ * @default true
46
+ */
47
+ lock?: boolean;
42
48
  };
43
49
  interface SchedulerDescriptor {
44
- [KIND]: typeof KEY;
45
- [OPTIONS]: SchedulerDescriptorOptions;
46
- (): Promise<void>;
50
+ [KIND]: typeof KEY;
51
+ [OPTIONS]: SchedulerDescriptorOptions;
52
+ (): Promise<void>;
47
53
  }
48
-
49
- /** Symbol key applied to readonly types */
50
- declare const ReadonlyKind: unique symbol;
51
- /** Symbol key applied to optional types */
52
- declare const OptionalKind: unique symbol;
53
- /** Symbol key applied to types */
54
- declare const Hint: unique symbol;
55
- /** Symbol key applied to types */
56
- declare const Kind: unique symbol;
57
-
58
- type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
59
- type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
60
- interface StringOptions extends SchemaOptions {
61
- /** The maximum string length */
62
- maxLength?: number;
63
- /** The minimum string length */
64
- minLength?: number;
65
- /** A regular expression pattern this string should match */
66
- pattern?: string;
67
- /** A format this string should match */
68
- format?: StringFormatOption;
69
- /** The content encoding for this string */
70
- contentEncoding?: StringContentEncodingOption;
71
- /** The content media type for this string */
72
- contentMediaType?: string;
73
- }
74
- interface TString extends TSchema, StringOptions {
75
- [Kind]: 'String';
76
- static: string;
77
- type: 'string';
78
- }
79
-
80
- type TOptional<T extends TSchema> = T & {
81
- [OptionalKind]: 'Optional';
82
- };
83
-
84
- interface SchemaOptions {
85
- $schema?: string;
86
- /** Id for this schema */
87
- $id?: string;
88
- /** Title of this schema */
89
- title?: string;
90
- /** Description of this schema */
91
- description?: string;
92
- /** Default value for this schema */
93
- default?: any;
94
- /** Example values matching this schema */
95
- examples?: any;
96
- /** Optional annotation for readOnly */
97
- readOnly?: boolean;
98
- /** Optional annotation for writeOnly */
99
- writeOnly?: boolean;
100
- [prop: string]: any;
54
+ interface SchedulerHandlerArguments {
55
+ now: DateTime;
101
56
  }
102
- interface TKind {
103
- [Kind]: string;
57
+ //#endregion
58
+ //#region src/providers/CronScheduler.d.ts
59
+ interface CronJob {
60
+ handler: (context: {
61
+ now: DateTime;
62
+ }) => Promise<void>;
63
+ cron: Cron;
64
+ loop: boolean;
65
+ running?: boolean;
66
+ onError?: (error: Error) => void;
67
+ abort: AbortController;
104
68
  }
105
- interface TSchema extends TKind, SchemaOptions {
106
- [ReadonlyKind]?: string;
107
- [OptionalKind]?: string;
108
- [Hint]?: string;
109
- params: unknown[];
110
- static: unknown;
69
+ declare class CronProvider {
70
+ protected readonly dt: DateTimeProvider;
71
+ protected readonly alepha: Alepha;
72
+ protected readonly log: _alepha_core9.Logger;
73
+ start(cron: CronJob): void;
74
+ stop(cron: CronJob): void;
75
+ create(expression: string, handler: (context: {
76
+ now: DateTime;
77
+ }) => Promise<void>): CronJob;
78
+ run(task: CronJob, now?: dayjs10.Dayjs): void;
111
79
  }
112
-
113
- declare const envSchema: _alepha_core.TObject<{
114
- SCHEDULER_PREFIX: TOptional<TString>;
80
+ //#endregion
81
+ //#region src/providers/SchedulerDescriptorProvider.d.ts
82
+ declare const envSchema: _alepha_core2.TObject<{
83
+ SCHEDULER_PREFIX: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
115
84
  }>;
116
85
  declare module "alepha" {
117
- interface Env extends Partial<Static<typeof envSchema>> {
118
- }
86
+ interface Env extends Partial<Static<typeof envSchema>> {}
119
87
  }
120
88
  declare class SchedulerDescriptorProvider {
121
- protected readonly log: _alepha_core.Logger;
122
- protected readonly env: {
123
- SCHEDULER_PREFIX?: string | undefined;
124
- };
125
- protected readonly alepha: Alepha;
126
- protected readonly dateTimeProvider: DateTimeProvider;
127
- protected readonly schedulers: Scheduler[];
128
- protected readonly configure: _alepha_core.HookDescriptor<"configure">;
129
- protected readonly start: _alepha_core.HookDescriptor<"start">;
130
- protected readonly stop: _alepha_core.HookDescriptor<"stop">;
131
- /**
132
- * Get the schedulers.
133
- */
134
- getSchedulers(): Scheduler[];
135
- /**
136
- * Process scheduler descriptors.
137
- *
138
- * @protected
139
- */
140
- protected processSchedulerDescriptors(): void;
141
- /**
142
- * Create a scheduler.
143
- *
144
- * @param options - The scheduler options.
145
- * @param instance - The instance of the scheduler.
146
- * @param key - Property key name.
147
- * @protected
148
- */
149
- protected createScheduler(options: SchedulerDescriptorOptions, instance: any, key: string): Scheduler;
150
- trigger(name: string): Promise<void>;
151
- protected runLock: _alepha_lock.LockDescriptor<(options: SchedulerDescriptorOptions & {
152
- name: string;
153
- }) => Promise<void>>;
154
- protected run(options: SchedulerDescriptorOptions): Promise<void>;
155
- /**
156
- * Prefix the scheduler key.
157
- */
158
- protected prefix(key: string): string;
159
- /**
160
- *
161
- * @param options
162
- * @protected
163
- */
164
- protected getLockGracePeriod(options: SchedulerDescriptorOptions): number;
89
+ protected readonly log: _alepha_core2.Logger;
90
+ protected readonly env: {
91
+ SCHEDULER_PREFIX?: string | undefined;
92
+ };
93
+ protected readonly alepha: Alepha;
94
+ protected readonly dateTimeProvider: DateTimeProvider;
95
+ protected readonly cronProvider: CronProvider;
96
+ protected readonly schedulers: Scheduler[];
97
+ protected readonly configure: _alepha_core2.HookDescriptor<"configure">;
98
+ protected readonly start: _alepha_core2.HookDescriptor<"start">;
99
+ protected readonly stop: _alepha_core2.HookDescriptor<"stop">;
100
+ protected createContextId(): string;
101
+ /**
102
+ * Get the schedulers.
103
+ */
104
+ getSchedulers(): Scheduler[];
105
+ /**
106
+ * Process scheduler descriptors.
107
+ *
108
+ * @protected
109
+ */
110
+ protected processSchedulerDescriptors(): void;
111
+ /**
112
+ * Create a scheduler.
113
+ *
114
+ * @param options - The scheduler options.
115
+ * @param instance - The instance of the scheduler.
116
+ * @param key - Property key name.
117
+ * @protected
118
+ */
119
+ protected createScheduler(options: SchedulerDescriptorOptions, instance: any, key: string): Scheduler;
120
+ protected createHandler(name: string, options: SchedulerDescriptorOptions): (args: SchedulerHandlerArguments) => Promise<void>;
121
+ trigger(name: string): Promise<void>;
122
+ protected runLock: _alepha_lock8.LockDescriptor<(options: SchedulerDescriptorOptions & {
123
+ name: string;
124
+ args: SchedulerHandlerArguments;
125
+ }) => Promise<void>>;
126
+ /**
127
+ * Prefix the scheduler key.
128
+ */
129
+ protected prefix(key: string): string;
130
+ /**
131
+ *
132
+ * @param options
133
+ * @protected
134
+ */
135
+ protected getLockGracePeriod(options: SchedulerDescriptorOptions): number;
165
136
  }
166
137
  interface Scheduler {
167
- name: string;
168
- options: SchedulerDescriptorOptions;
169
- trigger: () => Promise<void>;
170
- cron?: ScheduledTask;
171
- interval?: Interval;
138
+ name: string;
139
+ options: SchedulerDescriptorOptions;
140
+ trigger: (args: SchedulerHandlerArguments) => Promise<void>;
141
+ cron?: CronJob;
142
+ interval?: Interval;
172
143
  }
173
-
144
+ //#endregion
145
+ //#region src/index.d.ts
174
146
  /**
175
147
  * Alepha Scheduler Module
176
148
  *
@@ -180,8 +152,9 @@ interface Scheduler {
180
152
  * @module alepha.scheduler
181
153
  */
182
154
  declare class AlephaScheduler {
183
- readonly name = "alepha.scheduler";
184
- readonly $services: (alepha: Alepha) => Alepha;
155
+ readonly name = "alepha.scheduler";
156
+ readonly $services: (alepha: Alepha) => Alepha;
185
157
  }
186
-
187
- export { $scheduler, AlephaScheduler, type Scheduler, type SchedulerDescriptor, type SchedulerDescriptorOptions, SchedulerDescriptorProvider, isScheduler };
158
+ //#endregion
159
+ export { $scheduler, AlephaScheduler, Scheduler, SchedulerDescriptor, SchedulerDescriptorOptions, SchedulerDescriptorProvider, SchedulerHandlerArguments, isScheduler };
160
+ //# sourceMappingURL=index.d.ts.map
package/scheduler.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/scheduler';
1
+ export * from '@alepha/scheduler'