alepha 0.7.5 → 0.7.7
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/cache/redis.cjs +4 -8
- package/cache/redis.d.ts +28 -89
- package/cache/redis.js +1 -1
- package/cache.cjs +4 -8
- package/cache.d.ts +189 -265
- package/cache.js +1 -1
- package/core.cjs +4 -8
- package/core.d.ts +951 -929
- package/core.js +1 -1
- package/datetime.cjs +4 -8
- package/datetime.d.ts +151 -146
- package/datetime.js +1 -1
- package/lock/redis.cjs +7 -49
- package/lock/redis.d.ts +15 -12
- package/lock/redis.js +1 -47
- package/lock.cjs +4 -8
- package/lock.d.ts +117 -170
- package/lock.js +1 -1
- package/package.json +105 -39
- package/postgres.cjs +4 -8
- package/postgres.d.ts +1410 -4433
- package/postgres.js +1 -1
- package/queue/redis.cjs +8 -0
- package/queue/redis.d.ts +31 -0
- package/queue/redis.js +1 -0
- package/queue.cjs +4 -8
- package/queue.d.ts +162 -205
- package/queue.js +1 -1
- package/react/auth.cjs +4 -8
- package/react/auth.d.ts +161 -282
- package/react/auth.js +1 -1
- package/react/head.cjs +8 -0
- package/react/head.d.ts +86 -0
- package/react/head.js +1 -0
- package/react.cjs +4 -8
- package/react.d.ts +468 -559
- package/react.js +1 -1
- package/redis.cjs +4 -8
- package/redis.d.ts +59 -132
- package/redis.js +1 -1
- package/retry.cjs +4 -8
- package/retry.d.ts +34 -31
- package/retry.js +1 -1
- package/scheduler.cjs +4 -8
- package/scheduler.d.ts +124 -182
- package/scheduler.js +1 -1
- package/security.cjs +4 -8
- package/security.d.ts +459 -595
- package/security.js +1 -1
- package/server/cache.cjs +4 -8
- package/server/cache.d.ts +43 -40
- package/server/cache.js +1 -1
- package/server/cookies.cjs +4 -8
- package/server/cookies.d.ts +49 -41
- package/server/cookies.js +1 -1
- package/server/cors.cjs +8 -0
- package/server/cors.d.ts +25 -0
- package/server/cors.js +1 -0
- package/server/health.cjs +8 -0
- package/server/health.d.ts +42 -0
- package/server/health.js +1 -0
- package/server/links.cjs +8 -0
- package/server/links.d.ts +188 -0
- package/server/links.js +1 -0
- package/server/proxy.cjs +8 -0
- package/server/proxy.d.ts +41 -0
- package/server/proxy.js +1 -0
- package/server/static.cjs +4 -8
- package/server/static.d.ts +98 -95
- package/server/static.js +1 -1
- package/server/swagger.cjs +4 -8
- package/server/swagger.d.ts +96 -92
- package/server/swagger.js +1 -1
- package/server.cjs +4 -8
- package/server.d.ts +602 -1087
- package/server.js +1 -1
- package/testing.cjs +8 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/topic/redis.cjs +8 -0
- package/topic/redis.d.ts +45 -0
- package/topic/redis.js +1 -0
- package/topic.cjs +4 -8
- package/topic.d.ts +161 -169
- package/topic.js +1 -1
- package/vite.cjs +4 -8
- package/vite.d.ts +89 -82
- package/vite.js +1 -1
- package/src/cache/redis.ts +0 -1
- package/src/cache.ts +0 -1
- package/src/core.ts +0 -1
- package/src/datetime.ts +0 -1
- package/src/lock/redis.ts +0 -1
- package/src/lock.ts +0 -1
- package/src/postgres.ts +0 -1
- package/src/queue/redis.ts +0 -1
- package/src/queue.ts +0 -1
- package/src/react/auth.ts +0 -1
- package/src/react.ts +0 -1
- package/src/redis.ts +0 -1
- package/src/retry.ts +0 -1
- package/src/scheduler.ts +0 -1
- package/src/security.ts +0 -1
- package/src/server/cache.ts +0 -1
- package/src/server/cookies.ts +0 -1
- package/src/server/static.ts +0 -1
- package/src/server/swagger.ts +0 -1
- package/src/server.ts +0 -1
- package/src/topic/redis.ts +0 -1
- package/src/topic.ts +0 -1
- package/src/vite.ts +0 -1
package/cache/redis.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(cacheRedis).forEach(function (k) {
|
|
2
|
+
var m = require('@alepha/cache-redis');
|
|
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
|
|
6
|
+
get: function () { return m[k]; }
|
|
11
7
|
});
|
|
12
|
-
});
|
|
8
|
+
});
|
package/cache/redis.d.ts
CHANGED
|
@@ -1,94 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { RedisProvider } from
|
|
1
|
+
import { CacheProvider } from "@alepha/cache";
|
|
2
|
+
import * as _alepha_core2 from "@alepha/core";
|
|
3
|
+
import { Alepha, Module, Static } from "@alepha/core";
|
|
4
|
+
import { RedisProvider } from "@alepha/redis";
|
|
5
|
+
import * as _sinclair_typebox0 from "@sinclair/typebox";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
declare const
|
|
8
|
-
|
|
9
|
-
declare const OptionalKind: unique symbol;
|
|
10
|
-
/** Symbol key applied to types */
|
|
11
|
-
declare const Hint: unique symbol;
|
|
12
|
-
/** Symbol key applied to types */
|
|
13
|
-
declare const Kind: unique symbol;
|
|
14
|
-
|
|
15
|
-
type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
|
|
16
|
-
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
17
|
-
interface StringOptions extends SchemaOptions {
|
|
18
|
-
/** The maximum string length */
|
|
19
|
-
maxLength?: number;
|
|
20
|
-
/** The minimum string length */
|
|
21
|
-
minLength?: number;
|
|
22
|
-
/** A regular expression pattern this string should match */
|
|
23
|
-
pattern?: string;
|
|
24
|
-
/** A format this string should match */
|
|
25
|
-
format?: StringFormatOption;
|
|
26
|
-
/** The content encoding for this string */
|
|
27
|
-
contentEncoding?: StringContentEncodingOption;
|
|
28
|
-
/** The content media type for this string */
|
|
29
|
-
contentMediaType?: string;
|
|
30
|
-
}
|
|
31
|
-
interface TString extends TSchema, StringOptions {
|
|
32
|
-
[Kind]: 'String';
|
|
33
|
-
static: string;
|
|
34
|
-
type: 'string';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type TOptional<T extends TSchema> = T & {
|
|
38
|
-
[OptionalKind]: 'Optional';
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
interface SchemaOptions {
|
|
42
|
-
$schema?: string;
|
|
43
|
-
/** Id for this schema */
|
|
44
|
-
$id?: string;
|
|
45
|
-
/** Title of this schema */
|
|
46
|
-
title?: string;
|
|
47
|
-
/** Description of this schema */
|
|
48
|
-
description?: string;
|
|
49
|
-
/** Default value for this schema */
|
|
50
|
-
default?: any;
|
|
51
|
-
/** Example values matching this schema */
|
|
52
|
-
examples?: any;
|
|
53
|
-
/** Optional annotation for readOnly */
|
|
54
|
-
readOnly?: boolean;
|
|
55
|
-
/** Optional annotation for writeOnly */
|
|
56
|
-
writeOnly?: boolean;
|
|
57
|
-
[prop: string]: any;
|
|
58
|
-
}
|
|
59
|
-
interface TKind {
|
|
60
|
-
[Kind]: string;
|
|
61
|
-
}
|
|
62
|
-
interface TSchema extends TKind, SchemaOptions {
|
|
63
|
-
[ReadonlyKind]?: string;
|
|
64
|
-
[OptionalKind]?: string;
|
|
65
|
-
[Hint]?: string;
|
|
66
|
-
params: unknown[];
|
|
67
|
-
static: unknown;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declare const envSchema: _alepha_core.TObject<{
|
|
71
|
-
REDIS_CACHE_PREFIX: TOptional<TString>;
|
|
7
|
+
//#region src/providers/RedisCacheProvider.d.ts
|
|
8
|
+
declare const envSchema: _alepha_core2.TObject<{
|
|
9
|
+
REDIS_CACHE_PREFIX: _sinclair_typebox0.TOptional<_sinclair_typebox0.TString>;
|
|
72
10
|
}>;
|
|
73
11
|
declare module "alepha" {
|
|
74
|
-
|
|
75
|
-
}
|
|
12
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
76
13
|
}
|
|
77
14
|
declare class RedisCacheProvider implements CacheProvider {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
15
|
+
protected readonly log: _alepha_core2.Logger;
|
|
16
|
+
protected readonly redisProvider: RedisProvider;
|
|
17
|
+
protected readonly env: {
|
|
18
|
+
REDIS_CACHE_PREFIX?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
protected readonly alepha: Alepha;
|
|
21
|
+
get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
22
|
+
set(name: string, key: string, value: Uint8Array | string, ttl?: number): Promise<Uint8Array>;
|
|
23
|
+
del(name: string, ...keys: string[]): Promise<void>;
|
|
24
|
+
has(name: string, key: string): Promise<boolean>;
|
|
25
|
+
keys(name: string): Promise<string[]>;
|
|
26
|
+
protected prefix(...path: string[]): string;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/index.d.ts
|
|
92
30
|
/**
|
|
93
31
|
* Alepha Cache Redis Module
|
|
94
32
|
*
|
|
@@ -98,8 +36,9 @@ declare class RedisCacheProvider implements CacheProvider {
|
|
|
98
36
|
* @module alepha.cache.redis
|
|
99
37
|
*/
|
|
100
38
|
declare class AlephaCacheRedis implements Module {
|
|
101
|
-
|
|
102
|
-
|
|
39
|
+
readonly name = "alepha.cache.redis";
|
|
40
|
+
readonly $services: (alepha: Alepha) => Alepha;
|
|
103
41
|
}
|
|
104
|
-
|
|
42
|
+
//#endregion
|
|
105
43
|
export { AlephaCacheRedis, RedisCacheProvider };
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
package/cache/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '@alepha/cache-redis'
|
|
1
|
+
export * from '@alepha/cache-redis'
|
package/cache.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(cache).forEach(function (k) {
|
|
2
|
+
var m = require('@alepha/cache');
|
|
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
|
|
6
|
+
get: function () { return m[k]; }
|
|
11
7
|
});
|
|
12
|
-
});
|
|
8
|
+
});
|
package/cache.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import * as _alepha_core0 from "@alepha/core";
|
|
2
|
+
import * as _alepha_core5 from "@alepha/core";
|
|
3
|
+
import { Alepha, KIND, Module, OPTIONS, Static } from "@alepha/core";
|
|
4
|
+
import { DateTimeProvider, DurationLike, Timeout } from "@alepha/datetime";
|
|
5
|
+
import * as _sinclair_typebox1 from "@sinclair/typebox";
|
|
4
6
|
|
|
7
|
+
//#region src/providers/CacheProvider.d.ts
|
|
5
8
|
/**
|
|
6
9
|
* Cache provider interface.
|
|
7
10
|
*
|
|
@@ -9,285 +12,205 @@ import { DurationLike, DateTimeProvider, Timeout } from '@alepha/datetime';
|
|
|
9
12
|
* Values are stored as Uint8Array.
|
|
10
13
|
*/
|
|
11
14
|
declare abstract class CacheProvider {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Get the value of a key.
|
|
17
|
+
*
|
|
18
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
19
|
+
* @param key The key of the value to get.
|
|
20
|
+
*
|
|
21
|
+
* @return The value of the key, or undefined if the key does not exist.
|
|
22
|
+
*/
|
|
23
|
+
abstract get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Set the string value of a key.
|
|
26
|
+
*
|
|
27
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
28
|
+
* @param key The key of the value to set.
|
|
29
|
+
* @param value The value to set.
|
|
30
|
+
* @param ttl The time-to-live of the key, in milliseconds.
|
|
31
|
+
*
|
|
32
|
+
* @return The value of the key.
|
|
33
|
+
*/
|
|
34
|
+
abstract set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
|
|
35
|
+
/**
|
|
36
|
+
* Remove the specified keys.
|
|
37
|
+
*
|
|
38
|
+
* @param name Cache name, used to group keys. Should be Redis-like "some:group:name" format.
|
|
39
|
+
* @param keys The keys to delete.
|
|
40
|
+
*/
|
|
41
|
+
abstract del(name: string, ...keys: string[]): Promise<void>;
|
|
42
|
+
abstract has(name: string, key: string): Promise<boolean>;
|
|
43
|
+
abstract keys(name: string): Promise<string[]>;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/descriptors/$cache.d.ts
|
|
43
47
|
declare const KEY = "CACHE";
|
|
44
48
|
/**
|
|
45
49
|
* Cache Descriptor
|
|
46
50
|
*/
|
|
47
51
|
declare const $cache: {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
<TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptor<TReturn, TParameter>;
|
|
53
|
+
[KIND]: string;
|
|
50
54
|
};
|
|
51
55
|
interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The cache name. This is useful for invalidating multiple caches at once.
|
|
58
|
+
*
|
|
59
|
+
* Store key as `cache:$name:$key`.
|
|
60
|
+
*
|
|
61
|
+
* @default ClassName:methodName
|
|
62
|
+
*/
|
|
63
|
+
name?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Function which returns cached data.
|
|
66
|
+
* @param args Arguments for handler.
|
|
67
|
+
*/
|
|
68
|
+
handler?: (...args: TParameter) => TReturn;
|
|
69
|
+
/**
|
|
70
|
+
* The key generator for the cache.
|
|
71
|
+
* If not provided, the arguments will be json.stringify().
|
|
72
|
+
*/
|
|
73
|
+
key?: (...args: TParameter) => string;
|
|
74
|
+
/**
|
|
75
|
+
* The store provider for the cache.
|
|
76
|
+
* If not provided, the default store provider will be used.
|
|
77
|
+
*/
|
|
78
|
+
provider?: CacheProvider | (() => CacheProvider) | "memory";
|
|
79
|
+
/**
|
|
80
|
+
* The time-to-live for the cache in seconds.
|
|
81
|
+
* Set 0 to skip expiration.
|
|
82
|
+
*
|
|
83
|
+
* @default 300 (5 minutes).
|
|
84
|
+
*/
|
|
85
|
+
ttl?: DurationLike;
|
|
86
|
+
/**
|
|
87
|
+
* If the cache is disabled.
|
|
88
|
+
*/
|
|
89
|
+
disabled?: boolean;
|
|
86
90
|
}
|
|
87
91
|
interface CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
declare const ReadonlyKind: unique symbol;
|
|
120
|
-
/** Symbol key applied to optional types */
|
|
121
|
-
declare const OptionalKind: unique symbol;
|
|
122
|
-
/** Symbol key applied to types */
|
|
123
|
-
declare const Hint: unique symbol;
|
|
124
|
-
/** Symbol key applied to types */
|
|
125
|
-
declare const Kind: unique symbol;
|
|
126
|
-
|
|
127
|
-
type StringFormatOption = 'date-time' | 'time' | 'date' | 'email' | 'idn-email' | 'hostname' | 'idn-hostname' | 'ipv4' | 'ipv6' | 'uri' | 'uri-reference' | 'iri' | 'uuid' | 'iri-reference' | 'uri-template' | 'json-pointer' | 'relative-json-pointer' | 'regex' | ({} & string);
|
|
128
|
-
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
129
|
-
interface StringOptions extends SchemaOptions {
|
|
130
|
-
/** The maximum string length */
|
|
131
|
-
maxLength?: number;
|
|
132
|
-
/** The minimum string length */
|
|
133
|
-
minLength?: number;
|
|
134
|
-
/** A regular expression pattern this string should match */
|
|
135
|
-
pattern?: string;
|
|
136
|
-
/** A format this string should match */
|
|
137
|
-
format?: StringFormatOption;
|
|
138
|
-
/** The content encoding for this string */
|
|
139
|
-
contentEncoding?: StringContentEncodingOption;
|
|
140
|
-
/** The content media type for this string */
|
|
141
|
-
contentMediaType?: string;
|
|
142
|
-
}
|
|
143
|
-
interface TString extends TSchema, StringOptions {
|
|
144
|
-
[Kind]: 'String';
|
|
145
|
-
static: string;
|
|
146
|
-
type: 'string';
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
interface TBoolean extends TSchema {
|
|
150
|
-
[Kind]: 'Boolean';
|
|
151
|
-
static: boolean;
|
|
152
|
-
type: 'boolean';
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
interface NumberOptions extends SchemaOptions {
|
|
156
|
-
exclusiveMaximum?: number;
|
|
157
|
-
exclusiveMinimum?: number;
|
|
158
|
-
maximum?: number;
|
|
159
|
-
minimum?: number;
|
|
160
|
-
multipleOf?: number;
|
|
161
|
-
}
|
|
162
|
-
interface TNumber extends TSchema, NumberOptions {
|
|
163
|
-
[Kind]: 'Number';
|
|
164
|
-
static: number;
|
|
165
|
-
type: 'number';
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
type TOptional<T extends TSchema> = T & {
|
|
169
|
-
[OptionalKind]: 'Optional';
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
interface SchemaOptions {
|
|
173
|
-
$schema?: string;
|
|
174
|
-
/** Id for this schema */
|
|
175
|
-
$id?: string;
|
|
176
|
-
/** Title of this schema */
|
|
177
|
-
title?: string;
|
|
178
|
-
/** Description of this schema */
|
|
179
|
-
description?: string;
|
|
180
|
-
/** Default value for this schema */
|
|
181
|
-
default?: any;
|
|
182
|
-
/** Example values matching this schema */
|
|
183
|
-
examples?: any;
|
|
184
|
-
/** Optional annotation for readOnly */
|
|
185
|
-
readOnly?: boolean;
|
|
186
|
-
/** Optional annotation for writeOnly */
|
|
187
|
-
writeOnly?: boolean;
|
|
188
|
-
[prop: string]: any;
|
|
189
|
-
}
|
|
190
|
-
interface TKind {
|
|
191
|
-
[Kind]: string;
|
|
192
|
-
}
|
|
193
|
-
interface TSchema extends TKind, SchemaOptions {
|
|
194
|
-
[ReadonlyKind]?: string;
|
|
195
|
-
[OptionalKind]?: string;
|
|
196
|
-
[Hint]?: string;
|
|
197
|
-
params: unknown[];
|
|
198
|
-
static: unknown;
|
|
199
|
-
}
|
|
200
|
-
|
|
92
|
+
[KIND]: typeof KEY;
|
|
93
|
+
[OPTIONS]: CacheDescriptorOptions<TReturn, TParameter>;
|
|
94
|
+
/**
|
|
95
|
+
* Cache handler.
|
|
96
|
+
*/
|
|
97
|
+
(...args: TParameter): Promise<TReturn>;
|
|
98
|
+
/**
|
|
99
|
+
* Cache key generator.
|
|
100
|
+
*/
|
|
101
|
+
key: (...args: TParameter) => string;
|
|
102
|
+
/**
|
|
103
|
+
* Invalidate cache by keys.
|
|
104
|
+
*/
|
|
105
|
+
invalidate: (...keys: string[]) => Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Set cache with key, value and ttl.
|
|
108
|
+
*
|
|
109
|
+
* @param key
|
|
110
|
+
* @param value
|
|
111
|
+
* @param ttl
|
|
112
|
+
*/
|
|
113
|
+
set: (key: string, value: TReturn, ttl?: DurationLike) => Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Get cache by key.
|
|
116
|
+
*
|
|
117
|
+
* @param key
|
|
118
|
+
*/
|
|
119
|
+
get: (key: string) => Promise<TReturn | undefined>;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/providers/MemoryCacheProvider.d.ts
|
|
201
123
|
type CacheName = string;
|
|
202
124
|
type CacheKey = string;
|
|
203
125
|
type CacheValue = {
|
|
204
|
-
|
|
205
|
-
|
|
126
|
+
data?: Uint8Array;
|
|
127
|
+
timeout?: Timeout;
|
|
206
128
|
};
|
|
207
129
|
declare class MemoryCacheProvider implements CacheProvider {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
130
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
131
|
+
protected readonly log: _alepha_core0.Logger;
|
|
132
|
+
protected store: Record<CacheName, Record<CacheKey, CacheValue>>;
|
|
133
|
+
get(name: string, key: string): Promise<Uint8Array | undefined>;
|
|
134
|
+
set(name: string, key: string, value: Uint8Array, ttl?: number): Promise<Uint8Array>;
|
|
135
|
+
del(name: string, ...keys: string[]): Promise<void>;
|
|
136
|
+
has(name: string, key: string): Promise<boolean>;
|
|
137
|
+
keys(name: string): Promise<string[]>;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/providers/CacheDescriptorProvider.d.ts
|
|
141
|
+
declare const envSchema: _alepha_core5.TObject<{
|
|
142
|
+
CACHE_DEFAULT_TTL: _sinclair_typebox1.TNumber;
|
|
143
|
+
CACHE_PREFIX: _sinclair_typebox1.TOptional<_sinclair_typebox1.TString>;
|
|
144
|
+
CACHE_ENABLED: _sinclair_typebox1.TBoolean;
|
|
222
145
|
}>;
|
|
223
146
|
declare module "alepha" {
|
|
224
|
-
|
|
225
|
-
}
|
|
147
|
+
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
226
148
|
}
|
|
227
149
|
declare class CacheDescriptorProvider {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
150
|
+
protected readonly alepha: Alepha;
|
|
151
|
+
protected readonly cacheProvider: CacheProvider;
|
|
152
|
+
protected readonly memoryCacheProvider: MemoryCacheProvider;
|
|
153
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
154
|
+
protected readonly env: {
|
|
155
|
+
CACHE_PREFIX?: string | undefined;
|
|
156
|
+
CACHE_DEFAULT_TTL: number;
|
|
157
|
+
CACHE_ENABLED: boolean;
|
|
158
|
+
};
|
|
159
|
+
protected readonly caches: Cache[];
|
|
160
|
+
protected readonly configure: _alepha_core5.HookDescriptor<"configure">;
|
|
161
|
+
register(cache: Cache): Cache<any, any[]>;
|
|
162
|
+
processDescriptors(): void;
|
|
163
|
+
getCaches(): Cache[];
|
|
164
|
+
/**
|
|
165
|
+
* Clear all cache entries.
|
|
166
|
+
*/
|
|
167
|
+
clear(): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Get the store provider for the given cache options.
|
|
170
|
+
*
|
|
171
|
+
* @param options
|
|
172
|
+
*/
|
|
173
|
+
provider(options: Pick<CacheDescriptorOptions<any[], any>, "provider">): CacheProvider;
|
|
174
|
+
/**
|
|
175
|
+
* Get the cache key for the given state and arguments.
|
|
176
|
+
*/
|
|
177
|
+
key(cache: Cache, ...args: any[]): string;
|
|
178
|
+
/**
|
|
179
|
+
* Invalidate the cache for the given state and arguments.
|
|
180
|
+
*/
|
|
181
|
+
invalidate(cache: Cache, ...keys: string[]): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Run the cache handler with the given state and arguments.
|
|
184
|
+
* You must run on a $cache with a handler defined.
|
|
185
|
+
*/
|
|
186
|
+
run<TReturn, TParameter extends any[]>(cache: Cache<TReturn, TParameter>, ...args: TParameter): Promise<TReturn>;
|
|
187
|
+
get<TReturn>(cache: Cache<TReturn>, key: string): Promise<TReturn | undefined>;
|
|
188
|
+
/**
|
|
189
|
+
* Manually set a value in the cache.
|
|
190
|
+
* It's used by .run() method, but you will need it when you don't have cache handler defined.
|
|
191
|
+
*
|
|
192
|
+
* @param cache Cache object with all configuration and options (even TTL).
|
|
193
|
+
* @param key Cache key, build with .key() method or manually.
|
|
194
|
+
* @param value Value to store in cache.
|
|
195
|
+
* @param ttl Override cache.ttl option.
|
|
196
|
+
*/
|
|
197
|
+
set<TReturn>(cache: Cache<TReturn>, key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
|
|
198
|
+
protected encoder: TextEncoder;
|
|
199
|
+
protected decoder: TextDecoder;
|
|
200
|
+
protected codes: {
|
|
201
|
+
BINARY: number;
|
|
202
|
+
JSON: number;
|
|
203
|
+
STRING: number;
|
|
204
|
+
};
|
|
205
|
+
protected serialize<TReturn>(value: TReturn): Uint8Array;
|
|
206
|
+
protected deserialize<TReturn>(uint8Array: Uint8Array): Promise<TReturn>;
|
|
285
207
|
}
|
|
286
208
|
interface Cache<TReturn = any, TParameter extends any[] = any[]> {
|
|
287
|
-
|
|
288
|
-
|
|
209
|
+
name: string;
|
|
210
|
+
options: CacheDescriptorOptions<TReturn, TParameter>;
|
|
289
211
|
}
|
|
290
|
-
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/index.d.ts
|
|
291
214
|
/**
|
|
292
215
|
* Alepha Cache Module
|
|
293
216
|
*
|
|
@@ -298,8 +221,9 @@ interface Cache<TReturn = any, TParameter extends any[] = any[]> {
|
|
|
298
221
|
* @module alepha.cache
|
|
299
222
|
*/
|
|
300
223
|
declare class AlephaCache implements Module {
|
|
301
|
-
|
|
302
|
-
|
|
224
|
+
readonly name = "alepha.cache";
|
|
225
|
+
readonly $services: (alepha: Alepha) => Alepha;
|
|
303
226
|
}
|
|
304
|
-
|
|
305
|
-
export { $cache, AlephaCache,
|
|
227
|
+
//#endregion
|
|
228
|
+
export { $cache, AlephaCache, Cache, CacheDescriptor, CacheDescriptorOptions, CacheDescriptorProvider, CacheProvider, MemoryCacheProvider };
|
|
229
|
+
//# sourceMappingURL=index.d.ts.map
|
package/cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '@alepha/cache'
|
|
1
|
+
export * from '@alepha/cache'
|