@elizaos/plugin-sql 1.6.4-alpha.20 → 1.6.4-alpha.21
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 +31 -3
- package/dist/browser/index.browser.js.map +3 -3
- package/dist/browser/tsconfig.build.tsbuildinfo +1 -1
- package/dist/node/index.node.js +31 -3
- package/dist/node/index.node.js.map +3 -3
- package/dist/node/tsconfig.build.node.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -20198,6 +20198,24 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
20198
20198
|
super();
|
|
20199
20199
|
this.agentId = agentId;
|
|
20200
20200
|
}
|
|
20201
|
+
normalizeEntityNames(names) {
|
|
20202
|
+
if (names == null) {
|
|
20203
|
+
return [];
|
|
20204
|
+
}
|
|
20205
|
+
if (typeof names === "string") {
|
|
20206
|
+
return [names];
|
|
20207
|
+
}
|
|
20208
|
+
if (Array.isArray(names)) {
|
|
20209
|
+
return names.map(String);
|
|
20210
|
+
}
|
|
20211
|
+
if (names instanceof Set) {
|
|
20212
|
+
return Array.from(names).map(String);
|
|
20213
|
+
}
|
|
20214
|
+
if (typeof names === "object" && typeof names[Symbol.iterator] === "function") {
|
|
20215
|
+
return Array.from(names).map(String);
|
|
20216
|
+
}
|
|
20217
|
+
return [String(names)];
|
|
20218
|
+
}
|
|
20201
20219
|
async withRetry(operation) {
|
|
20202
20220
|
let lastError = new Error("Unknown error");
|
|
20203
20221
|
for (let attempt = 1;attempt <= this.maxRetries; attempt++) {
|
|
@@ -20469,7 +20487,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
20469
20487
|
return this.withDatabase(async () => {
|
|
20470
20488
|
try {
|
|
20471
20489
|
return await this.db.transaction(async (tx) => {
|
|
20472
|
-
|
|
20490
|
+
const normalizedEntities = entities.map((entity) => ({
|
|
20491
|
+
...entity,
|
|
20492
|
+
names: this.normalizeEntityNames(entity.names),
|
|
20493
|
+
metadata: entity.metadata || {}
|
|
20494
|
+
}));
|
|
20495
|
+
await tx.insert(entityTable).values(normalizedEntities);
|
|
20473
20496
|
logger7.debug(`${entities.length} Entities created successfully`);
|
|
20474
20497
|
return true;
|
|
20475
20498
|
});
|
|
@@ -20503,7 +20526,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
|
|
|
20503
20526
|
throw new Error("Entity ID is required for update");
|
|
20504
20527
|
}
|
|
20505
20528
|
return this.withDatabase(async () => {
|
|
20506
|
-
|
|
20529
|
+
const normalizedEntity = {
|
|
20530
|
+
...entity,
|
|
20531
|
+
names: this.normalizeEntityNames(entity.names),
|
|
20532
|
+
metadata: entity.metadata || {}
|
|
20533
|
+
};
|
|
20534
|
+
await this.db.update(entityTable).set(normalizedEntity).where(eq(entityTable.id, entity.id));
|
|
20507
20535
|
});
|
|
20508
20536
|
}
|
|
20509
20537
|
async deleteEntity(entityId) {
|
|
@@ -22216,5 +22244,5 @@ export {
|
|
|
22216
22244
|
DatabaseMigrationService
|
|
22217
22245
|
};
|
|
22218
22246
|
|
|
22219
|
-
//# debugId=
|
|
22247
|
+
//# debugId=1883B6786029AB3864756E2164756E21
|
|
22220
22248
|
//# sourceMappingURL=index.browser.js.map
|