@dexto/storage 1.6.0 → 1.6.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.
- package/dist/index.d.cts +503 -24
- package/dist/schemas.d.cts +299 -4
- package/package.json +3 -3
- package/dist/blob/factories/index.d.cts +0 -6
- package/dist/blob/factories/local.d.cts +0 -21
- package/dist/blob/factories/memory.d.cts +0 -21
- package/dist/blob/factory.d.cts +0 -36
- package/dist/blob/index.d.cts +0 -8
- package/dist/blob/local-blob-store.d.cts +0 -56
- package/dist/blob/memory-blob-store.d.cts +0 -69
- package/dist/blob/schemas.d.cts +0 -87
- package/dist/blob/types.d.cts +0 -1
- package/dist/cache/factories/index.d.cts +0 -6
- package/dist/cache/factories/memory.d.cts +0 -21
- package/dist/cache/factories/redis.d.cts +0 -24
- package/dist/cache/factory.d.cts +0 -42
- package/dist/cache/index.d.cts +0 -7
- package/dist/cache/memory-cache-store.d.cts +0 -27
- package/dist/cache/redis-store.d.cts +0 -34
- package/dist/cache/schemas.d.cts +0 -93
- package/dist/cache/types.d.cts +0 -1
- package/dist/database/factories/index.d.cts +0 -7
- package/dist/database/factories/memory.d.cts +0 -20
- package/dist/database/factories/postgres.d.cts +0 -23
- package/dist/database/factories/sqlite.d.cts +0 -24
- package/dist/database/factory.d.cts +0 -42
- package/dist/database/index.d.cts +0 -8
- package/dist/database/memory-database-store.d.cts +0 -30
- package/dist/database/postgres-store.d.cts +0 -57
- package/dist/database/schemas.d.cts +0 -127
- package/dist/database/sqlite-store.d.cts +0 -35
- package/dist/database/types.d.cts +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RedisCacheConfig } from '../schemas.cjs';
|
|
2
|
-
import { CacheFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for Redis cache storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores data in a Redis server using the ioredis package.
|
|
10
|
-
* It's ideal for production deployments requiring scalability, persistence,
|
|
11
|
-
* and multi-machine access.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Native TTL support
|
|
15
|
-
* - Connection pooling
|
|
16
|
-
* - Pub/sub capabilities (via additional methods)
|
|
17
|
-
* - Suitable for distributed deployments
|
|
18
|
-
*
|
|
19
|
-
* Note: ioredis is an optional dependency. Install it with:
|
|
20
|
-
* npm install ioredis
|
|
21
|
-
*/
|
|
22
|
-
declare const redisCacheFactory: CacheFactory<RedisCacheConfig>;
|
|
23
|
-
|
|
24
|
-
export { redisCacheFactory };
|
package/dist/cache/factory.d.cts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Logger, Cache } from '@dexto/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Factory interface for creating cache instances.
|
|
6
|
-
*
|
|
7
|
-
* Factories are plain exports (no global registries). Images decide which factories are
|
|
8
|
-
* available by including them in `image.storage.cache`.
|
|
9
|
-
*/
|
|
10
|
-
interface CacheFactory<TConfig = unknown> {
|
|
11
|
-
/**
|
|
12
|
-
* Zod schema for validating factory-specific configuration.
|
|
13
|
-
* The schema must output the `TConfig` type.
|
|
14
|
-
*/
|
|
15
|
-
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* Factory function to create a Cache instance.
|
|
18
|
-
*
|
|
19
|
-
* Cache factories may return a Promise to support lazy loading of optional
|
|
20
|
-
* dependencies (e.g., `ioredis`).
|
|
21
|
-
*
|
|
22
|
-
* @param config - Validated configuration specific to this backend
|
|
23
|
-
* @param logger - Logger instance for the cache
|
|
24
|
-
* @returns A Cache implementation (or Promise for async backends)
|
|
25
|
-
*/
|
|
26
|
-
create(config: TConfig, logger: Logger): Cache | Promise<Cache>;
|
|
27
|
-
/**
|
|
28
|
-
* Optional metadata for documentation, UIs, and discovery.
|
|
29
|
-
*/
|
|
30
|
-
metadata?: {
|
|
31
|
-
/** Human-readable name (e.g., "Redis", "Memcached") */
|
|
32
|
-
displayName: string;
|
|
33
|
-
/** Brief description of this cache backend */
|
|
34
|
-
description: string;
|
|
35
|
-
/** Whether this backend requires network connectivity */
|
|
36
|
-
requiresNetwork?: boolean;
|
|
37
|
-
/** Whether this backend supports TTL (time-to-live) */
|
|
38
|
-
supportsTTL?: boolean;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type { CacheFactory };
|
package/dist/cache/index.d.cts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { CacheFactory } from './factory.cjs';
|
|
2
|
-
export { Cache } from '@dexto/core';
|
|
3
|
-
export { inMemoryCacheFactory } from './factories/memory.cjs';
|
|
4
|
-
export { redisCacheFactory } from './factories/redis.cjs';
|
|
5
|
-
export { CACHE_TYPES, CacheConfig, CacheConfigSchema, CacheType, InMemoryCacheConfig, InMemoryCacheSchema, RedisCacheConfig, RedisCacheSchema } from './schemas.cjs';
|
|
6
|
-
export { MemoryCacheStore } from './memory-cache-store.cjs';
|
|
7
|
-
import 'zod';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Cache } from '@dexto/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* In-memory cache store for development and testing.
|
|
5
|
-
* Supports TTL for automatic cleanup of temporary data.
|
|
6
|
-
* Data is lost when the process restarts.
|
|
7
|
-
*/
|
|
8
|
-
declare class MemoryCacheStore implements Cache {
|
|
9
|
-
private data;
|
|
10
|
-
private ttls;
|
|
11
|
-
private connected;
|
|
12
|
-
connect(): Promise<void>;
|
|
13
|
-
disconnect(): Promise<void>;
|
|
14
|
-
isConnected(): boolean;
|
|
15
|
-
getStoreType(): string;
|
|
16
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
17
|
-
set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
18
|
-
delete(key: string): Promise<void>;
|
|
19
|
-
private checkConnection;
|
|
20
|
-
private checkTTL;
|
|
21
|
-
clear(): Promise<void>;
|
|
22
|
-
dump(): Promise<{
|
|
23
|
-
data: Record<string, unknown>;
|
|
24
|
-
}>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { MemoryCacheStore };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Cache, Logger } from '@dexto/core';
|
|
2
|
-
import { RedisCacheConfig } from './schemas.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Redis cache store for production cache operations.
|
|
7
|
-
* Implements the Cache interface with connection pooling and optimizations.
|
|
8
|
-
* EXPERIMENTAL - NOT FULLY TESTED YET
|
|
9
|
-
*/
|
|
10
|
-
declare class RedisStore implements Cache {
|
|
11
|
-
private config;
|
|
12
|
-
private redis;
|
|
13
|
-
private connected;
|
|
14
|
-
private logger;
|
|
15
|
-
constructor(config: RedisCacheConfig, logger: Logger);
|
|
16
|
-
connect(): Promise<void>;
|
|
17
|
-
disconnect(): Promise<void>;
|
|
18
|
-
isConnected(): boolean;
|
|
19
|
-
getStoreType(): string;
|
|
20
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
21
|
-
set<T>(key: string, value: T, ttlSeconds?: number): Promise<void>;
|
|
22
|
-
delete(key: string): Promise<void>;
|
|
23
|
-
mget<T>(keys: string[]): Promise<(T | undefined)[]>;
|
|
24
|
-
mset<T>(entries: [string, T][]): Promise<void>;
|
|
25
|
-
exists(key: string): Promise<boolean>;
|
|
26
|
-
expire(key: string, ttlSeconds: number): Promise<void>;
|
|
27
|
-
increment(key: string, by?: number): Promise<number>;
|
|
28
|
-
decrement(key: string, by?: number): Promise<number>;
|
|
29
|
-
private checkConnection;
|
|
30
|
-
flushdb(): Promise<void>;
|
|
31
|
-
info(): Promise<string>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { RedisStore };
|
package/dist/cache/schemas.d.cts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
declare const CACHE_TYPES: readonly ["in-memory", "redis"];
|
|
4
|
-
type CacheType = (typeof CACHE_TYPES)[number];
|
|
5
|
-
declare const InMemoryCacheSchema: z.ZodObject<{
|
|
6
|
-
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
8
|
-
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
-
} & {
|
|
11
|
-
type: z.ZodLiteral<"in-memory">;
|
|
12
|
-
}, "strict", z.ZodTypeAny, {
|
|
13
|
-
type: "in-memory";
|
|
14
|
-
maxConnections?: number | undefined;
|
|
15
|
-
idleTimeoutMillis?: number | undefined;
|
|
16
|
-
connectionTimeoutMillis?: number | undefined;
|
|
17
|
-
options?: Record<string, unknown> | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
type: "in-memory";
|
|
20
|
-
maxConnections?: number | undefined;
|
|
21
|
-
idleTimeoutMillis?: number | undefined;
|
|
22
|
-
connectionTimeoutMillis?: number | undefined;
|
|
23
|
-
options?: Record<string, unknown> | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
type InMemoryCacheConfig = z.output<typeof InMemoryCacheSchema>;
|
|
26
|
-
declare const RedisCacheSchema: z.ZodEffects<z.ZodObject<{
|
|
27
|
-
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
28
|
-
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
30
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
|
-
} & {
|
|
32
|
-
type: z.ZodLiteral<"redis">;
|
|
33
|
-
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
34
|
-
host: z.ZodOptional<z.ZodString>;
|
|
35
|
-
port: z.ZodOptional<z.ZodNumber>;
|
|
36
|
-
password: z.ZodOptional<z.ZodString>;
|
|
37
|
-
database: z.ZodOptional<z.ZodNumber>;
|
|
38
|
-
}, "strict", z.ZodTypeAny, {
|
|
39
|
-
type: "redis";
|
|
40
|
-
maxConnections?: number | undefined;
|
|
41
|
-
idleTimeoutMillis?: number | undefined;
|
|
42
|
-
connectionTimeoutMillis?: number | undefined;
|
|
43
|
-
options?: Record<string, unknown> | undefined;
|
|
44
|
-
url?: string | undefined;
|
|
45
|
-
host?: string | undefined;
|
|
46
|
-
port?: number | undefined;
|
|
47
|
-
password?: string | undefined;
|
|
48
|
-
database?: number | undefined;
|
|
49
|
-
}, {
|
|
50
|
-
type: "redis";
|
|
51
|
-
maxConnections?: number | undefined;
|
|
52
|
-
idleTimeoutMillis?: number | undefined;
|
|
53
|
-
connectionTimeoutMillis?: number | undefined;
|
|
54
|
-
options?: Record<string, unknown> | undefined;
|
|
55
|
-
url?: string | undefined;
|
|
56
|
-
host?: string | undefined;
|
|
57
|
-
port?: number | undefined;
|
|
58
|
-
password?: string | undefined;
|
|
59
|
-
database?: number | undefined;
|
|
60
|
-
}>, {
|
|
61
|
-
type: "redis";
|
|
62
|
-
maxConnections?: number | undefined;
|
|
63
|
-
idleTimeoutMillis?: number | undefined;
|
|
64
|
-
connectionTimeoutMillis?: number | undefined;
|
|
65
|
-
options?: Record<string, unknown> | undefined;
|
|
66
|
-
url?: string | undefined;
|
|
67
|
-
host?: string | undefined;
|
|
68
|
-
port?: number | undefined;
|
|
69
|
-
password?: string | undefined;
|
|
70
|
-
database?: number | undefined;
|
|
71
|
-
}, {
|
|
72
|
-
type: "redis";
|
|
73
|
-
maxConnections?: number | undefined;
|
|
74
|
-
idleTimeoutMillis?: number | undefined;
|
|
75
|
-
connectionTimeoutMillis?: number | undefined;
|
|
76
|
-
options?: Record<string, unknown> | undefined;
|
|
77
|
-
url?: string | undefined;
|
|
78
|
-
host?: string | undefined;
|
|
79
|
-
port?: number | undefined;
|
|
80
|
-
password?: string | undefined;
|
|
81
|
-
database?: number | undefined;
|
|
82
|
-
}>;
|
|
83
|
-
type RedisCacheConfig = z.output<typeof RedisCacheSchema>;
|
|
84
|
-
declare const CacheConfigSchema: z.ZodObject<{
|
|
85
|
-
type: z.ZodString;
|
|
86
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
87
|
-
type: z.ZodString;
|
|
88
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
89
|
-
type: z.ZodString;
|
|
90
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
91
|
-
type CacheConfig = z.output<typeof CacheConfigSchema>;
|
|
92
|
-
|
|
93
|
-
export { CACHE_TYPES, type CacheConfig, CacheConfigSchema, type CacheType, type InMemoryCacheConfig, InMemoryCacheSchema, type RedisCacheConfig, RedisCacheSchema };
|
package/dist/cache/types.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Cache } from '@dexto/core';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { InMemoryDatabaseConfig } from '../schemas.cjs';
|
|
2
|
-
import { DatabaseFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for in-memory database storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores data in RAM and is ideal for development,
|
|
10
|
-
* testing, and ephemeral use cases where persistence is not required.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Zero external dependencies
|
|
14
|
-
* - Fast in-memory operations
|
|
15
|
-
* - No network required
|
|
16
|
-
* - Data is lost on restart
|
|
17
|
-
*/
|
|
18
|
-
declare const inMemoryDatabaseFactory: DatabaseFactory<InMemoryDatabaseConfig>;
|
|
19
|
-
|
|
20
|
-
export { inMemoryDatabaseFactory };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { PostgresDatabaseConfig } from '../schemas.cjs';
|
|
2
|
-
import { DatabaseFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for PostgreSQL database storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores data in a PostgreSQL database server using the pg package.
|
|
10
|
-
* It's ideal for production deployments requiring scalability and multi-machine access.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Connection pooling for efficient resource usage
|
|
14
|
-
* - JSONB storage for flexible data types
|
|
15
|
-
* - Transaction support
|
|
16
|
-
* - Suitable for distributed deployments
|
|
17
|
-
*
|
|
18
|
-
* Note: pg is an optional dependency. Install it with:
|
|
19
|
-
* npm install pg
|
|
20
|
-
*/
|
|
21
|
-
declare const postgresDatabaseFactory: DatabaseFactory<PostgresDatabaseConfig>;
|
|
22
|
-
|
|
23
|
-
export { postgresDatabaseFactory };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SqliteDatabaseConfig } from '../schemas.cjs';
|
|
2
|
-
import { DatabaseFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for SQLite database storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores data in a local SQLite database file using better-sqlite3.
|
|
10
|
-
* It's ideal for single-machine deployments and development scenarios where
|
|
11
|
-
* persistence is required without the overhead of a database server.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Uses better-sqlite3 for synchronous, fast operations
|
|
15
|
-
* - WAL mode enabled for better concurrency
|
|
16
|
-
* - No external server required
|
|
17
|
-
* - Persistent storage survives restarts
|
|
18
|
-
*
|
|
19
|
-
* Note: better-sqlite3 is an optional dependency. Install it with:
|
|
20
|
-
* npm install better-sqlite3
|
|
21
|
-
*/
|
|
22
|
-
declare const sqliteDatabaseFactory: DatabaseFactory<SqliteDatabaseConfig>;
|
|
23
|
-
|
|
24
|
-
export { sqliteDatabaseFactory };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Logger, Database } from '@dexto/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Factory interface for creating database instances.
|
|
6
|
-
*
|
|
7
|
-
* Factories are plain exports (no global registries). Images decide which factories are
|
|
8
|
-
* available by including them in `image.storage.database`.
|
|
9
|
-
*/
|
|
10
|
-
interface DatabaseFactory<TConfig = unknown> {
|
|
11
|
-
/**
|
|
12
|
-
* Zod schema for validating factory-specific configuration.
|
|
13
|
-
* The schema must output the `TConfig` type.
|
|
14
|
-
*/
|
|
15
|
-
configSchema: z.ZodType<TConfig, z.ZodTypeDef, unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* Factory function to create a Database instance.
|
|
18
|
-
*
|
|
19
|
-
* Database factories may return a Promise to support lazy loading of optional
|
|
20
|
-
* dependencies (e.g., `better-sqlite3`, `pg`).
|
|
21
|
-
*
|
|
22
|
-
* @param config - Validated configuration specific to this backend
|
|
23
|
-
* @param logger - Logger instance for the database
|
|
24
|
-
* @returns A Database implementation (or Promise for async backends)
|
|
25
|
-
*/
|
|
26
|
-
create(config: TConfig, logger: Logger): Database | Promise<Database>;
|
|
27
|
-
/**
|
|
28
|
-
* Optional metadata for documentation, UIs, and discovery.
|
|
29
|
-
*/
|
|
30
|
-
metadata?: {
|
|
31
|
-
/** Human-readable name (e.g., "SQLite", "PostgreSQL") */
|
|
32
|
-
displayName: string;
|
|
33
|
-
/** Brief description of this storage backend */
|
|
34
|
-
description: string;
|
|
35
|
-
/** Whether this backend requires network connectivity */
|
|
36
|
-
requiresNetwork?: boolean;
|
|
37
|
-
/** Whether this backend supports list operations (append/getRange) */
|
|
38
|
-
supportsListOperations?: boolean;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type { DatabaseFactory };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { DatabaseFactory } from './factory.cjs';
|
|
2
|
-
export { Database } from '@dexto/core';
|
|
3
|
-
export { inMemoryDatabaseFactory } from './factories/memory.cjs';
|
|
4
|
-
export { sqliteDatabaseFactory } from './factories/sqlite.cjs';
|
|
5
|
-
export { postgresDatabaseFactory } from './factories/postgres.cjs';
|
|
6
|
-
export { DATABASE_TYPES, DatabaseConfig, DatabaseConfigSchema, DatabaseType, InMemoryDatabaseConfig, InMemoryDatabaseSchema, PostgresDatabaseConfig, PostgresDatabaseSchema, SqliteDatabaseConfig, SqliteDatabaseSchema } from './schemas.cjs';
|
|
7
|
-
export { MemoryDatabaseStore } from './memory-database-store.cjs';
|
|
8
|
-
import 'zod';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Database } from '@dexto/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* In-memory database store for development and testing.
|
|
5
|
-
* Supports list operations for message history and enumeration for settings.
|
|
6
|
-
* Data is lost when the process restarts.
|
|
7
|
-
*/
|
|
8
|
-
declare class MemoryDatabaseStore implements Database {
|
|
9
|
-
private data;
|
|
10
|
-
private lists;
|
|
11
|
-
private connected;
|
|
12
|
-
connect(): Promise<void>;
|
|
13
|
-
disconnect(): Promise<void>;
|
|
14
|
-
isConnected(): boolean;
|
|
15
|
-
getStoreType(): string;
|
|
16
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
17
|
-
set<T>(key: string, value: T): Promise<void>;
|
|
18
|
-
delete(key: string): Promise<void>;
|
|
19
|
-
list(prefix: string): Promise<string[]>;
|
|
20
|
-
append<T>(key: string, item: T): Promise<void>;
|
|
21
|
-
getRange<T>(key: string, start: number, count: number): Promise<T[]>;
|
|
22
|
-
private checkConnection;
|
|
23
|
-
clear(): Promise<void>;
|
|
24
|
-
dump(): Promise<{
|
|
25
|
-
data: Record<string, unknown>;
|
|
26
|
-
lists: Record<string, unknown[]>;
|
|
27
|
-
}>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { MemoryDatabaseStore };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { PoolClient } from 'pg';
|
|
2
|
-
import { Database, Logger } from '@dexto/core';
|
|
3
|
-
import { PostgresDatabaseConfig } from './schemas.cjs';
|
|
4
|
-
import 'zod';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* PostgreSQL database store for production database operations.
|
|
8
|
-
* Implements the Database interface with connection pooling and JSONB support.
|
|
9
|
-
* EXPERIMENTAL - NOT FULLY TESTED YET
|
|
10
|
-
*/
|
|
11
|
-
declare class PostgresStore implements Database {
|
|
12
|
-
private config;
|
|
13
|
-
private pool;
|
|
14
|
-
private connected;
|
|
15
|
-
private logger;
|
|
16
|
-
constructor(config: PostgresDatabaseConfig, logger: Logger);
|
|
17
|
-
connect(): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a PostgreSQL schema if it doesn't exist.
|
|
20
|
-
*/
|
|
21
|
-
private createSchema;
|
|
22
|
-
disconnect(): Promise<void>;
|
|
23
|
-
isConnected(): boolean;
|
|
24
|
-
getStoreType(): string;
|
|
25
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
26
|
-
set<T>(key: string, value: T): Promise<void>;
|
|
27
|
-
delete(key: string): Promise<void>;
|
|
28
|
-
list(prefix: string): Promise<string[]>;
|
|
29
|
-
append<T>(key: string, item: T): Promise<void>;
|
|
30
|
-
getRange<T>(key: string, start: number, count: number): Promise<T[]>;
|
|
31
|
-
private createTables;
|
|
32
|
-
private checkConnection;
|
|
33
|
-
/**
|
|
34
|
-
* Check if an error is a connection error that should trigger a retry.
|
|
35
|
-
* Common with serverless databases (Neon) where connections go stale.
|
|
36
|
-
*/
|
|
37
|
-
private isConnectionError;
|
|
38
|
-
/**
|
|
39
|
-
* Execute a database operation with automatic retry on connection errors.
|
|
40
|
-
* Handles serverless DB connection issues (Neon cold starts, stale connections).
|
|
41
|
-
*/
|
|
42
|
-
private withRetry;
|
|
43
|
-
/**
|
|
44
|
-
* Execute a callback within a database transaction.
|
|
45
|
-
* Note: On connection failure, the entire callback will be retried on a new connection.
|
|
46
|
-
* Ensure callback operations are idempotent or use this only for read operations.
|
|
47
|
-
*/
|
|
48
|
-
transaction<T>(callback: (client: PoolClient) => Promise<T>): Promise<T>;
|
|
49
|
-
getStats(): Promise<{
|
|
50
|
-
kvCount: number;
|
|
51
|
-
listCount: number;
|
|
52
|
-
totalSize: string;
|
|
53
|
-
}>;
|
|
54
|
-
vacuum(): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export { PostgresStore };
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
declare const DATABASE_TYPES: readonly ["in-memory", "sqlite", "postgres"];
|
|
4
|
-
type DatabaseType = (typeof DATABASE_TYPES)[number];
|
|
5
|
-
declare const InMemoryDatabaseSchema: z.ZodObject<{
|
|
6
|
-
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
8
|
-
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
-
} & {
|
|
11
|
-
type: z.ZodLiteral<"in-memory">;
|
|
12
|
-
}, "strict", z.ZodTypeAny, {
|
|
13
|
-
type: "in-memory";
|
|
14
|
-
maxConnections?: number | undefined;
|
|
15
|
-
idleTimeoutMillis?: number | undefined;
|
|
16
|
-
connectionTimeoutMillis?: number | undefined;
|
|
17
|
-
options?: Record<string, unknown> | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
type: "in-memory";
|
|
20
|
-
maxConnections?: number | undefined;
|
|
21
|
-
idleTimeoutMillis?: number | undefined;
|
|
22
|
-
connectionTimeoutMillis?: number | undefined;
|
|
23
|
-
options?: Record<string, unknown> | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
type InMemoryDatabaseConfig = z.output<typeof InMemoryDatabaseSchema>;
|
|
26
|
-
declare const SqliteDatabaseSchema: z.ZodObject<{
|
|
27
|
-
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
28
|
-
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
29
|
-
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
30
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
|
-
} & {
|
|
32
|
-
type: z.ZodLiteral<"sqlite">;
|
|
33
|
-
path: z.ZodString;
|
|
34
|
-
}, "strict", z.ZodTypeAny, {
|
|
35
|
-
path: string;
|
|
36
|
-
type: "sqlite";
|
|
37
|
-
maxConnections?: number | undefined;
|
|
38
|
-
idleTimeoutMillis?: number | undefined;
|
|
39
|
-
connectionTimeoutMillis?: number | undefined;
|
|
40
|
-
options?: Record<string, unknown> | undefined;
|
|
41
|
-
}, {
|
|
42
|
-
path: string;
|
|
43
|
-
type: "sqlite";
|
|
44
|
-
maxConnections?: number | undefined;
|
|
45
|
-
idleTimeoutMillis?: number | undefined;
|
|
46
|
-
connectionTimeoutMillis?: number | undefined;
|
|
47
|
-
options?: Record<string, unknown> | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
type SqliteDatabaseConfig = z.output<typeof SqliteDatabaseSchema>;
|
|
50
|
-
declare const PostgresDatabaseSchema: z.ZodEffects<z.ZodObject<{
|
|
51
|
-
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
52
|
-
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
54
|
-
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
55
|
-
} & {
|
|
56
|
-
type: z.ZodLiteral<"postgres">;
|
|
57
|
-
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
58
|
-
connectionString: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
59
|
-
host: z.ZodOptional<z.ZodString>;
|
|
60
|
-
port: z.ZodOptional<z.ZodNumber>;
|
|
61
|
-
database: z.ZodOptional<z.ZodString>;
|
|
62
|
-
password: z.ZodOptional<z.ZodString>;
|
|
63
|
-
keyPrefix: z.ZodOptional<z.ZodString>;
|
|
64
|
-
}, "strict", z.ZodTypeAny, {
|
|
65
|
-
type: "postgres";
|
|
66
|
-
maxConnections?: number | undefined;
|
|
67
|
-
idleTimeoutMillis?: number | undefined;
|
|
68
|
-
connectionTimeoutMillis?: number | undefined;
|
|
69
|
-
options?: Record<string, unknown> | undefined;
|
|
70
|
-
url?: string | undefined;
|
|
71
|
-
host?: string | undefined;
|
|
72
|
-
port?: number | undefined;
|
|
73
|
-
password?: string | undefined;
|
|
74
|
-
database?: string | undefined;
|
|
75
|
-
connectionString?: string | undefined;
|
|
76
|
-
keyPrefix?: string | undefined;
|
|
77
|
-
}, {
|
|
78
|
-
type: "postgres";
|
|
79
|
-
maxConnections?: number | undefined;
|
|
80
|
-
idleTimeoutMillis?: number | undefined;
|
|
81
|
-
connectionTimeoutMillis?: number | undefined;
|
|
82
|
-
options?: Record<string, unknown> | undefined;
|
|
83
|
-
url?: string | undefined;
|
|
84
|
-
host?: string | undefined;
|
|
85
|
-
port?: number | undefined;
|
|
86
|
-
password?: string | undefined;
|
|
87
|
-
database?: string | undefined;
|
|
88
|
-
connectionString?: string | undefined;
|
|
89
|
-
keyPrefix?: string | undefined;
|
|
90
|
-
}>, {
|
|
91
|
-
type: "postgres";
|
|
92
|
-
maxConnections?: number | undefined;
|
|
93
|
-
idleTimeoutMillis?: number | undefined;
|
|
94
|
-
connectionTimeoutMillis?: number | undefined;
|
|
95
|
-
options?: Record<string, unknown> | undefined;
|
|
96
|
-
url?: string | undefined;
|
|
97
|
-
host?: string | undefined;
|
|
98
|
-
port?: number | undefined;
|
|
99
|
-
password?: string | undefined;
|
|
100
|
-
database?: string | undefined;
|
|
101
|
-
connectionString?: string | undefined;
|
|
102
|
-
keyPrefix?: string | undefined;
|
|
103
|
-
}, {
|
|
104
|
-
type: "postgres";
|
|
105
|
-
maxConnections?: number | undefined;
|
|
106
|
-
idleTimeoutMillis?: number | undefined;
|
|
107
|
-
connectionTimeoutMillis?: number | undefined;
|
|
108
|
-
options?: Record<string, unknown> | undefined;
|
|
109
|
-
url?: string | undefined;
|
|
110
|
-
host?: string | undefined;
|
|
111
|
-
port?: number | undefined;
|
|
112
|
-
password?: string | undefined;
|
|
113
|
-
database?: string | undefined;
|
|
114
|
-
connectionString?: string | undefined;
|
|
115
|
-
keyPrefix?: string | undefined;
|
|
116
|
-
}>;
|
|
117
|
-
type PostgresDatabaseConfig = z.output<typeof PostgresDatabaseSchema>;
|
|
118
|
-
declare const DatabaseConfigSchema: z.ZodObject<{
|
|
119
|
-
type: z.ZodString;
|
|
120
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
121
|
-
type: z.ZodString;
|
|
122
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
123
|
-
type: z.ZodString;
|
|
124
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
125
|
-
type DatabaseConfig = z.output<typeof DatabaseConfigSchema>;
|
|
126
|
-
|
|
127
|
-
export { DATABASE_TYPES, type DatabaseConfig, DatabaseConfigSchema, type DatabaseType, type InMemoryDatabaseConfig, InMemoryDatabaseSchema, type PostgresDatabaseConfig, PostgresDatabaseSchema, type SqliteDatabaseConfig, SqliteDatabaseSchema };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Database, Logger } from '@dexto/core';
|
|
2
|
-
import { SqliteDatabaseConfig } from './schemas.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* SQLite database store for local development and production.
|
|
7
|
-
* Implements the Database interface with proper schema and connection handling.
|
|
8
|
-
*/
|
|
9
|
-
declare class SQLiteStore implements Database {
|
|
10
|
-
private db;
|
|
11
|
-
private dbPath;
|
|
12
|
-
private config;
|
|
13
|
-
private logger;
|
|
14
|
-
constructor(config: SqliteDatabaseConfig, logger: Logger);
|
|
15
|
-
private initializeTables;
|
|
16
|
-
connect(): Promise<void>;
|
|
17
|
-
disconnect(): Promise<void>;
|
|
18
|
-
isConnected(): boolean;
|
|
19
|
-
getStoreType(): string;
|
|
20
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
21
|
-
set<T>(key: string, value: T): Promise<void>;
|
|
22
|
-
delete(key: string): Promise<void>;
|
|
23
|
-
list(prefix: string): Promise<string[]>;
|
|
24
|
-
append<T>(key: string, item: T): Promise<void>;
|
|
25
|
-
getRange<T>(key: string, start: number, count: number): Promise<T[]>;
|
|
26
|
-
private checkConnection;
|
|
27
|
-
vacuum(): Promise<void>;
|
|
28
|
-
getStats(): Promise<{
|
|
29
|
-
kvCount: number;
|
|
30
|
-
listCount: number;
|
|
31
|
-
dbSize: number;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { SQLiteStore };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Database } from '@dexto/core';
|