alepha 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +47 -44
  3. package/batch.d.ts +87 -88
  4. package/bucket.cjs +8 -0
  5. package/bucket.d.ts +194 -0
  6. package/bucket.js +1 -0
  7. package/cache/redis.d.ts +14 -16
  8. package/cache.d.ts +101 -170
  9. package/command.d.ts +70 -77
  10. package/core.d.ts +1043 -887
  11. package/datetime.d.ts +91 -117
  12. package/file.cjs +8 -0
  13. package/file.d.ts +56 -0
  14. package/file.js +1 -0
  15. package/lock/redis.d.ts +11 -13
  16. package/lock.d.ts +125 -117
  17. package/package.json +66 -38
  18. package/postgres.d.ts +232 -275
  19. package/queue/redis.d.ts +13 -15
  20. package/queue.d.ts +88 -116
  21. package/react/auth.d.ts +50 -55
  22. package/react/head.d.ts +5 -8
  23. package/react.d.ts +71 -73
  24. package/redis.d.ts +32 -14
  25. package/retry.d.ts +70 -58
  26. package/router.cjs +8 -0
  27. package/router.d.ts +45 -0
  28. package/router.js +1 -0
  29. package/scheduler.d.ts +54 -96
  30. package/security.d.ts +117 -119
  31. package/server/cache.d.ts +22 -31
  32. package/server/compress.d.ts +16 -7
  33. package/server/cookies.d.ts +70 -61
  34. package/server/cors.d.ts +15 -13
  35. package/server/health.d.ts +23 -26
  36. package/server/helmet.d.ts +17 -20
  37. package/server/links.d.ts +113 -90
  38. package/server/metrics.d.ts +25 -23
  39. package/server/multipart.d.ts +12 -16
  40. package/server/proxy.d.ts +25 -20
  41. package/server/security.cjs +8 -0
  42. package/server/security.d.ts +90 -0
  43. package/server/security.js +1 -0
  44. package/server/static.d.ts +67 -68
  45. package/server/swagger.d.ts +77 -65
  46. package/server.d.ts +265 -308
  47. package/topic/redis.d.ts +25 -26
  48. package/topic.d.ts +76 -122
  49. package/vite.d.ts +52 -36
package/datetime.d.ts CHANGED
@@ -1,167 +1,141 @@
1
- import { Async, HookDescriptor, Logger } from "alepha";
1
+ import * as _alepha_core0$1 from "alepha";
2
+ import * as _alepha_core0 from "alepha";
3
+ import { Alepha, Descriptor, KIND } from "alepha";
2
4
  import dayjs, { Dayjs, ManipulateType } from "dayjs";
3
5
  import dayjsDuration from "dayjs/plugin/duration.js";
4
6
 
5
- //#region src/helpers/Interval.d.ts
6
- declare class Interval {
7
- private timer;
8
- private readonly run;
9
- private duration;
10
- private options;
11
- constructor(duration: number, options: IntervalDescriptorOptions);
12
- /**
13
- * Start the interval.
14
- */
15
- start(): Promise<void>;
16
- /**
17
- * Add time to the interval.
18
- *
19
- * @param amountMs
20
- */
21
- add(amountMs: number): Promise<void>;
22
- /**
23
- * Clear the interval.
24
- */
25
- clear(): void;
26
- }
27
- //#endregion
28
- //#region src/helpers/Timeout.d.ts
29
- declare class Timeout {
30
- private timer;
31
- private duration;
32
- private readonly now;
33
- private readonly callback;
34
- constructor(now: number, duration: number, callback: () => void);
35
- /**
36
- * Add time to the timeout.
37
- */
38
- add(amountMs: number): void;
39
- /**
40
- * Clear the timeout.
41
- */
42
- clear(): void;
43
- /**
44
- * Start the timeout.
45
- *
46
- * @private
47
- */
48
- private start;
49
- }
50
- //#endregion
51
7
  //#region src/providers/DateTimeProvider.d.ts
