alepha 0.7.1 → 0.7.2

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/datetime.d.ts CHANGED
@@ -1,36 +1,7 @@
1
- import { DurationLike as DurationLike$1, DateTime, Duration as Duration$1, DurationLikeObject } from 'luxon';
2
- export { DateTime } from 'luxon';
3
1
  import * as _alepha_core from '@alepha/core';
4
2
  import { Async } from '@alepha/core';
5
-
6
- interface IntervalDescriptorOptions {
7
- /**
8
- * Whether to start the interval immediately.
9
- *
10
- * @default false
11
- */
12
- run?: boolean;
13
- /**
14
- * Whether to attach the interval to the context.
15
- *
16
- * Attached intervals are automatically started when the context starts and stopped when the context stops.
17
- *
18
- * @default true
19
- */
20
- attach?: boolean;
21
- /**
22
- * The interval handler.
23
- */
24
- handler: () => Async<void>;
25
- /**
26
- * The interval duration.
27
- */
28
- duration: DurationLike$1;
29
- }
30
- /**
31
- * Registers a new interval.
32
- */
33
- declare const $interval: (options: IntervalDescriptorOptions) => Interval;
3
+ import dayjs, { ManipulateType, Dayjs } from 'dayjs';
4
+ import dayjsDuration from 'dayjs/plugin/duration';
34
5
 
35
6
  declare class Interval {
36
7
  private timer;
@@ -76,23 +47,25 @@ declare class Timeout {
76
47
  private start;
77
48
  }
78
49
 
50
+ type DateTime = dayjs.Dayjs;
51
+ type Duration = dayjsDuration.Duration;
52
+ type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
79
53
  declare class DateTimeProvider {
80
54
  protected log: _alepha_core.Logger;
81
55
  protected ref: DateTime | null;
82
56
  protected readonly timeouts: Timeout[];
83
57
  protected readonly intervals: Interval[];
58
+ constructor();
84
59
  protected readonly start: _alepha_core.HookDescriptor<"start">;
85
60
  protected readonly stop: _alepha_core.HookDescriptor<"stop">;
86
61
  /**
87
62
  * Create a new DateTime instance.
88
- *
89
- * @param date
90
63
  */
91
- of(date: Date | string | DateTime): DateTime<true>;
64
+ of(date: string | number | Date | Dayjs | null | undefined): DateTime;
92
65
  /**
93
66
  * Get the current date.
94
67
  */
95
- now(): DateTime<true>;
68
+ now(): DateTime;
96
69
  /**
97
70
  * Get the current date as a string.
98
71
  *
@@ -108,61 +81,76 @@ declare class DateTimeProvider {
108
81
  *
109
82
  * @protected
110
83
  */
111
- protected getCurrentDate(): DateTime<true>;
84
+ protected getCurrentDate(): DateTime;
112
85
  /**
113
86
  * Create a new Duration instance.
114
- *
115
- * @param duration
116
87
  */
117
- duration(duration: DurationLike$1 | string): Duration$1;
118
- /**
119
- * Add time to the current date.
120
- */
121
- add(duration: DurationLikeObject): Promise<void>;
88
+ duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
89
+ isDurationLike(value: unknown): value is DurationLike;
122
90
  /**
123
91
  * Return a promise that resolves after a next tick.
124
92
  * It uses `setTimeout` with 0ms delay.
125
93
  */
126
94
  tick(): Promise<void>;
95
+ /**
96
+ * Wait for a certain duration.
97
+ */
98
+ wait(duration: DurationLike, signal?: AbortSignal): Promise<void>;
99
+ /**
100
+ * Run a callback after a certain duration.
101
+ */
102
+ timeout(callback: () => void, duration: DurationLike): Timeout;
103
+ /**
104
+ * Create an interval.
105
+ *
106
+ * @param args
107
+ */
108
+ interval(args: IntervalDescriptorOptions): Interval;
109
+ /**
110
+ * Run a function with a deadline.
111
+ */
112
+ deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
113
+ /**
114
+ * Add time to the current date.
115
+ */
116
+ travel(duration: DurationLike): Promise<void>;
127
117
  /**
128
118
  * Stop the time.
129
119
  */
130
- pause(): DateTime<boolean>;
120
+ pause(): dayjs.Dayjs;
131
121
  /**
132
122
  * Reset the reference date.
133
123
  */
134
124
  reset(): void;
125
+ }
126
+
127
+ interface IntervalDescriptorOptions {
135
128
  /**
136
- * Wait for a certain duration.
129
+ * Whether to start the interval immediately.
137
130
  *
138
- * @param duration
139
- * @param signal
131
+ * @default false
140
132
  */
141
- wait(duration: DurationLike$1, signal?: AbortSignal): Promise<void>;
133
+ run?: boolean;
142
134
  /**
143
- * Run a callback after a certain duration.
135
+ * Whether to attach the interval to the context.
136
+ *
137
+ * Attached intervals are automatically started when the context starts and stopped when the context stops.
144
138
  *
145
- * @param callback
146
- * @param duration
139
+ * @default true
147
140
  */
148
- timeout(callback: () => void, duration: DurationLike$1): Timeout;
141
+ attach?: boolean;
149
142
  /**
150
- * Create an interval.
151
- *
152
- * @param args
143
+ * The interval handler.
153
144
  */
154
- interval(args: IntervalDescriptorOptions): Interval;
145
+ handler: () => Async<void>;
155
146
  /**
156
- * Run a function with a deadline.
157
- *
158
- * @param fn
159
- * @param duration
147
+ * The interval duration.
160
148
  */
161
- deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike$1): Promise<T>;
149
+ duration: DurationLike;
162
150
  }
