alepha 0.6.7 → 0.6.8
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.d.ts +353 -1
- package/core.d.ts +991 -19
- package/datetime.d.ts +167 -1
- package/lock.d.ts +280 -1
- package/package.json +21 -21
- package/postgres.d.ts +1452 -1
- package/queue.d.ts +305 -1
- package/react/auth.d.ts +300 -1
- package/react.d.ts +617 -1
- package/redis.d.ts +135 -1
- package/scheduler.d.ts +185 -1
- package/security.d.ts +647 -1
- package/server/cookies.d.ts +56 -1
- package/server/metrics.d.ts +14 -1
- package/server/proxy.d.ts +34 -1
- package/server/static.d.ts +103 -1
- package/server/swagger.d.ts +102 -1
- package/server.d.ts +858 -1
- package/topic.d.ts +301 -1
- package/vite.d.ts +80 -1
package/cache.d.ts
CHANGED
|
@@ -1 +1,353 @@
|
|
|
1
|
-
|
|
1
|
+
import * as _alepha_core from '@alepha/core';
|
|
2
|
+
import { KIND, OPTIONS, Static, Alepha } from '@alepha/core';
|
|
3
|
+
import { DurationLike, DateTimeProvider, Timeout } from '@alepha/datetime';
|
|
4
|
+
import { RedisProvider, RedisClient } from '@alepha/redis';
|
|
5
|
+
|
|
6
|
+
/** Symbol key applied to readonly types */
|
|
7
|
+
declare const ReadonlyKind: unique symbol;
|
|
8
|
+
/** Symbol key applied to optional types */
|
|
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
|
+
interface TUnsafe<T> extends TSchema {
|
|
16
|
+
[Kind]: string;
|
|
17
|
+
static: T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
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);
|
|
21
|
+
type StringContentEncodingOption = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64' | ({} & string);
|
|
22
|
+
interface StringOptions extends SchemaOptions {
|
|
23
|
+
/** The maximum string length */
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
/** The minimum string length */
|
|
26
|
+
minLength?: number;
|
|
27
|
+
/** A regular expression pattern this string should match */
|
|
28
|
+
pattern?: string;
|
|
29
|
+
/** A format this string should match */
|
|
30
|
+
format?: StringFormatOption;
|
|
31
|
+
/** The content encoding for this string */
|
|
32
|
+
contentEncoding?: StringContentEncodingOption;
|
|
33
|
+
/** The content media type for this string */
|
|
34
|
+
contentMediaType?: string;
|
|
35
|
+
}
|
|
36
|
+
interface TString extends TSchema, StringOptions {
|
|
37
|
+
[Kind]: 'String';
|
|
38
|
+
static: string;
|
|
39
|
+
type: 'string';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface TBoolean extends TSchema {
|
|
43
|
+
[Kind]: 'Boolean';
|
|
44
|
+
static: boolean;
|
|
45
|
+
type: 'boolean';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface NumberOptions extends SchemaOptions {
|
|
49
|
+
exclusiveMaximum?: number;
|
|
50
|
+
exclusiveMinimum?: number;
|
|
51
|
+
maximum?: number;
|
|
52
|
+
minimum?: number;
|
|
53
|
+
multipleOf?: number;
|
|
54
|
+
}
|
|
55
|
+
interface TNumber extends TSchema, NumberOptions {
|
|
56
|
+
[Kind]: 'Number';
|
|
57
|
+
static: number;
|
|
58
|
+
type: 'number';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type TOptional<T extends TSchema> = T & {
|
|
62
|
+
[OptionalKind]: 'Optional';
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
interface SchemaOptions {
|
|
66
|
+
$schema?: string;
|
|
67
|
+
/** Id for this schema */
|
|
68
|
+
$id?: string;
|
|
69
|
+
/** Title of this schema */
|
|
70
|
+
title?: string;
|
|
71
|
+
/** Description of this schema */
|
|
72
|
+
description?: string;
|
|
73
|
+
/** Default value for this schema */
|
|
74
|
+
default?: any;
|
|
75
|
+
/** Example values matching this schema */
|
|
76
|
+
examples?: any;
|
|
77
|
+
/** Optional annotation for readOnly */
|
|
78
|
+
readOnly?: boolean;
|
|
79
|
+
/** Optional annotation for writeOnly */
|
|
80
|
+
writeOnly?: boolean;
|
|
81
|
+
[prop: string]: any;
|
|
82
|
+
}
|
|
83
|
+
interface TKind {
|
|
84
|
+
[Kind]: string;
|
|
85
|
+
}
|
|
86
|
+
interface TSchema extends TKind, SchemaOptions {
|
|
87
|
+
[ReadonlyKind]?: string;
|
|
88
|
+
[OptionalKind]?: string;
|
|
89
|
+
[Hint]?: string;
|
|
90
|
+
params: unknown[];
|
|
91
|
+
static: unknown;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class CacheProvider {
|
|
95
|
+
/**
|
|
96
|
+
* Get the value of a key.
|
|
97
|
+
*
|
|
98
|
+
* @param group The group of the value to get.
|
|
99
|
+
* @param key The key of the value to get.
|
|
100
|
+
*/
|
|
101
|
+
get(group: string, key: string): Promise<string | undefined>;
|
|
102
|
+
/**
|
|
103
|
+
* Set the string value of a key.
|
|
104
|
+
*
|
|
105
|
+
* @param group The group of the value to get.
|
|
106
|
+
* @param key The key of the value to set.
|
|
107
|
+
* @param value The value to set.
|
|
108
|
+
* @param ttl The time-to-live of the key, in milliseconds.
|
|
109
|
+
*/
|
|
110
|
+
set(group: string, key: string, value: string, ttl?: number): Promise<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Remove the specified keys.
|
|
113
|
+
*
|
|
114
|
+
* @param group The group of the value to get.
|
|
115
|
+
* @param keys The keys to delete.
|
|
116
|
+
*/
|
|
117
|
+
del(group: string, ...keys: string[]): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare const KEY = "CACHE";
|
|
121
|
+
interface CacheDescriptorOptions<TReturn, TParameter extends any[] = any[]> {
|
|
122
|
+
/**
|
|
123
|
+
* Function which returns cached data.
|
|
124
|
+
* @param args Arguments for handler.
|
|
125
|
+
*/
|
|
126
|
+
handler?: (...args: TParameter) => TReturn;
|
|
127
|
+
/**
|
|
128
|
+
* The key generator for the cache.
|
|
129
|
+
* If not provided, the arguments will be json.stringify().
|
|
130
|
+
*/
|
|
131
|
+
key?: (...args: TParameter) => string;
|
|
132
|
+
/**
|
|
133
|
+
* The store provider for the cache.
|
|
134
|
+
* If not provided, the default store provider will be used.
|
|
135
|
+
*/
|
|
136
|
+
provider?: (() => CacheProvider) | "memory";
|
|
137
|
+
/**
|
|
138
|
+
* The cache group. This is useful for invalidating multiple caches at once.
|
|
139
|
+
* Key is used as the group if not provided.
|
|
140
|
+
*
|
|
141
|
+
* Store key as `cache:$group:$key`.
|
|
142
|
+
*
|
|
143
|
+
* @default ClassName:methodName
|
|
144
|
+
*/
|
|
145
|
+
group?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The time-to-live for the cache in seconds.
|
|
148
|
+
* Set 0 to skip expiration.
|
|
149
|
+
*
|
|
150
|
+
* @default 300 (5 minutes).
|
|
151
|
+
*/
|
|
152
|
+
ttl?: DurationLike;
|
|
153
|
+
/**
|
|
154
|
+
* If the cache is disabled.
|
|
155
|
+
*/
|
|
156
|
+
disabled?: boolean;
|
|
157
|
+
}
|
|
158
|
+
interface CacheDescriptor<TReturn = any, TParameter extends any[] = any[]> {
|
|
159
|
+
[KIND]: typeof KEY;
|
|
160
|
+
[OPTIONS]: CacheDescriptorOptions<TReturn, TParameter>;
|
|
161
|
+
/**
|
|
162
|
+
* Cache handler.
|
|
163
|
+
*/
|
|
164
|
+
(...args: TParameter): Promise<TReturn>;
|
|
165
|
+
/**
|
|
166
|
+
* Cache key generator.
|
|
167
|
+
*/
|
|
168
|
+
key: (...args: TParameter) => string;
|
|
169
|
+
/**
|
|
170
|
+
* Invalidate cache by keys.
|
|
171
|
+
*/
|
|
172
|
+
invalidate: (...keys: string[]) => Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Set cache with key, value and ttl.
|
|
175
|
+
*
|
|
176
|
+
* @param key
|
|
177
|
+
* @param value
|
|
178
|
+
* @param ttl
|
|
179
|
+
*/
|
|
180
|
+
set: (key: string, value: TReturn, ttl?: DurationLike) => Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Get cache by key.
|
|
183
|
+
*
|
|
184
|
+
* @param key
|
|
185
|
+
*/
|
|
186
|
+
get: (key: string) => Promise<TReturn | undefined>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Cache Descriptor
|
|
190
|
+
*
|
|
191
|
+
* @param options
|
|
192
|
+
*/
|
|
193
|
+
declare const $cache: {
|
|
194
|
+
<TReturn = string, TParameter extends any[] = any[]>(options?: CacheDescriptorOptions<TReturn, TParameter>): CacheDescriptor<TReturn, TParameter>;
|
|
195
|
+
[KIND]: string;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* A simple in-memory store provider.
|
|
200
|
+
*/
|
|
201
|
+
declare class MemoryCacheProvider implements CacheProvider {
|
|
202
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
203
|
+
protected readonly log: _alepha_core.Logger;
|
|
204
|
+
/**
|
|
205
|
+
* The in-memory store.
|
|
206
|
+
*/
|
|
207
|
+
protected store: Record<string, Record<string, string>>;
|
|
208
|
+
/**
|
|
209
|
+
* Timeouts used to expire keys.
|
|
210
|
+
*/
|
|
211
|
+
protected storeTimeout: Record<string, Record<string, Timeout>>;
|
|
212
|
+
/**
|
|
213
|
+
* Get the value of a key.
|
|
214
|
+
*
|
|
215
|
+
* @param group The group of the value to get.
|
|
216
|
+
* @param key The key of the value to get.
|
|
217
|
+
*/
|
|
218
|
+
get(group: string, key: string): Promise<string | undefined>;
|
|
219
|
+
/**
|
|
220
|
+
* Set the string value of a key.
|
|
221
|
+
*
|
|
222
|
+
* @param group The group of the value to get.
|
|
223
|
+
* @param key The key of the value to set.
|
|
224
|
+
* @param value The value to set.
|
|
225
|
+
* @param ttl The time-to-live of the key, in milliseconds.
|
|
226
|
+
*/
|
|
227
|
+
set(group: string, key: string, value: string, ttl?: number): Promise<string>;
|
|
228
|
+
/**
|
|
229
|
+
* Remove the specified keys.
|
|
230
|
+
*
|
|
231
|
+
* @param group The group of the value to get.
|
|
232
|
+
* @param keys The keys to delete.
|
|
233
|
+
*/
|
|
234
|
+
del(group: string, ...keys: string[]): Promise<void>;
|
|
235
|
+
private ttl;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
declare const envSchema$2: _alepha_core.TObject<{
|
|
239
|
+
CACHE_DEFAULT_TTL: TNumber;
|
|
240
|
+
CACHE_PREFIX: TOptional<TString>;
|
|
241
|
+
CACHE_ENABLED: TBoolean;
|
|
242
|
+
}>;
|
|
243
|
+
declare module "alepha" {
|
|
244
|
+
interface Env extends Partial<Static<typeof envSchema$2>> {
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
declare class CacheDescriptorProvider {
|
|
248
|
+
protected readonly alepha: Alepha;
|
|
249
|
+
protected readonly cacheProvider: CacheProvider;
|
|
250
|
+
protected readonly memoryCacheProvider: MemoryCacheProvider;
|
|
251
|
+
protected readonly dateTimeProvider: DateTimeProvider;
|
|
252
|
+
protected readonly env: {
|
|
253
|
+
CACHE_PREFIX?: string | undefined;
|
|
254
|
+
CACHE_DEFAULT_TTL: number;
|
|
255
|
+
CACHE_ENABLED: boolean;
|
|
256
|
+
};
|
|
257
|
+
protected readonly caches: Cache[];
|
|
258
|
+
protected readonly configure: _alepha_core.HookDescriptor<"configure">;
|
|
259
|
+
processDescriptors(): void;
|
|
260
|
+
/**
|
|
261
|
+
* Clear all cache entries.
|
|
262
|
+
*/
|
|
263
|
+
clear(): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Get the store provider for the given cache options.
|
|
266
|
+
*
|
|
267
|
+
* @param options
|
|
268
|
+
*/
|
|
269
|
+
provider(options: Pick<CacheDescriptorOptions<any[], any>, "provider">): CacheProvider;
|
|
270
|
+
/**
|
|
271
|
+
* Get the cache key for the given state and arguments.
|
|
272
|
+
*/
|
|
273
|
+
key(cache: Cache, ...args: any[]): string;
|
|
274
|
+
/**
|
|
275
|
+
* Invalidate the cache for the given state and arguments.
|
|
276
|
+
*
|
|
277
|
+
* @param cache
|
|
278
|
+
* @param keys
|
|
279
|
+
*/
|
|
280
|
+
invalidate(cache: Cache, ...keys: string[]): Promise<void>;
|
|
281
|
+
/**
|
|
282
|
+
*
|
|
283
|
+
*/
|
|
284
|
+
protected run<TReturn, TParameter extends any[]>(cache: Cache<TReturn, TParameter>, ...args: TParameter): Promise<TReturn>;
|
|
285
|
+
get<TReturn>(cache: Cache<TReturn>, key: string): Promise<TReturn | undefined>;
|
|
286
|
+
set<TReturn>(cache: Cache<TReturn>, key: string, value: TReturn, ttl?: DurationLike): Promise<void>;
|
|
287
|
+
}
|
|
288
|
+
interface Cache<TReturn = any, TParameter extends any[] = any[]> {
|
|
289
|
+
options: CacheDescriptorOptions<TReturn, TParameter>;
|
|
290
|
+
group: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare const envSchema$1: _alepha_core.TObject<{
|
|
294
|
+
REDIS_CACHE_PREFIX: TOptional<TString>;
|
|
295
|
+
}>;
|
|
296
|
+
declare module "alepha/core" {
|
|
297
|
+
interface Env extends Partial<Static<typeof envSchema$1>> {
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
declare class RedisCacheProvider implements CacheProvider {
|
|
301
|
+
protected readonly log: _alepha_core.Logger;
|
|
302
|
+
protected readonly redisProvider: RedisProvider;
|
|
303
|
+
protected readonly env: {
|
|
304
|
+
REDIS_CACHE_PREFIX?: string | undefined;
|
|
305
|
+
};
|
|
306
|
+
get publisher(): RedisClient;
|
|
307
|
+
/**
|
|
308
|
+
* Get the value of a key.
|
|
309
|
+
*
|
|
310
|
+
* @param group - The group of the value to get.
|
|
311
|
+
* @param key - The key of the value to get.
|
|
312
|
+
*/
|
|
313
|
+
get(group: string, key: string): Promise<string | undefined>;
|
|
314
|
+
/**
|
|
315
|
+
* Set the string value of a key.
|
|
316
|
+
*
|
|
317
|
+
* @param group - The group of the value to get.
|
|
318
|
+
* @param key - The key of the value to set.
|
|
319
|
+
* @param value - The value to set.
|
|
320
|
+
* @param ttl - The time-to-live of the key, in milliseconds.
|
|
321
|
+
*/
|
|
322
|
+
set(group: string, key: string, value: string, ttl?: number): Promise<string>;
|
|
323
|
+
/**
|
|
324
|
+
* Remove the specified keys.
|
|
325
|
+
*
|
|
326
|
+
* @param group - The group of the value to get.
|
|
327
|
+
* @param keys - The keys to delete.
|
|
328
|
+
*/
|
|
329
|
+
del(group: string, ...keys: string[]): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Prefix the cache key.
|
|
332
|
+
*
|
|
333
|
+
* @param path - The path to prefix.
|
|
334
|
+
*/
|
|
335
|
+
protected prefix(...path: string[]): string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
declare const envSchema: _alepha_core.TObject<{
|
|
339
|
+
CACHE_PROVIDER: TUnsafe<"memory" | "redis" | "sqlite">;
|
|
340
|
+
}>;
|
|
341
|
+
declare module "@alepha/core" {
|
|
342
|
+
interface Env extends Partial<Static<typeof envSchema>> {
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
declare class CacheModule {
|
|
346
|
+
protected readonly alepha: Alepha;
|
|
347
|
+
protected readonly env: {
|
|
348
|
+
CACHE_PROVIDER: "memory" | "redis" | "sqlite";
|
|
349
|
+
};
|
|
350
|
+
constructor();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export { $cache, type Cache, type CacheDescriptor, type CacheDescriptorOptions, CacheDescriptorProvider, CacheModule, CacheProvider, MemoryCacheProvider, RedisCacheProvider };
|