@utaba/deep-memory-storage-sqlserver 0.2.0 → 0.3.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.d.cts CHANGED
@@ -1,6 +1,7 @@
1
+ import * as _utaba_deep_memory_types from '@utaba/deep-memory/types';
2
+ import { StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
1
3
  import sql from 'mssql';
2
4
  import { StorageProvider, EnsureSchemaResult, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
3
- import { StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
4
5
 
5
6
  /** Configuration for SqlServerStorageProvider */
6
7
  interface SqlServerStorageProviderConfig {
@@ -32,7 +33,11 @@ declare class SqlServerStorageProvider implements StorageProvider {
32
33
  getRepository(repositoryId: string): Promise<StoredRepository | null>;
33
34
  listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<StoredRepositorySummary>>;
34
35
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
35
- deleteRepository(repositoryId: string): Promise<void>;
36
+ deleteRepository(repositoryId: string, _onProgress?: _utaba_deep_memory_types.DeleteProgressCallback): Promise<void>;
37
+ deleteAllContents(repositoryId: string, _onProgress?: _utaba_deep_memory_types.DeleteProgressCallback): Promise<{
38
+ deletedEntities: number;
39
+ deletedRelationships: number;
40
+ }>;
36
41
  getRepositoryStats(repositoryId: string): Promise<RepositoryStats>;
37
42
  getVocabulary(repositoryId: string): Promise<MemoryVocabulary>;
38
43
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
@@ -64,7 +69,7 @@ declare class SqlServerStorageProvider implements StorageProvider {
64
69
  findPaths(repositoryId: string, sourceId: string, targetId: string, options: StoragePathOptions): Promise<StoragePathResult>;
65
70
  getTimeline(repositoryId: string, entityId: string, options: StorageTimelineOptions): Promise<StorageTimelineResult>;
66
71
  exportAll(repositoryId: string): AsyncIterable<ExportChunk>;
67
- importBulk(repositoryId: string, data: ImportChunk[]): Promise<BulkImportResult>;
72
+ importBulk(repositoryId: string, data: ImportChunk[], _options?: _utaba_deep_memory_types.BulkImportOptions): Promise<BulkImportResult>;
68
73
  /** Creates a TVP table from an array of string IDs (eliminates plan cache bloat from IN clauses). */
69
74
  private createIdListTvp;
70
75
  /** Returns a StoredEntity without the embedding column (lighter I/O). */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import * as _utaba_deep_memory_types from '@utaba/deep-memory/types';
2
+ import { StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
1
3
  import sql from 'mssql';
2
4
  import { StorageProvider, EnsureSchemaResult, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
3
- import { StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
4
5
 
5
6
  /** Configuration for SqlServerStorageProvider */
6
7
  interface SqlServerStorageProviderConfig {
@@ -32,7 +33,11 @@ declare class SqlServerStorageProvider implements StorageProvider {
32
33
  getRepository(repositoryId: string): Promise<StoredRepository | null>;
33
34
  listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<StoredRepositorySummary>>;
34
35
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
35
- deleteRepository(repositoryId: string): Promise<void>;
36
+ deleteRepository(repositoryId: string, _onProgress?: _utaba_deep_memory_types.DeleteProgressCallback): Promise<void>;
37
+ deleteAllContents(repositoryId: string, _onProgress?: _utaba_deep_memory_types.DeleteProgressCallback): Promise<{
38
+ deletedEntities: number;
39
+ deletedRelationships: number;
40
+ }>;
36
41
  getRepositoryStats(repositoryId: string): Promise<RepositoryStats>;
37
42
  getVocabulary(repositoryId: string): Promise<MemoryVocabulary>;
38
43
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
@@ -64,7 +69,7 @@ declare class SqlServerStorageProvider implements StorageProvider {
64
69
  findPaths(repositoryId: string, sourceId: string, targetId: string, options: StoragePathOptions): Promise<StoragePathResult>;
65
70
  getTimeline(repositoryId: string, entityId: string, options: StorageTimelineOptions): Promise<StorageTimelineResult>;
66
71
  exportAll(repositoryId: string): AsyncIterable<ExportChunk>;
67
- importBulk(repositoryId: string, data: ImportChunk[]): Promise<BulkImportResult>;
72
+ importBulk(repositoryId: string, data: ImportChunk[], _options?: _utaba_deep_memory_types.BulkImportOptions): Promise<BulkImportResult>;
68
73
  /** Creates a TVP table from an array of string IDs (eliminates plan cache bloat from IN clauses). */
69
74
  private createIdListTvp;
70
75
  /** Returns a StoredEntity without the embedding column (lighter I/O). */
package/dist/index.js CHANGED
@@ -667,13 +667,23 @@ var SqlServerStorageProvider = class {
667
667
  if (!updated) throw new RepositoryNotFoundError(repositoryId);
668
668
  return updated;
669
669
  }
670
- async deleteRepository(repositoryId) {
670
+ async deleteRepository(repositoryId, _onProgress) {
671
671
  const pool = this.getPool();
672
672
  const result = await pool.request().input("id", sql.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_repositories")} WHERE [repository_id] = @id`);
673
673
  if (result.rowsAffected[0] === 0) {
674
674
  throw new RepositoryNotFoundError(repositoryId);
675
675
  }
676
676
  }
677
+ async deleteAllContents(repositoryId, _onProgress) {
678
+ await this.assertRepository(repositoryId);
679
+ const pool = this.getPool();
680
+ const relResult = await pool.request().input("id", sql.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_relationships")} WHERE [repository_id] = @id`);
681
+ const entityResult = await pool.request().input("id", sql.UniqueIdentifier, repositoryId).query(`DELETE FROM ${this.t("dm_entities")} WHERE [repository_id] = @id`);
682
+ return {
683
+ deletedEntities: entityResult.rowsAffected[0] ?? 0,
684
+ deletedRelationships: relResult.rowsAffected[0] ?? 0
685
+ };
686
+ }
677
687
  async getRepositoryStats(repositoryId) {
678
688
  await this.assertRepository(repositoryId);
679
689
  const pool = this.getPool();
@@ -1363,7 +1373,7 @@ var SqlServerStorageProvider = class {
1363
1373
  }
1364
1374
  }
1365
1375
  }
1366
- async importBulk(repositoryId, data) {
1376
+ async importBulk(repositoryId, data, _options) {
1367
1377
  await this.assertRepository(repositoryId);
1368
1378
  const pool = this.getPool();
1369
1379
  let entitiesImported = 0;