8
+ type DateTimeApi = typeof dayjs;
52
9
  type DateTime = dayjs.Dayjs;
53
10
  type Duration = dayjsDuration.Duration;
54
11
  type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
55
12
  declare class DateTimeProvider {
56
- protected log: Logger;
13
+ protected alepha: Alepha;
14
+ protected log: _alepha_core0$1.Logger;
57
15
  protected ref: DateTime | null;
58
16
  protected readonly timeouts: Timeout[];
59
17
  protected readonly intervals: Interval[];
60
18
  constructor();
61
- protected readonly start: HookDescriptor<"start">;
62
- protected readonly stop: HookDescriptor<"stop">;
63
19
  /**
64
- * Create a new DateTime instance.
65
- */
20
+ * Load Day.js plugins.
21
+ *
22
+ * You can override this method to add custom plugins.
23
+ */
24
+ protected plugins(api: DateTimeApi): void;
25
+ protected readonly start: _alepha_core0$1.HookDescriptor<"start">;
26
+ protected readonly stop: _alepha_core0$1.HookDescriptor<"stop">;
27
+ /**
28
+ * Create a new DateTime instance.
29
+ */
66
30
  of(date: string | number | Date | Dayjs | null | undefined): DateTime;
67
31
  /**
68
- * Get the current date.
69
- */
32
+ * Get the current date.
33
+ */
70
34
  now(): DateTime;
71
35
  /**
72
- * Get the current date as a string.
73
- *
74
- * @param date
75
- */
36
+ * Get the current date as a string.
37
+ *
38
+ * @param date
39
+ */
76
40
  toISOString(date?: Date | string | DateTime): string;
77
41
  /**
78
- * Get the current date as a string.
79
- */
42
+ * Get the current date as a string.
43
+ */
80
44
  nowISOString(): string;
81
45
  /**
82
- * Get the current date as a string.
83
- *
84
- * @protected
85
- */
46
+ * Get the current date as a string.
47
+ *
48
+ * @protected
49
+ */
86
50
  protected getCurrentDate(): DateTime;
87
51
  /**
88
- * Create a new Duration instance.
89
- */
52
+ * Create a new Duration instance.
53
+ */
90
54
  duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
91
55
  isDurationLike(value: unknown): value is DurationLike;
92
56
  /**
93
- * Return a promise that resolves after a next tick.
94
- * It uses `setTimeout` with 0ms delay.
95
- */
57
+ * Return a promise that resolves after the next tick.
58
+ * It uses `setTimeout` with 0 ms delay.
59
+ */
96
60
  tick(): Promise<void>;
97
61
  /**
98
- * Wait for a certain duration.
99
- *
100
- * You can clear the timeout by using the `AbortSignal` API.
101
- * Aborted signal will resolve the promise immediately, it does not reject it.
102
- */
62
+ * Wait for a certain duration.
63
+ *
64
+ * You can clear the timeout by using the `AbortSignal` API.
65
+ * Aborted signal will resolve the promise immediately, it does not reject it.
66
+ */
103
67
  wait(duration: DurationLike, options?: {
104
68
  signal?: AbortSignal;
105
69
  now?: number;
106
70
  }): Promise<void>;
71
+ createInterval(run: () => unknown, distance: DurationLike): Interval;
107
72
  /**
108
- * Run a callback after a certain duration.
109
- */
110
- timeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
111
- /**
112
- * Create an interval.
113
- *
114
- * @param args
115
- */
116
- interval(args: IntervalDescriptorOptions): Interval;
73
+ * Run a callback after a certain duration.
74
+ */
75
+ createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
76
+ clearTimeout(timeout: Timeout): void;
117
77
  /**
118
- * Run a function with a deadline.
119
- */
78
+ * Run a function with a deadline.
79
+ */
120
80
  deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
121
- // Testing
122
81
  /**
123
- * Add time to the current date.
124
- */
82
+ * Add time to the current date.
83
+ */
125
84
  travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
126
85
  /**
127
- * Stop the time.
128
- */
86
+ * Stop the time.
87
+ */
129
88
  pause(): DateTime;
130
89
  /**
131
- * Reset the reference date.
132
- */
90
+ * Reset the reference date.
91
+ */
133
92
  reset(): void;
134
93
  }
