@dexto/storage 1.6.0 → 1.6.1
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
package/dist/schemas.d.cts
CHANGED
|
@@ -1,7 +1,302 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
declare const DATABASE_TYPES: readonly ["in-memory", "sqlite", "postgres"];
|
|
94
|
+
type DatabaseType = (typeof DATABASE_TYPES)[number];
|
|
95
|
+
declare const InMemoryDatabaseSchema: z.ZodObject<{
|
|
96
|
+
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
100
|
+
} & {
|
|
101
|
+
type: z.ZodLiteral<"in-memory">;
|
|
102
|
+
}, "strict", z.ZodTypeAny, {
|
|
103
|
+
type: "in-memory";
|
|
104
|
+
maxConnections?: number | undefined;
|
|
105
|
+
idleTimeoutMillis?: number | undefined;
|
|
106
|
+
connectionTimeoutMillis?: number | undefined;
|
|
107
|
+
options?: Record<string, unknown> | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
type: "in-memory";
|
|
110
|
+
maxConnections?: number | undefined;
|
|
111
|
+
idleTimeoutMillis?: number | undefined;
|
|
112
|
+
connectionTimeoutMillis?: number | undefined;
|
|
113
|
+
options?: Record<string, unknown> | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
type InMemoryDatabaseConfig = z.output<typeof InMemoryDatabaseSchema>;
|
|
116
|
+
declare const SqliteDatabaseSchema: z.ZodObject<{
|
|
117
|
+
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
120
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
121
|
+
} & {
|
|
122
|
+
type: z.ZodLiteral<"sqlite">;
|
|
123
|
+
path: z.ZodString;
|
|
124
|
+
}, "strict", z.ZodTypeAny, {
|
|
125
|
+
path: string;
|
|
126
|
+
type: "sqlite";
|
|
127
|
+
maxConnections?: number | undefined;
|
|
128
|
+
idleTimeoutMillis?: number | undefined;
|
|
129
|
+
connectionTimeoutMillis?: number | undefined;
|
|
130
|
+
options?: Record<string, unknown> | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
path: string;
|
|
133
|
+
type: "sqlite";
|
|
134
|
+
maxConnections?: number | undefined;
|
|
135
|
+
idleTimeoutMillis?: number | undefined;
|
|
136
|
+
connectionTimeoutMillis?: number | undefined;
|
|
137
|
+
options?: Record<string, unknown> | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
type SqliteDatabaseConfig = z.output<typeof SqliteDatabaseSchema>;
|
|
140
|
+
declare const PostgresDatabaseSchema: z.ZodEffects<z.ZodObject<{
|
|
141
|
+
maxConnections: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
idleTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
connectionTimeoutMillis: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
145
|
+
} & {
|
|
146
|
+
type: z.ZodLiteral<"postgres">;
|
|
147
|
+
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
148
|
+
connectionString: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
149
|
+
host: z.ZodOptional<z.ZodString>;
|
|
150
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
database: z.ZodOptional<z.ZodString>;
|
|
152
|
+
password: z.ZodOptional<z.ZodString>;
|
|
153
|
+
keyPrefix: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, "strict", z.ZodTypeAny, {
|
|
155
|
+
type: "postgres";
|
|
156
|
+
maxConnections?: number | undefined;
|
|
157
|
+
idleTimeoutMillis?: number | undefined;
|
|
158
|
+
connectionTimeoutMillis?: number | undefined;
|
|
159
|
+
options?: Record<string, unknown> | undefined;
|
|
160
|
+
url?: string | undefined;
|
|
161
|
+
host?: string | undefined;
|
|
162
|
+
port?: number | undefined;
|
|
163
|
+
password?: string | undefined;
|
|
164
|
+
database?: string | undefined;
|
|
165
|
+
connectionString?: string | undefined;
|
|
166
|
+
keyPrefix?: string | undefined;
|
|
167
|
+
}, {
|
|
168
|
+
type: "postgres";
|
|
169
|
+
maxConnections?: number | undefined;
|
|
170
|
+
idleTimeoutMillis?: number | undefined;
|
|
171
|
+
connectionTimeoutMillis?: number | undefined;
|
|
172
|
+
options?: Record<string, unknown> | undefined;
|
|
173
|
+
url?: string | undefined;
|
|
174
|
+
host?: string | undefined;
|
|
175
|
+
port?: number | undefined;
|
|
176
|
+
password?: string | undefined;
|
|
177
|
+
database?: string | undefined;
|
|
178
|
+
connectionString?: string | undefined;
|
|
179
|
+
keyPrefix?: string | undefined;
|
|
180
|
+
}>, {
|
|
181
|
+
type: "postgres";
|
|
182
|
+
maxConnections?: number | undefined;
|
|
183
|
+
idleTimeoutMillis?: number | undefined;
|
|
184
|
+
connectionTimeoutMillis?: number | undefined;
|
|
185
|
+
options?: Record<string, unknown> | undefined;
|
|
186
|
+
url?: string | undefined;
|
|
187
|
+
host?: string | undefined;
|
|
188
|
+
port?: number | undefined;
|
|
189
|
+
password?: string | undefined;
|
|
190
|
+
database?: string | undefined;
|
|
191
|
+
connectionString?: string | undefined;
|
|
192
|
+
keyPrefix?: string | undefined;
|
|
193
|
+
}, {
|
|
194
|
+
type: "postgres";
|
|
195
|
+
maxConnections?: number | undefined;
|
|
196
|
+
idleTimeoutMillis?: number | undefined;
|
|
197
|
+
connectionTimeoutMillis?: number | undefined;
|
|
198
|
+
options?: Record<string, unknown> | undefined;
|
|
199
|
+
url?: string | undefined;
|
|
200
|
+
host?: string | undefined;
|
|
201
|
+
port?: number | undefined;
|
|
202
|
+
password?: string | undefined;
|
|
203
|
+
database?: string | undefined;
|
|
204
|
+
connectionString?: string | undefined;
|
|
205
|
+
keyPrefix?: string | undefined;
|
|
206
|
+
}>;
|
|
207
|
+
type PostgresDatabaseConfig = z.output<typeof PostgresDatabaseSchema>;
|
|
208
|
+
declare const DatabaseConfigSchema: z.ZodObject<{
|
|
209
|
+
type: z.ZodString;
|
|
210
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
211
|
+
type: z.ZodString;
|
|
212
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
213
|
+
type: z.ZodString;
|
|
214
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
215
|
+
type DatabaseConfig = z.output<typeof DatabaseConfigSchema>;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Built-in blob store types shipped by `@dexto/storage`.
|
|
219
|
+
* Custom backends shipped via images are not included in this list.
|
|
220
|
+
*/
|
|
221
|
+
declare const BLOB_STORE_TYPES: readonly ["in-memory", "local"];
|
|
222
|
+
type BlobStoreType = (typeof BLOB_STORE_TYPES)[number];
|
|
223
|
+
/**
|
|
224
|
+
* In-memory blob store configuration
|
|
225
|
+
*/
|
|
226
|
+
declare const InMemoryBlobStoreSchema: z.ZodObject<{
|
|
227
|
+
type: z.ZodLiteral<"in-memory">;
|
|
228
|
+
maxBlobSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
229
|
+
maxTotalSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
230
|
+
}, "strict", z.ZodTypeAny, {
|
|
231
|
+
type: "in-memory";
|
|
232
|
+
maxBlobSize: number;
|
|
233
|
+
maxTotalSize: number;
|
|
234
|
+
}, {
|
|
235
|
+
type: "in-memory";
|
|
236
|
+
maxBlobSize?: number | undefined;
|
|
237
|
+
maxTotalSize?: number | undefined;
|
|
238
|
+
}>;
|
|
239
|
+
type InMemoryBlobStoreConfigInput = z.input<typeof InMemoryBlobStoreSchema>;
|
|
240
|
+
type InMemoryBlobStoreConfig = z.output<typeof InMemoryBlobStoreSchema>;
|
|
241
|
+
/**
|
|
242
|
+
* Local filesystem blob store configuration
|
|
243
|
+
*/
|
|
244
|
+
declare const LocalBlobStoreSchema: z.ZodObject<{
|
|
245
|
+
type: z.ZodLiteral<"local">;
|
|
246
|
+
storePath: z.ZodString;
|
|
247
|
+
maxBlobSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
248
|
+
maxTotalSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
249
|
+
cleanupAfterDays: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
250
|
+
}, "strict", z.ZodTypeAny, {
|
|
251
|
+
type: "local";
|
|
252
|
+
maxBlobSize: number;
|
|
253
|
+
maxTotalSize: number;
|
|
254
|
+
storePath: string;
|
|
255
|
+
cleanupAfterDays: number;
|
|
256
|
+
}, {
|
|
257
|
+
type: "local";
|
|
258
|
+
storePath: string;
|
|
259
|
+
maxBlobSize?: number | undefined;
|
|
260
|
+
maxTotalSize?: number | undefined;
|
|
261
|
+
cleanupAfterDays?: number | undefined;
|
|
262
|
+
}>;
|
|
263
|
+
type LocalBlobStoreConfigInput = z.input<typeof LocalBlobStoreSchema>;
|
|
264
|
+
type LocalBlobStoreConfig = z.output<typeof LocalBlobStoreSchema>;
|
|
265
|
+
/**
|
|
266
|
+
* Blob store configuration schema.
|
|
267
|
+
*
|
|
268
|
+
* This schema uses `.passthrough()` to accept any backend-specific configuration.
|
|
269
|
+
* It only validates that a `type` field exists as a string.
|
|
270
|
+
*
|
|
271
|
+
* Detailed validation happens in the product-layer resolver (`@dexto/agent-config`) via
|
|
272
|
+
* each image factory's `configSchema`. Built-in backends are validated by their factory schemas.
|
|
273
|
+
*
|
|
274
|
+
* This approach allows:
|
|
275
|
+
* - Custom backends to be provided by a custom image
|
|
276
|
+
* - Each backend to define its own configuration structure and strict schema
|
|
277
|
+
*
|
|
278
|
+
* Example flow:
|
|
279
|
+
* 1. Config passes this schema (basic structure check)
|
|
280
|
+
* 2. Product layer resolves backend via image + validates against factory schema
|
|
281
|
+
* 3. Core receives a concrete `BlobStore` instance (DI)
|
|
282
|
+
*/
|
|
283
|
+
declare const BlobStoreConfigSchema: z.ZodObject<{
|
|
284
|
+
type: z.ZodString;
|
|
285
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
286
|
+
type: z.ZodString;
|
|
287
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
288
|
+
type: z.ZodString;
|
|
289
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
290
|
+
/**
|
|
291
|
+
* Blob store configuration type.
|
|
292
|
+
*
|
|
293
|
+
* Union type including built-in backends (local, in-memory) and a catch-all
|
|
294
|
+
* for custom backends provided via images at runtime.
|
|
295
|
+
*/
|
|
296
|
+
type BlobStoreConfig = InMemoryBlobStoreConfig | LocalBlobStoreConfig | {
|
|
297
|
+
type: string;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
};
|
|
5
300
|
|
|
6
301
|
/**
|
|
7
302
|
* Top-level storage configuration schema
|
|
@@ -69,4 +364,4 @@ declare const StorageSchema: z.ZodBranded<z.ZodObject<{
|
|
|
69
364
|
type StorageConfig = z.input<typeof StorageSchema>;
|
|
70
365
|
type ValidatedStorageConfig = z.output<typeof StorageSchema>;
|
|
71
366
|
|
|
72
|
-
export { type StorageConfig, StorageSchema, type ValidatedStorageConfig };
|
|
367
|
+
export { BLOB_STORE_TYPES, type BlobStoreConfig, BlobStoreConfigSchema, type BlobStoreType, CACHE_TYPES, type CacheConfig, CacheConfigSchema, type CacheType, DATABASE_TYPES, type DatabaseConfig, DatabaseConfigSchema, type DatabaseType, type InMemoryBlobStoreConfig, type InMemoryBlobStoreConfigInput, InMemoryBlobStoreSchema, type InMemoryCacheConfig, InMemoryCacheSchema, type InMemoryDatabaseConfig, InMemoryDatabaseSchema, type LocalBlobStoreConfig, type LocalBlobStoreConfigInput, LocalBlobStoreSchema, type PostgresDatabaseConfig, PostgresDatabaseSchema, type RedisCacheConfig, RedisCacheSchema, type SqliteDatabaseConfig, SqliteDatabaseSchema, type StorageConfig, StorageSchema, type ValidatedStorageConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/storage",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Storage backends and factories for Dexto agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^3.25.0",
|
|
24
|
-
"@dexto/core": "1.6.
|
|
24
|
+
"@dexto/core": "1.6.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"better-sqlite3": "^11.10.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "tsup",
|
|
51
|
+
"build": "tsup && node ../../scripts/clean-tsbuildinfo.mjs && tsc -b tsconfig.json --emitDeclarationOnly",
|
|
52
52
|
"typecheck": "tsc --noEmit",
|
|
53
53
|
"clean": "rm -rf dist"
|
|
54
54
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { LocalBlobStoreConfig } from '../schemas.cjs';
|
|
2
|
-
import { BlobStoreFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for local filesystem blob storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores blobs on the local filesystem with content-based
|
|
10
|
-
* deduplication and metadata tracking. It's ideal for development and
|
|
11
|
-
* single-machine deployments.
|
|
12
|
-
*
|
|
13
|
-
* Features:
|
|
14
|
-
* - Zero external dependencies (uses Node.js fs module)
|
|
15
|
-
* - Content-based deduplication (same hash = same blob)
|
|
16
|
-
* - Automatic cleanup of old blobs
|
|
17
|
-
* - No network required
|
|
18
|
-
*/
|
|
19
|
-
declare const localBlobStoreFactory: BlobStoreFactory<LocalBlobStoreConfig>;
|
|
20
|
-
|
|
21
|
-
export { localBlobStoreFactory };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { InMemoryBlobStoreConfig } from '../schemas.cjs';
|
|
2
|
-
import { BlobStoreFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for in-memory blob storage.
|
|
8
|
-
*
|
|
9
|
-
* This factory stores blobs in RAM, making it ideal for testing and
|
|
10
|
-
* development. All data is lost when the process exits.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Zero dependencies
|
|
14
|
-
* - Extremely fast (no I/O)
|
|
15
|
-
* - Configurable size limits
|
|
16
|
-
* - No network required
|
|
17
|
-
* - Perfect for unit tests
|
|
18
|
-
*/
|
|
19
|
-
declare const inMemoryBlobStoreFactory: BlobStoreFactory<InMemoryBlobStoreConfig>;
|
|
20
|
-
|
|
21
|
-
export { inMemoryBlobStoreFactory };
|
package/dist/blob/factory.d.cts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Logger, BlobStore } from '@dexto/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Factory interface for creating blob store instances.
|
|
6
|
-
*
|
|
7
|
-
* Factories are plain exports (no global registries). Images decide which factories are
|
|
8
|
-
* available by including them in `image.storage.blob`.
|
|
9
|
-
*/
|
|
10
|
-
interface BlobStoreFactory<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 BlobStore instance.
|
|
18
|
-
* @param config - Validated configuration specific to this backend
|
|
19
|
-
* @param logger - Logger instance for the blob store
|
|
20
|
-
* @returns A BlobStore implementation
|
|
21
|
-
*/
|
|
22
|
-
create(config: TConfig, logger: Logger): BlobStore | Promise<BlobStore>;
|
|
23
|
-
/**
|
|
24
|
-
* Optional metadata for documentation, UIs, and discovery.
|
|
25
|
-
*/
|
|
26
|
-
metadata?: {
|
|
27
|
-
/** Human-readable name (e.g., "Local Filesystem", "Amazon S3") */
|
|
28
|
-
displayName: string;
|
|
29
|
-
/** Brief description of this storage backend */
|
|
30
|
-
description: string;
|
|
31
|
-
/** Whether this backend requires network connectivity */
|
|
32
|
-
requiresNetwork?: boolean;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type { BlobStoreFactory };
|
package/dist/blob/index.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { BlobStoreFactory } from './factory.cjs';
|
|
2
|
-
export { BlobData, BlobInput, BlobMetadata, BlobReference, BlobStats, BlobStore, StoredBlobMetadata } from '@dexto/core';
|
|
3
|
-
export { localBlobStoreFactory } from './factories/local.cjs';
|
|
4
|
-
export { inMemoryBlobStoreFactory } from './factories/memory.cjs';
|
|
5
|
-
export { BLOB_STORE_TYPES, BlobStoreConfig, BlobStoreConfigSchema, BlobStoreType, InMemoryBlobStoreConfig, InMemoryBlobStoreConfigInput, InMemoryBlobStoreSchema, LocalBlobStoreConfig, LocalBlobStoreConfigInput, LocalBlobStoreSchema } from './schemas.cjs';
|
|
6
|
-
export { LocalBlobStore } from './local-blob-store.cjs';
|
|
7
|
-
export { MemoryBlobStore } from './memory-blob-store.cjs';
|
|
8
|
-
import 'zod';
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { BlobStore, Logger, BlobInput, BlobMetadata, BlobReference, BlobData, BlobStats } from '@dexto/core';
|
|
2
|
-
import { LocalBlobStoreConfig } from './schemas.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Local filesystem blob store implementation.
|
|
7
|
-
*
|
|
8
|
-
* Stores blobs on the local filesystem with content-based deduplication
|
|
9
|
-
* and metadata tracking. This is the default store for development
|
|
10
|
-
* and single-machine deployments.
|
|
11
|
-
*/
|
|
12
|
-
declare class LocalBlobStore implements BlobStore {
|
|
13
|
-
private config;
|
|
14
|
-
private storePath;
|
|
15
|
-
private connected;
|
|
16
|
-
private statsCache;
|
|
17
|
-
private statsCachePromise;
|
|
18
|
-
private lastStatsRefresh;
|
|
19
|
-
private logger;
|
|
20
|
-
private static readonly STATS_REFRESH_INTERVAL_MS;
|
|
21
|
-
constructor(config: LocalBlobStoreConfig, logger: Logger);
|
|
22
|
-
connect(): Promise<void>;
|
|
23
|
-
disconnect(): Promise<void>;
|
|
24
|
-
isConnected(): boolean;
|
|
25
|
-
getStoreType(): string;
|
|
26
|
-
store(input: BlobInput, metadata?: BlobMetadata): Promise<BlobReference>;
|
|
27
|
-
retrieve(reference: string, format?: 'base64' | 'buffer' | 'path' | 'stream' | 'url'): Promise<BlobData>;
|
|
28
|
-
exists(reference: string): Promise<boolean>;
|
|
29
|
-
delete(reference: string): Promise<void>;
|
|
30
|
-
cleanup(olderThan?: Date): Promise<number>;
|
|
31
|
-
getStats(): Promise<BlobStats>;
|
|
32
|
-
getStoragePath(): string | undefined;
|
|
33
|
-
listBlobs(): Promise<BlobReference[]>;
|
|
34
|
-
private ensureStatsCache;
|
|
35
|
-
private refreshStatsCache;
|
|
36
|
-
private updateStatsCacheAfterStore;
|
|
37
|
-
private updateStatsCacheAfterDelete;
|
|
38
|
-
/**
|
|
39
|
-
* Convert various input types to Buffer
|
|
40
|
-
*/
|
|
41
|
-
private inputToBuffer;
|
|
42
|
-
/**
|
|
43
|
-
* Parse blob reference to extract ID
|
|
44
|
-
*/
|
|
45
|
-
private parseReference;
|
|
46
|
-
/**
|
|
47
|
-
* Detect MIME type from buffer content and/or filename
|
|
48
|
-
*/
|
|
49
|
-
private detectMimeType;
|
|
50
|
-
/**
|
|
51
|
-
* Check if buffer contains text content
|
|
52
|
-
*/
|
|
53
|
-
private isTextBuffer;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { LocalBlobStore };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { BlobStore, Logger, BlobInput, BlobMetadata, BlobReference, BlobData, BlobStats } from '@dexto/core';
|
|
2
|
-
import { InMemoryBlobStoreConfigInput } from './schemas.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* In-memory blob store implementation.
|
|
7
|
-
*
|
|
8
|
-
* Stores blobs in memory with content-based deduplication and size limits.
|
|
9
|
-
* Suitable for development, testing, and scenarios where blob persistence
|
|
10
|
-
* across restarts is not required.
|
|
11
|
-
*
|
|
12
|
-
* Features:
|
|
13
|
-
* - Content-based deduplication (same as LocalBlobStore)
|
|
14
|
-
* - Configurable size limits (per-blob and total)
|
|
15
|
-
* - Automatic cleanup of old blobs
|
|
16
|
-
* - MIME type detection
|
|
17
|
-
* - Multi-format retrieval (base64, buffer, stream, data URI)
|
|
18
|
-
*
|
|
19
|
-
* Limitations:
|
|
20
|
-
* - Data lost on restart (no persistence)
|
|
21
|
-
* - Path format not supported (no filesystem)
|
|
22
|
-
* - Memory usage proportional to blob size
|
|
23
|
-
*/
|
|
24
|
-
type MemoryBlobStoreOptions = Omit<InMemoryBlobStoreConfigInput, 'type'>;
|
|
25
|
-
declare class MemoryBlobStore implements BlobStore {
|
|
26
|
-
private config;
|
|
27
|
-
private blobs;
|
|
28
|
-
private connected;
|
|
29
|
-
private logger;
|
|
30
|
-
constructor(options: MemoryBlobStoreOptions, logger: Logger);
|
|
31
|
-
connect(): Promise<void>;
|
|
32
|
-
disconnect(): Promise<void>;
|
|
33
|
-
isConnected(): boolean;
|
|
34
|
-
getStoreType(): string;
|
|
35
|
-
store(input: BlobInput, metadata?: BlobMetadata): Promise<BlobReference>;
|
|
36
|
-
retrieve(reference: string, format?: 'base64' | 'buffer' | 'path' | 'stream' | 'url'): Promise<BlobData>;
|
|
37
|
-
exists(reference: string): Promise<boolean>;
|
|
38
|
-
delete(reference: string): Promise<void>;
|
|
39
|
-
cleanup(olderThan?: Date): Promise<number>;
|
|
40
|
-
getStats(): Promise<BlobStats>;
|
|
41
|
-
listBlobs(): Promise<BlobReference[]>;
|
|
42
|
-
getStoragePath(): string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Calculate total size of all blobs in memory
|
|
45
|
-
*/
|
|
46
|
-
private getTotalSize;
|
|
47
|
-
/**
|
|
48
|
-
* Convert various input types to Buffer.
|
|
49
|
-
* Copied from LocalBlobStore with minor adaptations.
|
|
50
|
-
*/
|
|
51
|
-
private inputToBuffer;
|
|
52
|
-
/**
|
|
53
|
-
* Parse blob reference to extract ID.
|
|
54
|
-
* Copied from LocalBlobStore.
|
|
55
|
-
*/
|
|
56
|
-
private parseReference;
|
|
57
|
-
/**
|
|
58
|
-
* Detect MIME type from buffer content and/or filename.
|
|
59
|
-
* Copied from LocalBlobStore.
|
|
60
|
-
*/
|
|
61
|
-
private detectMimeType;
|
|
62
|
-
/**
|
|
63
|
-
* Check if buffer contains text content.
|
|
64
|
-
* Copied from LocalBlobStore.
|
|
65
|
-
*/
|
|
66
|
-
private isTextBuffer;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { MemoryBlobStore, type MemoryBlobStoreOptions };
|
package/dist/blob/schemas.d.cts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Built-in blob store types shipped by `@dexto/storage`.
|
|
5
|
-
* Custom backends shipped via images are not included in this list.
|
|
6
|
-
*/
|
|
7
|
-
declare const BLOB_STORE_TYPES: readonly ["in-memory", "local"];
|
|
8
|
-
type BlobStoreType = (typeof BLOB_STORE_TYPES)[number];
|
|
9
|
-
/**
|
|
10
|
-
* In-memory blob store configuration
|
|
11
|
-
*/
|
|
12
|
-
declare const InMemoryBlobStoreSchema: z.ZodObject<{
|
|
13
|
-
type: z.ZodLiteral<"in-memory">;
|
|
14
|
-
maxBlobSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
-
maxTotalSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
16
|
-
}, "strict", z.ZodTypeAny, {
|
|
17
|
-
type: "in-memory";
|
|
18
|
-
maxBlobSize: number;
|
|
19
|
-
maxTotalSize: number;
|
|
20
|
-
}, {
|
|
21
|
-
type: "in-memory";
|
|
22
|
-
maxBlobSize?: number | undefined;
|
|
23
|
-
maxTotalSize?: number | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
type InMemoryBlobStoreConfigInput = z.input<typeof InMemoryBlobStoreSchema>;
|
|
26
|
-
type InMemoryBlobStoreConfig = z.output<typeof InMemoryBlobStoreSchema>;
|
|
27
|
-
/**
|
|
28
|
-
* Local filesystem blob store configuration
|
|
29
|
-
*/
|
|
30
|
-
declare const LocalBlobStoreSchema: z.ZodObject<{
|
|
31
|
-
type: z.ZodLiteral<"local">;
|
|
32
|
-
storePath: z.ZodString;
|
|
33
|
-
maxBlobSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
34
|
-
maxTotalSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
35
|
-
cleanupAfterDays: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
36
|
-
}, "strict", z.ZodTypeAny, {
|
|
37
|
-
type: "local";
|
|
38
|
-
maxBlobSize: number;
|
|
39
|
-
maxTotalSize: number;
|
|
40
|
-
storePath: string;
|
|
41
|
-
cleanupAfterDays: number;
|
|
42
|
-
}, {
|
|
43
|
-
type: "local";
|
|
44
|
-
storePath: string;
|
|
45
|
-
maxBlobSize?: number | undefined;
|
|
46
|
-
maxTotalSize?: number | undefined;
|
|
47
|
-
cleanupAfterDays?: number | undefined;
|
|
48
|
-
}>;
|
|
49
|
-
type LocalBlobStoreConfigInput = z.input<typeof LocalBlobStoreSchema>;
|
|
50
|
-
type LocalBlobStoreConfig = z.output<typeof LocalBlobStoreSchema>;
|
|
51
|
-
/**
|
|
52
|
-
* Blob store configuration schema.
|
|
53
|
-
*
|
|
54
|
-
* This schema uses `.passthrough()` to accept any backend-specific configuration.
|
|
55
|
-
* It only validates that a `type` field exists as a string.
|
|
56
|
-
*
|
|
57
|
-
* Detailed validation happens in the product-layer resolver (`@dexto/agent-config`) via
|
|
58
|
-
* each image factory's `configSchema`. Built-in backends are validated by their factory schemas.
|
|
59
|
-
*
|
|
60
|
-
* This approach allows:
|
|
61
|
-
* - Custom backends to be provided by a custom image
|
|
62
|
-
* - Each backend to define its own configuration structure and strict schema
|
|
63
|
-
*
|
|
64
|
-
* Example flow:
|
|
65
|
-
* 1. Config passes this schema (basic structure check)
|
|
66
|
-
* 2. Product layer resolves backend via image + validates against factory schema
|
|
67
|
-
* 3. Core receives a concrete `BlobStore` instance (DI)
|
|
68
|
-
*/
|
|
69
|
-
declare const BlobStoreConfigSchema: z.ZodObject<{
|
|
70
|
-
type: z.ZodString;
|
|
71
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
72
|
-
type: z.ZodString;
|
|
73
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
74
|
-
type: z.ZodString;
|
|
75
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
76
|
-
/**
|
|
77
|
-
* Blob store configuration type.
|
|
78
|
-
*
|
|
79
|
-
* Union type including built-in backends (local, in-memory) and a catch-all
|
|
80
|
-
* for custom backends provided via images at runtime.
|
|
81
|
-
*/
|
|
82
|
-
type BlobStoreConfig = InMemoryBlobStoreConfig | LocalBlobStoreConfig | {
|
|
83
|
-
type: string;
|
|
84
|
-
[key: string]: unknown;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { BLOB_STORE_TYPES, type BlobStoreConfig, BlobStoreConfigSchema, type BlobStoreType, type InMemoryBlobStoreConfig, type InMemoryBlobStoreConfigInput, InMemoryBlobStoreSchema, type LocalBlobStoreConfig, type LocalBlobStoreConfigInput, LocalBlobStoreSchema };
|
package/dist/blob/types.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { BlobData, BlobInput, BlobMetadata, BlobReference, BlobStats, BlobStore, StoredBlobMetadata } from '@dexto/core';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { InMemoryCacheConfig } from '../schemas.cjs';
|
|
2
|
-
import { CacheFactory } from '../factory.cjs';
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@dexto/core';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Factory for in-memory cache 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
|
-
* - TTL support for automatic expiration
|
|
16
|
-
* - No network required
|
|
17
|
-
* - Data is lost on restart
|
|
18
|
-
*/
|
|
19
|
-
declare const inMemoryCacheFactory: CacheFactory<InMemoryCacheConfig>;
|
|
20
|
-
|
|
21
|
-
export { inMemoryCacheFactory };
|