alepha 0.7.0 → 0.7.1
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/README.md +14 -3
- package/assets/logo.png +0 -0
- package/cache.cjs +0 -1
- package/cache.d.ts +30 -13
- package/cache.js +0 -1
- package/core.cjs +0 -1
- package/core.d.ts +465 -196
- package/core.js +0 -1
- package/datetime.cjs +0 -1
- package/datetime.d.ts +32 -31
- package/datetime.js +0 -1
- package/lock.cjs +0 -1
- package/lock.d.ts +2 -2
- package/lock.js +0 -1
- package/package.json +55 -47
- package/postgres.cjs +0 -1
- package/postgres.d.ts +3238 -275
- package/postgres.js +0 -1
- package/queue.cjs +0 -1
- package/queue.d.ts +2 -2
- package/queue.js +0 -1
- package/react/auth.cjs +0 -1
- package/react/auth.d.ts +12 -5
- package/react/auth.js +0 -1
- package/react.cjs +0 -1
- package/react.d.ts +361 -206
- package/react.js +0 -1
- package/redis.cjs +0 -1
- package/redis.js +0 -1
- package/retry.cjs +12 -0
- package/retry.d.ts +68 -0
- package/retry.js +1 -0
- package/scheduler.cjs +0 -1
- package/scheduler.js +0 -1
- package/security.cjs +0 -1
- package/security.d.ts +82 -35
- package/security.js +0 -1
- package/server/cookies.cjs +0 -1
- package/server/cookies.d.ts +1 -1
- package/server/cookies.js +0 -1
- package/server/metrics.cjs +0 -1
- package/server/metrics.js +0 -1
- package/server/proxy.cjs +0 -1
- package/server/proxy.js +0 -1
- package/server/static.cjs +0 -1
- package/server/static.d.ts +1 -0
- package/server/static.js +0 -1
- package/server/swagger.cjs +0 -1
- package/server/swagger.js +0 -1
- package/server.cjs +0 -1
- package/server.d.ts +402 -327
- package/server.js +0 -1
- package/src/retry.ts +1 -0
- package/topic.cjs +0 -1
- package/topic.d.ts +3 -3
- package/topic.js +0 -1
- package/vite.cjs +0 -1
- package/vite.d.ts +24 -35
- package/vite.js +0 -1
- package/cache.cjs.map +0 -1
- package/cache.js.map +0 -1
- package/core.cjs.map +0 -1
- package/core.js.map +0 -1
- package/datetime.cjs.map +0 -1
- package/datetime.js.map +0 -1
- package/lock.cjs.map +0 -1
- package/lock.js.map +0 -1
- package/postgres.cjs.map +0 -1
- package/postgres.js.map +0 -1
- package/queue.cjs.map +0 -1
- package/queue.js.map +0 -1
- package/react/auth.cjs.map +0 -1
- package/react/auth.js.map +0 -1
- package/react.cjs.map +0 -1
- package/react.js.map +0 -1
- package/redis.cjs.map +0 -1
- package/redis.js.map +0 -1
- package/scheduler.cjs.map +0 -1
- package/scheduler.js.map +0 -1
- package/security.cjs.map +0 -1
- package/security.js.map +0 -1
- package/server/cookies.cjs.map +0 -1
- package/server/cookies.js.map +0 -1
- package/server/metrics.cjs.map +0 -1
- package/server/metrics.js.map +0 -1
- package/server/proxy.cjs.map +0 -1
- package/server/proxy.js.map +0 -1
- package/server/static.cjs.map +0 -1
- package/server/static.js.map +0 -1
- package/server/swagger.cjs.map +0 -1
- package/server/swagger.js.map +0 -1
- package/server.cjs.map +0 -1
- package/server.js.map +0 -1
- package/topic.cjs.map +0 -1
- package/topic.js.map +0 -1
- package/vite.cjs.map +0 -1
- package/vite.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
<img src="./assets/logo.png" alt="Logo" style="width: 256px"/>
|
|
4
|
+
|
|
5
|
+
<h1>Alepha</h1>
|
|
6
|
+
|
|
7
|
+
<p style="max-width: 512px">
|
|
8
|
+
🚧
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/alepha)
|
|
14
|
+
[](https://www.npmjs.com/package/alepha)
|
|
15
|
+
[](https://www.npmjs.com/package/alepha)
|
|
5
16
|
|
|
6
17
|
## Installation
|
|
7
18
|
|
package/assets/logo.png
ADDED
|
Binary file
|
package/cache.cjs
CHANGED
package/cache.d.ts
CHANGED
|
@@ -91,8 +91,7 @@ interface TSchema extends TKind, SchemaOptions {
|
|
|
91
91
|
static: unknown;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
constructor();
|
|
94
|
+
interface CacheProvider {
|
|
96
95
|
/**
|
|
97
96
|
* Get the value of a key.
|
|
98
97
|
*
|
|
@@ -118,6 +117,13 @@ declare class CacheProvider {
|
|
|
118
117
|
del(group: string, ...keys: string[]): Promise<void>;
|
|
119
118
|
}
|
|
120
119
|
|
|
120
|
+
declare class DefaultCacheProvider implements CacheProvider {
|
|
121
|
+
constructor();
|
|
122
|
+
get(): Promise<string | undefined>;
|
|
123
|
+
set(): Promise<string>;
|
|
124
|
+
del(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
|
|
121
127
|
declare const KEY = "CACHE";
|
|
122
128
|
interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
|
|
123
129
|
/**
|
|
@@ -134,7 +140,7 @@ interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
|
|
|
134
140
|
* The store provider for the cache.
|
|
135
141
|
* If not provided, the default store provider will be used.
|
|
136
142
|
*/
|
|
137
|
-
provider?: (() =>
|
|
143
|
+
provider?: (() => DefaultCacheProvider) | "memory";
|
|
138
144
|
/**
|
|
139
145
|
* The cache group. This is useful for invalidating multiple caches at once.
|
|
140
146
|
* Key is used as the group if not provided.
|
|
@@ -247,7 +253,7 @@ declare module "alepha" {
|
|
|
247
253
|
}
|
|
248
254
|
declare class CacheDescriptorProvider {
|
|
249
255
|
protected readonly alepha: Alepha;
|
|
250
|
-
protected readonly cacheProvider:
|
|
256
|
+
protected readonly cacheProvider: DefaultCacheProvider;
|
|
251
257
|
protected readonly memoryCacheProvider: MemoryCacheProvider;
|
|
252
258
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
253
259
|
protected readonly env: {
|
|
@@ -257,7 +263,9 @@ declare class CacheDescriptorProvider {
|
|
|
257
263
|
};
|
|
258
264
|
protected readonly caches: Cache[];
|
|
259
265
|
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
266
|
+
register(cache: Cache): Cache<any, any[]>;
|
|
260
267
|
processDescriptors(): void;
|
|
268
|
+
getCaches(): Cache[];
|
|
261
269
|
/**
|
|
262
270
|
* Clear all cache entries.
|
|
263
271
|
*/
|
|
@@ -274,21 +282,30 @@ declare class CacheDescriptorProvider {
|
|
|
274
282
|
key(cache: Cache, ...args: any[]): string;
|
|
275
283
|
/**
|
|
276
284
|
* Invalidate the cache for the given state and arguments.
|
|
277
|
-
*
|
|
278
|
-
* @param cache
|
|
279
|
-
* @param keys
|
|
280
285
|
*/
|
|
281
286
|
invalidate(cache: Cache, ...keys: string[]): Promise<void>;
|
|
282
287
|
/**
|
|
283
|
-
*
|
|
288
|
+
* Run the cache handler with the given state and arguments.
|
|
289
|
+
* You must run on a $cache with a handler defined.
|
|
284
290
|
*/
|
|
285
|
-
|
|
291
|
+
run<TReturn, TParameter extends any[]>(cache: Cache<TReturn, TParameter>, ...args: TParameter): Promise<TReturn>;
|
|
286
292
|
get<TReturn>(cache: Cache<TReturn>, key: string): Promise<TReturn | undefined>;
|
|
293
|
+
/**
|
|
294
|
+
* Manually set a value in the cache.
|
|
295
|
+
* It's used by .run() method, but you will need it when you don't have cache handler defined.
|
|
296
|
+
*
|
|
297
|
+
* @param cache Cache object with all configuration and options (even TTL).
|
|
298
|
+
* @param key Cache key, build with .key() method or manually.
|
|
299
|
+
* @param value Value to store in cache.
|
|
300
|
+
* @param ttl Override cache.ttl option.
|
|
301
|
+
*/
|
|
287
302
|
set<TReturn>(cache: Cache<TReturn>, key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
|
|
303
|
+
protected serialize<TReturn>(value: TReturn): string;
|
|
304
|
+
protected deserialize<TReturn>(value: string): TReturn;
|
|
288
305
|
}
|
|
289
306
|
interface Cache<TReturn = any, TParameter extends any[] = any[]> {
|
|
290
|
-
options: CacheDescriptorOptions<TReturn, TParameter>;
|
|
291
307
|
group: string;
|
|
308
|
+
options: CacheDescriptorOptions<TReturn, TParameter>;
|
|
292
309
|
}
|
|
293
310
|
|
|
294
311
|
declare const envSchema$1: _alepha_core.TObject<{
|
|
@@ -337,7 +354,7 @@ declare class RedisCacheProvider implements CacheProvider {
|
|
|
337
354
|
}
|
|
338
355
|
|
|
339
356
|
declare const envSchema: _alepha_core.TObject<{
|
|
340
|
-
CACHE_PROVIDER: TUnsafe<"memory" | "redis"
|
|
357
|
+
CACHE_PROVIDER: TUnsafe<"memory" | "redis">;
|
|
341
358
|
}>;
|
|
342
359
|
declare module "@alepha/core" {
|
|
343
360
|
interface Env extends Partial<Static<typeof envSchema>> {
|
|
@@ -346,9 +363,9 @@ declare module "@alepha/core" {
|
|
|
346
363
|
declare class CacheModule {
|
|
347
364
|
protected readonly alepha: Alepha;
|
|
348
365
|
protected readonly env: {
|
|
349
|
-
CACHE_PROVIDER: "memory" | "redis"
|
|
366
|
+
CACHE_PROVIDER: "memory" | "redis";
|
|
350
367
|
};
|
|
351
368
|
constructor();
|
|
352
369
|
}
|
|
353
370
|
|
|
354
|
-
export { $cache, type Cache, type CacheDescriptor, type CacheDescriptorOptions, CacheDescriptorProvider, CacheModule, CacheProvider, MemoryCacheProvider, RedisCacheProvider };
|
|
371
|
+
export { $cache, type Cache, type CacheDescriptor, type CacheDescriptorOptions, CacheDescriptorProvider, CacheModule, type CacheProvider, DefaultCacheProvider, MemoryCacheProvider, RedisCacheProvider };
|
package/cache.js
CHANGED
package/core.cjs
CHANGED