94
+ interface Interval {
95
+ timer?: any;
96
+ duration: number;
97
+ run: () => unknown;
98
+ }
99
+ interface Timeout {
100
+ now: number;
101
+ timer?: any;
102
+ duration: number;
103
+ callback: () => void;
104
+ clear: () => void;
105
+ }
106
+ //# sourceMappingURL=DateTimeProvider.d.ts.map
135
107
  //#endregion
136
108
  //#region src/descriptors/$interval.d.ts
109
+ /**
110
+ * Run a function periodically.
111
+ * It uses the `setInterval` internally.
112
+ * It starts by default when the context starts and stops when the context stops.
113
+ */
114
+ declare const $interval: {
115
+ (options: IntervalDescriptorOptions): IntervalDescriptor;
116
+ [KIND]: typeof IntervalDescriptor;
117
+ };
137
118
  interface IntervalDescriptorOptions {
138
119
  /**
139
- * Whether to start the interval immediately.
140
- *
141
- * @default false
142
- */
143
- run?: boolean;
144
- /**
145
- * Whether to attach the interval to the context.
146
- *
147
- * Attached intervals are automatically started when the context starts and stopped when the context stops.
148
- *
149
- * @default true
150
- */
151
- attach?: boolean;
152
- /**
153
- * The interval handler.
154
- */
155
- handler: () => Async<void>;
156
- /**
157
- * The interval duration.
158
- */
120
+ * The interval handler.
121
+ */
122
+ handler: () => unknown;
123
+ /**
124
+ * The interval duration.
125
+ */
159
126
  duration: DurationLike;
160
127
  }
161
- /**
162
- * Registers a new interval.
163
- */
164
- declare const $interval: (options: IntervalDescriptorOptions) => Interval;
128
+ declare class IntervalDescriptor extends Descriptor<IntervalDescriptorOptions> {
129
+ protected readonly dateTimeProvider: DateTimeProvider;
130
+ called: number;
131
+ protected onInit(): void;
132
+ }
133
+ //# sourceMappingURL=$interval.d.ts.map
134
+ //#endregion
135
+ //#region src/index.d.ts
136
+ declare const AlephaDateTime: _alepha_core0.ModuleDescriptor;
137
+ //# sourceMappingURL=index.d.ts.map
138
+
165
139
  //#endregion
166
- export { $interval, DateTime, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptorOptions, Timeout };
140
+ export { $interval, AlephaDateTime, DateTime, DateTimeApi, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptor, IntervalDescriptorOptions, Timeout };
167
141
  //# sourceMappingURL=index.d.ts.map
