alepha 0.7.6 → 0.8.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 (59) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +44 -44
  3. package/batch.cjs +8 -0
  4. package/batch.d.ts +114 -0
  5. package/batch.js +1 -0
  6. package/cache/redis.d.ts +15 -18
  7. package/cache.d.ts +115 -119
  8. package/command.cjs +8 -0
  9. package/command.d.ts +154 -0
  10. package/command.js +1 -0
  11. package/core.d.ts +800 -795
  12. package/datetime.d.ts +76 -76
  13. package/lock/redis.d.ts +12 -12
  14. package/lock.d.ts +70 -75
  15. package/package.json +102 -29
  16. package/postgres.d.ts +385 -278
  17. package/queue/redis.d.ts +15 -13
  18. package/queue.d.ts +16 -13
  19. package/react/auth.d.ts +16 -16
  20. package/react/head.cjs +8 -0
  21. package/react/head.d.ts +92 -0
  22. package/react/head.js +1 -0
  23. package/react.d.ts +90 -116
  24. package/redis.d.ts +20 -27
  25. package/retry.d.ts +74 -54
  26. package/scheduler.d.ts +14 -13
  27. package/security.d.ts +38 -41
  28. package/server/cache.d.ts +9 -7
  29. package/server/compress.cjs +8 -0
  30. package/server/compress.d.ts +26 -0
  31. package/server/compress.js +1 -0
  32. package/server/cookies.d.ts +71 -14
  33. package/server/cors.cjs +8 -0
  34. package/server/cors.d.ts +29 -0
  35. package/server/cors.js +1 -0
  36. package/server/health.cjs +8 -0
  37. package/server/health.d.ts +42 -0
  38. package/server/health.js +1 -0
  39. package/server/helmet.cjs +8 -0
  40. package/server/helmet.d.ts +72 -0
  41. package/server/helmet.js +1 -0
  42. package/server/links.cjs +8 -0
  43. package/server/links.d.ts +179 -0
  44. package/server/links.js +1 -0
  45. package/server/metrics.cjs +8 -0
  46. package/server/metrics.d.ts +37 -0
  47. package/server/metrics.js +1 -0
  48. package/server/multipart.cjs +8 -0
  49. package/server/multipart.d.ts +48 -0
  50. package/server/multipart.js +1 -0
  51. package/server/proxy.cjs +8 -0
  52. package/server/proxy.d.ts +41 -0
  53. package/server/proxy.js +1 -0
  54. package/server/static.d.ts +63 -51
  55. package/server/swagger.d.ts +50 -50
  56. package/server.d.ts +220 -437
  57. package/topic/redis.d.ts +24 -23
  58. package/topic.d.ts +9 -19
  59. package/vite.d.ts +8 -1
package/datetime.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as _alepha_core1 from "@alepha/core";
2
- import { Async } from "@alepha/core";
1
+ import { Async, HookDescriptor, Logger } from "alepha";
3
2
  import dayjs, { Dayjs, ManipulateType } from "dayjs";
4
3
  import dayjsDuration from "dayjs/plugin/duration.js";
5
4
 
@@ -11,18 +10,18 @@ declare class Interval {
11
10
  private options;
12
11
  constructor(duration: number, options: IntervalDescriptorOptions);
13
12
  /**
14
- * Start the interval.
15
- */
13
+ * Start the interval.
14
+ */
16
15
  start(): Promise<void>;
17
16
  /**
18
- * Add time to the interval.
19
- *
20
- * @param amountMs
21
- */
17
+ * Add time to the interval.
18
+ *
19
+ * @param amountMs
20
+ */
22
21
  add(amountMs: number): Promise<void>;
23
22
  /**
24
- * Clear the interval.
25
- */
23
+ * Clear the interval.
24
+ */
26
25
  clear(): void;
27
26
  }
28
27
  //#endregion
@@ -34,18 +33,18 @@ declare class Timeout {
34
33
  private readonly callback;
35
34
  constructor(now: number, duration: number, callback: () => void);
36
35
  /**
37
- * Add time to the timeout.
38
- */
36
+ * Add time to the timeout.
37
+ */
39
38
  add(amountMs: number): void;
40
39
  /**
41
- * Clear the timeout.
42
- */
40
+ * Clear the timeout.
41
+ */
43
42
  clear(): void;
44
43
  /**
45
- * Start the timeout.
46
- *
47
- * @private
48
- */
44
+ * Start the timeout.
45
+ *
46
+ * @private
47
+ */
49
48
  private start;
50
49
  }
51
50
  //#endregion
@@ -54,113 +53,114 @@ type DateTime = dayjs.Dayjs;
54
53
  type Duration = dayjsDuration.Duration;
