@elysiumjs/core 0.6.0 → 0.7.0
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/dist/app.d.ts +0 -14
- package/dist/index.d.ts +0 -7
- package/dist/index.js +9 -9
- package/dist/redis.d.ts +0 -84
- package/dist/websocket.d.ts +2 -2
- package/package.json +43 -44
- package/.turbo/turbo-build.log +0 -8
- package/dist/cache.d.ts +0 -113
- package/dist/database.d.ts +0 -112
- package/dist/model.d.ts +0 -2413
- package/dist/repository.d.ts +0 -175
- package/dist/tenancy.d.ts +0 -244
package/dist/cache.d.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface for a cache storage.
|
|
3
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
4
|
-
*/
|
|
5
|
-
export interface CacheInterface {
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves the cached data for a given key.
|
|
8
|
-
* @typeParam T The type of the cached data.
|
|
9
|
-
*
|
|
10
|
-
* @param key The key of the cached data.
|
|
11
|
-
*/
|
|
12
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves the cached data for a given list of keys.
|
|
15
|
-
* @typeParam T The type of the cached data.
|
|
16
|
-
*
|
|
17
|
-
* @param keys The list of cached data keys.
|
|
18
|
-
*/
|
|
19
|
-
mget<T>(keys: string[]): Promise<Array<T | undefined>>;
|
|
20
|
-
/**
|
|
21
|
-
* Gets the TTL of the cached data with the given key.
|
|
22
|
-
* @param key The key of the cached data.
|
|
23
|
-
* @returns The TTL of the cached data, or `undefined` if the data does not exist.
|
|
24
|
-
*/
|
|
25
|
-
ttl(key: string): Promise<number | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* Caches data under the given key and an optional TTL.
|
|
28
|
-
* @typeParam T The type of the data to cache.
|
|
29
|
-
*
|
|
30
|
-
* @param key The key of the cached data.
|
|
31
|
-
* @param data The data to cache.
|
|
32
|
-
* @param ttl The optional TTL of the cached data. If not defined, the data is cached forever.
|
|
33
|
-
* @returns The cached data.
|
|
34
|
-
*/
|
|
35
|
-
set<T>(key: string, data: T, ttl?: number): Promise<T>;
|
|
36
|
-
/**
|
|
37
|
-
* Caches data under the given list of keys and an optional TTL.
|
|
38
|
-
* @typeParam T The type of the data to cache.
|
|
39
|
-
*
|
|
40
|
-
* @param data The list of data to cache.
|
|
41
|
-
* @returns The list of cached data.
|
|
42
|
-
*/
|
|
43
|
-
mset<T>(data: Array<{
|
|
44
|
-
key: string;
|
|
45
|
-
value: T;
|
|
46
|
-
ttl?: number;
|
|
47
|
-
}>): Promise<Array<{
|
|
48
|
-
key: string;
|
|
49
|
-
value: T;
|
|
50
|
-
ttl?: number;
|
|
51
|
-
}>>;
|
|
52
|
-
/**
|
|
53
|
-
* Deletes the cached data with the given key.
|
|
54
|
-
* @typeParam T The type of the data to cache.
|
|
55
|
-
*
|
|
56
|
-
* @param key The key of the cached data.
|
|
57
|
-
* @returns `true` if the data was deleted, `false` otherwise.
|
|
58
|
-
*/
|
|
59
|
-
del(key: string): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Deletes the cached data with the given list of keys.
|
|
62
|
-
* @typeParam T The type of the data to cache.
|
|
63
|
-
*
|
|
64
|
-
* @param keys The list of cached data keys.
|
|
65
|
-
* @returns `true` if the data was deleted, `false` otherwise.
|
|
66
|
-
*/
|
|
67
|
-
mdel(keys: string[]): Promise<boolean>;
|
|
68
|
-
/**
|
|
69
|
-
* Deletes all cached data.
|
|
70
|
-
* @returns `true` if the data was deleted, `false` otherwise.
|
|
71
|
-
*/
|
|
72
|
-
clear(): Promise<boolean>;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a sub-cache with the given tags.
|
|
75
|
-
* @param tags The list of tags for the sub-cache.
|
|
76
|
-
*/
|
|
77
|
-
tags(...tags: string[]): Omit<CacheInterface, 'tags'>;
|
|
78
|
-
}
|
|
79
|
-
export declare abstract class Cache {
|
|
80
|
-
#private;
|
|
81
|
-
/**
|
|
82
|
-
* A weak cache storage for simple non-intrusive caching of data.
|
|
83
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
84
|
-
*/
|
|
85
|
-
static readonly weak: {
|
|
86
|
-
/**
|
|
87
|
-
* INTERNAL USAGE ONLY.
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
map: WeakMap<object, unknown>;
|
|
91
|
-
/**
|
|
92
|
-
* Gets the cached data for a given context.
|
|
93
|
-
* @param ctx The cache context.
|
|
94
|
-
* @returns The cached data.
|
|
95
|
-
*/
|
|
96
|
-
get<T extends object>(ctx: object): T;
|
|
97
|
-
/**
|
|
98
|
-
* Deletes the cached data for a given context.
|
|
99
|
-
* @param ctx The cache context.
|
|
100
|
-
*/
|
|
101
|
-
del(ctx: object): void;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Redis-based cache storage.
|
|
105
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
106
|
-
*/
|
|
107
|
-
static get redis(): CacheInterface;
|
|
108
|
-
/**
|
|
109
|
-
* Memory-based cache storage.
|
|
110
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
111
|
-
*/
|
|
112
|
-
static get memory(): CacheInterface;
|
|
113
|
-
}
|
package/dist/database.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { DrizzleConfig } from 'drizzle-orm';
|
|
2
|
-
import type { BunSQLDatabase } from 'drizzle-orm/bun-sql';
|
|
3
|
-
import type { CacheConfig } from 'drizzle-orm/cache/core/types';
|
|
4
|
-
import { Table } from 'drizzle-orm';
|
|
5
|
-
import { Cache as DrizzleCache } from 'drizzle-orm/cache/core';
|
|
6
|
-
/**
|
|
7
|
-
* Properties used to create a new database connection.
|
|
8
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
9
|
-
*/
|
|
10
|
-
export type DatabaseConnectionProps<TSchema extends Record<string, unknown> = Record<string, never>> = Omit<DrizzleConfig<TSchema>, 'cache'> & ({
|
|
11
|
-
connection: string | ({
|
|
12
|
-
url?: string;
|
|
13
|
-
} & Bun.SQLOptions);
|
|
14
|
-
} | {
|
|
15
|
-
client: Bun.SQL;
|
|
16
|
-
}) & {
|
|
17
|
-
/**
|
|
18
|
-
* Configures caching behavior for the database connection.
|
|
19
|
-
* Set it to `true` to enable caching with default configurations.
|
|
20
|
-
*/
|
|
21
|
-
cache?: true | {
|
|
22
|
-
/**
|
|
23
|
-
* Whether to enable caching.
|
|
24
|
-
*/
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* The default TTL for cached data, in seconds.
|
|
28
|
-
* @default 1
|
|
29
|
-
*/
|
|
30
|
-
ttl?: number;
|
|
31
|
-
/**
|
|
32
|
-
* The caching strategy.
|
|
33
|
-
* Set it to `all` to cache all queries automatically.
|
|
34
|
-
* Set it to `explicit` to cache queries manually.
|
|
35
|
-
* @default 'explicit'
|
|
36
|
-
*/
|
|
37
|
-
strategy?: 'explicit' | 'all';
|
|
38
|
-
/**
|
|
39
|
-
* The storage engine to use.
|
|
40
|
-
* @default 'redis'
|
|
41
|
-
*/
|
|
42
|
-
storage?: 'redis' | 'memory';
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* A database connection.
|
|
47
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
48
|
-
*/
|
|
49
|
-
export type DatabaseConnection = BunSQLDatabase<Record<string, never>> & {
|
|
50
|
-
$client: Bun.SQL;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Database cache implementation for Drizzle.
|
|
54
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
55
|
-
*/
|
|
56
|
-
export declare class DatabaseCache extends DrizzleCache {
|
|
57
|
-
#private;
|
|
58
|
-
private readonly cacheStrategy;
|
|
59
|
-
private readonly globalTtl;
|
|
60
|
-
private usedTablesPerKey;
|
|
61
|
-
constructor(cacheStrategy?: 'explicit' | 'all', globalTtl?: number, storageEngine?: 'redis' | 'memory');
|
|
62
|
-
strategy(): 'explicit' | 'all';
|
|
63
|
-
get(key: string): Promise<any[] | undefined>;
|
|
64
|
-
put(key: string, response: any, tables: string[], _isTag: boolean, config?: CacheConfig): Promise<void>;
|
|
65
|
-
onMutate(params: {
|
|
66
|
-
tags: string | string[];
|
|
67
|
-
tables: string | string[] | Table<any> | Table<any>[];
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
}
|
|
70
|
-
export declare namespace Database {
|
|
71
|
-
/**
|
|
72
|
-
* Retrieves the connection with the given name.
|
|
73
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
74
|
-
* @param name The connection name.
|
|
75
|
-
* @returns The connection with the given name.
|
|
76
|
-
*/
|
|
77
|
-
const getConnection: (name: string) => DatabaseConnection;
|
|
78
|
-
/**
|
|
79
|
-
* Creates and registers a new connection.
|
|
80
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
81
|
-
*
|
|
82
|
-
* This will make the registered connection available for dependency injection with
|
|
83
|
-
* the key `db.connection.{name}`, where `{name}` is replaced with the given name.
|
|
84
|
-
*
|
|
85
|
-
* @param name The connection name.
|
|
86
|
-
* @param config The connection properties.
|
|
87
|
-
* @returns The newly created and registered connection.
|
|
88
|
-
*/
|
|
89
|
-
const registerConnection: (name: string, config: DatabaseConnectionProps) => BunSQLDatabase<Record<string, never>> & {
|
|
90
|
-
$client: Bun.SQL;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Checks if a connection with the given name exists.
|
|
94
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
95
|
-
* @param name The name of the connection to check.
|
|
96
|
-
* @returns `true` if the connection exists, `false` otherwise.
|
|
97
|
-
*/
|
|
98
|
-
const connectionExists: (name: string) => boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Retrieves the default connection.
|
|
101
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
102
|
-
* @returns The default connection.
|
|
103
|
-
*/
|
|
104
|
-
const getDefaultConnection: () => DatabaseConnection;
|
|
105
|
-
/**
|
|
106
|
-
* Sets the default connection.
|
|
107
|
-
* @author Axel Nana <axel.nana@workbud.com>
|
|
108
|
-
* @param name The name of the connection to set as default.
|
|
109
|
-
* @returns The default connection.
|
|
110
|
-
*/
|
|
111
|
-
const setDefaultConnection: (name: string) => DatabaseConnection;
|
|
112
|
-
}
|