package/file.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+ var m = require('@alepha/file');
3
+ Object.keys(m).forEach(function (k) {
4
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
+ enumerable: true,
6
+ get: function () { return m[k]; }
7
+ });
8
+ });
package/file.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { FileLike, StreamLike } from "alepha";
2
+
3
+ //#region src/helpers/createFile.d.ts
4
+ declare const createFile: (source: string | Buffer | ArrayBuffer | StreamLike | File, options?: {
5
+ type?: string;
6
+ name?: string;
7
+ size?: number;
8
+ }) => FileLike;
9
+ declare const createFileFromWebFile: (source: File, options?: {
10
+ type?: string;
11
+ name?: string;
12
+ size?: number;
13
+ }) => FileLike;
14
+ declare const createFileFromBuffer: (source: Buffer, options?: {
15
+ type?: string;
16
+ name?: string;
17
+ }) => FileLike;
18
+ declare const createFileFromStream: (source: StreamLike, options?: {
19
+ type?: string;
20
+ name?: string;
21
+ size?: number;
22
+ }) => FileLike & {
23
+ _buffer: null | Buffer;
24
+ };
25
+ declare const createFileFromUrl: (url: string, options?: {
26
+ type?: string;
27
+ name?: string;
28
+ }) => FileLike;
29
+ /**
30
+ * Converts a stream-like object to a Buffer.
31
+ */
32
+ declare const streamToBuffer: (streamLike: StreamLike) => Promise<Buffer>;
33
+ /**
34
+ * Converts a Node.js Buffer to an ArrayBuffer.
35
+ */
36
+ declare const bufferToArrayBuffer: (buffer: Buffer) => ArrayBuffer;
37
+ declare const isReadableStream: (obj: unknown) => obj is NodeJS.ReadableStream;
38
+ //# sourceMappingURL=createFile.d.ts.map
39
+ //#endregion
40
+ //#region src/helpers/getContentType.d.ts
41
+ /**
42
+ * Can be used to get the content type of file based on its extension.
43
+ *
44
+ * Feel free to add more mime types in your project!
45
+ */
46
+ declare const mimeMap: Record<string, string>;
47
+ /**
48
+ * Returns the content type of file based on its filename.
49
+ * @see {mimeMap}
50
+ */
51
+ declare const getContentType: (filename: string) => string;
52
+ //# sourceMappingURL=getContentType.d.ts.map
53
+
54
+ //#endregion
55
+ export { bufferToArrayBuffer, createFile, createFileFromBuffer, createFileFromStream, createFileFromUrl, createFileFromWebFile, getContentType, isReadableStream, mimeMap, streamToBuffer };
56
+ //# sourceMappingURL=index.d.ts.map
package/file.js ADDED
@@ -0,0 +1 @@
1
+ export * from '@alepha/file'
package/lock/redis.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import * as _alepha_core0 from "alepha";
2
+ import { Logger } from "alepha";
1
3
  import { LockProvider } from "alepha/lock";
2
- import { Alepha, Logger } from "alepha";
3
4
  import { RedisProvider } from "alepha/redis";
4
5
 
5
6
  //#region src/providers/RedisLockProvider.d.ts
@@ -9,21 +10,18 @@ declare class RedisLockProvider implements LockProvider {
9
10
  set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
10
11
  del(...keys: string[]): Promise<void>;
11
12
  }
13
+ //# sourceMappingURL=RedisLockProvider.d.ts.map
12
14
  //#endregion
13
15
  //#region src/index.d.ts
14
- // ---------------------------------------------------------------------------------------------------------------------
15
16
  /**
16
- * Alepha Lock Redis Module
17
- *
18
- * Plugin for Alepha that provides a locking mechanism.
19
- *
20
- * @see {@link RedisLockProvider}
21
- * @module alepha.lock.redis
22
- */
23
- declare class AlephaLockRedis {
24
- readonly name = "alepha.lock.redis";
25
- readonly $services: (alepha: Alepha) => Alepha;
26
- }
17
+ * Plugin for Alepha that provides a locking mechanism.
18
+ *
19
+ * @see {@link RedisLockProvider}
20
+ * @module alepha.lock.redis
21
+ */
22
+ declare const AlephaLockRedis: _alepha_core0.ModuleDescriptor;
23
+ //# sourceMappingURL=index.d.ts.map
24
+
27
25
  //#endregion
28
26
  export { AlephaLockRedis, RedisLockProvider };
29
27
  //# sourceMappingURL=index.d.ts.map
package/lock.d.ts CHANGED
@@ -1,162 +1,170 @@
1
- import { Alepha, AsyncFn, HookDescriptor, KIND, Logger, OPTIONS, Static, TObject, TString } from "alepha";
2
- import { TopicDescriptor, TopicProvider } from "alepha/topic";
1
+ import * as _alepha_core1 from "alepha";
2
+ import * as _alepha_core0$1 from "alepha";
3
+ import * as _alepha_core0 from "alepha";
4
+ import { AsyncFn, Descriptor, KIND, Static } from "alepha";
5
+ import * as _alepha_topic0 from "alepha/topic";
6
+ import { TopicProvider } from "alepha/topic";
3
7
  import { DateTime, DateTimeProvider, DurationLike, Timeout } from "alepha/datetime";
