alepha 0.7.5 → 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 (98) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +44 -44
  3. package/cache/redis.cjs +4 -8
  4. package/cache/redis.d.ts +28 -89
  5. package/cache/redis.js +1 -1
  6. package/cache.cjs +4 -8
  7. package/cache.d.ts +189 -265
  8. package/cache.js +1 -1
  9. package/core.cjs +4 -8
  10. package/core.d.ts +950 -929
  11. package/core.js +1 -1
  12. package/datetime.cjs +4 -8
  13. package/datetime.d.ts +151 -146
  14. package/datetime.js +1 -1
  15. package/lock/redis.cjs +7 -49
  16. package/lock/redis.d.ts +15 -12
  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 -39
  22. package/postgres.cjs +4 -8
  23. package/postgres.d.ts +1314 -4398
  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 +166 -282
  33. package/react/auth.js +1 -1
  34. package/react.cjs +4 -8
  35. package/react.d.ts +509 -551
  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 +125 -182
  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 +41 -38
  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 +96 -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 +89 -82
  75. package/vite.js +1 -1
  76. package/src/cache/redis.ts +0 -1
  77. package/src/cache.ts +0 -1
  78. package/src/core.ts +0 -1
  79. package/src/datetime.ts +0 -1
  80. package/src/lock/redis.ts +0 -1
  81. package/src/lock.ts +0 -1
  82. package/src/postgres.ts +0 -1
  83. package/src/queue/redis.ts +0 -1
  84. package/src/queue.ts +0 -1
  85. package/src/react/auth.ts +0 -1
  86. package/src/react.ts +0 -1
  87. package/src/redis.ts +0 -1
  88. package/src/retry.ts +0 -1
  89. package/src/scheduler.ts +0 -1
  90. package/src/security.ts +0 -1
  91. package/src/server/cache.ts +0 -1
  92. package/src/server/cookies.ts +0 -1
  93. package/src/server/static.ts +0 -1
  94. package/src/server/swagger.ts +0 -1
  95. package/src/server.ts +0 -1
  96. package/src/topic/redis.ts +0 -1
  97. package/src/topic.ts +0 -1
  98. package/src/vite.ts +0 -1
package/core.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/core';
1
+ export * from '@alepha/core'
package/datetime.cjs CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict';
2
-
3
- var datetime = require('@alepha/datetime');
4
-
5
-
6
-
7
- Object.keys(datetime).forEach(function (k) {
2
+ var m = require('@alepha/datetime');
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 datetime[k]; }
6
+ get: function () { return m[k]; }
11
7
  });
12
- });
8
+ });
package/datetime.d.ts CHANGED
@@ -1,162 +1,167 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Async } from '@alepha/core';
3
- import dayjs, { ManipulateType, Dayjs } from 'dayjs';
4
- import dayjsDuration from 'dayjs/plugin/duration.js';
1
+ import * as _alepha_core1 from "@alepha/core";
2
+ import { Async } from "@alepha/core";
3
+ import dayjs, { Dayjs, ManipulateType } from "dayjs";
4
+ import dayjsDuration from "dayjs/plugin/duration.js";
5
5
 
6
+ //#region src/helpers/Interval.d.ts
6
7
  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;
8
+ private timer;
9
+ private readonly run;
10
+ private duration;
11
+ private options;
12
+ constructor(duration: number, options: IntervalDescriptorOptions);
13
+ /**
14
+ * Start the interval.
15
+ */
16
+ start(): Promise<void>;
17
+ /**
18
+ * Add time to the interval.
19
+ *
20
+ * @param amountMs
21
+ */
22
+ add(amountMs: number): Promise<void>;
23
+ /**
24
+ * Clear the interval.
25
+ */
26
+ clear(): void;
26
27
  }
