@axiom-lattice/pg-stores 1.0.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/.turbo/turbo-build.log +20 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +201 -0
- package/MIGRATION_GUIDE.md +310 -0
- package/README.md +341 -0
- package/dist/index.d.mts +211 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +614 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +583 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -0
- package/src/index.ts +25 -0
- package/src/migrations/assistant_migrations.ts +44 -0
- package/src/migrations/migration.ts +184 -0
- package/src/migrations/thread_migrations.ts +42 -0
- package/src/stores/PostgreSQLAssistantStore.ts +303 -0
- package/src/stores/PostgreSQLThreadStore.ts +276 -0
- package/src/types.ts +10 -0
- package/tsconfig.json +26 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
// src/stores/PostgreSQLThreadStore.ts
|
|
2
|
+
import { Pool } from "pg";
|
|
3
|
+
|
|
4
|
+
// src/migrations/migration.ts
|
|
5
|
+
var MigrationManager = class {
|
|
6
|
+
constructor(pool) {
|
|
7
|
+
this.migrations = [];
|
|
8
|
+
this.pool = pool;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register a migration
|
|
12
|
+
*/
|
|
13
|
+
register(migration) {
|
|
14
|
+
this.migrations.push(migration);
|
|
15
|
+
this.migrations.sort((a, b) => a.version - b.version);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Initialize migrations table if it doesn't exist
|
|
19
|
+
*/
|
|
20
|
+
async ensureMigrationsTable(client) {
|
|
21
|
+
await client.query(`
|
|
22
|
+
CREATE TABLE IF NOT EXISTS lattice_schema_migrations (
|
|
23
|
+
version INTEGER PRIMARY KEY,
|
|
24
|
+
name VARCHAR(255) NOT NULL,
|
|
25
|
+
applied_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
26
|
+
)
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get applied migrations from database
|
|
31
|
+
*/
|
|
32
|
+
async getAppliedMigrations(client) {
|
|
33
|
+
await client.query(`
|
|
34
|
+
CREATE TABLE IF NOT EXISTS lattice_schema_migrations (
|
|
35
|
+
version INTEGER PRIMARY KEY,
|
|
36
|
+
name VARCHAR(255) NOT NULL,
|
|
37
|
+
applied_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
38
|
+
)
|
|
39
|
+
`);
|
|
40
|
+
const result = await client.query(
|
|
41
|
+
"SELECT version, name, applied_at FROM lattice_schema_migrations ORDER BY version"
|
|
42
|
+
);
|
|
43
|
+
return result.rows;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Apply pending migrations
|
|
47
|
+
*/
|
|
48
|
+
async migrate() {
|
|
49
|
+
const client = await this.pool.connect();
|
|
50
|
+
try {
|
|
51
|
+
await client.query("BEGIN");
|
|
52
|
+
await this.ensureMigrationsTable(client);
|
|
53
|
+
const appliedMigrations = await this.getAppliedMigrations(client);
|
|
54
|
+
const appliedVersions = new Set(appliedMigrations.map((m) => m.version));
|
|
55
|
+
const pendingMigrations = this.migrations.filter(
|
|
56
|
+
(m) => !appliedVersions.has(m.version)
|
|
57
|
+
);
|
|
58
|
+
if (pendingMigrations.length === 0) {
|
|
59
|
+
console.log("No pending migrations");
|
|
60
|
+
await client.query("COMMIT");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
for (const migration of pendingMigrations) {
|
|
64
|
+
console.log(
|
|
65
|
+
`Applying migration ${migration.version}: ${migration.name}`
|
|
66
|
+
);
|
|
67
|
+
await migration.up(client);
|
|
68
|
+
await client.query(
|
|
69
|
+
"INSERT INTO lattice_schema_migrations (version, name) VALUES ($1, $2)",
|
|
70
|
+
[migration.version, migration.name]
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
await client.query("COMMIT");
|
|
74
|
+
console.log(`Applied ${pendingMigrations.length} migration(s)`);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
await client.query("ROLLBACK");
|
|
77
|
+
throw error;
|
|
78
|
+
} finally {
|
|
79
|
+
client.release();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Rollback last migration
|
|
84
|
+
*/
|
|
85
|
+
async rollback() {
|
|
86
|
+
const client = await this.pool.connect();
|
|
87
|
+
try {
|
|
88
|
+
await client.query("BEGIN");
|
|
89
|
+
const appliedMigrations = await this.getAppliedMigrations(client);
|
|
90
|
+
if (appliedMigrations.length === 0) {
|
|
91
|
+
console.log("No migrations to rollback");
|
|
92
|
+
await client.query("COMMIT");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const lastMigration = appliedMigrations[appliedMigrations.length - 1];
|
|
96
|
+
const migration = this.migrations.find(
|
|
97
|
+
(m) => m.version === lastMigration.version
|
|
98
|
+
);
|
|
99
|
+
if (!migration || !migration.down) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Migration ${lastMigration.version} does not have a down migration`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
console.log(
|
|
105
|
+
`Rolling back migration ${lastMigration.version}: ${lastMigration.name}`
|
|
106
|
+
);
|
|
107
|
+
await migration.down(client);
|
|
108
|
+
await client.query(
|
|
109
|
+
"DELETE FROM lattice_schema_migrations WHERE version = $1",
|
|
110
|
+
[lastMigration.version]
|
|
111
|
+
);
|
|
112
|
+
await client.query("COMMIT");
|
|
113
|
+
console.log("Rollback completed");
|
|
114
|
+
} catch (error) {
|
|
115
|
+
await client.query("ROLLBACK");
|
|
116
|
+
throw error;
|
|
117
|
+
} finally {
|
|
118
|
+
client.release();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get current migration version
|
|
123
|
+
*/
|
|
124
|
+
async getCurrentVersion() {
|
|
125
|
+
const client = await this.pool.connect();
|
|
126
|
+
try {
|
|
127
|
+
const appliedMigrations = await this.getAppliedMigrations(client);
|
|
128
|
+
if (appliedMigrations.length === 0) {
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
return Math.max(...appliedMigrations.map((m) => m.version));
|
|
132
|
+
} finally {
|
|
133
|
+
client.release();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/migrations/thread_migrations.ts
|
|
139
|
+
var createThreadsTable = {
|
|
140
|
+
version: 1,
|
|
141
|
+
name: "create_threads_table",
|
|
142
|
+
up: async (client) => {
|
|
143
|
+
await client.query(`
|
|
144
|
+
CREATE TABLE IF NOT EXISTS lattice_threads (
|
|
145
|
+
id VARCHAR(255) NOT NULL,
|
|
146
|
+
assistant_id VARCHAR(255) NOT NULL,
|
|
147
|
+
metadata JSONB DEFAULT '{}',
|
|
148
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
149
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
150
|
+
PRIMARY KEY (id, assistant_id)
|
|
151
|
+
)
|
|
152
|
+
`);
|
|
153
|
+
await client.query(`
|
|
154
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_threads_assistant_id
|
|
155
|
+
ON lattice_threads(assistant_id)
|
|
156
|
+
`);
|
|
157
|
+
await client.query(`
|
|
158
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_threads_created_at
|
|
159
|
+
ON lattice_threads(created_at DESC)
|
|
160
|
+
`);
|
|
161
|
+
},
|
|
162
|
+
down: async (client) => {
|
|
163
|
+
await client.query("DROP INDEX IF EXISTS idx_lattice_threads_created_at");
|
|
164
|
+
await client.query("DROP INDEX IF EXISTS idx_lattice_threads_assistant_id");
|
|
165
|
+
await client.query("DROP TABLE IF EXISTS lattice_threads");
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// src/stores/PostgreSQLThreadStore.ts
|
|
170
|
+
var PostgreSQLThreadStore = class {
|
|
171
|
+
constructor(options) {
|
|
172
|
+
this.initialized = false;
|
|
173
|
+
this.ownsPool = true;
|
|
174
|
+
if (typeof options.poolConfig === "string") {
|
|
175
|
+
this.pool = new Pool({ connectionString: options.poolConfig });
|
|
176
|
+
} else {
|
|
177
|
+
this.pool = new Pool(options.poolConfig);
|
|
178
|
+
}
|
|
179
|
+
this.migrationManager = new MigrationManager(this.pool);
|
|
180
|
+
this.migrationManager.register(createThreadsTable);
|
|
181
|
+
if (options.autoMigrate !== false) {
|
|
182
|
+
this.initialize().catch((error) => {
|
|
183
|
+
console.error("Failed to initialize PostgreSQLThreadStore:", error);
|
|
184
|
+
throw error;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Dispose resources and close the connection pool
|
|
190
|
+
* Should be called when the store is no longer needed
|
|
191
|
+
*/
|
|
192
|
+
async dispose() {
|
|
193
|
+
if (this.ownsPool && this.pool) {
|
|
194
|
+
await this.pool.end();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Initialize the store and run migrations
|
|
199
|
+
*/
|
|
200
|
+
async initialize() {
|
|
201
|
+
if (this.initialized) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
await this.migrationManager.migrate();
|
|
205
|
+
this.initialized = true;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get all threads for a specific assistant
|
|
209
|
+
*/
|
|
210
|
+
async getThreadsByAssistantId(assistantId) {
|
|
211
|
+
await this.ensureInitialized();
|
|
212
|
+
const result = await this.pool.query(
|
|
213
|
+
`
|
|
214
|
+
SELECT id, assistant_id, metadata, created_at, updated_at
|
|
215
|
+
FROM lattice_threads
|
|
216
|
+
WHERE assistant_id = $1
|
|
217
|
+
ORDER BY created_at DESC
|
|
218
|
+
`,
|
|
219
|
+
[assistantId]
|
|
220
|
+
);
|
|
221
|
+
return result.rows.map(this.mapRowToThread);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get a thread by ID for a specific assistant
|
|
225
|
+
*/
|
|
226
|
+
async getThreadById(assistantId, threadId) {
|
|
227
|
+
await this.ensureInitialized();
|
|
228
|
+
const result = await this.pool.query(
|
|
229
|
+
`
|
|
230
|
+
SELECT id, assistant_id, metadata, created_at, updated_at
|
|
231
|
+
FROM lattice_threads
|
|
232
|
+
WHERE id = $1 AND assistant_id = $2
|
|
233
|
+
`,
|
|
234
|
+
[threadId, assistantId]
|
|
235
|
+
);
|
|
236
|
+
if (result.rows.length === 0) {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
return this.mapRowToThread(result.rows[0]);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Create a new thread for an assistant
|
|
243
|
+
*/
|
|
244
|
+
async createThread(assistantId, threadId, data) {
|
|
245
|
+
await this.ensureInitialized();
|
|
246
|
+
const now = /* @__PURE__ */ new Date();
|
|
247
|
+
const metadata = data.metadata || {};
|
|
248
|
+
await this.pool.query(
|
|
249
|
+
`
|
|
250
|
+
INSERT INTO lattice_threads (id, assistant_id, metadata, created_at, updated_at)
|
|
251
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
252
|
+
ON CONFLICT (id, assistant_id) DO UPDATE SET
|
|
253
|
+
metadata = EXCLUDED.metadata,
|
|
254
|
+
updated_at = EXCLUDED.updated_at
|
|
255
|
+
`,
|
|
256
|
+
[threadId, assistantId, JSON.stringify(metadata), now, now]
|
|
257
|
+
);
|
|
258
|
+
return {
|
|
259
|
+
id: threadId,
|
|
260
|
+
assistantId,
|
|
261
|
+
metadata,
|
|
262
|
+
createdAt: now,
|
|
263
|
+
updatedAt: now
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Update an existing thread
|
|
268
|
+
*/
|
|
269
|
+
async updateThread(assistantId, threadId, updates) {
|
|
270
|
+
await this.ensureInitialized();
|
|
271
|
+
const existing = await this.getThreadById(assistantId, threadId);
|
|
272
|
+
if (!existing) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
const updatedMetadata = {
|
|
276
|
+
...existing.metadata,
|
|
277
|
+
...updates.metadata || {}
|
|
278
|
+
};
|
|
279
|
+
const now = /* @__PURE__ */ new Date();
|
|
280
|
+
await this.pool.query(
|
|
281
|
+
`
|
|
282
|
+
UPDATE lattice_threads
|
|
283
|
+
SET metadata = $1, updated_at = $2
|
|
284
|
+
WHERE id = $3 AND assistant_id = $4
|
|
285
|
+
`,
|
|
286
|
+
[JSON.stringify(updatedMetadata), now, threadId, assistantId]
|
|
287
|
+
);
|
|
288
|
+
return {
|
|
289
|
+
...existing,
|
|
290
|
+
metadata: updatedMetadata,
|
|
291
|
+
updatedAt: now
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Delete a thread by ID
|
|
296
|
+
*/
|
|
297
|
+
async deleteThread(assistantId, threadId) {
|
|
298
|
+
await this.ensureInitialized();
|
|
299
|
+
const result = await this.pool.query(
|
|
300
|
+
`
|
|
301
|
+
DELETE FROM lattice_threads
|
|
302
|
+
WHERE id = $1 AND assistant_id = $2
|
|
303
|
+
`,
|
|
304
|
+
[threadId, assistantId]
|
|
305
|
+
);
|
|
306
|
+
return result.rowCount !== null && result.rowCount > 0;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Check if thread exists
|
|
310
|
+
*/
|
|
311
|
+
async hasThread(assistantId, threadId) {
|
|
312
|
+
await this.ensureInitialized();
|
|
313
|
+
const result = await this.pool.query(
|
|
314
|
+
`
|
|
315
|
+
SELECT 1 FROM lattice_threads
|
|
316
|
+
WHERE id = $1 AND assistant_id = $2
|
|
317
|
+
LIMIT 1
|
|
318
|
+
`,
|
|
319
|
+
[threadId, assistantId]
|
|
320
|
+
);
|
|
321
|
+
return result.rows.length > 0;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Ensure store is initialized
|
|
325
|
+
*/
|
|
326
|
+
async ensureInitialized() {
|
|
327
|
+
if (!this.initialized) {
|
|
328
|
+
await this.initialize();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Map database row to Thread object
|
|
333
|
+
*/
|
|
334
|
+
mapRowToThread(row) {
|
|
335
|
+
return {
|
|
336
|
+
id: row.id,
|
|
337
|
+
assistantId: row.assistant_id,
|
|
338
|
+
metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata || {},
|
|
339
|
+
createdAt: row.created_at,
|
|
340
|
+
updatedAt: row.updated_at
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// src/stores/PostgreSQLAssistantStore.ts
|
|
346
|
+
import { Pool as Pool2 } from "pg";
|
|
347
|
+
|
|
348
|
+
// src/migrations/assistant_migrations.ts
|
|
349
|
+
var createAssistantsTable = {
|
|
350
|
+
version: 1,
|
|
351
|
+
name: "create_assistants_table",
|
|
352
|
+
up: async (client) => {
|
|
353
|
+
await client.query(`
|
|
354
|
+
CREATE TABLE IF NOT EXISTS lattice_assistants (
|
|
355
|
+
id VARCHAR(255) PRIMARY KEY,
|
|
356
|
+
name VARCHAR(255) NOT NULL,
|
|
357
|
+
description TEXT,
|
|
358
|
+
graph_definition JSONB NOT NULL,
|
|
359
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
360
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
361
|
+
)
|
|
362
|
+
`);
|
|
363
|
+
await client.query(`
|
|
364
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_assistants_name
|
|
365
|
+
ON lattice_assistants(name)
|
|
366
|
+
`);
|
|
367
|
+
await client.query(`
|
|
368
|
+
CREATE INDEX IF NOT EXISTS idx_lattice_assistants_created_at
|
|
369
|
+
ON lattice_assistants(created_at DESC)
|
|
370
|
+
`);
|
|
371
|
+
},
|
|
372
|
+
down: async (client) => {
|
|
373
|
+
await client.query(
|
|
374
|
+
"DROP INDEX IF EXISTS idx_lattice_assistants_created_at"
|
|
375
|
+
);
|
|
376
|
+
await client.query("DROP INDEX IF EXISTS idx_lattice_assistants_name");
|
|
377
|
+
await client.query("DROP TABLE IF EXISTS lattice_assistants");
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// src/stores/PostgreSQLAssistantStore.ts
|
|
382
|
+
var PostgreSQLAssistantStore = class {
|
|
383
|
+
constructor(options) {
|
|
384
|
+
this.initialized = false;
|
|
385
|
+
this.ownsPool = true;
|
|
386
|
+
if (typeof options.poolConfig === "string") {
|
|
387
|
+
this.pool = new Pool2({ connectionString: options.poolConfig });
|
|
388
|
+
} else {
|
|
389
|
+
this.pool = new Pool2(options.poolConfig);
|
|
390
|
+
}
|
|
391
|
+
this.migrationManager = new MigrationManager(this.pool);
|
|
392
|
+
this.migrationManager.register(createAssistantsTable);
|
|
393
|
+
if (options.autoMigrate !== false) {
|
|
394
|
+
this.initialize().catch((error) => {
|
|
395
|
+
console.error("Failed to initialize PostgreSQLAssistantStore:", error);
|
|
396
|
+
throw error;
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Initialize the store and run migrations
|
|
402
|
+
*/
|
|
403
|
+
async initialize() {
|
|
404
|
+
if (this.initialized) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
await this.migrationManager.migrate();
|
|
408
|
+
this.initialized = true;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Get all assistants
|
|
412
|
+
*/
|
|
413
|
+
async getAllAssistants() {
|
|
414
|
+
await this.ensureInitialized();
|
|
415
|
+
const result = await this.pool.query(
|
|
416
|
+
`
|
|
417
|
+
SELECT id, name, description, graph_definition, created_at, updated_at
|
|
418
|
+
FROM lattice_assistants
|
|
419
|
+
ORDER BY created_at DESC
|
|
420
|
+
`
|
|
421
|
+
);
|
|
422
|
+
return result.rows.map(this.mapRowToAssistant);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get assistant by ID
|
|
426
|
+
*/
|
|
427
|
+
async getAssistantById(id) {
|
|
428
|
+
await this.ensureInitialized();
|
|
429
|
+
const result = await this.pool.query(
|
|
430
|
+
`
|
|
431
|
+
SELECT id, name, description, graph_definition, created_at, updated_at
|
|
432
|
+
FROM lattice_assistants
|
|
433
|
+
WHERE id = $1
|
|
434
|
+
`,
|
|
435
|
+
[id]
|
|
436
|
+
);
|
|
437
|
+
if (result.rows.length === 0) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
return this.mapRowToAssistant(result.rows[0]);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Create a new assistant
|
|
444
|
+
*/
|
|
445
|
+
async createAssistant(id, data) {
|
|
446
|
+
await this.ensureInitialized();
|
|
447
|
+
const now = /* @__PURE__ */ new Date();
|
|
448
|
+
await this.pool.query(
|
|
449
|
+
`
|
|
450
|
+
INSERT INTO lattice_assistants (id, name, description, graph_definition, created_at, updated_at)
|
|
451
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
452
|
+
ON CONFLICT (id) DO UPDATE SET
|
|
453
|
+
name = EXCLUDED.name,
|
|
454
|
+
description = EXCLUDED.description,
|
|
455
|
+
graph_definition = EXCLUDED.graph_definition,
|
|
456
|
+
updated_at = EXCLUDED.updated_at
|
|
457
|
+
`,
|
|
458
|
+
[
|
|
459
|
+
id,
|
|
460
|
+
data.name,
|
|
461
|
+
data.description || null,
|
|
462
|
+
JSON.stringify(data.graphDefinition),
|
|
463
|
+
now,
|
|
464
|
+
now
|
|
465
|
+
]
|
|
466
|
+
);
|
|
467
|
+
return {
|
|
468
|
+
id,
|
|
469
|
+
name: data.name,
|
|
470
|
+
description: data.description,
|
|
471
|
+
graphDefinition: data.graphDefinition,
|
|
472
|
+
createdAt: now,
|
|
473
|
+
updatedAt: now
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Update an existing assistant
|
|
478
|
+
*/
|
|
479
|
+
async updateAssistant(id, updates) {
|
|
480
|
+
await this.ensureInitialized();
|
|
481
|
+
const existing = await this.getAssistantById(id);
|
|
482
|
+
if (!existing) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
const updateFields = [];
|
|
486
|
+
const updateValues = [];
|
|
487
|
+
let paramIndex = 1;
|
|
488
|
+
if (updates.name !== void 0) {
|
|
489
|
+
updateFields.push(`name = $${paramIndex++}`);
|
|
490
|
+
updateValues.push(updates.name);
|
|
491
|
+
}
|
|
492
|
+
if (updates.description !== void 0) {
|
|
493
|
+
updateFields.push(`description = $${paramIndex++}`);
|
|
494
|
+
updateValues.push(updates.description || null);
|
|
495
|
+
}
|
|
496
|
+
if (updates.graphDefinition !== void 0) {
|
|
497
|
+
updateFields.push(`graph_definition = $${paramIndex++}`);
|
|
498
|
+
updateValues.push(JSON.stringify(updates.graphDefinition));
|
|
499
|
+
}
|
|
500
|
+
if (updateFields.length === 0) {
|
|
501
|
+
return existing;
|
|
502
|
+
}
|
|
503
|
+
updateFields.push(`updated_at = $${paramIndex++}`);
|
|
504
|
+
updateValues.push(/* @__PURE__ */ new Date());
|
|
505
|
+
updateValues.push(id);
|
|
506
|
+
await this.pool.query(
|
|
507
|
+
`
|
|
508
|
+
UPDATE lattice_assistants
|
|
509
|
+
SET ${updateFields.join(", ")}
|
|
510
|
+
WHERE id = $${paramIndex}
|
|
511
|
+
`,
|
|
512
|
+
updateValues
|
|
513
|
+
);
|
|
514
|
+
return await this.getAssistantById(id);
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Delete an assistant by ID
|
|
518
|
+
*/
|
|
519
|
+
async deleteAssistant(id) {
|
|
520
|
+
await this.ensureInitialized();
|
|
521
|
+
const result = await this.pool.query(
|
|
522
|
+
`
|
|
523
|
+
DELETE FROM lattice_assistants
|
|
524
|
+
WHERE id = $1
|
|
525
|
+
`,
|
|
526
|
+
[id]
|
|
527
|
+
);
|
|
528
|
+
return result.rowCount !== null && result.rowCount > 0;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Check if assistant exists
|
|
532
|
+
*/
|
|
533
|
+
async hasAssistant(id) {
|
|
534
|
+
await this.ensureInitialized();
|
|
535
|
+
const result = await this.pool.query(
|
|
536
|
+
`
|
|
537
|
+
SELECT 1 FROM lattice_assistants
|
|
538
|
+
WHERE id = $1
|
|
539
|
+
LIMIT 1
|
|
540
|
+
`,
|
|
541
|
+
[id]
|
|
542
|
+
);
|
|
543
|
+
return result.rows.length > 0;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Dispose resources and close the connection pool
|
|
547
|
+
* Should be called when the store is no longer needed
|
|
548
|
+
*/
|
|
549
|
+
async dispose() {
|
|
550
|
+
if (this.ownsPool && this.pool) {
|
|
551
|
+
await this.pool.end();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Ensure store is initialized
|
|
556
|
+
*/
|
|
557
|
+
async ensureInitialized() {
|
|
558
|
+
if (!this.initialized) {
|
|
559
|
+
await this.initialize();
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Map database row to Assistant object
|
|
564
|
+
*/
|
|
565
|
+
mapRowToAssistant(row) {
|
|
566
|
+
return {
|
|
567
|
+
id: row.id,
|
|
568
|
+
name: row.name,
|
|
569
|
+
description: row.description || void 0,
|
|
570
|
+
graphDefinition: typeof row.graph_definition === "string" ? JSON.parse(row.graph_definition) : row.graph_definition,
|
|
571
|
+
createdAt: row.created_at,
|
|
572
|
+
updatedAt: row.updated_at
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
export {
|
|
577
|
+
MigrationManager,
|
|
578
|
+
PostgreSQLAssistantStore,
|
|
579
|
+
PostgreSQLThreadStore,
|
|
580
|
+
createAssistantsTable,
|
|
581
|
+
createThreadsTable
|
|
582
|
+
};
|
|
583
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stores/PostgreSQLThreadStore.ts","../src/migrations/migration.ts","../src/migrations/thread_migrations.ts","../src/stores/PostgreSQLAssistantStore.ts","../src/migrations/assistant_migrations.ts"],"sourcesContent":["/**\n * PostgreSQL implementation of ThreadStore\n */\n\nimport { Pool, PoolClient, PoolConfig } from \"pg\";\nimport {\n ThreadStore,\n Thread,\n CreateThreadRequest,\n} from \"@axiom-lattice/protocols\";\nimport { MigrationManager } from \"../migrations/migration\";\nimport { createThreadsTable } from \"../migrations/thread_migrations\";\n\n/**\n * PostgreSQL ThreadStore options\n */\nexport interface PostgreSQLThreadStoreOptions {\n /**\n * PostgreSQL connection pool configuration\n * Can be a connection string or PoolConfig object\n */\n poolConfig: string | PoolConfig;\n\n /**\n * Whether to run migrations automatically on initialization\n * @default true\n */\n autoMigrate?: boolean;\n}\n\n/**\n * PostgreSQL implementation of ThreadStore\n */\nexport class PostgreSQLThreadStore implements ThreadStore {\n private pool: Pool;\n private migrationManager: MigrationManager;\n private initialized: boolean = false;\n private ownsPool: boolean = true;\n\n constructor(options: PostgreSQLThreadStoreOptions) {\n // Create Pool from config\n if (typeof options.poolConfig === \"string\") {\n this.pool = new Pool({ connectionString: options.poolConfig });\n } else {\n this.pool = new Pool(options.poolConfig);\n }\n\n this.migrationManager = new MigrationManager(this.pool);\n this.migrationManager.register(createThreadsTable);\n\n // Auto-migrate by default\n if (options.autoMigrate !== false) {\n this.initialize().catch((error) => {\n console.error(\"Failed to initialize PostgreSQLThreadStore:\", error);\n throw error;\n });\n }\n }\n\n /**\n * Dispose resources and close the connection pool\n * Should be called when the store is no longer needed\n */\n async dispose(): Promise<void> {\n if (this.ownsPool && this.pool) {\n await this.pool.end();\n }\n }\n\n /**\n * Initialize the store and run migrations\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n await this.migrationManager.migrate();\n this.initialized = true;\n }\n\n /**\n * Get all threads for a specific assistant\n */\n async getThreadsByAssistantId(assistantId: string): Promise<Thread[]> {\n await this.ensureInitialized();\n\n const result = await this.pool.query<{\n id: string;\n assistant_id: string;\n metadata: any;\n created_at: Date;\n updated_at: Date;\n }>(\n `\n SELECT id, assistant_id, metadata, created_at, updated_at\n FROM lattice_threads\n WHERE assistant_id = $1\n ORDER BY created_at DESC\n `,\n [assistantId]\n );\n\n return result.rows.map(this.mapRowToThread);\n }\n\n /**\n * Get a thread by ID for a specific assistant\n */\n async getThreadById(\n assistantId: string,\n threadId: string\n ): Promise<Thread | undefined> {\n await this.ensureInitialized();\n\n const result = await this.pool.query<{\n id: string;\n assistant_id: string;\n metadata: any;\n created_at: Date;\n updated_at: Date;\n }>(\n `\n SELECT id, assistant_id, metadata, created_at, updated_at\n FROM lattice_threads\n WHERE id = $1 AND assistant_id = $2\n `,\n [threadId, assistantId]\n );\n\n if (result.rows.length === 0) {\n return undefined;\n }\n\n return this.mapRowToThread(result.rows[0]);\n }\n\n /**\n * Create a new thread for an assistant\n */\n async createThread(\n assistantId: string,\n threadId: string,\n data: CreateThreadRequest\n ): Promise<Thread> {\n await this.ensureInitialized();\n\n const now = new Date();\n const metadata = data.metadata || {};\n\n await this.pool.query(\n `\n INSERT INTO lattice_threads (id, assistant_id, metadata, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5)\n ON CONFLICT (id, assistant_id) DO UPDATE SET\n metadata = EXCLUDED.metadata,\n updated_at = EXCLUDED.updated_at\n `,\n [threadId, assistantId, JSON.stringify(metadata), now, now]\n );\n\n return {\n id: threadId,\n assistantId,\n metadata,\n createdAt: now,\n updatedAt: now,\n };\n }\n\n /**\n * Update an existing thread\n */\n async updateThread(\n assistantId: string,\n threadId: string,\n updates: Partial<CreateThreadRequest>\n ): Promise<Thread | null> {\n await this.ensureInitialized();\n\n // Get existing thread\n const existing = await this.getThreadById(assistantId, threadId);\n if (!existing) {\n return null;\n }\n\n // Merge metadata\n const updatedMetadata = {\n ...existing.metadata,\n ...(updates.metadata || {}),\n };\n\n const now = new Date();\n\n await this.pool.query(\n `\n UPDATE lattice_threads\n SET metadata = $1, updated_at = $2\n WHERE id = $3 AND assistant_id = $4\n `,\n [JSON.stringify(updatedMetadata), now, threadId, assistantId]\n );\n\n return {\n ...existing,\n metadata: updatedMetadata,\n updatedAt: now,\n };\n }\n\n /**\n * Delete a thread by ID\n */\n async deleteThread(assistantId: string, threadId: string): Promise<boolean> {\n await this.ensureInitialized();\n\n const result = await this.pool.query(\n `\n DELETE FROM lattice_threads\n WHERE id = $1 AND assistant_id = $2\n `,\n [threadId, assistantId]\n );\n\n return result.rowCount !== null && result.rowCount > 0;\n }\n\n /**\n * Check if thread exists\n */\n async hasThread(assistantId: string, threadId: string): Promise<boolean> {\n await this.ensureInitialized();\n\n const result = await this.pool.query(\n `\n SELECT 1 FROM lattice_threads\n WHERE id = $1 AND assistant_id = $2\n LIMIT 1\n `,\n [threadId, assistantId]\n );\n\n return result.rows.length > 0;\n }\n\n /**\n * Ensure store is initialized\n */\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.initialize();\n }\n }\n\n /**\n * Map database row to Thread object\n */\n private mapRowToThread(row: {\n id: string;\n assistant_id: string;\n metadata: any;\n created_at: Date;\n updated_at: Date;\n }): Thread {\n return {\n id: row.id,\n assistantId: row.assistant_id,\n metadata:\n typeof row.metadata === \"string\"\n ? JSON.parse(row.metadata)\n : row.metadata || {},\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n }\n}\n","/**\n * Migration system for database schema management\n */\n\nimport { Pool, PoolClient } from \"pg\";\n\n/**\n * Migration record stored in database\n */\ninterface MigrationRecord {\n version: number;\n name: string;\n applied_at: Date;\n}\n\n/**\n * Migration definition\n */\nexport interface Migration {\n version: number;\n name: string;\n up: (client: PoolClient) => Promise<void>;\n down?: (client: PoolClient) => Promise<void>;\n}\n\n/**\n * Migration manager\n */\nexport class MigrationManager {\n private pool: Pool;\n private migrations: Migration[] = [];\n\n constructor(pool: Pool) {\n this.pool = pool;\n }\n\n /**\n * Register a migration\n */\n register(migration: Migration): void {\n this.migrations.push(migration);\n // Sort migrations by version\n this.migrations.sort((a, b) => a.version - b.version);\n }\n\n /**\n * Initialize migrations table if it doesn't exist\n */\n private async ensureMigrationsTable(client: PoolClient): Promise<void> {\n await client.query(`\n CREATE TABLE IF NOT EXISTS lattice_schema_migrations (\n version INTEGER PRIMARY KEY,\n name VARCHAR(255) NOT NULL,\n applied_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n )\n `);\n }\n\n /**\n * Get applied migrations from database\n */\n private async getAppliedMigrations(\n client: PoolClient\n ): Promise<MigrationRecord[]> {\n await client.query(`\n CREATE TABLE IF NOT EXISTS lattice_schema_migrations (\n version INTEGER PRIMARY KEY,\n name VARCHAR(255) NOT NULL,\n applied_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n )\n `);\n\n const result = await client.query<MigrationRecord>(\n \"SELECT version, name, applied_at FROM lattice_schema_migrations ORDER BY version\"\n );\n return result.rows;\n }\n\n /**\n * Apply pending migrations\n */\n async migrate(): Promise<void> {\n const client = await this.pool.connect();\n try {\n await client.query(\"BEGIN\");\n\n await this.ensureMigrationsTable(client);\n const appliedMigrations = await this.getAppliedMigrations(client);\n const appliedVersions = new Set(appliedMigrations.map((m) => m.version));\n\n // Find pending migrations\n const pendingMigrations = this.migrations.filter(\n (m) => !appliedVersions.has(m.version)\n );\n\n if (pendingMigrations.length === 0) {\n console.log(\"No pending migrations\");\n await client.query(\"COMMIT\");\n return;\n }\n\n // Apply pending migrations\n for (const migration of pendingMigrations) {\n console.log(\n `Applying migration ${migration.version}: ${migration.name}`\n );\n await migration.up(client);\n await client.query(\n \"INSERT INTO lattice_schema_migrations (version, name) VALUES ($1, $2)\",\n [migration.version, migration.name]\n );\n }\n\n await client.query(\"COMMIT\");\n console.log(`Applied ${pendingMigrations.length} migration(s)`);\n } catch (error) {\n await client.query(\"ROLLBACK\");\n throw error;\n } finally {\n client.release();\n }\n }\n\n /**\n * Rollback last migration\n */\n async rollback(): Promise<void> {\n const client = await this.pool.connect();\n try {\n await client.query(\"BEGIN\");\n\n const appliedMigrations = await this.getAppliedMigrations(client);\n if (appliedMigrations.length === 0) {\n console.log(\"No migrations to rollback\");\n await client.query(\"COMMIT\");\n return;\n }\n\n const lastMigration = appliedMigrations[appliedMigrations.length - 1];\n const migration = this.migrations.find(\n (m) => m.version === lastMigration.version\n );\n\n if (!migration || !migration.down) {\n throw new Error(\n `Migration ${lastMigration.version} does not have a down migration`\n );\n }\n\n console.log(\n `Rolling back migration ${lastMigration.version}: ${lastMigration.name}`\n );\n await migration.down(client);\n await client.query(\n \"DELETE FROM lattice_schema_migrations WHERE version = $1\",\n [lastMigration.version]\n );\n\n await client.query(\"COMMIT\");\n console.log(\"Rollback completed\");\n } catch (error) {\n await client.query(\"ROLLBACK\");\n throw error;\n } finally {\n client.release();\n }\n }\n\n /**\n * Get current migration version\n */\n async getCurrentVersion(): Promise<number> {\n const client = await this.pool.connect();\n try {\n const appliedMigrations = await this.getAppliedMigrations(client);\n if (appliedMigrations.length === 0) {\n return 0;\n }\n return Math.max(...appliedMigrations.map((m) => m.version));\n } finally {\n client.release();\n }\n }\n}\n","/**\n * Thread table migrations\n */\n\nimport { PoolClient } from \"pg\";\nimport { Migration } from \"./migration\";\n\n/**\n * Initial migration: Create threads table\n */\nexport const createThreadsTable: Migration = {\n version: 1,\n name: \"create_threads_table\",\n up: async (client: PoolClient) => {\n await client.query(`\n CREATE TABLE IF NOT EXISTS lattice_threads (\n id VARCHAR(255) NOT NULL,\n assistant_id VARCHAR(255) NOT NULL,\n metadata JSONB DEFAULT '{}',\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (id, assistant_id)\n )\n `);\n\n // Create indexes for better query performance\n await client.query(`\n CREATE INDEX IF NOT EXISTS idx_lattice_threads_assistant_id \n ON lattice_threads(assistant_id)\n `);\n\n await client.query(`\n CREATE INDEX IF NOT EXISTS idx_lattice_threads_created_at \n ON lattice_threads(created_at DESC)\n `);\n },\n down: async (client: PoolClient) => {\n await client.query(\"DROP INDEX IF EXISTS idx_lattice_threads_created_at\");\n await client.query(\"DROP INDEX IF EXISTS idx_lattice_threads_assistant_id\");\n await client.query(\"DROP TABLE IF EXISTS lattice_threads\");\n },\n};\n","/**\n * PostgreSQL implementation of AssistantStore\n */\n\nimport { Pool, PoolClient, PoolConfig } from \"pg\";\nimport {\n AssistantStore,\n Assistant,\n CreateAssistantRequest,\n} from \"@axiom-lattice/protocols\";\nimport { MigrationManager } from \"../migrations/migration\";\nimport { createAssistantsTable } from \"../migrations/assistant_migrations\";\n\n/**\n * PostgreSQL AssistantStore options\n */\nexport interface PostgreSQLAssistantStoreOptions {\n /**\n * PostgreSQL connection pool configuration\n * Can be a connection string or PoolConfig object\n */\n poolConfig: string | PoolConfig;\n\n /**\n * Whether to run migrations automatically on initialization\n * @default true\n */\n autoMigrate?: boolean;\n}\n\n/**\n * PostgreSQL implementation of AssistantStore\n */\nexport class PostgreSQLAssistantStore implements AssistantStore {\n private pool: Pool;\n private migrationManager: MigrationManager;\n private initialized: boolean = false;\n private ownsPool: boolean = true;\n\n constructor(options: PostgreSQLAssistantStoreOptions) {\n // Create Pool from config\n if (typeof options.poolConfig === \"string\") {\n this.pool = new Pool({ connectionString: options.poolConfig });\n } else {\n this.pool = new Pool(options.poolConfig);\n }\n\n this.migrationManager = new MigrationManager(this.pool);\n this.migrationManager.register(createAssistantsTable);\n\n // Auto-migrate by default\n if (options.autoMigrate !== false) {\n this.initialize().catch((error) => {\n console.error(\"Failed to initialize PostgreSQLAssistantStore:\", error);\n throw error;\n });\n }\n }\n\n /**\n * Initialize the store and run migrations\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n await this.migrationManager.migrate();\n this.initialized = true;\n }\n\n /**\n * Get all assistants\n */\n async getAllAssistants(): Promise<Assistant[]> {\n await this.ensureInitialized();\n\n const result = await this.pool.query<{\n id: string;\n name: string;\n description: string | null;\n graph_definition: any;\n created_at: Date;\n updated_at: Date;\n }>(\n `\n SELECT id, name, description, graph_definition, created_at, updated_at\n FROM lattice_assistants\n ORDER BY created_at DESC\n `\n );\n\n return result.rows.map(this.mapRowToAssistant);\n }\n\n /**\n * Get assistant by ID\n */\n async getAssistantById(id: string): Promise<Assistant | null> {\n await this.ensureInitialized();\n\n const result = await this.pool.query<{\n id: string;\n name: string;\n description: string | null;\n graph_definition: any;\n created_at: Date;\n updated_at: Date;\n }>(\n `\n SELECT id, name, description, graph_definition, created_at, updated_at\n FROM lattice_assistants\n WHERE id = $1\n `,\n [id]\n );\n\n if (result.rows.length === 0) {\n return null;\n }\n\n return this.mapRowToAssistant(result.rows[0]);\n }\n\n /**\n * Create a new assistant\n */\n async createAssistant(\n id: string,\n data: CreateAssistantRequest\n ): Promise<Assistant> {\n await this.ensureInitialized();\n\n const now = new Date();\n\n await this.pool.query(\n `\n INSERT INTO lattice_assistants (id, name, description, graph_definition, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6)\n ON CONFLICT (id) DO UPDATE SET\n name = EXCLUDED.name,\n description = EXCLUDED.description,\n graph_definition = EXCLUDED.graph_definition,\n updated_at = EXCLUDED.updated_at\n `,\n [\n id,\n data.name,\n data.description || null,\n JSON.stringify(data.graphDefinition),\n now,\n now,\n ]\n );\n\n return {\n id,\n name: data.name,\n description: data.description,\n graphDefinition: data.graphDefinition,\n createdAt: now,\n updatedAt: now,\n };\n }\n\n /**\n * Update an existing assistant\n */\n async updateAssistant(\n id: string,\n updates: Partial<CreateAssistantRequest>\n ): Promise<Assistant | null> {\n await this.ensureInitialized();\n\n // Get existing assistant\n const existing = await this.getAssistantById(id);\n if (!existing) {\n return null;\n }\n\n // Build update query dynamically based on provided fields\n const updateFields: string[] = [];\n const updateValues: any[] = [];\n let paramIndex = 1;\n\n if (updates.name !== undefined) {\n updateFields.push(`name = $${paramIndex++}`);\n updateValues.push(updates.name);\n }\n\n if (updates.description !== undefined) {\n updateFields.push(`description = $${paramIndex++}`);\n updateValues.push(updates.description || null);\n }\n\n if (updates.graphDefinition !== undefined) {\n updateFields.push(`graph_definition = $${paramIndex++}`);\n updateValues.push(JSON.stringify(updates.graphDefinition));\n }\n\n if (updateFields.length === 0) {\n // No fields to update\n return existing;\n }\n\n // Always update updated_at\n updateFields.push(`updated_at = $${paramIndex++}`);\n updateValues.push(new Date());\n\n // Add id for WHERE clause\n updateValues.push(id);\n\n await this.pool.query(\n `\n UPDATE lattice_assistants\n SET ${updateFields.join(\", \")}\n WHERE id = $${paramIndex}\n `,\n updateValues\n );\n\n // Return updated assistant\n return await this.getAssistantById(id);\n }\n\n /**\n * Delete an assistant by ID\n */\n async deleteAssistant(id: string): Promise<boolean> {\n await this.ensureInitialized();\n\n const result = await this.pool.query(\n `\n DELETE FROM lattice_assistants\n WHERE id = $1\n `,\n [id]\n );\n\n return result.rowCount !== null && result.rowCount > 0;\n }\n\n /**\n * Check if assistant exists\n */\n async hasAssistant(id: string): Promise<boolean> {\n await this.ensureInitialized();\n\n const result = await this.pool.query(\n `\n SELECT 1 FROM lattice_assistants\n WHERE id = $1\n LIMIT 1\n `,\n [id]\n );\n\n return result.rows.length > 0;\n }\n\n /**\n * Dispose resources and close the connection pool\n * Should be called when the store is no longer needed\n */\n async dispose(): Promise<void> {\n if (this.ownsPool && this.pool) {\n await this.pool.end();\n }\n }\n\n /**\n * Ensure store is initialized\n */\n private async ensureInitialized(): Promise<void> {\n if (!this.initialized) {\n await this.initialize();\n }\n }\n\n /**\n * Map database row to Assistant object\n */\n private mapRowToAssistant(row: {\n id: string;\n name: string;\n description: string | null;\n graph_definition: any;\n created_at: Date;\n updated_at: Date;\n }): Assistant {\n return {\n id: row.id,\n name: row.name,\n description: row.description || undefined,\n graphDefinition:\n typeof row.graph_definition === \"string\"\n ? JSON.parse(row.graph_definition)\n : row.graph_definition,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n }\n}\n","/**\n * Assistant table migrations\n */\n\nimport { PoolClient } from \"pg\";\nimport { Migration } from \"./migration\";\n\n/**\n * Initial migration: Create assistants table\n */\nexport const createAssistantsTable: Migration = {\n version: 1,\n name: \"create_assistants_table\",\n up: async (client: PoolClient) => {\n await client.query(`\n CREATE TABLE IF NOT EXISTS lattice_assistants (\n id VARCHAR(255) PRIMARY KEY,\n name VARCHAR(255) NOT NULL,\n description TEXT,\n graph_definition JSONB NOT NULL,\n created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n )\n `);\n\n // Create indexes for better query performance\n await client.query(`\n CREATE INDEX IF NOT EXISTS idx_lattice_assistants_name \n ON lattice_assistants(name)\n `);\n\n await client.query(`\n CREATE INDEX IF NOT EXISTS idx_lattice_assistants_created_at \n ON lattice_assistants(created_at DESC)\n `);\n },\n down: async (client: PoolClient) => {\n await client.query(\n \"DROP INDEX IF EXISTS idx_lattice_assistants_created_at\"\n );\n await client.query(\"DROP INDEX IF EXISTS idx_lattice_assistants_name\");\n await client.query(\"DROP TABLE IF EXISTS lattice_assistants\");\n },\n};\n"],"mappings":";AAIA,SAAS,YAAoC;;;ACwBtC,IAAM,mBAAN,MAAuB;AAAA,EAI5B,YAAY,MAAY;AAFxB,SAAQ,aAA0B,CAAC;AAGjC,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAS,WAA4B;AACnC,SAAK,WAAW,KAAK,SAAS;AAE9B,SAAK,WAAW,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,sBAAs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AC,KAAK,aAAa;AACrB,YAAM,KAAK,WAAW;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,kBAAkB,KAOZ;AACZ,WAAO;AAAA,MACL,IAAI,IAAI;AAAA,MACR,MAAM,IAAI;AAAA,MACV,aAAa,IAAI,eAAe;AAAA,MAChC,iBACE,OAAO,IAAI,qBAAqB,WAC5B,KAAK,MAAM,IAAI,gBAAgB,IAC/B,IAAI;AAAA,MACV,WAAW,IAAI;AAAA,MACf,WAAW,IAAI;AAAA,IACjB;AAAA,EACF;AACF;","names":["Pool","Pool"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@axiom-lattice/pg-stores",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "PG stores implementation for Axiom Lattice framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"lattice",
|
|
17
|
+
"pg",
|
|
18
|
+
"stores"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"pg": "^8.16.3",
|
|
24
|
+
"@axiom-lattice/protocols": "2.1.6",
|
|
25
|
+
"@axiom-lattice/core": "2.1.12"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^20.11.24",
|
|
29
|
+
"@types/pg": "^8.11.10",
|
|
30
|
+
"rimraf": "^5.0.5",
|
|
31
|
+
"tsup": "^8.0.1",
|
|
32
|
+
"typescript": "^5.4.2"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --sourcemap",
|
|
36
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
37
|
+
"lint": "tsc --noEmit",
|
|
38
|
+
"clean": "rimraf dist"
|
|
39
|
+
}
|
|
40
|
+
}
|