151
+ /**
152
+ * Registers a new interval.
153
+ */
154
+ declare const $interval: (options: IntervalDescriptorOptions) => Interval;
163
155
 
164
- type DurationLike = DurationLike$1;
165
- type Duration = Duration$1;
166
- declare const isDurationLike: (value: unknown) => value is DurationLike;
167
-
168
- export { $interval, DateTimeProvider, type Duration, type DurationLike, Interval, type IntervalDescriptorOptions, Timeout, isDurationLike };
156
+ export { $interval, type DateTime, DateTimeProvider, type Duration, type DurationLike, Interval, type IntervalDescriptorOptions, Timeout };
package/lock.d.ts CHANGED
@@ -82,18 +82,9 @@ interface LockDescriptorOptions<TFunc extends AsyncFn> {
82
82
  * @default false
83
83
  */
84
84
  wait?: boolean;
85
- /**
86
- *
87
- */
88
85
  key?: string | ((...args: Parameters<TFunc>) => string);
89
- /**
90
- *
91
- */
92
86
  maxDuration?: DurationLike;
93
- /**
94
- *
95
- */
96
- gracePeriod?: DurationLike | ((...args: Parameters<TFunc>) => DurationLike | undefined);
87
+ gracePeriod?: (...args: Parameters<TFunc>) => DurationLike | undefined;
97
88
  }
98
89
  interface LockDescriptor<TFunc extends AsyncFn> {
99
90
  [KIND]: typeof KEY;
@@ -257,8 +248,6 @@ declare class RedisLockProvider implements LockProvider {
257
248
  set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
258
249
  /**
259
250
  * Remove the specified keys.
260
- *
261
- * @param keys The keys to delete.
262
251
  */
263
252
  del(...keys: string[]): Promise<void>;
264
253
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alepha",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "TypeScript framework for building full-stack apps with strict conventions, custom schemas, and React-based SPA or SSR without filesystem-based routing.",
@@ -12,28 +12,26 @@
12
12
  "main": "./core.js",
13
13
  "types": "./core.d.ts",
14
14
  "dependencies": {
15
- "@alepha/cache": "0.7.1",
16
- "@alepha/core": "0.7.1",
17
- "@alepha/datetime": "0.7.1",
18
- "@alepha/lock": "0.7.1",
19
- "@alepha/postgres": "0.7.1",
20
- "@alepha/queue": "0.7.1",
21
- "@alepha/react": "0.7.1",
22
- "@alepha/react-auth": "0.7.1",
23
- "@alepha/redis": "0.7.1",
24
- "@alepha/retry": "0.7.1",
25
- "@alepha/scheduler": "0.7.1",
26
- "@alepha/security": "0.7.1",
27
- "@alepha/server": "0.7.1",
28
- "@alepha/server-cookies": "0.7.1",
29
- "@alepha/server-metrics": "0.7.1",
30
- "@alepha/server-proxy": "0.6.10",
31
- "@alepha/server-static": "0.7.1",
32
- "@alepha/server-swagger": "0.7.1",
33
- "@alepha/testing": "0.7.1",
34
- "@alepha/topic": "0.7.1",
35
- "@alepha/vite": "0.7.1",
36
- "drizzle-kit": "0.31.2"
15
+ "@alepha/cache": "0.7.2",
16
+ "@alepha/core": "0.7.2",
17
+ "@alepha/datetime": "0.7.2",
18
+ "@alepha/lock": "0.7.2",
19
+ "@alepha/postgres": "0.7.2",
20
+ "@alepha/queue": "0.7.2",
21
+ "@alepha/react": "0.7.2",
22
+ "@alepha/react-auth": "0.7.2",
23
+ "@alepha/redis": "0.7.2",
24
+ "@alepha/retry": "0.7.2",
25
+ "@alepha/scheduler": "0.7.2",
26
+ "@alepha/security": "0.7.2",
27
+ "@alepha/server": "0.7.2",
28
+ "@alepha/server-cookies": "0.7.2",
29
+ "@alepha/server-metrics": "0.7.2",
30
+ "@alepha/server-static": "0.7.2",
31
+ "@alepha/server-swagger": "0.7.2",
32
+ "@alepha/testing": "0.7.2",
33
+ "@alepha/topic": "0.7.2",
34
+ "@alepha/vite": "0.7.2"
37
35
  },
38
36
  "peerDependencies": {
39
37
  "@types/react": "^19",
@@ -148,11 +146,6 @@
148
146
  "require": "./server/metrics.cjs",
149
147
  "types": "./server/metrics.d.ts"
150
148
  },
151
- "./server/proxy": {
152
- "import": "./server/proxy.js",
153
- "require": "./server/proxy.cjs",
154
- "types": "./server/proxy.d.ts"
155
- },
156
149
  "./server/static": {
157
150
  "import": "./server/static.js",
158
151
  "require": "./server/static.cjs",