8
+ import * as dayjs_plugin_duration0 from "dayjs/plugin/duration";
4
9
 
5
- //#region src/descriptors/$lock.d.ts
6
- declare const KEY = "LOCK";
7
- interface LockDescriptorOptions<TFunc extends AsyncFn> {
8
- /**
9
- * Function executed when the lock is acquired.
10
- */
11
- handler: TFunc;
10
+ //#region src/providers/LockProvider.d.ts
11
+ /**
12
+ * Store Provider Interface
13
+ */
14
+ declare abstract class LockProvider {
12
15
  /**
13
- * If true, the handler will wait for the lock to be released.
14
- *
15
- * @default false
16
- */
17
- wait?: boolean;
18
- key?: string | ((...args: Parameters<TFunc>) => string);
19
- maxDuration?: DurationLike;
20
- gracePeriod?: (...args: Parameters<TFunc>) => DurationLike | undefined;
21
- }
22
- interface LockDescriptor<TFunc extends AsyncFn> {
23
- [KIND]: typeof KEY;
24
- [OPTIONS]: LockDescriptorOptions<TFunc>;
16
+ * Set the string value of a key.
17
+ *
18
+ * @param key The key of the value to set.
19
+ * @param value The value to set.
20
+ * @param nx If set to true, the key will only be set if it does not already exist.
21
+ * @param px Set the specified expire time, in milliseconds.
22
+ */
23
+ abstract set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
25
24
  /**
26
- * Apply the lock.
27
- *
28
- * @param args
29
- */
30
- (...args: Parameters<TFunc>): Promise<void>;
25
+ * Remove the specified keys.
26
+ *
27
+ * @param keys The keys to delete.
28
+ */
29
+ abstract del(...keys: string[]): Promise<void>;
31
30
  }
31
+ //# sourceMappingURL=LockProvider.d.ts.map
32
+ //#endregion
33
+ //#region src/descriptors/$lock.d.ts
32
34
  /**
33
- * Lock descriptor
34
- *
35
- * Make sure that only one instance of the handler is running at a time.
36
- *
37
- * When connected to a remote store, the lock is shared across all processes.
38
- *
39
- * @param options
40
- */
35
+ * Lock descriptor
36
+ *
37
+ * Make sure that only one instance of the handler is running at a time.
38
+ *
39
+ * When connected to a remote store, the lock is shared across all processes.
40
+ *
41
+ * @param options
42
+ */
41
43
  declare const $lock: {
42
44
  <TFunc extends AsyncFn>(options: LockDescriptorOptions<TFunc>): LockDescriptor<TFunc>;
43
- [KIND]: string;
45
+ [KIND]: typeof LockDescriptor;
44
46
  };
45
- //#endregion
46
- //#region src/providers/LockProvider.d.ts
47
- /**
48
- * Store Provider Interface
49
- */
50
- declare abstract class LockProvider {
47
+ interface LockDescriptorOptions<TFunc extends AsyncFn> {
51
48
  /**
52
- * Set the string value of a key.
53
- *
54
- * @param key The key of the value to set.
55
- * @param value The value to set.
56
- * @param nx If set to true, the key will only be set if it does not already exist.
57
- * @param px Set the specified expire time, in milliseconds.
58
- */
59
- abstract set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
49
+ * Function executed when the lock is acquired.
50
+ */
51
+ handler: TFunc;
60
52
  /**
61
- * Remove the specified keys.
62
- *
63
- * @param keys The keys to delete.
64
- */
65
- abstract del(...keys: string[]): Promise<void>;
53
+ * If true, the handler will wait for the lock to be released.
54
+ *
55
+ * To understand:
56
+ *
57
+ * ### wait = false
58
+ * You have 3 servers running scheduled tasks, you want to ensure that only one of them runs the task at a time.
59
+ * But you don't want the other servers to wait for the lock to be released before they run the task.
60
+ *
61
+ * Problem with not waiting:
62
+ * If the lock is released before a new late trigger, handler will be executed multiple times.
63
+ * Aka, if you have 3 servers but not clock synchronized.
64
+ *
65
+ * ### wait = true
66
+ * You have 3 servers running a migration script on startup, migration script must be run only once.
67
+ * You want to wait the end of migration for each server as they all require the migration to be completed.
68
+ *
69
+ *
70
+ * @default false
71
+ */
72
+ wait?: boolean;
73
+ /**
74
+ * Create you own unique key for the lock.
75
+ */
76
+ name?: string | ((...args: Parameters<TFunc>) => string);
77
+ /**
78
+ * Lock timeout.
79
+ *
80
+ * @default 5 minutes
81
+ */
82
+ maxDuration?: DurationLike;
83
+ /**
84
+ * Additional lifetime of the lock after the handler has finished executing.
85
+ *
86
+ * This is useful to ensure that the lock is not released too early
87
+ *
88
+ * @default null
89
+ */
90
+ gracePeriod?: ((...args: Parameters<TFunc>) => DurationLike | undefined) | DurationLike;
66
91
  }
67
- //#endregion
68
- //#region src/providers/LockTopicProvider.d.ts
69
- declare class LockTopicProvider extends TopicProvider {}
70
- //#endregion
71
- //#region src/providers/LockDescriptorProvider.d.ts
72
- declare const envSchema: TObject<{
73
- LOCK_PREFIX_KEY: TString;
92
+ declare const envSchema: _alepha_core1.TObject<{
93
+ LOCK_PREFIX_KEY: _alepha_core1.TString;
74
94
  }>;
75
95
  declare module "alepha" {
76
96
  interface Env extends Partial<Static<typeof envSchema>> {}
77
97
  }
78
- declare class LockDescriptorProvider {
79
- protected readonly alepha: Alepha;
98
+ declare class LockDescriptor<TFunc extends AsyncFn> extends Descriptor<LockDescriptorOptions<TFunc>> {
99
+ protected readonly log: _alepha_core1.Logger;
100
+ protected readonly provider: LockProvider;
101
+ protected readonly env: {
102
+ LOCK_PREFIX_KEY: string;
103
+ };
80
104
  protected readonly dateTimeProvider: DateTimeProvider;
81
- protected readonly lockProvider: LockProvider;
82
- protected readonly lockTopicProvider: LockTopicProvider;
83
- protected readonly log: Logger;
84
- protected readonly env: Static<typeof envSchema>;
85
- protected readonly id: string;
86
- protected readonly locks: Map<string, LockDescriptorValue>;
87
- protected readonly configure: HookDescriptor<"configure">;
88
- protected readonly topicLockEnd: TopicDescriptor<{
89
- payload: TObject<{
90
- name: TString;
105
+ protected readonly id: `${string}-${string}-${string}-${string}-${string}`;
106
+ readonly maxDuration: dayjs_plugin_duration0.Duration;
107
+ protected readonly topicLockEnd: _alepha_topic0.TopicDescriptor<{
108
+ payload: _alepha_core1.TObject<{
109
+ name: _alepha_core1.TString;
91
110
  }>;
92
111
  }>;
93
- protected prefixKey(key: string): string;
112
+ run(...args: Parameters<TFunc>): Promise<void>;
94
113
  /**
95
- * Run the lock handler.
96
- *
97
- * @param value
98
- * @param args
99
- */
100
- protected run(value: LockDescriptorValue, ...args: any[]): Promise<void>;
114
+ * Set the lock for the given key.
115
+ */
116
+ protected lock(key: string): Promise<LockResult>;
117
+ protected setGracePeriod(key: string, lock: LockResult, ...args: Parameters<TFunc>): Promise<void>;
101
118
  protected wait(key: string, maxDuration: DurationLike): Promise<void>;
102
- /**
103
- * Lock the key.
104
- *
105
- * @param key - The key to lock.
106
- * @param item - The lock descriptor value.
107
- */
108
- protected lock(key: string, item: LockDescriptorValue): Promise<LockObject>;
109
- protected parse(value: string): LockObject;
119
+ protected key(...args: Parameters<TFunc>): string;
120
+ protected parse(value: string): LockResult;
110
121
  }
111
- interface LockDescriptorValue {
112
- options: LockDescriptorOptions<AsyncFn>;
113
- key: (...args: any[]) => string;
114
- maxDuration: DurationLike;
115
- }
116
- interface LockObject {
122
+ interface LockResult {
117
123
  id: string;
118
124
  createdAt: DateTime;
119
125
  endedAt?: DateTime;
120
126
  response?: string;
121
127
  }
128
+ //#endregion
129
+ //#region src/providers/LockTopicProvider.d.ts
130
+ declare abstract class LockTopicProvider extends TopicProvider {}
131
+ //# sourceMappingURL=LockTopicProvider.d.ts.map
132
+
122
133
  //#endregion
123
134
  //#region src/providers/MemoryLockProvider.d.ts
124
135
  /**
125
- * A simple in-memory store provider.
126
- */
136
+ * A simple in-memory store provider.
137
+ */
127
138
  declare class MemoryLockProvider implements LockProvider {
128
139
  protected readonly dateTimeProvider: DateTimeProvider;
129
- protected readonly log: Logger;
140
+ protected readonly log: _alepha_core0$1.Logger;
130
141
  /**
131
- * The in-memory store.
132
- */
142
+ * The in-memory store.
143
+ */
133
144
  protected store: Record<string, string>;
134
145
  /**
135
- * Timeouts used to expire keys.
136
- */
146
+ * Timeouts used to expire keys.
147
+ */
137
148
  protected storeTimeout: Record<string, Timeout>;
138
149
  set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
139
150
  del(...keys: string[]): Promise<void>;
140
151
  private ttl;
141
152
  }
153
+ //# sourceMappingURL=MemoryLockProvider.d.ts.map
142
154
  //#endregion
143
155
  //#region src/index.d.ts
144
- // ---------------------------------------------------------------------------------------------------------------------
145
156
  /**
146
- * Alepha Lock Module
147
- *
148
- * Lock a resource for a certain period of time.
149
- *
150
- * This module provides a memory implementation of the lock provider.
151
- * You probably want to use an implementation like RedisLockProvider for distributed systems.
152
- *
153
- * @see {@link $lock}
154
- * @module alepha.lock
155
- */
156
- declare class AlephaLock {
157
- readonly name = "alepha.lock";
158
- readonly $services: (alepha: Alepha) => Alepha;
159
- }
157
+ * Lock a resource for a certain period of time.
158
+ *
159
+ * This module provides a memory implementation of the lock provider.
160
+ * You probably want to use an implementation like RedisLockProvider for distributed systems.
161
+ *
162
+ * @see {@link $lock}
163
+ * @module alepha.lock
164
+ */
165
+ declare const AlephaLock: _alepha_core0.ModuleDescriptor;
166
+ //# sourceMappingURL=index.d.ts.map
167
+
160
168
  //#endregion
161
- export { $lock, AlephaLock, LockDescriptor, LockDescriptorOptions, LockDescriptorProvider, LockDescriptorValue, LockObject, LockProvider, LockTopicProvider, MemoryLockProvider };
169
+ export { $lock, AlephaLock, LockDescriptor, LockDescriptorOptions, LockProvider, LockResult, LockTopicProvider, MemoryLockProvider };
162
170
  //# sourceMappingURL=index.d.ts.map