@utaba/deep-memory-storage-sqlserver 0.2.0 → 0.4.0

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.cjs CHANGED
@@ -437,13 +437,13 @@ var SqlServerStorageProvider = class {
437
437
  getPool() {
438
438
  if (!this.pool) {
439
439
  throw new import_deep_memory.ProviderError(
440
- "SqlServerStorageProvider not initialised. Call initialise() first."
440
+ "SqlServerStorageProvider not initialized. Call initialize() first."
441
441
  );
442
442
  }
443
443
  return this.pool;
444
444
  }
445
445
  // ─── Lifecycle ────────────────────────────────────────────────────
446
- async initialise() {
446
+ async initialize() {
447
447
  if (this.config.connection instanceof import_mssql.default.ConnectionPool) {
448
448
  this.pool = this.config.connection;
449
449
  this.ownsPool = false;
@@ -698,13 +698,23 @@ var SqlServerStorageProvider = class {
698
698
  if (!updated) throw new import_deep_memory.RepositoryNotFoundError(repositoryId);
699
699
  return updated;
700
700
  }
701
- async deleteRepository(repositoryId) {
701
+ async deleteRepository(repositoryId, _onProgress) {
702
702
  const pool = this.getPool();
703
703
  const result = await pool.request().input("id", import_mssql.default.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_repositories")} WHERE [repository_id] = @id`);
704
704
  if (result.rowsAffected[0] === 0) {
705
705
  throw new import_deep_memory.RepositoryNotFoundError(repositoryId);
706
706
  }
707
707
  }
708
+ async deleteAllContents(repositoryId, _onProgress) {
709
+ await this.assertRepository(repositoryId);
710
+ const pool = this.getPool();
711
+ const relResult = await pool.request().input("id", import_mssql.default.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_relationships")} WHERE [repository_id] = @id`);
712
+ const entityResult = await pool.request().input("id", import_mssql.default.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_entities")} WHERE [repository_id] = @id`);
713
+ return {
714
+ deletedEntities: entityResult.rowsAffected[0] ?? 0,
715
+ deletedRelationships: relResult.rowsAffected[0] ?? 0
716
+ };
717
+ }
708
718
  async getRepositoryStats(repositoryId) {
709
719
  await this.assertRepository(repositoryId);
710
720
  const pool = this.getPool();
@@ -1148,9 +1158,9 @@ var SqlServerStorageProvider = class {
1148
1158
  return { deletedRelationships: result.rowsAffected[0] ?? 0 };
1149
1159
  }
1150
1160
  // ─── Graph Traversal ────────────────────────────────────────────
1151
- async exploreNeighbourhood(repositoryId, entityId, options) {
1152
- const centre = await this.getEntityLight(repositoryId, entityId);
1153
- if (!centre) {
1161
+ async exploreNeighborhood(repositoryId, entityId, options) {
1162
+ const center = await this.getEntityLight(repositoryId, entityId);
1163
+ if (!center) {
1154
1164
  throw new import_deep_memory.EntityNotFoundError(entityId);
1155
1165
  }
1156
1166
  const layers = [];
@@ -1212,7 +1222,7 @@ var SqlServerStorageProvider = class {
1212
1222
  currentFrontier = nextFrontier;
1213
1223
  if (nextFrontier.size === 0) break;
1214
1224
  }
1215
- return { centreId: entityId, layers };
1225
+ return { centerId: entityId, layers };
1216
1226
  }
1217
1227
  async findPaths(repositoryId, sourceId, targetId, options) {
1218
1228
  const [source, target] = await Promise.all([
@@ -1394,7 +1404,7 @@ var SqlServerStorageProvider = class {
1394
1404
  }
1395
1405
  }
1396
1406
  }
1397
- async importBulk(repositoryId, data) {
1407
+ async importBulk(repositoryId, data, _options) {
1398
1408
  await this.assertRepository(repositoryId);
1399
1409
  const pool = this.getPool();
1400
1410
  let entitiesImported = 0;
@@ -1594,7 +1604,7 @@ var SqlServerStorageProvider = class {
1594
1604
  // src/SqlServerSearchProvider.ts
1595
1605
  var import_mssql2 = __toESM(require("mssql"), 1);
1596
1606
  var import_deep_memory2 = require("@utaba/deep-memory");
1597
- function normaliseRank(rank) {
1607
+ function normalizeRank(rank) {
1598
1608
  return Math.min(1, Math.max(0, rank / 1e3));
1599
1609
  }
1600
1610
  function buildHighlights(query, row) {
@@ -1694,7 +1704,7 @@ var SqlServerSearchProvider = class {
1694
1704
  const total = rows.length > 0 ? rows[0]["total_count"] : 0;
1695
1705
  const items = rows.map((row) => ({
1696
1706
  id: row["entity_id"],
1697
- score: normaliseRank(row["ft_rank"]),
1707
+ score: normalizeRank(row["ft_rank"]),
1698
1708
  highlights: buildHighlights(query, row)
1699
1709
  }));
1700
1710
  return {