27
-
28
+ //#endregion
29
+ //#region src/helpers/Timeout.d.ts
28
30
  declare class Timeout {
29
- private timer;
30
- private duration;
31
- private readonly now;
32
- private readonly callback;
33
- constructor(now: number, duration: number, callback: () => void);
34
- /**
35
- * Add time to the timeout.
36
- */
37
- add(amountMs: number): void;
38
- /**
39
- * Clear the timeout.
40
- */
41
- clear(): void;
42
- /**
43
- * Start the timeout.
44
- *
45
- * @private
46
- */
47
- private start;
31
+ private timer;
32
+ private duration;
33
+ private readonly now;
34
+ private readonly callback;
35
+ constructor(now: number, duration: number, callback: () => void);
36
+ /**
37
+ * Add time to the timeout.
38
+ */
39
+ add(amountMs: number): void;
40
+ /**
41
+ * Clear the timeout.
42
+ */
43
+ clear(): void;
44
+ /**
45
+ * Start the timeout.
46
+ *
47
+ * @private
48
+ */
49
+ private start;
48
50
  }
49
-
51
+ //#endregion
52
+ //#region src/providers/DateTimeProvider.d.ts
50
53
  type DateTime = dayjs.Dayjs;
51
54
  type Duration = dayjsDuration.Duration;
52
55
  type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
53
56
  declare class DateTimeProvider {
54
- protected log: _alepha_core.Logger;
55
- protected ref: DateTime | null;
56
- protected readonly timeouts: Timeout[];
57
- protected readonly intervals: Interval[];
58
- constructor();
59
- protected readonly start: _alepha_core.HookDescriptor<"start">;
60
- protected readonly stop: _alepha_core.HookDescriptor<"stop">;
61
- /**
62
- * Create a new DateTime instance.
63
- */
64
- of(date: string | number | Date | Dayjs | null | undefined): DateTime;
65
- /**
66
- * Get the current date.
67
- */
68
- now(): DateTime;
69
- /**
70
- * Get the current date as a string.
71
- *
72
- * @param date
73
- */
74
- toISOString(date?: Date | string | DateTime): string;
75
- /**
76
- * Get the current date as a string.
77
- */
78
- nowISOString(): string;
79
- /**
80
- * Get the current date as a string.
81
- *
82
- * @protected
83
- */
84
- protected getCurrentDate(): DateTime;
85
- /**
86
- * Create a new Duration instance.
87
- */
88
- duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
89
- isDurationLike(value: unknown): value is DurationLike;
90
- /**
91
- * Return a promise that resolves after a next tick.
92
- * It uses `setTimeout` with 0ms delay.
93
- */
94
- tick(): Promise<void>;
95
- /**
96
- * Wait for a certain duration.
97
- *
98
- * You can clear the timeout by using the `AbortSignal` API.
99
- * Aborted signal will resolve the promise immediately, it does not reject it.
100
- */
101
- wait(duration: DurationLike, options?: {
102
- signal?: AbortSignal;
103
- now?: number;
104
- }): Promise<void>;
105
- /**
106
- * Run a callback after a certain duration.
107
- */
108
- timeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
109
- /**
110
- * Create an interval.
111
- *
112
- * @param args
113
- */
114
- interval(args: IntervalDescriptorOptions): Interval;
115
- /**
116
- * Run a function with a deadline.
117
- */
118
- deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
119
- /**
120
- * Add time to the current date.
121
- */
122
- travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
123
- /**
124
- * Stop the time.
125
- */
126
- pause(): dayjs.Dayjs;
127
- /**
128
- * Reset the reference date.
129
- */
130
- reset(): void;
57
+ protected log: _alepha_core1.Logger;
58
+ protected ref: DateTime | null;
59
+ protected readonly timeouts: Timeout[];
60
+ protected readonly intervals: Interval[];
61
+ constructor();
62
+ protected readonly start: _alepha_core1.HookDescriptor<"start">;
63
+ protected readonly stop: _alepha_core1.HookDescriptor<"stop">;
64
+ /**
65
+ * Create a new DateTime instance.
66
+ */
67
+ of(date: string | number | Date | Dayjs | null | undefined): DateTime;
68
+ /**
69
+ * Get the current date.
70
+ */
71
+ now(): DateTime;
72
+ /**
73
+ * Get the current date as a string.
74
+ *
75
+ * @param date
76
+ */
77
+ toISOString(date?: Date | string | DateTime): string;
78
+ /**
79
+ * Get the current date as a string.
80
+ */
81
+ nowISOString(): string;
82
+ /**
83
+ * Get the current date as a string.
84
+ *
85
+ * @protected
86
+ */
87
+ protected getCurrentDate(): DateTime;
88
+ /**
89
+ * Create a new Duration instance.
90
+ */
91
+ duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
92
+ isDurationLike(value: unknown): value is DurationLike;
93
+ /**
94
+ * Return a promise that resolves after a next tick.
95
+ * It uses `setTimeout` with 0ms delay.
96
+ */
97
+ tick(): Promise<void>;
98
+ /**
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
+ */
104
+ wait(duration: DurationLike, options?: {
105
+ signal?: AbortSignal;
106
+ now?: number;
107
+ }): Promise<void>;
108
+ /**
109
+ * Run a callback after a certain duration.
110
+ */
111
+ timeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
112
+ /**
113
+ * Create an interval.
114
+ *
115
+ * @param args
116
+ */
117
+ interval(args: IntervalDescriptorOptions): Interval;
118
+ /**
119
+ * Run a function with a deadline.
120
+ */
121
+ deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
122
+ /**
123
+ * Add time to the current date.
124
+ */
125
+ travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
126
+ /**
127
+ * Stop the time.
128
+ */
129
+ pause(): dayjs.Dayjs;
130
+ /**
131
+ * Reset the reference date.
132
+ */
133
+ reset(): void;
131
134
  }
