@elizaos/plugin-sql 1.7.1-alpha.12 → 1.7.1-alpha.13
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/browser/index.browser.js +14 -12
- package/dist/browser/index.browser.js.map +5 -5
- package/dist/browser/tsconfig.build.tsbuildinfo +1 -1
- package/dist/node/index.node.js +11236 -2710
- package/dist/node/index.node.js.map +35 -10
- package/dist/node/tsconfig.build.node.tsbuildinfo +1 -1
- package/package.json +7 -5
|
@@ -20741,14 +20741,16 @@ async function installRLSFunctions(adapter) {
|
|
|
20741
20741
|
await db.execute(sql24`
|
|
20742
20742
|
CREATE OR REPLACE FUNCTION current_server_id() RETURNS UUID AS $$
|
|
20743
20743
|
DECLARE
|
|
20744
|
-
|
|
20744
|
+
server_id_text TEXT;
|
|
20745
20745
|
BEGIN
|
|
20746
|
-
|
|
20746
|
+
server_id_text := NULLIF(current_setting('app.server_id', TRUE), '');
|
|
20747
|
+
|
|
20748
|
+
IF server_id_text IS NULL OR server_id_text = '' THEN
|
|
20749
|
+
RETURN NULL;
|
|
20750
|
+
END IF;
|
|
20747
20751
|
|
|
20748
|
-
-- Return NULL if application_name is not set or not a valid UUID
|
|
20749
|
-
-- This allows admin queries to work without RLS restrictions
|
|
20750
20752
|
BEGIN
|
|
20751
|
-
RETURN
|
|
20753
|
+
RETURN server_id_text::UUID;
|
|
20752
20754
|
EXCEPTION WHEN OTHERS THEN
|
|
20753
20755
|
RETURN NULL;
|
|
20754
20756
|
END;
|
|
@@ -22222,7 +22224,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
22222
22224
|
if (offset !== undefined && offset < 0) {
|
|
22223
22225
|
throw new Error("offset must be a non-negative number");
|
|
22224
22226
|
}
|
|
22225
|
-
return this.
|
|
22227
|
+
return this.withIsolationContext(entityId ?? null, async (tx) => {
|
|
22226
22228
|
const conditions = [eq2(memoryTable.type, tableName)];
|
|
22227
22229
|
if (start) {
|
|
22228
22230
|
conditions.push(gte(memoryTable.createdAt, new Date(start)));
|
|
@@ -22422,7 +22424,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
22422
22424
|
try {
|
|
22423
22425
|
const sanitizedBody = this.sanitizeJsonObject(params.body);
|
|
22424
22426
|
const jsonString = JSON.stringify(sanitizedBody);
|
|
22425
|
-
await this.
|
|
22427
|
+
await this.withIsolationContext(params.entityId, async (tx) => {
|
|
22426
22428
|
await tx.insert(logTable).values({
|
|
22427
22429
|
body: sql25`${jsonString}::jsonb`,
|
|
22428
22430
|
entityId: params.entityId,
|
|
@@ -22470,7 +22472,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
22470
22472
|
}
|
|
22471
22473
|
async getLogs(params) {
|
|
22472
22474
|
const { entityId, roomId, type, count: count2, offset } = params;
|
|
22473
|
-
return this.
|
|
22475
|
+
return this.withIsolationContext(entityId ?? null, async (tx) => {
|
|
22474
22476
|
const result = await tx.select().from(logTable).where(and(roomId ? eq2(logTable.roomId, roomId) : undefined, type ? eq2(logTable.type, type) : undefined)).orderBy(desc(logTable.createdAt)).limit(count2 ?? 10).offset(offset ?? 0);
|
|
22475
22477
|
const logs = result.map((log2) => ({
|
|
22476
22478
|
...log2,
|
|
@@ -22490,7 +22492,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
22490
22492
|
const limit = Math.min(Math.max(params.limit ?? 20, 1), 100);
|
|
22491
22493
|
const fromDate = typeof params.from === "number" ? new Date(params.from) : undefined;
|
|
22492
22494
|
const toDate = typeof params.to === "number" ? new Date(params.to) : undefined;
|
|
22493
|
-
return this.
|
|
22495
|
+
return this.withIsolationContext(params.entityId ?? null, async (tx) => {
|
|
22494
22496
|
const runMap = new Map;
|
|
22495
22497
|
const conditions = [
|
|
22496
22498
|
eq2(logTable.type, "run_event"),
|
|
@@ -22736,7 +22738,7 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
22736
22738
|
}
|
|
22737
22739
|
const contentToInsert = typeof memory.content === "string" ? memory.content : JSON.stringify(memory.content ?? {});
|
|
22738
22740
|
const metadataToInsert = typeof memory.metadata === "string" ? memory.metadata : JSON.stringify(memory.metadata ?? {});
|
|
22739
|
-
await this.
|
|
22741
|
+
await this.withIsolationContext(memory.entityId, async (tx) => {
|
|
22740
22742
|
await tx.insert(memoryTable).values([
|
|
22741
22743
|
{
|
|
22742
22744
|
id: memoryId,
|
|
@@ -23748,7 +23750,7 @@ class PgliteDatabaseAdapter extends BaseDrizzleAdapter {
|
|
|
23748
23750
|
this.manager = manager;
|
|
23749
23751
|
this.db = drizzle(this.manager.getConnection());
|
|
23750
23752
|
}
|
|
23751
|
-
async
|
|
23753
|
+
async withIsolationContext(_entityId, callback) {
|
|
23752
23754
|
return this.db.transaction(callback);
|
|
23753
23755
|
}
|
|
23754
23756
|
async getEntityByIds(entityIds) {
|
|
@@ -23877,5 +23879,5 @@ export {
|
|
|
23877
23879
|
DatabaseMigrationService
|
|
23878
23880
|
};
|
|
23879
23881
|
|
|
23880
|
-
//# debugId=
|
|
23882
|
+
//# debugId=E88A6E483DDDF13C64756E2164756E21
|
|
23881
23883
|
//# sourceMappingURL=index.browser.js.map
|