alepha 0.7.0 → 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.
Files changed (100) hide show
  1. package/README.md +14 -3
  2. package/assets/logo.png +0 -0
  3. package/cache.cjs +0 -1
  4. package/cache.d.ts +30 -13
  5. package/cache.js +0 -1
  6. package/core.cjs +0 -1
  7. package/core.d.ts +465 -196
  8. package/core.js +0 -1
  9. package/datetime.cjs +0 -1
  10. package/datetime.d.ts +68 -79
  11. package/datetime.js +0 -1
  12. package/lock.cjs +0 -1
  13. package/lock.d.ts +3 -14
  14. package/lock.js +0 -1
  15. package/package.json +54 -53
  16. package/postgres.cjs +0 -1
  17. package/postgres.d.ts +3250 -288
  18. package/postgres.js +0 -1
  19. package/queue.cjs +0 -1
  20. package/queue.d.ts +2 -2
  21. package/queue.js +0 -1
  22. package/react/auth.cjs +0 -1
  23. package/react/auth.d.ts +12 -5
  24. package/react/auth.js +0 -1
  25. package/react.cjs +0 -1
  26. package/react.d.ts +317 -206
  27. package/react.js +0 -1
  28. package/redis.cjs +0 -1
  29. package/redis.d.ts +10 -8
  30. package/redis.js +0 -1
  31. package/retry.cjs +12 -0
  32. package/retry.d.ts +68 -0
  33. package/retry.js +1 -0
  34. package/scheduler.cjs +0 -1
  35. package/scheduler.js +0 -1
  36. package/security.cjs +0 -1
  37. package/security.d.ts +82 -35
  38. package/security.js +0 -1
  39. package/server/cookies.cjs +0 -1
  40. package/server/cookies.d.ts +1 -1
  41. package/server/cookies.js +0 -1
  42. package/server/metrics.cjs +0 -1
  43. package/server/metrics.js +0 -1
  44. package/server/static.cjs +0 -1
  45. package/server/static.d.ts +1 -0
  46. package/server/static.js +0 -1
  47. package/server/swagger.cjs +0 -1
  48. package/server/swagger.js +0 -1
  49. package/server.cjs +0 -1
  50. package/server.d.ts +402 -327
  51. package/server.js +0 -1
  52. package/src/retry.ts +1 -0
  53. package/topic.cjs +0 -1
  54. package/topic.d.ts +3 -20
  55. package/topic.js +0 -1
  56. package/vite.cjs +0 -1
  57. package/vite.d.ts +57 -38
  58. package/vite.js +0 -1
  59. package/cache.cjs.map +0 -1
  60. package/cache.js.map +0 -1
  61. package/core.cjs.map +0 -1
  62. package/core.js.map +0 -1
  63. package/datetime.cjs.map +0 -1
  64. package/datetime.js.map +0 -1
  65. package/lock.cjs.map +0 -1
  66. package/lock.js.map +0 -1
  67. package/postgres.cjs.map +0 -1
  68. package/postgres.js.map +0 -1
  69. package/queue.cjs.map +0 -1
  70. package/queue.js.map +0 -1
  71. package/react/auth.cjs.map +0 -1
  72. package/react/auth.js.map +0 -1
  73. package/react.cjs.map +0 -1
  74. package/react.js.map +0 -1
  75. package/redis.cjs.map +0 -1
  76. package/redis.js.map +0 -1
  77. package/scheduler.cjs.map +0 -1
  78. package/scheduler.js.map +0 -1
  79. package/security.cjs.map +0 -1
  80. package/security.js.map +0 -1
  81. package/server/cookies.cjs.map +0 -1
  82. package/server/cookies.js.map +0 -1
  83. package/server/metrics.cjs.map +0 -1
  84. package/server/metrics.js.map +0 -1
  85. package/server/proxy.cjs +0 -13
  86. package/server/proxy.cjs.map +0 -1
  87. package/server/proxy.d.ts +0 -1
  88. package/server/proxy.js +0 -2
  89. package/server/proxy.js.map +0 -1
  90. package/server/static.cjs.map +0 -1
  91. package/server/static.js.map +0 -1
  92. package/server/swagger.cjs.map +0 -1
  93. package/server/swagger.js.map +0 -1
  94. package/server.cjs.map +0 -1
  95. package/server.js.map +0 -1
  96. package/src/server/proxy.ts +0 -1
  97. package/topic.cjs.map +0 -1
  98. package/topic.js.map +0 -1
  99. package/vite.cjs.map +0 -1
  100. package/vite.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,18 @@
1
- # Alepha
1
+ <div align="center">
2
2
 
3
- Alepha is a collection of packages designed to provide a powerful and flexible framework for building applications.
4
- It includes a variety of tools and utilities to help developers create robust and maintainable code.
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
+ [![npm](https://img.shields.io/npm/v/alepha.svg)](https://www.npmjs.com/package/alepha)
14
+ [![license](https://img.shields.io/npm/l/alepha.svg)](https://www.npmjs.com/package/alepha)
15
+ [![downloads](https://img.shields.io/npm/dt/alepha.svg)](https://www.npmjs.com/package/alepha)
5
16
 
6
17
  ## Installation
7
18
 
Binary file
package/cache.cjs CHANGED
@@ -10,4 +10,3 @@ Object.keys(cache).forEach(function (k) {
10
10
  get: function () { return cache[k]; }
11
11
  });
12
12
  });
13
- //# sourceMappingURL=cache.cjs.map
package/cache.d.ts CHANGED
@@ -91,8 +91,7 @@ interface TSchema extends TKind, SchemaOptions {
91
91
  static: unknown;
92
92
  }
93
93
 
94
- declare class CacheProvider {
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?: (() => CacheProvider) | "memory";
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: 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
- protected run<TReturn, TParameter extends any[]>(cache: Cache<TReturn, TParameter>, ...args: TParameter): Promise<TReturn>;
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" | "sqlite">;
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" | "sqlite";
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
@@ -1,2 +1 @@
1
1
  export * from '@alepha/cache';
2
- //# sourceMappingURL=cache.js.map
package/core.cjs CHANGED
@@ -10,4 +10,3 @@ Object.keys(core).forEach(function (k) {
10
10
  get: function () { return core[k]; }
11
11
  });
12
12
  });
13
- //# sourceMappingURL=core.cjs.map