132
-
135
+ //#endregion
136
+ //#region src/descriptors/$interval.d.ts
133
137
  interface IntervalDescriptorOptions {
134
- /**
135
- * Whether to start the interval immediately.
136
- *
137
- * @default false
138
- */
139
- run?: boolean;
140
- /**
141
- * Whether to attach the interval to the context.
142
- *
143
- * Attached intervals are automatically started when the context starts and stopped when the context stops.
144
- *
145
- * @default true
146
- */
147
- attach?: boolean;
148
- /**
149
- * The interval handler.
150
- */
151
- handler: () => Async<void>;
152
- /**
153
- * The interval duration.
154
- */
155
- duration: DurationLike;
138
+ /**
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
+ */
159
+ duration: DurationLike;
156
160
  }
157
161
  /**
158
162
  * Registers a new interval.
159
163
  */
160
164
  declare const $interval: (options: IntervalDescriptorOptions) => Interval;
161
-
162
- export { $interval, type DateTime, DateTimeProvider, type Duration, type DurationLike, Interval, type IntervalDescriptorOptions, Timeout };
165
+ //#endregion
166
+ export { $interval, DateTime, DateTimeProvider, Duration, DurationLike, Interval, IntervalDescriptorOptions, Timeout };
167
+ //# sourceMappingURL=index.d.ts.map
package/datetime.js CHANGED
@@ -1 +1 @@
1
- export * from '@alepha/datetime';
1
+ export * from '@alepha/datetime'
package/lock/redis.cjs CHANGED
@@ -1,50 +1,8 @@
1
1
  'use strict';
2
-
3
- var lock = require('@alepha/lock');
4
- var topicRedis = require('@alepha/topic-redis');
5
- var core = require('@alepha/core');
6
- var redis = require('@alepha/redis');
7
-
8
- class RedisLockProvider {
9
- log = core.$logger();
10
- redisProvider = core.$inject(redis.RedisProvider);
11
- async set(key, value, nx, px) {
12
- const options = {
13
- GET: true
14
- // all the secrets of $lock is based on this
15
- };
16
- if (px) {
17
- options.expiration = {
18
- type: "PX",
19
- value: px
20
- };
21
- }
22
- if (nx) {
23
- options.condition = "NX";
24
- }
25
- const resp = await this.redisProvider.set(key, value, options);
26
- if (resp === null) {
27
- this.log.debug(`Lock already exists`, { key, value });
28
- return value;
29
- }
30
- return resp.toString("utf-8");
31
- }
32
- async del(...keys) {
33
- await this.redisProvider.del(keys);
34
- }
35
- }
36
- class AlephaLockRedis {
37
- name = "alepha.lock.redis";
38
- $services = (alepha) => alepha.with({
39
- provide: lock.LockTopicProvider,
40
- use: topicRedis.RedisTopicProvider,
41
- optional: true
42
- }).with({
43
- provide: lock.LockProvider,
44
- use: RedisLockProvider,
45
- optional: true
46
- }).with(lock.AlephaLock);
47
- }
48
-
49
- exports.AlephaLockRedis = AlephaLockRedis;
50
- exports.RedisLockProvider = RedisLockProvider;
2
+ var m = require('@alepha/lock-redis');
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/lock/redis.d.ts CHANGED
@@ -1,15 +1,17 @@
1
- import * as _alepha_core from '@alepha/core';
2
- import { Alepha } from '@alepha/core';
3
- import { LockProvider } from '@alepha/lock';
4
- import { RedisProvider } from '@alepha/redis';
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";
5
5
 