55
54
  type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
56
55
  declare class DateTimeProvider {
57
- protected log: _alepha_core1.Logger;
56
+ protected log: Logger;
58
57
  protected ref: DateTime | null;
59
58
  protected readonly timeouts: Timeout[];
60
59
  protected readonly intervals: Interval[];
61
60
  constructor();
62
- protected readonly start: _alepha_core1.HookDescriptor<"start">;
63
- protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
61
+ protected readonly start: HookDescriptor<"start">;
62
+ protected readonly stop: HookDescriptor<"stop">;
64
63
  /**
65
- * Create a new DateTime instance.
66
- */
64
+ * Create a new DateTime instance.
65
+ */
67
66
  of(date: string | number | Date | Dayjs | null | undefined): DateTime;
68
67
  /**
69
- * Get the current date.
70
- */
68
+ * Get the current date.
69
+ */
71
70
  now(): DateTime;
72
71
  /**
73
- * Get the current date as a string.
74
- *
75
- * @param date
76
- */
72
+ * Get the current date as a string.
73
+ *
74
+ * @param date
75
+ */
77
76
  toISOString(date?: Date | string | DateTime): string;
78
77
  /**
79
- * Get the current date as a string.
80
- */
78
+ * Get the current date as a string.
79
+ */
81
80
  nowISOString(): string;
82
81
  /**
83
- * Get the current date as a string.
84
- *
85
- * @protected
86
- */
82
+ * Get the current date as a string.
83
+ *
84
+ * @protected
85
+ */
87
86
  protected getCurrentDate(): DateTime;
88
87
  /**
89
- * Create a new Duration instance.
90
- */
88
+ * Create a new Duration instance.
89
+ */
91
90
  duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
92
91
  isDurationLike(value: unknown): value is DurationLike;
93
92
  /**
94
- * Return a promise that resolves after a next tick.
95
- * It uses `setTimeout` with 0ms delay.
96
- */
93
+ * Return a promise that resolves after a next tick.
94
+ * It uses `setTimeout` with 0ms delay.
95
+ */
97
96
  tick(): Promise<void>;
98
97
  /**
99
- * Wait for a certain duration.
100
- *
101
- * You can clear the timeout by using the `AbortSignal` API.
102
- * Aborted signal will resolve the promise immediately, it does not reject it.
103
- */
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
+ */
104
103
  wait(duration: DurationLike, options?: {
105
104
  signal?: AbortSignal;
106
105
  now?: number;
107
106
  }): Promise<void>;
108
107
  /**
109
- * Run a callback after a certain duration.
110
- */
108
+ * Run a callback after a certain duration.
109
+ */
111
110
  timeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
112
111
  /**
113
- * Create an interval.
114
- *
115
- * @param args
116
- */
112
+ * Create an interval.
113
+ *
114
+ * @param args
115
+ */
117
116
  interval(args: IntervalDescriptorOptions): Interval;
118
117
  /**
119
- * Run a function with a deadline.
120
- */
118
+ * Run a function with a deadline.
119
+ */
121
120
  deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
121
+ // Testing
122
122
  /**
123
- * Add time to the current date.
124
- */
123
+ * Add time to the current date.
124
+ */
125
125
  travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
126
126
  /**
127
- * Stop the time.
128
- */
129
- pause(): dayjs.Dayjs;
127
+ * Stop the time.
128
+ */
129
+ pause(): DateTime;
130
130
  /**
131
- * Reset the reference date.
132
- */
131
+ * Reset the reference date.
132
+ */
133
133
  reset(): void;
134
134
  }
135
135
  //#endregion
136
136
  //#region src/descriptors/$interval.d.ts
137
137
  interface IntervalDescriptorOptions {
138
138
  /**
139
- * Whether to start the interval immediately.
140
- *
141
- * @default false
142
- */
139
+ * Whether to start the interval immediately.
140
+ *
141
+ * @default false
142
+ */
143
143
  run?: boolean;
144
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
- */
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
151
  attach?: boolean;
152
152
  /**
153
- * The interval handler.
154
- */
153
+ * The interval handler.
154
+ */
155
155
  handler: () => Async<void>;
156
156
  /**
157
- * The interval duration.
158
- */
157
+ * The interval duration.
158
+ */
159
159
  duration: DurationLike;
160
160
  }
161
161
  /**
162
- * Registers a new interval.
163
- */
162
+ * Registers a new interval.
163
+ */
164
164
  declare const $interval: (options: IntervalDescriptorOptions) => Interval;
165
165
  //#endregion
166
166
  export { $interval, DateTime, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptorOptions, Timeout };
