@elizaos/plugin-sql 1.6.4-alpha.20 → 1.6.4-alpha.22

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.
@@ -8570,6 +8570,24 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
8570
8570
  super();
8571
8571
  this.agentId = agentId;
8572
8572
  }
8573
+ normalizeEntityNames(names) {
8574
+ if (names == null) {
8575
+ return [];
8576
+ }
8577
+ if (typeof names === "string") {
8578
+ return [names];
8579
+ }
8580
+ if (Array.isArray(names)) {
8581
+ return names.map(String);
8582
+ }
8583
+ if (names instanceof Set) {
8584
+ return Array.from(names).map(String);
8585
+ }
8586
+ if (typeof names === "object" && typeof names[Symbol.iterator] === "function") {
8587
+ return Array.from(names).map(String);
8588
+ }
8589
+ return [String(names)];
8590
+ }
8573
8591
  async withRetry(operation) {
8574
8592
  let lastError = new Error("Unknown error");
8575
8593
  for (let attempt = 1;attempt <= this.maxRetries; attempt++) {
@@ -8841,7 +8859,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
8841
8859
  return this.withDatabase(async () => {
8842
8860
  try {
8843
8861
  return await this.db.transaction(async (tx) => {
8844
- await tx.insert(entityTable).values(entities);
8862
+ const normalizedEntities = entities.map((entity2) => ({
8863
+ ...entity2,
8864
+ names: this.normalizeEntityNames(entity2.names),
8865
+ metadata: entity2.metadata || {}
8866
+ }));
8867
+ await tx.insert(entityTable).values(normalizedEntities);
8845
8868
  logger8.debug(`${entities.length} Entities created successfully`);
8846
8869
  return true;
8847
8870
  });
@@ -8875,7 +8898,12 @@ class BaseDrizzleAdapter extends DatabaseAdapter {
8875
8898
  throw new Error("Entity ID is required for update");
8876
8899
  }
8877
8900
  return this.withDatabase(async () => {
8878
- await this.db.update(entityTable).set(entity2).where(eq(entityTable.id, entity2.id));
8901
+ const normalizedEntity = {
8902
+ ...entity2,
8903
+ names: this.normalizeEntityNames(entity2.names),
8904
+ metadata: entity2.metadata || {}
8905
+ };
8906
+ await this.db.update(entityTable).set(normalizedEntity).where(eq(entityTable.id, entity2.id));
8879
8907
  });
8880
8908
  }
8881
8909
  async deleteEntity(entityId) {
@@ -11364,5 +11392,5 @@ export {
11364
11392
  DatabaseMigrationService
11365
11393
  };
11366
11394
 
11367
- //# debugId=81727AD4C0F30EE564756E2164756E21
11395
+ //# debugId=A92CE19BE9F182BF64756E2164756E21
11368
11396
  //# sourceMappingURL=index.node.js.map