6
+ //#region src/providers/RedisLockProvider.d.ts
6
7
  declare class RedisLockProvider implements LockProvider {
7
- protected readonly log: _alepha_core.Logger;
8
- protected readonly redisProvider: RedisProvider;
9
- set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
10
- del(...keys: string[]): Promise<void>;
8
+ protected readonly log: _alepha_core0.Logger;
9
+ protected readonly redisProvider: RedisProvider;
10
+ set(key: string, value: string, nx?: boolean, px?: number): Promise<string>;
11
+ del(...keys: string[]): Promise<void>;
11
12
  }
12
-
13
+ //#endregion
14
+ //#region src/index.d.ts
13
15
  /**
14
16
  * Alepha Lock Redis Module
15
17
  *
@@ -19,8 +21,9 @@ declare class RedisLockProvider implements LockProvider {
19
21
  * @module alepha.lock.redis
20
22
  */
21
23
  declare class AlephaLockRedis {
22
- readonly name = "alepha.lock.redis";
23
- readonly $services: (alepha: Alepha) => Alepha;
24
+ readonly name = "alepha.lock.redis";
25
+ readonly $services: (alepha: Alepha) => Alepha;
24
26
  }
25
-
27
+ //#endregion
26
28
  export { AlephaLockRedis, RedisLockProvider };
29
+ //# sourceMappingURL=index.d.ts.map
package/lock/redis.js CHANGED
@@ -1,47 +1 @@
1
- import { LockTopicProvider, LockProvider, AlephaLock } from '@alepha/lock';
2
- import { RedisTopicProvider } from '@alepha/topic-redis';
3
- import { $logger, $inject } from '@alepha/core';
4
- import { RedisProvider } from '@alepha/redis';
5
-
6
- class RedisLockProvider {
7
- log = $logger();
8
- redisProvider = $inject(RedisProvider);
9
- async set(key, value, nx, px) {
10
- const options = {
11
- GET: true
12
- // all the secrets of $lock is based on this
13
- };
14
- if (px) {
15
- options.expiration = {
16
- type: "PX",
17
- value: px
18
- };
19
- }
20
- if (nx) {
21
- options.condition = "NX";
22
- }
23
- const resp = await this.redisProvider.set(key, value, options);
24
- if (resp === null) {
25
- this.log.debug(`Lock already exists`, { key, value });
26
- return value;
27
- }
28
- return resp.toString("utf-8");
29
- }
30
- async del(...keys) {
31
- await this.redisProvider.del(keys);
32
- }
33
- }
34
- class AlephaLockRedis {
35
- name = "alepha.lock.redis";
36
- $services = (alepha) => alepha.with({
37
- provide: LockTopicProvider,
38
- use: RedisTopicProvider,
39
- optional: true
40
- }).with({
41
- provide: LockProvider,
42
- use: RedisLockProvider,
43
- optional: true
44
- }).with(AlephaLock);
45
- }
46
-
47
- export { AlephaLockRedis, RedisLockProvider };
1
+ export * from '@alepha/lock-redis'
package/lock.cjs CHANGED
@@ -1,12 +1,8 @@
1
1
  'use strict';
2
-
3
- var lock = require('@alepha/lock');
4
-
5
-
6
-
7
- Object.keys(lock).forEach(function (k) {
2
+ var m = require('@alepha/lock');
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 lock[k]; }
6
+ get: function () { return m[k]; }
11
7
  });
12
- });
8
+ });