package/lock/redis.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- import { LockProvider } from "@alepha/lock";
2
- import * as _alepha_core0 from "@alepha/core";
3
- import { Alepha } from "@alepha/core";
4
- import { RedisProvider } from "@alepha/redis";
1
+ import { LockProvider } from "alepha/lock";
2
+ import { Alepha, Logger } from "alepha";
3
+ import { RedisProvider } from "alepha/redis";
5
4
 
6
5
  //#region src/providers/RedisLockProvider.d.ts
7
6
  declare class RedisLockProvider implements LockProvider {
8
- protected readonly log: _alepha_core0.Logger;
7
+ protected readonly log: Logger;
9
8
  protected readonly redisProvider: RedisProvider;
10
9
  set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
11
10
  del(...keys: string[]): Promise<void>;
12
11
  }
13
12
  //#endregion
14
13
  //#region src/index.d.ts
14
+ // ---------------------------------------------------------------------------------------------------------------------
15
15
  /**
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
- */
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
23
  declare class AlephaLockRedis {
24
24
  readonly name = "alepha.lock.redis";
25
25
  readonly $services: (alepha: Alepha) => Alepha;
package/lock.d.ts CHANGED
@@ -1,23 +1,19 @@
1
- import * as _alepha_core2 from "@alepha/core";
2
- import * as _alepha_core0 from "@alepha/core";
3
- import { Alepha, AsyncFn, KIND, OPTIONS, Static } from "@alepha/core";
4
- import * as _alepha_topic8 from "@alepha/topic";
5
- import { TopicProvider } from "@alepha/topic";
6
- import { DateTime, DateTimeProvider, DurationLike, Timeout } from "@alepha/datetime";
7
- import * as _sinclair_typebox1 from "@sinclair/typebox";
1
+ import { Alepha, AsyncFn, HookDescriptor, KIND, Logger, OPTIONS, Static, TObject, TString } from "alepha";
2
+ import { TopicDescriptor, TopicProvider } from "alepha/topic";
3
+ import { DateTime, DateTimeProvider, DurationLike, Timeout } from "alepha/datetime";
8
4
 
9
5
  //#region src/descriptors/$lock.d.ts
10
6
  declare const KEY = "LOCK";
11
7
  interface LockDescriptorOptions<TFunc extends AsyncFn> {
12
8
  /**
13
- * Function executed when the lock is acquired.
14
- */
9
+ * Function executed when the lock is acquired.
10
+ */
15
11
  handler: TFunc;
16
12
  /**
17
- * If true, the handler will wait for the lock to be released.
18
- *
19
- * @default false
20
- */
13
+ * If true, the handler will wait for the lock to be released.
14
+ *
15
+ * @default false
16
+ */
21
17
  wait?: boolean;
22
18
  key?: string | ((...args: Parameters<TFunc>) => string);
23
19
  maxDuration?: DurationLike;
@@ -27,21 +23,21 @@ interface LockDescriptor<TFunc extends AsyncFn> {
27
23
  [KIND]: typeof KEY;
28
24
  [OPTIONS]: LockDescriptorOptions<TFunc>;
29
25
  /**
30
- * Apply the lock.
31
- *
32
- * @param args
33
- */
26
+ * Apply the lock.
27
+ *
28
+ * @param args
29
+ */
34
30
  (...args: Parameters<TFunc>): Promise<void>;
35
31
  }
36
32
  /**
37
- * Lock descriptor
38
- *
39
- * Make sure that only one instance of the handler is running at a time.
40
- *
41
- * When connected to a remote store, the lock is shared across all processes.
42
- *
43
- * @param options
44
- */
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
+ */
45
41
  declare const $lock: {
46
42
  <TFunc extends AsyncFn>(options: LockDescriptorOptions<TFunc>): LockDescriptor<TFunc>;
47
43
  [KIND]: string;
@@ -49,23 +45,23 @@ declare const $lock: {
49
45
  //#endregion
50
46
  //#region src/providers/LockProvider.d.ts
51
47
  /**
52
- * Store Provider Interface
53
- */
48
+ * Store Provider Interface
49
+ */
54
50
  declare abstract class LockProvider {
55
51
  /**
56
- * Set the string value of a key.
57
- *
58
- * @param key The key of the value to set.
59
- * @param value The value to set.
60
- * @param nx If set to true, the key will only be set if it does not already exist.
61
- * @param px Set the specified expire time, in milliseconds.
62
- */
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
+ */
63
59
  abstract set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
64
60
  /**
65
- * Remove the specified keys.
66
- *
67
- * @param keys The keys to delete.
68
- */
61
+ * Remove the specified keys.
62
+ *
63
+ * @param keys The keys to delete.
64
+ */
69
65
  abstract del(...keys: string[]): Promise<void>;
70
66
  }
71
67
  //#endregion
@@ -73,8 +69,8 @@ declare abstract class LockProvider {
73
69
  declare class LockTopicProvider extends TopicProvider {}
74
70
  //#endregion
75
71
  //#region src/providers/LockDescriptorProvider.d.ts
76
- declare const envSchema: _alepha_core2.TObject<{
77
- LOCK_PREFIX_KEY: _sinclair_typebox1.TString;
72
+ declare const envSchema: TObject<{
73
+ LOCK_PREFIX_KEY: TString;
78
74
  }>;
79
75
  declare module "alepha" {
80
76
  interface Env extends Partial<Static<typeof envSchema>> {}
@@ -84,33 +80,31 @@ declare class LockDescriptorProvider {
84
80
  protected readonly dateTimeProvider: DateTimeProvider;
85
81
  protected readonly lockProvider: LockProvider;
86
82
  protected readonly lockTopicProvider: LockTopicProvider;
87
- protected readonly log: _alepha_core2.Logger;
88
- protected readonly env: {
89
- LOCK_PREFIX_KEY: string;
90
- };
83
+ protected readonly log: Logger;
84
+ protected readonly env: Static<typeof envSchema>;
91
85
  protected readonly id: string;
92
86
  protected readonly locks: Map<string, LockDescriptorValue>;
93
- protected readonly configure: _alepha_core2.HookDescriptor<"configure">;
94
- protected readonly topicLockEnd: _alepha_topic8.TopicDescriptor<{
95
- payload: _alepha_core2.TObject<{
96
- name: _sinclair_typebox1.TString;
87
+ protected readonly configure: HookDescriptor<"configure">;
88
+ protected readonly topicLockEnd: TopicDescriptor<{
89
+ payload: TObject<{
90
+ name: TString;
97
91
  }>;
98
92
  }>;
99
93
  protected prefixKey(key: string): string;
100
94
  /**
101
- * Run the lock handler.
102
- *
103
- * @param value
104
- * @param args
105
- */
95
+ * Run the lock handler.
96
+ *
97
+ * @param value
98
+ * @param args
99
+ */
106
100
  protected run(value: LockDescriptorValue, ...args: any[]): Promise<void>;
107
101
  protected wait(key: string, maxDuration: DurationLike): Promise<void>;
108
102
  /**
109
- * Lock the key.
110
- *
111
- * @param key - The key to lock.
112
- * @param item - The lock descriptor value.
113
- */
103
+ * Lock the key.
104
+ *
105
+ * @param key - The key to lock.
106
+ * @param item - The lock descriptor value.
107
+ */
114
108
  protected lock(key: string, item: LockDescriptorValue): Promise<LockObject>;
115
109
  protected parse(value: string): LockObject;
116
110
  }
@@ -128,18 +122,18 @@ interface LockObject {
128
122
  //#endregion
129
123
  //#region src/providers/MemoryLockProvider.d.ts
130
124
  /**
131
- * A simple in-memory store provider.
132
- */
125
+ * A simple in-memory store provider.
126
+ */
133
127
  declare class MemoryLockProvider implements LockProvider {
134
128
  protected readonly dateTimeProvider: DateTimeProvider;
135
- protected readonly log: _alepha_core0.Logger;
129
+ protected readonly log: Logger;
136
130
  /**
137
- * The in-memory store.
138
- */
131
+ * The in-memory store.
132
+ */
139
133
  protected store: Record<string, string>;
140
134
  /**
141
- * Timeouts used to expire keys.
142
- */
135
+ * Timeouts used to expire keys.
136
+ */
143
137
  protected storeTimeout: Record<string, Timeout>;
144
138
  set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
145
139
  del(...keys: string[]): Promise<void>;
@@ -147,17 +141,18 @@ declare class MemoryLockProvider implements LockProvider {
147
141
  }
148
142
  //#endregion
149
143
  //#region src/index.d.ts
144
+ // ---------------------------------------------------------------------------------------------------------------------
150
145
  /**
151
- * Alepha Lock Module
152
- *
153
- * Lock a resource for a certain period of time.
154
- *
155
- * This module provides a memory implementation of the lock provider.
156
- * You probably want to use an implementation like RedisLockProvider for distributed systems.
157
- *
158
- * @see {@link $lock}
159
- * @module alepha.lock
160
- */
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
+ */
161
156
  declare class AlephaLock {
162
157
  readonly name = "alepha.lock";
163
158
  readonly $services: (alepha: Alepha) => Alepha;